reserve N for with_zero set;
reserve N for with_zero set;
reserve x,y,z,A,B for set,
  f,g,h for Function,
  i,j,k for Nat;
reserve S for IC-Ins-separated non empty
     with_non-empty_values AMI-Struct over N,
  s for State of S;
reserve N for non empty with_zero set,
 S for IC-Ins-separated non empty with_non-empty_values AMI-Struct over N,
  s for State of S;
reserve n for Nat;
reserve N for with_zero non empty set;

theorem Th22:
  for N be non empty with_zero set,
      S be IC-Ins-separated halting
       non empty with_non-empty_values AMI-Struct over N,
      p being NAT-defined (the InstructionsF of S)-valued Function,
      s being State of S, m being Nat
   holds p halts_on s iff p halts_on Comput(p,s,m)
proof
  let N;
  let S be IC-Ins-separated halting
   non empty
  with_non-empty_values AMI-Struct over N,
  p be NAT-defined (the InstructionsF of S)-valued Function,
  s be State of S, m be Nat;
  hereby
    assume p halts_on s;
    then consider n being Nat such that
A1:  IC Comput(p,s,n) in dom p and
A2:   CurInstr(p, Comput(p,s,n)) = halt S;
    reconsider n as Nat;
    per cases;
    suppose
      n <= m;
      then
       Comput(p,s,n) = Comput(p,s,m+0) by A2,Th5
        .= Comput(p,Comput(p,s,m),0);
      hence p halts_on Comput(p,s,m) by A2,A1;
    end;
    suppose
      n >= m;
      then reconsider k = n - m as Element of NAT by INT_1:5;
      Comput(p,Comput(p,s,m),k)
         = Comput(p,s,m+k) by Th4
        .= Comput(p,s,n);
     hence p halts_on Comput(p,s,m)
      by A1,A2;
    end;
  end;
  given n being Nat such that
A3: IC Comput(p, Comput(p,s,m),n) in dom p and
A4: CurInstr(p, Comput(p,Comput(p,s,m),n)) = halt S;
   reconsider nn=n as Nat;
  take m+nn;
  thus IC Comput(p,s,m+nn) in dom p &
   CurInstr(p, Comput(p,s,m+nn)) = halt S by A3,A4,Th4;
end;
