reserve n,i,j,k for Nat;
reserve T for TuringStr,
  s for All-State of T;

theorem Th31:
  for s being All-State of SuccTuring, t be Tape of SuccTuring,
  head,n be Element of NAT st s=[0,head,t] & t storeData <*head,n*> holds s is
  Accept-Halt & (Result s)`2_3=head & (Result s)`3_3 storeData <*head,n+1*>
proof
  reconsider F=0 as Symbol of SuccTuring by Lm6;
  let s be All-State of SuccTuring,t be Tape of SuccTuring, h,n be Element of
  NAT;
  assume that
A1: s=[0,h,t] and
A2: t storeData <*h,n *>;
A3: t.h=0 by A2,Th17;
  set i3=h+1+1+n+1;
  reconsider h1=h+1 as Element of INT by INT_1:def 2;
  reconsider p1=1 as State of SuccTuring by Lm5;
A4: h1+1+n < i3 by XREAL_1:29;
  h <= h+n by NAT_1:11;
  then
A5: h+2 <= h+n+2 by XREAL_1:7;
A6: h1 < h+2 by XREAL_1:8;
  then
A7: h1 < h+n+2 by A5,XXREAL_0:2;
  reconsider p2=2 as State of SuccTuring by Lm5;
  reconsider i2=h1+1 as Element of INT by INT_1:def 2;
  reconsider nk=h1+1+n as Element of INT by INT_1:def 2;
  reconsider hh=h as Element of INT by INT_1:def 2;
  reconsider n3=i3 as Element of INT by INT_1:def 2;
  reconsider T=1 as Symbol of SuccTuring by Lm6;
  set t1=Tape-Chg(t,h1,T);
A8: h < h1 by XREAL_1:29;
A9: t.(h+n+2)=0 by A2,Th17;
A10: t1.h=0 & t1.(h+n+2)=0 & for i be Integer st h < i & i < h+n+2 holds t1.
  i=1
  proof
    thus t1.h=0 by A3,A8,Th26;
    thus t1.(h+n+2)=0 by A9,A5,A6,Th26;
    hereby
      let i be Integer;
      assume
A11:  h < i & i < h+n+2;
      per cases;
      suppose
        h1=i;
        hence t1.i=1 by Th26;
      end;
      suppose
        h1<>i;
        hence t1.i=t.i by Th26
          .=1 by A2,A11,Th17;
      end;
    end;
  end;
A12: for i be Integer st h+1+1 <= i & i < h+1+1+n holds t1.i=1
  proof
    let i be Integer;
    assume that
A13: h+1+1 <= i and
A14: i < h+1+1+n;
    h1 < h1+1 by XREAL_1:29;
    then h1 < i by A13,XXREAL_0:2;
    then h < i by A8,XXREAL_0:2;
    hence thesis by A10,A14;
  end;
  reconsider s3=s`3_3 as Tape of SuccTuring;
A15: TRAN(s) =Succ_Tran.[s`1_3, s3.Head(s)] by Def17
    .=Succ_Tran.[0,s3.Head(s)] by A1
    .=Succ_Tran.[0,t.Head(s)] by A1
    .=[1,0,1] by A1,A3,Th30;
  then
A16: offset TRAN(s)=1;
  set s1= [p1,h1,t];
  reconsider s3=s1`3_3 as Tape of SuccTuring;
  Tape-Chg(s`3_3, Head(s),(TRAN(s))`2_3)=Tape-Chg(t, Head(s),(TRAN(s))`2_3)
   by A1
    .=Tape-Chg(t,h,(TRAN(s))`2_3) by A1
    .=Tape-Chg(t,h,F) by A15
    .=t by A3,Th24;
  then
A17: Following s = [(TRAN(s))`1_3, Head(s)+offset TRAN(s),t] by A1,Lm7
    .= [1, Head(s)+ offset TRAN(s),t] by A15
    .= s1 by A1,A16;
A18: TRAN(s1) =Succ_Tran.[s1`1_3, s3.Head(s1)] by Def17
    .=Succ_Tran.[p1,s3.Head(s1)]
    .=Succ_Tran.[p1,t.Head(s1)]
    .=Succ_Tran.[1,t.h1]
    .=[1,1,1] by A2,A8,A7,Th17,Th30;
  then
A19: offset TRAN(s1)=1;
  reconsider p1=1 as State of SuccTuring by Lm5;
  set s2=[p1,i2,t1];
  Tape-Chg(s1`3_3, Head(s1),(TRAN(s1))`2_3)=Tape-Chg(t, Head(s1),(TRAN(s1))`2_3
  )
    .=Tape-Chg(t,h1,(TRAN(s1))`2_3)
    .=t1 by A18;
  then
A20: Following s1 = [(TRAN(s1))`1_3,Head(s1)+ offset TRAN(s1),t1] by Lm7
    .= [1,Head(s1)+ offset TRAN(s1),t1] by A18
    .= s2 by A19;
  reconsider p3=3 as State of SuccTuring by Lm5;
  set sn=[p1,nk,t1];
  set t2=Tape-Chg(t1,nk,T);
  set t3=Tape-Chg(t2,n3,F);
  (the Tran of SuccTuring).[p1,1] =[p1,1,1] & p1 <> the AcceptS of
  SuccTuring by Def17,Th30;
  then
A21: (Computation s2).n=[p1,h+1+1+n,t1] by A12,Lm4;
  h1+1 <= h+1+1+n & h1 < h1+1 by NAT_1:11,XREAL_1:29;
  then
A22: h1 < h1+1+n by XXREAL_0:2;
A23: t2.h=0 & for i be Integer st h < i & i <= h+n+2 holds t2.i=1
  proof
    thus t2.h=0 by A8,A10,A22,Th26;
    hereby
      let i be Integer;
      assume that
A24:  h < i and
A25:  i <= h+n+2;
      per cases;
      suppose
A26:    i <> h+n+2;
        then
A27:    i < h+n+2 by A25,XXREAL_0:1;
        thus t2.i=t1.i by A26,Th26
          .=1 by A10,A24,A27;
      end;
      suppose
        i = h+n+2;
        hence t2.i=1 by Th26;
      end;
    end;
  end;
  set sp3=[p3,nk,t3];
  set sm=[p2,n3,t2];
  reconsider sm3=sm`3_3 as Tape of SuccTuring;
A28: the Symbols of SuccTuring = {0,1} by Def17;
A29: now
    per cases by A28,TARSKI:def 2;
    suppose
      t2.n3=1;
      hence Succ_Tran.[2,t2.n3 ]=[p3,0,-1] by Th30;
    end;
    suppose
      t2.n3=0;
      hence Succ_Tran.[2,t2.n3 ]=[p3,0,-1] by Th30;
    end;
  end;
A30: TRAN(sm) =Succ_Tran.[sm`1_3, sm3.Head(sm)] by Def17
    .=Succ_Tran.[2,sm3.Head(sm)]
    .=Succ_Tran.[2,t2.Head(sm)]
    .=[p3,0,-1] by A29;
  then
A31: offset TRAN(sm)=-1;
  set j1=1+1+n, sp5=[p3,hh, t3];
  defpred R[Nat] means
    h+$1 <= nk implies (Computation sp3).$1=[3,
  nk-$1,t3];
  reconsider sn3=sn`3_3 as Tape of SuccTuring;
A32: h+j1 =nk;
  set Rs=(Computation s).(1+1+(n+1+1+(j1+1)));
A33: TRAN(sn) =Succ_Tran.[sn`1_3, sn3.Head(sn)] by Def17
    .=Succ_Tran.[p1,sn3.Head(sn)]
    .=Succ_Tran.[p1,t1.Head(sn)]
    .=[2,1,1] by A10,Th30;
  then
A34: offset TRAN(sn)=1;
A35: h < h1+1+n by A8,A22,XXREAL_0:2;
A36: t3.h=0 & t3.(h+(n+1)+2)=0 & for k be Integer st h < k & k < h+(n+1)+2
  holds t3.k=1
  proof
    thus t3.h=0 by A35,A23,A4,Th26;
    thus t3.(h+(n+1)+2)=0 by Th26;
    hereby
      let i be Integer;
      assume that
A37:  h < i and
A38:  i < h+(n+1)+2;
      i+1 <= h+(n+1)+2 by A38,INT_1:7;
      then
A39:  i <= h+(n+1)+2-1 by XREAL_1:19;
      thus t3.i=t2.i by A38,Th26
        .=1 by A23,A37,A39;
    end;
  end;
  then
A40: t3 is_1_between h,h+(n+1)+2;
  Tape-Chg(sm`3_3, Head(sm),(TRAN(sm))`2_3) =Tape-Chg(t2, Head(sm),(TRAN(sm))
  `2_3)
    .=Tape-Chg(t2,n3,(TRAN(sm))`2_3)
    .=t3 by A30;
  then
A41: Following sm = [(TRAN(sm))`1_3, Head(sm)+ offset TRAN(sm), t3] by Lm7
    .= [p3,Head(sm)+ offset TRAN(sm),t3] by A30
    .= sp3 by A31;
  Tape-Chg(sn`3_3,Head(sn),(TRAN(sn))`2_3)=Tape-Chg(t1, Head(sn),(TRAN(sn))`2_3
  )
    .=Tape-Chg(t1,nk,(TRAN(sn))`2_3)
    .=t2 by A33;
  then
A42: Following sn = [(TRAN(sn))`1_3, Head(sn)+ offset TRAN(sn), t2] by Lm7
    .= [2, Head(sn)+ offset TRAN(sn), t2] by A33
    .= sm by A34;
A43: for k being Nat st R[k] holds R[k+1]
  proof
    let k be Nat;
    assume
A44: R[k];
    now
      reconsider ik=nk-k as Element of INT by INT_1:def 2;
      set k3=nk-k;
A45:  h+k < h+k+1 by XREAL_1:29;
      set sk=[p3,ik,t3];
      reconsider tt=sk`3_3 as Tape of SuccTuring;
      nk <= nk+k by INT_1:6;
      then
A46:  nk -k <= nk by XREAL_1:20;
      assume
A47:  h+(k+1) <= nk;
      then h+k < nk+0 by A45,XXREAL_0:2;
      then
A48:  h-0 < nk-k by XREAL_1:21;
      reconsider ii=nk-k as Element of NAT by A48,INT_1:3;
      h+n+2 < h+n+2+1 by XREAL_1:29;
      then ii < h+(n+1)+2 by A46,XXREAL_0:2;
      then
A49:  t3.ii=1 by A36,A48;
A50:  TRAN(sk) =Succ_Tran.[sk`1_3, tt.Head(sk)] by Def17
        .=Succ_Tran.[p3,tt.Head(sk)]
        .=Succ_Tran.[p3,t3.Head(sk)]
        .=[3,1,-1] by A49,Th30;
      then
A51:  offset TRAN(sk)=-1;
A52:  Tape-Chg(sk`3_3, Head(sk),(TRAN(sk))`2_3)=Tape-Chg(t3,Head(sk), (TRAN(
      sk))`2_3)
        .=Tape-Chg(t3,k3,(TRAN(sk))`2_3)
        .=Tape-Chg(t3,k3,T) by A50
        .=t3 by A49,Th24;
      hereby
        thus (Computation sp3).(k+1)=Following sk by A44,A47,A45,Def7,
XXREAL_0:2
          .= [(TRAN(sk))`1_3, Head(sk)+ offset TRAN(sk), t3] by A52,Lm7
          .= [3, Head(sk)+ offset TRAN(sk), t3] by A50
          .= [3, nk-k+-1, t3] by A51
          .= [3, nk-(k+1), t3];
      end;
    end;
    hence thesis;
  end;
A53: R[0] by Def7;
  for k being Nat holds R[k] from NAT_1:sch 2(A53,A43);
  then
A54: (Computation sp3).j1=[3,nk-j1,t3] by A32
    .=sp5;
A55: now
    reconsider tt=sp5`3_3 as Tape of SuccTuring;
A56: TRAN(sp5) =Succ_Tran.[sp5`1_3, tt.Head(sp5)] by Def17
      .=Succ_Tran.[3,tt.Head(sp5)]
      .=Succ_Tran.[3,t3.Head(sp5)]
      .=[4,0,0] by A36,Th30;
    then
A57: offset TRAN(sp5)=0;
    Tape-Chg(sp5`3_3, Head(sp5),(TRAN(sp5))`2_3) =Tape-Chg(t3, Head(sp5),(
    TRAN(sp5))`2_3)
      .=Tape-Chg(t3,h,(TRAN(sp5))`2_3)
      .=Tape-Chg(t3,h,F) by A56
      .=t3 by A36,Th24;
    hence Following sp5 = [(TRAN(sp5))`1_3, Head(sp5)+ offset TRAN(sp5), t3]
by Lm7
      .= [4, Head(sp5)+ offset TRAN(sp5), t3] by A56
      .= [4, h+ 0, t3] by A57;
  end;
  Rs=(Computation (Computation s).(1+1)).(n+1+1+(j1+1)) by Th10
    .=(Computation Following (Computation s).1).(n+1+1+(j1+1)) by Def7
    .=(Computation Following s1).(n+1+1+(j1+1)) by A17,Th9
    .=(Computation (Computation s2).(n+1+1)).(j1+1) by A20,Th10
    .=(Computation Following (Computation s2).(n+1)).(j1+1) by Def7;
  then Rs=(Computation sp3).(j1+1) by A21,A42,A41,Def7;
  then
A58: Rs=[4, h, t3] by A54,A55,Def7;
  then
A59: Rs`1_3 = 4
    .=the AcceptS of SuccTuring by Def17;
  hence s is Accept-Halt;
  then
A60: Result s =Rs by A59,Def9;
  hence (Result s)`2_3= h by A58;
  (Result s)`3_3= t3 by A58,A60;
  hence thesis by A40,Th16;
end;
