reserve l, m, n for Nat,
  i,j,k for Instruction of SCMPDS,
  I,J,K for Program of SCMPDS,
  p,q,r for PartState of SCMPDS;
reserve a,b,c for Int_position,
  s,s1,s2 for State of SCMPDS,
  k1,k2 for Integer;
reserve x for set;
reserve l,l1,loc for Nat;

theorem Th18:
 for P,Q being Instruction-Sequence of SCMPDS
  st Q = P +*((IC s,IC s + 1) --> (goto 1, goto -1))
 holds
  not Q halts_on s
proof
 let P,Q be Instruction-Sequence of SCMPDS such that
A1: Q = P +*((IC s,IC s + 1) --> (goto 1, goto -1));
  set m=(IC s,IC s + 1) --> (goto 1, goto -1);
A2: m.(IC s + 1)=goto -1 by FUNCT_4:63;
  IC s<>IC s + 1;
  then
A3: m.(IC s) = goto 1 by FUNCT_4:63;
  defpred X[Nat] means
   IC(Comput(Q,s,$1)) = IC s or IC(Comput(Q,s,$1)) = IC s + 1;
A4: dom m = {IC s,IC s + 1} by FUNCT_4:62;
  then
A5: IC s + 1 in dom m by TARSKI:def 2;
A6: IC s in dom m by A4,TARSKI:def 2;
  now
    let n;
    set Cn=Comput(Q,s,n);
    assume
A7: IC Cn = IC s or IC Cn = IC s + 1;
    per cases by A7;
    case
A8:   IC Cn = IC s;
      then
A9:   CurInstr(Q,Cn) = Q.IC s by PBOOLE:143
        .= goto 1 by A6,A3,A1,FUNCT_4:13;
      thus IC (Comput(Q,s,n+1)) = IC Following(Q,Cn)
      by EXTPRO_1:3
        .= ICplusConst(Cn,1) by A9,SCMPDS_2:54
        .= IC s + 1 by A8,SCMPDS_3:10;
    end;
    case
A10:  IC Cn = IC s + 1;
      reconsider i = IC s as Element of NAT;
A11:  ex j be Element of NAT st j = IC Cn & ICplusConst(Cn,-1) =|.j+(-1)
      .| by SCMPDS_2:def 18;
A12:  CurInstr(Q,Comput(Q,s,n))
        = Q.(IC s + 1) by A10,PBOOLE:143
        .= goto -1 by A5,A2,A1,FUNCT_4:13;
      thus IC(Comput(Q,s,n+1)) = IC Following(Q,Cn)
       by EXTPRO_1:3
        .=|.i+4 + -4 .| by A10,A12,A11,SCMPDS_2:54
        .=IC s by ABSVALUE:def 1;
    end;
  end;
  then
A13: for n st X[n] holds X[n+1];
  let nn be Nat;
   reconsider n=nn as Nat;
  assume IC Comput(Q,s,nn) in dom Q;
A14: X[0];
A15: for n holds X[n] from NAT_1:sch 2(A14,A13);
  per cases by A15;
  suppose
    IC(Comput(Q,s,n)) = IC s;
    then CurInstr(Q,Comput(Q,s,n))
     = Q.IC s by PBOOLE:143
    .= goto 1 by A6,A3,A1,FUNCT_4:13;
   hence thesis by SCMPDS_2:73;
  end;
  suppose
    IC(Comput(Q,s,n)) = IC s + 1;
    then CurInstr(Q,Comput(Q,s,n))
     = Q.(IC s + 1) by PBOOLE:143
    .= goto -1 by A5,A2,A1,FUNCT_4:13;
    hence thesis by SCMPDS_2:73;
  end;
end;
