reserve x for set,
  m,n for Nat,
  a,b for Int_position,
  i,j,k for Instruction of SCMPDS,
  s,s1,s2 for State of SCMPDS,
  k1,k2 for Integer,
  loc,l for Nat,
  I,J,K for Program of SCMPDS;
reserve P,P1,P2,Q for Instruction-Sequence of SCMPDS;

theorem Th17: ::SCMPDS_5:33
  for I being Program of SCMPDS,J being Program of SCMPDS, k being
  Nat st I is_closed_on s,P & I is_halting_on s,P &
   k <= LifeSpan(P +* stop I,Initialize s)
    holds  Comput(P +* stop I,Initialize s,k)
   =  Comput(P+*(I ';' J), Initialize s,k)
proof
  let I be Program of SCMPDS,J be Program of SCMPDS,k be Nat;
  set spI= stop I;
  set s1 = Initialize s, P1 = P +* spI;
  set s2 = Initialize s, P2 = P +* (I ';' J);
  set n=LifeSpan(P1,s1);
  assume that
A1: I is_closed_on s,P and
A2: I is_halting_on s,P;
 assume
A3: k <= n;
  defpred X[Nat] means $1 <= n implies
    Comput(P1,s1,$1)
   =  Comput(P2,s2,$1);
A4: for m being Nat st X[m] holds X[m+1]
  proof
    let m be Nat;
    assume
A5: m <= n implies
    Comput(P1,s1,m) =  Comput(P2,s2,m);
A6: Comput(P1,s1,m+1) = Following(P1,Comput(P1,s1,m)) by EXTPRO_1:3
      .= Exec(CurInstr(P1,Comput(P1,s1,m)),
      Comput(P1,s1,m));
A7: IC Comput(P1,s1,m) in dom spI by A1,SCMPDS_6:def 2;
A8: Comput(P2,s2,m+1) = Following(P2,Comput(P2,s2,m)) by EXTPRO_1:3
      .= Exec(CurInstr(P2,Comput(P2,s2,m)),
      Comput(P2,s2,m));
    assume
A9: m+1 <= n;
    then m < n by NAT_1:13;
    then
A10: IC Comput(P1,s1,m) in dom I by A1,A2,SCMPDS_6:26;
    then
A11: IC Comput(P1,s1,m) in dom (I ';' J) by FUNCT_4:12;
    CurInstr(P1,Comput(P1,s1,m))
     = P1.IC Comput(P1,s1,m) by PBOOLE:143
      .= spI.IC Comput(P1,s1,m) by A7,FUNCT_4:13
      .= I.IC Comput(P1,s1,m) by A10,AFINSQ_1:def 3
      .= (I ';' J).IC Comput(P1,s1,m) by A10,AFINSQ_1:def 3
      .= P2.IC Comput(P1,s1,m) by A11,FUNCT_4:13
      .=CurInstr(P2,Comput(P2,s2,m)) by A5,A9,NAT_1:13,PBOOLE:143;
    hence thesis by A5,A9,A8,A6,NAT_1:13;
  end;
A12: X[0];
  for k being Nat holds X[k] from NAT_1:sch 2(A12, A4);
  hence thesis by A3;
end;
