reserve s, s1, s2 for State of SCM+FSA,
  p, p1 for Instruction-Sequence of SCM+FSA,
  a, b for Int-Location,
  d for read-write Int-Location,
  f for FinSeq-Location,
  I for MacroInstruction of SCM+FSA,
  J for good MacroInstruction of SCM+FSA,
  k, m for Nat;

theorem Th19:
 for J being good really-closed MacroInstruction of SCM+FSA holds
  s.a = k & (ProperTimesBody a,J,s,p or J is parahalting) & (s.
  intloc 0 = 1 or a is read-write) implies
   DataPart IExec(times(a,J),p,s) =
  DataPart StepTimes(a,J,p,s).k
proof let J be good really-closed MacroInstruction of SCM+FSA;
  set I = J;
  assume
A1: s.a = k;
  set ST = StepTimes(a,I,p,s);
  set au = 1-stRWNotIn ({a} \/ UsedILoc I);
  reconsider  ISu = I ";" SubFrom(au, intloc 0)
    as really-closed MacroInstruction of SCM+FSA;
  set s1 = Exec(au := a, Initialized s);
  set Is1 = Initialized s1;
  set SW = StepWhile>0(au, ISu, p, s1);
  set ISW = StepWhile>0(au, ISu, p, Is1);
  s1.intloc 0 = (Initialized s).intloc 0 by SCMFSA_2:63
    .= 1 by SCMFSA_M:9;
  then
A2: DataPart Is1 = DataPart s1 by SCMFSA_M:19;
  set WH = while>0 ( au, ISu );
  assume
A3: ProperTimesBody a,I,s,p or I is parahalting;
  then
A4: ProperTimesBody a,I,s,p by Th11;
  assume
A5: s.intloc 0 = 1 or a is read-write;
A6: ProperBodyWhile>0 au, ISu, s1, p
  proof
    let k be Nat;
    assume SW.k.au > 0;
    then
A7: k < s.a by A1,A4,A5,Th14;
    then
A8: ST.k.intloc 0 = 1 by A3,Th11,Th12;
    then
A9: DataPart ST.k = DataPart Initialized (ST.k) by SCMFSA_M:19;
    I is_halting_on ST.k,p+*times*(a,I) by A4,A7;
    then
A10: I is_halting_on Initialized ST.k,p+*times*(a,I) by A8,SCMFSA8B:42;
    Macro SubFrom(au, intloc 0)
     is_halting_on IExec(I,p+*times*(a,I),ST.k),p+*times*(a,I) by SCMFSA7B:19;
    then ISu is_halting_on
     Initialized ST.k,p+*times*(a,I) by A10,SFMASTR1:3;
    hence thesis by A9,SCMFSA8B:5;
  end;
  then
A11: DataPart ISW.k = DataPart SW.k by A2,SCMFSA9A:34;
A12: WithVariantWhile>0 au, ISu, Is1, p
  proof
    reconsider sa = s.a as Element of NAT by A1,ORDINAL1:def 12;
    deffunc U(State of SCM+FSA) = |.$1.au.|;
    consider f being Function of product the_Values_of SCM+FSA,NAT such
    that
A13: for x being Element of product the_Values_of SCM+FSA holds f
    .x = U(x) from FUNCT_2:sch 4;
A14: for x being State of SCM+FSA holds f.x = U(x)
     proof let x be State of SCM+FSA;
      reconsider x as Element of product the_Values_of SCM+FSA
        by CARD_3:107;
       f.x = U(x) by A13;
      hence thesis;
     end;
    take f;
    let k be Nat;
    DataPart ISW.k = DataPart SW.k by A2,A6,SCMFSA9A:34;
    then
A15: ISW.k.au = SW.k.au by SCMFSA_M:2;
    DataPart ISW.(k+1) = DataPart SW.(k+1) by A2,A6,SCMFSA9A:34;
    then
A16: ISW.(k+1).au = SW.(k+1).au by SCMFSA_M:2;
    per cases;
    suppose
A17:  k < s.a;
      then
A18:  k-k < s.a-k by XREAL_1:9;
A19:  ST.k.au+k = s.a by A4,A5,A17,Th13;
A20:  k+1 <= sa by A17,NAT_1:13;
      then
A21:  (k+1)-(k+1) <= s.a-(k+1) by XREAL_1:9;
A22:  ST.(k+1).au+(k+1) = s.a by A4,A5,A20,Th13;
      then
A23:  s.a = (ST.(k+1).au+1)+k;
A24:  f.(ISW.(k+1)) = |. ISW.(k+1).au .| by A14
        .= SW.(k+1).au by A16,A22,A21,ABSVALUE:def 1;
      f.(ISW.k) = |. ISW.k.au .| by A14
        .= SW.k.au by A15,A19,A18,ABSVALUE:def 1;
      hence thesis by A19,A23,A24,NAT_1:13;
    end;
    suppose
      k >= s.a;
      hence thesis by A1,A4,A5,A15,Th14;
    end;
  end;
A25: ProperBodyWhile>0 au, ISu, Is1, p
  proof
    let k be Nat;
    assume
A26: ISW.k.au > 0;
A27: DataPart ISW.k = DataPart SW.k by A2,A6,SCMFSA9A:34;
    then
A28: SW.k.au = ISW.k.au by SCMFSA_M:2;
    ISu is_halting_on SW.k, p+*WH by A6,A26,A28;
    hence thesis by A27,SCMFSA8B:5;
  end;
  then consider K being Nat such that
A29: ExitsAtWhile>0(au, ISu, p, Is1) = K and
A30: ISW.K.au <= 0 and
A31: for i being Nat st ISW.i.au <= 0 holds K <= i and
  DataPart Comput(p+*WH,(Initialize Is1),(LifeSpan(p+*WH,Initialize Is1)))
   = DataPart ISW.K by A12,SCMFSA9A:def 6;
 WH is_halting_on Is1,p by A25,A12,SCMFSA9A:27;
  then
A32: WH is_halting_on s1,p by A2,SCMFSA8B:5;
A33: DataPart IExec(WH,p,s1)
 = DataPart ISW.ExitsAtWhile>0(au, ISu, p, Is1) by A25,A12,SCMFSA9A:36;
A34: DataPart ISW.K = DataPart SW.K by A2,A6,SCMFSA9A:34;
  SW.k.au = 0 by A1,A4,A5,Th14;
  then ISW.k.au = 0 by A11,SCMFSA_M:2;
  then
A35: K <= k by A31;
  then
A36: SW.K.au+K = k by A1,A4,A5,Th13;
  K-K <= k-K by A35,XREAL_1:9;
  then
A37: ISW.K.au = 0 by A30,A34,A36,SCMFSA_M:2;
A38: ISW.K.au+K = k by A34,A36,SCMFSA_M:2;
A39:  now
      let x be Int-Location;
      thus IExec(times(a,I),p,s).x
       = IExec(WH,p,s1).x by A32,SFMASTR1:14
        .= ST.k.x by A33,A29,A11,A38,A37,SCMFSA_M:2;
    end;
  now
    let x be FinSeq-Location;
    thus IExec(times(a,I),p,s).x
     = IExec(WH,p,s1).x by A32,SFMASTR1:15
      .= ST.k.x by A33,A29,A11,A38,A37,SCMFSA_M:2;
  end;
  hence thesis by A39,SCMFSA_M:2;
end;
