reserve m,n for Nat,
  I for Program of SCM+FSA,
  s,s1,s2 for State of SCM+FSA,
  a for Int-Location,
  f for FinSeq-Location,
  p,p1,p2 for Instruction-Sequence of SCM+FSA;

theorem Th9:
  for I being really-closed Program of SCM+FSA
   st p+*I halts_on s &
   Directed I c= p &
   Initialize ((intloc 0) .--> 1) c= s
   holds IC Comput(p, s,LifeSpan(p +* I,s) + 1) =  card I
proof
  set A = NAT;
  let I be really-closed Program of SCM+FSA;
  assume that
A1: p+*I halts_on s and
A2: Directed I c= p and
A3: iS c= s;
  set sISA0 = s +* iS,
      pISA0 = p +* I;
    set s1 = sISA0 +* EP,
        p1 = pISA0 +* (I ";" I);
A4: sISA0 = s by A3,FUNCT_4:98;
A5: I c= pISA0 by FUNCT_4:25;
  reconsider sISA0 as State of SCM+FSA;
  set m = LifeSpan(pISA0,sISA0);
  set l1 = IC Comput(pISA0, sISA0,m);
A6: I c= pISA0 by FUNCT_4:25;
  IC sISA0 = 0 by MEMSTR_0:def 11;
  then IC sISA0 in dom I by AFINSQ_1:65;
  then
A7: l1 in dom I by AMISTD_1:21,A6;
  set s2 = sISA0 +* EP,
      p2 = pISA0 +* Directed I;
A8: Directed I c= p2 by FUNCT_4:25;
 now
    let k be Nat;
    defpred X[Nat] means $1 <= k implies
      Comput(p1, s1,$1) =  Comput(p2, s2,$1);
    assume
A9: k <= m;
A10: for n being Nat st X[n] holds X[n+1]
    proof
      let n be Nat;
      assume
A11:  n <= k implies
       Comput(p1, s1,n) =  Comput(p2,s2,n);
A12:  Comput(p2, s2,n + 1) = Following(p2,Comput(p2,s2,n)) by EXTPRO_1:3
        .= Exec(CurInstr(p2,Comput(p2,s2,n)),
        Comput(p2, s2,n));
A13:  Comput(p1, s1,n + 1) = Following(p1,Comput(p1,s1,n)) by EXTPRO_1:3
        .= Exec(CurInstr(p1,Comput(p1,s1,n)),
        Comput(p1, s1,n));
A14:  n <= n + 1 by NAT_1:12;
      assume
A15:  n + 1 <= k;
A16: I c= p +* I by FUNCT_4:25;
     IC s1 = 0 by MEMSTR_0:def 11;
     then
A17:    IC s1 in dom I by AFINSQ_1:65;
      n <= k by A15,A14,XXREAL_0:2;
      then IC Comput(pISA0, sISA0,n)
       = IC Comput(p1, s1,n) by A1,A3,Th8,A5,A4,A9,XXREAL_0:2;
      then
A18:  IC Comput(p1, s1,n) in dom I by AMISTD_1:21,A16,A17;
      then
A19:  IC Comput(p2, s2,n) in dom Directed I
       by A15,A11,A14,FUNCT_4:99,XXREAL_0:2;
A20:  CurInstr(p2,Comput(p2,s2,n))
         = p2.IC Comput(p2, s2,n) by PBOOLE:143
        .= (Directed I).IC Comput(p2, s2,n) by A19,FUNCT_4:13;
      dom I c= dom (I ";" I) &
      CurInstr(p1, Comput(p1,s1,n)) = p1.IC
      Comput(p1, s1,n) by PBOOLE:143,SCMFSA6A:17;
      then Directed I c= I ";" I &
      CurInstr(p1,Comput(p1,s1,n)) = (I ";" I).IC
      Comput(p1, s1,n) by A18,FUNCT_4:13,SCMFSA6A:16;
      hence thesis by A11,A15,A14,A20,A13,A12,A19,GRFUNC_1:2,XXREAL_0:2;
    end;
A21: X[0];
    for n being Nat holds X[n] from NAT_1:sch 2(A21,A10);
    then  Comput(p1,s1,k) =  Comput(p2,s2,k);
    hence  Comput(pISA0, sISA0,k) =  Comput(p2,s2,k)
       by A1,A3,A9,Th8,A5,A4;
  end;
  then
A22:  Comput(pISA0, sISA0,m) =  Comput(p2,s2,m);
A23: I.l1 = pISA0.l1 by A7,A5,GRFUNC_1:2
    .=CurInstr(pISA0,Comput(pISA0,sISA0,m)) by PBOOLE:143
    .= halt SCM+FSA by A1,A4,EXTPRO_1:def 15;
  IC Comput(p2,s2,m) in dom Directed I by A7,A22,FUNCT_4:99;
  then
A24: p2.l1 = (Directed I).l1 by A22,A8,GRFUNC_1:2
    .= goto  card I by A7,A23,FUNCT_4:106;
A25: Comput(p2, s2,m + 1)
     = Following(p2,Comput(p2,s2,m)) by EXTPRO_1:3
    .= Exec(goto  card I,Comput(p2,s2,m)) by A22,A24,PBOOLE:143;
  set m = LifeSpan(pISA0,sISA0);
    dom Directed I = dom I by FUNCT_4:99;
    then
A26: p +* I +* Directed I = p +* Directed I by FUNCT_4:74
     .= p by A2,FUNCT_4:98;
     s2 = sISA0
    .= s by A3,FUNCT_4:98;
hence
    IC Comput(p, s,LifeSpan(p +* I,s) + 1)
       = IC Comput(p2, s2,m + 1) by A26
      .=  card I by A25,SCMFSA_2:69;
end;
