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 Th18: ::SCMPDS_5:29
  for I,J being Program of SCMPDS,k be Nat st I c= J &
I is_closed_on s,P & I is_halting_on s,P &
 k <= LifeSpan(P +* stop I,Initialize s)
holds  Comput(P +* J, Initialize s,k)
 =  Comput(P +* stop I,Initialize s,k)
proof
  let I,J be Program of SCMPDS,k be Nat;
  set m=LifeSpan(P +* stop I,Initialize s);
  assume that
A1: I c= J and
A2: I is_closed_on s,P and
A3: I is_halting_on s,P and
A4: k <= m;
  set s1 = Initialize s, s2 = Initialize s,
      P1 = P +* J, P2 = P +* stop I;
  defpred P[Nat] means $1 <= m implies
    Comput(P1,s1,$1) =  Comput(P2,s2,$1);
A5: now
    let k be Nat;
    assume
A6: P[k];
    now
A7:   Comput(P2,s2,k+1) = Following(P2,Comput(P2,s2,k)) by EXTPRO_1:3
        .= Exec(CurInstr(P2,Comput(P2,s2,k)),
        Comput(P2,s2,k));
A8:   Comput(P1,s1,k+1) = Following(P1,Comput(P1,s1,k)) by EXTPRO_1:3
        .= Exec(CurInstr(P1,Comput(P1,s1,k)),
        Comput(P1,s1,k));
A9:  k < k+1 by XREAL_1:29;
      assume
A10:  k+1 <= m;
      then k < m by A9,XXREAL_0:2;
      then
A11:  IC Comput(P2,s2,k) in dom I by A2,A3,SCMPDS_6:26;
      then
A12:  IC Comput(P2,s2,k) in dom (stop I) by FUNCT_4:12;
A13:   J c= P1 by FUNCT_4:25;
A14:      dom I c= dom J by A1,RELAT_1:11;
      CurInstr(P1,Comput(P1,s1,k))
       = P1.IC Comput(P2,s2,k) by A6,A10,A9,PBOOLE:143,XXREAL_0:2
        .= J.IC Comput(P2,s2,k) by A13,A14,A11,GRFUNC_1:2
        .= I.IC Comput(P2,s2,k) by A1,A11,GRFUNC_1:2
        .= (stop I).IC Comput(P2,s2,k) by A11,AFINSQ_1:def 3
        .= P2.IC Comput(P2,s2,k) by A12,FUNCT_4:13
        .= CurInstr(P2,Comput(P2,s2,k)) by PBOOLE:143;
      hence
       Comput(P1,s1,k+1) =  Comput(P2,s2,k+1)
        by A6,A10,A9,A8,A7,XXREAL_0:2;
    end;
    hence P[k+1];
  end;
A15: P[0];
  for k be Nat holds P[k] from NAT_1:sch 2(A15,A5);
  hence thesis by A4;
end;
