reserve m,n for Element of NAT,
  i,j for Instruction of SCMPDS,
  I for Program
  of SCMPDS,
  a for Int_position;
reserve Q,U,P for Instruction-Sequence of SCMPDS;

theorem Th6:
  for s being 0-started State of SCMPDS,I being halt-free shiftable
Program of SCMPDS, a,f0,f1 being Int_position,n,i be Element of NAT
 st s.a=0 & s.f0=0 & s.f1=1 & s.intpos i=n &
  (for t be 0-started State of SCMPDS,Q
  for k be
  Element of NAT st n=t.intpos i+k & t.f0=Fib k & t.f1 = Fib (k+1) & t.a=0 & t.
  intpos i > 0 holds IExec(I,Q,t).a=0 & I is_closed_on t,Q
   & I is_halting_on t,Q &
  IExec(I,Q,t).intpos i=t.intpos i-1
   & IExec(I,Q,t).f0=Fib (k+1) &
   IExec(I,Q,t).f1 = Fib (k+1+1))
 holds IExec(while>0(a,i,I),P,s).f0=Fib n
 & IExec(while>0(a,i,I),P,s).
  f1=Fib (n+1) & 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,f0,
  f1 be Int_position,n,i be Element of NAT;
  set Iw=IExec(while>0(a,i,I),P,s), Dw=Initialize Iw;
  set da=DataLoc(s.a,i);
  defpred P[State of SCMPDS] means $1.intpos i >= 0 & ex k be Element of NAT
  st n=$1.intpos i+k & $1.f0=Fib k & $1.f1=Fib (k+1);
  assume that
A1: s.a=0 and
A2: s.f0=0 and
A3: s.f1=1 and
A4: s.intpos i=n;
  consider ff be Function of product the_Values_of SCMPDS,NAT such that
A5: for t be State of SCMPDS holds
    (t.da <= 0 implies ff.t =0) & (t.da > 0 implies ff.t=t.da) by SCMPDS_8:5;
A6: for t be 0-started State of SCMPDS holds
    (t.da <= 0 implies ff.t =0) & (t.da > 0 implies ff.t=t.da) by A5;
  deffunc F(State of SCMPDS) = ff.$1;
A7: for t being 0-started State of SCMPDS st P[t] holds
     not(F(t)=0 & t.da > 0) & (t.da <= 0 implies F(t)=0) by A6;
  assume
A8: for t be 0-started State of SCMPDS,Q
  for k be Element of NAT st n=t.intpos i+k & t.
  f0=Fib k & t.f1 = Fib (k+1) & t.a=0 & t.intpos i > 0
   holds IExec(I,Q,t).a=0 & I is_closed_on t,Q & I is_halting_on t,Q
 & IExec(I,Q,t).intpos i=t.intpos i-1 & IExec(I,Q,t).f0=Fib (k+1)
  & IExec(I,Q,t).f1 = Fib (k+1+1);
A9: now
    let t be 0-started State of SCMPDS, Q;
    assume that
A10: P[t] and
A11: t.a=s.a and
A12: t.DataLoc(s.a,i) > 0;
    set It=IExec(I,Q,t);
    set Dit=Initialize It;
    consider k be Element of NAT such that
A13: n=t.intpos i+k and
A14: t.f0=Fib k and
A15: t.f1=Fib (k+1) by A10;
A16: t.f1=Fib (k+1) by A15;
A17: intpos (0+i)=da by A1,SCMP_GCD:1;
A18: n=t.intpos i+k & t.f0=Fib k by A13,A14;
    hence IExec(I,Q,t).a=t.a by A1,A8,A11,A12,A16,A17;
    thus I is_closed_on t,Q & I is_halting_on t,Q by A1,A8,A11,A12,A18,A16,A17;
A19: It.intpos i=t.intpos i-1 by A1,A8,A11,A12,A18,A16,A17;
    hereby
      per cases;
      suppose
        It.intpos i <= 0;
        then Dit.da <= 0 by A17,SCMPDS_5:15;
        then
A20:    F(Dit)=0 by A6;
        F(t) <> 0 by A7,A10,A12;
        hence F(Dit) < F(t) by A20;
      end;
      suppose
A21:    It.intpos i > 0;
        t.da > 0 by A12;
        then
A22:    F(t)=t.da by A6
          .=t.intpos i by A17;
        Dit.da > 0 by A17,A21,SCMPDS_5:15;
        then F(Dit)=Dit.da by A6
          .=t.intpos i-1 by A17,A19,SCMPDS_5:15;
        hence F(Dit) < F(t) by A22,XREAL_1:146;
      end;
    end;
    thus P[Dit]
    proof
      t.intpos i >= 1+0 by A12,A17,INT_1:7;
      then t.intpos i-1 >= 0 by XREAL_1:48;
      hence Dit.intpos i >= 0 by A19,SCMPDS_5:15;
      take m=k+1;
      thus n=t.intpos i-1+1+k by A13
        .=Dit.intpos i+1+k by A19,SCMPDS_5:15
        .=Dit.intpos i+m;
      It.f0=Fib m & It.f1=Fib (k+1+1) by A1,A8,A11,A12,A18,A16,A17;
      hence thesis by SCMPDS_5:15;
    end;
  end;
A23: P[s]
  proof
    s.intpos i =n by A4;
    hence s.intpos i >= 0;
    take k=0;
    thus n=s.intpos i+k by A4;
    thus s.f0=Fib k by A2,PRE_FF:1;
    thus thesis by A3,PRE_FF:1;
  end;
A24: F(Dw)=0 & P[Dw] from WhileGEnd(A7,A23,A9);
A25: Dw.da = Iw.da by SCMPDS_5:15;
  Dw.intpos i=Iw.intpos(0+i) by SCMPDS_5:15
    .=Iw.da by A1,SCMP_GCD:1;
  then Dw.intpos i <= 0 by A7,A24,A25;
  then Dw.intpos i=0 by A24;
  hence Iw.f0=Fib n & Iw.f1=Fib (n+1) by A24,SCMPDS_5:15;
A26: for t be 0-started State of SCMPDS st P[t] & F(t)=0
       holds t.da <= 0 by A7;
  while>0(a,i,I) is_closed_on s,P & while>0(a,i,I)
  is_halting_on s,P from SCMPDS_8:sch 3(A26,A23,A9);
  hence thesis;
end;
