Theory AlphabetEnlargement_ForwardStage

theory AlphabetEnlargement_ForwardStage
  imports AlphabetEnlargement_ForwardStep
begin

subsection ‹Per-tape unified forward stage›

text ‹The primary forward-stage statement, feeding
  ‹ae_simulation_phase_step_count› (theory
  ‹AlphabetEnlargement_Acceptance›).  Tip of the forward-stage
  chain ‹ForwardCells → ForwardStep → ForwardStage›: it
  applies the SS5‹→›SS8 super-step
  (‹ae_forward_stage_step_chain›) and the per-tape reconstruction
  leaves (theory ‹AlphabetEnlargement_ForwardCells›) to advance the
  simulation by one ‹M›-step.

  Each tape ‹k› picks its regime (steady / le1 / le0)
  independently from its own ‹mt_pos c' k›; mixed
  configurations across tapes are handled natively, with no
  uniform-regime case-split at the call site.  Per-tape dispatch is
  mandatory: the regimes can differ from tape to tape.

  The ‹no_le_per_tape› hypothesis bundles a per-tape
  LE-free window whose start and width depend on the tape's
  block position: ‹3c›-cell window starting at the
  left neighbour for steady tapes, ‹2c›-cell window
  starting at position 1 for le1 tapes, ‹c›-cell window
  starting at position 1 for le0 tapes.  Discharged at the call
  site via substrate's ‹valid_reach_LE_only_pos0_mttm›
  for any reach-from-init configuration.

  The displacement disjunct's leftward branch is conditioned on
  ‹mt_pos c' kk > 0› — le0 tapes cannot move left from
  block 0.›

lemma ae_simulates_forward_stage_general:
  fixes M :: "('q, 'a) mttm"
    and cM cM_k :: "('a, 'q) mt_config"
    and c' :: "('c :: enum ⇒ 'a,
                'q × ('a, 'c) ae_stage) mt_config"
    and k :: nat
  assumes vM:        "valid_mttm M"
      and lu:        "le_unique M"
      and sim:       "ae_simulates M cM c'"
      and qM_in_Q:   "mt_state cM ∈ Q_tm M"
      and q_neq_t:   "mt_state cM ≠ t_tm M"
      and q_neq_r:   "mt_state cM ≠ r_tm M"
      and buf_gamma: "ae_buffer_in_gamma_block M c'"
      and k_le:      "k ≤ card (UNIV :: 'c set)"
      and trace:     "(cM, cM_k) ∈ mttm_step (delta_tm M) ^^ k"
      and end_or_halt:
            "k = card (UNIV :: 'c set)
              ∨ mt_state cM_k ∈ {t_tm M, r_tm M}"
      and le_anchor:
            "∀k<k_tm M. mt_tape c' k 0 = LE_block (le_tm M)"
      and le_neq_bl:
            "le_tm M ≠ bl_tm M"
      and no_le_per_tape:
            "∀k. (mt_pos c' k ≥ 2
                    ⟶ (∀i. i < 3 * card (UNIV :: 'c set)
                              ⟶ mt_tape cM k
                                    ((mt_pos c' k - 2) * card (UNIV :: 'c set) + 1 + i)
                                  ≠ le_tm M))
                 ∧ (mt_pos c' k = 1
                      ⟶ (∀i. i < 2 * card (UNIV :: 'c set)
                                ⟶ mt_tape cM k (Suc i) ≠ le_tm M))
                 ∧ (mt_pos c' k = 0
                      ⟶ (∀i. i < card (UNIV :: 'c set)
                                ⟶ mt_tape cM k (Suc i) ≠ le_tm M))"
  obtains c'' c1 c2 c3 c4 c5 c6 c7 ofs_f buf_f dest_f where
      "(c', c'') ∈ mttm_step (alphabet_enlarge_delta M) ^^ 8"
    and "ae_simulates M cM_k c''"
    and "ae_buffer_in_gamma_block M c''"
    and "∀kk<k_tm M. mt_tape c'' kk 0 = LE_block (le_tm M)"
    ― ‹SS5 exposure for the det-free reverse arm
        (‹nae_sim_proto›): the full substep chain, the SS5 state
        shape + window correspondence in ‹(dest, ofs)› bp form, and
        the buffer ‹γ›-block carrying the frozen inactive
        tails.›
    and "(c', c1) ∈ mttm_step (ae_delta_ss1_ss2 M)"
    and "(c1, c2) ∈ mttm_step (ae_delta_ss2_ss3 M)"
    and "(c2, c3) ∈ mttm_step (ae_delta_ss3_ss4 M)"
    and "(c3, c4) ∈ mttm_step (ae_delta_ss4_ss5 M)"
    and "(c4, c5) ∈ mttm_step (ae_delta_ss5_ss6 M)"
    and "(c5, c6) ∈ mttm_step (ae_delta_ss6_ss7 M)"
    and "(c6, c7) ∈ mttm_step (ae_delta_ss7_ss8 M)"
    and "(c7, c'') ∈ mttm_step (ae_delta_ss8_ss1 M)"
    and "mt_state c4 = (mt_state cM_k, ofs_f, buf_f, dest_f, SS5)"
    and "∀kk<k_tm M. ae_window_invariant_general
              (mt_tape cM_k kk) (mt_pos cM_k kk)
              (dest_f kk, ofs_f kk) (buf_f kk) (mt_pos c' kk) (le_tm M)"
    and "ae_buffer_in_gamma_block M c4"
proof -
  ― ‹Unpack ‹ae_simulates› at SS1 entry via the shared
      regime-agnostic helper.  No regime-specific hypothesis enters
      here — the unpack is uniform across steady / le1 / le0.›
  obtain qM' ofs buf dest where
      c'_state: "mt_state c' = (qM', ofs, buf, dest, SS1)"
    and qM_eq: "mt_state cM = qM'"
    and qM'_in_Q: "qM' ∈ Q_tm M"
    and qM'_neq_t: "qM' ≠ t_tm M"
    and qM'_neq_r: "qM' ≠ r_tm M"
    and tape_corr: "∀k<k_tm M. ae_tape_correspondence (le_tm M)
                          (mt_tape cM k) (mt_tape c' k)"
    and pos_corr:  "∀k<k_tm M. mt_pos cM k = ae_decode_pos (mt_pos c' k) (ofs k)"
    and gamma_c':  "ae_tape_in_gamma_block M c'"
    and inv_ss1:   "ae_inv_ss1 M c'"
    and pos_link_c': "ae_position_link M c'"
    by (rule ae_forward_stage_unpack_sim[OF sim qM_in_Q q_neq_t q_neq_r])

  ― ‹Buffer-load substeps SS1‹→›SS2‹→›SS3
      ‹→›SS4 via the shared regime-agnostic load-chain
      helper.  Yields the SS4-entry config ‹c3› together with
      its SS4 invariant, gamma and buffer-gamma side-bands, state
      preservation, and position-link side-band.  Each per-tape
      branch will refine the buffer-content characterisation
      separately in the regime-aware substeps that follow.›
  obtain c1 c2 c3 where
      step1_sub: "(c', c1) ∈ mttm_step (ae_delta_ss1_ss2 M)"
    and step1:   "(c', c1) ∈ mttm_step (alphabet_enlarge_delta M)"
    and step2_sub: "(c1, c2) ∈ mttm_step (ae_delta_ss2_ss3 M)"
    and step2:   "(c1, c2) ∈ mttm_step (alphabet_enlarge_delta M)"
    and step3_sub: "(c2, c3) ∈ mttm_step (ae_delta_ss3_ss4 M)"
    and step3:   "(c2, c3) ∈ mttm_step (alphabet_enlarge_delta M)"
    and inv_ss4: "ae_inv_ss4 M c3"
    and gamma_c3:    "ae_tape_in_gamma_block M c3"
    and buf_gamma_c3: "ae_buffer_in_gamma_block M c3"
    and c3_fst_eq:   "fst (mt_state c3) = qM'"
    and pos_link_c3: "ae_position_link M c3"
    by (rule ae_forward_stage_load_chain[OF vM c'_state inv_ss1 gamma_c'
                                            buf_gamma pos_link_c'
                                            qM'_neq_t qM'_neq_r])
  have c3_fst_neq_t: "fst (mt_state c3) ≠ t_tm M"
    using c3_fst_eq qM'_neq_t by simp
  have c3_fst_neq_r: "fst (mt_state c3) ≠ r_tm M"
    using c3_fst_eq qM'_neq_r by simp

  ― ‹Per-tape home-cell classification: each tape ‹k›
      either has ‹mt_pos c' k = 0› with home = ‹LE_block›
      (forward arm via ‹le_anchor›) or
      ‹mt_pos c' k ≥ 1› with home ‹≠ LE_block›
      (backward arm via ‹ae_tape_correspondence› at the home
      block with witness ‹c_idx x = 0›, projecting
      ‹no_le_per_tape› to the regime branch).›
  have c_ge_1: "1 ≤ card (UNIV :: 'c set)"
    using c_idx_lt_card[of "SOME x :: 'c. True"] by simp
  have c_eq_len: "card (UNIV :: 'c set) = length (enum_class.enum :: 'c list)"
    using enum_class.UNIV_enum enum_class.enum_distinct
    by (metis distinct_card length_remdups_card_conv set_remdups)

  have home_classification:
      "∀k<k_tm M. (mt_pos c' k = 0
              ⟶ mt_tape c' k (mt_pos c' k) = LE_block (le_tm M))
           ∧ (mt_pos c' k ≥ 1
              ⟶ mt_tape c' k (mt_pos c' k) ≠ LE_block (le_tm M))"
    by (rule ae_home_classification[OF le_anchor no_le_per_tape tape_corr])

  ― ‹SS4-entry characterisation via the per-tape unified
      buffer-chars helper.  Buffer at SS4 is per-tape: tapes at
      ‹pos = 0› get ‹(bl_block, LE_block, snd (snd (buf k)))›
      (the LE-arm shape from ‹ae_ss1_to_ss4_buffer_chars_le0›);
      tapes at ‹pos ≥ 1› get ‹(mt_tape c' k (pos - 1),
      mt_tape c' k pos, snd (snd (buf k)))› (the steady-arm shape
      from ‹ae_ss1_to_ss4_buffer_chars›).  Tape and position
      conclusions are uniform across regimes.›
  have c3_state:
      "mt_state c3 = (qM', ofs,
                       (λk. if k < k_tm M
                              then (if mt_pos c' k = 0
                                      then (bl_block (bl_tm M),
                                            LE_block (le_tm M),
                                            snd (snd (buf k)))
                                      else (mt_tape c' k (mt_pos c' k - 1),
                                            mt_tape c' k (mt_pos c' k),
                                            snd (snd (buf k))))
                              else init_buffer (le_tm M) k),
                       dest, SS4)"
    using ae_ss1_to_ss4_buffer_chars_general(1)[OF c'_state step1_sub
                                                   step2_sub step3_sub
                                                   home_classification] .
  have c3_tape: "mt_tape c3 = mt_tape c'"
    using ae_ss1_to_ss4_buffer_chars_general(2)[OF c'_state step1_sub
                                                   step2_sub step3_sub
                                                   home_classification] .
  have c3_pos: "⋀k. k < k_tm M ⟹ mt_pos c3 k = mt_pos c' k + 1"
    using ae_ss1_to_ss4_buffer_chars_general(3)[OF c'_state step1_sub
                                                   step2_sub step3_sub
                                                   home_classification] .

  ― ‹Per-tape SS4 window invariant via the unified
      from-correspondence helper.  The buffer triple is the
      regime-aware shape that ‹ae_delta_ss4_ss5› reads from
      ‹c3›: left and home from the SS4-entry per-tape buffer,
      right freshly read at ‹mt_pos c' k + 1›.  The conclusion
      is the per-tape ‹ae_window_invariant_general›, indexed
      by ‹mt_pos c' k› (the frozen regime selector).›
  have window_at_ss4:
      "∀k<k_tm M. ae_window_invariant_general
              (mt_tape cM k) (mt_pos cM k)
              (AE_Home, ofs k)
              (if mt_pos c' k = 0
                 then (bl_block (bl_tm M),
                       LE_block (le_tm M),
                       mt_tape c' k 1)
               else if mt_pos c' k = 1
                 then (mt_tape c' k 0,
                       mt_tape c' k 1,
                       mt_tape c' k 2)
               else (mt_tape c' k (mt_pos c' k - 1),
                     mt_tape c' k (mt_pos c' k),
                     mt_tape c' k (mt_pos c' k + 1)))
              (mt_pos c' k)
              (le_tm M)"
    using ae_ss4_window_from_correspondence_general[OF sim c'_state
                                                       le_anchor
                                                       no_le_per_tape] .

  ― ‹Re-express ‹cM› via ‹ConfigM› to
      match the trace lemma's toolkit hypothesis shape (arm-uniform
      with le0 / le1 / steady).  Surfaces ‹ts_cM = mt_tape cM›
      and ‹n_cM = mt_pos cM› for direct substitution into the
      trace, no-LE and window hypotheses.›
  obtain ts_cM n_cM where cM_eq:
      "cM = ConfigM qM' ts_cM n_cM"
    using qM_eq by (cases cM) auto
  have ts_cM_eq: "ts_cM = mt_tape cM" using cM_eq by simp
  have n_cM_eq: "n_cM = mt_pos cM" using cM_eq by simp

  ― ‹Trace toolkit: rewrite the precondition's
      ‹(cM, cM_k) ∈ mttm_step^^k› shape into the trace
      lemma's
      ‹(ConfigM (fst (mt_state c3)) ts_cM n_cM, cM_k) ∈ …›
      form, via ‹cM_eq› and ‹c3_fst_eq›.›
  have trace_toolkit:
      "(ConfigM (fst (mt_state c3)) ts_cM n_cM, cM_k)
          ∈ mttm_step (delta_tm M) ^^ k"
    using trace cM_eq c3_fst_eq by simp

  ― ‹No-LE toolkit: rephrase ‹no_le_per_tape› in terms
      of ‹ts_cM› (= ‹mt_tape cM›) for the trace lemma's
      ‹tsM›-parameter.  Same shape modulo the rewrite of
      ‹mt_tape cM› to ‹ts_cM›.›
  have no_le_toolkit_general:
      "∀kk. (mt_pos c' kk = 0
              ⟶ (∀i. i < card (UNIV :: 'c set)
                        ⟶ ts_cM kk (Suc i) ≠ le_tm M))
           ∧ (mt_pos c' kk = 1
                ⟶ (∀i. i < 2 * card (UNIV :: 'c set)
                          ⟶ ts_cM kk (Suc i) ≠ le_tm M))
           ∧ (mt_pos c' kk ≥ 2
                ⟶ (∀i. i < 3 * card (UNIV :: 'c set)
                          ⟶ ts_cM kk
                                ((mt_pos c' kk - 2) * card (UNIV :: 'c set)
                                  + 1 + i)
                              ≠ le_tm M))"
    using no_le_per_tape ts_cM_eq by simp

  ― ‹Left-slot guard for pos=0 tapes at ‹c3›: the SS4-entry
      left slot for tapes at block 0 is ‹bl_block (bl_tm M)›
      (per ‹c3_state›'s if-branch), distinct from
      ‹LE_block (le_tm M)› via ‹le_neq_bl›.  Le1 and
      steady tapes carry no obligation here (the trace lemma's
      hypothesis is ‹pos k = 0 ⟶ …›).›
  have bl_neq_le:
      "(bl_block (bl_tm M) :: 'c ⇒ 'a) ≠ LE_block (le_tm M)"
  proof
    assume eq: "(bl_block (bl_tm M) :: 'c ⇒ 'a) = LE_block (le_tm M)"
    have "bl_block (bl_tm M) (SOME x :: 'c. True)
            = LE_block (le_tm M) (SOME x :: 'c. True)"
      using eq by simp
    hence "bl_tm M = le_tm M"
      unfolding bl_block_def LE_block_def by simp
    with le_neq_bl show False by simp
  qed
  have left_not_le_c3_toolkit:
      "case mt_state c3 of (_, _, b, _, _) ⇒
           ∀kk<k_tm M. mt_pos c' kk = 0
                 ⟶ fst (b kk) ≠ LE_block (le_tm M)"
    using c3_state bl_neq_le by simp

  ― ‹Window-invariant toolkit: convert ‹window_at_ss4›
      from its ‹c'›-tape if-then-else form into the
      ‹case mt_state c3› form expected by the trace lemma.
      Per-tape regime case-split on ‹mt_pos c' kk›; in each
      branch, ‹c3_state›'s if-then-else and the
      ‹window_at_ss4› nested-if reduce to the same buffer triple.›
  have window_toolkit_general:
      "∀kk<k_tm M. ae_window_invariant_general (ts_cM kk) (n_cM kk)
              (case mt_state c3 of (_, ofs', _, _, _)
                  ⇒ (AE_Home, ofs' kk))
              (case mt_state c3 of (_, _, buf', _, _)
                  ⇒ (fst (buf' kk), fst (snd (buf' kk)),
                      mt_tape c3 kk (mt_pos c3 kk)))
              (mt_pos c' kk) (le_tm M)"
  proof (intro allI impI)
    fix kk
    assume kklt: "kk < k_tm M"
    have c3_buf_triple:
        "(case mt_state c3 of (_, _, buf', _, _) ⇒
              (fst (buf' kk), fst (snd (buf' kk)),
               mt_tape c3 kk (mt_pos c3 kk)))
          = (if mt_pos c' kk = 0
                then (bl_block (bl_tm M), LE_block (le_tm M),
                      mt_tape c' kk (mt_pos c' kk + 1))
             else (mt_tape c' kk (mt_pos c' kk - 1),
                   mt_tape c' kk (mt_pos c' kk),
                   mt_tape c' kk (mt_pos c' kk + 1)))"
      using c3_state c3_tape c3_pos kklt by simp
    have c3_ofs_pair:
        "(case mt_state c3 of (_, ofs', _, _, _) ⇒ (AE_Home, ofs' kk))
          = (AE_Home, ofs kk)"
      using c3_state by simp
    have win_at_ss4_kk:
        "ae_window_invariant_general (mt_tape cM kk) (mt_pos cM kk)
              (AE_Home, ofs kk)
              (if mt_pos c' kk = 0
                 then (bl_block (bl_tm M), LE_block (le_tm M),
                       mt_tape c' kk 1)
               else if mt_pos c' kk = 1
                 then (mt_tape c' kk 0,
                       mt_tape c' kk 1,
                       mt_tape c' kk 2)
               else (mt_tape c' kk (mt_pos c' kk - 1),
                     mt_tape c' kk (mt_pos c' kk),
                     mt_tape c' kk (mt_pos c' kk + 1)))
              (mt_pos c' kk) (le_tm M)"
      using window_at_ss4 kklt by blast
    consider (le0) "mt_pos c' kk = 0"
           | (le1) "mt_pos c' kk = 1"
           | (steady) "mt_pos c' kk ≥ 2"
      by linarith
    thus "ae_window_invariant_general (ts_cM kk) (n_cM kk)
            (case mt_state c3 of (_, ofs', _, _, _)
                ⇒ (AE_Home, ofs' kk))
            (case mt_state c3 of (_, _, buf', _, _)
                ⇒ (fst (buf' kk), fst (snd (buf' kk)),
                    mt_tape c3 kk (mt_pos c3 kk)))
            (mt_pos c' kk) (le_tm M)"
    proof cases
      case le0
      show ?thesis
        using win_at_ss4_kk c3_buf_triple c3_ofs_pair le0
              ts_cM_eq n_cM_eq
        by simp
    next
      case le1
      show ?thesis
        using win_at_ss4_kk c3_buf_triple c3_ofs_pair le1
              ts_cM_eq n_cM_eq
        by (simp add: numeral_2_eq_2)
    next
      case steady
      have pos_ne_0: "mt_pos c' kk ≠ 0" using steady by simp
      have pos_ne_1: "mt_pos c' kk ≠ 1" using steady by simp
      show ?thesis
        using win_at_ss4_kk c3_buf_triple c3_ofs_pair pos_ne_0 pos_ne_1
              ts_cM_eq n_cM_eq
        by simp
    qed
  qed

  ― ‹Invoke the trace-driven SS4‹→›SS5 helper
      for the per-tape unified case.  The trace lemma's
      ‹pos› parameter is inferred from
      ‹window_toolkit_general›'s ‹mt_pos c' kk›
      regime selector, giving ‹pos := mt_pos c'›.›
  obtain c4 where
      step4_sub: "(c3, c4) ∈ mttm_step (ae_delta_ss4_ss5 M)"
    and step4: "(c3, c4) ∈ mttm_step (alphabet_enlarge_delta M)"
    and c4_q_out: "case mt_state c4 of (q_out, _, _, _, _)
                     ⇒ q_out = mt_state cM_k"
    and c4_buf_not_le_per_tape:
            "case mt_state c4 of (_, _, b, _, _) ⇒
                 ∀kk<k_tm M. (mt_pos c' kk = 0
                        ⟶ fst (b kk) ≠ LE_block (le_tm M)
                          ∧ snd (snd (b kk)) ≠ LE_block (le_tm M))
                     ∧ (mt_pos c' kk = 1
                          ⟶ fst (snd (b kk)) ≠ LE_block (le_tm M)
                            ∧ snd (snd (b kk)) ≠ LE_block (le_tm M))
                     ∧ (mt_pos c' kk ≥ 2
                          ⟶ fst (b kk) ≠ LE_block (le_tm M)
                            ∧ fst (snd (b kk)) ≠ LE_block (le_tm M)
                            ∧ snd (snd (b kk)) ≠ LE_block (le_tm M))"
    and c4_window_general:
            "case mt_state c4 of (_, ofs', buf', dest', _) ⇒
                 ∀kk<k_tm M. ae_window_invariant_general
                       (mt_tape cM_k kk) (mt_pos cM_k kk)
                       (dest' kk, ofs' kk) (buf' kk)
                       (mt_pos c' kk) (le_tm M)"
    using ae_step_ss4_ss5_exists_general_trace[OF vM lu inv_ss4 gamma_c3
                                                  buf_gamma_c3
                                                  c3_fst_neq_t c3_fst_neq_r
                                                  window_toolkit_general
                                                  no_le_toolkit_general
                                                  trace_toolkit k_le
                                                  end_or_halt
                                                  left_not_le_c3_toolkit]
    by blast

  ― ‹Sub-step 5a: SS5‹→›SS6 invocation.  Arm-uniform with
      the three per-regime variants: ‹inv_ss5›, gamma + buf-gamma
      at ‹c4› propagate from ‹c3› via the arm-agnostic
      preservation lemmas.  ‹ae_step_ss5_ss6_exists› takes only
      these three (no pos-link required at SS5), so ‹c5› is
      obtained directly.›
  have inv_ss5: "ae_inv_ss5 M c4"
    using ae_step_ss4_ss5_invariant[OF vM inv_ss4 step4_sub] .
  have gamma_c4: "ae_tape_in_gamma_block M c4"
    using ae_step_alphabet_enlarge_gamma_preserve[OF gamma_c3 step4] .
  have buf_gamma_c4: "ae_buffer_in_gamma_block M c4"
    using ae_step_alphabet_enlarge_buffer_gamma_preserve[OF vM buf_gamma_c3
                                                            gamma_c3 step4] .
  ― ‹The SS5‹→›SS8 super-step: extracted to
      ‹ae_forward_stage_step_chain›.  Re-binds the 12 intermediate
      witnesses and 29 named facts the per-tape reconstruction below
      consumes.›
  obtain c5 q5 ofs5 buf5 dest5 c6 c7 q6 ofs6 buf6 dest6 c8
    where step5_sub: "(c4, c5) ∈ mttm_step (ae_delta_ss5_ss6 M)"
      and step5: "(c4, c5) ∈ mttm_step (alphabet_enlarge_delta M)"
      and c4_state: "mt_state c4 = (q5, ofs5, buf5, dest5, SS5)"
      and c5_state: "mt_state c5 = (q5, ofs5, buf5, dest5, SS6)"
      and tape_c4_eq_c': "mt_tape c4 = mt_tape c'"
      and buf5_not_le_per_tape:
      "∀k<k_tm M. (mt_pos c' k = 0
      ⟶ fst (buf5 k) ≠ LE_block (le_tm M)
      ∧ snd (snd (buf5 k)) ≠ LE_block (le_tm M))
      ∧ (mt_pos c' k = 1
      ⟶ fst (snd (buf5 k)) ≠ LE_block (le_tm M)
      ∧ snd (snd (buf5 k)) ≠ LE_block (le_tm M))
      ∧ (mt_pos c' k ≥ 2
      ⟶ fst (buf5 k) ≠ LE_block (le_tm M)
      ∧ fst (snd (buf5 k)) ≠ LE_block (le_tm M)
      ∧ snd (snd (buf5 k)) ≠ LE_block (le_tm M))"
      and right_not_le_c':
      "∀k. mt_tape c' k (mt_pos c' k + 1) ≠ LE_block (le_tm M)"
      and c4_pos_all: "∀kk. kk < k_tm M ⟶ mt_pos c4 kk = mt_pos c' kk"
      and tape_c5_zero_le: "∀k<k_tm M. mt_tape c5 k 0 = LE_block (le_tm M)"
      and c5_pos_for_pos1_all:
      "∀kk. kk < k_tm M ⟶ mt_pos c' kk = 1 ⟶ dest5 kk ≠ AE_Left
      ⟶ mt_pos c5 kk = 0"
      and step6_sub: "(c5, c6) ∈ mttm_step (ae_delta_ss6_ss7 M)"
      and step6: "(c5, c6) ∈ mttm_step (alphabet_enlarge_delta M)"
      and step7_sub: "(c6, c7) ∈ mttm_step (ae_delta_ss7_ss8 M)"
      and step7: "(c6, c7) ∈ mttm_step (alphabet_enlarge_delta M)"
      and gamma_c7: "ae_tape_in_gamma_block M c7"
      and buf_gamma_c7: "ae_buffer_in_gamma_block M c7"
      and c6_state: "mt_state c6 = (q6, ofs6, buf6, dest6, SS7)"
      and c7_state: "mt_state c7 = (q6, ofs6, buf6, dest6, SS8)"
      and buf6_eq_buf5: "buf6 = buf5"
      and q6_eq_q5: "q6 = q5"
      and ofs6_eq_ofs5: "ofs6 = ofs5"
      and dest6_eq_dest5: "dest6 = dest5"
      and c5_pos_for_pos1_dest_left_all:
      "∀kk. kk < k_tm M ⟶ mt_pos c' kk = 1 ⟶ dest5 kk = AE_Left
      ⟶ mt_pos c5 kk = 2"
      and tape_c5_at_one_pos1_all:
      "∀kk. kk < k_tm M ⟶ mt_pos c' kk = 1
      ⟶ mt_tape c5 kk 1 = fst (snd (buf5 kk))"
      and c6_pos_for_pos1_dest_left_all:
      "∀kk. kk < k_tm M ⟶ mt_pos c' kk = 1 ⟶ dest5 kk = AE_Left
      ⟶ mt_pos c6 kk = 1"
      and c7_pos_for_pos1_dest_left_all:
      "∀kk. kk < k_tm M ⟶ mt_pos c' kk = 1 ⟶ dest5 kk = AE_Left
      ⟶ mt_pos c7 kk = 0"
      and tape_c7_zero_le_pos1_dest_left_all:
      "∀kk. kk < k_tm M ⟶ mt_pos c' kk = 1 ⟶ dest5 kk = AE_Left
      ⟶ mt_tape c7 kk 0 = LE_block (le_tm M)"
      and step8_sub: "(c7, c8) ∈ mttm_step (ae_delta_ss8_ss1 M)"
      and step8: "(c7, c8) ∈ mttm_step (alphabet_enlarge_delta M)"
    by (rule ae_forward_stage_step_chain[OF vM le_anchor no_le_per_tape
          tape_corr step1_sub step2_sub step3_sub c_ge_1 c_eq_len
          home_classification c3_pos bl_neq_le step4_sub c4_buf_not_le_per_tape
          inv_ss5 gamma_c4 buf_gamma_c4])
  ― ‹Recover the ‹⋀kk› form of the per-tape facts
      (the chain helper exposes them as ‹∀kk› to survive
      elim-resolution) so the per-tape
      reconstruction below uses them unchanged.›
  note c4_pos = c4_pos_all[rule_format]
  note c5_pos_for_pos1 = c5_pos_for_pos1_all[rule_format]
  note c5_pos_for_pos1_dest_left = c5_pos_for_pos1_dest_left_all[rule_format]
  note tape_c5_at_one_pos1 = tape_c5_at_one_pos1_all[rule_format]
  note c6_pos_for_pos1_dest_left = c6_pos_for_pos1_dest_left_all[rule_format]
  note c7_pos_for_pos1_dest_left = c7_pos_for_pos1_dest_left_all[rule_format]
  note tape_c7_zero_le_pos1_dest_left = tape_c7_zero_le_pos1_dest_left_all[rule_format]
  ― ‹Sub-step 6a: chain composition + c8 state shape +
      arm-uniform reconstruction facts (‹sim_i›, ‹sim_ii›, gamma, buf-gamma).
      The chain composition uses ‹relpow_Suc_I› Suc-by-Suc; the c8
      state shape is the halt-aware ‹?stage8› let-term from
      ‹ae_delta_ss8_ss1›.›
  let ?rel = "mttm_step (alphabet_enlarge_delta M)"
  have chain1: "(c', c1) ∈ ?rel ^^ Suc 0"
    using step1 by simp
  have chain2: "(c', c2) ∈ ?rel ^^ Suc (Suc 0)"
    using chain1 step2 by (rule relpow_Suc_I)
  have chain3: "(c', c3) ∈ ?rel ^^ Suc (Suc (Suc 0))"
    using chain2 step3 by (rule relpow_Suc_I)
  have chain4: "(c', c4) ∈ ?rel ^^ Suc (Suc (Suc (Suc 0)))"
    using chain3 step4 by (rule relpow_Suc_I)
  have chain5: "(c', c5) ∈ ?rel ^^ Suc (Suc (Suc (Suc (Suc 0))))"
    using chain4 step5 by (rule relpow_Suc_I)
  have chain6: "(c', c6) ∈ ?rel ^^ Suc (Suc (Suc (Suc (Suc (Suc 0)))))"
    using chain5 step6 by (rule relpow_Suc_I)
  have chain7:
      "(c', c7) ∈ ?rel ^^ Suc (Suc (Suc (Suc (Suc (Suc (Suc 0))))))"
    using chain6 step7 by (rule relpow_Suc_I)
  have chain8_suc:
      "(c', c8) ∈ ?rel ^^ Suc (Suc (Suc (Suc (Suc (Suc (Suc (Suc 0)))))))"
    using chain7 step8 by (rule relpow_Suc_I)
  have chain8: "(c', c8) ∈ ?rel ^^ 8"
    using chain8_suc by (simp add: numeral_eq_Suc)

  let ?stage8 = "if q6 ∈ {t_tm M, r_tm M}
                 then init_stage (le_tm M)
                 else (ofs6, buf6, init_dest, SS1)"
  have c8_state: "mt_state c8 = (q6, ?stage8)"
    using step8_sub c7_state
    by (auto simp: ae_delta_ss8_ss1_def elim: mttm_step.cases)

  ― ‹‹sim_i›: state-tuple disjunction at ‹c8›.  The SS8‹→›SS1
      rule's ‹?stage'› case-splits on ‹q ∈ {t_tm M, r_tm M}›:
      halt routes to ‹init_stage le›, non-halt to ‹(ofs, buf, init_dest, SS1)›.
      The disjunction is XOR-style, with each branch matching one of the
      ‹ae_simulates›-defining disjuncts directly.›
  have sim_i_c8:
      "case mt_state c8 of (qq8, ofs8, buf8, dest8, idx8) ⇒
           (idx8 = SS1 ∧ qq8 ∉ {t_tm M, r_tm M})
         ∨ (qq8 ∈ {t_tm M, r_tm M}
              ∧ (ofs8, buf8, dest8, idx8) = init_stage (le_tm M))"
  proof (cases "q6 ∈ {t_tm M, r_tm M}")
    case True
    have shape: "?stage8 = init_stage (le_tm M)" using True by simp
    have "mt_state c8 = (q6, init_stage (le_tm M))"
      using c8_state shape by simp
    thus ?thesis using True by (simp add: init_stage_def)
  next
    case False
    have shape: "?stage8 = (ofs6, buf6, init_dest, SS1)" using False by simp
    have "mt_state c8 = (q6, ofs6, buf6, init_dest, SS1)"
      using c8_state shape by simp
    thus ?thesis using False by simp
  qed

  ― ‹‹sim_ii›: ‹mt_state cM_k = q6›.  q5 = q6 (no q changes through
      SS5/SS6/SS7); q5 = c4's M-state projection = ‹mt_state cM_k›
      (via ‹c4_q_out› from the trace lemma).›
  have q5_eq_q6: "q5 = q6" using q6_eq_q5 by simp
  have q5_eq_cM_k: "q5 = mt_state cM_k"
    using c4_q_out c4_state by simp
  have q6_eq_cM_k: "q6 = mt_state cM_k"
    using q5_eq_q6 q5_eq_cM_k by simp
  have sim_ii_c8:
      "case mt_state c8 of (qq8, _, _, _, _) ⇒ mt_state cM_k = qq8"
    using c8_state q6_eq_cM_k by simp

  ― ‹gamma + buf-gamma at ‹c8›: chained preservation.›
  have gamma_c8: "ae_tape_in_gamma_block M c8"
    using ae_step_alphabet_enlarge_gamma_preserve[OF gamma_c7 step8] .
  have buf_gamma_c8: "ae_buffer_in_gamma_block M c8"
    using ae_step_alphabet_enlarge_buffer_gamma_preserve[OF vM buf_gamma_c7
                                                            gamma_c7 step8] .

  ― ‹Sub-step 6b1: per-tape regime-aware ‹cM_k›-side window
      invariant.  Projection of ‹c4_window_general› through
      ‹c4_state› = ‹(q5, ofs5, buf5, dest5, SS5)›: each tape
      ‹kk› has the hybrid ‹ae_window_invariant_general›
      indexed by its regime selector ‹mt_pos c' kk›.  This
      single fact unpacks into le0/le1/steady sub-invariants
      per tape via the definition's case-split on ‹pos = 0›,
      ‹pos = 1›, ‹pos ≥ 2›.›
  have cM_k_window_general:
      "∀kk<k_tm M. ae_window_invariant_general
              (mt_tape cM_k kk) (mt_pos cM_k kk)
              (dest5 kk, ofs5 kk) (buf5 kk)
              (mt_pos c' kk) (le_tm M)"
    using c4_window_general c4_state by simp

  ― ‹Sub-step 6b1: ‹cM_k›'s tape at position 0 is
      ‹LE_block (le_tm M)›, equivalently ‹le_tm M› as a
      bare tape value — the s=0 conjunct of ‹ae_tape_correspondence›.
      Per-tape regime case-split: pos=0 and pos=1 extract the
      ‹tM 0 = le› clause directly from the regime-specific
      window invariant (‹ae_window_invariant_le0_def› and
      ‹_le1_def›); pos‹≥›2 has no such clause in its
      window invariant (which only constrains
      ‹[p_start, p_start + 3c)›) so the M-side entry
      correspondence at s=0 (‹mt_tape cM kk 0 = le›) chains
      with ‹mttm_relpow_tape_off_window›'s zero preservation
      (‹mt_pos cM kk ≥ c + 1 > k› for pos‹≥›2 tapes).›
  let ?c = "card (UNIV :: 'c set)"
  have c_ge1: "(1 :: nat) ≤ ?c"
    using c_idx_lt_card[of "SOME x :: 'c. True"] by linarith
  have cM_k_zero: "⋀kk. kk < k_tm M ⟹ mt_tape cM_k kk 0 = le_tm M"
  proof -
    fix kk
    assume kklt: "kk < k_tm M"
    show "mt_tape cM_k kk 0 = le_tm M"
    proof (cases "mt_pos c' kk = 0")
      case True
      have win_kk:
          "ae_window_invariant_le0
                (mt_tape cM_k kk) (mt_pos cM_k kk)
                (dest5 kk, ofs5 kk) (buf5 kk) (le_tm M)"
        using cM_k_window_general[rule_format, OF kklt] True
        unfolding ae_window_invariant_general_def by blast
      thus ?thesis unfolding ae_window_invariant_le0_def by simp
    next
      case ne0: False
      show ?thesis
      proof (cases "mt_pos c' kk = 1")
        case True
        have win_kk:
            "ae_window_invariant_le1
                  (mt_tape cM_k kk) (mt_pos cM_k kk)
                  (dest5 kk, ofs5 kk) (buf5 kk) (le_tm M)"
          using cM_k_window_general[rule_format, OF kklt] True
          unfolding ae_window_invariant_general_def by blast
        thus ?thesis unfolding ae_window_invariant_le1_def by simp
      next
        case ne1: False
        have hge2: "mt_pos c' kk ≥ 2" using ne0 ne1 by linarith
        have decode:
            "mt_pos cM kk = (mt_pos c' kk - 1) * ?c + c_idx (ofs kk) + 1"
          using pos_corr kklt hge2 by (simp add: ae_decode_pos_def)
        have step_mult: "(mt_pos c' kk - 1) * ?c ≥ ?c"
        proof -
          have "(mt_pos c' kk - 1) ≥ 1" using hge2 by linarith
          hence "(mt_pos c' kk - 1) * ?c ≥ 1 * ?c"
            by (rule mult_le_mono1)
          thus ?thesis by simp
        qed
        have pos_ge_c1: "mt_pos cM kk ≥ ?c + 1"
          using decode step_mult by linarith
        have k_lt: "k < mt_pos cM kk" using k_le pos_ge_c1 by linarith
        have far_disj:
            "(0 :: nat) > mt_pos cM kk + k ∨ (0 :: nat) + k < mt_pos cM kk"
          using k_lt by simp
        have entry_zero: "mt_tape cM kk 0 = le_tm M"
          using tape_corr[rule_format, OF kklt] unfolding ae_tape_correspondence_def by simp
        have "mt_tape cM_k kk 0 = mt_tape cM kk 0"
          using mttm_relpow_tape_off_window[OF trace far_disj] .
        thus ?thesis using entry_zero by simp
      qed
    qed
  qed

  ― ‹Sub-step 6b2: M-side off-window preservation per tape regime.
      Each regime gives a different M-side window characterisation;
      ‹mttm_relpow_tape_off_window› applied with the entry
      M-head position (‹pos_corr› + ‹ae_decode_pos›) and
      displacement bound ‹≤ k ≤ c› closes each branch.›
  have m_tape_off_window_le0:
      "⋀kk p. kk < k_tm M ⟹ mt_pos c' kk = 0
              ⟹ p > ?c
              ⟹ mt_tape cM_k kk p = mt_tape cM kk p"
  proof -
    fix kk and p :: nat
    assume kklt: "kk < k_tm M"
    assume pos_eq: "mt_pos c' kk = 0"
    assume p_gt: "p > ?c"
    have m_pos_zero: "mt_pos cM kk = 0"
      using pos_corr kklt pos_eq by (simp add: ae_decode_pos_def)
    have far: "p > mt_pos cM kk + k" using p_gt m_pos_zero k_le by linarith
    have far_disj: "p > mt_pos cM kk + k ∨ p + k < mt_pos cM kk"
      using far by simp
    show "mt_tape cM_k kk p = mt_tape cM kk p"
      using mttm_relpow_tape_off_window[OF trace far_disj] .
  qed
  have m_tape_off_window_le1:
      "⋀kk p. kk < k_tm M ⟹ mt_pos c' kk = 1
              ⟹ p > 2 * ?c
              ⟹ mt_tape cM_k kk p = mt_tape cM kk p"
  proof -
    fix kk and p :: nat
    assume kklt: "kk < k_tm M"
    assume pos_eq: "mt_pos c' kk = 1"
    assume p_gt: "p > 2 * ?c"
    have m_pos_le_c: "mt_pos cM kk ≤ ?c"
    proof -
      have decode: "mt_pos cM kk = Suc (c_idx (ofs kk))"
        using pos_corr kklt pos_eq by (simp add: ae_decode_pos_def)
      have idx_lt: "c_idx (ofs kk) < ?c" by (rule c_idx_lt_card)
      show ?thesis using decode idx_lt by linarith
    qed
    have far: "p > mt_pos cM kk + k"
      using p_gt m_pos_le_c k_le by linarith
    have far_disj: "p > mt_pos cM kk + k ∨ p + k < mt_pos cM kk"
      using far by simp
    show "mt_tape cM_k kk p = mt_tape cM kk p"
      using mttm_relpow_tape_off_window[OF trace far_disj] .
  qed
  have m_tape_off_window_steady:
      "⋀kk p. kk < k_tm M ⟹ mt_pos c' kk ≥ 2
              ⟹ p < (mt_pos c' kk - 2) * ?c + 1
                  ∨ p ≥ (mt_pos c' kk - 2) * ?c + 1 + 3 * ?c
              ⟹ mt_tape cM_k kk p = mt_tape cM kk p"
  proof -
    fix kk and p :: nat
    assume kklt: "kk < k_tm M"
    assume hge2: "mt_pos c' kk ≥ 2"
    assume p_off: "p < (mt_pos c' kk - 2) * ?c + 1
                    ∨ p ≥ (mt_pos c' kk - 2) * ?c + 1 + 3 * ?c"
    have decode:
        "mt_pos cM kk = (mt_pos c' kk - 1) * ?c + c_idx (ofs kk) + 1"
      using pos_corr kklt hge2 by (simp add: ae_decode_pos_def)
    have ws_alt:
        "(mt_pos c' kk - 1) * ?c = (mt_pos c' kk - 2) * ?c + ?c"
    proof -
      have suc_eq: "Suc (mt_pos c' kk - 2) = mt_pos c' kk - 1"
        using hge2 by simp
      have "Suc (mt_pos c' kk - 2) * ?c = (mt_pos c' kk - 2) * ?c + ?c"
        by simp
      with suc_eq show ?thesis by simp
    qed
    have m_pos_eq:
        "mt_pos cM kk = (mt_pos c' kk - 2) * ?c + 1 + ?c + c_idx (ofs kk)"
      using decode ws_alt by simp
    have idx_lt: "c_idx (ofs kk) < ?c" by (rule c_idx_lt_card)
    have far_disj: "p > mt_pos cM kk + k ∨ p + k < mt_pos cM kk"
      using p_off k_le m_pos_eq idx_lt by linarith
    show "mt_tape cM_k kk p = mt_tape cM kk p"
      using mttm_relpow_tape_off_window[OF trace far_disj] .
  qed

  ― ‹Sub-step 6b3: head trajectory ‹c5_pos› for pos=0 tapes.
      For pos=0, ‹c4_pos kk = 0› by ‹c4_pos›, so SS5 reads
      ‹mt_tape c4 kk 0 = mt_tape c' kk 0 = LE_block› by
      ‹le_anchor›.  ‹ae_ss5_action›'s first branch
      (‹a = LE_block›) fires: write ‹a› (no-op), direction N.
      Head stays at 0.›
  have c5_pos_for_pos0:
      "⋀kk. kk < k_tm M ⟹ mt_pos c' kk = 0 ⟹ mt_pos c5 kk = 0"
  proof -
    fix kk
    assume kklt: "kk < k_tm M"
    assume pos_kk: "mt_pos c' kk = 0"
    obtain qq tts nn qq' aa5 dr5 where
        c4_eq5: "c4 = ConfigM qq tts nn"
      and c5_eq: "c5 = ConfigM qq'
                          (λk. (tts k)(nn k := aa5 k))
                          (λk. go_dir (dr5 k) (nn k))"
      and tr_in: "(qq, λk. tts k (nn k), qq', aa5, dr5)
                    ∈ ae_delta_ss5_ss6 M"
      using step5_sub by (auto elim: mttm_step.cases)
    obtain q ofs buf dest where
        qq_eq: "qq = (q, ofs, buf, dest, SS5)"
      and dr5_eq:
          "dr5 = (λk. if k < k_tm M
                       then snd (ae_ss5_action (le_tm M)
                                  (tts k (nn k)) (buf k) (dest k))
                       else dir.N)"
      using tr_in by (auto simp: ae_delta_ss5_ss6_def)
    have qq_state: "qq = (q5, ofs5, buf5, dest5, SS5)"
      using c4_state c4_eq5 by simp
    have buf_eq: "buf = buf5" using qq_eq qq_state by simp
    have nn_kk: "nn kk = mt_pos c4 kk" using c4_eq5 by simp
    have c4_kk: "mt_pos c4 kk = 0" using c4_pos kklt pos_kk by simp
    have nn_kk_0: "nn kk = 0" using nn_kk c4_kk by simp
    have read_LE: "tts kk (nn kk) = LE_block (le_tm M)"
    proof -
      have "tts kk (nn kk) = mt_tape c4 kk (mt_pos c4 kk)"
        using c4_eq5 nn_kk by simp
      also have "… = mt_tape c' kk 0"
        using c4_kk tape_c4_eq_c' by simp
      also have "… = LE_block (le_tm M)" using le_anchor[rule_format, OF kklt] by simp
      finally show ?thesis .
    qed
    obtain ll hh rr where buf5_kk: "buf5 kk = (ll, hh, rr)"
      using prod.exhaust by metis
    have dr5_kk: "dr5 kk = dir.N"
      using dr5_eq buf_eq buf5_kk read_LE kklt by simp
    have "mt_pos c5 kk = go_dir (dr5 kk) (nn kk)"
      using c5_eq by simp
    also have "… = nn kk" using dr5_kk by simp
    also have "… = 0" using nn_kk_0 .
    finally show "mt_pos c5 kk = 0" .
  qed

  ― ‹Sub-step 6b3: head trajectory ‹c5_pos› for pos‹≥›2 tapes.
      Two sub-cases on ‹dest5 kk›.  For ‹dest ≠ AE_Left›:
      SS5's else branch fires with direction L, head lands at
      ‹c4_pos - 1 = mt_pos c' kk - 1›.  For ‹dest = AE_Left›:
      SS5's else branch fires with direction R, head lands at
      ‹c4_pos + 1 = mt_pos c' kk + 1›.  Mirrors the pos=1
      derivations ‹c5_pos_for_pos1› and ‹_dest_left›, but
      with ‹mt_pos c' kk ≥ 2› so the result is
      ‹mt_pos c' kk \<mp> 1› rather than landing at the
      ‹LE_block› sentinel.›
  have c5_pos_for_pos_ge2:
      "⋀kk. kk < k_tm M ⟹ mt_pos c' kk ≥ 2 ⟹ dest5 kk ≠ AE_Left
            ⟹ mt_pos c5 kk = mt_pos c' kk - 1"
  proof -
    fix kk
    assume kklt: "kk < k_tm M"
    assume hge2: "mt_pos c' kk ≥ 2"
    assume dest_ne: "dest5 kk ≠ AE_Left"
    obtain qq tts nn qq' aa5 dr5 where
        c4_eq5: "c4 = ConfigM qq tts nn"
      and c5_eq: "c5 = ConfigM qq'
                          (λk. (tts k)(nn k := aa5 k))
                          (λk. go_dir (dr5 k) (nn k))"
      and tr_in: "(qq, λk. tts k (nn k), qq', aa5, dr5)
                    ∈ ae_delta_ss5_ss6 M"
      using step5_sub by (auto elim: mttm_step.cases)
    obtain q ofs buf dest where
        qq_eq: "qq = (q, ofs, buf, dest, SS5)"
      and dr5_eq:
          "dr5 = (λk. if k < k_tm M
                       then snd (ae_ss5_action (le_tm M)
                                  (tts k (nn k)) (buf k) (dest k))
                       else dir.N)"
      using tr_in by (auto simp: ae_delta_ss5_ss6_def)
    have qq_state: "qq = (q5, ofs5, buf5, dest5, SS5)"
      using c4_state c4_eq5 by simp
    have buf_eq: "buf = buf5" using qq_eq qq_state by simp
    have dest_eq: "dest = dest5" using qq_eq qq_state by simp
    have nn_kk: "nn kk = mt_pos c4 kk" using c4_eq5 by simp
    have c4_kk: "mt_pos c4 kk = mt_pos c' kk"
      using c4_pos kklt by simp
    have pos_ge1: "(1 :: nat) ≤ mt_pos c' kk" using hge2 by linarith
    have read_ne_LE: "tts kk (nn kk) ≠ LE_block (le_tm M)"
    proof -
      have "tts kk (nn kk) = mt_tape c4 kk (mt_pos c4 kk)"
        using c4_eq5 nn_kk by simp
      also have "… = mt_tape c' kk (mt_pos c' kk)"
        using c4_kk tape_c4_eq_c' by simp
      finally have read_eq: "tts kk (nn kk) = mt_tape c' kk (mt_pos c' kk)" .
      have "mt_tape c' kk (mt_pos c' kk) ≠ LE_block (le_tm M)"
        using home_classification[rule_format, OF kklt] pos_ge1 by blast
      thus ?thesis using read_eq by simp
    qed
    obtain ll hh rr where buf5_kk: "buf5 kk = (ll, hh, rr)"
      using prod.exhaust by metis
    have h_ne_LE: "hh ≠ LE_block (le_tm M)"
    proof -
      have "fst (snd (buf5 kk)) ≠ LE_block (le_tm M)"
        using buf5_not_le_per_tape[rule_format, OF kklt] hge2 by blast
      thus ?thesis using buf5_kk by simp
    qed
    have dr5_kk:
        "dr5 kk = (if dest5 kk = AE_Left then dir.R else dir.L)"
      using dr5_eq buf_eq dest_eq buf5_kk read_ne_LE h_ne_LE kklt by simp
    have dr5_kk_L: "dr5 kk = dir.L" using dr5_kk dest_ne by simp
    have "mt_pos c5 kk = go_dir (dr5 kk) (nn kk)"
      using c5_eq by simp
    also have "… = (nn kk) - 1" using dr5_kk_L by simp
    also have "… = mt_pos c' kk - 1" using nn_kk c4_kk by simp
    finally show "mt_pos c5 kk = mt_pos c' kk - 1" .
  qed

  have c5_pos_for_pos_ge2_dest_left:
      "⋀kk. kk < k_tm M ⟹ mt_pos c' kk ≥ 2 ⟹ dest5 kk = AE_Left
            ⟹ mt_pos c5 kk = mt_pos c' kk + 1"
  proof -
    fix kk
    assume kklt: "kk < k_tm M"
    assume hge2: "mt_pos c' kk ≥ 2"
    assume dest_eq: "dest5 kk = AE_Left"
    obtain qq tts nn qq' aa5 dr5 where
        c4_eq5: "c4 = ConfigM qq tts nn"
      and c5_eq: "c5 = ConfigM qq'
                          (λk. (tts k)(nn k := aa5 k))
                          (λk. go_dir (dr5 k) (nn k))"
      and tr_in: "(qq, λk. tts k (nn k), qq', aa5, dr5)
                    ∈ ae_delta_ss5_ss6 M"
      using step5_sub by (auto elim: mttm_step.cases)
    obtain q ofs buf dest where
        qq_eq: "qq = (q, ofs, buf, dest, SS5)"
      and dr5_eq:
          "dr5 = (λk. if k < k_tm M
                       then snd (ae_ss5_action (le_tm M)
                                  (tts k (nn k)) (buf k) (dest k))
                       else dir.N)"
      using tr_in by (auto simp: ae_delta_ss5_ss6_def)
    have qq_state: "qq = (q5, ofs5, buf5, dest5, SS5)"
      using c4_state c4_eq5 by simp
    have buf_eq: "buf = buf5" using qq_eq qq_state by simp
    have dest_eq': "dest = dest5" using qq_eq qq_state by simp
    have nn_kk: "nn kk = mt_pos c4 kk" using c4_eq5 by simp
    have c4_kk: "mt_pos c4 kk = mt_pos c' kk" using c4_pos kklt by simp
    have pos_ge1: "(1 :: nat) ≤ mt_pos c' kk" using hge2 by linarith
    have read_ne_LE: "tts kk (nn kk) ≠ LE_block (le_tm M)"
    proof -
      have "tts kk (nn kk) = mt_tape c4 kk (mt_pos c4 kk)"
        using c4_eq5 nn_kk by simp
      also have "… = mt_tape c' kk (mt_pos c' kk)"
        using c4_kk tape_c4_eq_c' by simp
      finally have read_eq: "tts kk (nn kk) = mt_tape c' kk (mt_pos c' kk)" .
      have "mt_tape c' kk (mt_pos c' kk) ≠ LE_block (le_tm M)"
        using home_classification[rule_format, OF kklt] pos_ge1 by blast
      thus ?thesis using read_eq by simp
    qed
    obtain ll hh rr where buf5_kk: "buf5 kk = (ll, hh, rr)"
      using prod.exhaust by metis
    have h_ne_LE: "hh ≠ LE_block (le_tm M)"
    proof -
      have "fst (snd (buf5 kk)) ≠ LE_block (le_tm M)"
        using buf5_not_le_per_tape[rule_format, OF kklt] hge2 by blast
      thus ?thesis using buf5_kk by simp
    qed
    have dr5_kk:
        "dr5 kk = (if dest5 kk = AE_Left then dir.R else dir.L)"
      using dr5_eq buf_eq dest_eq' buf5_kk read_ne_LE h_ne_LE kklt by simp
    have dr5_kk_R: "dr5 kk = dir.R" using dr5_kk dest_eq by simp
    have "mt_pos c5 kk = go_dir (dr5 kk) (nn kk)"
      using c5_eq by simp
    also have "… = Suc (nn kk)" using dr5_kk_R by simp
    also have "… = mt_pos c' kk + 1" using nn_kk c4_kk by simp
    finally show "mt_pos c5 kk = mt_pos c' kk + 1" .
  qed

  ― ‹Sub-step 6b3 helper: ‹left_not_le_c'_steady›.  Mirror of
      ‹right_not_le_c'› for the left side at pos‹≥›2: block
      ‹mt_pos c' k - 1› mapped via the tape correspondence at
      sub-index 0 (which gives cell address ‹(mt_pos c' k - 2) ⋅ c + 1›),
      then no-LE via ‹no_le_per_tape›'s steady branch at ‹i = 0›.
      Powers the SS5‹→›SS6 head-trajectory for pos‹≥›2
      tapes with ‹dest ≠ AE_Left›: c5 reads the cell at
      ‹c5_pos = pos - 1›, which is c'-side block pos-1.›
  have left_not_le_c'_steady:
      "∀k. mt_pos c' k ≥ 2
            ⟶ mt_tape c' k (mt_pos c' k - 1) ≠ LE_block (le_tm M)"
  proof (intro allI impI)
    fix k :: nat
    assume hge2: "mt_pos c' k ≥ 2"
    show "mt_tape c' k (mt_pos c' k - 1) ≠ LE_block (le_tm M)"
    proof (cases "k < k_tm M")
      case True
    let ?x = "(enum_class.enum :: 'c list) ! 0"
    let ?c = "card (UNIV :: 'c set)"
    have zero_lt_len: "0 < length (enum_class.enum :: 'c list)"
      using c_ge_1 c_eq_len by linarith
    have x_idx0: "c_idx ?x = 0"
      using c_idx_enum_nth[OF zero_lt_len] .
    have tc_k: "ae_tape_correspondence (le_tm M) (mt_tape cM k) (mt_tape c' k)"
      using tape_corr[rule_format, OF True] by simp
    have s_ge1: "mt_pos c' k - 1 ≥ 1" using hge2 by linarith
    have addr_via_tc:
        "mt_tape cM k ((mt_pos c' k - 2) * ?c + 1)
          = mt_tape c' k (mt_pos c' k - 1) ?x"
    proof -
      from tc_k have unf:
          "∀s≥1. ∀i. mt_tape cM k ((s - 1) * ?c + c_idx i + 1)
                      = mt_tape c' k s i"
        unfolding ae_tape_correspondence_def by simp
      from unf s_ge1 have eq:
          "mt_tape cM k ((mt_pos c' k - 1 - 1) * ?c + c_idx ?x + 1)
            = mt_tape c' k (mt_pos c' k - 1) ?x"
        by blast
      have idx_arith:
          "mt_pos c' k - 1 - 1 = mt_pos c' k - 2"
        using hge2 by simp
      thus ?thesis using eq x_idx0 idx_arith by simp
    qed
    have idx_lt: "(0 :: nat) < 3 * ?c" using c_ge_1 by simp
    have nle: "mt_tape cM k ((mt_pos c' k - 2) * ?c + 1 + 0) ≠ le_tm M"
      using no_le_per_tape hge2 idx_lt by blast
    hence nle': "mt_tape cM k ((mt_pos c' k - 2) * ?c + 1) ≠ le_tm M"
      by simp
    have "mt_tape c' k (mt_pos c' k - 1) ?x ≠ le_tm M"
      using nle' addr_via_tc by simp
    thus "mt_tape c' k (mt_pos c' k - 1) ≠ LE_block (le_tm M)"
      unfolding LE_block_def by auto
    next
      case False
      hence kge: "k_tm M ≤ k" by simp
      have "mt_tape c' k (mt_pos c' k - 1) = bl_block (bl_tm M)"
        using gamma_c4 kge
        unfolding ae_tape_in_gamma_block_def tape_c4_eq_c'[symmetric]
        by simp
      thus ?thesis using bl_neq_le by simp
    qed
  qed

  ― ‹Sub-step 6b3 helpers: positive buffer-slot characterisations
      projected from ‹c4_window_general›'s regime-specific clauses.
      For pos=0 tapes, ‹ae_window_invariant_le0› contributes
      ‹fst (snd blocks) = LE_block› (the head buffer slot is LE).
      For pos=1 tapes, ‹ae_window_invariant_le1› contributes
      ‹fst blocks = LE_block› (the left buffer slot is LE).
      These complement ‹buf5_not_le_per_tape› (negative facts)
      with positive identifications, powering the SS7 LE-guard
      branches that fire for pos=0 (‹h = LE›) and the SS8
      ‹AE_Left› dispatch for pos=1 (‹l = LE›).›
  have buf5_h_le_for_pos0:
      "∀k<k_tm M. mt_pos c' k = 0 ⟶ fst (snd (buf5 k)) = LE_block (le_tm M)"
  proof (intro allI impI)
    fix k :: nat
    assume klt: "k < k_tm M"
    assume pos_k: "mt_pos c' k = 0"
    have wi: "ae_window_invariant_general
                (mt_tape cM_k k) (mt_pos cM_k k)
                (dest5 k, ofs5 k) (buf5 k)
                (mt_pos c' k) (le_tm M)"
      using cM_k_window_general[rule_format, OF klt] by simp
    hence "ae_window_invariant_le0
              (mt_tape cM_k k) (mt_pos cM_k k)
              (dest5 k, ofs5 k) (buf5 k) (le_tm M)"
      using pos_k unfolding ae_window_invariant_general_def by simp
    thus "fst (snd (buf5 k)) = LE_block (le_tm M)"
      unfolding ae_window_invariant_le0_def by simp
  qed

  have buf5_l_le_for_pos1:
      "∀k<k_tm M. mt_pos c' k = 1 ⟶ fst (buf5 k) = LE_block (le_tm M)"
  proof (intro allI impI)
    fix k :: nat
    assume klt: "k < k_tm M"
    assume pos_k: "mt_pos c' k = 1"
    have wi: "ae_window_invariant_general
                (mt_tape cM_k k) (mt_pos cM_k k)
                (dest5 k, ofs5 k) (buf5 k)
                (mt_pos c' k) (le_tm M)"
      using cM_k_window_general[rule_format, OF klt] by simp
    hence "ae_window_invariant_le1
              (mt_tape cM_k k) (mt_pos cM_k k)
              (dest5 k, ofs5 k) (buf5 k) (le_tm M)"
      using pos_k unfolding ae_window_invariant_general_def by simp
    thus "fst (buf5 k) = LE_block (le_tm M)"
      unfolding ae_window_invariant_le1_def by simp
  qed

  ― ‹Sub-step 6b3: head trajectory ‹c6_pos› for pos=0 tapes.
      ‹c5_pos = 0› (‹c5_pos_for_pos0›); SS6 reads
      ‹mt_tape c5 kk 0 = LE_block› via ‹tape_c5_zero_le›.
      ‹ae_ss6_action›'s first branch fires (‹a = LE_block›),
      writing a (no-op), direction R.  Head lands at
      ‹c5_pos + 1 = 1›.›
  have c6_pos_for_pos0:
      "⋀kk. kk < k_tm M ⟹ mt_pos c' kk = 0 ⟹ mt_pos c6 kk = 1"
  proof -
    fix kk
    assume kklt: "kk < k_tm M"
    assume pos_kk: "mt_pos c' kk = 0"
    obtain qq tts nn qq' aa6 dr6 where
        c5_eq6: "c5 = ConfigM qq tts nn"
      and c6_eq: "c6 = ConfigM qq'
                          (λk. (tts k)(nn k := aa6 k))
                          (λk. go_dir (dr6 k) (nn k))"
      and tr_in: "(qq, λk. tts k (nn k), qq', aa6, dr6)
                    ∈ ae_delta_ss6_ss7 M"
      using step6_sub by (auto elim: mttm_step.cases)
    obtain q ofs buf dest where
        qq_eq: "qq = (q, ofs, buf, dest, SS6)"
      and dr6_eq:
          "dr6 = (λk. if k < k_tm M then snd (ae_ss6_action (le_tm M)
                              (tts k (nn k)) (buf k) (dest k)) else dir.N)"
      using tr_in by (auto simp: ae_delta_ss6_ss7_def)
    have qq_state: "qq = (q5, ofs5, buf5, dest5, SS6)"
      using c5_state c5_eq6 by simp
    have buf_eq: "buf = buf5" using qq_eq qq_state by simp
    have nn_kk: "nn kk = mt_pos c5 kk" using c5_eq6 by simp
    have c5_kk: "mt_pos c5 kk = 0" using c5_pos_for_pos0[OF kklt pos_kk] .
    have nn_kk_0: "nn kk = 0" using nn_kk c5_kk by simp
    have read_LE: "tts kk (nn kk) = LE_block (le_tm M)"
    proof -
      have "tts kk (nn kk) = mt_tape c5 kk (mt_pos c5 kk)"
        using c5_eq6 nn_kk by simp
      also have "… = mt_tape c5 kk 0" using c5_kk by simp
      also have "… = LE_block (le_tm M)" using tape_c5_zero_le[rule_format, OF kklt] by simp
      finally show ?thesis .
    qed
    obtain ll hh rr where buf5_kk: "buf5 kk = (ll, hh, rr)"
      using prod.exhaust by metis
    have dr6_kk: "dr6 kk = dir.R"
      using dr6_eq buf_eq buf5_kk read_LE kklt by simp
    have "mt_pos c6 kk = go_dir (dr6 kk) (nn kk)"
      using c6_eq by simp
    also have "… = Suc (nn kk)" using dr6_kk by simp
    also have "… = 1" using nn_kk_0 by simp
    finally show "mt_pos c6 kk = 1" .
  qed

  ― ‹Sub-step 6b3: head trajectory ‹c6_pos› for pos‹≥›2 tapes.
      Both dest branches converge to ‹c6_pos = pos› (SS6 writes the
      home block and returns the head to home).  Case-split on
      ‹dest5 kk = AE_Left›.  For ‹dest = AE_Left›: ‹c5_pos = pos + 1›,
      SS6 reads at ‹pos + 1› non-LE (‹right_not_le_c'›), ‹h› non-LE
      (‹buf5_not_le_per_tape› pos‹≥›2), action's else branch
      direction L, head lands at ‹c5_pos - 1 = pos›.  For
      ‹dest ≠ AE_Left›: ‹c5_pos = pos - 1›, SS6 reads at ‹pos - 1›
      non-LE (‹left_not_le_c'_steady›), ‹h› non-LE, action's else
      branch direction R, head lands at ‹c5_pos + 1 = pos›.
      Extracted to ‹ae_fwd_c6_pos_for_pos_ge2›.›
  have c6_pos_for_pos_ge2:
      "⋀kk. kk < k_tm M ⟹ mt_pos c' kk ≥ 2 ⟹ mt_pos c6 kk = mt_pos c' kk"
    by (rule ae_fwd_c6_pos_for_pos_ge2[OF step5 c5_state tape_c4_eq_c'
          buf5_not_le_per_tape right_not_le_c' c4_pos step6_sub
          c5_pos_for_pos_ge2 c5_pos_for_pos_ge2_dest_left left_not_le_c'_steady])
  ― ‹Sub-step 6b4: head trajectory ‹c7_pos› for pos=0 tapes.
      ‹c6_pos = 1› (‹c6_pos_for_pos0›); SS7 reads
      ‹mt_tape c6 kk 1› which off-traces through SS6 (‹c5_pos = 0›),
      SS5 (‹c4_pos = 0›) to ‹mt_tape c' kk 1›, non-LE via
      ‹right_not_le_c'›.  Buffer's head slot ‹h = LE_block›
      (‹buf5_h_le_for_pos0›), so ‹ae_ss7_action›'s second branch
      fires: writes ‹r›, direction ‹N› if ‹dest = AE_Right›
      else ‹L›.  Head lands at ‹1› (‹dest = AE_Right›) or ‹0›
      (otherwise).›
  have c7_pos_for_pos0:
      "⋀kk. kk < k_tm M ⟹ mt_pos c' kk = 0
            ⟹ mt_pos c7 kk = (if dest5 kk = AE_Right then 1 else 0)"
  proof -
    fix kk
    assume kklt: "kk < k_tm M"
    assume pos_kk: "mt_pos c' kk = 0"
    obtain qq tts nn qq' aa7 dr7 where
        c6_eq7: "c6 = ConfigM qq tts nn"
      and c7_eq: "c7 = ConfigM qq'
                          (λk. (tts k)(nn k := aa7 k))
                          (λk. go_dir (dr7 k) (nn k))"
      and tr_in: "(qq, λk. tts k (nn k), qq', aa7, dr7)
                    ∈ ae_delta_ss7_ss8 M"
      using step7_sub by (auto elim: mttm_step.cases)
    obtain q ofs buf dest where
        qq_eq: "qq = (q, ofs, buf, dest, SS7)"
      and dr7_eq:
          "dr7 = (λk. if k < k_tm M then snd (ae_ss7_action (le_tm M)
                              (tts k (nn k)) (buf k) (dest k)) else dir.N)"
      using tr_in by (auto simp: ae_delta_ss7_ss8_def)
    have qq_state: "qq = (q6, ofs6, buf6, dest6, SS7)"
      using c6_state c6_eq7 by simp
    have buf_eq: "buf = buf6" using qq_eq qq_state by simp
    have dest_eq: "dest = dest6" using qq_eq qq_state by simp
    have nn_kk: "nn kk = mt_pos c6 kk" using c6_eq7 by simp
    have c6_kk: "mt_pos c6 kk = 1" using c6_pos_for_pos0[OF kklt pos_kk] .
    have nn_kk_1: "nn kk = 1" using nn_kk c6_kk by simp
    have one_ne_c5_pos: "(1 :: nat) ≠ mt_pos c5 kk"
      using c5_pos_for_pos0[OF kklt pos_kk] by simp
    have one_ne_c4_pos: "(1 :: nat) ≠ mt_pos c4 kk"
      using c4_pos kklt pos_kk by simp
    have c6_at_1: "mt_tape c6 kk 1 = mt_tape c' kk 1"
    proof -
      have "mt_tape c6 kk 1 = mt_tape c5 kk 1"
        using mttm_step_tape_off_head[OF step6 one_ne_c5_pos] .
      also have "… = mt_tape c4 kk 1"
        using mttm_step_tape_off_head[OF step5 one_ne_c4_pos] .
      also have "… = mt_tape c' kk 1"
        using tape_c4_eq_c' by simp
      finally show ?thesis .
    qed
    have read_ne_LE: "tts kk (nn kk) ≠ LE_block (le_tm M)"
    proof -
      have "tts kk (nn kk) = mt_tape c6 kk (mt_pos c6 kk)"
        using c6_eq7 nn_kk by simp
      also have "… = mt_tape c6 kk 1" using c6_kk by simp
      also have "… = mt_tape c' kk 1" using c6_at_1 .
      finally have read_eq: "tts kk (nn kk) = mt_tape c' kk 1" .
      have "mt_tape c' kk (mt_pos c' kk + 1) ≠ LE_block (le_tm M)"
        using right_not_le_c' by blast
      hence "mt_tape c' kk 1 ≠ LE_block (le_tm M)" using pos_kk by simp
      thus ?thesis using read_eq by simp
    qed
    obtain ll hh rr where buf5_kk: "buf5 kk = (ll, hh, rr)"
      using prod.exhaust by metis
    have hh_le: "hh = LE_block (le_tm M)"
    proof -
      have "fst (snd (buf5 kk)) = LE_block (le_tm M)"
        using buf5_h_le_for_pos0[rule_format, OF kklt] pos_kk by blast
      thus ?thesis using buf5_kk by simp
    qed
    have buf6_kk: "buf6 kk = (ll, hh, rr)"
      using buf5_kk buf6_eq_buf5 by simp
    have dr7_kk:
        "dr7 kk = (if dest6 kk = AE_Right then dir.N else dir.L)"
      using dr7_eq buf_eq dest_eq buf6_kk hh_le read_ne_LE kklt by simp
    show "mt_pos c7 kk = (if dest5 kk = AE_Right then 1 else 0)"
    proof (cases "dest5 kk = AE_Right")
      case True
      have dest6_eq: "dest6 kk = AE_Right"
        using True dest6_eq_dest5 by simp
      have dr7_kk_N: "dr7 kk = dir.N" using dr7_kk dest6_eq by simp
      have "mt_pos c7 kk = go_dir (dr7 kk) (nn kk)"
        using c7_eq by simp
      also have "… = nn kk" using dr7_kk_N by simp
      also have "… = 1" using nn_kk_1 .
      finally show ?thesis using True by simp
    next
      case False
      have dest6_ne: "dest6 kk ≠ AE_Right"
        using False dest6_eq_dest5 by simp
      have dr7_kk_L: "dr7 kk = dir.L" using dr7_kk dest6_ne by simp
      have "mt_pos c7 kk = go_dir (dr7 kk) (nn kk)"
        using c7_eq by simp
      also have "… = (nn kk) - 1" using dr7_kk_L by simp
      also have "… = 0" using nn_kk_1 by simp
      finally show ?thesis using False by simp
    qed
  qed

  ― ‹Sub-step 6b4 helper: SS5's write at ‹c4_pos = pos› for
      pos‹≥›2 tapes records the home buffer slot ‹fst (snd
      (buf5 k))›.  Action ‹ae_ss5_action›'s else branch fires
      (read non-LE via ‹home_classification›, head buf slot non-LE
      via ‹buf5_not_le_per_tape› pos‹≥›2), writing ‹h›.
      Powers the SS7 read characterisation at ‹c6_pos = pos›
      (off-write from SS6 which writes at ‹c5_pos = pos \<mp> 1›).›
  have tape_c5_at_pos_for_pos_ge2:
      "⋀kk. kk < k_tm M ⟹ mt_pos c' kk ≥ 2
            ⟹ mt_tape c5 kk (mt_pos c' kk) = fst (snd (buf5 kk))"
  proof -
    fix kk
    assume kklt: "kk < k_tm M"
    assume hge2: "mt_pos c' kk ≥ 2"
    obtain qq tts nn qq' aa5 dr5 where
        c4_eq5: "c4 = ConfigM qq tts nn"
      and c5_eq: "c5 = ConfigM qq'
                          (λk. (tts k)(nn k := aa5 k))
                          (λk. go_dir (dr5 k) (nn k))"
      and tr_in: "(qq, λk. tts k (nn k), qq', aa5, dr5)
                    ∈ ae_delta_ss5_ss6 M"
      using step5_sub by (auto elim: mttm_step.cases)
    obtain q ofs buf dest where
        qq_eq: "qq = (q, ofs, buf, dest, SS5)"
      and aa5_eq:
          "aa5 = (λk. if k < k_tm M then fst (ae_ss5_action (le_tm M)
                              (tts k (nn k)) (buf k) (dest k)) else bl_block (bl_tm M))"
      using tr_in by (auto simp: ae_delta_ss5_ss6_def)
    have qq_state: "qq = (q5, ofs5, buf5, dest5, SS5)"
      using c4_state c4_eq5 by simp
    have buf_eq: "buf = buf5" using qq_eq qq_state by simp
    have nn_kk: "nn kk = mt_pos c4 kk" using c4_eq5 by simp
    have c4_kk: "mt_pos c4 kk = mt_pos c' kk" using c4_pos kklt by simp
    have pos_ge1: "(1 :: nat) ≤ mt_pos c' kk" using hge2 by linarith
    have read_ne_LE: "tts kk (nn kk) ≠ LE_block (le_tm M)"
    proof -
      have "tts kk (nn kk) = mt_tape c4 kk (mt_pos c4 kk)"
        using c4_eq5 nn_kk by simp
      also have "… = mt_tape c' kk (mt_pos c' kk)"
        using c4_kk tape_c4_eq_c' by simp
      finally have read_eq:
          "tts kk (nn kk) = mt_tape c' kk (mt_pos c' kk)" .
      have "mt_tape c' kk (mt_pos c' kk) ≠ LE_block (le_tm M)"
        using home_classification[rule_format, OF kklt] pos_ge1 by blast
      thus ?thesis using read_eq by simp
    qed
    obtain ll hh rr where buf5_kk: "buf5 kk = (ll, hh, rr)"
      using prod.exhaust by metis
    have h_ne_LE: "hh ≠ LE_block (le_tm M)"
    proof -
      have "fst (snd (buf5 kk)) ≠ LE_block (le_tm M)"
        using buf5_not_le_per_tape[rule_format, OF kklt] hge2 by blast
      thus ?thesis using buf5_kk by simp
    qed
    have aa5_kk: "aa5 kk = hh"
      using aa5_eq buf_eq buf5_kk read_ne_LE h_ne_LE kklt by simp
    have "mt_tape c5 kk (mt_pos c' kk) = aa5 kk"
      using c5_eq nn_kk c4_kk by simp
    also have "… = hh" using aa5_kk .
    also have "… = fst (snd (buf5 kk))" using buf5_kk by simp
    finally show "mt_tape c5 kk (mt_pos c' kk) = fst (snd (buf5 kk))" .
  qed

  ― ‹Sub-step 6b4: head trajectory ‹c7_pos› for pos‹≥›2
      tapes.  ‹c6_pos = pos› (‹c6_pos_for_pos_ge2›); SS7 reads
      ‹mt_tape c6 kk pos› = ‹mt_tape c5 kk pos› (off-write from
      SS6 at ‹c5_pos = pos \<mp> 1›) = ‹fst (snd (buf5 kk))›
      (‹tape_c5_at_pos_for_pos_ge2›), non-LE via
      ‹buf5_not_le_per_tape›.  ‹h = fst (snd (buf6 kk))›
      non-LE.  ‹ae_ss7_action›'s else branch fires: dir L if
      ‹dest = AE_Left› else R.  Head lands at ‹pos - 1›
      (‹dest = AE_Left›) or ‹pos + 1› (otherwise).›
  have c7_pos_for_pos_ge2:
      "⋀kk. kk < k_tm M ⟹ mt_pos c' kk ≥ 2
            ⟹ mt_pos c7 kk = (if dest5 kk = AE_Left
                                  then mt_pos c' kk - 1
                                  else mt_pos c' kk + 1)"
  proof -
    fix kk
    assume kklt: "kk < k_tm M"
    assume hge2: "mt_pos c' kk ≥ 2"
    obtain qq tts nn qq' aa7 dr7 where
        c6_eq7: "c6 = ConfigM qq tts nn"
      and c7_eq: "c7 = ConfigM qq'
                          (λk. (tts k)(nn k := aa7 k))
                          (λk. go_dir (dr7 k) (nn k))"
      and tr_in: "(qq, λk. tts k (nn k), qq', aa7, dr7)
                    ∈ ae_delta_ss7_ss8 M"
      using step7_sub by (auto elim: mttm_step.cases)
    obtain q ofs buf dest where
        qq_eq: "qq = (q, ofs, buf, dest, SS7)"
      and dr7_eq:
          "dr7 = (λk. if k < k_tm M then snd (ae_ss7_action (le_tm M)
                              (tts k (nn k)) (buf k) (dest k)) else dir.N)"
      using tr_in by (auto simp: ae_delta_ss7_ss8_def)
    have qq_state: "qq = (q6, ofs6, buf6, dest6, SS7)"
      using c6_state c6_eq7 by simp
    have buf_eq: "buf = buf6" using qq_eq qq_state by simp
    have dest_eq: "dest = dest6" using qq_eq qq_state by simp
    have nn_kk: "nn kk = mt_pos c6 kk" using c6_eq7 by simp
    have c6_kk: "mt_pos c6 kk = mt_pos c' kk"
      using c6_pos_for_pos_ge2[OF kklt hge2] .
    have nn_kk_val: "nn kk = mt_pos c' kk" using nn_kk c6_kk by simp
    obtain ll hh rr where buf5_kk: "buf5 kk = (ll, hh, rr)"
      using prod.exhaust by metis
    have buf6_kk: "buf6 kk = (ll, hh, rr)"
      using buf5_kk buf6_eq_buf5 by simp
    have h_ne_LE: "hh ≠ LE_block (le_tm M)"
    proof -
      have "fst (snd (buf5 kk)) ≠ LE_block (le_tm M)"
        using buf5_not_le_per_tape[rule_format, OF kklt] hge2 by blast
      thus ?thesis using buf5_kk by simp
    qed
    have pos_ne_c5_pos: "mt_pos c' kk ≠ mt_pos c5 kk"
    proof (cases "dest5 kk = AE_Left")
      case True
      have "mt_pos c5 kk = mt_pos c' kk + 1"
        using c5_pos_for_pos_ge2_dest_left[OF kklt hge2 True] .
      thus ?thesis by linarith
    next
      case False
      have "mt_pos c5 kk = mt_pos c' kk - 1"
        using c5_pos_for_pos_ge2[OF kklt hge2 False] .
      thus ?thesis using hge2 by linarith
    qed
    have c6_at_pos: "mt_tape c6 kk (mt_pos c' kk) = mt_tape c5 kk (mt_pos c' kk)"
      using mttm_step_tape_off_head[OF step6 pos_ne_c5_pos] .
    have c5_at_pos:
        "mt_tape c5 kk (mt_pos c' kk) = fst (snd (buf5 kk))"
      using tape_c5_at_pos_for_pos_ge2[OF kklt hge2] .
    have read_ne_LE: "tts kk (nn kk) ≠ LE_block (le_tm M)"
    proof -
      have "tts kk (nn kk) = mt_tape c6 kk (mt_pos c6 kk)"
        using c6_eq7 nn_kk by simp
      also have "… = mt_tape c6 kk (mt_pos c' kk)" using c6_kk by simp
      also have "… = mt_tape c5 kk (mt_pos c' kk)" using c6_at_pos .
      also have "… = fst (snd (buf5 kk))" using c5_at_pos .
      also have "… = hh" using buf5_kk by simp
      finally have read_eq: "tts kk (nn kk) = hh" .
      show ?thesis using read_eq h_ne_LE by simp
    qed
    have dr7_kk:
        "dr7 kk = (if dest6 kk = AE_Left then dir.L else dir.R)"
      using dr7_eq buf_eq dest_eq buf6_kk h_ne_LE read_ne_LE kklt by simp
    show "mt_pos c7 kk = (if dest5 kk = AE_Left
                            then mt_pos c' kk - 1
                            else mt_pos c' kk + 1)"
    proof (cases "dest5 kk = AE_Left")
      case True
      have dest6_eq: "dest6 kk = AE_Left" using True dest6_eq_dest5 by simp
      have dr7_kk_L: "dr7 kk = dir.L" using dr7_kk dest6_eq by simp
      have "mt_pos c7 kk = go_dir (dr7 kk) (nn kk)"
        using c7_eq by simp
      also have "… = (nn kk) - 1" using dr7_kk_L by simp
      also have "… = mt_pos c' kk - 1" using nn_kk_val by simp
      finally show ?thesis using True by simp
    next
      case False
      have dest6_ne: "dest6 kk ≠ AE_Left" using False dest6_eq_dest5 by simp
      have dr7_kk_R: "dr7 kk = dir.R" using dr7_kk dest6_ne by simp
      have "mt_pos c7 kk = go_dir (dr7 kk) (nn kk)"
        using c7_eq by simp
      also have "… = Suc (nn kk)" using dr7_kk_R by simp
      also have "… = mt_pos c' kk + 1" using nn_kk_val by simp
      finally show ?thesis using False by simp
    qed
  qed

  ― ‹Sub-step 6b4: head trajectory ‹c6_pos› for pos=1 tapes,
      uniform across ‹dest›.  ‹dest = AE_Left› routes via
      ‹c6_pos_for_pos1_dest_left› (‹c5_pos = 2›, dir L);
      ‹dest ≠ AE_Left› routes via ‹c5_pos_for_pos1›
      (‹c5_pos = 0›): SS6 reads LE at 0 (‹tape_c5_zero_le›),
      action's first branch (a = LE) fires with direction R,
      head lands at ‹c5_pos + 1 = 1›.›
  have c6_pos_for_pos1:
      "⋀kk. kk < k_tm M ⟹ mt_pos c' kk = 1 ⟹ mt_pos c6 kk = 1"
  proof -
    fix kk
    assume kklt: "kk < k_tm M"
    assume pos_kk: "mt_pos c' kk = 1"
    show "mt_pos c6 kk = 1"
    proof (cases "dest5 kk = AE_Left")
      case True
      show ?thesis using c6_pos_for_pos1_dest_left[OF kklt pos_kk True] .
    next
      case False
      obtain qq tts nn qq' aa6 dr6 where
          c5_eq6: "c5 = ConfigM qq tts nn"
        and c6_eq: "c6 = ConfigM qq'
                            (λk. (tts k)(nn k := aa6 k))
                            (λk. go_dir (dr6 k) (nn k))"
        and tr_in: "(qq, λk. tts k (nn k), qq', aa6, dr6)
                      ∈ ae_delta_ss6_ss7 M"
        using step6_sub by (auto elim: mttm_step.cases)
      obtain q ofs buf dest where
          qq_eq: "qq = (q, ofs, buf, dest, SS6)"
        and dr6_eq:
            "dr6 = (λk. if k < k_tm M then snd (ae_ss6_action (le_tm M)
                                (tts k (nn k)) (buf k) (dest k)) else dir.N)"
        using tr_in by (auto simp: ae_delta_ss6_ss7_def)
      have qq_state: "qq = (q5, ofs5, buf5, dest5, SS6)"
        using c5_state c5_eq6 by simp
      have buf_eq: "buf = buf5" using qq_eq qq_state by simp
      have nn_kk: "nn kk = mt_pos c5 kk" using c5_eq6 by simp
      have c5_kk: "mt_pos c5 kk = 0"
        using c5_pos_for_pos1[OF kklt pos_kk False] .
      have nn_kk_0: "nn kk = 0" using nn_kk c5_kk by simp
      have read_LE: "tts kk (nn kk) = LE_block (le_tm M)"
      proof -
        have "tts kk (nn kk) = mt_tape c5 kk (mt_pos c5 kk)"
          using c5_eq6 nn_kk by simp
        also have "… = mt_tape c5 kk 0" using c5_kk by simp
        also have "… = LE_block (le_tm M)" using tape_c5_zero_le[rule_format, OF kklt] by simp
        finally show ?thesis .
      qed
      obtain ll hh rr where buf5_kk: "buf5 kk = (ll, hh, rr)"
        using prod.exhaust by metis
      have dr6_kk: "dr6 kk = dir.R"
        using dr6_eq buf_eq buf5_kk read_LE kklt by simp
      have "mt_pos c6 kk = go_dir (dr6 kk) (nn kk)"
        using c6_eq by simp
      also have "… = Suc (nn kk)" using dr6_kk by simp
      also have "… = 1" using nn_kk_0 by simp
      finally show ?thesis .
    qed
  qed

  ― ‹Sub-step 6b4: head trajectory ‹c7_pos› for pos=1 tapes.
      ‹c6_pos = 1› uniformly.  For ‹dest = AE_Left›: defers to
      the sub-step 5 lemma ‹c7_pos_for_pos1_dest_left›
      (‹c7_pos = 0›).  For ‹dest ≠ AE_Left›: SS7 reads
      ‹mt_tape c6 kk 1 = mt_tape c5 kk 1› (off-write from SS6 at
      ‹c5_pos = 0›) ‹= fst (snd (buf5 kk)) = hh›
      (‹tape_c5_at_one_pos1›), non-LE (‹buf5_not_le_per_tape›
      pos=1).  ‹h› non-LE; ‹ae_ss7_action›'s else branch
      with ‹dest ≠ AE_Left› gives dir R, head lands at ‹2›.›
  have c7_pos_for_pos1:
      "⋀kk. kk < k_tm M ⟹ mt_pos c' kk = 1
            ⟹ mt_pos c7 kk = (if dest5 kk = AE_Left then 0 else 2)"
  proof -
    fix kk
    assume kklt: "kk < k_tm M"
    assume pos_kk: "mt_pos c' kk = 1"
    show "mt_pos c7 kk = (if dest5 kk = AE_Left then 0 else 2)"
    proof (cases "dest5 kk = AE_Left")
      case True
      have "mt_pos c7 kk = 0"
        using c7_pos_for_pos1_dest_left[OF kklt pos_kk True] .
      thus ?thesis using True by simp
    next
      case False
      obtain qq tts nn qq' aa7 dr7 where
          c6_eq7: "c6 = ConfigM qq tts nn"
        and c7_eq: "c7 = ConfigM qq'
                            (λk. (tts k)(nn k := aa7 k))
                            (λk. go_dir (dr7 k) (nn k))"
        and tr_in: "(qq, λk. tts k (nn k), qq', aa7, dr7)
                      ∈ ae_delta_ss7_ss8 M"
        using step7_sub by (auto elim: mttm_step.cases)
      obtain q ofs buf dest where
          qq_eq: "qq = (q, ofs, buf, dest, SS7)"
        and dr7_eq:
            "dr7 = (λk. if k < k_tm M then snd (ae_ss7_action (le_tm M)
                                (tts k (nn k)) (buf k) (dest k)) else dir.N)"
        using tr_in by (auto simp: ae_delta_ss7_ss8_def)
      have qq_state: "qq = (q6, ofs6, buf6, dest6, SS7)"
        using c6_state c6_eq7 by simp
      have buf_eq: "buf = buf6" using qq_eq qq_state by simp
      have dest_eq: "dest = dest6" using qq_eq qq_state by simp
      have nn_kk: "nn kk = mt_pos c6 kk" using c6_eq7 by simp
      have c6_kk: "mt_pos c6 kk = 1" using c6_pos_for_pos1[OF kklt pos_kk] .
      have nn_kk_1: "nn kk = 1" using nn_kk c6_kk by simp
      have one_ne_c5_pos: "(1 :: nat) ≠ mt_pos c5 kk"
        using c5_pos_for_pos1[OF kklt pos_kk False] by simp
      have c6_at_1: "mt_tape c6 kk 1 = mt_tape c5 kk 1"
        using mttm_step_tape_off_head[OF step6 one_ne_c5_pos] .
      obtain ll hh rr where buf5_kk: "buf5 kk = (ll, hh, rr)"
        using prod.exhaust by metis
      have buf6_kk: "buf6 kk = (ll, hh, rr)"
        using buf5_kk buf6_eq_buf5 by simp
      have c5_at_1: "mt_tape c5 kk 1 = hh"
      proof -
        have "mt_tape c5 kk 1 = fst (snd (buf5 kk))"
          using tape_c5_at_one_pos1[OF kklt pos_kk] .
        thus ?thesis using buf5_kk by simp
      qed
      have h_ne_LE: "hh ≠ LE_block (le_tm M)"
      proof -
        have "fst (snd (buf5 kk)) ≠ LE_block (le_tm M)"
          using buf5_not_le_per_tape[rule_format, OF kklt] pos_kk by blast
        thus ?thesis using buf5_kk by simp
      qed
      have read_ne_LE: "tts kk (nn kk) ≠ LE_block (le_tm M)"
      proof -
        have "tts kk (nn kk) = mt_tape c6 kk (mt_pos c6 kk)"
          using c6_eq7 nn_kk by simp
        also have "… = mt_tape c6 kk 1" using c6_kk by simp
        also have "… = mt_tape c5 kk 1" using c6_at_1 .
        also have "… = hh" using c5_at_1 .
        finally have "tts kk (nn kk) = hh" .
        thus ?thesis using h_ne_LE by simp
      qed
      have dr7_kk:
          "dr7 kk = (if dest6 kk = AE_Left then dir.L else dir.R)"
        using dr7_eq buf_eq dest_eq buf6_kk h_ne_LE read_ne_LE kklt by simp
      have dest6_ne: "dest6 kk ≠ AE_Left" using False dest6_eq_dest5 by simp
      have dr7_kk_R: "dr7 kk = dir.R" using dr7_kk dest6_ne by simp
      have "mt_pos c7 kk = go_dir (dr7 kk) (nn kk)"
        using c7_eq by simp
      also have "… = Suc (nn kk)" using dr7_kk_R by simp
      also have "… = 2" using nn_kk_1 by simp
      finally show ?thesis using False by simp
    qed
  qed

  ― ‹Sub-step 6b5 helper: ‹c6› tape at cell 0 for pos=0 tapes.
      SS6 writes at ‹c5_pos = 0›, reading ‹c5@0 = LE_block›
      (‹tape_c5_zero_le›); action's first branch ‹a = LE› fires,
      writing ‹a = LE_block› back.  So ‹c6@0 = LE_block›.›
  have tape_c6_zero_le_for_pos0:
      "⋀kk. kk < k_tm M ⟹ mt_pos c' kk = 0 ⟹ mt_tape c6 kk 0 = LE_block (le_tm M)"
  proof -
    fix kk
    assume kklt: "kk < k_tm M"
    assume pos_kk: "mt_pos c' kk = 0"
    obtain qq tts nn qq' aa6 dr6 where
        c5_eq6: "c5 = ConfigM qq tts nn"
      and c6_eq: "c6 = ConfigM qq'
                          (λk. (tts k)(nn k := aa6 k))
                          (λk. go_dir (dr6 k) (nn k))"
      and tr_in: "(qq, λk. tts k (nn k), qq', aa6, dr6)
                    ∈ ae_delta_ss6_ss7 M"
      using step6_sub by (auto elim: mttm_step.cases)
    obtain q ofs buf dest where
        qq_eq: "qq = (q, ofs, buf, dest, SS6)"
      and aa6_eq:
          "aa6 = (λk. if k < k_tm M then fst (ae_ss6_action (le_tm M)
                              (tts k (nn k)) (buf k) (dest k)) else bl_block (bl_tm M))"
      using tr_in by (auto simp: ae_delta_ss6_ss7_def)
    have qq_state: "qq = (q5, ofs5, buf5, dest5, SS6)"
      using c5_state c5_eq6 by simp
    have buf_eq: "buf = buf5" using qq_eq qq_state by simp
    have nn_kk: "nn kk = mt_pos c5 kk" using c5_eq6 by simp
    have c5_kk: "mt_pos c5 kk = 0" using c5_pos_for_pos0[OF kklt pos_kk] .
    have nn_kk_0: "nn kk = 0" using nn_kk c5_kk by simp
    have read_LE: "tts kk (nn kk) = LE_block (le_tm M)"
    proof -
      have "tts kk (nn kk) = mt_tape c5 kk (mt_pos c5 kk)"
        using c5_eq6 nn_kk by simp
      also have "… = mt_tape c5 kk 0" using c5_kk by simp
      also have "… = LE_block (le_tm M)" using tape_c5_zero_le[rule_format, OF kklt] by simp
      finally show ?thesis .
    qed
    obtain ll hh rr where buf5_kk: "buf5 kk = (ll, hh, rr)"
      using prod.exhaust by metis
    have aa6_kk: "aa6 kk = LE_block (le_tm M)"
      using aa6_eq buf_eq buf5_kk read_LE kklt by simp
    have "mt_tape c6 kk 0 = aa6 kk"
      using c6_eq nn_kk_0 by simp
    also have "… = LE_block (le_tm M)" using aa6_kk .
    finally show "mt_tape c6 kk 0 = LE_block (le_tm M)" .
  qed

  ― ‹Sub-step 6b5 helper: ‹c7› tape at cell 1 for pos=0 tapes
      under ‹dest = AE_Right›.  SS7 writes at ‹c6_pos = 1›,
      reading ‹c6@1› non-LE and with home-slot ‹h = LE›;
      action's second branch fires (h = LE), and with ‹dest =
      AE_Right› writes ‹r = snd (snd (buf5 kk))›.›
  have tape_c7_at_one_for_pos0_right:
      "⋀kk. kk < k_tm M ⟹ mt_pos c' kk = 0 ⟹ dest5 kk = AE_Right
            ⟹ mt_tape c7 kk 1 = snd (snd (buf5 kk))"
  proof -
    fix kk
    assume kklt: "kk < k_tm M"
    assume pos_kk: "mt_pos c' kk = 0"
    assume dest_eq: "dest5 kk = AE_Right"
    obtain qq tts nn qq' aa7 dr7 where
        c6_eq7: "c6 = ConfigM qq tts nn"
      and c7_eq: "c7 = ConfigM qq'
                          (λk. (tts k)(nn k := aa7 k))
                          (λk. go_dir (dr7 k) (nn k))"
      and tr_in: "(qq, λk. tts k (nn k), qq', aa7, dr7)
                    ∈ ae_delta_ss7_ss8 M"
      using step7_sub by (auto elim: mttm_step.cases)
    obtain q ofs buf dest where
        qq_eq: "qq = (q, ofs, buf, dest, SS7)"
      and aa7_eq:
          "aa7 = (λk. if k < k_tm M then fst (ae_ss7_action (le_tm M)
                              (tts k (nn k)) (buf k) (dest k)) else bl_block (bl_tm M))"
      using tr_in by (auto simp: ae_delta_ss7_ss8_def)
    have qq_state: "qq = (q6, ofs6, buf6, dest6, SS7)"
      using c6_state c6_eq7 by simp
    have buf_eq: "buf = buf6" using qq_eq qq_state by simp
    have dest_eq2: "dest = dest6" using qq_eq qq_state by simp
    have nn_kk: "nn kk = mt_pos c6 kk" using c6_eq7 by simp
    have c6_kk: "mt_pos c6 kk = 1" using c6_pos_for_pos0[OF kklt pos_kk] .
    have nn_kk_1: "nn kk = 1" using nn_kk c6_kk by simp
    have one_ne_c5_pos: "(1 :: nat) ≠ mt_pos c5 kk"
      using c5_pos_for_pos0[OF kklt pos_kk] by simp
    have one_ne_c4_pos: "(1 :: nat) ≠ mt_pos c4 kk"
      using c4_pos kklt pos_kk by simp
    have c6_at_1: "mt_tape c6 kk 1 = mt_tape c' kk 1"
    proof -
      have "mt_tape c6 kk 1 = mt_tape c5 kk 1"
        using mttm_step_tape_off_head[OF step6 one_ne_c5_pos] .
      also have "… = mt_tape c4 kk 1"
        using mttm_step_tape_off_head[OF step5 one_ne_c4_pos] .
      also have "… = mt_tape c' kk 1" using tape_c4_eq_c' by simp
      finally show ?thesis .
    qed
    have read_ne_LE: "tts kk (nn kk) ≠ LE_block (le_tm M)"
    proof -
      have "tts kk (nn kk) = mt_tape c6 kk (mt_pos c6 kk)"
        using c6_eq7 nn_kk by simp
      also have "… = mt_tape c6 kk 1" using c6_kk by simp
      also have "… = mt_tape c' kk 1" using c6_at_1 .
      finally have read_eq: "tts kk (nn kk) = mt_tape c' kk 1" .
      have "mt_tape c' kk (mt_pos c' kk + 1) ≠ LE_block (le_tm M)"
        using right_not_le_c' by blast
      hence "mt_tape c' kk 1 ≠ LE_block (le_tm M)" using pos_kk by simp
      thus ?thesis using read_eq by simp
    qed
    obtain ll hh rr where buf5_kk: "buf5 kk = (ll, hh, rr)"
      using prod.exhaust by metis
    have buf6_kk: "buf6 kk = (ll, hh, rr)"
      using buf5_kk buf6_eq_buf5 by simp
    have hh_le: "hh = LE_block (le_tm M)"
    proof -
      have "fst (snd (buf5 kk)) = LE_block (le_tm M)"
        using buf5_h_le_for_pos0[rule_format, OF kklt] pos_kk by blast
      thus ?thesis using buf5_kk by simp
    qed
    have dest6_eq: "dest6 kk = AE_Right" using dest_eq dest6_eq_dest5 by simp
    have aa7_kk: "aa7 kk = rr"
      using aa7_eq buf_eq dest_eq2 dest6_eq buf6_kk hh_le read_ne_LE kklt by simp
    have "mt_tape c7 kk 1 = aa7 kk" using c7_eq nn_kk_1 by simp
    also have "… = rr" using aa7_kk .
    also have "… = snd (snd (buf5 kk))" using buf5_kk by simp
    finally show "mt_tape c7 kk 1 = snd (snd (buf5 kk))" .
  qed

  ― ‹Sub-step 6b4: head trajectory ‹c8_pos› for pos=0 tapes.
      Internal case-split on ‹dest5 kk = AE_Right›.  For
      ‹dest = AE_Right›: ‹c7_pos = 1›, read ‹r› non-LE,
      ‹h = LE›, action's h-LE branch with ‹dest = AE_Right›
      gives ‹(r, N)›; ‹c8_pos = 1›.  For ‹dest ≠
      AE_Right›: ‹c7_pos = 0›, read LE (‹c6@0 = LE› via
      ‹tape_c6_zero_le_for_pos0›, off-write at SS7);
      action's first branch ‹a = LE› gives ‹(a, N)›;
      ‹c8_pos = 0›.›
  have c8_pos_for_pos0:
      "⋀kk. kk < k_tm M ⟹ mt_pos c' kk = 0
            ⟹ mt_pos c8 kk = (if dest5 kk = AE_Right then 1 else 0)"
  proof -
    fix kk
    assume kklt: "kk < k_tm M"
    assume pos_kk: "mt_pos c' kk = 0"
    obtain qq tts nn qq' aa8 dr8 where
        c7_eq8: "c7 = ConfigM qq tts nn"
      and c8_eq: "c8 = ConfigM qq'
                          (λk. (tts k)(nn k := aa8 k))
                          (λk. go_dir (dr8 k) (nn k))"
      and tr_in: "(qq, λk. tts k (nn k), qq', aa8, dr8)
                    ∈ ae_delta_ss8_ss1 M"
      using step8_sub by (auto elim: mttm_step.cases)
    obtain q ofs buf dest where
        qq_eq: "qq = (q, ofs, buf, dest, SS8)"
      and dr8_eq:
          "dr8 = (λk. if k < k_tm M then snd (ae_ss8_action (le_tm M)
                              (tts k (nn k)) (buf k) (dest k)) else dir.N)"
      using tr_in by (auto simp: ae_delta_ss8_ss1_def)
    have qq_state: "qq = (q6, ofs6, buf6, dest6, SS8)"
      using c7_state c7_eq8 by simp
    have buf_eq: "buf = buf6" using qq_eq qq_state by simp
    have dest_eq: "dest = dest6" using qq_eq qq_state by simp
    have nn_kk: "nn kk = mt_pos c7 kk" using c7_eq8 by simp
    obtain ll hh rr where buf5_kk: "buf5 kk = (ll, hh, rr)"
      using prod.exhaust by metis
    have buf6_kk: "buf6 kk = (ll, hh, rr)"
      using buf5_kk buf6_eq_buf5 by simp
    have hh_le: "hh = LE_block (le_tm M)"
    proof -
      have "fst (snd (buf5 kk)) = LE_block (le_tm M)"
        using buf5_h_le_for_pos0[rule_format, OF kklt] pos_kk by blast
      thus ?thesis using buf5_kk by simp
    qed
    show "mt_pos c8 kk = (if dest5 kk = AE_Right then 1 else 0)"
    proof (cases "dest5 kk = AE_Right")
      case True
      have dest6_eq: "dest6 kk = AE_Right" using True dest6_eq_dest5 by simp
      have c7_kk: "mt_pos c7 kk = 1" using c7_pos_for_pos0[OF kklt pos_kk] True by simp
      have nn_kk_1: "nn kk = 1" using nn_kk c7_kk by simp
      have rr_ne_LE: "rr ≠ LE_block (le_tm M)"
      proof -
        have "snd (snd (buf5 kk)) ≠ LE_block (le_tm M)"
          using buf5_not_le_per_tape[rule_format, OF kklt] pos_kk by blast
        thus ?thesis using buf5_kk by simp
      qed
      have c7_at_1: "mt_tape c7 kk 1 = rr"
      proof -
        have "mt_tape c7 kk 1 = snd (snd (buf5 kk))"
          using tape_c7_at_one_for_pos0_right[OF kklt pos_kk True] .
        thus ?thesis using buf5_kk by simp
      qed
      have read_ne_LE: "tts kk (nn kk) ≠ LE_block (le_tm M)"
      proof -
        have "tts kk (nn kk) = mt_tape c7 kk (mt_pos c7 kk)"
          using c7_eq8 nn_kk by simp
        also have "… = mt_tape c7 kk 1" using c7_kk by simp
        also have "… = rr" using c7_at_1 .
        finally have "tts kk (nn kk) = rr" .
        thus ?thesis using rr_ne_LE by simp
      qed
      have dr8_kk: "dr8 kk = dir.N"
        using dr8_eq buf_eq dest_eq dest6_eq buf6_kk hh_le read_ne_LE kklt by simp
      have "mt_pos c8 kk = go_dir (dr8 kk) (nn kk)"
        using c8_eq by simp
      also have "… = nn kk" using dr8_kk by simp
      also have "… = 1" using nn_kk_1 .
      finally show ?thesis using True by simp
    next
      case False
      have c7_kk: "mt_pos c7 kk = 0"
        using c7_pos_for_pos0[OF kklt pos_kk] False by simp
      have nn_kk_0: "nn kk = 0" using nn_kk c7_kk by simp
      have zero_ne_c6_pos: "(0 :: nat) ≠ mt_pos c6 kk"
        using c6_pos_for_pos0[OF kklt pos_kk] by simp
      have c7_at_0: "mt_tape c7 kk 0 = mt_tape c6 kk 0"
        using mttm_step_tape_off_head[OF step7 zero_ne_c6_pos] .
      have read_LE: "tts kk (nn kk) = LE_block (le_tm M)"
      proof -
        have "tts kk (nn kk) = mt_tape c7 kk (mt_pos c7 kk)"
          using c7_eq8 nn_kk by simp
        also have "… = mt_tape c7 kk 0" using c7_kk by simp
        also have "… = mt_tape c6 kk 0" using c7_at_0 .
        also have "… = LE_block (le_tm M)"
          using tape_c6_zero_le_for_pos0[OF kklt pos_kk] .
        finally show ?thesis .
      qed
      have dr8_kk: "dr8 kk = dir.N"
        using dr8_eq read_LE kklt by simp
      have "mt_pos c8 kk = go_dir (dr8 kk) (nn kk)"
        using c8_eq by simp
      also have "… = nn kk" using dr8_kk by simp
      also have "… = 0" using nn_kk_0 .
      finally show ?thesis using False by simp
    qed
  qed

  ― ‹Sub-step 6b4: head trajectory ‹c8_pos› for pos‹≥›2
      tapes.  Three-way case-split on ‹dest5 kk›.  For
      ‹AE_Left›: ‹c7_pos = pos - 1›, SS8 reads
      ‹mt_tape c' kk (pos - 1)› non-LE (via
      ‹left_not_le_c'_steady›, chained off SS5/SS6/SS7
      writes); action's else branch ‹AE_Left› gives ‹(l, N)›;
      ‹c8_pos = pos - 1›.  For ‹AE_Home›: ‹c7_pos = pos + 1›,
      reads ‹mt_tape c' kk (pos + 1)› non-LE (via
      ‹right_not_le_c'›); else branch ‹AE_Home› gives
      ‹(r, L)›; ‹c8_pos = pos›.  For ‹AE_Right›:
      same read as ‹AE_Home›; else branch ‹AE_Right› gives
      ‹(r, N)›; ‹c8_pos = pos + 1›.  Extracted to
      ‹ae_fwd_c8_pos_for_pos_ge2›.›
  have c8_pos_for_pos_ge2:
      "⋀kk. kk < k_tm M ⟹ mt_pos c' kk ≥ 2
            ⟹ mt_pos c8 kk = (case dest5 kk of
                                  AE_Left  ⇒ mt_pos c' kk - 1
                                | AE_Home  ⇒ mt_pos c' kk
                                | AE_Right ⇒ mt_pos c' kk + 1)"
    by (rule ae_fwd_c8_pos_for_pos_ge2[OF step5 tape_c4_eq_c'
          buf5_not_le_per_tape right_not_le_c' c4_pos step6 step7 c7_state
          buf6_eq_buf5 dest6_eq_dest5 step8_sub c5_pos_for_pos_ge2
          c5_pos_for_pos_ge2_dest_left left_not_le_c'_steady c6_pos_for_pos_ge2
          c7_pos_for_pos_ge2])
  ― ‹Sub-step 6b4: head trajectory ‹c8_pos› for pos=1 tapes.
      Three-way case-split on ‹dest5 kk›.  For ‹AE_Left›:
      defers to sub-step 5's ‹c7_pos_for_pos1_dest_left›
      (‹c7_pos = 0›) and ‹tape_c7_zero_le_pos1_dest_left›
      (‹c7@0 = LE›); SS8's a=LE first branch gives ‹(a, N)›;
      ‹c8_pos = 0›.  For ‹AE_Home›/‹AE_Right›:
      ‹c7_pos = 2›, SS8 reads ‹mt_tape c' kk 2› non-LE
      (via ‹right_not_le_c'› at pos=1); ‹h› non-LE
      (‹buf5_not_le_per_tape› pos=1); else branch dispatches
      ‹AE_Home› to dir L (‹c8_pos = 1›), ‹AE_Right› to
      dir N (‹c8_pos = 2›).  Extracted to
      ‹ae_fwd_c8_pos_for_pos1›.›
  have c8_pos_for_pos1:
      "⋀kk. kk < k_tm M ⟹ mt_pos c' kk = 1
            ⟹ mt_pos c8 kk = (case dest5 kk of
                                  AE_Left  ⇒ 0
                                | AE_Home  ⇒ 1
                                | AE_Right ⇒ 2)"
    by (rule ae_fwd_c8_pos_for_pos1[OF step5 tape_c4_eq_c' buf5_not_le_per_tape
          right_not_le_c' c4_pos c5_pos_for_pos1 step6 step7 c7_state
          buf6_eq_buf5 dest6_eq_dest5 c7_pos_for_pos1_dest_left
          tape_c7_zero_le_pos1_dest_left step8_sub c6_pos_for_pos1
          c7_pos_for_pos1])
  ― ‹Sub-step 6d: ‹tape_c6_zero_le›.  Cell 0 of ‹c6›
      is ‹LE_block› for every tape.  Case-split on whether SS6's
      write site ‹mt_pos c5 kk› equals 0.  If yes (pos=0 always,
      or pos=1 with ‹dest ≠ AE_Left›): SS6 reads
      ‹c5@0 = LE› (‹tape_c5_zero_le›) and writes LE back via
      the first branch.  If no (pos=1 with ‹dest = AE_Left›
      has ‹c5_pos = 2›; pos‹≥›2 has
      ‹c5_pos ∈ {pos-1, pos+1}›): SS6 writes off cell 0, so
      ‹c6@0 = c5@0 = LE›.›
  have tape_c6_zero_le: "∀kk<k_tm M. mt_tape c6 kk 0 = LE_block (le_tm M)"
  proof (intro allI impI)
    fix kk
    assume kklt: "kk < k_tm M"
    obtain qq tts nn qq' aa6 dr6 where
        c5_eq6: "c5 = ConfigM qq tts nn"
      and c6_eq: "c6 = ConfigM qq'
                          (λk. (tts k)(nn k := aa6 k))
                          (λk. go_dir (dr6 k) (nn k))"
      and tr_in: "(qq, λk. tts k (nn k), qq', aa6, dr6)
                    ∈ ae_delta_ss6_ss7 M"
      using step6_sub by (auto elim: mttm_step.cases)
    obtain q ofs buf dest where
        qq_eq: "qq = (q, ofs, buf, dest, SS6)"
      and aa6_eq:
          "aa6 = (λk. if k < k_tm M then fst (ae_ss6_action (le_tm M)
                              (tts k (nn k)) (buf k) (dest k)) else bl_block (bl_tm M))"
      using tr_in by (auto simp: ae_delta_ss6_ss7_def)
    have qq_state: "qq = (q5, ofs5, buf5, dest5, SS6)"
      using c5_state c5_eq6 by simp
    have buf_eq: "buf = buf5" using qq_eq qq_state by simp
    have nn_kk: "nn kk = mt_pos c5 kk" using c5_eq6 by simp
    show "mt_tape c6 kk 0 = LE_block (le_tm M)"
    proof (cases "mt_pos c5 kk = 0")
      case True
      have nn_kk_0: "nn kk = 0" using nn_kk True by simp
      have read_LE: "tts kk (nn kk) = LE_block (le_tm M)"
      proof -
        have "tts kk (nn kk) = mt_tape c5 kk (mt_pos c5 kk)"
          using c5_eq6 nn_kk by simp
        also have "… = mt_tape c5 kk 0" using True by simp
        also have "… = LE_block (le_tm M)" using tape_c5_zero_le[rule_format, OF kklt] by simp
        finally show ?thesis .
      qed
      obtain ll hh rr where buf5_kk: "buf5 kk = (ll, hh, rr)"
        using prod.exhaust by metis
      have aa6_kk: "aa6 kk = LE_block (le_tm M)"
        using aa6_eq buf_eq buf5_kk read_LE kklt by simp
      have "mt_tape c6 kk 0 = aa6 kk" using c6_eq nn_kk_0 by simp
      also have "… = LE_block (le_tm M)" using aa6_kk .
      finally show ?thesis .
    next
      case False
      have zero_ne_c5: "(0 :: nat) ≠ mt_pos c5 kk" using False by simp
      have "mt_tape c6 kk 0 = mt_tape c5 kk 0"
        using mttm_step_tape_off_head[OF step6 zero_ne_c5] .
      also have "… = LE_block (le_tm M)" using tape_c5_zero_le[rule_format, OF kklt] by simp
      finally show ?thesis .
    qed
  qed

  ― ‹Sub-step 6d: ‹tape_c7_zero_le›.  Cell 0 of ‹c7›
      is ‹LE_block›.  SS7's write site ‹mt_pos c6 kk› is
      never 0: pos=0 has ‹c6_pos = 1›; pos=1 has ‹c6_pos = 1›;
      pos‹≥›2 has ‹c6_pos = pos ≥ 2›.  Off-write,
      ‹c7@0 = c6@0 = LE›.›
  have tape_c7_zero_le: "∀kk<k_tm M. mt_tape c7 kk 0 = LE_block (le_tm M)"
  proof (intro allI impI)
    fix kk
    assume kklt: "kk < k_tm M"
    have zero_ne_c6: "(0 :: nat) ≠ mt_pos c6 kk"
    proof -
      consider (le0) "mt_pos c' kk = 0"
             | (le1) "mt_pos c' kk = 1"
             | (steady) "mt_pos c' kk ≥ 2"
        by linarith
      thus ?thesis
      proof cases
        case le0    thus ?thesis using c6_pos_for_pos0[OF kklt le0] by simp
      next
        case le1    thus ?thesis using c6_pos_for_pos1[OF kklt le1] by simp
      next
        case steady thus ?thesis using c6_pos_for_pos_ge2[OF kklt steady] by linarith
      qed
    qed
    have "mt_tape c7 kk 0 = mt_tape c6 kk 0"
      using mttm_step_tape_off_head[OF step7 zero_ne_c6] .
    also have "… = LE_block (le_tm M)"
      using tape_c6_zero_le[rule_format, OF kklt] by simp
    finally show "mt_tape c7 kk 0 = LE_block (le_tm M)" .
  qed

  ― ‹Sub-step 6d: ‹tape_c8_zero_le›.  Cell 0 of ‹c8›
      is ‹LE_block›.  Case-split on whether SS8's write site
      ‹mt_pos c7 kk› equals 0.  If yes (pos=0 with ‹dest ≠
      AE_Right›, or pos=1 with ‹dest = AE_Left›): SS8 reads
      ‹c7@0 = LE› (‹tape_c7_zero_le›) and writes LE back
      via the first branch.  If no: SS8 writes off 0, so
      ‹c8@0 = c7@0 = LE›.›
  have tape_c8_zero_le: "∀kk<k_tm M. mt_tape c8 kk 0 = LE_block (le_tm M)"
  proof (intro allI impI)
    fix kk
    assume kklt: "kk < k_tm M"
    obtain qq tts nn qq' aa8 dr8 where
        c7_eq8: "c7 = ConfigM qq tts nn"
      and c8_eq: "c8 = ConfigM qq'
                          (λk. (tts k)(nn k := aa8 k))
                          (λk. go_dir (dr8 k) (nn k))"
      and tr_in: "(qq, λk. tts k (nn k), qq', aa8, dr8)
                    ∈ ae_delta_ss8_ss1 M"
      using step8_sub by (auto elim: mttm_step.cases)
    obtain q ofs buf dest where
        qq_eq: "qq = (q, ofs, buf, dest, SS8)"
      and aa8_eq:
          "aa8 = (λk. if k < k_tm M then fst (ae_ss8_action (le_tm M)
                              (tts k (nn k)) (buf k) (dest k)) else bl_block (bl_tm M))"
      using tr_in by (auto simp: ae_delta_ss8_ss1_def)
    have nn_kk: "nn kk = mt_pos c7 kk" using c7_eq8 by simp
    show "mt_tape c8 kk 0 = LE_block (le_tm M)"
    proof (cases "mt_pos c7 kk = 0")
      case True
      have nn_kk_0: "nn kk = 0" using nn_kk True by simp
      have read_LE: "tts kk (nn kk) = LE_block (le_tm M)"
      proof -
        have "tts kk (nn kk) = mt_tape c7 kk (mt_pos c7 kk)"
          using c7_eq8 nn_kk by simp
        also have "… = mt_tape c7 kk 0" using True by simp
        also have "… = LE_block (le_tm M)"
          using tape_c7_zero_le[rule_format, OF kklt] by simp
        finally show ?thesis .
      qed
      obtain ll hh rr where buf_kk: "buf kk = (ll, hh, rr)"
        using prod.exhaust by metis
      have aa8_kk: "aa8 kk = LE_block (le_tm M)"
        using aa8_eq buf_kk read_LE kklt by simp
      have "mt_tape c8 kk 0 = aa8 kk" using c8_eq nn_kk_0 by simp
      also have "… = LE_block (le_tm M)" using aa8_kk .
      finally show ?thesis .
    next
      case False
      have zero_ne_c7: "(0 :: nat) ≠ mt_pos c7 kk" using False by simp
      have "mt_tape c8 kk 0 = mt_tape c7 kk 0"
        using mttm_step_tape_off_head[OF step8 zero_ne_c7] .
      also have "… = LE_block (le_tm M)"
        using tape_c7_zero_le[rule_format, OF kklt] by simp
      finally show ?thesis .
    qed
  qed

  ― ‹Sub-step 6b6: M'-side off-window preservation.
      Regime-agnostic form: cells outside all four SS5‹…›SS8 write
      sites are preserved from ‹c'›.  Each substep writes at one
      per-tape position; chaining the four ‹mttm_step_tape_off_head›
      facts plus ‹tape_c4_eq_c'› gives the result.  Per-regime
      instantiation provides the s-not-in-window precondition.›
  have c8_tape_off_window:
      "⋀kk s. s ≠ mt_pos c4 kk ⟹ s ≠ mt_pos c5 kk
              ⟹ s ≠ mt_pos c6 kk ⟹ s ≠ mt_pos c7 kk
              ⟹ mt_tape c8 kk s = mt_tape c' kk s"
  proof -
    fix kk
    fix s :: nat
    assume s_ne_c4: "s ≠ mt_pos c4 kk"
    assume s_ne_c5: "s ≠ mt_pos c5 kk"
    assume s_ne_c6: "s ≠ mt_pos c6 kk"
    assume s_ne_c7: "s ≠ mt_pos c7 kk"
    have c5_eq_c4: "mt_tape c5 kk s = mt_tape c4 kk s"
      using mttm_step_tape_off_head[OF step5 s_ne_c4] .
    have c6_eq_c5: "mt_tape c6 kk s = mt_tape c5 kk s"
      using mttm_step_tape_off_head[OF step6 s_ne_c5] .
    have c7_eq_c6: "mt_tape c7 kk s = mt_tape c6 kk s"
      using mttm_step_tape_off_head[OF step7 s_ne_c6] .
    have c8_eq_c7: "mt_tape c8 kk s = mt_tape c7 kk s"
      using mttm_step_tape_off_head[OF step8 s_ne_c7] .
    show "mt_tape c8 kk s = mt_tape c' kk s"
      using c8_eq_c7 c7_eq_c6 c6_eq_c5 c5_eq_c4 tape_c4_eq_c' by simp
  qed

  ― ‹Sub-step 6b5: pos=0 in-window c8 value at block 1.
      Uniformly ‹c8@1 = rr› (= the buf5 right slot).  Case-split
      on ‹dest5 kk = AE_Right›.  For ‹dest = AE_Right›:
      SS7 wrote ‹r› at ‹c6_pos = 1›; SS8 wrote at ‹c7_pos = 1›
      with action h=LE+dest=Right giving ‹(r, N)›; ‹c8@1 = r›.
      For ‹dest ≠ AE_Right›: SS7 wrote ‹r› at ‹c6_pos = 1›
      (action h=LE+dest‹\<ne>›Right gives ‹(r, L)›); SS8 wrote at
      ‹c7_pos = 0 ≠ 1›, off-write; ‹c8@1 = c7@1 = r›.
      Extracted to ‹ae_fwd_c8_at_one_for_pos0›.›
  have c8_tape_at_one_for_pos0:
      "⋀kk. kk < k_tm M ⟹ mt_pos c' kk = 0
            ⟹ mt_tape c8 kk 1 = snd (snd (buf5 kk))"
    by (rule ae_fwd_c8_at_one_for_pos0[OF step5 tape_c4_eq_c'
          buf5_not_le_per_tape right_not_le_c' c4_pos step6 step7_sub c6_state
          c7_state buf6_eq_buf5 dest6_eq_dest5 step8_sub step8 c5_pos_for_pos0
          buf5_h_le_for_pos0 c6_pos_for_pos0 c7_pos_for_pos0])
  ― ‹Sub-step 6b5 helper: ‹c7›'s block 1 for pos=1 tapes.
      Uniformly ‹c7@1 = hh›.  SS7 writes ‹aa7› at ‹c6_pos = 1›;
      action reads ‹a = c6@1 = c5@1 = hh› (via off SS6 write at
      ‹c5_pos ∈ {0, 2}›, then ‹tape_c5_at_one_pos1›), h non-LE;
      else branch writes ‹a = hh› regardless of ‹dest›.›
  have c7_tape_at_one_for_pos1:
      "⋀kk. kk < k_tm M ⟹ mt_pos c' kk = 1
            ⟹ mt_tape c7 kk 1 = fst (snd (buf5 kk))"
  proof -
    fix kk
    assume kklt: "kk < k_tm M"
    assume pos_kk: "mt_pos c' kk = 1"
    obtain qq tts nn qq' aa7 dr7 where
        c6_eq7: "c6 = ConfigM qq tts nn"
      and c7_eq: "c7 = ConfigM qq'
                          (λk. (tts k)(nn k := aa7 k))
                          (λk. go_dir (dr7 k) (nn k))"
      and tr_in: "(qq, λk. tts k (nn k), qq', aa7, dr7)
                    ∈ ae_delta_ss7_ss8 M"
      using step7_sub by (auto elim: mttm_step.cases)
    obtain q7 ofs7 buf7 dest7 where
        qq_eq: "qq = (q7, ofs7, buf7, dest7, SS7)"
      and aa7_eq:
          "aa7 = (λk. if k < k_tm M then fst (ae_ss7_action (le_tm M)
                              (tts k (nn k)) (buf7 k) (dest7 k)) else bl_block (bl_tm M))"
      using tr_in by (auto simp: ae_delta_ss7_ss8_def)
    have qq_state: "qq = (q6, ofs6, buf6, dest6, SS7)"
      using c6_state c6_eq7 by simp
    have buf7_eq: "buf7 = buf6" using qq_eq qq_state by simp
    have dest7_eq: "dest7 = dest6" using qq_eq qq_state by simp
    have nn_kk: "nn kk = mt_pos c6 kk" using c6_eq7 by simp
    have c6_kk: "mt_pos c6 kk = 1" using c6_pos_for_pos1[OF kklt pos_kk] .
    have nn_kk_1: "nn kk = 1" using nn_kk c6_kk by simp
    have one_ne_c5_pos: "(1 :: nat) ≠ mt_pos c5 kk"
    proof (cases "dest5 kk = AE_Left")
      case True
      have "mt_pos c5 kk = 2"
        using c5_pos_for_pos1_dest_left[OF kklt pos_kk True] .
      thus ?thesis by simp
    next
      case False
      have "mt_pos c5 kk = 0"
        using c5_pos_for_pos1[OF kklt pos_kk False] .
      thus ?thesis by simp
    qed
    have c6_at_1_eq_hh:
        "mt_tape c6 kk 1 = fst (snd (buf5 kk))"
    proof -
      have "mt_tape c6 kk 1 = mt_tape c5 kk 1"
        using mttm_step_tape_off_head[OF step6 one_ne_c5_pos] .
      also have "… = fst (snd (buf5 kk))"
        using tape_c5_at_one_pos1[OF kklt pos_kk] .
      finally show ?thesis .
    qed
    obtain ll hh rr where buf5_kk: "buf5 kk = (ll, hh, rr)"
      using prod.exhaust by metis
    have buf6_kk: "buf6 kk = (ll, hh, rr)"
      using buf5_kk buf6_eq_buf5 by simp
    have h_ne_LE: "hh ≠ LE_block (le_tm M)"
    proof -
      have "fst (snd (buf5 kk)) ≠ LE_block (le_tm M)"
        using buf5_not_le_per_tape[rule_format, OF kklt] pos_kk by blast
      thus ?thesis using buf5_kk by simp
    qed
    have read_ne_LE: "tts kk (nn kk) ≠ LE_block (le_tm M)"
    proof -
      have "tts kk (nn kk) = mt_tape c6 kk (mt_pos c6 kk)"
        using c6_eq7 nn_kk by simp
      also have "… = mt_tape c6 kk 1" using c6_kk by simp
      also have "… = fst (snd (buf5 kk))" using c6_at_1_eq_hh .
      also have "… = hh" using buf5_kk by simp
      finally have "tts kk (nn kk) = hh" .
      thus ?thesis using h_ne_LE by simp
    qed
    ― ‹Action's else branch fires, returning ‹(a, _)› regardless
        of ‹dest›.›
    have aa7_kk: "aa7 kk = tts kk (nn kk)"
      using aa7_eq buf7_eq buf6_kk h_ne_LE read_ne_LE kklt by simp
    have tts_eq_hh: "tts kk (nn kk) = hh"
    proof -
      have "tts kk (nn kk) = mt_tape c6 kk 1"
        using c6_eq7 nn_kk_1 by simp
      also have "… = fst (snd (buf5 kk))" using c6_at_1_eq_hh .
      also have "… = hh" using buf5_kk by simp
      finally show ?thesis .
    qed
    have "mt_tape c7 kk 1 = aa7 kk" using c7_eq nn_kk_1 by simp
    also have "… = tts kk (nn kk)" using aa7_kk .
    also have "… = hh" using tts_eq_hh .
    also have "… = fst (snd (buf5 kk))" using buf5_kk by simp
    finally show "mt_tape c7 kk 1 = fst (snd (buf5 kk))" .
  qed

  ― ‹Sub-step 6b5: pos=1 in-window c8 value at block 1.
      ‹c7_pos ∈ {0, 2}›, never 1; so SS8 writes off cell 1.
      ‹c8@1 = c7@1 = hh›.›
  have c8_tape_at_one_for_pos1:
      "⋀kk. kk < k_tm M ⟹ mt_pos c' kk = 1
            ⟹ mt_tape c8 kk 1 = fst (snd (buf5 kk))"
  proof -
    fix kk
    assume kklt: "kk < k_tm M"
    assume pos_kk: "mt_pos c' kk = 1"
    have c7_pos_ne_1: "mt_pos c7 kk ≠ 1"
    proof (cases "dest5 kk = AE_Left")
      case True
      have "mt_pos c7 kk = 0"
        using c7_pos_for_pos1_dest_left[OF kklt pos_kk True] .
      thus ?thesis by simp
    next
      case False
      have "mt_pos c7 kk = 2"
        using c7_pos_for_pos1[OF kklt pos_kk] False by simp
      thus ?thesis by simp
    qed
    have ne: "(1 :: nat) ≠ mt_pos c7 kk" using c7_pos_ne_1 by simp
    have "mt_tape c8 kk 1 = mt_tape c7 kk 1"
      using mttm_step_tape_off_head[OF step8 ne] .
    also have "… = fst (snd (buf5 kk))"
      using c7_tape_at_one_for_pos1[OF kklt pos_kk] .
    finally show "mt_tape c8 kk 1 = fst (snd (buf5 kk))" .
  qed

  ― ‹Sub-step 6b5: pos=1 in-window c8 value at block 2.
      Three-way case-split on ‹dest5 kk›; uniformly ‹c8@2 = rr›.
      For ‹AE_Left›: SS6 writes ‹r› at ‹c5_pos = 2›
      (action's else branch with ‹ds = AE_Left› gives ‹(r, L)›);
      SS7, SS8 off cell 2.  For ‹AE_Home›/‹AE_Right›: SS6,
      SS7 off cell 2; SS8 writes ‹r› at ‹c7_pos = 2› (action's
      else branch with ‹ds = AE_Home› gives ‹(r, L)›,
      ‹ds = AE_Right› gives ‹(r, N)›).  Extracted to
      ‹ae_fwd_c8_at_two_for_pos1›.›
  have c8_tape_at_two_for_pos1:
      "⋀kk. kk < k_tm M ⟹ mt_pos c' kk = 1
            ⟹ mt_tape c8 kk 2 = snd (snd (buf5 kk))"
    by (rule ae_fwd_c8_at_two_for_pos1[OF step5 c5_state tape_c4_eq_c'
          buf5_not_le_per_tape right_not_le_c' c4_pos c5_pos_for_pos1 step6_sub
          step6 step7 c7_state buf6_eq_buf5 dest6_eq_dest5
          c5_pos_for_pos1_dest_left c7_pos_for_pos1_dest_left step8_sub step8
          c6_pos_for_pos1 c7_pos_for_pos1])
  ― ‹Sub-step 6b5 helper: ‹c7›'s block pos for pos‹≥›2.
      Uniformly ‹c7@pos = hh›.  SS7 writes ‹aa7› at ‹c6_pos =
      pos›; action reads ‹a = c6@pos = c5@pos = hh› (via off
      SS6 write at ‹c5_pos = pos \<mp> 1›, then
      ‹tape_c5_at_pos_for_pos_ge2›); else branch writes ‹a = hh›
      regardless of ‹dest›.›
  have c7_tape_at_pos_for_pos_ge2:
      "⋀kk. kk < k_tm M ⟹ mt_pos c' kk ≥ 2
            ⟹ mt_tape c7 kk (mt_pos c' kk) = fst (snd (buf5 kk))"
  proof -
    fix kk
    assume kklt: "kk < k_tm M"
    assume hge2: "mt_pos c' kk ≥ 2"
    obtain qq tts nn qq' aa7 dr7 where
        c6_eq7: "c6 = ConfigM qq tts nn"
      and c7_eq: "c7 = ConfigM qq'
                          (λk. (tts k)(nn k := aa7 k))
                          (λk. go_dir (dr7 k) (nn k))"
      and tr_in: "(qq, λk. tts k (nn k), qq', aa7, dr7)
                    ∈ ae_delta_ss7_ss8 M"
      using step7_sub by (auto elim: mttm_step.cases)
    obtain q ofs buf dest where
        qq_eq: "qq = (q, ofs, buf, dest, SS7)"
      and aa7_eq:
          "aa7 = (λk. if k < k_tm M then fst (ae_ss7_action (le_tm M)
                              (tts k (nn k)) (buf k) (dest k)) else bl_block (bl_tm M))"
      using tr_in by (auto simp: ae_delta_ss7_ss8_def)
    have qq_state: "qq = (q6, ofs6, buf6, dest6, SS7)"
      using c6_state c6_eq7 by simp
    have buf_eq: "buf = buf6" using qq_eq qq_state by simp
    have nn_kk: "nn kk = mt_pos c6 kk" using c6_eq7 by simp
    have c6_kk: "mt_pos c6 kk = mt_pos c' kk"
      using c6_pos_for_pos_ge2[OF kklt hge2] .
    have nn_kk_pos: "nn kk = mt_pos c' kk" using nn_kk c6_kk by simp
    have pos_ne_c5: "mt_pos c' kk ≠ mt_pos c5 kk"
    proof (cases "dest5 kk = AE_Left")
      case True
      have "mt_pos c5 kk = mt_pos c' kk + 1"
        using c5_pos_for_pos_ge2_dest_left[OF kklt hge2 True] .
      thus ?thesis by linarith
    next
      case False
      have "mt_pos c5 kk = mt_pos c' kk - 1"
        using c5_pos_for_pos_ge2[OF kklt hge2 False] .
      thus ?thesis using hge2 by linarith
    qed
    have c6_at_pos:
        "mt_tape c6 kk (mt_pos c' kk) = fst (snd (buf5 kk))"
    proof -
      have "mt_tape c6 kk (mt_pos c' kk) = mt_tape c5 kk (mt_pos c' kk)"
        using mttm_step_tape_off_head[OF step6 pos_ne_c5] .
      also have "… = fst (snd (buf5 kk))"
        using tape_c5_at_pos_for_pos_ge2[OF kklt hge2] .
      finally show ?thesis .
    qed
    obtain ll hh rr where buf5_kk: "buf5 kk = (ll, hh, rr)"
      using prod.exhaust by metis
    have buf6_kk: "buf6 kk = (ll, hh, rr)"
      using buf5_kk buf6_eq_buf5 by simp
    have h_ne_LE: "hh ≠ LE_block (le_tm M)"
    proof -
      have "fst (snd (buf5 kk)) ≠ LE_block (le_tm M)"
        using buf5_not_le_per_tape[rule_format, OF kklt] hge2 by blast
      thus ?thesis using buf5_kk by simp
    qed
    have read_eq_hh: "tts kk (nn kk) = hh"
    proof -
      have "tts kk (nn kk) = mt_tape c6 kk (mt_pos c6 kk)"
        using c6_eq7 nn_kk by simp
      also have "… = mt_tape c6 kk (mt_pos c' kk)" using c6_kk by simp
      also have "… = fst (snd (buf5 kk))" using c6_at_pos .
      also have "… = hh" using buf5_kk by simp
      finally show ?thesis .
    qed
    have read_ne_LE: "tts kk (nn kk) ≠ LE_block (le_tm M)"
      using read_eq_hh h_ne_LE by simp
    have aa7_kk: "aa7 kk = tts kk (nn kk)"
      using aa7_eq buf_eq buf6_kk h_ne_LE read_ne_LE kklt by simp
    have "mt_tape c7 kk (mt_pos c' kk) = aa7 kk"
      using c7_eq nn_kk_pos by simp
    also have "… = tts kk (nn kk)" using aa7_kk .
    also have "… = hh" using read_eq_hh .
    also have "… = fst (snd (buf5 kk))" using buf5_kk by simp
    finally show "mt_tape c7 kk (mt_pos c' kk) = fst (snd (buf5 kk))" .
  qed

  ― ‹Sub-step 6b5: pos‹≥›2 in-window c8 value at block
      pos.  Uniformly ‹c8@pos = hh›.  SS8 writes at ‹c7_pos = pos \<mp> 1›,
      never pos for pos‹≥›2; ‹c8@pos = c7@pos = hh›
      via off-write preservation and ‹c7_tape_at_pos_for_pos_ge2›.›
  have c8_tape_at_pos_for_pos_ge2:
      "⋀kk. kk < k_tm M ⟹ mt_pos c' kk ≥ 2
            ⟹ mt_tape c8 kk (mt_pos c' kk) = fst (snd (buf5 kk))"
  proof -
    fix kk
    assume kklt: "kk < k_tm M"
    assume hge2: "mt_pos c' kk ≥ 2"
    have pos_ne_c7: "mt_pos c' kk ≠ mt_pos c7 kk"
    proof (cases "dest5 kk = AE_Left")
      case True
      have "mt_pos c7 kk = mt_pos c' kk - 1"
        using c7_pos_for_pos_ge2[OF kklt hge2] True by simp
      thus ?thesis using hge2 by linarith
    next
      case False
      have "mt_pos c7 kk = mt_pos c' kk + 1"
        using c7_pos_for_pos_ge2[OF kklt hge2] False by simp
      thus ?thesis by linarith
    qed
    have "mt_tape c8 kk (mt_pos c' kk) = mt_tape c7 kk (mt_pos c' kk)"
      using mttm_step_tape_off_head[OF step8 pos_ne_c7] .
    also have "… = fst (snd (buf5 kk))"
      using c7_tape_at_pos_for_pos_ge2[OF kklt hge2] .
    finally show "mt_tape c8 kk (mt_pos c' kk) = fst (snd (buf5 kk))" .
  qed

  ― ‹Sub-step 6b5: pos‹≥›2 in-window c8 value at block
      pos-1.  Uniformly ‹c8@(pos-1) = ll›.  Three-way dest case-split.
      For ‹AE_Left›: SS5/SS6/SS7 off pos-1; SS8 writes ‹l› at
      ‹c7_pos = pos - 1› (action's else branch with ‹ds = AE_Left›
      gives ‹(l, N)›).  For ‹AE_Home›/‹AE_Right›: SS6 writes
      ‹l› at ‹c5_pos = pos - 1› (action's else branch with
      ‹ds ≠ AE_Left› gives ‹(l, R)›); SS7, SS8 off pos-1.
      Extracted to ‹ae_fwd_c8_at_pos_minus_1_ge2›.›
  have c8_tape_at_pos_minus_1_for_pos_ge2:
      "⋀kk. kk < k_tm M ⟹ mt_pos c' kk ≥ 2
            ⟹ mt_tape c8 kk (mt_pos c' kk - 1) = fst (buf5 kk)"
    by (rule ae_fwd_c8_at_pos_minus_1_ge2[OF step5 c5_state tape_c4_eq_c'
          buf5_not_le_per_tape c4_pos step6_sub step6 step7 c7_state
          buf6_eq_buf5 dest6_eq_dest5 step8_sub step8 c5_pos_for_pos_ge2
          c5_pos_for_pos_ge2_dest_left left_not_le_c'_steady
          c6_pos_for_pos_ge2 c7_pos_for_pos_ge2])
  ― ‹Sub-step 6b5: pos‹≥›2 in-window c8 value at block
      pos+1.  Uniformly ‹c8@(pos+1) = rr›.  Three-way dest case-split.
      For ‹AE_Left›: SS6 writes ‹r› at ‹c5_pos = pos + 1›
      (else branch with ‹ds = AE_Left› gives ‹(r, L)›); SS7, SS8
      off pos+1.  For ‹AE_Home›/‹AE_Right›: SS6/SS7 off pos+1;
      SS8 writes ‹r› at ‹c7_pos = pos + 1› (else branch with
      ‹ds = AE_Home› gives ‹(r, L)›, ‹ds = AE_Right› gives
      ‹(r, N)›).  Extracted to ‹ae_fwd_c8_at_pos_plus_1_ge2›.›
  have c8_tape_at_pos_plus_1_for_pos_ge2:
      "⋀kk. kk < k_tm M ⟹ mt_pos c' kk ≥ 2
            ⟹ mt_tape c8 kk (mt_pos c' kk + 1) = snd (snd (buf5 kk))"
    by (rule ae_fwd_c8_at_pos_plus_1_ge2[OF step5 c5_state tape_c4_eq_c'
          buf5_not_le_per_tape right_not_le_c' c4_pos step6_sub step6 step7
          c7_state buf6_eq_buf5 dest6_eq_dest5 step8_sub step8
          c5_pos_for_pos_ge2 c5_pos_for_pos_ge2_dest_left c6_pos_for_pos_ge2
          c7_pos_for_pos_ge2])
  let ?c = "card (UNIV :: 'c set)"

  ― ‹Sub-step 6b5: M-side buf-lin transfers per regime, per
      in-window block.  Projects the window invariant's
      linearisation clause for each ‹(regime, s)› pair.  Six
      lemmas: pos=0/s=1; pos=1/s=1,2; pos‹≥›2/s=pos-1,pos,pos+1.›
  have tape_cM_k_at_one_for_pos0:
      "⋀kk i. kk < k_tm M ⟹ mt_pos c' kk = 0
              ⟹ mt_tape cM_k kk (Suc (c_idx (i :: 'c)))
                    = (snd (snd (buf5 kk))) i"
  proof -
    fix kk
    fix i :: 'c
    assume kklt: "kk < k_tm M"
    assume pos_kk: "mt_pos c' kk = 0"
    have c_idx_lt: "c_idx i < ?c" by (rule c_idx_lt_card)
    have wi: "ae_window_invariant_general
                (mt_tape cM_k kk) (mt_pos cM_k kk)
                (dest5 kk, ofs5 kk) (buf5 kk)
                (mt_pos c' kk) (le_tm M)"
      using cM_k_window_general[rule_format, OF kklt] by simp
    hence win_le0: "ae_window_invariant_le0
              (mt_tape cM_k kk) (mt_pos cM_k kk)
              (dest5 kk, ofs5 kk) (buf5 kk) (le_tm M)"
      using pos_kk unfolding ae_window_invariant_general_def by simp
    have buf_eq:
        "mt_tape cM_k kk (Suc (c_idx i))
            = buf_lin_at (buf5 kk) (2 * ?c + c_idx i)"
      using win_le0 c_idx_lt unfolding ae_window_invariant_le0_def by blast
    obtain ll hh rr where buf5_kk: "buf5 kk = (ll, hh, rr)"
      using prod.exhaust by metis
    have not_lt_c: "¬ 2 * ?c + c_idx i < ?c" by simp
    have not_lt_2c: "¬ 2 * ?c + c_idx i < 2 * ?c" by simp
    have buf_lin_eq:
        "buf_lin_at (buf5 kk) (2 * ?c + c_idx i)
            = rr ((enum_class.enum :: 'c list) ! ((2 * ?c + c_idx i) - 2 * ?c))"
      using buf5_kk not_lt_c not_lt_2c
      unfolding buf_lin_at_def Let_def by simp
    have sub_simp: "(2 * ?c + c_idx i) - 2 * ?c = c_idx i" by simp
    have enum_at_idx:
        "(enum_class.enum :: 'c list) ! c_idx i = i"
      by (rule c_idx_in_range(2))
    show "mt_tape cM_k kk (Suc (c_idx i)) = (snd (snd (buf5 kk))) i"
      using buf_eq buf_lin_eq sub_simp enum_at_idx buf5_kk by simp
  qed

  have tape_cM_k_at_one_for_pos1:
      "⋀kk i. kk < k_tm M ⟹ mt_pos c' kk = 1
              ⟹ mt_tape cM_k kk (Suc (c_idx (i :: 'c)))
                    = (fst (snd (buf5 kk))) i"
  proof -
    fix kk
    fix i :: 'c
    assume kklt: "kk < k_tm M"
    assume pos_kk: "mt_pos c' kk = 1"
    have c_idx_lt: "c_idx i < ?c" by (rule c_idx_lt_card)
    have c_idx_lt_2c: "c_idx i < 2 * ?c" using c_idx_lt by linarith
    have wi: "ae_window_invariant_general
                (mt_tape cM_k kk) (mt_pos cM_k kk)
                (dest5 kk, ofs5 kk) (buf5 kk)
                (mt_pos c' kk) (le_tm M)"
      using cM_k_window_general[rule_format, OF kklt] by simp
    hence win_le1: "ae_window_invariant_le1
              (mt_tape cM_k kk) (mt_pos cM_k kk)
              (dest5 kk, ofs5 kk) (buf5 kk) (le_tm M)"
      using pos_kk unfolding ae_window_invariant_general_def by simp
    have buf_eq:
        "mt_tape cM_k kk (Suc (c_idx i))
            = buf_lin_at (buf5 kk) (?c + c_idx i)"
      using win_le1 c_idx_lt_2c unfolding ae_window_invariant_le1_def by blast
    obtain ll hh rr where buf5_kk: "buf5 kk = (ll, hh, rr)"
      using prod.exhaust by metis
    have lt_2c: "?c + c_idx i < 2 * ?c" using c_idx_lt by linarith
    have not_lt_c: "¬ ?c + c_idx i < ?c" by simp
    have buf_lin_eq:
        "buf_lin_at (buf5 kk) (?c + c_idx i)
            = hh ((enum_class.enum :: 'c list) ! ((?c + c_idx i) - ?c))"
      using buf5_kk not_lt_c lt_2c
      unfolding buf_lin_at_def Let_def by simp
    have sub_simp: "(?c + c_idx i) - ?c = c_idx i" by simp
    have enum_at_idx:
        "(enum_class.enum :: 'c list) ! c_idx i = i"
      by (rule c_idx_in_range(2))
    show "mt_tape cM_k kk (Suc (c_idx i)) = (fst (snd (buf5 kk))) i"
      using buf_eq buf_lin_eq sub_simp enum_at_idx buf5_kk by simp
  qed

  have tape_cM_k_at_two_for_pos1:
      "⋀kk i. kk < k_tm M ⟹ mt_pos c' kk = 1
              ⟹ mt_tape cM_k kk (Suc (?c + c_idx (i :: 'c)))
                    = (snd (snd (buf5 kk))) i"
  proof -
    fix kk
    fix i :: 'c
    assume kklt: "kk < k_tm M"
    assume pos_kk: "mt_pos c' kk = 1"
    have c_idx_lt: "c_idx i < ?c" by (rule c_idx_lt_card)
    have addr_lt_2c: "?c + c_idx i < 2 * ?c" using c_idx_lt by linarith
    have wi: "ae_window_invariant_general
                (mt_tape cM_k kk) (mt_pos cM_k kk)
                (dest5 kk, ofs5 kk) (buf5 kk)
                (mt_pos c' kk) (le_tm M)"
      using cM_k_window_general[rule_format, OF kklt] by simp
    hence win_le1: "ae_window_invariant_le1
              (mt_tape cM_k kk) (mt_pos cM_k kk)
              (dest5 kk, ofs5 kk) (buf5 kk) (le_tm M)"
      using pos_kk unfolding ae_window_invariant_general_def by simp
    have buf_eq:
        "mt_tape cM_k kk (Suc (?c + c_idx i))
            = buf_lin_at (buf5 kk) (?c + (?c + c_idx i))"
      using win_le1 addr_lt_2c unfolding ae_window_invariant_le1_def by blast
    obtain ll hh rr where buf5_kk: "buf5 kk = (ll, hh, rr)"
      using prod.exhaust by metis
    have addr_eq: "?c + (?c + c_idx i) = 2 * ?c + c_idx i" by simp
    have not_lt_c: "¬ 2 * ?c + c_idx i < ?c" by simp
    have not_lt_2c: "¬ 2 * ?c + c_idx i < 2 * ?c" by simp
    have buf_lin_eq:
        "buf_lin_at (buf5 kk) (2 * ?c + c_idx i)
            = rr ((enum_class.enum :: 'c list) ! ((2 * ?c + c_idx i) - 2 * ?c))"
      using buf5_kk not_lt_c not_lt_2c
      unfolding buf_lin_at_def Let_def by simp
    have sub_simp: "(2 * ?c + c_idx i) - 2 * ?c = c_idx i" by simp
    have enum_at_idx:
        "(enum_class.enum :: 'c list) ! c_idx i = i"
      by (rule c_idx_in_range(2))
    show "mt_tape cM_k kk (Suc (?c + c_idx i)) = (snd (snd (buf5 kk))) i"
      using buf_eq addr_eq buf_lin_eq sub_simp enum_at_idx buf5_kk by simp
  qed

  have tape_cM_k_at_pos_minus_1_for_pos_ge2:
      "⋀kk i. kk < k_tm M ⟹ mt_pos c' kk ≥ 2
              ⟹ mt_tape cM_k kk ((mt_pos c' kk - 2) * ?c
                                    + c_idx (i :: 'c) + 1)
                    = (fst (buf5 kk)) i"
  proof -
    fix kk
    fix i :: 'c
    assume kklt: "kk < k_tm M"
    assume hge2: "mt_pos c' kk ≥ 2"
    have c_idx_lt: "c_idx i < ?c" by (rule c_idx_lt_card)
    have c_idx_lt_3c: "c_idx i < 3 * ?c" using c_idx_lt by linarith
    have wi: "ae_window_invariant_general
                (mt_tape cM_k kk) (mt_pos cM_k kk)
                (dest5 kk, ofs5 kk) (buf5 kk)
                (mt_pos c' kk) (le_tm M)"
      using cM_k_window_general[rule_format, OF kklt] by simp
    hence win_steady:
        "ae_window_invariant (mt_tape cM_k kk) (mt_pos cM_k kk)
            (dest5 kk, ofs5 kk) (buf5 kk)
            ((mt_pos c' kk - 2) * ?c + 1)"
      using hge2 unfolding ae_window_invariant_general_def by simp
    have buf_eq:
        "mt_tape cM_k kk (((mt_pos c' kk - 2) * ?c + 1) + c_idx i)
            = buf_lin_at (buf5 kk) (c_idx i)"
      using win_steady c_idx_lt_3c
      unfolding ae_window_invariant_def by blast
    have addr_simp:
        "((mt_pos c' kk - 2) * ?c + 1) + c_idx i
          = (mt_pos c' kk - 2) * ?c + c_idx i + 1" by simp
    obtain ll hh rr where buf5_kk: "buf5 kk = (ll, hh, rr)"
      using prod.exhaust by metis
    have buf_lin_eq:
        "buf_lin_at (buf5 kk) (c_idx i)
            = ll ((enum_class.enum :: 'c list) ! c_idx i)"
      using buf5_kk c_idx_lt unfolding buf_lin_at_def Let_def by simp
    have enum_at_idx:
        "(enum_class.enum :: 'c list) ! c_idx i = i"
      by (rule c_idx_in_range(2))
    show "mt_tape cM_k kk ((mt_pos c' kk - 2) * ?c + c_idx i + 1)
            = (fst (buf5 kk)) i"
      using buf_eq addr_simp buf_lin_eq enum_at_idx buf5_kk by simp
  qed

  have tape_cM_k_at_pos_for_pos_ge2:
      "⋀kk i. kk < k_tm M ⟹ mt_pos c' kk ≥ 2
              ⟹ mt_tape cM_k kk ((mt_pos c' kk - 1) * ?c
                                    + c_idx (i :: 'c) + 1)
                    = (fst (snd (buf5 kk))) i"
  proof -
    fix kk
    fix i :: 'c
    assume kklt: "kk < k_tm M"
    assume hge2: "mt_pos c' kk ≥ 2"
    have c_idx_lt: "c_idx i < ?c" by (rule c_idx_lt_card)
    have addr_lt_3c: "?c + c_idx i < 3 * ?c" using c_idx_lt by linarith
    have wi: "ae_window_invariant_general
                (mt_tape cM_k kk) (mt_pos cM_k kk)
                (dest5 kk, ofs5 kk) (buf5 kk)
                (mt_pos c' kk) (le_tm M)"
      using cM_k_window_general[rule_format, OF kklt] by simp
    hence win_steady:
        "ae_window_invariant (mt_tape cM_k kk) (mt_pos cM_k kk)
            (dest5 kk, ofs5 kk) (buf5 kk)
            ((mt_pos c' kk - 2) * ?c + 1)"
      using hge2 unfolding ae_window_invariant_general_def by simp
    have buf_eq:
        "mt_tape cM_k kk (((mt_pos c' kk - 2) * ?c + 1) + (?c + c_idx i))
            = buf_lin_at (buf5 kk) (?c + c_idx i)"
      using win_steady addr_lt_3c
      unfolding ae_window_invariant_def by blast
    have addr_simp:
        "((mt_pos c' kk - 2) * ?c + 1) + (?c + c_idx i)
          = (mt_pos c' kk - 1) * ?c + c_idx i + 1"
      using hge2 by (simp add: algebra_simps diff_mult_distrib)
    have buf_eq_rewritten:
        "mt_tape cM_k kk ((mt_pos c' kk - 1) * ?c + c_idx i + 1)
            = buf_lin_at (buf5 kk) (?c + c_idx i)"
      using buf_eq[unfolded addr_simp] .
    obtain ll hh rr where buf5_kk: "buf5 kk = (ll, hh, rr)"
      using prod.exhaust by metis
    have not_lt_c: "¬ ?c + c_idx i < ?c" by simp
    have lt_2c: "?c + c_idx i < 2 * ?c" using c_idx_lt by linarith
    have buf_lin_eq:
        "buf_lin_at (buf5 kk) (?c + c_idx i)
            = hh ((enum_class.enum :: 'c list) ! ((?c + c_idx i) - ?c))"
      using buf5_kk not_lt_c lt_2c
      unfolding buf_lin_at_def Let_def by simp
    have sub_simp: "(?c + c_idx i) - ?c = c_idx i" by simp
    have enum_at_idx:
        "(enum_class.enum :: 'c list) ! c_idx i = i"
      by (rule c_idx_in_range(2))
    show "mt_tape cM_k kk ((mt_pos c' kk - 1) * ?c + c_idx i + 1)
            = (fst (snd (buf5 kk))) i"
      using buf_eq_rewritten buf_lin_eq sub_simp enum_at_idx buf5_kk by simp
  qed

  have tape_cM_k_at_pos_plus_1_for_pos_ge2:
      "⋀kk i. kk < k_tm M ⟹ mt_pos c' kk ≥ 2
              ⟹ mt_tape cM_k kk (mt_pos c' kk * ?c
                                    + c_idx (i :: 'c) + 1)
                    = (snd (snd (buf5 kk))) i"
  proof -
    fix kk
    fix i :: 'c
    assume kklt: "kk < k_tm M"
    assume hge2: "mt_pos c' kk ≥ 2"
    have c_idx_lt: "c_idx i < ?c" by (rule c_idx_lt_card)
    have addr_lt_3c: "2 * ?c + c_idx i < 3 * ?c" using c_idx_lt by linarith
    have wi: "ae_window_invariant_general
                (mt_tape cM_k kk) (mt_pos cM_k kk)
                (dest5 kk, ofs5 kk) (buf5 kk)
                (mt_pos c' kk) (le_tm M)"
      using cM_k_window_general[rule_format, OF kklt] by simp
    hence win_steady:
        "ae_window_invariant (mt_tape cM_k kk) (mt_pos cM_k kk)
            (dest5 kk, ofs5 kk) (buf5 kk)
            ((mt_pos c' kk - 2) * ?c + 1)"
      using hge2 unfolding ae_window_invariant_general_def by simp
    have buf_eq:
        "mt_tape cM_k kk (((mt_pos c' kk - 2) * ?c + 1) + (2 * ?c + c_idx i))
            = buf_lin_at (buf5 kk) (2 * ?c + c_idx i)"
      using win_steady addr_lt_3c
      unfolding ae_window_invariant_def by blast
    have addr_simp:
        "((mt_pos c' kk - 2) * ?c + 1) + (2 * ?c + c_idx i)
          = mt_pos c' kk * ?c + c_idx i + 1"
      using hge2 by (simp add: algebra_simps diff_mult_distrib)
    have buf_eq_rewritten:
        "mt_tape cM_k kk (mt_pos c' kk * ?c + c_idx i + 1)
            = buf_lin_at (buf5 kk) (2 * ?c + c_idx i)"
      using buf_eq[unfolded addr_simp] .
    obtain ll hh rr where buf5_kk: "buf5 kk = (ll, hh, rr)"
      using prod.exhaust by metis
    have not_lt_c: "¬ 2 * ?c + c_idx i < ?c" by simp
    have not_lt_2c: "¬ 2 * ?c + c_idx i < 2 * ?c" by simp
    have buf_lin_eq:
        "buf_lin_at (buf5 kk) (2 * ?c + c_idx i)
            = rr ((enum_class.enum :: 'c list) ! ((2 * ?c + c_idx i) - 2 * ?c))"
      using buf5_kk not_lt_c not_lt_2c
      unfolding buf_lin_at_def Let_def by simp
    have sub_simp: "(2 * ?c + c_idx i) - 2 * ?c = c_idx i" by simp
    have enum_at_idx:
        "(enum_class.enum :: 'c list) ! c_idx i = i"
      by (rule c_idx_in_range(2))
    show "mt_tape cM_k kk (mt_pos c' kk * ?c + c_idx i + 1)
            = (snd (snd (buf5 kk))) i"
      using buf_eq_rewritten buf_lin_eq sub_simp enum_at_idx buf5_kk by simp
  qed

  ― ‹Sub-step 6b-assemble: per-tape regime-aware
      ‹ae_tape_correspondence› between ‹cM_k› and ‹c8›.
      Per-tape branches on ‹mt_pos c' kk›; within each regime,
      per-block branches on ‹s› match an in-window value
      (buf-lin transfer + c8 in-window value coincide on buf5 slot)
      or an off-window value (‹cM_k = cM = c'› M-side via
      ‹m_tape_off_window› + ‹tape_corr›; ‹c8 = c'› M'-side via
      ‹c8_tape_off_window›).  Extracted to ‹ae_fwd_tape_corr_c8›.›
  have tape_corr_c8:
      "∀kk<k_tm M. ae_tape_correspondence (le_tm M)
              (mt_tape cM_k kk) (mt_tape c8 kk)"
    by (rule ae_fwd_tape_corr_c8[OF tape_corr c_ge_1 c4_pos c5_pos_for_pos1
          c5_pos_for_pos1_dest_left c7_pos_for_pos1_dest_left cM_k_zero
          m_tape_off_window_le0 m_tape_off_window_le1 m_tape_off_window_steady
          c5_pos_for_pos0 c5_pos_for_pos_ge2 c5_pos_for_pos_ge2_dest_left
          c6_pos_for_pos0 c6_pos_for_pos_ge2 c7_pos_for_pos0 c7_pos_for_pos_ge2
          c6_pos_for_pos1 c7_pos_for_pos1 c8_tape_off_window
          c8_tape_at_one_for_pos0 c8_tape_at_one_for_pos1 c8_tape_at_two_for_pos1
          c8_tape_at_pos_for_pos_ge2 c8_tape_at_pos_minus_1_for_pos_ge2
          c8_tape_at_pos_plus_1_for_pos_ge2 tape_cM_k_at_one_for_pos0
          tape_cM_k_at_one_for_pos1 tape_cM_k_at_two_for_pos1
          tape_cM_k_at_pos_minus_1_for_pos_ge2 tape_cM_k_at_pos_for_pos_ge2
          tape_cM_k_at_pos_plus_1_for_pos_ge2])
  ― ‹Sub-step 6c: position decode at ‹c8›.  Per-tape regime
      case-split on ‹mt_pos c' kk›, then per-dest case-split.
      The ‹idx = SS1› antecedent excludes the halt branch
      (which lands at ‹init_stage› = VFwd).  Extracted to
      ‹ae_fwd_pos_decode_c8›.›
  have pos_decode_c8:
      "(case mt_state c8 of (_, _, _, _, idx) ⇒ idx = SS1)
        ⟶ (∀k<k_tm M. mt_pos cM_k k
                  = ae_decode_pos (mt_pos c8 k)
                      (case mt_state c8 of (_, off, _, _, _) ⇒ off k))"
    by (rule ae_fwd_pos_decode_c8[OF ofs6_eq_ofs5 c8_state cM_k_window_general
          c8_pos_for_pos0 c8_pos_for_pos_ge2 c8_pos_for_pos1])
  ― ‹Sub-step 6f: final assembly via ‹rule that›.  The four
      obligations of the ‹obtains›: chain composition (‹chain8›),
      ‹ae_simulates M cM_k c8› (the four per-conjunct facts
      ‹conj_i›, ‹conj_ii›, ‹tape_corr_c8›,
      ‹pos_decode_c8›, plus gamma and buf-gamma side-bands),
      ‹ae_buffer_in_gamma_block M c8›, and ‹c8› cell 0 is
      ‹LE_block›.›
  ― ‹SS5 exposure (det-free reverse arm): the SS5 state in
      ‹(q_out, ofs, buf, dest)› form (‹q_out = mt_state cM_k› via
      ‹c4_q_out›) and the window correspondence in ‹(dest, ofs)›
      bp form (from ‹c4_window_general› under ‹c4_state›).›
  have q5_eq: "q5 = mt_state cM_k"
    using c4_q_out c4_state by simp
  have c4f_state_exp: "mt_state c4 = (mt_state cM_k, ofs5, buf5, dest5, SS5)"
    using c4_state q5_eq by simp
  have fwd_window_exp:
      "∀kk<k_tm M. ae_window_invariant_general
              (mt_tape cM_k kk) (mt_pos cM_k kk)
              (dest5 kk, ofs5 kk) (buf5 kk) (mt_pos c' kk) (le_tm M)"
    using c4_window_general c4_state by simp

  obtain qq8 ofs8 buf8 dest8 idx8 where
      c8_full: "mt_state c8 = (qq8, ofs8, buf8, dest8, idx8)"
    by (cases "mt_state c8") auto
  have conj_i:
      "(idx8 = SS1 ∧ qq8 ∉ {t_tm M, r_tm M})
        ∨ (qq8 ∈ {t_tm M, r_tm M}
             ∧ (ofs8, buf8, dest8, idx8) = init_stage (le_tm M))"
    using sim_i_c8 c8_full by simp
  have conj_ii: "mt_state cM_k = qq8"
    using sim_ii_c8 c8_full by simp
  have conj_iv:
      "idx8 = SS1
        ⟶ (∀k<k_tm M. mt_pos cM_k k = ae_decode_pos (mt_pos c8 k) (ofs8 k))"
    using pos_decode_c8 c8_full by simp
  have sim_c8: "ae_simulates M cM_k c8"
    unfolding ae_simulates_def
    using conj_i conj_ii conj_iv tape_corr_c8 gamma_c8 c8_full
    by simp

  show ?thesis
    by (rule that[OF chain8 sim_c8 buf_gamma_c8 tape_c8_zero_le
                     step1_sub step2_sub step3_sub step4_sub
                     step5_sub step6_sub step7_sub step8_sub
                     c4f_state_exp fwd_window_exp buf_gamma_c4])
qed

end