reserve A for non empty set;
reserve a,b,c,x,y,z for Element of A;
reserve o,o9 for Element of LinPreorders A;
reserve o99 for Element of LinOrders A;
reserve A,N for finite non empty set;
reserve a,b,c,d,a9,c9 for Element of A;
reserve i,n,nb,nc for Element of N;
reserve o,oI,oII for Element of LinPreorders A;
reserve p,p9,pI,pII,pI9,pII9 for Element of Funcs(N,LinPreorders A);
reserve f for Function of Funcs(N,LinPreorders A),LinPreorders A;
reserve k,k0 for Nat;

theorem Th14:
  (for p,a,b st for i holds a <_p.i, b holds a <_f.p, b) & (for p,p9,a,b st
  for i holds (a <_p.i, b iff a <_p9.i, b) & (b <_p.i, a iff b <_p9.i, a)
  holds a <_f.p, b iff a <_f.p9, b) & card A >= 3 implies
  ex n st for p,a,b st a <_p.n, b holds a <_f.p, b
proof
  assume that
A1: for p,a,b st for i holds a <_p.i, b holds a <_f.p, b and
A2: for p,p9,a,b st
  for i holds (a <_p.i, b iff a <_p9.i, b) & (b <_p.i, a iff b <_p9.i, a)
  holds a <_f.p, b iff a <_f.p9, b and
A3: card A >= 3;
  defpred extreme[Element of LinPreorders A,Element of A] means
  (for a st a <> $2 holds $2 <_$1, a) or (for a st a <> $2 holds a <_$1, $2);
A4: for p,b st for i holds extreme[p.i,b] holds extreme[f.p,b]
  proof
    assume not thesis;
    then consider p,b such that
A5: ex a st a <> b & a <=_f.p, b and
A6: ex c st c <> b & b <=_f.p, c and
A7: for i holds extreme[p.i,b];
    consider a9 such that
A8: a9 <> b & a9 <=_f.p, b by A5;
    consider c9 such that
A9: b <> c9 & b <=_f.p, c9 by A6;
 ex a,c st a <> b & b <> c & a <> c & a <=_f.p, b & b <=_f.p, c
    proof
      per cases;
      suppose
A10:    a9 <> c9;
        take a9,c9;
        thus thesis by A8,A9,A10;
      end;
      suppose
A11:    a9 = c9;
        consider d such that
A12:    d <> b & d <> a9 by A3,Th2;
        per cases by Th4;
        suppose
A13:      d <=_f.p, b;
          take d,c9;
          thus thesis by A9,A11,A12,A13;
        end;
        suppose
A14:      b <=_f.p, d;
          take a9,d;
          thus thesis by A8,A12,A14;
        end;
      end;
    end;
    then consider a,c such that
A15: a <> b & b <> c and
A16: a <> c and
A17: a <=_f.p, b & b <=_f.p, c;
    defpred P[Element of N,Element of LinPreorders A] means
    (a <_p.$1, b iff a <_$2, b) & (b <_p.$1, a iff b <_$2, a) &
    (b <_p.$1, c iff b <_$2, c) & (c <_p.$1, b iff c <_$2, b) & c <_$2, a;
A18: for i holds ex o st P[i,o]
    proof
      let i;
      per cases by A7;
      suppose
    for c st c <> b holds b <_p.i, c;
then A19:    b <_p.i, a & b <_p.i, c by A15;
        consider o such that
A20:    b <_o, c & c <_o, a by A15,A16,Th7;
        take o;
        thus thesis by A19,A20,Th4,Th5;
      end;
      suppose
    for a st a <> b holds a <_p.i, b;
then A21:    a <_p.i, b & c <_p.i, b by A15;
        consider o such that
A22:    c <_o, a & a <_o, b by A15,A16,Th7;
        take o;
        thus thesis by A21,A22,Th4,Th5;
      end;
    end;
    consider p9 being Function of N,LinPreorders A such that
A23: for i holds P[i,p9.i] from FUNCT_2:sch 3(A18);
    reconsider p9 as Element of Funcs(N,LinPreorders A) by FUNCT_2:8;
 a <=_f.p9, b & b <=_f.p9, c by A2,A17,A23;
then  a <=_f.p9, c by Th5;
    hence contradiction by A1,A23;
  end;
A24: for b holds ex nb,pI,pII st (for i st i <> nb holds pI.i = pII.i) &
  (for i holds extreme[pI.i,b]) & (for i holds extreme[pII.i,b]) &
  (for a st a <> b holds b <_pI.nb, a) &
  (for a st a <> b holds a <_pII.nb, b) &
  (for a st a <> b holds b <_f.pI, a) & for a st a <> b holds a <_f.pII, b
  proof
    consider t being FinSequence such that
A25: rng t = N and
A26: t is one-to-one by FINSEQ_4:58;
    reconsider t as FinSequence of N by A25,FINSEQ_1:def 4;
    let b;
    consider oI such that
A27: for a st a <> b holds b <_oI, a by Th8;
    consider oII such that
A28: for a st a <> b holds a <_oII, b by Th9;
A29: for k0 holds ex p st (for k st k in dom t & k < k0 holds p.(t.k) = oII) &
    for k st k in dom t & k >= k0 holds p.(t.k) = oI
    proof
      let k0;
      defpred P[Element of N,Element of LinPreorders A] means
      ex k st k in dom t & $1 = t.k &
      (k < k0 implies $2 = oII) & (k >= k0 implies $2 = oI);
A30:  for i holds ex o st P[i,o]
      proof
        let i;
        consider k being object such that
A31:    k in dom t and
A32:    i = t.k by A25,FUNCT_1:def 3;
        reconsider k as Nat by A31;
        per cases;
        suppose
A33:      k < k0;
          take oII;
          thus thesis by A31,A32,A33;
        end;
        suppose
A34:      k >= k0;
          take oI;
          thus thesis by A31,A32,A34;
        end;
      end;
      consider p being Function of N,LinPreorders A such that
A35:  for i holds P[i,p.i] from FUNCT_2:sch 3(A30);
      reconsider p as Element of Funcs(N,LinPreorders A) by FUNCT_2:8;
      take p;
      thus for k st k in dom t & k < k0 holds p.(t.k) = oII
      proof
        let k;
        assume that
A36:    k in dom t and
A37:    k < k0;
        reconsider i = t.k as Element of N by A36,PARTFUN1:4;
    P[i,p.i] by A35;
        hence thesis by A26,A36,A37,FUNCT_1:def 4;
      end;
      let k;
      assume that
A38:  k in dom t and
A39:  k >= k0;
      reconsider i = t.k as Element of N by A38,PARTFUN1:4;
  P[i,p.i] by A35;
      hence thesis by A26,A38,A39,FUNCT_1:def 4;
    end;
    defpred Q[Nat] means for p st
    (for k st k in dom t & k < $1 holds p.(t.k) = oII) &
    (for k st k in dom t & k >= $1 holds p.(t.k) = oI)
    holds for a st a <> b holds a <_f.p, b;
    reconsider kII9 = len t + 1 as Element of NAT by ORDINAL1:def 12;
A40: Q[kII9]
    proof
      let p;
      assume that
A41:  for k st k in dom t & k < kII9 holds p.(t.k) = oII
      and for k st k in dom t & k >= kII9 holds p.(t.k) = oI;
      let a;
      assume
A42:  a <> b;
  for i holds a <_p.i, b
      proof
        let i;
        consider k being object such that
A43:    k in dom t and
A44:    i = t.k by A25,FUNCT_1:def 3;
        reconsider k as Nat by A43;
    k <= len t by A43,FINSEQ_3:25;
then     k + 0 < kII9 by XREAL_1:8;
then     p.i = oII by A41,A43,A44;
        hence thesis by A28,A42;
      end;
      hence thesis by A1;
    end;
then A45: ex kII9 being Nat st Q[kII9];
    consider kII being Nat such that
A46: Q[kII] & for k0 being Nat st Q[k0] holds k0 >= kII from NAT_1:sch 5(A45
    );
    consider pII such that
A47: for k st k in dom t & k < kII holds pII.(t.k) = oII and
A48: for k st k in dom t & k >= kII holds pII.(t.k) = oI by A29;
A49: kII > 1
    proof
      assume
A50:  kII <= 1;
      consider a such that
A51:  a <> b by A3,Th1,XXREAL_0:2;
A52:  for i holds b <_pII.i, a
      proof
        let i;
        consider k being object such that
A53:    k in dom t and
A54:    i = t.k by A25,FUNCT_1:def 3;
        reconsider k as Nat by A53;
    k >= 1 by A53,FINSEQ_3:25;
then     pII.i = oI by A48,A50,A53,A54,XXREAL_0:2;
        hence thesis by A27,A51;
      end;
A55:  a <_f.pII, b by A46,A47,A48,A51;
  b <_f.pII, a by A1,A52;
      hence contradiction by A55,Th4;
    end;
    then reconsider kI = kII - 1 as Nat by NAT_1:20;
    reconsider kI as Element of NAT by ORDINAL1:def 12;
A56: kII = kI + 1;
 kI > 1 - 1 by A49,XREAL_1:9;
then A57: kI >= 0 + 1 by INT_1:7;
 kII <= kII9 by A40,A46;
then  kI <= kII9 - 1 by XREAL_1:9;
then A58: kI in dom t by A57,FINSEQ_3:25;
    then reconsider nb = t.kI as Element of N by PARTFUN1:4;
A59: kI + 0 < kII by A56,XREAL_1:8;
    then consider pI such that
A60: for k st k in dom t & k < kI holds pI.(t.k) = oII and
A61: for k st k in dom t & k >= kI holds pI.(t.k) = oI and
A62: not(for a st a <> b holds a <_f.pI, b) by A46;
    take nb,pI,pII;
    thus for i st i <> nb holds pI.i = pII.i
    proof
      let i;
      assume
A63:  i <> nb;
      consider k being object such that
A64:  k in dom t and
A65:  i = t.k by A25,FUNCT_1:def 3;
      reconsider k as Nat by A64;
      per cases by A63,A65,XXREAL_0:1;
      suppose
    k < kI;
then     k + 0 < kII & pI.i = oII by A56,A60,A64,A65,XREAL_1:8;
        hence thesis by A47,A64,A65;
      end;
      suppose
    k > kI;
then     k >= kII & pI.i = oI by A56,A61,A64,A65,INT_1:7;
        hence thesis by A48,A64,A65;
      end;
    end;
    thus
A66: for i holds extreme[pI.i,b]
    proof
      let i;
  ex k being object st k in dom t & i = t.k by A25,FUNCT_1:def 3;
then   pI.i = oII or pI.i = oI by A60,A61;
      hence thesis by A27,A28;
    end;
    thus for i holds extreme[pII.i,b]
    proof
      let i;
  ex k being object st k in dom t & i = t.k by A25,FUNCT_1:def 3;
then   pII.i = oII or pII.i = oI by A47,A48;
      hence thesis by A27,A28;
    end;
 pI.nb = oI by A58,A61;
    hence for a st a <> b holds b <_pI.nb, a by A27;
 pII.nb = oII by A47,A58,A59;
    hence for a st a <> b holds a <_pII.nb, b by A28;
    thus for a st a <> b holds b <_f.pI, a by A4,A62,A66;
    thus thesis by A46,A47,A48;
  end;
A67: for b holds ex nb,pI,pII st (for i st i <> nb holds pI.i = pII.i) &
  (for i holds extreme[pI.i,b]) &
  (for a st a <> b holds b <_f.pI, a) & (for a st a <> b holds a <_f.pII, b) &
  for p,a,c st a <> b & c <> b & a <_p.nb, c holds a <_f.p, c
  proof
    let b;
    consider nb,pI,pII such that
A68: for i st i <> nb holds pI.i = pII.i and
A69: for i holds extreme[pI.i,b] and
A70: for i holds extreme[pII.i,b] and
A71: for a st a <> b holds b <_pI.nb, a and
A72: for a st a <> b holds a <_pII.nb, b and
    A73: (
 for a st a <> b holds b <_f.pI, a)& for a st a <> b holds a <_f.pII, b
    by A24;
    take nb,pI,pII;
    thus (for i st i <> nb holds pI.i = pII.i) &
    (for i holds extreme[pI.i,b]) &
    (for a st a <> b holds b <_f.pI, a) & for a st a <> b holds a <_f.pII, b
    by A68,A69,A73;
    let p,a,c;
    assume that
A74: a <> b and
A75: c <> b and
A76: a <_p.nb, c;
A77: a <> c by A76,Th3;
    defpred P[Element of N,Element of LinPreorders A] means
    (a <_p.$1, c iff a <_$2, c) & (c <_p.$1, a iff c <_$2, a) &
    ($1 = nb implies a <_$2, b & b <_$2, c) & ($1 <> nb implies
    ((for d st d <> b holds b <_pII.$1, d) implies b <_$2, a & b <_$2, c) &
    ((for d st d <> b holds d <_pII.$1, b) implies a <_$2, b & c <_$2, b));
A78: for i holds ex o st P[i,o]
    proof
      let i;
      per cases;
      suppose
A79:   i = nb;
        consider o such that
A80:   a <_o, b & b <_o, c by A74,A75,A77,Th7;
        take o;
        thus thesis by A76,A79,A80,Th4,Th5;
      end;
      suppose
A81:   i <> nb;
        per cases by A70;
        suppose
     for d st d <> b holds b <_pII.i, d;
then      b <_pII.i, a by A74;
then A82:     not a <_pII.i, b by Th4;
          consider o such that
          A83:     b
 <_o, a & b <_o, c & ( a <_o, c iff a <_p.i, c)&( c <_o, a iff c <_p.i,
          a)
          by A74,A75,Th10;
          take o;
          thus thesis by A74,A81,A82,A83;
        end;
        suppose
     for d st d <> b holds d <_pII.i, b;
then      a <_pII.i, b by A74;
then A84:     not b <_pII.i, a by Th4;
          consider o such that
          A85:     a
 <_o, b & c <_o, b & ( a <_o, c iff a <_p.i, c)&( c <_o, a iff c <_p.i,
          a)
          by A74,A75,Th11;
          take o;
          thus thesis by A74,A81,A84,A85;
        end;
      end;
    end;
    consider pIII being Function of N,LinPreorders A such that
A86: for i holds P[i,pIII.i] from FUNCT_2:sch 3(A78);
    reconsider pIII as Element of Funcs(N,LinPreorders A) by FUNCT_2:8;
 for i holds (a <_pII.i, b iff a <_pIII.i, b) &
    (b <_pII.i, a iff b <_pIII.i, a)
    proof
      let i;
      per cases;
      suppose
   i = nb;
then    a <_pII.i, b & a <_pIII.i, b by A72,A74,A86;
        hence thesis by Th4;
      end;
      suppose
A87:   i <> nb;
        per cases by A70;
        suppose
     for d st d <> b holds b <_pII.i, d;
then      b <_pII.i, a & b <_pIII.i, a by A74,A86,A87;
          hence thesis by Th4;
        end;
        suppose
     for d st d <> b holds d <_pII.i, b;
then      a <_pII.i, b & a <_pIII.i, b by A74,A86,A87;
          hence thesis by Th4;
        end;
      end;
    end;
then A88: a <_f.pII, b iff a <_f.pIII, b by A2;
     for
 i holds (b <_pI.i, c iff b <_pIII.i, c) & (c <_pI.i, b iff c <_pIII.i, b )
    proof
      let i;
      per cases;
      suppose
   i = nb;
then    b <_pI.i, c & b <_pIII.i, c by A71,A75,A86;
        hence thesis by Th4;
      end;
      suppose
A89:   i <> nb;
        per cases by A70;
        suppose
A90:     for d st d <> b holds b <_pII.i, d;
then      b <_pII.i, c by A75;
then A91:     b <_pI.i, c by A68,A89;
     b <_pIII.i, c by A86,A89,A90;
          hence thesis by A91,Th4;
        end;
        suppose
A92:     for d st d <> b holds d <_pII.i, b;
then      c <_pII.i, b by A75;
then A93:     c <_pI.i, b by A68,A89;
     c <_pIII.i, b by A86,A89,A92;
          hence thesis by A93,Th4;
        end;
      end;
    end;
then  b <_f.pI, c iff b <_f.pIII, c by A2;
then  a <_f.pIII, c by A73,A74,A88,Th5;
    hence thesis by A2,A86;
  end;
  set b = the Element of A;
  consider nb,pI,pII such that
A94: for i st i <> nb holds pI.i = pII.i and
A95: for i holds extreme[pI.i,b] and
  A96: (
 for a st a <> b holds b <_f.pI, a)& for a st a <> b holds a <_f.pII, b and
A97: for p,a,c st a <> b & c <> b & a <_p.nb, c holds a <_f.p, c by A67;
  take nb;
  let p,a,a9;
  assume
A98: a <_p.nb, a9;
then A99: a <> a9 by Th4;
  per cases;
  suppose
 a <> b & a9 <> b;
    hence thesis by A97,A98;
  end;
  suppose
A100: a = b or a9 = b;
    consider c such that
A101: c <> a & c <> a9 by A3,Th2;
    consider nc,pI9,pII9 such that
    for i st i <> nc holds pI9.i = pII9.i and
    for i holds extreme[pI9.i,c] and
    for a st a <> c holds c <_f.pI9, a and
    for a st a <> c holds a <_f.pII9, c and
A102: for p,a,a9 st a <> c & a9 <> c & a <_p.nc, a9 holds a <_f.p, a9 by A67;
 nc = nb
    proof
      per cases by A100;
      suppose
A103:   a = b;
        assume
A104:   nc <> nb;
   b <_pI.nc, a9 or a9 <_pI.nc, b by A95,A99,A103;
then    b <_pII.nc, a9 & a9 <_f.pII, b or
        a9 <_pI.nc, b & b <_f.pI, a9 by A94,A96,A99,A103,A104;
then    b <_pII.nc, a9 & a9 <=_f.pII, b or
        a9 <_pI.nc, b & b <=_f.pI, a9 by Th4;
        hence contradiction by A101,A102,A103;
      end;
      suppose
A105:   a9 = b;
        assume
A106:   nc <> nb;
   b <_pI.nc, a or a <_pI.nc, b by A95,A99,A105;
then    b <_pII.nc, a & a <_f.pII, b or
        a <_pI.nc, b & b <_f.pI, a by A94,A96,A99,A105,A106;
then    b <_pII.nc, a & a <=_f.pII, b or
        a <_pI.nc, b & b <=_f.pI, a by Th4;
        hence contradiction by A101,A102,A105;
      end;
    end;
    hence thesis by A98,A101,A102;
  end;
end;
