reserve V for Universe,
  a,b,x,y,z,x9,y9 for Element of V,
  X for Subclass of V,
  o,p,q,r,s,t,u,a1,a2,a3,A,B,C,D for set,
  K,L,M for Ordinal,
  n for Element of omega,
  fs for finite Subset of omega,
  e,g,h for Function,
  E for non empty set,
  f for Function of VAR,E,
  k,k1 for Element of NAT,
  v1,v2,v3 for Element of VAR,
  H,H9 for ZF-formula;

theorem Th21:
  X is closed_wrt_A1-A7 & E in X implies for H,v1 st Diagram(H,E)
  in X holds Diagram(All(v1,H),E) in X
proof
  assume that
A1: X is closed_wrt_A1-A7 and
A2: E in X;
  let H,v1 such that
A3: Diagram(H,E) in X;
  per cases;
  suppose
A4: not v1 in Free(H);
    then Free(H)=Free(H)\{v1} by ZFMISC_1:57;
    then
A5: Free(All(v1,H))=Free(H) by ZF_LANG1:62;
    Diagram(All(v1,H),E)=Diagram(H,E)
    proof
      thus Diagram(All(v1,H),E)c=Diagram(H,E)
      proof
        let p be object;
        assume p in Diagram(All(v1,H),E);
        then consider f such that
A6:     p=(f*decode)|code Free(All(v1,H)) and
A7:     f in St(All(v1,H),E) by Def4;
        f in St(H,E) by A7,ZF_MODEL:6;
        hence thesis by A5,A6,Def4;
      end;
      let p be object;
      assume p in Diagram(H,E);
      then consider f such that
A8:   p=(f*decode)|code Free(H) and
A9:   f in St(H,E) by Def4;
      for g being Function of VAR,E st for v2 st g.v2<>f.v2 holds v1=v2
      holds g in St(H,E)
      proof
        let g be Function of VAR,E;
        assume for v2 st g.v2<>f.v2 holds v1=v2;
        then
A10:    for v2 st v2 in Free(H) holds f.v2=g.v2 by A4;
        E,f |= H by A9,ZF_MODEL:def 4;
        then E,g |= H by A10,ZF_LANG1:75;
        hence thesis by ZF_MODEL:def 4;
      end;
      then f in St(All(v1,H),E) by A9,ZF_MODEL:6;
      hence thesis by A5,A8,Def4;
    end;
    hence thesis by A3;
  end;
  suppose
A11: v1 in Free(H);
    reconsider m=E as Element of V by A2;
    set n= x".v1;
    set fs=code Free(H);
A12: Diagram('not' H,E) c= Funcs(fs,E)
    proof
      let p be object;
      assume p in Diagram('not' H,E);
      then
A13:  ex f being Function of VAR,E st p=(f*decode)|code Free('not' H) & f
      in St('not' H,E) by Def4;
      Free('not' H)=Free H by ZF_LANG1:60;
      hence thesis by A13,Lm3;
    end;
A14: fs\{n}=(code Free H)\(code {v1}) by Lm6
      .=code((Free H)\{v1}) by Lm1,FUNCT_1:64;
    then
A15: fs\{n}=code Free(All(v1,H)) by ZF_LANG1:62;
A16: Diagram('not' H,E) in X by A1,A2,A3,Th19;
    then reconsider Dn=Diagram('not' H,E) as Element of V;
    set C={x: x in Funcs(fs\{n},m) & ex u st {[n,u]} \/ x in Dn};
A17: Funcs(fs\{n},m) in X by A1,A2,Th9;
    {v1}c=Free(H) by A11,ZFMISC_1:31;
    then Free(H)=(Free(H)\{v1}) \/ {v1} by XBOOLE_1:45;
    then
A18: fs=code(Free(H)\{v1}) \/ code {v1} by RELAT_1:120
      .=code(Free(H)\{v1}) \/ {n} by Lm6;
A19: Funcs(fs\{n},m)\C=Diagram(All(v1,H),E)
    proof
      thus Funcs(fs\{n},m)\C c= Diagram(All(v1,H),E)
      proof
        let p be object;
        assume
A20:    p in Funcs(fs\{n},m)\C;
        then consider h such that
A21:    p=h and
        dom h = fs\{n} and
        rng h c= E by FUNCT_2:def 2;
        consider f such that
A22:    h=(f*decode)|(fs\{n}) by A20,A21,Lm11;
A23:    not p in C by A20,XBOOLE_0:def 5;
        f in St(All(v1,H),E)
        proof
          assume
A24:      not f in St(All(v1,H),E);
A25:      for ff being Function of VAR,E st p=(ff*decode)|code Free(All(
          v1,H)) holds ff in St(H,E)
          proof
            let ff be Function of VAR,E;
            assume
A26:        p=(ff*decode)|code Free(All(v1,H));
            (ff*decode)|(fs\{n}) in Funcs(fs\{n},m) by Lm3;
            then reconsider x=((ff*decode)|(fs\{n})) as Element of V by A17,Th1
;
            assume not ff in St(H,E);
            then ff in St('not' H,E) by ZF_MODEL:4;
            then (ff*decode)|code Free('not' H) in Dn by Def4;
            then ((ff*decode)|((fs\{n}) \/ {n})) in Dn by A18,A14,ZF_LANG1:60;
            then
A27:        ((ff*decode)|(fs\{n})) \/ ((ff*decode)|{n}) in Dn by RELAT_1:78;
            dom((ff*decode)|{n})={n} by Lm3;
            then {[n,((ff*decode)|{n}).n]} \/ x in Dn by A27,GRFUNC_1:7;
            hence contradiction by A15,A20,A23,A26;
          end;
          then f in St(H,E) by A15,A21,A22;
          then consider e being Function of VAR,E such that
A28:      for v2 st e.v2<>f.v2 holds v2=v1 and
A29:      not e in St(H,E) by A24,ZF_MODEL:6;
          now
            thus
A30:        fs\{n}=dom((e*decode)|(fs\{n})) & fs\{n}=dom((f*decode)|
            (fs\{n})) by Lm3;
            let q be object;
            assume
A31:        q in fs\{n};
            then reconsider p99 = q as Element of omega;
A32:        q= x".x.card p99 by Lm2;
            not q in {n} by A31,XBOOLE_0:def 5;
            then
A33:        x.card p99 <> v1 by A32,TARSKI:def 1;
            thus ((e*decode)|(fs\{n})).q=(e*decode).q by A30,A31,FUNCT_1:47
              .=e.(x.card p99) by A32,Lm4
              .=f.(x.card p99) by A28,A33
              .=(f*decode).q by A32,Lm4
              .=((f*decode)|(fs\{n})).q by A30,A31,FUNCT_1:47;
          end;
          hence contradiction by A15,A21,A22,A25,A29,FUNCT_1:2;
        end;
        hence thesis by A15,A21,A22,Def4;
      end;
      let p be object;
      assume p in Diagram(All(v1,H),E);
      then consider f such that
A34:  p=(f*decode)|code Free(All(v1,H)) and
A35:  f in St(All(v1,H),E) by Def4;
A36:  p in Funcs(fs\{n},m) by A15,A34,Lm3;
      then reconsider x=p as Element of V by A17,Th1;
A37:  now
A38:    fs=code Free('not' H) by ZF_LANG1:60;
        given u such that
A39:    {[n,u]} \/ x in Dn;
        consider h being Function of VAR,E such that
A40:    {[n,u]} \/ x=(h*decode)|fs by A12,A39,Lm11;
        now
          reconsider g={[n,u]} as Function;
          thus
A41:      dom((h*decode)|(fs\{n}))=(fs\{n}) & dom((f*decode)|(fs\{n}
          ))=(fs\{n}) by Lm3;
          let q be object such that
A42:      q in (fs\{n});
          ((h*decode)|(fs\{n})) c= ((h*decode)|fs) by RELAT_1:75,XBOOLE_1:36;
          hence ((h*decode)|(fs\{n})).q=((h*decode)|fs).q by A41,A42,GRFUNC_1:2
            .=((f*decode)|(fs\{n})).q by A15,A34,A40,A41,A42,GRFUNC_1:15;
        end;
        then
A43:    h in St(All(v1,H),E) by A15,A35,Lm10,FUNCT_1:2;
        ex hh being Function of VAR,E st {[n,u]} \/ x=(hh*decode)|code
        Free('not' H) & hh in St('not' H,E) by A39,Def4;
        then h in St('not' H,E) by A40,A38,Lm10;
        then not h in St(H,E) by ZF_MODEL:4;
        hence contradiction by A43,ZF_MODEL:6;
      end;
      now
        assume x in C;
        then ex y st y=x & y in Funcs(fs\{n},m) & ex u st {[n,u]} \/ y in Dn;
        hence contradiction by A37;
      end;
      hence thesis by A36,XBOOLE_0:def 5;
    end;
    n in fs by A11,Lm5;
    then C in X by A1,A2,A16,A12,Th11;
    hence thesis by A1,A17,A19,Th4;
  end;
end;
