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 st s.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 & 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 IExec(while<0(a,i,I),P,s)
      =IExec(while<0(a,i,I),P,Initialize IExec(I,P,s))
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;
A1: Initialize s = s by MEMSTR_0:44;
  set b=DataLoc(s.a,i);
  set WHL=while<0(a,i,I), pWHL = stop WHL, P1 = P +* pWHL;
  set i1=(a,i)>=0_goto (card I+2), i2=goto -(card I+1);
  assume
A2: s.b < 0;
  set Es=IExec(I,P,s), bj=DataLoc((Initialize Es).a,i), EP = P;
  set PI = P +* stop I, m1=LifeSpan(PI,s)+2,
  s2=Initialize IExec(I,P,s), P2 = P +* pWHL,
  m2=LifeSpan(P2,s2);
  assume
A3: 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;
  then WHL is_halting_on s, P by Th13;
  then
A4: P1 halts_on s by A1,SCMPDS_6:def 3;
A5: stop I c= PI by FUNCT_4:25;
A6: for x st x in X holds s.x=s.x;
  then I is_halting_on s, P by A2,A3;
  then
A7: PI halts_on s by A1,SCMPDS_6:def 3;
  PI +* stop I halts_on s by A7;
  then
A8: I is_halting_on s, PI by A1,SCMPDS_6:def 3;
A9: (Initialize Es).a = Es.a by SCMPDS_5:15
       .=s.a by A2,A3,A6;
  now
    let t be 0-started State of SCMPDS, Q;
    assume that
A10: for x st x in X holds t.x=(Initialize Es).x and
A11: t.a=(Initialize Es).a & t.bj < 0;
A12: now
      let x be Int_position;
      assume
A13:  x in X;
      hence t.x = (Initialize Es).x by A10
        .=Es.x by SCMPDS_5:15
        .=s.x by A2,A3,A6,A13;
    end;
    hence IExec(I,Q,t).a=t.a by A3,A9,A11;
    thus IExec(I,Q,t).bj > t.bj by A3,A9,A11,A12;
    thus 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 by A3,A9,A11,A12;
  end;
  then WHL is_halting_on Initialize Es, P by Th13;
  then
A14: P +* stop WHL halts_on Initialize Initialize Es by SCMPDS_6:def 3;
  set m0=LifeSpan(P1,s);
  set s4 = Comput(P1,s,1), P4 = P1;
A15: IC s = 0 by MEMSTR_0:def 11;
A16: WHL = i1 ';' (I ';' i2) by SCMPDS_4:15;
A17: Comput(P1,s,0+1) = Following(P1,
Comput(P1,s,0)) by EXTPRO_1:3
    .= Following(P1,s)
    .= Exec(i1,s) by A16,A1,SCMPDS_6:11;
A18: IC s4 = IC s + 1 by A2,A17,SCMPDS_2:57
    .= (0+1) by A15;
  set mI=LifeSpan(PI,s), s5=Comput(P4,s4,mI), P5 = P4,
  l1= (card I + 1);
  for a holds s.a= s4.a by A17,SCMPDS_2:57;
  then
A19: DataPart s = DataPart s4 by SCMPDS_4:8;
  set m3=mI +1;
  set s6=Comput(P1,s,m3), P6 = P1;
  card I + 1 < card I + 2 by XREAL_1:6;
  then
A20: l1 in dom WHL by Th5;
  set s7=Comput(P1,s,m3+1);
A21:     WHL c= pWHL by AFINSQ_1:74;
   pWHL c= P1 by FUNCT_4:25;
  then
A22: WHL c= P1 by A21,XBOOLE_1:1;
  Shift(I,1) c= WHL by Lm2;
  then
A23: Shift(I,1) c= P4 by A22,XBOOLE_1:1;
A24: I is_closed_on s, PI by A2,A3,A6;
  then
A25: IC s5=l1 by A5,A8,A18,A19,A23,SCMPDS_7:18;
A26: P6/.IC s6 = P6.IC s6 by PBOOLE:143;
A27: s6=s5 by EXTPRO_1:4;
  then
A28: CurInstr(P6,s6) =P4.l1 by A5,A8,A24,A18,A19,A23,A26,SCMPDS_7:18
    .=WHL.l1 by A20,A22,GRFUNC_1:2
    .=i2 by Th6;
A29: s7 = Following(P1,s6) by EXTPRO_1:3
    .= Exec(i2,s6) by A28;
  then IC s7=ICplusConst(s6,0-(card I+1)) by SCMPDS_2:54
    .= 0 by A25,A27,SCMPDS_7:1;
  then
A30: IC s2 =IC Comput(P1,s,m1) by MEMSTR_0:def 11;
A31: DataPart Comput(PI,s,mI) = DataPart s5 by A5,A8,A24,A18,A19,A23,
SCMPDS_7:18;
  now
    let x be Int_position;
A32: not x in dom Start-At(0,SCMPDS) by SCMPDS_4:18;
    s5.x=Comput(PI,s,mI).x by A31,SCMPDS_4:8
      .=(Result(PI,s)).x by A7,EXTPRO_1:23
      .=IExec(I,P,s).x by SCMPDS_4:def 5;
    hence s7.x=IExec(I,P,s).x by A27,A29,SCMPDS_2:54
      .=s2.x by A32,FUNCT_4:11;
  end;
  then
A33: DataPart s7 = DataPart s2 by SCMPDS_4:8;
A34: Comput(P1,s,m1)=s2 by A33,A30,MEMSTR_0:78;
  then CurInstr(P1,Comput(P1,s,m1))=i1 by A16,SCMPDS_6:11;
  then m0 > m1 by A4,EXTPRO_1:36,SCMPDS_6:18;
  then consider nn be Nat such that
A35: m0=m1+nn by NAT_1:10;
  reconsider nn as Nat;
  Comput(P1,s,m1+m2) = Comput(P1,s2,m2) by A34,EXTPRO_1:4;
  then CurInstr(P1,Comput(P1,s,m1+m2))
   = halt SCMPDS by A14,EXTPRO_1:def 15;
  then m1 + m2 >= m0 by A4,EXTPRO_1:def 15;
  then
A36: m2 >= nn by A35,XREAL_1:6;
A37: Comput(P1,s,m0) = Comput(P1,s2,nn) by A34,A35,EXTPRO_1:4;
  then CurInstr(P2,Comput(P2,s2,nn))
   =halt SCMPDS by A4,EXTPRO_1:def 15;
  then nn >= m2 by A14,EXTPRO_1:def 15;
  then nn=m2 by A36,XXREAL_0:1;
  then Result(P1,s) = Comput(P2,s2,m2) by A4,A37,EXTPRO_1:23;
  hence IExec(WHL,P,s) = Comput(P2,s2,m2) by SCMPDS_4:def 5
    .= Result(P2,s2) by A14,EXTPRO_1:23
    .= IExec(WHL,P,Initialize IExec(I,P,s)) by SCMPDS_4:def 5;
end;
