reserve x,y, X,Y,Z for set,
        D for non empty set,
        n,k for Nat,
        i,i1,i2 for Integer;

theorem
  for Y be Subset-Family of X st
     Y is finite with_non-empty_elements c=-linear & X in Y
  ex Y1 be Subset-Family of X st
    Y c= Y1 & Y1 is with_non-empty_elements c=-linear & card X = card Y1 &
    for Z st Z in Y1 & card Z <> 1 ex x st x in Z & Z\{x} in Y1
 proof
  let Y be Subset-Family of X such that
   A1: Y is finite with_non-empty_elements c=-linear and
   A2: X in Y;
  defpred P[object,object] means
  ex A being set st A = $2 &
   $1 in A & $2 in Y & for y st y in Y & $1 in y holds A c= y;
  A3: for x being object st x in X ex y being object st P[x,y]
  proof
   let x be object;
   set U={A where A is Subset of X:x in A & A in Y};
   A4: U c=Y
   proof
    let y be object;
    assume y in U;
    then ex A be Subset of X st y=A & x in A & A in Y;
    hence thesis;
   end;
   then reconsider U as Subset-Family of X by XBOOLE_1:1;
   assume x in X;
   then X in U by A2;
   then consider m be set such that
    A5: m in U and
    A6: for y st y in U holds m c=y by A1,A4,FINSET_1:11;
   take m;
    consider A be Subset of X such that
A7:   m=A & x in A & A in Y by A5;
   take A;
   thus A = m by A7;
   thus x in A & m in Y by A7;
   let y;
   assume y in Y & x in y;
   then y in U;
   hence thesis by A6,A7;
  end;
  consider f be Function such that
A8: dom f=X &
     for x being object st x in X holds P[x,f.x] from CLASSES1:sch 1(A3);
  defpred Q[object,object] means
   ex D1,D2 being set st D1 = $1 & D2 = $2 &
   (D2 in Y or D2 is empty) & D2 c<D1 &
   (for x st x in Y & x c<D1 holds x c=D2) &
  (for x st x in Y & D2 c=x & x c= D1 holds x=D1 or x=D2);
A9: for x being object st x in Y ex y being object st y in bool X & Q[x,y]
  proof
   let x be object;
    reconsider xx = x as set by TARSKI:1;
   assume A10: x in Y;
   set U={A where A is Subset of X:A c<xx & A in Y};
   A11: U c=Y
   proof
    let y be object;
    assume y in U;
    then ex A be Subset of X st y=A & A c<xx & A in Y;
    hence thesis;
   end;
   then reconsider U as Subset-Family of X by XBOOLE_1:1;
   take u=union U;
   thus u in bool X;
   A12: for y st y in Y & y c<xx holds y c=u
   proof
    let y;
    assume that
     A13: y in Y and
     A14: y c<xx;
    y in U by A13,A14;
    hence thesis by ZFMISC_1:74;
   end;
   per cases;
   suppose
A15:   U is empty;
   take xx,u;
   thus xx = x & u = u;
   thus  (u in Y or u is empty) & u c<xx & for y st y in Y & y c<xx holds y
c=u by A1,A10,A12,A15,XBOOLE_1:61,ZFMISC_1:2;
    let y;
    assume that
     A16: y in Y and
     A17: u c=y and
     A18: y c=xx;
    assume y<>xx;
    then y c<xx by A18;
    then y c=u by A12,A16;
    hence thesis by A17;
   end;
   suppose U is non empty;
    then u in U by A1,A11,Th9;
    then
A19:ex A be Subset of X st A=u & A c<xx & A in Y;
   take xx,u;
   thus xx = x & u = u;
    thus (u in Y or u is empty) & u c<xx & for y st y in Y & y c<xx holds y
c=u by A12,A19;
    let y;
    assume that
     A20: y in Y and
     A21: u c=y and
     A22: y c=xx;
    assume y<>xx;
    then y c<xx by A22;
    then y c=u by A12,A20;
    hence thesis by A21;
   end;
  end;
  consider g be Function of Y,bool X such that
A23: for x being object st x in Y holds Q[x,g.x] from FUNCT_2:sch 1(A9);
  defpred R[object,object] means
   ex A being set,
      h be Function of A\(g.A),bool(A\(g.A))
  st A = $1 & $2=h & h is one-to-one & rng
h is with_non-empty_elements c=-linear & dom h in rng h & for Z st Z in rng h &
card Z<>1 ex x st x in Z & Z\{x} in rng h;
  A24: for x being object st x in Y ex y being object st R[x,y]
  proof
   let y be object;
   assume
A25:  y in Y;
   reconsider y as set by TARSKI:1;
   Q[y,g.y] by A23,A25;
   then g.y c<y;
   then y\(g.y)<>{} by XBOOLE_1:105;
   then consider Z be Subset-Family of y\(g.y) such that
    A26: Z is with_non-empty_elements c=-linear & y\(g.y) in Z and
    A27: card(y\g.y)=card Z and
    A28: for z be set st z in Z & card z<>1 ex x st x in z & z\{x} in Z by Th12
;
   y\g.y,Z are_equipotent by A27,CARD_1:5;
   then consider h be Function such that
    A29: h is one-to-one and
    A30: dom h=y\g.y & rng h=Z by WELLORD2:def 4;
   reconsider h as Function of y\g.y,bool(y\g.y) by A30,FUNCT_2:2;
   take h;
   thus thesis by A26,A28,A29,A30;
  end;
  consider h be Function such that
A31: dom h=Y &
   for x being object st x in Y holds R[x,h.x] from CLASSES1:sch 1(A24);
  now let x be object;
   assume x in dom h;
   then R[x,h.x] by A31;
   hence h.x is Function;
  end;
  then reconsider h as Function-yielding Function by FUNCOP_1:def 6;
  deffunc Z(object)=g.(f.$1)\/(h.(f.$1)).$1;
  A32: for x st x in X holds x in (f.x)\(g.(f.x))
  proof
   let x;
   assume  x in X;
   then
A33:  P[x,f.x] by A8;
   then A34: f.x in Y;
   assume A35: not x in (f.x)\(g.(f.x));
   x in f.x by A33;
   then A36: x in g.(f.x) by A35,XBOOLE_0:def 5;
A37:  Q[f.x,g.(f.x)] by A23,A34;
   then g.(f.x) in Y by A36;
   then A38: f.x c=g.(f.x) by A36,A33;
   g.(f.x)c<f.x by A37;
   hence thesis by A38,XBOOLE_0:def 8;
  end;
  A39: for x being object st x in X holds Z(x) in bool X
  proof
   let x be object;
   set fx=f.x;
   assume A40: x in X;
    then
  P[x,f.x] by A8;
   then A41: fx in Y;
   then R[fx,h.fx] by A31;
   then consider A being set,
      H be Function of fx\(g.fx),bool(fx\(g.fx)) such that
    A42: h.fx=H and
    H is one-to-one and
    rng H is with_non-empty_elements c=-linear and
    dom H in rng H and
    for Z st Z in rng H & card Z<>1 ex x st x in Z & Z\{x} in rng H;
   A43: x in fx\(g.fx) by A32,A40;
   dom H=fx\(g.fx) by FUNCT_2:def 1;
   then H.x in rng H by A43,FUNCT_1:def 3;
   then H.x c=fx by XBOOLE_1:1;
   then A44: H.x c=X by A41,XBOOLE_1:1;
   Q[fx,g.fx] by A23,A41;
   then g.fx in Y or g.fx is empty;
   then Z(x)c=X by A42,A44,XBOOLE_1:8;
   hence thesis;
  end;
  consider z be Function of X,bool X such that
A45: for x being object st x in X holds z.x=Z(x) from FUNCT_2:sch 2(A39);
  A46: dom z=X by FUNCT_2:def 1;
  A47: Y c=rng z
  proof
   let y be object;
    reconsider yy=y as set by TARSKI:1;
   assume A48: y in Y;
   then R[y,h.y] by A31;
   then consider H be Function of yy\(g.y),bool(yy\(g.y)) such that
    A49: h.y=H and
    H is one-to-one and
    rng H is with_non-empty_elements c=-linear and
    A50: dom H in rng H and
    for Z st Z in rng H & card Z<>1 ex x st x in Z & Z\{x} in rng H;
   consider x being object such that
    A51: x in dom H and
    A52: H.x=dom H by A50,FUNCT_1:def 3;
   A53: dom H=yy\(g.yy) by FUNCT_2:def 1;
   then A54: x in yy by A51;
   then
A55:  P[x,f.x] by A8,A48;
   then A56: x in f.x;
   Q[y,g.y] by A23,A48;
   then g.y c<yy;
   then A57: g.y c=yy;
   A58: f.x c=yy by A48,A54,A55;
   A59: f.x in Y by A55;
   f.x=y
   proof
    assume f.x<>y;
    then
A60: f.x c<yy by A58;
    Q[y,g.y] by A23,A48;
    then f.x c=g.y by A59,A60;
    hence contradiction by A51,A56,XBOOLE_0:def 5;
   end;
   then z.x=g.y\/(yy\(g.y)) by A45,A48,A49,A52,A53,A54
    .=y by A57,XBOOLE_1:45;
   hence thesis by A46,A48,A54,FUNCT_1:def 3;
  end;
  A61: for Z st Z in rng z & card Z<>1 ex x st x in Z & Z\{x} in rng z
  proof
   let Z;
   assume that
    A62: Z in rng z and
    A63: card Z<>1;
   consider x be object such that
    A64: x in dom z and
    A65: z.x=Z by A62,FUNCT_1:def 3;
   set fx=f.x;
   P[x,fx] by A8,A64;
   then
   A66: fx in Y;
   then R[fx,h.fx] by A31;
   then consider H be Function of fx\(g.fx),bool(fx\(g.fx)) such that
    A67: h.fx=H and
    H is one-to-one and
    rng H is with_non-empty_elements c=-linear and
    dom H in rng H and
    A68: for Z st Z in rng H & card Z<>1 ex x st x in Z & Z\{x} in rng H;
   A69: z.x=g.fx\/H.x by A45,A64,A67;
   A70: dom H=fx\(g.fx) by FUNCT_2:def 1;
   x in fx\(g.fx) by A32,A64;
   then A71: H.x in rng H by A70,FUNCT_1:def 3;
   per cases;
   suppose A72: card(H.x)=1;
    then
A73:  g.fx<>{} by A63,A65,A69;
    Q[fx,g.fx] by A23,A66;
    then A74: g.fx in Y by A73;
    consider a be object such that
     A75: H.x={a} by A72,CARD_2:42;
     reconsider a as set by TARSKI:1;
    take a;
    A76: a in H.x by A75,TARSKI:def 1;
    then A77: not a in g.fx by A71,XBOOLE_0:def 5;
    thus a in Z by A65,A69,A76,XBOOLE_0:def 3;
    Z\{a}=(g.fx\/H.x)\H.x by A45,A64,A65,A67,A75
     .=g.fx\H.x by XBOOLE_1:40
     .=g.fx by A75,A77,ZFMISC_1:57;
    hence thesis by A47,A74;
   end;
   suppose card(H.x)<>1;
    then consider a be set such that
     A78: a in H.x and
     A79: H.x\{a} in rng H by A68,A71;
    A80: not a in g.fx by A71,A78,XBOOLE_0:def 5;
    take a;
    thus a in Z by A65,A69,A78,XBOOLE_0:def 3;
    consider b be object such that
     A81: b in dom H and
     A82: H.b=H.x\{a} by A79,FUNCT_1:def 3;
    A83: b in fx by A70,A81;
    then
A84:  P[b,f.b] by A8,A66;
    then A85: b in f.b;
    A86: f.b in Y by A84;
    A87: f.b c=fx by A66,A83,A84;
    fx=f.b
    proof
     assume fx<>f.b;
     then
A88:   f.b c<fx by A87;
    Q[fx,g.fx] by A23,A66;
     then f.b c=g.fx by A86,A88;
     hence contradiction by A81,A85,XBOOLE_0:def 5;
    end;
    then z.b=g.fx\/(H.x\{a}) by A45,A66,A67,A82,A83
     .=(g.fx\/H.x)\{a} by A80,XBOOLE_1:87,ZFMISC_1:50
     .=Z\{a} by A65,A45,A64,A67;
    hence thesis by A46,A66,A83,FUNCT_1:def 3;
   end;
  end;
  A89: rng z is c=-linear
  proof
   let y1,y2 be set;
   assume that
    A90: y1 in rng z and
    A91: y2 in rng z;
   consider x1 be object such that
    A92: x1 in dom z and
    A93: z.x1=y1 by A90,FUNCT_1:def 3;
   consider x2 be object such that
    A94: x2 in dom z and
    A95: z.x2=y2 by A91,FUNCT_1:def 3;
   set fx1=f.x1,fx2=f.x2;
   A96: x1 in fx1\(g.fx1) by A32,A92;
    P[x1,f.x1] by A8,A92;
    then
   A97: fx1 in Y;
   then R[fx1,h.fx1] by A31;
   then consider H1 be Function of fx1\(g.fx1),bool(fx1\(g.fx1)) such that
    A98: h.fx1=H1 and
    H1 is one-to-one and
  rng H1 is with_non-empty_elements c=-linear and
    dom H1 in rng H1 and
    for Z st Z in rng H1 & card Z<>1 ex x st x in Z & Z\{x} in rng H1;
   A99: z.x1=g.fx1\/H1.x1 by A45,A92,A98;
   dom H1=fx1\(g.fx1) by FUNCT_2:def 1;
   then A100: H1.x1 in rng H1 by A96,FUNCT_1:def 3;
   A101: x2 in fx2\(g.fx2) by A32,A94;
    P[x2,fx2] by A8,A94;
    then
   A102: fx2 in Y;
   then R[fx2,h.fx2] by A31;
   then consider H2 be Function of fx2\(g.fx2),bool(fx2\(g.fx2)) such that
    A103: h.fx2=H2 and
    H2 is one-to-one and
    A104: rng H2 is with_non-empty_elements c=-linear and
    dom H2 in rng H2 and
    for Z st Z in rng H2 & card Z<>1 ex x st x in Z & Z\{x} in rng H2;
   A105: z.x2=g.fx2\/H2.x2 by A45,A94,A103;
   dom H2=fx2\(g.fx2) by FUNCT_2:def 1;
   then A106: H2.x2 in rng H2 by A101,FUNCT_1:def 3;
   A107: fx1,fx2 are_c=-comparable by A1,A97,A102;
   per cases by A107;
   suppose A108: fx1=fx2;
    then H1.x1,H1.x2 are_c=-comparable by A98,A100,A103,A104,A106;
    then H1.x1 c=H1.x2 or H1.x2 c=H1.x1;
    then z.x1 c=z.x2 or z.x2 c=z.x1 by A98,A99,A103,A105,A108,XBOOLE_1:9;
    hence thesis by A93,A95;
   end;
   suppose fx1 c=fx2 & fx1<>fx2;
    then
A109:   fx1 c<fx2;
    Q[fx2,g.fx2] by A23,A102;
    then A110: fx1 c=g.fx2 by A97,A109;
    g.fx2 c=z.x2 by A105,XBOOLE_1:7;
    then A111: fx1 c=z.x2 by A110;
    Q[fx1,g.fx1] by A23,A97;
    then g.fx1 c<fx1;
    then g.fx1 c=fx1;
    then A112: g.fx1\/(fx1\(g.fx1))=fx1 by XBOOLE_1:45;
    z.x1 c=g.fx1\/(fx1\(g.fx1)) by A99,A100,XBOOLE_1:9;
    then z.x1 c=z.x2 by A111,A112;
    hence thesis by A93,A95;
   end;
   suppose fx2 c=fx1 & fx1<>fx2;
    then
A113:  fx2 c<fx1;
    Q[fx1,g.fx1] by A23,A97;
    then A114: fx2 c=g.fx1 by A102,A113;
    g.fx1 c=z.x1 by A99,XBOOLE_1:7;
    then A115: fx2 c=z.x1 by A114;
    Q[fx2,g.fx2] by A23,A102;
    then g.fx2 c<fx2;
    then g.fx2 c=fx2;
    then A116: g.fx2\/(fx2\(g.fx2))=fx2 by XBOOLE_1:45;
    z.x2 c=g.fx2\/(fx2\(g.fx2)) by A105,A106,XBOOLE_1:9;
    then z.x2 c=z.x1 by A115,A116;
    hence thesis by A93,A95;
   end;
  end;
  A117: rng z is with_non-empty_elements
  proof
   assume rng z is non with_non-empty_elements;
   then {} in rng z;
   then consider x being object such that
    A118: x in dom z and
    A119: z.x={} by FUNCT_1:def 3;
   set fx=f.x;
   A120: x in fx\(g.fx) by A32,A118;
   P[x,fx] by A8,A118;
   then fx in Y;
   then R[fx,h.fx] by A31;
   then consider H be Function of fx\(g.fx),bool(fx\(g.fx)) such that
    A121: h.fx=H and
    H is one-to-one and
    A122: rng H is with_non-empty_elements c=-linear and
    dom H in rng H and
    for Z st Z in rng H & card Z<>1 ex x st x in Z & Z\{x} in rng H;
   dom H=fx\(g.fx) by FUNCT_2:def 1;
   then A123: H.x in rng H by A120,FUNCT_1:def 3;
   z.x=g.fx\/H.x by A45,A118,A121;
   hence contradiction by A119,A122,A123;
  end;
  take rng z;
  for x1,x2 be object st x1 in dom z & x2 in dom z & z.x1=z.x2 holds x1=x2
  proof
   let x1,x2 be object;
   set f1=f.x1,f2=f.x2;
   assume that
    A124: x1 in dom z and
    A125: x2 in dom z and
    A126: z.x1=z.x2;
   A127: z.x1=Z(x1) & z.x2=Z(x2) by A45,A124,A125;
    P[x2,f2] by A8,A125;
    then
   A128: f2 in Y;
   then R[f2,h.f2] by A31;
   then consider H2 be Function of f2\(g.f2),bool(f2\(g.f2)) such that
    A129: h.f2=H2 and
    A130: H2 is one-to-one and
    A131: rng H2 is with_non-empty_elements c=-linear and
    dom H2 in rng H2 and
    for Z st Z in rng H2 & card Z<>1 ex x st x in Z & Z\{x} in rng H2;
   dom H2=f2\(g.f2) by FUNCT_2:def 1;
   then A132: x2 in dom H2 by A32,A125;
   then A133: H2.x2 in rng H2 by FUNCT_1:def 3;
   then A134: g.f2 misses H2.x2 by XBOOLE_1:63,79;
   P[x1,f1] by A8,A124;
   then
   A135: f1 in Y;
   then R[f1,h.f1] by A31;
   then consider H1 be Function of f1\(g.f1),bool(f1\(g.f1)) such that
    A136: h.f1=H1 and
    H1 is one-to-one and
    A137: rng H1 is with_non-empty_elements c=-linear and
    dom H1 in rng H1 and
    for Z st Z in rng H1 & card Z<>1 ex x st x in Z & Z\{x} in rng H1;
   dom H1=f1\(g.f1) by FUNCT_2:def 1;
   then A138: x1 in dom H1 by A32,A124;
   then A139: H1.x1 in rng H1 by FUNCT_1:def 3;
   then A140: g.f1 misses H1.x1 by XBOOLE_1:63,79;
   A141: f1,f2 are_c=-comparable by A1,A128,A135;
   per cases by A141;
   suppose A142: f1=f2;
    then H1.x1=H1.x2 by A126,A127,A129,A134,A136,A140,XBOOLE_1:71;
    hence thesis by A129,A130,A132,A136,A138,A142,FUNCT_1:def 4;
   end;
   suppose A143: f1 c=f2 & f1<>f2;
    Q[f1,g.f1] by A23,A135;
    then g.f1 c<f1;
    then g.f1 c=f1;
    then g.f1\/(f1\(g.f1))=f1 by XBOOLE_1:45;
    then A144: Z(x2)c=f1 by A126,A127,A136,A139,XBOOLE_1:9;
A145:  f1 c<f2 by A143;
    Q[f2,g.f2] by A23,A128;
    then f1 c=g.f2 by A135,A145;
    then Z(x2)c=g.f2 by A144;
    then H2.x2 c=g.f2 by A129,XBOOLE_1:11;
    hence thesis by A131,A133,XBOOLE_1:67,79;
   end;
   suppose A146: f2 c=f1 & f1<>f2;
    Q[f2,g.f2] by A23,A128;
    then g.f2 c<f2;
    then g.f2 c=f2;
    then g.f2\/(f2\(g.f2))=f2 by XBOOLE_1:45;
    then A147: Z(x1)c=f2 by A126,A127,A129,A133,XBOOLE_1:9;
A148:  f2 c<f1 by A146;
    Q[f1,g.f1] by A23,A135;
    then f2 c=g.f1 by A128,A148;
    then Z(x1)c=g.f1 by A147;
    then H1.x1 c=g.f1 by A136,XBOOLE_1:11;
    hence thesis by A137,A139,XBOOLE_1:67,79;
   end;
  end;
  then z is one-to-one by FUNCT_1:def 4;
  then X,rng z are_equipotent by A46,WELLORD2:def 4;
  hence thesis by A47,A61,A89,A117,CARD_1:5;
 end;
