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

theorem Th23:
  for s being 0-started State of SCMPDS,I being halt-free shiftable
  Program of SCMPDS, a be Int_position, i,c be Integer,X,Y be set,f being
  Function of product the_Values_of SCMPDS,NAT st s.DataLoc(s.a,i) > 0 &
 (for t be 0-started State of SCMPDS st f.t=0 holds t.DataLoc(s.a,i) <= 0) &
 (for x st x in X holds s.x >= c+s.DataLoc(s.a,i)) &
 (for t be 0-started State of SCMPDS,Q
  st (for x st x in X holds t.x >= c+t.DataLoc(s.a,i)) &
  (for x st x in Y holds t.x=s.x) & t.a=s.a & t.DataLoc(s.a,i) > 0
  holds IExec(I,Q,t).a=t.a & I is_closed_on t,Q & I is_halting_on t,Q &
   f.Initialize(IExec(I,Q,t)) < f.t
 & (for x st x in X holds IExec(I,Q,t).x >= c+IExec(I,Q,t).DataLoc(s.a,i))
 & for x st x in Y 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,c be Integer,X,Y be set,
  f be Function of product the_Values_of SCMPDS,NAT;
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 s4 = Comput(P1,s,1), P4 = P1;
A3: IC s = 0 by MEMSTR_0:def 11;
A4: WHL = i1 ';' (I ';' i2) by SCMPDS_4:15;
A5: Comput(P1,s,0+1) = Following(P1,
Comput(P1,s,0)) by EXTPRO_1:3
    .= Following(P1,s)
    .= Exec(i1,s) by A4,A1,SCMPDS_6:11;
  set m0=LifeSpan(P1,s);
  set Es=IExec(I,P,s), bj=DataLoc((Initialize Es).a,i), EP = P;
  assume
A6: for t be 0-started State of SCMPDS st f.t=0 holds t.b <= 0;
  assume
A7: for x st x in X holds s.x >= c+s.b;
  assume
A8: for t be 0-started State of SCMPDS,Q st
 (for x st x in X holds t.x >= c+t.b) &
 (for x st x in Y holds t.x=s.x) & t.a=s.a & t.b > 0
   holds IExec(I,Q,t).a=t.a & I is_closed_on t,Q & I is_halting_on t,Q &
  f.Initialize(IExec(I,Q,t)) < f.t
 & (for x st x in X holds IExec(I,Q,t).x >= c+IExec(I,Q,t).b)
 & for x st x in Y holds IExec(I,Q,t).x=t.x;
  then WHL is_halting_on s, P by A6,A7,Th22;
  then
A9: P1 halts_on s by A1,SCMPDS_6:def 3;
A10: for x st x in Y holds s.x=s.x;
A11: bj = DataLoc(Es.a,i) by SCMPDS_5:15
      .=b by A2,A7,A8,A10;
  set PI = P +* stop I, m1=LifeSpan(PI,s)+2,
  s2=Initialize IExec(I,P,s), P2 = P +* pWHL, m2 =LifeSpan(P2,s2);
A12: stop I c= PI by FUNCT_4:25;
A13: (Initialize IExec(I,P,s)).a = IExec(I,P,s).a by SCMPDS_5:15
       .=s.a by A2,A7,A8,A10;
A14: now
    let t be 0-started State of SCMPDS,Q;
    assume that
A15: for x st x in X holds t.x >= c+t.bj and
A16: for x st x in Y holds t.x=(Initialize Es).x and
A17: t.a=(Initialize Es).a and
A18: t.bj > 0;
A19: now
      let x;
      assume
A20:  x in Y;
      hence t.x=(Initialize Es).x by A16
        .= Es.x by SCMPDS_5:15
        .=s.x by A2,A7,A8,A10,A20;
    end;
    thus (Initialize IExec(I,Q,t)).a = IExec(I,Q,t).a by SCMPDS_5:15
       .=t.a by A8,A13,A15,A17,A18,A19;
A21: t.a = Es.a by A17,SCMPDS_5:15
      .=s.a by A2,A7,A8,A10;
    hence I is_closed_on t,Q & I is_halting_on t,Q by A8,A15,A17,A18,A19;
    thus f.Initialize(IExec(I,Q,t)) < f.t
     by A8,A15,A17,A18,A19,A21;
    thus for x st x in X
     holds (Initialize IExec(I,Q,t)).x >= c+(Initialize IExec(I,Q,t)).bj
    proof let x;
      (Initialize IExec(I,Q,t)).x = IExec(I,Q,t).x &
      (Initialize IExec(I,Q,t)).bj = IExec(I,Q,t).bj by SCMPDS_5:15;
     hence thesis by A8,A13,A15,A17,A18,A19;
    end;
   thus for x st x in Y holds IExec(I,Q,t).x=t.x
     by A8,A15,A17,A18,A19,A21;
  end;
A22:  for x st x in X holds (Initialize Es).x >= c+(Initialize Es).bj
  proof let x;
A23: (Initialize Es).x =Es.x by SCMPDS_5:15;
A24: (Initialize Es).bj =Es.bj by SCMPDS_5:15;
   assume x in X;
   hence (Initialize Es).x >= c+(Initialize Es).bj by A2,A7,A8,A10,A13,A23,A24;
  end;

  for t be 0-started State of SCMPDS,Q st
   (for x st x in X holds t.x >= c+t.DataLoc((Initialize Es).a,i)) &
   (for x st x in Y holds t.x=(Initialize Es).x) & t.a=(Initialize Es).a
    & t.DataLoc((Initialize Es).a,i) > 0
    holds IExec(I,Q,t).a=t.a &
     I is_closed_on t,Q & I is_halting_on t,Q &
     f.Initialize(IExec(I,Q,t)) < f.t
   & (for x st x in X holds
    IExec(I,Q,t).x >= c+IExec(I,Q,t).DataLoc((Initialize Es).a,i))
 & for x st x in Y holds IExec(I,Q,t).x=t.x
  proof let t be 0-started State of SCMPDS,Q such that
A25: for x st x in X holds t.x >= c+t.DataLoc((Initialize Es).a,i) and
A26: for x st x in Y holds t.x=(Initialize Es).x and
A27: t.a=(Initialize Es).a and
A28:  t.DataLoc((Initialize Es).a,i) > 0;
   thus IExec(I,Q,t).a = (Initialize IExec(I,Q,t)).a by SCMPDS_5:15
    .=t.a by A14,A25,A26,A27,A28;
   thus I is_closed_on t,Q & I is_halting_on t,Q
            by A14,A25,A26,A27,A28;
   thus f.Initialize(IExec(I,Q,t)) < f.t
            by A14,A25,A26,A27,A28;
   thus for x st x in X holds
    IExec(I,Q,t).x >= c+IExec(I,Q,t).DataLoc((Initialize Es).a,i)
    proof let x;
      IExec(I,Q,t).x = (Initialize IExec(I,Q,t)).x &
      IExec(I,Q,t).DataLoc((Initialize Es).a,i)
       = (Initialize IExec(I,Q,t)).DataLoc((Initialize Es).a,i)
                by SCMPDS_5:15;
     hence x in X implies
    IExec(I,Q,t).x >= c+IExec(I,Q,t).DataLoc((Initialize Es).a,i)
            by A14,A25,A26,A27,A28;
    end;
   thus for x st x in Y holds IExec(I,Q,t).x=t.x
            by A14,A25,A26,A27,A28;
  end;
  then WHL is_halting_on Initialize Es, EP by A6,A11,Th22,A22;
  then
A29: P +* stop WHL halts_on Initialize Initialize Es by SCMPDS_6:def 3;
  for a holds s.a = s4.a by A5,SCMPDS_2:56;
  then
A30: DataPart s = DataPart s4 by SCMPDS_4:8;
  set mI=LifeSpan(PI,s), s5=Comput(P4,s4,mI), P5 = P4,
  l1= card I + 1;
A31:     WHL c= pWHL by AFINSQ_1:74;
  pWHL c= P1 by FUNCT_4:25;
  then
A32: WHL c= P1 by A31,XBOOLE_1:1;
  set m3=mI +1;
  set s7=Comput(P1,s,m3+1), P7 = P1;
  set s6=Comput(P1,s,m3), P6 = P1;
  card I + 1 < card I + 2 by XREAL_1:6;
  then
A33: l1 in dom WHL by Th16;
  Shift(I,1) c= WHL by Lm4;
  then
A34: Shift(I,1) c= P4 by A32,XBOOLE_1:1;
  I is_halting_on s, P by A2,A7,A8,A10;
  then
A35: PI halts_on s by A1,SCMPDS_6:def 3;
  PI +* stop I halts_on s by A35;
  then
A36: I is_halting_on s, PI by A1,SCMPDS_6:def 3;
A37: IC s4 = IC s + 1 by A2,A5,SCMPDS_2:56
    .= (0+1) by A3;
A38: I is_closed_on s, PI by A2,A7,A8,A10;
  then
A39: IC s5=l1 by A12,A36,A37,A30,A34,SCMPDS_7:18;
A40: P6/.IC s6 = P6.IC s6 by PBOOLE:143;
A41: s6=s5 by EXTPRO_1:4;
  then
A42: CurInstr(P6,s6) =P4.l1 by A12,A36,A38,A37,A30,A34,A40,SCMPDS_7:18
    .=WHL.l1 by A33,A32,GRFUNC_1:2
    .=i2 by Th17;
A43: s7 = Following(P1,s6) by EXTPRO_1:3
    .= Exec(i2,s6) by A42;
  then IC s7=ICplusConst(s6,0-(card I+1)) by SCMPDS_2:54
    .= 0 by A39,A41,SCMPDS_7:1;
  then
A44: IC s2 =IC Comput(P1,s,m1) by MEMSTR_0:def 11;
A45: DataPart Comput(PI,s,mI) = DataPart s5 by A12,A36,A38,A37,A30,A34,
SCMPDS_7:18;
  now
    let x be Int_position;
A46: not x in dom Start-At(0,SCMPDS) by SCMPDS_4:18;
    s5.x=Comput(PI,s,mI).x by A45,SCMPDS_4:8
      .=(Result(PI,s)).x by A35,EXTPRO_1:23
      .=IExec(I,P,s).x by SCMPDS_4:def 5;
    hence s7.x=IExec(I,P,s).x by A41,A43,SCMPDS_2:54
      .=s2.x by A46,FUNCT_4:11;
  end;
  then
A47: DataPart s7 = DataPart s2 by SCMPDS_4:8;
A48: Comput(P1,s,m1)=s2 by A47,A44,MEMSTR_0:78;
  then CurInstr(P1,Comput(P1,s,m1))=i1
   by A4,SCMPDS_6:11;
  then m0 > m1 by A9,EXTPRO_1:36,SCMPDS_6:17;
  then consider nn be Nat such that
A49: m0=m1+nn by NAT_1:10;
  reconsider nn as Nat;
  Comput(P1,s,m1+m2) = Comput(P1,s2,m2) by A48,EXTPRO_1:4;
  then CurInstr(P1,Comput(P1,s,m1+m2))
   = halt SCMPDS by A29,EXTPRO_1:def 15;
  then m1 + m2 >= m0 by A9,EXTPRO_1:def 15;
  then
A50: m2 >= nn by A49,XREAL_1:6;
A51: Comput(P1,s,m0) = Comput(P1,s2,nn) by A48,A49,EXTPRO_1:4;
  then CurInstr(P2,Comput(P2,s2,nn))
   =halt SCMPDS by A9,EXTPRO_1:def 15;
  then nn >= m2 by A29,EXTPRO_1:def 15;
  then nn=m2 by A50,XXREAL_0:1;
  then Result(P1,s) = Comput(P2,s2,m2) by A9,A51,EXTPRO_1:23;
  hence IExec(WHL,P,s) = Comput(P2,s2,m2) by SCMPDS_4:def 5
    .= Result(P2,s2) by A29,EXTPRO_1:23
    .= IExec(WHL,P,Initialize IExec(I,P,s)) by SCMPDS_4:def 5;
end;
