reserve s for State of SCM+FSA,
  a, c for read-write Int-Location,
  aa, bb, cc,
  dd, x for Int-Location,
  f for FinSeq-Location,
  I, J for MacroInstruction of SCM+FSA,
  Ig for good MacroInstruction of SCM+FSA,
  i, k for Nat,
  p for Instruction-Sequence of SCM+FSA;
reserve I for MacroInstruction of SCM+FSA;

theorem Th23:
 for Ig being good really-closed MacroInstruction of SCM+FSA holds
  s.intloc 0 = 1 & k = s.cc-s.bb+1 & (ProperForUpBody a, bb, cc,
Ig, s,p or Ig is parahalting)
 implies DataPart IExec(for-up(a, bb, cc, Ig),p, s) =
  DataPart StepForUp(a,bb,cc,Ig,p,s).k
proof let Ig be good really-closed MacroInstruction of SCM+FSA;
  set I = Ig;
  assume that
A1: s.intloc 0 = 1 and
A2: k = s.cc-s.bb+1 and
A3: ProperForUpBody a,bb,cc,I,s,p or I is parahalting;
  set scb1 = s.cc-s.bb+1;
  set SF = StepForUp(a,bb,cc,I,p,s);
A4: ProperForUpBody a,bb,cc,I,s,p by A3,Th15;
  set i3 = a := bb;
  set aux = 1-stRWNotIn ({a, bb, cc} \/ UsedILoc I);
  set i0 = aux := cc;
  set i1 = SubFrom(aux, bb);
  set i2 = AddTo(aux, intloc 0);
  reconsider IB = I ";" AddTo(a, intloc 0) ";" SubFrom(aux, intloc 0)
     as really-closed MacroInstruction of SCM+FSA;
  set I03 = i0 ";" i1 ";" i2 ";" i3;
  set s1 = IExec(I03,p,s),
      p1 = p;
A5: s1.intloc 0 = Exec(i3, IExec(i0 ";" i1 ";" i2,p,s)).intloc 0 by SCMFSA6C:6
    .= IExec(i0 ";" i1 ";" i2,p,s).intloc 0 by SCMFSA_2:63
    .= Exec(i2, IExec(i0 ";" i1,p,s)).intloc 0 by SCMFSA6C:6
    .= IExec(i0 ";" i1,p,s).intloc 0 by SCMFSA_2:64
    .= Exec(i1, Exec(i0, Initialized s)).intloc 0 by SCMFSA6C:8
    .= Exec(i0, Initialized s).intloc 0 by SCMFSA_2:65
    .= (Initialized s).intloc 0 by SCMFSA_2:63
    .= 1 by SCMFSA_M:9;
  then
A6: DataPart Initialized s1 = DataPart s1 by SCMFSA_M:19;
  set Ex1 = ExitsAtWhile>0(aux, IB,p1, Initialized s1);
  set SW1 = StepWhile>0(aux, IB,p1, Initialized s1);
A7: ProperBodyWhile>0 aux, IB, s1,p1 by A1,A3,Lm1;
  then
A8: ProperBodyWhile>0 aux, IB, Initialized s1,p1 by A6,SCMFSA9A:38;
  set s2 = s+*(aux, s.cc-s.bb+1)+*(a, s.bb),
      p2 = p;
  set SW2 = StepWhile>0(aux,IB,p2,s2);
A9: DataPart s1 = DataPart s2 by A1,Th14;
  then DataPart SW1.k = DataPart SW2.k by A6,A8,SCMFSA9A:34;
  then
A10: SW1.k.aux = SW2.k.aux by SCMFSA_M:2;
A11: WithVariantWhile>0 aux, IB, s1,p1 by A1,A3,Lm1;
  then
A12: WithVariantWhile>0 aux, IB, Initialized s1,p1 by A5,A6,A7,SCMFSA9A:41;
  consider K being Nat such that
A13:  ExitsAtWhile>0(aux, IB, p1, Initialized s1) = K and
A14: (StepWhile>0(aux,IB,p1,Initialized s1).K).aux <= 0 and
A15:    (for i being Nat
     st (StepWhile>0(aux,IB,p1,Initialized s1).i).aux <= 0
     holds K <= i) &
    DataPart Comput(p1 +* while>0(aux, IB),
        Initialize Initialized s1,
       (LifeSpan(p1 +* while>0(aux, IB),Initialize Initialized s1)))
     = DataPart StepWhile>0(aux,IB,p1,Initialized s1).K
      by A12,A8,SCMFSA9A:def 6;
  DataPart SW1.K = DataPart SW2.K by A6,A8,A9,SCMFSA9A:34;
  then
A16: SW1.K.aux = SW2.K.aux by SCMFSA_M:2;
A17: now
    assume
A18: K < scb1;
    then SF.K.aux + K < 0+scb1 by A14,A16,XREAL_1:8;
    hence contradiction by A1,A4,A18,Th17;
  end;
  SF.k.aux+k = scb1 by A1,A2,A4,Th17;
  then K <= k by A2,A15,A10;
  then
A19: Ex1 = k by A2,A13,A17,XXREAL_0:1;
  set MI = for-up(a, bb, cc, I);
  set I4 = while>0( aux, IB);
  I4 is_halting_on s1,p1 by A7,A11,SCMFSA9A:27;
  hence DataPart IExec(MI,p,s) = DataPart IExec(I4,p1,s1) by SFMASTR1:9
    .= DataPart SW1.Ex1 by A8,A12,SCMFSA9A:36
    .= DataPart StepForUp(a,bb,cc,I,p,s).k by A6,A8,A9,A19,SCMFSA9A:34;
end;
