reserve A for QC-alphabet;
reserve X,T for Subset of CQC-WFF(A);
reserve F,G,H,p,q,r,t for Element of CQC-WFF(A);
reserve s,h for QC-formula of A;
reserve x,y for bound_QC-variable of A;
reserve f for FinSequence of [:CQC-WFF(A),Proof_Step_Kinds:];
reserve i,j for Element of NAT;

theorem
  F is closed & (X \/ {F})|- G implies X |- F => G
proof
  assume that
A1: F is closed and
A2: (X \/ {F}) |- G;
  G in Cn(X \/ {F}) by A2;
  then consider f such that
A3: f is_a_proof_wrt (X \/ {F}) and
A4: Effect f = G by CQC_THE1:36;
  f <> {} by A3;
  then
A5: G = (f.len f)`1 by A4,CQC_THE1:def 6;
  defpred P[Nat] means 1 <= $1 & $1 <= len f implies for H st H = (f.$1)`1
  holds X|- F => H;
A6: for n being Nat st for k being Nat st k < n holds P[k] holds P[n]
  proof
    let n be Nat such that
A7: for k being Nat st k < n holds 1 <= k & k <= len f implies for H
    st H = (f.k)`1 holds X|- F => H;
    assume that
A8: 1 <= n and
A9: n <= len f;
A10: f,n is_a_correct_step_wrt (X \/ {F}) by A3,A8,A9;
    let H such that
A11: H = (f.n)`1;
    now
     (f.n)`2 = 0 or ... or (f.n)`2 = 9 by A8,A9,CQC_THE1:23;
      then per cases;
      suppose
        (f.n)`2 = 0;
        then H in X \/ {F} by A11,A10,CQC_THE1:def 4;
        then
A12:    H in X or H in {F} by XBOOLE_0:def 3;
        now
          per cases by A12,TARSKI:def 1;
          suppose
A13:        H in X;
            X c= Cn(X) by CQC_THE1:17;
            then
A14:        X|- H by A13;
            X|- H => (F => H) by CQC_THE1:59;
            hence thesis by A14,CQC_THE1:55;
          end;
          suppose
            H = F;
            hence thesis by CQC_THE1:59;
          end;
        end;
        hence thesis;
      end;
      suppose
        (f.n)`2 = 1;
        then H = VERUM(A) by A11,A10,CQC_THE1:def 4;
        hence thesis by CQC_THE1:59,LUKASI_1:46;
      end;
      suppose
        (f.n)`2 = 2;
        then ex p st H = ('not' p => p) => p by A11,A10,CQC_THE1:def 4;
        then H is valid by CQC_THE1:61;
        hence thesis by CQC_THE1:59,LUKASI_1:61;
      end;
      suppose
        (f.n)`2 = 3;
        then ex p,q st H = p => ('not' p => q) by A11,A10,CQC_THE1:def 4;
        then H is valid by CQC_THE1:62;
        hence thesis by CQC_THE1:59,LUKASI_1:61;
      end;
      suppose
        (f.n)`2 = 4;
        then
        ex p,q,r st H = (p => q) => ('not'(q '&' r) => 'not'(p '&' r)) by A11
,A10,CQC_THE1:def 4;
        then H is valid by CQC_THE1:63;
        hence thesis by CQC_THE1:59,LUKASI_1:61;
      end;
      suppose
        (f.n)`2 = 5;
        then ex p,q st H = p '&' q => q '&' p by A11,A10,CQC_THE1:def 4;
        then H is valid by CQC_THE1:64;
        hence thesis by CQC_THE1:59,LUKASI_1:61;
      end;
      suppose
        (f.n)`2 = 6;
        then ex p,x st H = All(x,p) => p by A11,A10,CQC_THE1:def 4;
        then H is valid by CQC_THE1:66;
        hence thesis by CQC_THE1:59,LUKASI_1:61;
      end;
      suppose
        (f.n)`2 = 7;
        then consider i,j being Nat, p,q such that
A15:    1 <= i and
A16:    i < n and
A17:    1 <= j and
A18:    j < i and
A19:    p = (f.j)`1 and
A20:    q = H and
A21:    (f.i)`1 = p => q by A11,A10,CQC_THE1:def 4;
        i <= len f by A9,A16,XXREAL_0:2;
        then
A22:    X|- F => (p => q) by A7,A15,A16,A21;
        X|- (F => (p => q)) => ((F => p) => (F => q)) by CQC_THE1:59;
        then
A23:    X|- (F => p) => (F => q) by A22,CQC_THE1:55;
        j < n by A16,A18,XXREAL_0:2;
        then
A24:    j <= len f by A9,XXREAL_0:2;
        j < n by A16,A18,XXREAL_0:2;
        then X|- F => p by A7,A17,A19,A24;
        hence thesis by A20,A23,CQC_THE1:55;
      end;
      suppose
        (f.n)`2 = 8;
        then consider i being Nat,p,q,x such that
A25:    1 <= i and
A26:    i < n and
A27:    (f.i)`1 = p => q and
A28:    not x in still_not-bound_in p and
A29:    H = p => All(x,q) by A11,A10,CQC_THE1:def 4;
A30:    X|- All(x,p => q) => (p => All(x,q)) by A28,Th74,CQC_THE1:59;
        not x in still_not-bound_in F by A1,QC_LANG1:def 31;
        then
A31:    X|- All(x,F => (p => q)) => (F => All(x,p => q)) by Th74,CQC_THE1:59;
        i <= len f by A9,A26,XXREAL_0:2;
        then X|- All(x,F => (p => q)) by A7,A25,A26,A27,Th90;
        then X|- F => All(x,p => q) by A31,CQC_THE1:55;
        hence thesis by A29,A30,LUKASI_1:59;
      end;
      suppose
        (f.n)`2 = 9;
        then consider i being Nat,x,y,s such that
A32:    1 <= i and
A33:    i < n and
A34:    s.x in CQC-WFF(A) & s.y in CQC-WFF(A) and
A35:    not x in still_not-bound_in s and
A36:    s.x = (f.i)`1 and
A37:    H = s.y by A11,A10,CQC_THE1:def 4;
        reconsider s1 = s.x, s2 = s.y as Element of CQC-WFF(A) by A34;
A38:    X|- All(x,s1) => s2 by A35,Th25,CQC_THE1:59;
        not x in still_not-bound_in F by A1,QC_LANG1:def 31;
        then
A39:    X|- All(x,F => s1) => (F => All(x,s1)) by Th74,CQC_THE1:59;
        i <= len f by A9,A33,XXREAL_0:2;
        then X|- All(x,F => s1) by A7,A32,A33,A36,Th90;
        then X |- F => All(x,s1) by A39,CQC_THE1:55;
        hence thesis by A37,A38,LUKASI_1:59;
      end;
    end;
    hence thesis;
  end;
A40: for n be Nat holds P[n] from NAT_1:sch 4(A6);
  1 <= len f by A3,CQC_THE1:25;
  hence thesis by A40,A5;
end;
