reserve Al for QC-alphabet;
reserve PHI for Consistent Subset of CQC-WFF(Al),
        p,q,r,s for Element of CQC-WFF(Al),
        A for non empty set,
        J for interpretation of Al,A,
        v for Element of Valuations_in(Al,A),
        m,n,i,j,k for Nat,
        l for CQC-variable_list of k,Al,
        P for QC-pred_symbol of k,Al,
        x,y,z for bound_QC-variable of Al,
        b for QC-symbol of Al,
        PR for FinSequence of [:set_of_CQC-WFF-seq(Al),Proof_Step_Kinds:];
reserve Al2 for Al-expanding QC-alphabet,
        J2 for interpretation of Al2,A,
        Jp for interpretation of Al,A,
        v2 for Element of Valuations_in(Al2,A),
        vp for Element of Valuations_in(Al,A);

theorem Th9:
  Jp = J2|QC-pred_symbols(Al) & vp = v2|bound_QC-variables(Al)
  implies (J2,v2 |= Al2-Cast(r) iff Jp,vp |= r)
proof
  defpred T[Element of CQC-WFF(Al)] means
      for J2,Jp,v2,vp holds
       Jp = J2|QC-pred_symbols(Al) & vp = v2|bound_QC-variables(Al) implies
    (( J2,v2 |= Al2-Cast($1) ) iff Jp,vp |= $1);
A1: T[VERUM(Al)]
  proof
    let J2, Jp, v2, vp;
    J2,v2 |= VERUM(Al2) by VALUAT_1:32;
    hence thesis by VALUAT_1:32;
  end;
A2: for k,P,l holds T[P!l]
  proof
    let k,P,l;
    let J2, Jp, v2, vp;
    assume
A3: Jp = J2|QC-pred_symbols(Al) & vp = v2|bound_QC-variables(Al);
    set p = P!l;
    the_arity_of P = len l by Th1;
    then
A4: P!l = <*P*>^l by QC_LANG1:def 12;
    P is QC-pred_symbol of k,Al2  & l is CQC-variable_list of k,Al2
    by Th5, Th6;
    then consider P2 being QC-pred_symbol of k,Al2,
    l2 being CQC-variable_list of k,Al2 such that
A5: P=P2 & l=l2;
A6: the_arity_of P2 = len l2 by Th1;
A7: v2*'l2 = vp*'l
    proof
A8:   bound_QC-variables(Al) c= bound_QC-variables(Al2) by Th4;
A9:   for j st 1 <= j & j <= len l holds l.j in bound_QC-variables(Al) iff
       l.j in bound_QC-variables(Al2)
      proof
        let j such that
A10:    1 <= j & j <= len l;
        thus l.j in bound_QC-variables(Al) implies
         l.j in bound_QC-variables(Al2) by A8;
        hereby
          assume l.j in bound_QC-variables(Al2);
          len l = k by CARD_1:def 7;
          then j in Seg k by A10, FINSEQ_1:1;
          then j in dom l by FINSEQ_1:89;
          hence l.j in bound_QC-variables(Al) by FUNCT_1:102;
        end;
      end;
      set t1 ={l.i: 1 <= i & i <= len l & l.i in bound_QC-variables(Al)};
      set t2 ={l.i: 1 <= i & i <= len l & l.i in bound_QC-variables(Al2)};
A11:  t1=t2
      proof
        thus t1 c= t2
        proof
         let x be object;
         assume x in t1;
         then consider i such that
A12:     x = l.i & 1 <= i & i <= len l & l.i in bound_QC-variables(Al);
         x = l.i & 1 <= i & i <= len l & l.i in bound_QC-variables(Al2)
           by A9,A12;
         hence x in t2;
        end;
        thus t2 c= t1
        proof
         let x be object;
         assume x in t2;
         then consider i such that
A13:     x = l.i & 1 <= i & i <= len l & l.i in bound_QC-variables(Al2);
         x = l.i & 1 <= i & i <= len l & l.i in bound_QC-variables(Al)
           by A9,A13;
         hence x in t1;
        end;
      end;
A14:  still_not-bound_in l = still_not-bound_in l2 by A5,A11;
A15:  vp|still_not-bound_in l
       = v2|(bound_QC-variables(Al) /\ still_not-bound_in l) by A3,RELAT_1:71
      .= v2|still_not-bound_in l by XBOOLE_1:28;
      v2*'l2 = l*(vp|still_not-bound_in l) by A5,A14,A15,SUBLEMMA:59
      .= vp*'l by SUBLEMMA:59;
      hence thesis;
    end;
A16:J2,v2 |= Al2-Cast(P!l) implies Jp,vp |= P!l
    proof
      assume J2,v2 |= Al2-Cast(P!l);
      then J2,v2 |= P2!l2 by A4,A5,A6,QC_LANG1:def 12;
      then Valid(P2!l2,J2).v2 = TRUE by VALUAT_1:def 7;
      then (l2 'in' (J2.P2)).v2 = TRUE by VALUAT_1:6;
      then
A17:  vp*'l in (J2.P2) by A7,VALUAT_1:def 4;
      vp*'l in (Jp.P) by FUNCT_1:49,A3,A5,A17;
      then (l 'in' (Jp.P)).vp = TRUE by VALUAT_1:def 4;
      then Valid(P!l,Jp).vp = TRUE by VALUAT_1:6;
      hence thesis by VALUAT_1:def 7;
    end;
    (not J2,v2 |= Al2-Cast(P!l)) implies (not Jp,vp |= P!l)
    proof
      assume not J2,v2 |= Al2-Cast(P!l);
      then not J2,v2 |= P2!l2 by A4,A5,A6,QC_LANG1:def 12;
      then not Valid(P2!l2,J2).v2 = TRUE by VALUAT_1:def 7;
      then not (l2 'in' (J2.P2)).v2 = TRUE by VALUAT_1:6;
      then
A18:  not vp*'l in (J2.P2) by A7,VALUAT_1:def 4;
      not vp*'l in (Jp.P) by FUNCT_1:49,A3,A5,A18;
      then not (l 'in' (Jp.P)).vp = TRUE by VALUAT_1:def 4;
      then not Valid(P!l,Jp).vp = TRUE by VALUAT_1:6;
      hence thesis by VALUAT_1:def 7;
    end;
    hence thesis by A16;
  end;
A19: for p holds T[p] implies T['not' p]
  proof
    let p;
    assume
A20:T[p];
    let J2, Jp, v2, vp;
    assume
A21:Jp = J2|QC-pred_symbols(Al) & vp = v2|bound_QC-variables(Al);
    per cases;
    suppose
A22:  not J2,v2 |= Al2-Cast(p);
      then
A23:  not Jp,vp |= p by A20,A21;
      J2,v2 |= 'not' (Al2-Cast(p)) by A22, VALUAT_1:17;
      hence thesis by A23,VALUAT_1:17;
    end;
    suppose
A24:  J2,v2 |= Al2-Cast(p);
      then
A25:  Jp,vp |= p by A20,A21;
      not J2,v2 |= 'not' (Al2-Cast(p)) by VALUAT_1:17, A24;
      hence thesis by A25,VALUAT_1:17;
    end;
  end;
A26: for p,r holds (T[p] & T[r]) implies T[p '&' r]
  proof
    let p,r;
    assume
A27:T[p] & T[r];
    let J2, Jp, v2, vp;
    assume
A28: Jp = J2|QC-pred_symbols(Al) & vp = v2|bound_QC-variables(Al);
A29:J2,v2 |= (Al2-Cast(p '&' r)) implies Jp,vp |= p '&' r
    proof
      assume J2,v2 |= Al2-Cast(p '&' r);
      then J2,v2 |= (Al2-Cast(p)) '&' (Al2-Cast(r));
      then J2,v2 |= Al2-Cast(p) & J2,v2 |= Al2-Cast(r) by VALUAT_1:18;
      then Jp,vp |= p & Jp,vp |= r by A27, A28;
      hence Jp,vp |= p '&' r by VALUAT_1:18;
    end;
    Jp,vp |= p '&' r implies J2,v2 |= (Al2-Cast(p '&' r))
    proof
      assume Jp,vp |= p '&' r;
      then Jp,vp |= p & Jp,vp |= r by VALUAT_1:18;
      then J2,v2 |= Al2-Cast(p) & J2,v2 |= Al2-Cast(r) by A27,A28;
      then J2,v2 |= (Al2-Cast(p)) '&' (Al2-Cast(r)) by VALUAT_1:18;
      hence J2,v2 |= Al2-Cast(p '&' r);
    end;
    hence thesis by A29;
  end;
A30: for x,r holds T[r] implies T[All(x,r)]
  proof
    let x,r;
    assume
A31:T[r];
    let J2, Jp, v2, vp;
    assume
A32: Jp = J2|QC-pred_symbols(Al) & vp = v2|bound_QC-variables(Al);
A33:J2,v2 |= Al2-Cast(All(x,r)) implies Jp,vp |= All(x,r)
    proof
      assume J2,v2 |= Al2-Cast(All(x,r));
      then
A34:  J2,v2 |= All(Al2-Cast(x),Al2-Cast(r));
      for vp1 being Element of Valuations_in(Al,A) st
           for y being bound_QC-variable of Al st x <> y holds vp1.y = vp.y
           holds Jp,vp1 |= r
      proof
        let vp1 be Element of Valuations_in(Al,A) such that
A35:    for y being bound_QC-variable of Al st x <> y holds vp1.y = vp.y;
        set s = Al2-Cast(x) .--> vp1.x;
A36:    s = {Al2-Cast(x)} --> vp1.x by FUNCOP_1:def 9;
        set v21 = v2 +* s;
        v2 is Element of Funcs(bound_QC-variables(Al2),A) by VALUAT_1:def 1;
        then
A37:    dom v2 = bound_QC-variables(Al2) & rng v2 c= A by FUNCT_2:92;
        dom s = {Al2-Cast(x)} by A36;
        then dom v21 = dom v2 \/ {Al2-Cast(x)} by FUNCT_4:def 1;
        then
A38:    dom v21 = bound_QC-variables(Al2) by A37,XBOOLE_1:12;
A39:    rng v2 \/ {vp1.x} c= A by A37, XBOOLE_1:8;
        rng s = {vp1.x} by A36, FUNCOP_1:8;
        then rng v21 c= rng v2 \/ {vp1.x} by FUNCT_4:17;
        then rng v21 c= A by A39;
        then v21 is Element of Funcs(bound_QC-variables(Al2),A)
             by A38, FUNCT_2:def 2;
        then reconsider v21 as Element of Valuations_in(Al2,A)
         by VALUAT_1:def 1;
        for y being bound_QC-variable of Al2 st Al2-Cast(x) <> y
           holds v21.y = v2.y by FUNCT_4:83;
        then
A40:    J2,v21 |= Al2-Cast(r) by A34,VALUAT_1:29;
        vp1 is Element of Funcs(bound_QC-variables(Al),A) by VALUAT_1:def 1;
        then
A41:    dom vp1 = bound_QC-variables(Al) by FUNCT_2:92
               .= (dom v21) /\ bound_QC-variables(Al) by A38, Th4, XBOOLE_1:28;
        for c being object st c in dom vp1 holds vp1.c = v21.c
        proof
          let c be object such that
A42:      c in dom vp1;
          per cases;
          suppose
A43:        c = Al2-Cast(x);
            then c in dom s by FUNCOP_1:74;
            hence v21.c = s.c by FUNCT_4:13
                 .= vp1.c by A43,FUNCOP_1:72;
          end;
          suppose
A44:        c <> Al2-Cast(x);
            reconsider c as bound_QC-variable of Al by A41,A42,XBOOLE_0:def 4;
            v21.c = v2.c by A44,FUNCT_4:83
                      .= (v2|bound_QC-variables(Al)).c by FUNCT_1:49
                      .= vp1.c by A32,A35,A44;
            hence thesis;
          end;
        end;
        then v21|bound_QC-variables(Al) = vp1 by FUNCT_1:46, A41;
        hence Jp,vp1 |= r by A32,A31,A40;
      end;
      hence Jp,vp |= All(x,r) by VALUAT_1:29;
    end;
    Jp,vp |= All(x,r) implies J2,v2 |= Al2-Cast(All(x,r))
    proof
      assume
A45:   Jp,vp |= All(x,r);
      for v21 being Element of Valuations_in(Al2,A) st
           for y being bound_QC-variable of Al2 st Al2-Cast(x) <> y holds
           v21.y = v2.y holds J2,v21 |= Al2-Cast(r)
      proof
        let v21 be Element of Valuations_in(Al2,A) such that
A46:    for y being bound_QC-variable of Al2 st Al2-Cast(x) <> y holds
              v21.y = v2.y;
        set s = x .--> v21.(Al2-Cast(x));
A47:    s = {x} --> v21.(Al2-Cast(x)) by FUNCOP_1:def 9;
        set vp1 = vp +* s;
        vp is Element of Funcs(bound_QC-variables(Al),A) by VALUAT_1:def 1;
        then
A48:    dom vp = bound_QC-variables(Al) & rng vp c= A by FUNCT_2:92;
        dom s = {x} by A47;
        then dom vp1 = dom vp \/ {x} by FUNCT_4:def 1;
        then
A49:    dom vp1 = bound_QC-variables(Al) by A48,XBOOLE_1:12;
A50:    rng vp \/ {v21.(Al2-Cast(x))} c= A by A48, XBOOLE_1:8;
        rng s = {v21.(Al2-Cast(x))} by A47, FUNCOP_1:8;
        then rng vp1 c= rng vp \/ {v21.(Al2-Cast(x))} by FUNCT_4:17;
        then rng vp1 c= A by A50;
        then vp1 is Element of Funcs(bound_QC-variables(Al),A)
             by A49, FUNCT_2:def 2;
        then reconsider vp1 as Element of Valuations_in(Al,A)
         by VALUAT_1:def 1;
        for y being bound_QC-variable of Al st x <> y
           holds vp1.y = vp.y by FUNCT_4:83;
        then
A51:    Jp,vp1 |= r by A45,VALUAT_1:29;
        v21 is Element of Funcs(bound_QC-variables(Al2),A) by VALUAT_1:def 1;
        then
A52:    dom v21 = bound_QC-variables(Al2) by FUNCT_2:92;
        vp1 is Element of Funcs(bound_QC-variables(Al),A) by VALUAT_1:def 1;
        then
A53:    dom vp1 = bound_QC-variables(Al) by FUNCT_2:92
            .= (dom v21) /\ bound_QC-variables(Al) by A52, Th4, XBOOLE_1:28;
        for c being object st c in dom vp1 holds vp1.c = v21.c
        proof
          let c be object such that
A54:      c in dom vp1;
          per cases;
          suppose
A55:        c = x;
            then c in dom s by FUNCOP_1:74;
            then vp1.c = s.x by A55,FUNCT_4:13 .= v21.c by A55,FUNCOP_1:72;
            hence vp1.c = v21.c;
          end;
          suppose
A56:        c <> x;
A57:        c in bound_QC-variables(Al) by A53,A54,XBOOLE_0:def 4;
            vp1 is Element of Funcs(bound_QC-variables(Al),A)
             by VALUAT_1:def 1;
            then dom vp1 = bound_QC-variables(Al) by FUNCT_2:92;
            then
A58:         dom vp1 c= bound_QC-variables(Al2) by Th4;
            vp1.c = vp.c by A56,FUNCT_4:83
                      .= v2.c by A32,A57,FUNCT_1:49
                      .= v21.c by A56,A46,A54,A58;
            hence thesis;
          end;
        end;
        then v21|bound_QC-variables(Al) = vp1 by FUNCT_1:46, A53;
        hence J2,v21 |= Al2-Cast(r) by A32,A31,A51;
      end;
      then J2,v2 |= All(Al2-Cast(x),Al2-Cast(r)) by VALUAT_1:29;
      hence J2,v2 |= Al2-Cast(All(x,r));
    end;
    hence thesis by A33;
  end;
A59: for r,s being Element of CQC-WFF(Al)
  for x being bound_QC-variable of Al for k
  for l being CQC-variable_list of k, Al for P being
  QC-pred_symbol of k,Al holds T[VERUM(Al)] & T[P!l] &
  (T[r] implies T['not' r]) & (T[r] & T[s] implies T[r '&' s]) &
  (T[r] implies T[All(x, r)]) by A1,A2,A19,A26,A30;
  for r being Element of CQC-WFF(Al) holds T[r] from CQC_LANG:sch 1(A59);
  hence thesis;
end;
