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
 for J being good really-closed MacroInstruction of SCM+FSA holds
  s.intloc 0 = 1 & (ProperTimesBody a,J,s,p or J is parahalting)
  implies times(a, J) is_halting_on s,p
proof let J be good really-closed MacroInstruction of SCM+FSA;
  set I = J;
  assume
A1: s.intloc 0 = 1;
  set taI = times(a, I);
  set ST = StepTimes(a,I,p,s);
  set au = 1-stRWNotIn ({a} \/ UsedILoc I);
  set ISu = I ";" SubFrom(au, intloc 0);
  set WH = while>0 ( au, ISu );
  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);
A2:  s1 =  IExec(Macro(au:=a),p,s) by SCMFSA6C:5;
  s1.intloc 0 = (Initialized s).intloc 0 by SCMFSA_2:63
    .= 1 by SCMFSA_M:9;
  then
A3: DataPart Is1 = DataPart s1 by SCMFSA_M:19;
  assume
A4: ProperTimesBody a,I,s,p or I is parahalting;
  then
A5: ProperTimesBody a,I,s,p by Th11;
A6: Macro(au := a) is_halting_on Initialized s,p by SCMFSA7B:19;
  per cases;
  suppose
A7: s.a < 0;
A8: a = intloc 0 or a is read-write by SCMFSA_M:def 2;
A9: s1.au = (Initialized s).a by SCMFSA_2:63
      .= s.a by A1,A8,SCMFSA_M:9,37;
    WH is_halting_on s1,p by A7,A9,SCMFSA_9:38;
    then taI is_halting_on Initialized s,p by A2,A6,SFMASTR1:3;
    hence thesis by A1,SCMFSA8B:42;
  end;
  suppose
A10: 0 <= s.a;
A11: ProperBodyWhile>0 au, ISu, s1, p
    proof
      let k be Nat;
      assume SW.k.au > 0;
      then
A12:  k < s.a by A1,A5,A10,Th14;
      then
A13:  ST.k.intloc 0 = 1 by A4,Th11,Th12;
      then
A14:  DataPart ST.k = DataPart Initialized (ST.k) by SCMFSA_M:19;
      I is_halting_on ST.k,p+*times*(a,I) by A5,A12;
      then
A15:  I is_halting_on Initialized ST.k,p+*times*(a,I) by A13,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 A15,SFMASTR1:3;
      hence thesis by A14,SCMFSA8B:5;
    end;
A16: WithVariantWhile>0 au, ISu, Is1, p
    proof
      reconsider sa = s.a as Element of NAT by A10,INT_1:3;
      deffunc U(State of SCM+FSA) = |.$1.au.|;
      consider f being Function of product the_Values_of SCM+FSA,NAT such
      that
A17:  for x being Element of product the_Values_of SCM+FSA holds
      f.x = U(x) from FUNCT_2:sch 4;
A18: 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 A17;
      hence thesis;
     end;
      take f;
      let k be Nat;
      DataPart ISW.k = DataPart SW.k by A3,A11,SCMFSA9A:34;
      then
A19:  ISW.k.au = SW.k.au by SCMFSA_M:2;
      DataPart ISW.(k+1) = DataPart SW.(k+1) by A3,A11,SCMFSA9A:34;
      then
A20:  ISW.(k+1).au = SW.(k+1).au by SCMFSA_M:2;
      per cases;
      suppose
A21:    k < s.a;
        then
A22:    k-k < s.a-k by XREAL_1:9;
A23:    ST.k.au+k = s.a by A1,A5,A21,Th13;
A24:    k+1 <= sa by A21,NAT_1:13;
        then
A25:    (k+1)-(k+1) <= s.a-(k+1) by XREAL_1:9;
A26:    ST.(k+1).au+(k+1) = s.a by A1,A5,A24,Th13;
        then
A27:    s.a = (ST.(k+1).au+1)+k;
A28:    f.(ISW.(k+1)) = |. ISW.(k+1).au .| by A18
          .= SW.(k+1).au by A20,A26,A25,ABSVALUE:def 1;
        f.(ISW.k) = |. ISW.k.au .| by A18
          .= SW.k.au by A19,A23,A22,ABSVALUE:def 1;
        hence thesis by A23,A27,A28,NAT_1:13;
      end;
      suppose
        k >= s.a;
        hence thesis by A1,A5,A10,A19,Th14;
      end;
    end;
A29: ProperBodyWhile>0 au, ISu, Is1, p
    proof
      let k be Nat;
      assume
A30:  ISW.k.au > 0;
A31:  DataPart ISW.k = DataPart SW.k by A3,A11,SCMFSA9A:34;
      then
A32:  SW.k.au = ISW.k.au by SCMFSA_M:2;
      ISu is_halting_on SW.k, p+*while>0(au,ISu) by A11,A30,A32;
      hence thesis by A31,SCMFSA8B:5;
    end;
     WH is_halting_on Is1,p by A29,A16,SCMFSA9A:27;
    then WH is_halting_on s1,p by A3,SCMFSA8B:5;
    then taI is_halting_on Initialized s,p by A2,A6,SFMASTR1:3;
    hence thesis by A1,SCMFSA8B:42;
  end;
end;
