reserve x,a for Int_position,
  s for State of SCMPDS;
reserve P,Q for Instruction-Sequence of SCMPDS;

theorem
  for s being 0-started State of SCMPDS,I being halt-free shiftable Program of
SCMPDS , a be Int_position, i be Integer,X be set,
    f being Function of product the_Values_of SCMPDS,NAT st
 (for t being 0-started State of SCMPDS st f.t=0 holds t.DataLoc(s.a,i) >= 0) &
(for t be 0-started State of SCMPDS,Q st (for x
be Int_position st x in X holds t.x=s.x) & t.a=s.a & t.DataLoc(s.a,i) < 0 holds
  IExec(I,Q,t).a=t.a & f.Initialize(IExec(I,Q,t)) < f.t
   & I is_closed_on t,Q & I
is_halting_on t,Q & for x be Int_position st x in X holds IExec(I,Q,t).x=t.x)
 holds
  while<0(a,i,I) is_closed_on s, P & while<0(a,i,I) is_halting_on s, P
proof
  let s be 0-started State of SCMPDS,
      I be halt-free shiftable Program of SCMPDS, a be
Int_position, i be Integer,X be set,
   f be Function of product the_Values_of SCMPDS,NAT;
  set b=DataLoc(s.a,i);
  set WHL=while<0(a,i,I), pWHL=stop WHL,
  pI=stop I;
  set i1=(a,i)>=0_goto (card I+2), i2=goto -(card I+1);
  defpred P[Nat] means
   for t be 0-started State of SCMPDS,Q st f.t <=
  $1 & (for x be Int_position st x in X holds t.x=s.x) & t.a=s.a holds WHL
  is_closed_on t,Q & WHL is_halting_on t,Q;
  assume
A1: for t be 0-started State of SCMPDS st f.t=0 holds t.b >= 0;
  assume
A2: for t be 0-started State of SCMPDS,Q st
 (for x st x in X holds t.x=s.x) & t.a=s.
  a & t.b < 0 holds IExec(I,Q,t).a=t.a &
  f.Initialize(IExec(I,Q,t)) < f.t & I
  is_closed_on t,Q & I is_halting_on t,Q & for x st x in X
   holds IExec(I,Q,t).x=t.x;
A3: for k be Nat st P[k] holds P[k + 1]
  proof
    let k be Nat;
    assume
A4: P[k];
    now
      let t be 0-started State of SCMPDS,Q;
A5:   Initialize t = t by MEMSTR_0:44;
      assume
A6:   f.t <= k+1;
      assume
A7:   for x st x in X holds t.x=s.x;
      assume
A8:   t.a=s.a;
      per cases;
      suppose
        t.b >= 0;
        hence WHL is_closed_on t,Q & WHL is_halting_on t,Q by A8,Th7;
      end;
      suppose
A9:     t.b < 0;
A10:     0 in dom pWHL by COMPOS_1:36;
A11:    WHL = i1 ';' (I ';' i2) by SCMPDS_4:15;
A12:    f.Initialize(IExec(I,Q,t)) < f.t by A2,A7,A8,A9;
        set t2 = t, Q2 = Q +* pI,
        t3 = t,
        Q3 = Q +* pWHL,
        t4 = Comput(Q3,t3,1), Q4 = Q3;
A13:    pI c= Q2 by FUNCT_4:25;
A14:    Comput(Q3,t3,0+1) = Following(Q3,
Comput(Q3,t3,0)) by EXTPRO_1:3
          .= Following(Q3,t3)
          .= Exec(i1,t3) by A11,A5,SCMPDS_6:11;
        for a holds t2.a = t4.a by A14,SCMPDS_2:57;
        then
A15:    DataPart t2 = DataPart t4 by SCMPDS_4:8;
A16:     WHL c= pWHL by AFINSQ_1:74;
        pWHL c= Q3 by FUNCT_4:25;
        then
A17:    WHL c= Q3 by A16,XBOOLE_1:1;
        Shift(I,1) c= WHL by Lm2;
        then
A18:    Shift(I,1) c= Q4 by A17,XBOOLE_1:1;
        set m2=LifeSpan(Q2,t2), t5=Comput(Q4,t4,m2), Q5 = Q4,
l1= (card I + 1);
A19:    IC t3 = 0 by MEMSTR_0:def 11;
        set m3=m2 +1;
        set t6=Comput(Q3,t3,m3), Q6 = Q3;
        set t7=Comput(Q3,t3,m3+1), Q7 = Q3;
        card I + 1 < card I + 2 by XREAL_1:6;
        then
A20:    l1 in dom WHL by Th5;
A21:    I is_closed_on t,Q by A2,A7,A8,A9;
A22:    I is_closed_on t2,Q2 by A2,A7,A8,A9;
        I is_halting_on t,Q by A2,A7,A8,A9;
        then
A23:    Q2 halts_on t2 by A5,SCMPDS_6:def 3;
        Q2+*pI halts_on t2 by A23;
        then
A24:    I is_halting_on t2,Q2 by A5,SCMPDS_6:def 3;
A25:    IC t4 = IC t3 + 1 by A9,A14,A8,SCMPDS_2:57
          .= 0+1 by A19;
        then
A26:    IC t5=l1 by A13,A24,A22,A15,A18,SCMPDS_7:18;
A27:  Q6/.IC t6 = Q6.IC t6 by PBOOLE:143;
A28:    t6=t5 by EXTPRO_1:4;
        then
A29:    CurInstr(Q6,t6) =Q4.l1 by A13,A24,A22,A25,A15,A18,A27,SCMPDS_7:18
          .=WHL.l1 by A20,A17,GRFUNC_1:2
          .=i2 by Th6;
A30:    DataPart Comput(Q2,t2,m2) = DataPart t5 by A13,A24,A22,A25,A15,A18,
SCMPDS_7:18;
        then
A31:    DataPart t5 =DataPart Result(Q2,t2) by A23,EXTPRO_1:23
          .=DataPart IExec(I,Q,t) by SCMPDS_4:def 5;
A32:    t7 = Following(Q3,t6) by EXTPRO_1:3
          .= Exec(i2,t6) by A29;
        then IC t7=ICplusConst(t6,0-(card I+1)) by SCMPDS_2:54
          .= 0 by A26,A28,SCMPDS_7:1;
        then
A33:    Initialize t7=t7 by MEMSTR_0:46;
A34:    IExec(I,Q,t) = Result(Q2,t2) by SCMPDS_4:def 5;
A35:    now
          let x be Int_position;
          assume
A36:      x in X;
          t5.x=Comput(Q2,t2,m2).x by A30,SCMPDS_4:8
            .=(Result(Q2,t2)).x by A23,EXTPRO_1:23
            .=IExec(I,Q,t).x by SCMPDS_4:def 5
            .=t.x by A2,A7,A8,A9,A36
            .=s.x by A7,A36;
          hence t7.x=s.x by A28,A32,SCMPDS_2:54;
        end;
        InsCode i2=14 by SCMPDS_2:12;
        then InsCode i2 in {0,4,5,6,14} by ENUMSET1:def 3;
        then
A37:    Initialize(t7)=Initialize(t6) by A32,Th2
          .=Initialize(IExec(I,Q,t)) by A31,A28,MEMSTR_0:80;
A38:    now
          assume
A39:      f.t7 > k;
          f.t7 < k+1 by A6,A12,A37,A33,XXREAL_0:2;
          hence contradiction by A39,INT_1:7;
        end;
A40:    t5.a=Comput(Q2,t2,m2).a by A30,SCMPDS_4:8
          .=(Result(Q2,t2)).a by A23,EXTPRO_1:23
          .=s.a by A8,A2,A7,A9,A34;
A41:    t7.a=t6.a by A32,SCMPDS_2:54
          .=s.a by A40,EXTPRO_1:4;
        then
A42:    WHL is_closed_on t7,Q7 by A4,A35,A38,A33;
        now
          let k be Nat;
          per cases;
          suppose
            k < m3+1;
            then
A43:        k <= m3 by INT_1:7;
            hereby
              per cases by A43,NAT_1:8;
              suppose
A44:            k <= m2;
                hereby
                  per cases;
                  suppose
                    k=0;
                    hence IC Comput(Q3,t3,k) in dom pWHL by A10,A19;
                  end;
                  suppose
                    k<>0;
                    then consider kn be Nat such that
A45:                k=kn+1 by NAT_1:6;
                    reconsider kn as Nat;
                    reconsider lm = IC Comput(Q2,t2,kn) as Element
of NAT;
                    kn < k by A45,XREAL_1:29;
                    then kn < m2 by A44,XXREAL_0:2;
                    then IC Comput(Q2,t2,kn) + 1 = IC Comput(
Q4,t4,kn) by A13,A24,A22,A25,A15,A18,SCMPDS_7:16;
                    then
A46:                IC Comput(Q3,t3,k) = (lm+1) by A45,EXTPRO_1:4;
                    IC Comput(Q2,t2,kn) in dom pI by A21,A5,SCMPDS_6:def 2;
                    then lm < card pI by AFINSQ_1:66;
                    then lm < card I+1 by COMPOS_1:55;
                    then
A47:                lm+1 <= card I +1 by INT_1:7;
                    card I + 1 < card I + 3 by XREAL_1:6;
                    then lm+1 < card I +3 by A47,XXREAL_0:2;
                    then lm+1 < card pWHL by Lm1;
                    hence IC Comput(Q3,t3,k) in dom pWHL by A46,AFINSQ_1:66;
                  end;
                end;
              end;
              suppose
A48:            k=m3;
                l1 in dom pWHL by A20,COMPOS_1:62;
                hence IC Comput(Q3,t3,k) in dom pWHL by A13,A24,A22,A25,A15,A18
,A28,A48,SCMPDS_7:18;
              end;
            end;
          end;
          suppose
            k >= m3+1;
            then consider nn be Nat such that
A49:        k=m3+1+nn by NAT_1:10;
            reconsider nn as Nat;
            Comput(Q3,t3,k)=
            Comput(Q7+*pWHL,t7,nn) by A49,EXTPRO_1:4;
            hence IC Comput(Q3,t3,k) in dom pWHL by A42,A33,SCMPDS_6:def 2;
          end;
        end;
        hence WHL is_closed_on t,Q by A5,SCMPDS_6:def 2;
A50:     Q7 = Q7 +* pWHL;
        WHL is_halting_on t7, Q7 by A4,A41,A35,A38,A33;
        then Q3 halts_on t7 by A33,A50,SCMPDS_6:def 3;
        then Q3 halts_on t3 by EXTPRO_1:22;
        hence WHL is_halting_on t,Q by A5,SCMPDS_6:def 3;
      end;
    end;
    hence thesis;
  end;
  set n=f.s;
A51: P[0]
  proof
    let t be 0-started State of SCMPDS,Q;
    assume f.t <= 0;
    then f.t=0;
    then
A52: t.b >= 0 by A1;
    assume for x st x in X holds t.x=s.x;
    assume
    t.a=s.a;
    hence thesis by A52,Th7;
  end;
  for k being Nat holds P[k] from NAT_1:sch 2(A51,A3);
  then
A53: P[n];
  (for x be Int_position st x in X holds s.x=s.x);
  hence thesis by A53;
end;
