reserve p,p1,p2,h for Instruction-Sequence of SCM+FSA;
reserve k, l, n for Nat,
  j for Integer,
  i,i1 for Instruction of SCM+FSA;
reserve s, s1, s2 for State of SCM+FSA,
  a for read-write Int-Location,
  b for Int-Location,
  I, J for MacroInstruction of SCM+FSA,
  Ig for good MacroInstruction of SCM+FSA,
  i, j, k, m, n for Nat;
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, n for Nat;
reserve a for read-write Int-Location;

theorem Th53:
  for J being good really-closed MacroInstruction of SCM+FSA holds
  J does not destroy a &
  ProperTimesBody a,J,s,p & 0 <= s.a
  implies
 for k st k >= s.a
  holds StepTimes(a,J,p,s).k.a = 0 & StepTimes(a,J,p,s).k.intloc 0 = 1
proof let J be good really-closed MacroInstruction of SCM+FSA;
  set I = J;
  assume that
A1: J does not destroy a and
A2: ProperTimesBody a,I,s,p and
A3: 0 <= s.a;
  set ST = StepTimes(a,I,p,s);
  set SW = StepWhile>0 (a, I ";" SubFrom(a, intloc 0),  p, Initialized s);
  defpred X[Nat] means $1 >= s.a implies ST.$1.a = 0 & ST.$1.intloc 0 = 1;
A4: for k st X[k] holds X[k+1]
  proof
    reconsider sa = s.a as Element of NAT by A3,INT_1:3;
    let k such that
A5: k >= s.a implies ST.k.a = 0 & ST.k.intloc 0 = 1 and
A6: k+1 >= s.a;
    per cases by A6,XXREAL_0:1;
    suppose
A7:   k+1 = sa;
      then ST.(k+1).a+(k+1) = s.a by A2,Th52,A1;
      hence ST.(k+1).a = 0 by A7;
      thus thesis by A2,A7,Th51,A1;
    end;
    suppose
A8:   k+1 > sa;
      then
A9:   DataPart SW.(k+1) = DataPart SW.k by A5,NAT_1:13,Th31;
      hence ST.(k+1).a = 0 by A5,A8,NAT_1:13,SCMFSA_M:2;
      thus thesis by A5,A8,A9,NAT_1:13,SCMFSA_M:2;
    end;
  end;
A10: X[0]
  proof
    assume
A11: 0 >= s.a;
    thus ST.0.a = ST.0.a+0
      .= 0 by A2,A3,A11,Th52,A1;
    thus thesis by A2,A3,Th51,A1;
  end;
  thus for k holds X[k] from NAT_1:sch 2(A10, A4);
end;
