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

theorem Th50:
  for s being State of SCMPDS,I being Program of SCMPDS, a being
  Int_position, k1 being Integer st s.DataLoc(s.a,k1)= 0 holds if<>0(a,k1,I)
  is_closed_on s,P & if<>0(a,k1,I) is_halting_on s,P
proof
  let s be State of SCMPDS,I be Program of SCMPDS, a be Int_position,k1 be
  Integer;
  set b=DataLoc(s.a,k1);
  assume
A1: s.b = 0;
  set IF=if<>0(a,k1,I), pIF=stop IF, s3 = Initialize s,
  P3 = P +* pIF,
  s4 = Comput(P3,s3,1), s5 = Comput(P3,s3,2), P4 = P3, P5 = P3;
A2: not b in dom Start-At(0,SCMPDS) by SCMPDS_4:18;
  not a in dom Start-At(0,SCMPDS) by SCMPDS_4:18;
  then
A3: s3.DataLoc(s3.a,k1)=s3.b by FUNCT_4:11
    .=0 by A1,A2,FUNCT_4:11;
A4: pIF c= P4 by FUNCT_4:25;
  set i = (a,k1)<>0_goto 2, j = goto (card I + 1);
A5: IF =i ';' (j ';' I) by SCMPDS_4:16;
A6: IC s3 = 0 by MEMSTR_0:47;
  Comput(P3, s3,0 + 1) = Following(P3,Comput(P3,s3,0)) by EXTPRO_1:3
    .= Following(P3,s3) by EXTPRO_1:2
    .= Exec(i,s3) by A5,Th3;
  then
A7: IC s4 = IC s3 + 1 by A3,SCMPDS_2:55
    .= (0+1) by A6;
A8:  1 in dom IF by Lm9;
  then  1 in dom pIF by COMPOS_1:62;
  then
A9: P4. 1 = pIF. 1 by A4,GRFUNC_1:2
    .=IF. 1 by A8,COMPOS_1:63
    .=j by Lm10;
A10: card IF=card I+2 by Lm8;
  then
A11: (card I+2) in dom pIF by COMPOS_1:64;
A12:  P3/.IC s4
 = P3.IC s4 by PBOOLE:143;
  Comput(P3, s3,1 + 1) = Following(P3,s4) by EXTPRO_1:3
    .= Exec(j,s4) by A7,A9,A12;
  then
A13: IC s5 = ICplusConst(s4,card I+1) by SCMPDS_2:54
    .= (card I+1+1) by A7,Th4
    .= (card I+(1+1));
A14:  (P3)/.IC s5
 = P3.IC s5 by PBOOLE:143;
  pIF c= P5 by FUNCT_4:25;
  then P5.(card I+2) = pIF.(card I+2) by A11,GRFUNC_1:2
    .=halt SCMPDS by A10,COMPOS_1:64;
  then
A15: CurInstr(P3,s5) = halt SCMPDS by A13,A14;
  now
    let k be Nat;
A16: k = 0 or 0 + 1 <= k by INT_1:7;
    per cases by A16,XXREAL_0:1;
    suppose
      k = 0;
      then Comput(P3,s3,k) = s3 by EXTPRO_1:2;
      hence IC Comput(P3,s3,k) in dom pIF by A6,COMPOS_1:36;
    end;
    suppose
      k = 1;
      hence IC Comput(P3,s3,k) in dom pIF by A8,A7,COMPOS_1:62;
    end;
    suppose
      1 < k;
      then 1+1 <= k by INT_1:7;
      hence IC Comput(P3,s3,k) in dom pIF
      by A11,A13,A15,EXTPRO_1:5;
    end;
  end;
  hence IF is_closed_on s,P;
  P3 halts_on s3 by A15,EXTPRO_1:29;
  hence thesis;
end;
