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

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