
theorem Th51:  ::  Dilworth: Finite case
for R being finite antisymmetric transitive RelStr
 ex C being Clique-partition of R st card(C) = stability# R
proof
  defpred P[Nat] means
  for P being finite antisymmetric transitive RelStr
   st card(P) = $1 ex C being Clique-partition of P st card(C) = stability# P;
A1: for n being Nat st for k being Nat st k < n holds P[k] holds P[n] proof
     let n be Nat; assume
   A2: for k being Nat st k < n holds P[k];
       let P be finite antisymmetric transitive RelStr; assume
   A3: card(P) = n;
       set wP = stability# P;
     per cases;
     suppose A4: n = 0;
      then P is empty by A3;
      then reconsider C = {} as Clique-partition of P by EQREL_1:45;
      take C;
        P is empty by A3,A4;
      hence card(C) = stability# P;
     end;
     suppose A5: n > 0;
  per cases;
  suppose ex A being StableSet of P st card(A) = stability# P &
                 A <> minimals(P) & A <> maximals(P);
      then consider A being StableSet of P such that
  A6: card A = stability# P and
  A7: A <> minimals(P) and
  A8: A <> maximals(P);
       set aA = Upper A, bA = Lower A;
       set cP = the carrier of P, Pa = subrelstr aA, Pb = subrelstr bA;
       reconsider PP = P as finite non empty antisymmetric transitive RelStr
        by A5,A3;
  A9: aA = the carrier of Pa by YELLOW_0:def 15;
  A10: bA = the carrier of Pb by YELLOW_0:def 15;
       not minimals PP c= aA by A7,Th40,Th26;
       then consider mi being object such that
  A11:  mi in minimals P and
  A12:  not mi in aA;
       not maximals PP c= bA by A8,Th41,Th27;
       then consider ma being object such that
  A13:  ma in maximals P and
  A14:  not ma in bA;
        reconsider Pa as finite antisymmetric transitive RelStr;
        mi in cP by A11;
        then aA c< cP by A12;
        then card Pa < card P by A9,CARD_2:48;
        then consider Ca being Clique-partition of Pa such that
   A15: card(Ca) = stability# Pa by A2,A3;
   A16: stability# Pa = wP by A6,Th45,XBOOLE_1:7;
        reconsider Pb as finite antisymmetric transitive RelStr;
        ma in cP by A13;
        then bA c< cP by A14;
        then card Pb < card P by A10,CARD_2:48;
        then consider L being Clique-partition of Pb such that
   A17: card(L) = stability# Pb by A2,A3;
    stability# Pb = wP by A6,Th45,XBOOLE_1:7;
      then consider C being Clique-partition of P such that
   A18: card C = stability# PP by A6,A15,A16,A17,Th49;
      take C;
      thus card(C) = stability# P by A18;
  end;
  suppose A19: for A being StableSet of P st card(A) = stability# P
               holds A = minimals(P) or A = maximals(P);
    consider S being StableSet of P such that
  A20: card(S) = stability# P by Def6;
      reconsider PP = P as finite non empty antisymmetric transitive RelStr
        by A5,A3;
      set cR = the carrier of PP;
      set a = the Element of minimals(P);
  A21: a in minimals(PP);
      then reconsider a as Element of PP;
      consider b being Element of PP such that
  A22: b is_maximal_in [#]PP and
  A23: a = b or a < b by Th38;
  A24: b in maximals(P) by A22,Def10;
      set cP = the carrier of P;
      set Cn = {a, b}; set cP9 = cP \ Cn;
  A25: cP = cP9 \/ Cn by XBOOLE_1:45;
  A26: cP9 misses {a,b} by XBOOLE_1:79;
       then A27: cP \ cP9 = {a,b} by A25,XBOOLE_1:88;
      reconsider cP9 as Subset of cR;
      set P9 = subrelstr cP9;
  A28: cP9 = the carrier of P9 by YELLOW_0:def 15;
  A29: card cP9= card P9 by YELLOW_0:def 15;
      card cP9 = card cP - card {a,b} by CARD_2:44;
      then consider C being Clique-partition of P9 such that
  A30: card(C) = stability# P9 by A2,A3,A29,XREAL_1:44;
  A31: not {a,b} in C proof
         assume :: works through typing: Subset-Family -> Subset bool ...
       A32: {a,b} in C;
        a in {a,b} by TARSKI:def 2;
         hence contradiction by A26,A28,A32,ZFMISC_1:49;
       end;
      set wP = stability# PP; set wP1 = wP - 1;
      0+1 <= wP by NAT_1:13;
      then 0+1-1 <= wP-1 by XREAL_1:9;
      then wP1 in NAT by INT_1:3;
      then reconsider wP1 as Nat;
      set S9 = S /\ cP9;
          S /\ cP = S by XBOOLE_1:28;
      then A33: S9 = S \ {a,b} by XBOOLE_1:49;
  A34: {a,b} = {a} \/ {b} by ENUMSET1:1;
      reconsider S9 as StableSet of P9 by Th31;
  A35: card S9 = wP1 proof
        per cases by A19,A20;
        suppose A36: S = minimals(P);
          S9 = S \ {a} proof
           per cases;
           suppose a = b;
             hence S9 = S \ {a} by A33,ENUMSET1:29;
           end;
           suppose A37: a <> b;
             now
               assume b in minimals(PP);
                then b is_minimal_in [#]PP by Def9;
               hence contradiction by A37,A23,WAYBEL_4:56;
             end;
             hence S9 = S \ {a} by A33,A34,A36,Th1;
           end;
          end;
          hence card S9 = card S - card {a} by A36,EULER_1:4
              .= wP1 by A20,CARD_1:30;
        end;
        suppose A38: S = maximals(PP);
         A39: S9 = S \ {b} proof
           per cases;
           suppose a = b;
             hence S9 = S \ {b} by A33,ENUMSET1:29;
           end;
           suppose A40: a <> b;
             now
               assume a in maximals(PP);
                then a is_maximal_in [#]PP by Def10;
               hence contradiction by A40,A23,WAYBEL_4:55;
             end;
             hence S9 = S \ {b} by A33,A34,A38,Th1;
           end;
         end;
         b in S by A38,A22,Def10;
         hence card S9 = card S - card {b} by A39,EULER_1:4
           .= wP1 by A20,CARD_1:30;
        end;
      end;
   for T being StableSet of P9 holds card(T) <= card(S9) proof
        let T be StableSet of P9;
        assume card(T) > card(S9);
        then card T >= card S9 + 1 by NAT_1:13;
        then consider V being StableSet of P9 such that
       A41: card V = card S9 + 1 by Th17;
        V is StableSet of P by Th30;
           then V = minimals(P) or V =maximals(P) by A19,A41,A35;
        hence contradiction by A21,A24,A28,A26,ZFMISC_1:49;
       end;
  then A42: stability# P9 + 1 = wP - 1 + 1 by A35,Def6 .= wP;
      set CC = C \/ {{a,b}};
      cP9 <> cP by A27,XBOOLE_1:37;
      then
A43:     cP9 c< cP;
      now :: Cliques in CC
         let x be set;
         assume A44: x in CC;
         per cases by A44,XBOOLE_0:def 3;
         suppose x in C;
             then x is Clique of P9 by Def11;
           hence x is Clique of P by Th28;
         end;
         suppose x in {{a,b}};
            then A45: x = {a,b} by TARSKI:def 1;
           per cases;
           suppose a = b;
             then x = {a} by A45,ENUMSET1:29;
            hence x is Clique of P;
           end;
           suppose a <> b;
             then a <= b by A23;
            hence x is Clique of P by A45,Th8;
           end;
         end;
      end;
      then reconsider CC as Clique-partition of P by A27,A28,Th4,Def11,A43;
      take CC;
      thus card(CC) = stability# P by A30,A42,A31,CARD_2:41;
  end;
     end;
   end;
A46: for n being Nat holds P[n] from NAT_1:sch 4(A1);
  let R be finite antisymmetric transitive RelStr;
  card R = card R;
  hence thesis by A46;
end;
