reserve x,y,y1,y2,z,a,b for object, X,Y,Z,V1,V2 for set,
  f,g,h,h9,f1,f2 for Function,
  i for Nat,
  P for Permutation of X,
  D,D1,D2,D3 for non empty set,
  d1 for Element of D1,
  d2 for Element of D2,
  d3 for Element of D3;

theorem
  Funcs(Union disjoin f,X),product Funcs(f,X) are_equipotent
proof
  defpred P[object,object] means
  ex g,h st $1 = g & $2 = h & dom h = dom f & for y
  st y in dom f holds (f.y = {} implies h.y = {}) & (f.y <> {} implies h.y = (
  curry' g).y);
A1: for x being object st x in Funcs(Union disjoin f, X)
     ex z being object st P[x,z]
  proof
    defpred P[object] means f.$1 = {};
    deffunc F(object) = {};
    let x be object;
    assume x in Funcs(Union disjoin f, X);
    then consider g such that
A2: x = g and
    dom g = Union disjoin f and
    rng g c= X by FUNCT_2:def 2;
    deffunc G(object) = (curry' g).$1;
    consider h such that
A3:   dom h = dom f &
      for y being object st y in dom f holds (P[y] implies h.y =
    F(y)) & (not P[y] implies h.y = G(y)) from PARTFUN1:sch 1;
   take z = h, g, h;
   thus
     x = g & z = h & dom h = dom f & for y
  st y in dom f holds (f.y = {} implies h.y = {}) &
    (f.y <> {} implies h.y = (
  curry' g).y) by A2,A3;
  end;
  consider F being Function such that
A4: dom F = Funcs(Union disjoin f, X) &
for x being object st x in Funcs(Union
  disjoin f, X) holds P[x,F.x] from CLASSES1:sch 1(A1);
  take F;
  thus F is one-to-one
  proof
    let x,y be object;
    assume that
A5: x in dom F and
A6: y in dom F and
A7: F.x = F.y;
A8: ex f2 being Function st y = f2 & dom f2 = Union disjoin f & rng f2 c=
    X by A4,A6,FUNCT_2:def 2;
    consider g1,h1 being Function such that
A9: x = g1 and
A10: F.x = h1 and
    dom h1 = dom f and
A11: for y st y in dom f holds (f.y = {} implies h1.y = {}) & (f.y <>
    {} implies h1.y = (curry' g1).y) by A4,A5;
    consider g2,h2 being Function such that
A12: y = g2 and
A13: F.y = h2 and
    dom h2 = dom f and
A14: for y st y in dom f holds (f.y = {} implies h2.y = {}) & (f.y <>
    {} implies h2.y = (curry' g2).y) by A4,A6;
A15: ex f1 being Function st x = f1 & dom f1 = Union disjoin f & rng f1 c=
    X by A4,A5,FUNCT_2:def 2;
    now
      let z be object;
      assume
A16:  z in Union disjoin f;
      then
A17:  z = [z`1,z`2] by CARD_3:22;
A18:  z`2 in dom f & z`1 in f.(z`2) by A16,CARD_3:22;
      then
A19:  h2.z`2 = (curry' g2).z`2 by A14;
      then reconsider
      g91 = h1.z`2, g92 = h2.z`2 as Function by A7,A10,A13;
A20:  g2.(z`1,z`2) = g92.z`1 by A8,A12,A16,A17,A19,FUNCT_5:22;
      h1.z`2 = (curry' g1).z`2 by A11,A18;
      then g1.(z`1,z`2) = g91.z`1 by A15,A9,A16,A17,FUNCT_5:22;
      hence g1.z = g2.z by A7,A10,A13,A17,A20;
    end;
    hence thesis by A15,A8,A9,A12,FUNCT_1:2;
  end;
  thus dom F = Funcs(Union disjoin f, X) by A4;
  thus rng F c= product Funcs(f,X)
  proof
    let y be object;
    assume y in rng F;
    then consider x being object such that
A21: x in dom F and
A22: y = F.x by FUNCT_1:def 3;
    consider g,h such that
A23: x = g and
A24: F.x = h and
A25: dom h = dom f and
A26: for y st y in dom f holds (f.y = {} implies h.y = {}) & (f.y <>
    {} implies h.y = (curry' g).y) by A4,A21;
A27: ex f1 being Function st x = f1 & dom f1 = Union disjoin f & rng f1 c=
    X by A4,A21,FUNCT_2:def 2;
A28: now
      let z be object;
      assume z in dom Funcs(f,X);
      then
A29:  z in dom f by Def7;
      then
A30:  Funcs(f,X).z = Funcs(f.z,X) by Def7;
A31:  now
        set a = the Element of f.z;
        assume
A32:    f.z <> {};
        [a,z]`1 = a & [a,z]`2 = z;
        then
A33:    [a,z] in Union disjoin f by A29,A32,CARD_3:22;
        reconsider k = (curry' g).z as Function;
A34:    z in dom curry' g by A23,A27,A33,FUNCT_5:21;
        then rng k c= rng g by FUNCT_5:34;
        then
A35:    rng k c= X by A23,A27;
A36:    dom k = proj1 (dom g /\ [:proj1 dom g,{z}:]) by A34,FUNCT_5:34;
A37:    dom k = f.z
        proof
          thus dom k c= f.z
          proof
            let b be object;
            assume b in dom k;
            then consider c being object such that
A38:        [b,c] in dom g /\ [:proj1 dom g,{z}:] by A36,XTUPLE_0:def 12;
            [b,c] in [:proj1 dom g,{z}:] by A38,XBOOLE_0:def 4;
            then
A39:        c in {z} by ZFMISC_1:87;
A40:        [b,c]`1 = b & [b,c]`2 = c;
            [b,c] in dom g by A38,XBOOLE_0:def 4;
            then b in f.c by A23,A27,A40,CARD_3:22;
            hence thesis by A39,TARSKI:def 1;
          end;
          let b be object such that
A41:      b in f.z;
A42:      z in {z} by TARSKI:def 1;
          [b,z]`1 = b & [b,z]`2 = z;
          then
A43:      [b,z] in dom g by A23,A27,A29,A41,CARD_3:22;
          then b in proj1 dom g by XTUPLE_0:def 12;
          then [b,z] in [:proj1 dom g,{z}:] by A42,ZFMISC_1:87;
          then [b,z] in dom g /\ [:proj1 dom g,{z}:] by A43,XBOOLE_0:def 4;
          hence thesis by A36,XTUPLE_0:def 12;
        end;
        h.z = k by A26,A29,A32;
        hence h.z in Funcs(f,X).z by A30,A35,A37,FUNCT_2:def 2;
      end;
      now
        assume f.z = {};
        then h.z = {} & Funcs(f,X).z = {{}} by A26,A29,A30,FUNCT_5:57;
        hence h.z in Funcs(f,X).z by TARSKI:def 1;
      end;
      hence h.z in Funcs(f,X).z by A31;
    end;
    dom h = dom Funcs(f,X) by A25,Def7;
    hence thesis by A22,A24,A28,CARD_3:def 5;
  end;
  let x be object;
  assume x in product Funcs(f,X);
  then consider s being Function such that
A44: x = s and
A45: dom s = dom Funcs(f,X) and
A46: for z being object st z in dom Funcs(f,X) holds s.z in Funcs(f,X).z
by CARD_3:def 5;
A47: dom s = dom f by A45,Def7;
A48: uncurry' s = ~uncurry s by FUNCT_5:def 4;
A49: dom uncurry' s = Union disjoin f
  proof
    thus dom uncurry' s c= Union disjoin f
    proof
      let z be object;
      assume
A50:  z in dom uncurry' s;
      then consider z1, z2 being object such that
A51:  z = [z1,z2] by A48,Th2;
A52:  z`1 = z1 & z`2 = z2 by A51;
      [z2,z1] in dom uncurry s by A48,A50,A51,FUNCT_4:42;
      then consider a being object, u being Function, b being object
      such that
A53:  [z2,z1] = [a,b] and
A54:  a in dom s and
A55:  u = s.a and
A56:  b in dom u by FUNCT_5:def 2;
A57:  [a,b]`1 = a & [z2,z1]`1 = z2;
      u in Funcs(f,X).a & Funcs(f,X).a = Funcs(f.a,X) by A45,A46,A47,A54,A55
,Def7;
      then
A58:  ex j being Function st u = j & dom j = f.z2 & rng j c= X by A53,A57,
FUNCT_2:def 2;
      [a,b]`2 = b & [z2,z1]`2 = z1;
      hence thesis by A47,A51,A53,A54,A56,A52,A57,A58,CARD_3:22;
    end;
    let z be object;
    assume
A59: z in Union disjoin f;
    then
A60: z`1 in f.z`2 & z = [z`1,z`2] by CARD_3:22;
A61: z`2 in dom f by A59,CARD_3:22;
    then
    s.z`2 in Funcs(f,X).z`2 & Funcs(f,X).z`2 = Funcs(f.z`2,X) by A45,A46,A47
,Def7;
    then ex j being Function st s.z`2 = j & dom j = f.z`2 & rng j c= X by
FUNCT_2:def 2;
    hence thesis by A47,A61,A60,FUNCT_5:39;
  end;
  rng uncurry' s c= X
  proof
    let d be object;
    assume d in rng uncurry' s;
    then consider z being object such that
A62: z in dom uncurry' s and
A63: d = (uncurry' s).z by FUNCT_1:def 3;
    consider z1, z2 being object such that
A64: z = [z1,z2] by A48,A62,Th2;
    [z2,z1] in dom uncurry s by A48,A62,A64,FUNCT_4:42;
    then consider a being object, u being Function, b being object such that
A65: [z2,z1] = [a,b] and
A66: a in dom s & u = s.a and
A67: b in dom u by FUNCT_5:def 2;
A68: [a,b]`1 = a & [z2,z1]`1 = z2;
    u in Funcs(f,X).a & Funcs(f,X).a = Funcs(f.a,X) by A45,A46,A47,A66,Def7;
    then
A69: ex j being Function st u = j & dom j = f.z2 & rng j c= X by A65,A68,
FUNCT_2:def 2;
A70: [a,b]`2 = b & [z2,z1]`2 = z1;
    (uncurry' s).(b,a) = u.b by A66,A67,FUNCT_5:39;
    then d in rng u by A63,A64,A65,A67,A68,A70,FUNCT_1:def 3;
    hence thesis by A69;
  end;
  then
A71: uncurry' s in dom F by A4,A49,FUNCT_2:def 2;
  then consider g,h such that
A72: uncurry' s = g and
A73: F.uncurry' s = h and
A74: dom h = dom f and
A75: for y st y in dom f holds (f.y = {} implies h.y = {}) & (f.y <> {}
  implies h.y = (curry' g).y) by A4;
  now
    let z be object;
    assume
A76: z in dom f;
    then s.z in Funcs(f,X).z & Funcs(f,X).z = Funcs(f.z,X) by A45,A46,A47,Def7;
    then consider v being Function such that
A77: s.z = v and
A78: dom v = f.z and
    rng v c= X by FUNCT_2:def 2;
A79: now
      set a = the Element of f.z;
      assume
A80:  f.z <> {};
      then
A81:  [a,z] in dom uncurry' s by A47,A76,A77,A78,FUNCT_5:39;
      reconsider j = (curry' uncurry' s).z as Function;
A82:  j = (curry ~uncurry' s).z by FUNCT_5:def 3;
A83:  ~uncurry' s = uncurry s by Th4;
      then
A84:  [z,a] in dom uncurry s by A81,FUNCT_4:42;
A85:  dom j = dom v
      proof
        thus dom j c= dom v
        proof
          let b be object;
          assume b in dom j;
          then [z,b] in dom uncurry s by A82,A83,A84,Lm3;
          then consider
          a1 being object, g1 being Function, a2 being object such that
A86:      [z,b] = [a1,a2] and
          a1 in dom s and
A87:      g1 = s.a1 & a2 in dom g1 by FUNCT_5:def 2;
          z = a1 by A86,XTUPLE_0:1;
          hence thesis by A77,A86,A87,XTUPLE_0:1;
        end;
        let b be object;
        assume b in dom v;
        then [z,b] in dom uncurry s by A47,A76,A77,FUNCT_5:38;
        hence thesis by A82,A83,FUNCT_5:20;
      end;
      now
        let b be object;
        assume b in f.z;
        then
A88:    [z,b] in dom uncurry s by A78,A82,A83,A84,A85,Lm3;
        then consider a1 being object, g1 being Function, a2 being object
        such that
A89:    [z,b] = [a1,a2] and
A90:    a1 in dom s & g1 = s.a1 & a2 in dom g1 by FUNCT_5:def 2;
A91:    j.b = (uncurry s).(z,b) by A82,A83,A88,FUNCT_5:20;
        z = a1 & b = a2 by A89,XTUPLE_0:1;
        hence j.b = v.b by A77,A90,A91,FUNCT_5:38;
      end;
      then v = j by A78,A85;
      hence s.z = h.z by A72,A75,A76,A77,A80;
    end;
    f.z = {} implies s.z = {} & h.z = {} by A75,A76,A77,A78;
    hence s.z = h.z by A79;
  end;
  then h = s by A47,A74;
  hence thesis by A44,A71,A73,FUNCT_1:def 3;
end;
