reserve x,y for set;
reserve C,C9,D,E for non empty set;
reserve c,c9,c1,c2,c3 for Element of C;
reserve B,B9,B1,B2 for Element of Fin C;
reserve A for Element of Fin C9;
reserve d,d1,d2,d3,d4,e for Element of D;
reserve F,G for BinOp of D;
reserve u for UnOp of D;
reserve f,f9 for Function of C,D;
reserve g for Function of C9,D;
reserve H for BinOp of E;
reserve h for Function of D,E;
reserve i,j for Nat;
reserve s for Function;
reserve p,q for FinSequence of D;
reserve T1,T2 for Element of i-tuples_on D;

theorem Th5:
  F is commutative associative & (A <> {} or F is having_a_unity) &
(ex s st dom s = A & rng s = B & s is one-to-one & g|A = f*s) implies F $$(A,g)
  = F $$(B,f)
proof
  defpred X[Element of Fin C9] means $1 <> {} or F is having_a_unity implies
for B st ex s st dom s = $1 & rng s = B & s is one-to-one & g|$1 = f*s holds F
  $$($1,g) = F $$(B,f);
  assume
A1: F is commutative associative;
A2: for B9 being Element of Fin C9, b being Element of C9 holds X[B9] & not
  b in B9 implies X[B9 \/ {.b.}]
  proof
    let A9 be Element of Fin C9,a be Element of C9 such that
A3: A9 <> {} or F is having_a_unity implies for B st ex s st dom s =
    A9 & rng s = B & s is one-to-one & g|A9 = f*s holds F $$(A9,g) = F $$(B,f)
    and
A4: not a in A9;
    assume A9 \/ {a} <> {} or F is having_a_unity;
    let B;
    set A = A9 \/ {.a.};
    given s such that
A5: dom s = A and
A6: rng s = B and
A7: s is one-to-one and
A8: g|A = f*s;
A9: a in A by ZFMISC_1:136;
    then
A10: s.a in B by A5,A6,FUNCT_1:def 3;
    B c= C by FINSUB_1:def 5;
    then reconsider c = s.a as Element of C by A10;
    set B9 = B \ {.c.};
    set s9 = s|A9;
A11: s9 is one-to-one by A7,FUNCT_1:52;
    now
      let y be object;
      thus y in rng s9 implies y in B9
      proof
        assume y in rng s9;
        then consider x being object such that
A12:    x in dom s9 and
A13:    y = s9.x by FUNCT_1:def 3;
A14:    s9.x = s.x by A12,FUNCT_1:47;
A15:    x in dom s /\ A9 by A12,RELAT_1:61;
        then x in dom s & x <> a by A4,XBOOLE_0:def 4;
        then s.x <> c by A5,A7,A9,FUNCT_1:def 4;
        then
A16:    not y in {c} by A13,A14,TARSKI:def 1;
        x in dom s by A15,XBOOLE_0:def 4;
        then y in B by A6,A13,A14,FUNCT_1:def 3;
        hence thesis by A16,XBOOLE_0:def 5;
      end;
      assume
A17:  y in B9;
      then y in B by XBOOLE_0:def 5;
      then consider x being object such that
A18:  x in dom s and
A19:  y = s.x by A6,FUNCT_1:def 3;
A20:  x in A9 or x in {a} by A5,A18,XBOOLE_0:def 3;
      not y in {c} by A17,XBOOLE_0:def 5;
      then x <> a by A19,TARSKI:def 1;
      then x in dom s /\ A9 by A18,A20,TARSKI:def 1,XBOOLE_0:def 4;
      then x in dom s9 & s9.x = s.x by FUNCT_1:48,RELAT_1:61;
      hence y in rng s9 by A19,FUNCT_1:def 3;
    end;
    then
A21: rng s9 = B9 by TARSKI:2;
    now
      let x be object;
      thus x in dom(g|A9) implies x in dom(f*s9)
      proof
        assume x in dom(g|A9);
        then
A22:    x in dom g /\ A9 by RELAT_1:61;
        then
A23:    x in A9 by XBOOLE_0:def 4;
A24:    x in dom g by A22,XBOOLE_0:def 4;
        x in A by A23,ZFMISC_1:136;
        then x in dom g /\ A by A24,XBOOLE_0:def 4;
        then
A25:    x in dom(f*s) by A8,RELAT_1:61;
        then
A26:    s.x in dom f by FUNCT_1:11;
        x in dom s by A25,FUNCT_1:11;
        then x in dom s /\ A9 by A23,XBOOLE_0:def 4;
        then
A27:    x in dom s9 by RELAT_1:61;
        then s9.x = s.x by FUNCT_1:47;
        hence thesis by A26,A27,FUNCT_1:11;
      end;
      assume
A28:  x in dom(f*s9);
      then
A29:  x in dom s9 by FUNCT_1:11;
      then
A30:  x in dom s /\ A9 by RELAT_1:61;
      then
A31:  x in dom s by XBOOLE_0:def 4;
      s9.x in dom f by A28,FUNCT_1:11;
      then s.x in dom f by A29,FUNCT_1:47;
      then x in dom(g|A) by A8,A31,FUNCT_1:11;
      then x in dom g /\ A by RELAT_1:61;
      then
A32:  x in dom g by XBOOLE_0:def 4;
      x in A9 by A30,XBOOLE_0:def 4;
      then x in dom g /\ A9 by A32,XBOOLE_0:def 4;
      hence x in dom(g|A9) by RELAT_1:61;
    end;
    then
A33: dom(g|A9) = dom(f*s9) by TARSKI:2;
    a in C9;
    then a in dom g by FUNCT_2:def 1;
    then a in dom g /\ A by A9,XBOOLE_0:def 4;
    then a in dom(f*s) & g.a = (f*s).a by A8,FUNCT_1:48,RELAT_1:61;
    then
A34: g.a = f.c by FUNCT_1:12;
    B9 \/ {c} = B \/ {c} by XBOOLE_1:39;
    then
A35: B = B9 \/ {c} by A10,ZFMISC_1:40;
A36: dom s9 = A9 by A5,RELAT_1:62,XBOOLE_1:7;
A37: for x being object st x in dom(g|A9) holds (g|A9).x = (f*s9).x
    proof
      let x be object;
      assume x in dom(g|A9);
      then
A38:  x in dom g /\ A9 by RELAT_1:61;
      then
A39:  x in A9 by XBOOLE_0:def 4;
      then
A40:  x in A by ZFMISC_1:136;
      x in dom g by A38,XBOOLE_0:def 4;
      then x in dom g /\ A by A40,XBOOLE_0:def 4;
      then x in dom(f*s) by A8,RELAT_1:61;
      then
A41:  x in dom s by FUNCT_1:11;
      then x in dom s /\ A9 by A39,XBOOLE_0:def 4;
      then
A42:  x in dom s9 by RELAT_1:61;
      then
A43:  s9.x = s.x by FUNCT_1:47;
      thus (g|A9).x = g.x by A39,FUNCT_1:49
        .= (f*s).x by A8,A40,FUNCT_1:49
        .= f.(s.x) by A41,FUNCT_1:13
        .= (f*s9).x by A42,A43,FUNCT_1:13;
    end;
    then
A44: g|A9 = f*s9 by A33,FUNCT_1:2;
    now
      let y be object;
      thus y in g.:A9 implies y in f.:B9
      proof
        assume y in g.:A9;
        then consider x being object such that
A45:    x in dom g and
A46:    x in A9 and
A47:    y = g.x by FUNCT_1:def 6;
        x in dom g /\ A9 by A45,A46,XBOOLE_0:def 4;
        then
A48:    x in dom(g|A9) by RELAT_1:61;
        then x in dom s9 by A33,FUNCT_1:11;
        then
A49:    s9.x in B9 by A21,FUNCT_1:def 3;
        y = (f*s9).x by A44,A46,A47,FUNCT_1:49;
        then
A50:    y = f.(s9.x) by A33,A48,FUNCT_1:12;
        s9.x in dom f by A33,A48,FUNCT_1:11;
        hence thesis by A50,A49,FUNCT_1:def 6;
      end;
      assume y in f.:B9;
      then consider x being object such that
      x in dom f and
A51:  x in B9 and
A52:  y = f.x by FUNCT_1:def 6;
      set x9 = s9".x;
A53:  x9 in A9 by A11,A36,A21,A51,FUNCT_1:32;
      A9 c= C9 by FINSUB_1:def 5;
      then x9 in C9 by A53;
      then
A54:  x9 in dom g by FUNCT_2:def 1;
      s9.x9 = x by A11,A21,A51,FUNCT_1:35;
      then y = (f*s9).x9 by A36,A52,A53,FUNCT_1:13
        .= g.x9 by A44,A53,FUNCT_1:49;
      hence y in g.:A9 by A53,A54,FUNCT_1:def 6;
    end;
    then
A55: f.:B9 = g.:A9 by TARSKI:2;
A56: not c in B9 by ZFMISC_1:56;
    now
      per cases;
      suppose
A57:    A9 = {};
        B9 c= C by FINSUB_1:def 5;
        then B9 c= dom f by FUNCT_2:def 1;
        then
A58:    B9 = {} by A55,A57;
        thus F $$(A,g) = f.c by A1,A34,A57,SETWISEO:17
          .= F $$(B,f) by A1,A35,A58,SETWISEO:17;
      end;
      suppose
A59:    A9 <> {};
        A9 c= C9 by FINSUB_1:def 5;
        then A9 c= dom g by FUNCT_2:def 1;
        then
A60:    B9 <> {} by A55,A59;
        thus F $$(A,g) = F.(F $$(A9,g),g.a) by A1,A4,A59,Th2
          .= F.(F $$(B9,f),f.c) by A3,A34,A11,A36,A21,A33,A37,A59,FUNCT_1:2
          .= F $$(B,f) by A1,A35,A56,A60,Th2;
      end;
    end;
    hence thesis;
  end;
A61: X[{}.C9]
  proof
    assume
A62: {}.C9 <> {} or F is having_a_unity;
    let B;
    given s such that
A63: dom s = {}.C9 & rng s = B & s is one-to-one and
    g|({}.C9) = f*s;
    B,{} are_equipotent by A63,WELLORD2:def 4;
    then
A64: B = {}.C by CARD_1:26;
    F $$({}.C9,g) = the_unity_wrt F by A1,A62,SETWISEO:31;
    hence thesis by A1,A62,A64,SETWISEO:31;
  end;
  for A holds X[A] from SETWISEO:sch 2(A61,A2);
  hence thesis;
end;
