
theorem  Th31: ::  AdjCol:
for R being with_finite_chromatic# RelStr,
    C being finite Coloring of R, c being set
 st c in C & card C = chromatic# R
  ex v being Element of R st v in c &
   for d being Element of C st d <> c
    ex w being Element of R st w in Adjacent(v) & w in d
proof
 let R be with_finite_chromatic# RelStr,
     C be finite Coloring of R, c be set such that
A1: c in C and
A2: card C = chromatic# R;
   assume
A3: not thesis;
   set cR = the carrier of R;
A4: union C = cR by EQREL_1:def 4;
   reconsider c as Subset of cR by A1;
A5: c <> {} by A1;
   set Cc = C\{c};
A6: c in {c} by TARSKI:def 1;
   per cases;
   suppose A7: Cc is empty;
     consider v being object such that
   A8: v in c by A5,XBOOLE_0:def 1;
     reconsider v as Element of R by A8;
     consider d being Element of C such that
   A9: d <> c and for w being Element of R
                        holds not (w in Adjacent(v) & w in d) by A8,A3;
     0 = card C - card{c} by A1,A7,CARD_1:27,EULER_1:4;
     then 0+1 = card C - 1 +1 by CARD_1:30;
     then consider x being object such that
   A10: C = {x} by CARD_2:42;
      c = x & d = x by A1,A10,TARSKI:def 1;
     hence thesis by A9;
   end;
   suppose Cc is non empty;
     then reconsider Cc as non empty set;
   defpred P[object, object] means
    ex D2 being set st D2 = $2 &
   for vv being Element of cR st $1 = vv
    holds $2 <> c & $2 in C &
    for w being Element of R holds not (w in Adjacent(vv) & w in D2);
A11: for e being object st e in c ex u being object st P[e,u]
proof
      let v be object such that
    A12: v in c;
        reconsider vv = v as Element of cR by A12;
        consider d being Element of C such that
    A13: d <> c and
    A14: for w being Element of R
         holds not (w in Adjacent(vv) & w in d) by A12,A3;
         take d,d;
         thus thesis by A13,A14,A1;
    end;
   consider r being Function such that
A15: dom r = c and
A16: for e being object st e in c holds P[e,r.e] from CLASSES1:sch 1(A11);
   deffunc DF(set) = $1 \/ r"{$1};
   reconsider Cc as finite non empty set;
   set D = { DF(d) where d is Element of Cc : P[d] };
   consider d being object such that
A17: d in Cc by XBOOLE_0:def 1;
   reconsider d as set by TARSKI:1;
A18: d \/ r"{d} in D by A17;
A19: D c= bool cR proof
    let x be object;
    reconsider xx=x as set by TARSKI:1;
    assume x in D;
      then consider d being Element of Cc such that
    A20: x = d \/ r"{d};
    A21: r"{d} c= c by A15,RELAT_1:132;
    A22: r"{d} c= cR by A21,XBOOLE_1:1;
        d in C by XBOOLE_0:def 5;
        then xx c= cR by A20,A22,XBOOLE_1:8;
     hence x in bool cR;
   end;
A23: union D = cR proof
     thus union D c= cR proof
       let x be object;
       assume x in union D;
        then consider Y being set such that
     A24: x in Y and
     A25: Y in D by TARSKI:def 4;
        thus x in cR by A24,A25,A19;
     end;
     thus cR c= union D proof
       let x be object;
       assume A26: x in cR;
       then consider d being set such that
     A27: x in d and
     A28: d in C by A4,TARSKI:def 4;
         reconsider xp1 = x as Element of cR by A26;
       per cases;
       suppose A29: d = c;
         then
A30:        P[xp1,r.xp1] by A27,A16;
         then r.xp1 <> c;
         then A31: not r.xp1 in {c} by TARSKI:def 1;
           r.xp1 in C by A30; then
         A32: r.xp1 in Cc by A31,XBOOLE_0:def 5;
           r.xp1 in {r.xp1} by TARSKI:def 1;
           then x in r"{r.xp1} by A27,A29,A15,FUNCT_1:def 7;
           then A33: x in r.xp1 \/ r"{r.xp1} by XBOOLE_0:def 3;
           r.xp1 \/ r"{r.xp1} in D by A32;
         hence x in union D by A33,TARSKI:def 4;
       end;
       suppose d <> c;
         then not d in {c} by TARSKI:def 1;
         then d in Cc by A28,XBOOLE_0:def 5;
         then A34: d \/ r"{d} in D;
           x in d \/ r"{d} by A27,XBOOLE_0:def 3;
         hence x in union D by A34,TARSKI:def 4;
       end;
     end;
   end;
A35: for A being Subset of cR st A in D holds A <> {} &
    for B being Subset of cR st B in D holds A = B or A misses B proof
     let A be Subset of cR;
     assume A in D;
       then consider da being Element of Cc such that
     A36: A = da \/ r"{da};
     A37: da in C by XBOOLE_0:def 5;
       then da is non empty;
     hence A <> {} by A36;
     let B be Subset of cR;
     assume B in D;
       then consider db being Element of Cc such that
     A38: B = db \/ r"{db};
     A39: db in C by XBOOLE_0:def 5;
     per cases;
     suppose da = db;
      hence A = B or A misses B by A36,A38;
     end;
     suppose A40: da <> db;
       then A41: da misses db by A37,A39,EQREL_1:def 4;
       A42: r"{da} misses r"{db} by A40,FUNCT_1:71,ZFMISC_1:11;
      assume A <> B;
      assume A meets B;
        then consider x being object such that
      A43: x in A and
      A44: x in B by XBOOLE_0:3;
      per cases by A43,A44,A36,A38,XBOOLE_0:def 3;
      suppose x in da & x in db;
        hence contradiction by A41,XBOOLE_0:3;
      end;
      suppose that A45: x in da and A46: x in r"{db};
      A47: da <> c by A6,XBOOLE_0:def 5;
        r"{db} c= c by A15,RELAT_1:132;
        then da meets c by A45,A46,XBOOLE_0:3;
        hence contradiction by A47,A37,A1,EQREL_1:def 4;
      end;
      suppose that A48: x in r"{da} and A49: x in db;
      A50: db <> c by A6,XBOOLE_0:def 5;
        r"{da} c= c by A15,RELAT_1:132;
        then db meets c by A48,A49,XBOOLE_0:3;
        hence contradiction by A50,A39,A1,EQREL_1:def 4;
      end;
      suppose x in r"{da} & x in r"{db};
        hence contradiction by A42,XBOOLE_0:3;
      end;
     end;
   end;
   reconsider D as a_partition of cR by A19,A23,A35,EQREL_1:def 4;
   now
     let x be set;
     assume A51: x in D;
     then reconsider S = x as Subset of R;
       consider d being Element of Cc such that
   A52: x = d \/ r"{d} by A51;
   A53: r"{d} c= c by A15,RELAT_1:132;
   A54: d in C by XBOOLE_0:def 5;
   A55: d is StableSet of R by A54,DILWORTH:def 12;
   A56: c is StableSet of R by A1,DILWORTH:def 12;
     S is stable proof
       let a, b be Element of R such that
     A57: a in S and
     A58: b in S and
     A59: a <> b;
       per cases by A57,A58,A52,XBOOLE_0:def 3;
       suppose a in d & b in d;
         hence not a <= b & not b <= a by A55,A59,DILWORTH:def 2;
       end;
       suppose that A60: a in d and A61: b in r"{d};
             r.b in {d} by A61,FUNCT_1:def 7;
             then
A62:          r.b = d by TARSKI:def 1;
             P[b,r.b] by A53,A61,A16;
             then not a in Adjacent(b) by A60,A62;
             then not a < b & not b < a by Def6;
         hence not a <= b & not b <= a by A59,ORDERS_2:def 6;
       end;
       suppose that A63: a in r"{d} and A64: b in d;
             r.a in {d} by A63,FUNCT_1:def 7;
             then
A65:           r.a = d by TARSKI:def 1;
             P[a,r.a] by A53,A63,A16;
             then not b in Adjacent(a) by A64,A65;
             then not a < b & not b < a by Def6;
         hence not a <= b & not b <= a by A59,ORDERS_2:def 6;
       end;
       suppose a in r"{d} & b in r"{d};
         hence not a <= b & not b <= a by A53,A56,A59,DILWORTH:def 2;
       end;
     end;
     hence x is StableSet of R;
   end;
   then reconsider D as Coloring of R by DILWORTH:def 12;
   card Cc = card C - card{c} by A1,EULER_1:4;
   then card Cc + 1 = card C -1+1 by CARD_1:30;
   then A66: card Cc < card C by NAT_1:13;

   deffunc FS(set) = $1 \/ r"{$1};
   consider s being Function such that
A67: dom s = Cc and
A68: for x being set st x in Cc holds s.x = FS(x) from FUNCT_1:sch 5;
A69:  rng s c= D proof
      let y be object;
      assume y in rng s;
      then consider d being object such that
    A70: d in dom s and
    A71: y = s.d by FUNCT_1:def 3;
     reconsider d as set by TARSKI:1;
        y = d \/ r"{d} by A67,A68,A70,A71;
      hence y in D by A70,A67;
    end;
   then reconsider s as Function of Cc, D by A67,FUNCT_2:2;
A72: s is one-to-one proof
      let x1, x2 be object such that
    A73: x1 in dom s and
    A74: x2 in dom s and
    A75: s.x1 = s.x2;
     reconsider x1,x2 as set by TARSKI:1;
    A76: s.x1 = x1 \/ r"{x1} by A73,A68;
    A77: s.x2 = x2 \/ r"{x2} by A74,A68;
A78:    x1 c= x2 proof
          let x be object;
          assume A79: x in x1;
            then A80: x in s.x1 by A76,XBOOLE_0:def 3;
          per cases by A80,A75,A77,XBOOLE_0:def 3;
          suppose x in x2;
            hence thesis;
          end;
          suppose A81: x in r"{x2};
            A82: r"{x2} c= dom r by RELAT_1:132;
            A83: x1 in C by A73,XBOOLE_0:def 5;
            then reconsider x1 as Subset of cR;
            x1 meets c by A82,A81,A15,A79,XBOOLE_0:3;
            then x1 = c by A83,A1,EQREL_1:def 4;
          hence thesis by A6,A73,XBOOLE_0:def 5;
          end;
        end;
         x2 c= x1 proof
          let x be object;
          assume A84: x in x2;
            then A85: x in s.x2 by A77,XBOOLE_0:def 3;
          per cases by A85,A75,A76,XBOOLE_0:def 3;
          suppose x in x1;
            hence thesis;
          end;
          suppose A86: x in r"{x1};
            A87:  r"{x1} c= dom r by RELAT_1:132;
          A88: x2 in C by A74,XBOOLE_0:def 5;
            then reconsider x2 as Subset of cR;
            x2 meets c by A87,A86,A15,A84,XBOOLE_0:3;
            then x2 = c by A88,A1,EQREL_1:def 4;
          hence thesis by A6,A74,XBOOLE_0:def 5;
          end;
        end;
     hence thesis by A78,XBOOLE_0:def 10;
    end;
    D c= rng s proof
     let x be object;
     assume x in D;
     then consider d being Element of Cc such that
    A89: x = d \/ r"{d};
        s.d = d \/ r"{d} by A68;
     hence x in rng s by A89,A67,FUNCT_1:def 3;
    end;
    then D = rng s by A69;
    then s is onto by FUNCT_2:def 3;
   then A90: card Cc = card D by A72,A18,EULER_1:11;
   then D is finite;
  hence contradiction by A66,A90,A2,Def3;
 end;
end;
