reserve v,x for object;
reserve D,V,A for set;
reserve n for Nat;
reserve p,q for PartialPredicate of D;
reserve f,g for BinominativeFunction of D;
reserve D for non empty set;
reserve d for Element of D;
reserve f,g for BinominativeFunction of D;
reserve p,q,r,s for PartialPredicate of D;

theorem
  f coincides_with p & dom p c= dom f &
  <*PP_and(r,p),f,p*> is SFHT of D implies
  <*p,PP_while(r,f),PP_and(PP_not(r),p)*> is SFHT of D
  proof
    set a = PP_and(r,p);
    set F = PP_while(r,f);
    set q = PP_and(PP_not(r),p);
    assume that
A1: f coincides_with p and
A2: dom p c= dom f and
A3: <*a,f,p*> is SFHT of D;
A4: dom a = {d where d is Element of D:
       d in dom r & r.d = FALSE or d in dom p & p.d = FALSE
       or d in dom r & r.d = TRUE & d in dom p & p.d = TRUE} by PARTPR_1:16;
    for d holds d in dom p & p.d = TRUE & d in dom F & F.d in dom q implies
     q.(F.d) = TRUE
    proof
      let d;
      assume that
A5:   d in dom p and
A6:   p.d = TRUE and
A7:   d in dom F and
A8:   F.d in dom q;
      consider n being Nat such that
A9:    for i being Nat st i <= n-1 holds
        d in dom(r*iter(f,i)) & (r*iter(f,i)).d = TRUE and
A10:  d in dom(r*iter(f,n)) and
A11:  (r*iter(f,n)).d = FALSE and
A12:  F.d = iter(f,n).d by A7,PARTPR_2:def 15;
      reconsider I = iter(f,n) as BinominativeFunction of D
      by FUNCT_7:86;
A13:  d in dom I by A10,FUNCT_1:11;
A14:  (r*I).d = r.(I.d) by A10,FUNCT_1:12;
      per cases by A8,PARTPR_1:17;
      suppose F.d in dom PP_not(r) & PP_not(r).(F.d) = FALSE;
        hence thesis by A11,A12,A14,PARTPR_1:def 2;
      end;
      suppose F.d in dom PP_not(r) & PP_not(r).(F.d) = TRUE &
        F.d in dom p & p.(F.d) = TRUE;
        hence thesis by PARTPR_1:18;
      end;
      suppose that
A15:    F.d in dom p and
A16:    p.(F.d) = FALSE;
        for i being Nat st i <= n & d in dom iter(f,i) & iter(f,i).d in dom p
         holds p.(iter(f,i).d) = TRUE
        proof
          defpred P[Nat] means $1 <= n implies
           for i being Nat st i <= $1 holds
            iter(f,i).d in dom p & d in dom iter(f,i) & p.(iter(f,i).d) = TRUE;
A17:      P[0]
          proof
            assume 0 <= n;
            let i be Nat;
            assume that
A18:        i <= 0;
A19:        i = 0 by A18,NAT_1:3;
A20:        iter(f,0) = id field f by FUNCT_7:68;
            dom f c= field f by XBOOLE_1:7;
            hence thesis by A2,A5,A6,A19,A20,FUNCT_1:18;
          end;
A21:      for k being Nat st P[k] holds P[k+1]
          proof
            let k be Nat;
            assume that
A22:        P[k] and
A23:        k+1 <= n;
            let i be Nat such that
A24:        i <= k+1;
A25:        k <= k+1 by NAT_1:11;
            per cases by A24,NAT_1:8;
            suppose i <= k;
              hence thesis by A22,A23,A25,XXREAL_0:2;
            end;
            suppose
A26:          i = k+1;
              set DD = iter(f,k).d;
A27:          k+1-1 <= n-1 by A23,XREAL_1:9;
A28:          d in dom(r*iter(f,k)) by A9,A27;
              then
A29:          d in dom iter(f,k) by FUNCT_1:11;
              iter(f,k) is BinominativeFunction of D by FUNCT_7:86;
              then reconsider DD as Element of D
              by A29,PARTFUN1:4;
A30:          DD in dom p by A22,A23,A25,XXREAL_0:2;
              (r*iter(f,k)).d = TRUE by A9,A27;
              then
A31:          r.DD = TRUE by A29,FUNCT_1:13;
A32:          DD in dom r by A28,FUNCT_1:11;
A33:          p.DD = TRUE by A22,A23,A25,XXREAL_0:2;
A34:          DD in dom a by A4,A30,A31,A32,A33;
A35:          a.DD = TRUE by A30,A31,A32,A33,PARTPR_1:18;
A36:          iter(f,k+1) = f*iter(f,k) by FUNCT_7:71;
A37:          f.DD = (f*iter(f,k)).d by A29,FUNCT_1:13;
              hence iter(f,i).d in dom p by A1,A22,A23,A25,A26,A36,XXREAL_0:2;
              thus d in dom iter(f,i) by A2,A26,A29,A30,A36,FUNCT_1:11;
              thus p.(iter(f,i).d) = TRUE
              by A1,A3,A2,A26,A30,A34,A35,A37,A36,Th11;
            end;
          end;
          for k being Nat holds P[k] from NAT_1:sch 2(A17,A21);
          hence thesis;
        end;
        hence q.(F.d) = TRUE by A12,A13,A15,A16;
      end;
    end;
    then <*p,F,q*> in SFHTs(D);
    hence thesis;
  end;
