
theorem Th49: :: Glueing lemma:
for R being with_finite_stability# antisymmetric transitive non empty RelStr,
    A being StableSet of R,
    U being Clique-partition of subrelstr Upper A,
    L being Clique-partition of subrelstr Lower A
 st card A = stability# R & card U = stability# R & card L = stability# R
  ex C being Clique-partition of R st card C = stability# R
proof
  let R be with_finite_stability# antisymmetric transitive non empty RelStr,
      A be StableSet of R,
      U be Clique-partition of subrelstr Upper A,
      L be Clique-partition of subrelstr Lower A such that
A1: card A = stability# R and
A2: card U = stability# R and
A3: card L = stability# R;
A4: A is non empty by A1;
       set aA = Upper A, bA = Lower A;
       set cR = the carrier of R, Pa = subrelstr aA, Pb = subrelstr bA;
A5: aA = the carrier of Pa by YELLOW_0:def 15;
A6: bA = the carrier of Pb by YELLOW_0:def 15;
    reconsider Pa = subrelstr Upper A as
       with_finite_stability# antisymmetric transitive non empty RelStr by A4;
      A /\ Upper A = A by XBOOLE_1:21;
    then  A is StableSet of Pa by Th31;
     then consider f being Function of A, U such that
A7: f is bijective and
A8: for x being set st x in A holds x in f.x by A1,A2,Th47;
A9: dom f = A by A4,FUNCT_2:def 1;
A10: rng f = U by A7,FUNCT_2:def 3;
    reconsider Pb = subrelstr Lower A as
       with_finite_stability# antisymmetric transitive non empty RelStr by A4;
     A /\ Lower A = A by XBOOLE_1:21;
    then  A is StableSet of Pb by Th31;
    then consider g being Function of A, L such that
A11: g is bijective and
A12: for x being set st x in A holds x in g.x by A1,A3,Th47;
A13: dom g = A by A4,FUNCT_2:def 1;
A14: rng g = L by A11,FUNCT_2:def 3;
    set h = f .\/ g; set C = rng h;
A15: dom h = dom f \/ dom g by LEXBFS:def 2;
A16: C c= bool cR proof
       let x be object;
    reconsider xx=x as set by TARSKI:1;
       assume x in C;
       then consider a being object such that
     A17: a in dom h and
     A18: h.a = x by FUNCT_1:def 3;
     A19: h.a = f.a \/ g.a by A17,A15,LEXBFS:def 2;
         f.a in U by A17,A15,FUNCT_2:5;
         then A20: f.a c= cR by A5,XBOOLE_1:1;
         g.a in L by A17,A15,FUNCT_2:5;
        then g.a c= cR by A6,XBOOLE_1:1;
       then xx c= cR by A18,A19,A20,XBOOLE_1:8;
       hence x in bool cR;
     end;
A21: union C = cR proof
        now let x be object;
         hereby assume x in union C;
           then consider Y being set such that
         A22: x in Y and
         A23: Y in C by TARSKI:def 4;
           consider a being object such that
         A24: a in dom h and
         A25: Y = h.a by A23,FUNCT_1:def 3;
         A26: x in f.a \/ g.a by A24,A25,A22,A15,LEXBFS:def 2;
             per cases by A26,XBOOLE_0:def 3;
             suppose A27: x in f.a;
               f.a in U by A24,A15,FUNCT_2:5;
               then x in aA by A27,A5;
               hence x in cR;
             end;
             suppose A28: x in g.a;
               g.a in L by A24,A15,FUNCT_2:5;
               then x in bA by A28,A6;
               hence x in cR;
             end;
         end;
         assume x in [#]R;
         then A29: x in Upper A \/ Lower A by A1,Th23;
         per cases by A29,XBOOLE_0:def 3;
         suppose x in Upper A;
            then x in union U by A5,EQREL_1:def 4;
            then consider Y being set such that
         A30: x in Y and
         A31: Y in U by TARSKI:def 4;
            consider a being object such that
         A32: a in dom f and
         A33: Y = f.a by A31,A10,FUNCT_1:def 3;
         A34: h.a in rng h by A32,A15,A9,A13,FUNCT_1:3;
             h.a = f.a \/ g.a by A32,A15,A9,A13,LEXBFS:def 2;
             then x in h.a by A30,A33,XBOOLE_0:def 3;
           hence x in union C by A34,TARSKI:def 4;
         end;
         suppose x in Lower A;
            then x in union L by A6,EQREL_1:def 4;
            then consider Y being set such that
         A35: x in Y and
         A36: Y in L by TARSKI:def 4;
            consider a being object such that
         A37: a in dom g and
         A38: Y = g.a by A36,A14,FUNCT_1:def 3;
         A39: h.a in rng h by A37,A15,A9,A13,FUNCT_1:3;
             h.a = f.a \/ g.a by A37,A15,A9,A13,LEXBFS:def 2;
             then x in h.a by A35,A38,XBOOLE_0:def 3;
           hence x in union C by A39,TARSKI:def 4;
         end;
       end;
      hence thesis by TARSKI:2;
     end;
A40: now
       let a be Subset of cR;
       assume a in C;
       then consider x being object such that
     A41: x in dom h and
     A42: h.x = a by FUNCT_1:def 3;
     A43: h.x = f.x \/ g.x by A41,A15,LEXBFS:def 2;
         set cfx = f.x, cgx = g.x;
     A44: cfx in U by A41,A15,FUNCT_2:5;
         then reconsider cfx as Subset of Pa;
     A45: cgx in L by A41,A15,FUNCT_2:5;
         then reconsider cgx as Subset of Pb;
         cfx <> {} by A44;
       hence a <> {} by A42,A43;
       let b be Subset of cR;
       assume b in C;
         then consider y being object such that
     A46: y in dom h and
     A47: h.y = b by FUNCT_1:def 3;
     A48: h.y = f.y \/ g.y by A46,A15,LEXBFS:def 2;
         set cfy = f.y, cgy = g.y;
     A49: cfy in U by A46,A15,FUNCT_2:5;
         then reconsider cfy as Subset of Pa;
     A50: cgy in L by A46,A15,FUNCT_2:5;
         then reconsider cgy as Subset of Pb;
       assume A51: a <> b;
     then
A52: cfx <> cfy by A7,A42,A47,A41,A46,A15,A9,FUNCT_1:def 4;
     A53: cgx <> cgy by A11,A51,A42,A47,A41,A46,A15,A13,FUNCT_1:def 4;
       assume a meets b;
       then a /\ b <> {};
       then consider z being object such that
     A54: z in a /\ b by XBOOLE_0:def 1;
     A55: z in a by A54,XBOOLE_0:def 4;
     A56: z in b by A54,XBOOLE_0:def 4;
       set cfz = f.z, cgz = g.z;
       per cases by A55,A56,A42,A47,A43,A48,XBOOLE_0:def 3;
       suppose z in cfx & z in cfy;
           then z in cfx /\ cfy by XBOOLE_0:def 4;
           then cfx meets cfy;
         hence contradiction by A44,A49,A52,EQREL_1:def 4;
       end;
       suppose A57: z in cfx & z in cgy;
       then A58: z in A by A5,A6,Th22;
       A59: z in f.z by A57,A5,A6,Th22,A8;
       A60: cfz in U by A57,A5,A6,Th22,FUNCT_2:5;
         then reconsider cfz as Subset of Pa;
         z in cfx /\ cfz by A57,A59,XBOOLE_0:def 4;
         then cfz meets cfx;
         then cfz = cfx by A44,A60,EQREL_1:def 4;
         then A61: z = x by A7,A41,A58,A15,A9,FUNCT_1:def 4;
       A62: z in g.z by A57,A5,A6,Th22,A12;
       A63: cgz in L by A57,A5,A6,Th22,FUNCT_2:5;
         then reconsider cgz as Subset of Pb;
         z in cgz /\ cgy by A57,A62,XBOOLE_0:def 4;
         then cgz meets cgy;
         then cgz = cgy by A50,A63,EQREL_1:def 4;
         hence contradiction by A61,A51,A42,A47,A11,A46,A58,A15,A13,
FUNCT_1:def 4;
       end;
       suppose A64: z in cgx & z in cfy;
       then A65: z in A by A5,A6,Th22;
       A66: z in f.z by A64,A5,A6,Th22,A8;
       A67: cfz in U by A64,A5,A6,Th22,FUNCT_2:5;
         then reconsider cfz as Subset of Pa;
         z in cfy /\ cfz by A64,A66,XBOOLE_0:def 4;
         then cfz meets cfy;
         then cfz = cfy by A49,A67,EQREL_1:def 4;
         then A68: z = y by A7,A46,A65,A15,A9,FUNCT_1:def 4;
       A69: z in g.z by A64,A5,A6,Th22,A12;
       A70: cgz in L by A64,A5,A6,Th22,FUNCT_2:5;
         then reconsider cgz as Subset of Pb;
         z in cgz /\ cgx by A64,A69,XBOOLE_0:def 4;
         then cgz meets cgx;
         then cgz = cgx by A45,A70,EQREL_1:def 4;
         hence contradiction by A68,A51,A42,A47,A11,A41,A65,A15,A13,
FUNCT_1:def 4;
       end;
       suppose z in cgx & z in cgy;
           then z in cgx /\ cgy by XBOOLE_0:def 4;
           then cgx meets cgy;
         hence contradiction by A45,A50,A53,EQREL_1:def 4;
       end;
     end;
A71: for x being set st x in C holds x is Clique of R
    proof
      let c be set;
      assume c in C;
        then consider x being object such that
    A72: x in dom h and
    A73: c = h.x by FUNCT_1:def 3;
    A74: c = f.x \/ g.x by A72,A73,A15,LEXBFS:def 2;
        set cf = f.x, cg = g.x;
        cf in U by A72,A15,FUNCT_2:5;
        then
    A75: cf is Clique of Pa by Def11;
        then A76: cf is Clique of R by Th28;
        cg in L by A72,A15,FUNCT_2:5;
        then
    A77: cg is Clique of Pb by Def11;
        then A78: cg is Clique of R by Th28;
        then reconsider c9 = c as Subset of R by A74,A76,XBOOLE_1:8;
        now let a, b being Element of R such that
        A79: a in c9 and
        A80: b in c9 and
        A81: a <> b;
        A82: x in cf by A72,A15,A8;
        A83: x in cg by A72,A15,A12;
            reconsider x as Element of R by A72,A15,A9,A13;
         per cases by A79,A80,A74,XBOOLE_0:def 3;
         suppose a in f.x & b in f.x;
           hence a <= b or b <= a by A76,A81,Th6;
         end;
         suppose A84: a in f.x & b in g.x;
         then A85: x = a or x <= a by A82,A72,A15,A75,Th35;
          x = b or b <= x by A83,A84,A72,A15,A77,Th34;
           hence a <= b or b <= a by A81,A85,YELLOW_0:def 2;
         end;
         suppose A86: a in g.x & b in f.x;
         then A87: x = a or a <= x by A83,A72,A15,A77,Th34;
          x = b or x <= b by A82,A86,A72,A15,A75,Th35;
           hence a <= b or b <= a by A81,A87,YELLOW_0:def 2;
         end;
         suppose a in g.x & b in g.x;
           hence a <= b or b <= a by A78,A81,Th6;
         end;
        end;
      hence c is Clique of R by Th6;
    end;
A88: h is one-to-one proof
     let x1,x2 be object such that
    A89: x1 in dom h and
    A90: x2 in dom h and
    A91: h.x1 = h.x2;
    A92: h.x1 is Clique of R by A71,A89,FUNCT_1:3;
    A93: h.x1 = f.x1 \/ g.x1 by A15,A89,LEXBFS:def 2;
         x1 in f.x1 & x1 in g.x1 by A89,A15,A8,A12;
    then A94: x1 in h.x1 by A93,XBOOLE_0:def 3;
    A95: h.x2 = f.x2 \/ g.x2 by A15,A90,LEXBFS:def 2;
         x2 in f.x2 & x2 in g.x2 by A90,A15,A8,A12;
         then x2 in h.x2 by A95,XBOOLE_0:def 3;
     hence x1 = x2 by A15,A89,A90,A91,A92,A94,Th15;
    end;
    reconsider C as Clique-partition of R
     by A16,A21,A40,A71,Def11,EQREL_1:def 4;
    take C;
    card C = card h by A88,PRE_POLY:19
          .= card A by A15,A9,A13,CARD_1:62;
    hence card C = stability# R by A1;
end;
