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;

theorem Th29: :: based on SCMFSA_9:10
  for s being 0-started State of SCM+FSA
   st while>0(a, I) c= p & s.a <= 0
  holds LifeSpan(p,s) = 3 & for k being Nat
   holds DataPart Comput(p,s,k) = DataPart s
proof
  let s be 0-started State of SCM+FSA;
A1: Start-At(0,SCM+FSA) c= s by MEMSTR_0:29;
  assume that
A2: while>0(a, I) c= p and
A3: s.a <= 0;
A4: p +* while>0(a, I) = p by A2,FUNCT_4:98;
  set i = a >0_goto 3;
  set s1 = Initialize s,
      p1 = p +* while>0(a,I);
A5: while>0(a,I) c= p1 by FUNCT_4:25;
A6: IC SCM+FSA in dom Start-At(0,SCM+FSA) by MEMSTR_0:15;
  not a in dom Start-At(0,SCM+FSA) by SCMFSA_2:102;
  then
A7: s1.a = s.a by FUNCT_4:11;
A8:  1 in dom while>0(a,I) by SCMFSA_X:9;
A9: p1. 1 = while>0(a,I). 1 by A8,FUNCT_4:13
    .= goto  2 by SCMFSA_X:10;
A10: IC s1 = IC Start-At(0,SCM+FSA) by A6,FUNCT_4:13
    .=  0 by FUNCOP_1:72;
A11:  p1/.IC s1 = p1.IC s1 by PBOOLE:143;
  0 in dom while>0(a,I) by AFINSQ_1:65;
  then p1. 0 = while>0(a,I). 0 by FUNCT_4:13
    .= i by SCMFSA_X:10;
  then
A12: CurInstr(p1,s1) = i by A10,A11;
A13: Comput(p1,s1,0+1) = Following(p1,Comput(p1,s1,0)) by EXTPRO_1:3
    .= Exec(i,s1) by A12;
  set loc5=  (card I +4);
  set s5 = Comput(p1,s1,3),
      p5 = p1;
  set s4 = Comput(p1,s1,2),
      p4 = p1;
  set s2 = Comput(p1,s1,1);
A14:  2 in dom while>0(a,I) by SCMFSA_X:7;
A15: p4.2 = while>0(a,I) .2 by A14,FUNCT_4:13
    .= goto loc5 by SCMFSA_X:17;
A16: loc5 in dom while>0(a,I) by SCMFSA_X:8;
A17: p5.loc5 = while>0(a,I).loc5 by A16,A5,GRFUNC_1:2
    .= halt SCM+FSA by SCMFSA_X:16;
A18: ( for c being Int-Location holds Exec(goto loc5, s4).c = s4.c)& for f
  being FinSeq-Location holds Exec(goto loc5, s4).f = s4.f by SCMFSA_2:69;
A19: ( for c being Int-Location holds Exec(goto  2, s2).c = s2.c)& for
f being FinSeq-Location holds Exec(goto  2, s2).f = s2.f by SCMFSA_2:69;
A20:  p1/.IC Comput(p1,s1,1) = p1.IC Comput(p1,s1,1) by PBOOLE:143;
  IC Comput(p1,s1,1) = 0 + 1 by A3,A10,A13,A7,SCMFSA_2:71;
  then
A21: CurInstr(p1,Comput(p1,s1,1)) = goto  2 by A9,A20;
A22: Comput(p1,s1,1+1) = Following(p1,s2) by EXTPRO_1:3
    .= Exec(goto  2,s2) by A21;
A23:  p4/.IC s4 = p4.IC s4 by PBOOLE:143;
  IC s4 =  2 by A22,SCMFSA_2:69;
  then
A24: CurInstr(p4,s4) = goto loc5 by A15,A23;
A25: Comput(p1,s1,2+1) = Following(p1,s4) by EXTPRO_1:3
    .= Exec(goto loc5,s4) by A24;
A26:  p5/.IC s5 = p5.IC s5 by PBOOLE:143;
  IC s5 = loc5 by A25,SCMFSA_2:69;
  then
A27: CurInstr(p5,s5) = halt SCM+FSA by A17,A26;
  then
A28: p1 halts_on s1 by EXTPRO_1:29;
A29: s = s1 by A1,FUNCT_4:98;
  now
    let k;
    assume
A30: CurInstr(p,Comput(p,s,k)) = halt SCM+FSA;
    assume 3 > k;
    then 2+1 > k;
    then
 k <= 2 by NAT_1:13;
    then k = 0 or ... or k = 2;
    then per cases;
    suppose
      k = 0;
      then Comput(p,s,k) = s;
      hence contradiction by A29,A12,A30,A4;
    end;
    suppose
      k = 1;
      hence contradiction by A29,A21,A30,A4;
    end;
    suppose
      k = 2;
      hence contradiction by A29,A24,A30,A4;
    end;
  end;
  hence
A31: LifeSpan(p,s) = 3 by A29,A27,A28,A4,EXTPRO_1:def 15;
A32: ( for c being Int-Location holds Exec(i, s1).c = s1.c)& for f being
  FinSeq-Location holds Exec(i, s1).f = s1.f by SCMFSA_2:71;
  then
A33: DataPart Comput(p,s,1) = DataPart s by A29,A13,A4,SCMFSA_M:2;
  then DataPart Comput(p,s,2) = DataPart s by A29,A22,A19,A4,SCMFSA_M:2;
  then
A34: DataPart Comput(p,s,3) = DataPart s by A29,A25,A18,A4,SCMFSA_M:2;
  let k be Nat;
  k <= 2 or 2 < k;
  then
A35: (k = 0 or ... or k = 2) or 2+1 <= k by NAT_1:13;
  per cases by A35;
  suppose
    k = 0;
    hence thesis;
  end;
  suppose
    k = 1;
    hence thesis by A29,A13,A32,A4,SCMFSA_M:2;
  end;
  suppose
    k = 2;
    hence thesis by A29,A22,A19,A33,A4,SCMFSA_M:2;
  end;
  suppose
    3 <= k;
    then CurInstr(p,Comput(p,s,k))
     = halt SCM+FSA by A29,A28,A31,A4,EXTPRO_1:36;
    hence thesis by A31,A34,EXTPRO_1:24;
  end;
end;
