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 Th97:
  A is free & [s, I\;J] in TerminatingPrograms(A,S,T,f) implies
  [s,I] in TerminatingPrograms(A,S,T,f) &
  [f.(s,I), J] in TerminatingPrograms(A,S,T,f)
proof
  set TP = TerminatingPrograms(A,S,T,f);
  assume that
A1: A is free and
A2: [s, I\;J] in TP;
  reconsider P = TP \ {[s, I\;J]} as Subset of [:S, the carrier of A:];
A3: [:S, ElementaryInstructions A:] c= P
  proof
    let x,y be object;
    assume
A4: [x,y] in [:S, ElementaryInstructions A:];
A5: I <> I\;J by A1,Th73;
A6: J <> I\;J by A1,Th73;
    y in ElementaryInstructions A by A4,ZFMISC_1:87;
    then
A7: y <> I\;J by A5,A6,Th50;
A8: [:S, ElementaryInstructions A:] c= TP by Def35;
    [x,y] <> [s, I\;J] by A7,XTUPLE_0:1;
    then [x,y] nin {[s, I\;J]} by TARSKI:def 1;
    hence thesis by A4,A8,XBOOLE_0:def 5;
  end;
A9: [:S, {EmptyIns A}:] c= P
  proof
    let x,y be object;
    assume
A10: [x,y] in [:S, {EmptyIns A}:];
    then y in {EmptyIns A} by ZFMISC_1:87;
    then y = EmptyIns A by TARSKI:def 1;
    then
A11: y <> I\;J by A1,Th72;
A12: [:S, {EmptyIns A}:] c= TP by Def35;
    [x,y] <> [s, I\;J] by A11,XTUPLE_0:1;
    then [x,y] nin {[s, I\;J]} by TARSKI:def 1;
    hence thesis by A10,A12,XBOOLE_0:def 5;
  end;
  set rr = s, IJ = I\;J;
A13: now
    let s be Element of S;
    let C,I,J be Element of A;
    hereby
      assume that
A14:  [s,C] in P and
A15:  [f.(s,C), I] in P and
A16:  f.(s, C) in T;
A17:  [s,C] in TP by A14,ZFMISC_1:56;
A18:  [f.(s,C), I] in TP by A15,ZFMISC_1:56;
A19:  IJ <> if-then-else(C,I,J) by A1,Th73;
A20:  [s, if-then-else(C,I,J)] in TP by A16,A17,A18,Def35;
      [rr,IJ] <> [s, if-then-else(C,I, J)] by A19,XTUPLE_0:1;
      hence [s, if-then-else(C,I,J)] in P by A20,ZFMISC_1:56;
    end;
    hereby
      assume that
A21:  [s,C] in P and
A22:  [f.(s,C), J] in P and
A23:  f.(s, C) nin T;
A24:  [s,C] in TP by A21,ZFMISC_1:56;
A25:  [f.(s,C), J] in TP by A22,ZFMISC_1:56;
A26:  IJ <> if-then-else(C,I,J) by A1,Th73;
A27:  [s, if-then-else(C,I,J)] in TP by A23,A24,A25,Def35;
      [rr,IJ] <> [s, if-then-else(C,I, J)] by A26,XTUPLE_0:1;
      hence [s, if-then-else(C,I,J)] in P by A27,ZFMISC_1:56;
    end;
    assume
A28: [s,C] in P;
    given r being non empty FinSequence of S such that
A29: r.1 = f.(s,C) and
A30: r.len r nin T and
A31: for i being Nat st 1 <= i & i < len r
    holds r.i in T & [r.i, I\;C] in P & r.(i+1) = f.(r.i, I\;C);
A32: now
      let i be Nat;
      assume that
A33:  1 <= i and
A34:  i < len r;
      [r.i, I\;C] in P by A31,A33,A34;
      hence r.i in T & [r.i, I\;C] in TP & r.(i+1) = f.(r.i, I\;C)
      by A31,A33,A34,ZFMISC_1:56;
    end;
A35: [s,C] in TP by A28,ZFMISC_1:56;
A36: while(C,I) <> IJ by A1,Th73;
A37: [s, while(C,I)] in TP by A29,A30,A32,A35,Def35;
    [s, while(C,I)] <> [rr,IJ] by A36,XTUPLE_0:1;
    hence [s, while(C,I)] in P by A37,ZFMISC_1:56;
  end;
  hereby
    assume
A38: [rr,I] nin TP;
    now
      let q be Element of S;
      let C,I9,J9 be Element of A;
      assume that
A39:  [q,I9] in P and
A40:  [f.(q,I9), J9] in P;
A41:  [q,I9] in TP by A39,ZFMISC_1:56;
A42:  [f.(q,I9), J9] in TP by A40,ZFMISC_1:56;
A43:  q <> rr or I9\;J9 <> I\;J by A1,A38,A41,Th73;
A44:  [q, I9\;J9] in TP by A41,A42,Def35;
      [q,I9\;J9] <> [rr,I\;J] by A43,XTUPLE_0:1;
      hence [q, I9\;J9] in P by A44,ZFMISC_1:56;
    end;
    then for s being Element of S for C,I,J being Element of A holds
    ([s,I] in P & [f.(s,I), J] in P implies [s, I\;J] in P) &
    ([s,C] in P & [f.(s,C), I] in P & f.(s, C) in T
    implies [s, if-then-else(C,I,J)] in P) &
    ([s,C] in P & [f.(s,C), J] in P & f.(s, C) nin T
    implies [s, if-then-else(C,I,J)] in P) & ([s,C] in P &
    (ex r being non empty FinSequence of S st r.1 = f.(s,C) & r.len r nin T &
    for i being Nat st 1 <= i & i < len r
    holds r.i in T & [r.i, I\;C] in P & r.(i+1) = f.(r.i, I\;C))
    implies [s, while(C,I)] in P) by A13;
    then TP c= P by A3,A9,Def35;
    hence contradiction by A2,ZFMISC_1:56;
  end;
  assume
A45: [f.(s,I), J] nin TP;
  now
    let q be Element of S;
    let C,I9,J9 be Element of A;
    assume that
A46: [q,I9] in P and
A47: [f.(q,I9), J9] in P;
A48: [q,I9] in TP by A46,ZFMISC_1:56;
A49: [f.(q,I9), J9] in TP by A47,ZFMISC_1:56;
    f.(q,I9) <> f.(s,I) or J9 <> J by A45,A47,ZFMISC_1:56;
    then
A50: q <> s or I9\;J9 <> I\;J by A1,Th73;
A51: [q, I9\;J9] in TP by A48,A49,Def35;
    [q,I9\;J9] <> [rr,I\;J] by A50,XTUPLE_0:1;
    hence [q, I9\;J9] in P by A51,ZFMISC_1:56;
  end;
  then for s being Element of S for C,I,J being Element of A holds
  ([s,I] in P & [f.(s,I), J] in P implies [s, I\;J] in P) &
  ([s,C] in P & [f.(s,C), I] in P & f.(s, C) in T
  implies [s, if-then-else(C,I,J)] in P) &
  ([s,C] in P & [f.(s,C), J] in P & f.(s, C) nin T
  implies [s, if-then-else(C,I,J)] in P) & ([s,C] in P &
  (ex r being non empty FinSequence of S st r.1 = f.(s,C) & r.len r nin T &
  for i being Nat st 1 <= i & i < len r
  holds r.i in T & [r.i, I\;C] in P & r.(i+1) = f.(r.i, I\;C))
  implies [s, while(C,I)] in P) by A13;
  then TP c= P by A3,A9,Def35;
  hence contradiction by A2,ZFMISC_1:56;
end;
