reserve A for preIfWhileAlgebra,
  C,I,J for Element of A;
reserve S for non empty set,
  T for Subset of S,
  s for Element of S;
reserve f for ExecutionFunction of A,S,T;

theorem
  for A being free ECIW-strict preIfWhileAlgebra
  for g being Function of [:S, ElementaryInstructions A:], S
  for s0 being Element of S ex f being ExecutionFunction of A, S, T
  st f|[:S, ElementaryInstructions A:] = g & for s being Element of S
  for C,I being Element of A st not f iteration_terminates_for I\;C, f.(s,C)
  holds f.(s, while(C,I)) = s0
proof
  let A be free ECIW-strict preIfWhileAlgebra;
  let g be Function of [:S, ElementaryInstructions A:], S;
  let s0 be Element of S;
  reconsider Ss0 = S-->s0 as Element of Funcs(S,S) by FUNCT_2:9;
  set Z = Funcs(S,S);
  deffunc ElemF(Element of A) = (curry' g).$1;
A1: for I being Element of A st I in ElementaryInstructions A
  holds ElemF(I) in Z
  proof
    let I be Element of A;
    assume
A2: I in ElementaryInstructions A;
    then reconsider B = ElementaryInstructions A as non empty set;
    reconsider I as Element of B by A2;
    reconsider g as Function of [:S,B:],S;
    (curry' g).I is Element of Z;
    hence thesis;
  end;
  reconsider idS = id S as Element of Z by FUNCT_2:126;
  deffunc ConF((Element of Z), Element of Z) = $2*$1 qua Element of Z;
  deffunc IfF((Element of Z), (Element of Z), Element of Z)
  = (($2,T)+*$3)*$1 qua Element of Z;
  deffunc WhiF((Element of Z), Element of Z)
  = ((T,Ss0) iter ($1*$2))*$1 qua Element of Z;
  consider h being Function of the carrier of A, Z such that
A3: for I being Element of A st I in ElementaryInstructions A
  holds h.I = ElemF(I) and
A4: h.EmptyIns A = idS and
A5: for I1,I2 being Element of A holds h.(I1\;I2) = ConF(h.I1,h.I2) and
A6: for C,I1,I2 being Element of A
  holds h.if-then-else(C,I1,I2) = IfF(h.C,h.I1,h.I2) and
A7: for C,I being Element of A holds h.while(C,I) = WhiF(h.C,h.I)
  from IndDef(A1);
  h in Funcs(the carrier of A, Z) by FUNCT_2:8;
  then uncurry' h in Funcs([:S, the carrier of A:], S) by FUNCT_6:11;
  then reconsider f = uncurry' h as Function of [:S, the carrier of A:], S
  by FUNCT_2:66;
A8: dom h = the carrier of A by FUNCT_2:def 1;
A9: f is complying_with_empty-instruction
  proof
    let s be Element of S;
    idS.s = s;
    hence thesis by A4,A8,FUNCT_5:39;
  end;
A10: f is complying_with_catenation
  proof
    let s be Element of S;
    let I1,I2 be Element of A;
A11: dom (h.(I1\;I2)) = S by FUNCT_2:def 1;
A12: dom (h.I1) = S by FUNCT_2:def 1;
A13: dom (h.I2) = S by FUNCT_2:def 1;
    thus f.(s,I1 \; I2) = (h.(I1\;I2)).s by A8,A11,FUNCT_5:39
      .= ((h.I2)*(h.I1)).s by A5
      .= (h.I2).((h.I1).s) by FUNCT_2:15
      .= (h.I2).(f.(s,I1)) by A8,A12,FUNCT_5:39
      .= f.(f.(s,I1),I2) by A8,A13,FUNCT_5:39;
  end;
A14: f complies_with_if_wrt T
  proof
    let s be Element of S;
    let C, I1,I2 be Element of A;
A15: dom (h.if-then-else(C,I1,I2)) = S by FUNCT_2:def 1;
A16: dom (h.C) = S by FUNCT_2:def 1;
A17: dom (h.I1) = S by FUNCT_2:def 1;
A18: dom (h.I2) = S by FUNCT_2:def 1;
A19: f.(s,if-then-else(C,I1,I2))
    = (h.if-then-else(C,I1,I2)).s by A8,A15,FUNCT_5:39
      .= IfF(h.C,h.I1,h.I2).s by A6
      .= ((h.I1,T)+*(h.I2)).((h.C).s) by FUNCT_2:15;
A20: f.(s,C) = (h.C).s by A8,A16,FUNCT_5:39;
    hereby
      assume f.(s,C) in T;
      hence f.(s,if-then-else(C,I1,I2)) = (h.I1).(f.(s,C)) by A17,A19,A20,Th4
        .= f.(f.(s,C),I1) by A8,A17,FUNCT_5:39;
    end;
    assume f.(s,C) nin T;
    hence f.(s,if-then-else(C,I1,I2)) = (h.I2).(f.(s,C)) by A18,A19,A20,Th5
      .= f.(f.(s,C),I2) by A8,A18,FUNCT_5:39;
  end;
  f complies_with_while_wrt T
  proof
    let s be Element of S;
    let C, I be Element of A;
A21: dom (h.while(C,I)) = S by FUNCT_2:def 1;
A22: dom (h.C) = S by FUNCT_2:def 1;
A23: dom (h.I) = S by FUNCT_2:def 1;
A24: dom ((h.C)*(h.I)) = S by FUNCT_2:def 1;
A25: f.(s,while(C,I)) = (h.while(C,I)).s by A8,A21,FUNCT_5:39
      .= WhiF(h.C,h.I).s by A7
      .= ((T,Ss0) iter ((h.C)*(h.I))).((h.C).s) by FUNCT_2:15;
A26: f.(s,C) = (h.C).s by A8,A22,FUNCT_5:39;
A27: rng ((h.C)*(h.I)) c= S;
    A28: now
      let z be Element of S;
      thus (Ss0*((h.C)*(h.I))).z = Ss0.(((h.C)*(h.I)).z) by FUNCT_2:15
        .= s0 by FUNCOP_1:7
        .= Ss0.z by FUNCOP_1:7;
    end;
    hereby
      assume f.(s,C) in T;
      hence f.(s,while(C,I))
      = ((T,Ss0) iter ((h.C)*(h.I))).(((h.C)*(h.I)).(f.(s,C)))
      by A24,A25,A26,A27,A28,Th11,FUNCT_2:63
        .= ((T,Ss0) iter ((h.C)*(h.I))).((h.C).((h.I).(f.(s,C))))
      by FUNCT_2:15
        .= (((T,Ss0) iter ((h.C)*(h.I)))*(h.C)).((h.I).(f.(s,C)))
      by FUNCT_2:15
        .= (((T,Ss0) iter ((h.C)*(h.I)))*(h.C)).(f.(f.(s,C),I))
      by A8,A23,FUNCT_5:39
        .= (h.while(C,I)).(f.(f.(s,C),I)) by A7
        .= f.(f.(f.(s,C),I),while(C,I)) by A8,A21,FUNCT_5:39;
    end;
    thus thesis by A24,A25,A26,A27,Th12;
  end;
  then reconsider f as ExecutionFunction of A, S, T by A9,A10,A14,Def32;
  take f;
  dom f = [:S, the carrier of A:] by FUNCT_2:def 1;
  then
A29: [:S, ElementaryInstructions A:] c= dom f by ZFMISC_1:95;
A30: dom g = [:S, ElementaryInstructions A:] by FUNCT_2:def 1;
A31: dom f /\ [:S, ElementaryInstructions A:] = [:S, ElementaryInstructions
  A:] by A29,XBOOLE_1:28;
  now
    let a be object;
    assume
A32: a in dom g;
    then consider s,I being object such that
A33: s in S and
A34: I in ElementaryInstructions A and
A35: a = [s,I] by ZFMISC_1:def 2;
    reconsider s as Element of S by A33;
    reconsider I as Element of A by A34;
    reconsider EI = (curry' g).I as Element of Z by A1,A34;
    g in Funcs([:S, ElementaryInstructions A:], S) by FUNCT_2:8;
    then curry' g in Funcs(ElementaryInstructions A, Z) by A32,FUNCT_6:10;
    then
A36: dom curry' g = ElementaryInstructions A by FUNCT_2:92;
A37: dom EI = S by FUNCT_2:92;
A38: dom (h.I) = S by FUNCT_2:92;
    thus g.a = g.(s,I) by A35
      .= EI.s by A34,A36,A37,FUNCT_5:34
      .= (h.I).s by A3,A34
      .= f.(s,I) by A8,A38,FUNCT_5:39
      .= f.a by A35;
  end;
  hence f|[:S, ElementaryInstructions A:] = g by A30,A31,FUNCT_1:46;
  let s be Element of S;
  let C,I be Element of A;
  assume
A39: not f iteration_terminates_for I\;C, f.(s,C);
A40: dom (h.while(C,I)) = S by FUNCT_2:def 1;
A41: dom (h.C) = S by FUNCT_2:def 1;
A42: dom ((h.C)*(h.I)) = S by FUNCT_2:def 1;
A43: f.(s,while(C,I)) = (h.while(C,I)).s by A8,A40,FUNCT_5:39
    .= WhiF(h.C,h.I).s by A7
    .= ((T,Ss0) iter ((h.C)*(h.I))).((h.C).s) by FUNCT_2:15;
A44: f.(s,C) = (h.C).s by A8,A41,FUNCT_5:39;
A45: rng ((h.C)*(h.I)) c= S;
  rng h c= Z;
  then h = curry' f by FUNCT_5:48;
  then (curry' f).(I\;C) = (h.C)*(h.I) by A5;
  then (h.C)*(h.I) orbit f.(s,C) c= T by A39,Th87;
  hence f.(s, while(C,I)) = Ss0.(f.(s,C)) by A42,A43,A44,A45,Def7
    .= s0 by FUNCOP_1:7;
end;
