reserve x for set,
  m,n for Nat,
  a,b,c for Int_position,
  i for Instruction of SCMPDS,
  s,s1,s2 for State of SCMPDS,
  k1,k2 for Integer,
  loc,l1 for Nat,
  I,J for Program of SCMPDS,
  N for with_non-empty_elements set;
reserve P,P1,P2,Q for Instruction-Sequence of SCMPDS;

theorem Th27:
 for s being 0-started State of SCMPDS
  for i being parahalting Instruction of SCMPDS
   holds Exec(i,s) = IExec(Load i,P,s)
proof
  let s be 0-started State of SCMPDS;
  let i be parahalting Instruction of SCMPDS;
  set Li=Load i, Mi= Macro i;
  set PI = P +* Mi;
  set IC1 = IC Comput(PI, s,1);
A1: Initialize s = s by MEMSTR_0:44;
  Mi c= PI by FUNCT_4:25;
  then
A2: PI halts_on s by SCMPDS_4:def 7;
A3:  1 in dom Mi by COMPOS_1:57;
A4:  0 in dom Mi by COMPOS_1:57;
A5: Mi. 1=halt SCMPDS by COMPOS_1:59;
A6: Mi. 0 = i by COMPOS_1:58;
A7: Mi c= PI by FUNCT_4:25;
     then
A8: IC1 in dom Mi by SCMPDS_4:def 6;
A9: PI/.IC s = PI.IC s by PBOOLE:143;
A10: Comput(PI, s,0+1) = Following(PI,Comput(PI,s,0)) by EXTPRO_1:3
    .= Following(PI,s)
    .= Exec(PI. 0, s) by A9,A1,MEMSTR_0:47
    .= Exec(i, s) by A4,A6,A7,GRFUNC_1:2;
  per cases by A8,COMPOS_1:60;
  suppose
A11: IC1 =  0;
    set Ni=InsCode i;
    IC s + 1 = 0+1 by A1,MEMSTR_0:47;
    then
A12: Ni in {0,1,4,5,6,14} by A10,A11,SCMPDS_4:1;
A13: CurInstr(PI,Comput(PI,s,1)) = PI. 0 by A11,PBOOLE:143
      .= i by A4,A6,A7,GRFUNC_1:2;
A14: Ni <> 1 by Th10;
    hereby
      per cases;
      suppose
        i = halt SCMPDS;
        hence thesis by A2,A10,A13,EXTPRO_1:def 9;
      end;
      suppose
A15:    i <> halt SCMPDS;
A16:    now
          let b;
          per cases by A12,A14,ENUMSET1:def 4;
          suppose
            InsCode i = 0;
            hence s.b=Exec(i, s).b by SCMPDS_2:86;
          end;
          suppose
            InsCode i = 14;
            then ex k1 st i = goto k1 by SCMPDS_2:26;
            hence s.b=Exec(i, s).b by SCMPDS_2:54;
          end;
          suppose
            InsCode i = 4;
            then ex a,k1,k2 st i = (a,k1)<>0_goto k2 by SCMPDS_2:30;
            hence s.b=Exec(i, s).b by SCMPDS_2:55;
          end;
          suppose
            InsCode i = 5;
            then ex a,k1,k2 st i = (a,k1)<=0_goto k2 by SCMPDS_2:31;
            hence s.b=Exec(i, s).b by SCMPDS_2:56;
          end;
          suppose
            InsCode i = 6;
            then ex a,k1,k2 st i = (a,k1)>=0_goto k2 by SCMPDS_2:32;
            hence s.b=Exec(i, s).b by SCMPDS_2:57;
          end;
        end;
A17:    Following(PI,s) = Following(PI,Comput(PI,s,0))
          .= Exec(i, s) by A10,EXTPRO_1:3;
A18:    IC s = IC Exec(i, s) by A10,A11,A1,MEMSTR_0:47;
        then
A19:    s = Exec(i, s) by A16,SCMPDS_2:44;
        now
          let n;
          Comput(PI, s,n) = s by A18,A16,A17,EXTPRO_1:27,SCMPDS_2:44
            .= Following(PI,Comput(PI,s,0))
            by A19,A17
            .= Comput(PI, s,0+1) by EXTPRO_1:3;
          hence CurInstr(PI,Comput(PI,s,n)) <> halt SCMPDS by A13,A15;
        end;
        then not PI halts_on s;
        hence thesis by A7,SCMPDS_4:def 7;
      end;
    end;
  end;
  suppose
A20:    IC1 =  1;
    CurInstr(PI,Comput(PI,s,1))
     = PI. 1 by A20,PBOOLE:143
      .= halt SCMPDS by A3,A5,A7,GRFUNC_1:2;
    hence thesis by A2,A10,EXTPRO_1:def 9;
  end;
end;
