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

theorem Th45:
  for T1,T2 being TuringStr,s1 be All-State of T1,h be Element of
  NAT, t be Tape of T1, s2 be All-State of T2,s3 be All-State of (T1 ';' T2) st
  s1 is Accept-Halt & s1=[the InitS of T1,h,t] & s2 is Accept-Halt & s2=[the
  InitS of T2,(Result s1)`2_3,(Result s1)`3_3] &
    s3=[the InitS of (T1 ';' T2),h,t]
  holds s3 is Accept-Halt & (Result s3)`2_3=(Result s2)`2_3 &
    (Result s3)`3_3=(Result
  s2)`3_3
proof
  let tm1,tm2 be TuringStr,s1 be All-State of tm1,h be Element of NAT, t be
  Tape of tm1, s2 be All-State of tm2, s3 be All-State of (tm1 ';' tm2);
  set p0=the InitS of tm1, q0=the InitS of tm2;
  assume that
A1: s1 is Accept-Halt and
A2: s1=[p0,h,t] and
A3: s2 is Accept-Halt and
A4: s2=[q0,(Result s1)`2_3,(Result s1)`3_3] and
A5: s3=[the InitS of (tm1 ';' tm2),h,t];
  set pF=the AcceptS of tm1, qF=the AcceptS of tm2;
  consider k such that
A6: ((Computation s1).k)`1_3 = pF and
A7: Result s1 = (Computation s1).k and
A8: for i be Nat st i < k holds ((Computation s1).i)`1_3 <> pF
  by A1,Th13;
  defpred P[Nat] means
  $1 <= k implies [((Computation s1).$1)`1_3,q0]
=((Computation s3).$1)`1_3 &
  ((Computation s1).$1)`2_3=((Computation s3).$1)`2_3 & ((
  Computation s1).$1)`3_3=((Computation s3).$1)`3_3;
A9: for i st P[i] holds P[i + 1]
  proof
    let i;
    assume
A10: P[i];
    now
      set s1i1=(Computation s1).(i+1), s1i=(Computation s1).i, s3i1=(
      Computation s3).(i+1), s3i=(Computation s3).i;
A11:  i < i+1 by XREAL_1:29;
      set f=TRAN(s3i);
      reconsider h=Head(s1i) as Element of INT;
      reconsider ss1=s1i`3_3 as Tape of tm1;
      reconsider y=ss1.h as Symbol of tm1;
      reconsider ss3=s3i`3_3 as Tape of tm1 ';' tm2;
      set p=s1i`1_3, g=TRAN(s1i);
      assume
A12:  i+1 <= k;
      then
A13:  i < k by A11,XXREAL_0:2;
      then
A14:  p <> pF by A8;
A15:  s3i`1_3 <> the AcceptS of tm1 ';' tm2
      proof
        assume s3i`1_3 = the AcceptS of tm1 ';' tm2;
        then [p,q0] = [pF,qF] by A10,A12,A11,Def31,XXREAL_0:2;
        hence contradiction by A14,XTUPLE_0:1;
      end;
A16:  f= (the Tran of tm1 ';' tm2).[[p,q0],y] by A10,A12,A11,XXREAL_0:2
        .= [[g`1_3,q0], g`2_3, g`3_3] by A8,A13,Th43;
      then
A17:  g`2_3=f`2_3;
A18:  s3i1=Following s3i by Def7
        .= [f`1_3, Head(s3i)+ offset (f),Tape-Chg(ss3,Head(s3i),f`2_3)]
           by A15,Def6;
A19:  s1i1=Following s1i by Def7
        .= [g`1_3, h+ offset(g),Tape-Chg(ss1,h,g`2_3)] by A14,Def6;
      hence [s1i1`1_3,q0]=[g`1_3,q0]
        .=f`1_3 by A16
        .=s3i1`1_3 by A18;
      offset g=offset f by A16;
      hence s1i1`2_3= Head(s3i) + offset f by A10,A12,A11,A19,XXREAL_0:2
        .= s3i1`2_3 by A18;
      thus s1i1`3_3= ss3 +* (h .--> (g`2_3)) by A10,A12,A11,A19,XXREAL_0:2
        .= s3i1`3_3 by A10,A12,A11,A17,A18,XXREAL_0:2;
    end;
    hence thesis;
  end;
  set s1k=(Computation s1).k, s3k=(Computation s3).k;
A20: s3=[[p0,q0],h,t] by A5,Def31;
A21: P[0]
  proof
    assume 0 <= k;
A22: ((Computation s3).0)`1_3=s3`1_3 by Def7
      .=[p0,q0] by A20;
    ((Computation s1).0)`1_3=s1`1_3 by Def7
      .=p0 by A2;
    hence [((Computation s1).0)`1_3,q0]=((Computation s3).0)`1_3 by A22;
    thus ((Computation s1).0)`2_3=s1`2_3 by Def7
      .=h by A2
      .=s3`2_3 by A5
      .=((Computation s3).0)`2_3 by Def7;
    thus ((Computation s1).0)`3_3=s1`3_3 by Def7
      .=t by A2
      .=s3`3_3 by A5
      .=((Computation s3).0)`3_3 by Def7;
  end;
A23: for i holds P[i] from NAT_1:sch 2(A21,A9);
  then
A24: s1k`2_3=s3k`2_3;
  consider m be Nat such that
A25: ((Computation s2).m)`1_3 = qF and
A26: Result s2 = (Computation s2).m and
A27: for i be Nat st i < m holds ((Computation s2).i)`1_3 <> qF
  by A3,Th13;
  defpred Q[Nat] means
   $1 <= m implies [pF,((Computation s2).$1)`1_3]
=((Computation s3k).$1)`1_3 &
  ((Computation s2).$1)`2_3=((Computation s3k).$1)`2_3 &
  ((Computation s2).$1)`3_3=((Computation s3k).$1)`3_3;
A28: for i st Q[i] holds Q[i + 1]
  proof
    let i;
    assume
A29: Q[i];
    now
      set s2i1=(Computation s2).(i+1), s2i=(Computation s2).i, ski1=(
      Computation s3k).(i+1), ski=(Computation s3k).i;
A30:  i < i+1 by XREAL_1:29;
      reconsider ssk=ski`3_3 as Tape of tm1 ';' tm2;
      set f=TRAN(ski);
      set q=s2i`1_3, g=TRAN(s2i);
      reconsider h=Head(s2i) as Element of INT;
      reconsider ss2=s2i`3_3 as Tape of tm2;
      reconsider y=ss2.h as Symbol of tm2;
      assume
A31:  i+1 <= m;
      then
A32:  f= (the Tran of tm1 ';' tm2).[[pF,q],y] by A29,A30,XXREAL_0:2
        .= [[pF,g`1_3], g`2_3, g`3_3] by Th44;
      then
A33:  g`2_3=f`2_3;
      i < m by A31,A30,XXREAL_0:2;
      then
A34:  q <> qF by A27;
A35:  ski`1_3 <> the AcceptS of tm1 ';' tm2
      proof
        assume ski`1_3 = the AcceptS of tm1 ';' tm2;
        then [pF,q] = [pF,qF] by A29,A31,A30,Def31,XXREAL_0:2;
        hence contradiction by A34,XTUPLE_0:1;
      end;
A36:  ski1=Following ski by Def7
        .= [f`1_3, Head(ski)+ offset (f),Tape-Chg(ssk,Head(ski),f`2_3)]
    by A35,Def6;
A37:  s2i1=Following s2i by Def7
        .= [g`1_3, h+ offset(g),Tape-Chg(ss2,h,g`2_3)] by A34,Def6;
      hence [pF,s2i1`1_3]=[pF,g`1_3]
        .=f`1_3 by A32
        .=ski1`1_3 by A36;
      offset g=offset f by A32;
      hence s2i1`2_3= Head(ski) + offset f by A29,A31,A30,A37,XXREAL_0:2
        .= ski1`2_3 by A36;
      thus s2i1`3_3= ssk +* (h .--> (g`2_3)) by A29,A31,A30,A37,XXREAL_0:2
        .= ski1`3_3 by A29,A31,A30,A33,A36,XXREAL_0:2;
    end;
    hence thesis;
  end;
A38: s1k`3_3=s3k`3_3 by A23;
  set s2m=(Computation s2).m, skm=(Computation s3k).m;
A39: (Computation s3).(k+m)=skm by Th10;
A40: [s1k`1_3,q0]=s3k`1_3 by A23;
A41: Q[0]
  proof
    assume 0 <= m;
    thus [pF,((Computation s2).0)`1_3]=[pF,s2`1_3] by Def7
      .=[pF,q0] by A4
      .=((Computation s3k).0)`1_3 by A6,A40,Def7;
    thus ((Computation s2).0)`2_3=s2`2_3 by Def7
      .=s3k`2_3 by A4,A7,A24
      .=((Computation s3k).0)`2_3 by Def7;
    thus ((Computation s2).0)`3_3=s2`3_3 by Def7
      .=s3k`3_3 by A4,A7,A38
      .=((Computation s3k).0)`3_3 by Def7;
  end;
A42: for i holds Q[i] from NAT_1:sch 2(A41,A28);
  then [pF,s2m`1_3]=skm`1_3;
  then
A43: ((Computation s3).(k+m))`1_3=the AcceptS of tm1 ';' tm2 by A25,A39,Def31;
  hence
A44: s3 is Accept-Halt;
  s2m`2_3=skm`2_3 & s2m`3_3=skm`3_3 by A42;
  hence thesis by A26,A39,A43,A44,Def9;
end;
