reserve x,y,z,x1,x2,x3,x4,y1,y2,s for Variable,
  M for non empty set,
  a,b for set,
  i,j,k for Element of NAT,
  m,m1,m2,m3,m4 for Element of M,
  H,H1,H2 for ZF-formula,
  v,v9,v1,v2 for Function of VAR,M;

theorem Th2:
  not y in variables_in H implies (x in Free H implies Free (H/(x,y
)) = (Free H \ {x}) \/ {y}) & (not x in Free H implies Free (H/(x,y)) = Free H)
proof
  defpred P[ZF-formula] means not y in variables_in $1 implies (x in Free $1
  implies Free ($1/(x,y)) = (Free $1 \ {x}) \/ {y}) & (not x in Free $1 implies
  Free ($1/(x,y)) = Free $1);
A1: for H1,H2 st P[H1] & P[H2] holds P[H1 '&' H2]
  proof
    let H1,H2;
    assume that
A2: P[H1] and
A3: P[H2] and
A4: not y in variables_in (H1 '&' H2);
A5: Free ((H1/(x,y)) '&' (H2/(x,y))) = Free (H1/(x,y)) \/ Free (H2/(x,y))
    by ZF_LANG1:61;
    set H = H1 '&' H2;
A6: Free (H1 '&' H2) = Free H1 \/ Free H2 by ZF_LANG1:61;
A7: variables_in (H1 '&' H2) = variables_in H1 \/ variables_in H2 by
ZF_LANG1:141;
A8: H/(x,y) = (H1/(x,y)) '&' (H2/(x,y)) by ZF_LANG1:158;
    thus x in Free H implies Free (H/(x,y)) = (Free H \ {x}) \/ {y}
    proof
      assume
A9:   x in Free H;
A10:  now
        assume
A11:    not x in Free H1;
        then Free H1 = Free H1 \ { x} by ZFMISC_1:57;
        hence
        Free (H/(x,y)) = (Free H1 \ {x}) \/ (Free H2 \ {x}) \/ {y} by A2,A3,A4
,A6,A5,A7,A8,A9,A11,XBOOLE_0:def 3,XBOOLE_1:4
          .= (Free H \ {x}) \/ {y} by A6,XBOOLE_1:42;
      end;
A12:  now
        assume
A13:    not x in Free H2;
        then Free H2 = Free H2 \ { x} by ZFMISC_1:57;
        hence
        Free (H/(x,y)) = (Free H1 \ {x}) \/ (Free H2 \ {x}) \/ {y} by A2,A3,A4
,A6,A5,A7,A8,A9,A13,XBOOLE_0:def 3,XBOOLE_1:4
          .= (Free H \ {x}) \/ {y} by A6,XBOOLE_1:42;
      end;
      now
        assume that
A14:    x in Free H1 and
A15:    x in Free H2;
        thus Free (H/(x,y)) = {y} \/ (Free H1 \ {x}) \/ (Free H2 \ {x}) \/ {y}
        by A2,A3,A4,A5,A7,A8,A14,A15,XBOOLE_0:def 3,XBOOLE_1:4
          .= {y} \/ ((Free H1 \ {x}) \/ (Free H2 \ {x})) \/ {y} by XBOOLE_1:4
          .= (Free H \ {x}) \/ {y} \/ {y} by A6,XBOOLE_1:42
          .= (Free H \ {x}) \/ ({y} \/ {y}) by XBOOLE_1:4
          .= (Free H \ {x}) \/ {y};
      end;
      hence thesis by A10,A12;
    end;
    assume not x in Free (H1 '&' H2);
    hence thesis by A2,A3,A4,A6,A5,A7,XBOOLE_0:def 3,ZF_LANG1:158;
  end;
A16: for H,z st P[H] holds P[All(z,H)]
  proof
    let H,z;
    assume that
A17: P[H] and
A18: not y in variables_in All(z,H);
    set G = All(z,H)/(x,y);
A19: Free All(z,H) = Free H \ {z} by ZF_LANG1:62;
    z = x or z <> x;
    then consider s such that
A20: z = x & s = y or z <> x & s = z;
A21: G = All(s,H/(x,y)) by A20,ZF_LANG1:159,160;
A22: Free All(s,H/(x,y)) = Free (H/(x,y)) \ {s} by ZF_LANG1:62;
A23: variables_in All(z,H) = variables_in H \/ {z} by ZF_LANG1:142;
    thus x in Free All(z,H) implies Free G = (Free All(z,H) \ {x}) \/ {y}
    proof
      assume
A24:  x in Free All(z,H);
      then
A25:  not x in {z} by A19,XBOOLE_0:def 5;
      thus Free G c= (Free All(z,H) \ {x}) \/ {y}
      proof
        let a be object;
        assume
A26:    a in Free G;
        then a in (Free H \ {x}) \/ {y} by A17,A18,A19,A22,A23,A21,A24,
XBOOLE_0:def 3,def 5;
        then a in Free H \ {x} or a in {y} by XBOOLE_0:def 3;
        then
A27:    a in Free H & not a in {x} or a in {y} by XBOOLE_0:def 5;
        not a in {z} by A20,A22,A21,A25,A26,TARSKI:def 1,XBOOLE_0:def 5;
        then a in Free All(z,H) & not a in {x} or a in {y} by A19,A27,
XBOOLE_0:def 5;
        then a in Free All(z,H) \ {x} or a in {y} by XBOOLE_0:def 5;
        hence thesis by XBOOLE_0:def 3;
      end;
      let a be object;
      assume a in (Free All(z,H) \ {x}) \/ {y};
      then a in Free All(z,H) \ {x} or a in {y} by XBOOLE_0:def 3;
      then
A28:  a in Free All(z,H) & not a in {x} or a in {y} & a = y by TARSKI:def 1
,XBOOLE_0:def 5;
      then a in Free H & not a in {x} or a in {y} by A19,XBOOLE_0:def 5;
      then a in Free H \ {x} or a in {y} by XBOOLE_0:def 5;
      then
A29:  a in (Free H \ {x}) \/ {y} by XBOOLE_0:def 3;
      not a in {z} by A18,A19,A23,A28,XBOOLE_0:def 3,def 5;
      hence thesis by A20,A17,A18,A19,A22,A23,A21,A24,A25,A29,TARSKI:def 1
,XBOOLE_0:def 3,def 5;
    end;
    assume not x in Free All(z,H);
    then
A30: not x in Free H or x in {z} by A19,XBOOLE_0:def 5;
A31: Free All(z,H) c= variables_in All(z,H) by ZF_LANG1:151;
A32: now
      assume
A33:  x in Free H;
      thus Free G = Free All(z,H)
      proof
        thus Free G c= Free All(z,H)
        proof
          let a be object;
          assume
A34:      a in Free G;
          then
A35:      not a in {y} by A20,A22,A21,A30,A33,TARSKI:def 1,XBOOLE_0:def 5;
          a in (Free H \ {z}) \/ {y} by A20,A17,A18,A22,A23,A21,A30,A33,A34,
TARSKI:def 1,XBOOLE_0:def 3,def 5;
          hence thesis by A19,A35,XBOOLE_0:def 3;
        end;
        let a be object;
        assume
A36:    a in Free All(z,H);
        then a <> y by A18,A31;
        then
A37:    not a in {y} by TARSKI:def 1;
        a in (Free H \ {x}) \/ {y} by A20,A19,A30,A33,A36,TARSKI:def 1
,XBOOLE_0:def 3;
        hence thesis by A20,A17,A18,A22,A23,A21,A30,A33,A37,TARSKI:def 1
,XBOOLE_0:def 3,def 5;
      end;
    end;
    now
      assume not x in Free H;
      then Free G = (Free H \ {z}) \ {y} & not y in Free All(z,H) or Free G =
      Free H \ {z} by A20,A17,A18,A22,A23,A21,A31,XBOOLE_0:def 3,ZFMISC_1:57;
      hence thesis by A19,ZFMISC_1:57;
    end;
    hence thesis by A32;
  end;
A38: for x1,x2 holds P[x1 '=' x2] & P[x1 'in' x2]
  proof
    let x1,x2;
A39: x2 = x or x2 <> x;
    x1 = x or x1 <> x;
    then consider y1,y2 such that
A40: x1 <> x & x2 <> x & y1 = x1 & y2 = x2 or x1 = x & x2 <> x & y1 = y
& y2 = x2 or x1 <> x & x2 = x & y1 = x1 & y2 = y or x1 = x & x2 = x & y1 = y &
    y2 = y by A39;
    (x1 '=' x2)/(x,y) = y1 '=' y2 by A40,ZF_LANG1:152;
    then
A41: Free ((x1 '=' x2)/(x,y)) = {y1,y2} by ZF_LANG1:58;
A42: Free (x1 '=' x2) = {x1,x2} by ZF_LANG1:58;
A43: variables_in (x1 '=' x2) = {x1,x2} by ZF_LANG1:138;
    thus P[x1 '=' x2]
    proof
      assume not y in variables_in (x1 '=' x2);
      thus x in Free (x1 '=' x2) implies Free ((x1 '=' x2)/(x,y)) = (Free (x1
      '=' x2) \ {x}) \/ {y}
      proof
        assume
A44:    x in Free (x1 '=' x2);
        thus Free ((x1 '=' x2)/(x,y)) c= (Free (x1 '=' x2) \ {x}) \/ {y} by Th1
;
        let a be object;
        assume a in (Free (x1 '=' x2) \ {x}) \/ {y};
        then a in Free (x1 '=' x2) \ {x} or a in {y} by XBOOLE_0:def 3;
        then a in Free (x1 '=' x2) & not a in {x} or a in {y} by XBOOLE_0:def 5
;
        then (a = x1 or a = x2) & a <> x or a = y by A42,TARSKI:def 1,def 2;
        hence thesis by A40,A41,A42,A44,TARSKI:def 2;
      end;
      assume not x in Free (x1 '=' x2);
      hence thesis by A42,A43,ZF_LANG1:182;
    end;
A45: Free (x1 'in' x2) = {x1,x2} by ZF_LANG1:59;
    assume not y in variables_in (x1 'in' x2);
    (x1 'in' x2)/(x,y) = y1 'in' y2 by A40,ZF_LANG1:154;
    then
A46: Free ((x1 'in' x2)/(x,y)) = {y1,y2} by ZF_LANG1:59;
    thus x in Free (x1 'in' x2) implies Free ((x1 'in' x2)/(x,y)) = (Free (x1
    'in' x2) \ {x}) \/ {y}
    proof
      assume
A47:  x in Free (x1 'in' x2);
      thus Free ((x1 'in' x2)/(x,y)) c= (Free (x1 'in' x2) \ {x}) \/ {y} by Th1
;
      let a be object;
      assume a in (Free (x1 'in' x2) \ {x}) \/ {y};
      then a in Free (x1 'in' x2) \ {x} or a in {y} by XBOOLE_0:def 3;
      then a in Free (x1 'in' x2) & not a in {x} or a in {y} by XBOOLE_0:def 5;
      then (a = x1 or a = x2) & a <> x or a = y by A45,TARSKI:def 1,def 2;
      hence thesis by A40,A46,A45,A47,TARSKI:def 2;
    end;
    assume not x in Free (x1 'in' x2);
    hence thesis by A41,A42,A46,A45,A43,ZF_LANG1:182;
  end;
A48: for H st P[H] holds P['not' H]
  proof
    let H;
A49: Free 'not' H = Free H by ZF_LANG1:60;
    Free 'not'(H/(x,y)) = Free (H/(x,y)) by ZF_LANG1:60;
    hence thesis by A49,ZF_LANG1:140,156;
  end;
  for H holds P[H] from ZF_LANG1:sch 1(A38,A48,A1,A16);
  hence thesis;
end;
