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 Th30:
  for s being State of SCMPDS,I being Program of SCMPDS,J being
shiftable Program of SCMPDS,a being Int_position,k1 being Integer st s.DataLoc(
  s.a,k1)<> 0 & J is_closed_on s,P & J is_halting_on s,P holds if=0(a,k1,I,J)
  is_closed_on s,P & if=0(a,k1,I,J) is_halting_on s,P
proof
  let s be State of SCMPDS,I be Program of SCMPDS, J be shiftable Program of
  SCMPDS, a be Int_position,k1 be Integer;
  set b=DataLoc(s.a,k1);
  set pJ=stop J, s1 = Initialize s, P1 = P +* pJ,
  IF=if=0(a,k1,I,J), pIF=
  stop IF, s3 = Initialize s, P3 = P +* pIF,
  s4 = Comput(P3,s3,1), P4 = P3;
  set i = (a,k1)<>0_goto (card I + 2);
  set G =Goto (card J+1), iG=i ';' I ';' G;
A1: IF = i ';' (I ';' G) ';' J by SCMPDS_4:14
    .= i ';' (I ';' G ';' J) by SCMPDS_4:14;
A2: 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 A1,Th3;
A3: 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
A4: s3.DataLoc(s3.a,k1)=s3.b by FUNCT_4:11
    .= s.b by A3,FUNCT_4:11;
A5: IC s3 = 0 by MEMSTR_0:47;
  assume
  s.b <> 0;
  then
A6: IC s4 = ICplusConst(s3,card I + 2) by A2,A4,SCMPDS_2:55
    .= (0+(card I + 2)) by A5,Th4;
  assume
A7: J is_closed_on s,P;
  then
A8: Start-At(0,SCMPDS) c= s1 & J is_closed_on s1,P1 by FUNCT_4:25;
A9: pIF c= P3 by FUNCT_4:25;
A10: card iG = card (i ';' I) + card G by AFINSQ_1:17
    .=card (i ';' I) + 1 by COMPOS_1:54
    .=card I +1 +1 by Th1
    .=card I +(1 +1);
  then Shift(pJ,card I+2) c= pIF by Th5;
  then
A11: Shift(pJ,card I+2) c= P4 by A9,XBOOLE_1:1;
  assume
  J is_halting_on s,P;
  then
A12: P1 halts_on s1;
  for a holds s1.a = s4.a by A2,SCMPDS_2:55;
  then
A13: DataPart s1 = DataPart s4 by SCMPDS_4:8;
A14:  pJ c= P1 by FUNCT_4:25;
  now
    let k be Nat;
    per cases;
    suppose
      0 < k;
      then consider k1 being Nat such that
A15:  k1 + 1 = k by NAT_1:6;
      reconsider k1 as Nat;
      reconsider m = IC Comput(P1, s1,k1) as Nat;
       m in dom pJ by A7;
      then m < card pJ by AFINSQ_1:66;
      then
A16:  m + (card I + 2) < card pJ + (card I + 2) by XREAL_1:6;
A17:  card pJ = card J + 1 by COMPOS_1:55;
A18:  card pIF = card IF+1 by COMPOS_1:55
        .=card I +2 +card J +1 by A10,AFINSQ_1:17
        .=card I +2 + card pJ by A17;
      IC Comput(P3,s3,k) = IC Comput(P3, s4,k1) by A15,EXTPRO_1:4
        .=  (m + (card I + 2)) by A8,A13,A11,A6,Th22,A14;
      hence IC Comput(P3,s3,k) in dom pIF by A18,A16,AFINSQ_1:66;
    end;
    suppose
      k = 0;
      then Comput(P3,s3,k) = s3 by EXTPRO_1:2;
      hence IC Comput(P3,s3,k) in dom pIF by A5,COMPOS_1:36;
    end;
  end;
  hence IF is_closed_on s,P;
A19: Comput(P3,s3,LifeSpan(P1,s1)+1)
= Comput(P3,Comput(P3,s3,1),LifeSpan(P1,
s1))
 by EXTPRO_1:4;
  CurInstr(P3,
  Comput(P3,s3,LifeSpan(P1,s1)+1))
   =CurInstr(P4,
   Comput(P4,s4,LifeSpan(P1,s1))) by A19
    .=CurInstr(P1,
    Comput(P1,s1,LifeSpan(P1,s1))) by A8,A13,A11,A6,Th22,A14
    .= halt SCMPDS by A12,EXTPRO_1:def 15;
  then P3 halts_on s3 by EXTPRO_1:29;
  hence thesis;
end;
