reserve x for Int_position,
  n,p0 for Nat;
reserve P,Q,V for Instruction-Sequence of SCMPDS;

theorem Th3:
  for s be State of SCMPDS,I be Program of SCMPDS st
   for t be 0-started State of SCMPDS, Q st DataPart t = DataPart s
    holds I is_halting_on t,Q
  holds I is_closed_on s,P
proof
  let s be State of SCMPDS,I be Program of SCMPDS;
  assume
A1: for t be 0-started State of SCMPDS,Q st DataPart t = DataPart s holds I
  is_halting_on t,Q;
  set pI=stop I, sI=Initialize s, PI = P +* pI;
  defpred X[Nat] means not IC Comput(PI,sI,$1) in dom pI;
A2: for a be Int_position holds s.a = sI.a
   proof let a be Int_position;
      not a in dom Start-At(0,SCMPDS) by SCMPDS_4:18;
    hence thesis by FUNCT_4:11;
   end;
  assume not I is_closed_on s,P;
  then ex k be Nat st X[k] by SCMPDS_6:def 2;
  then
A3: ex k be Nat st X[k];
  consider n be Nat such that
A4: X[n] and
A5: for m be Nat st X[m] holds n <= m from NAT_1:sch 5(A3);
  reconsider n as Nat;
  set s2 = Comput(PI,sI,n), P2 = PI,
  Ig = ((IC s2,IC s2 + 1) --> (goto 1,goto -1));
  reconsider P0 = PI +* Ig as Instruction-Sequence of SCMPDS;
  reconsider P1 = P2 +* Ig as Instruction-Sequence of SCMPDS;
  reconsider P3 = PI +* (IC s2,goto 1) as Instruction-Sequence of SCMPDS;
    reconsider P4 = P3 +* (IC s2 + 1,goto -1)
         as Instruction-Sequence of SCMPDS;
A6:   P0 = P4 by FUNCT_7:139;
A7: for m be Nat st m < n holds IC( Comput(PI, sI,m))
   in dom pI by A5;
A8: stop I c= PI by FUNCT_4:25;
  pI c= P3 by A4,FUNCT_4:25,FUNCT_7:89;
  then
A9: stop I c= P0 by A6,A4,AFINSQ_1:73,FUNCT_7:89;
  then
A10:  Comput(P0,sI,n) =  s2 by A8,A7,SCMPDS_4:21;
  DataPart sI = DataPart s by A2,SCMPDS_4:8;
  then I is_halting_on sI,P0 by A1;
  then
A11: P0+*pI halts_on Initialize sI
   by SCMPDS_6:def 3;
A12: not P0 halts_on s2 by SCMPDS_4:20;
   P0 +* pI=P0 by A9,FUNCT_4:98;
  hence contradiction by A12,A10,A11,EXTPRO_1:22;
end;
