AFTD Auto-Formalizing Theoretical Domains

op869_spliced_colors_update

theoremverified

Updating a local vertex coloring exactly matches updating the embedded vertex on the larger board.

Statement

theorem op869_spliced_colors_update {n m : ℕ} (offset : ℕ) (h : offset+n ≤ m)
    (base : Fin m → Finset ℕ) (C : Fin n → Finset ℕ) (i : Fin n) (colors : Finset ℕ) :
    op869_splice_colors offset h base (Function.update C i colors) =
      Function.update (op869_splice_colors offset h base C) (op869_offset_emb offset h i) colors
Source
AFTD formalization of arXiv:2610.41516, Lemma 2.5
Verified
18 Nov 2026
Axioms
Classical.choiceQuot.soundpropext
Built on 3
  • op869_graph_from_predecessorsThe simple graph on the ordered vertices Fin n whose edge from an earlier vertex a to a later vertex b exists exactly when a is in the…
  • TotalPreorderA total preorder: a preorder where ≤ is total (complete). This is weaker than LinearOrder — it does NOT require antisymmetry or…
  • LinearOrder.toTotalPreorderEvery LinearOrder is a TotalPreorder.
Used by 3
  • op869_disjoint_splice_bipartitionTwo bipartite graphs on disjoint board regions admit a combined bipartition that preserves both chosen side assignments.
  • op869_disjoint_interval_game_liftA local k-colorable online strategy can be played on a fresh disconnected interval after any k-colorable earlier graph, without changing…
  • op869_board_two_copies_amplifyOn the actual finite board, after two disjoint bipartite copies and a new vertex joined to the first designated side, one can orient the…

The proof, explained

The module embeds a gadget of size n into a larger board of size m at a given offset. The main theorem, op869_spliced_colors_update, proves that updating the local vertex coloring at index i coincides with updating the spliced coloring at the embedded vertex emb(i). By functional extensionality, the proof checks both sides at an arbitrary vertex x: at emb(i), both evaluate to the updated color set; away from emb(i), vertices inside the gadget correspond to local indices distinct from i (leaving their colors unaffected), while vertices outside remain fixed at the base board coloring.

  1. The offset mapping defines an order-preserving embedding of Fin n into Fin m.

    Each index x is mapped to offset + x, which is strictly less than m because offset + n ≤ m. For injectivity, if offset + x = offset + y, taking values via congrArg and applying Fin.ext shows x = y.

    lines 1–9

    uses Fin.ext, congrArg

    def op869_offset_emb {n m : ℕ} (offset : ℕ) (h : offset+n ≤ m) : Fin n ↪ Fin m where
      toFun x := ⟨offset+x.val, by omega⟩
      inj' := by
        intro x y he
        apply Fin.ext
        have hv := congrArg Fin.val he
        simp only at hv
        omega
    
  2. Definition of the spliced predecessor function op869_splice_preds.

    Vertices in the interval [offset, offset + n) receive the union of their external predecessors and the embedded image of their local predecessors under P; vertices outside this interval retain their predecessors from base.

    lines 10–17

    def op869_splice_preds {n m : ℕ} (offset : ℕ) (h : offset+n ≤ m)
        (base : Fin m → Finset (Fin m)) (ext : Fin n → Finset (Fin m))
        (P : Fin n → Finset (Fin n)) (x : Fin m) : Finset (Fin m) :=
      if hx : offset ≤ x.val ∧ x.val < offset+n then
        let a : Fin n := ⟨x.val-offset, by omega⟩
        ext a ∪ (P a).map (op869_offset_emb offset h)
      else base x
    
  3. Evaluating the spliced predecessors at an embedded vertex yields its spliced predecessors.

    Since offset ≤ offset + a < offset + n, unfolding op869_splice_preds and taking the then-branch with dif_pos simplifies the shifted index to a via Fin.ext.

    lines 18–37

    uses dif_pos, Fin.ext

    lemma op869_splice_preds_at {n m : ℕ} (offset : ℕ) (h : offset+n ≤ m)
        (base : Fin m → Finset (Fin m)) (ext : Fin n → Finset (Fin m))
        (P : Fin n → Finset (Fin n)) (a : Fin n) :
        op869_splice_preds offset h base ext P (op869_offset_emb offset h a) =
          ext a ∪ (P a).map (op869_offset_emb offset h) := by
      classical
      unfold op869_splice_preds
      have ha : offset ≤ (op869_offset_emb offset h a).val ∧
          (op869_offset_emb offset h a).val < offset+n := by
        change offset ≤ offset+a.val ∧ offset+a.val < offset+n
        omega
      simp only [dif_pos ha]
      have heq : (⟨(op869_offset_emb offset h a).val - offset, by
          change offset+a.val-offset < n
          omega⟩ : Fin n) = a := by
        apply Fin.ext
        change offset+a.val-offset = a.val
        omega
      rw [heq]
    
  4. The induced subgraph on the embedded block is isomorphic to the local predecessor graph P.

    For any local vertices a and b, adjacency in the spliced graph reduces via op869_splice_preds_at to checking membership in ext(b) ∪ map(emb, P b). Because external predecessors are strictly before offset, the embedded vertex cannot lie in ext(b), so false_or simplifies the condition to local predecessor membership.

    lines 38–73

    uses op869_splice_preds_at, Finset.mem_union, Finset.mem_map, false_or

    theorem op869_spliced_block_induced_graph {n m : ℕ} (offset : ℕ) (h : offset+n ≤ m)
        (base : Fin m → Finset (Fin m)) (ext : Fin n → Finset (Fin m))
        (P : Fin n → Finset (Fin n))
        (hexternal : ∀ a x, x ∈ ext a → x.val < offset) :
        ∀ a b, (op869_graph_from_predecessors (op869_splice_preds offset h base ext P)).Adj
          (op869_offset_emb offset h a) (op869_offset_emb offset h b) ↔
          (op869_graph_from_predecessors P).Adj a b := by
      classical
      intro a b
      have hmem (a b : Fin n) :
          op869_offset_emb offset h a ∈
            op869_splice_preds offset h base ext P (op869_offset_emb offset h b) ↔ a ∈ P b := by
        rw [op869_splice_preds_at]
        simp only [Finset.mem_union, Finset.mem_map]
        have hn : op869_offset_emb offset h a ∉ ext b := by
          intro ha
          have hx := hexternal b _ ha
          change offset+a.val < offset at hx
          omega
        simp only [hn, false_or]
        constructor
        · rintro ⟨x,hx,he⟩
          have hxa : x = a := (op869_offset_emb offset h).injective he
          simpa [hxa] using hx
        · intro ha
          exact ⟨a,ha,rfl⟩
      have hlt (a b : Fin n) : op869_offset_emb offset h a < op869_offset_emb offset h b ↔ a < b := by
        change offset+a.val < offset+b.val ↔ a.val < b.val
        omega
      change ((op869_offset_emb offset h a < op869_offset_emb offset h b ∧
          op869_offset_emb offset h a ∈ op869_splice_preds offset h base ext P (op869_offset_emb offset h b)) ∨
        (op869_offset_emb offset h b < op869_offset_emb offset h a ∧
          op869_offset_emb offset h b ∈ op869_splice_preds offset h base ext P (op869_offset_emb offset h a))) ↔
        ((a < b ∧ a ∈ P b) ∨ (b < a ∧ b ∈ P a))
      rw [hlt, hlt, hmem, hmem]
    
  5. Updating local predecessors at i corresponds to updating spliced predecessors at emb(i).

    By extensionality, if x = emb(i), both sides simplify to the updated predecessor set via Function.update_self and op869_splice_preds_at. If x ≠ emb(i), Function.update_of_ne applies, and within the gadget block the shifted index a ≠ i (proved using congrArg and Fin.ext), leaving local predecessors unchanged.

    lines 74–101

    uses Function.update_self, op869_splice_preds_at, Function.update_of_ne, Fin.ext, congrArg

    theorem op869_spliced_predecessors_update {n m : ℕ} (offset : ℕ) (h : offset+n ≤ m)
        (base : Fin m → Finset (Fin m)) (ext : Fin n → Finset (Fin m))
        (P : Fin n → Finset (Fin n)) (i : Fin n) (T : Finset (Fin m)) (S : Finset (Fin n)) :
        op869_splice_preds offset h base (Function.update ext i T) (Function.update P i S) =
          Function.update (op869_splice_preds offset h base ext P) (op869_offset_emb offset h i)
            (T ∪ S.map (op869_offset_emb offset h)) := by
      classical
      funext x
      by_cases hx : x = op869_offset_emb offset h i
      · subst x
        simp only [Function.update_self, op869_splice_preds_at]
      · rw [Function.update_of_ne hx]
        unfold op869_splice_preds
        split_ifs with hrange
        · let a : Fin n := ⟨x.val-offset, by omega⟩
          have hai : a ≠ i := by
            intro heq
            apply hx
            apply Fin.ext
            have hv := congrArg Fin.val heq
            change x.val-offset = i.val at hv
            change x.val = offset+i.val
            omega
          change (Function.update ext i T a) ∪ (Function.update P i S a).map (op869_offset_emb offset h) =
            ext a ∪ (P a).map (op869_offset_emb offset h)
          simp [Function.update_of_ne hai]
        · rfl
    
  6. Outside the gadget interval, spliced predecessors coincide with the base graph.

    For vertices strictly before offset or at least offset + n, the interval condition is false, so unfolding op869_splice_preds evaluates definitionally to base x.

    lines 102–111

    theorem op869_spliced_predecessors_outside {n m : ℕ} (offset : ℕ) (h : offset+n ≤ m)
        (base : Fin m → Finset (Fin m)) (ext : Fin n → Finset (Fin m))
        (P : Fin n → Finset (Fin n)) (x : Fin m)
        (hx : x.val < offset ∨ offset+n ≤ x.val) :
        op869_splice_preds offset h base ext P x = base x := by
      unfold op869_splice_preds
      split_ifs with hr
      · omega
      · rfl
    
  7. An earlier vertex x < offset is adjacent to an embedded vertex emb(a) if and only if x ∈ ext(a).

    Since x < offset ≤ offset + a, the edge orientation must be x < emb(a). Furthermore, x cannot belong to the embedded image of local predecessors because all embedded vertices are at least offset. Applying op869_splice_preds_at isolates the condition x ∈ ext(a).

    lines 112–134

    uses not_lt_of_ge, le_of_lt, op869_splice_preds_at

    theorem op869_spliced_earlier_edges {n m : ℕ} (offset : ℕ) (h : offset+n ≤ m)
        (base : Fin m → Finset (Fin m)) (ext : Fin n → Finset (Fin m))
        (P : Fin n → Finset (Fin n)) (x : Fin m) (a : Fin n) (hx : x.val < offset) :
        (op869_graph_from_predecessors (op869_splice_preds offset h base ext P)).Adj
          x (op869_offset_emb offset h a) ↔ x ∈ ext a := by
      classical
      have hlt : x < op869_offset_emb offset h a := by
        change x.val < offset+a.val
        omega
      have hmap : x ∉ (P a).map (op869_offset_emb offset h) := by
        intro hm
        obtain ⟨y,hy,he⟩ := Finset.mem_map.mp hm
        have heq := congrArg Fin.val he
        change offset+y.val = x.val at heq
        omega
      change ((x < op869_offset_emb offset h a ∧
          x ∈ op869_splice_preds offset h base ext P (op869_offset_emb offset h a)) ∨
        (op869_offset_emb offset h a < x ∧
          op869_offset_emb offset h a ∈ op869_splice_preds offset h base ext P x)) ↔ x ∈ ext a
      simp only [hlt, not_lt_of_ge (le_of_lt hlt), false_and, or_false, true_and]
      rw [op869_splice_preds_at]
      simp [hmap]
    
  8. Definition of the spliced coloring op869_splice_colors.

    Vertices in [offset, offset + n) receive the local color set C(x - offset), while vertices outside receive base x.

    lines 135–138

    def op869_splice_colors {n m : ℕ} (offset : ℕ) (h : offset+n ≤ m)
        (base : Fin m → Finset ℕ) (C : Fin n → Finset ℕ) (x : Fin m) : Finset ℕ :=
      if hx : offset ≤ x.val ∧ x.val < offset+n then C ⟨x.val-offset, by omega⟩ else base x
    
  9. Evaluating the spliced coloring at an embedded vertex emb(a) yields C(a).

    The embedded vertex offset + a lies in the gadget interval, so unfolding op869_splice_colors and selecting the then-branch with dif_pos reduces the index to a via Fin.ext.

    lines 139–158

    uses dif_pos, Fin.ext

    lemma op869_splice_colors_at {n m : ℕ} (offset : ℕ) (h : offset+n ≤ m)
        (base : Fin m → Finset ℕ) (C : Fin n → Finset ℕ) (a : Fin n) :
        op869_splice_colors offset h base C (op869_offset_emb offset h a) = C a := by
      classical
      unfold op869_splice_colors
      have ha : offset ≤ (op869_offset_emb offset h a).val ∧
          (op869_offset_emb offset h a).val < offset+n := by
        change offset ≤ offset+a.val ∧ offset+a.val < offset+n
        omega
      simp only [dif_pos ha]
      have heq : (⟨(op869_offset_emb offset h a).val - offset, by
          change offset+a.val-offset < n
          omega⟩ : Fin n) = a := by
        apply Fin.ext
        change offset+a.val-offset = a.val
        omega
      rw [heq]
    
    
    
  10. The prefix palette of the gadget is contained in the prefix palette of the spliced board.

    Every local vertex a < i embeds into a vertex emb(a) < offset + i, and by op869_splice_colors_at the colors at emb(a) match C(a). Hence the union over gadget vertices is contained in the union over the board prefix.

    lines 159–174

    uses Finset.mem_filter, Finset.mem_univ, op869_splice_colors_at

    theorem op869_spliced_prefix_palette_contains {n m : ℕ} (offset : ℕ) (h : offset+n ≤ m)
        (base : Fin m → Finset ℕ) (C : Fin n → Finset ℕ) (i : ℕ) :
        ((Finset.univ.filter (fun a : Fin n => a.val < i)).biUnion C) ⊆
          ((Finset.univ.filter (fun x : Fin m => x.val < offset+i)).biUnion
            (op869_splice_colors offset h base C)) := by
      classical
      intro c hc
      obtain ⟨a, ha, hca⟩ := Finset.mem_biUnion.mp hc
      have hai : a.val < i := (Finset.mem_filter.mp ha).2
      apply Finset.mem_biUnion.mpr
      refine ⟨op869_offset_emb offset h a, ?_, ?_⟩
      · simp only [Finset.mem_filter, Finset.mem_univ, true_and]
        change offset+a.val < offset+i
        omega
      · simpa [op869_splice_colors_at] using hca
    
  11. Disjointness of colors on the spliced graph transports to disjointness on the local gadget.

    For any local vertex a ∈ S, the embedded vertex emb(a) belongs to T ∪ map(emb, S) via Finset.mem_union_right. The hypothesis gives disjointness at emb(a), which translates to disjointness for C(a) using op869_splice_colors_at.

    lines 175–185

    uses Finset.mem_union_right, op869_splice_colors_at

    theorem op869_spliced_valid_response {n m : ℕ} (offset : ℕ) (h : offset+n ≤ m)
        (base : Fin m → Finset ℕ) (C : Fin n → Finset ℕ)
        (S : Finset (Fin n)) (T : Finset (Fin m)) (colors : Finset ℕ)
        (hvalid : ∀ x ∈ T ∪ S.map (op869_offset_emb offset h),
          Disjoint (op869_splice_colors offset h base C x) colors) :
        ∀ a ∈ S, Disjoint (C a) colors := by
      intro a ha
      have hx : op869_offset_emb offset h a ∈ T ∪ S.map (op869_offset_emb offset h) :=
        Finset.mem_union_right T (Finset.mem_map.mpr ⟨a,ha,rfl⟩)
      simpa [op869_splice_colors_at] using hvalid (op869_offset_emb offset h a) hx
    
  12. The union of spliced colors over the embedded image of A equals the union of C over A.

    By extensionality on colors, a color belongs to the spliced union over map(emb, A) if and only if it belongs to the spliced coloring at emb(a) for some a ∈ A. Using op869_splice_colors_at, this is equivalent to belonging to C(a).

    lines 186–199

    uses Finset.mem_biUnion, Finset.mem_map, op869_splice_colors_at

    theorem op869_spliced_colors_biUnion {n m : ℕ} (offset : ℕ) (h : offset+n ≤ m)
        (base : Fin m → Finset ℕ) (C : Fin n → Finset ℕ) (A : Finset (Fin n)) :
        ((A.map (op869_offset_emb offset h)).biUnion (op869_splice_colors offset h base C)) =
          A.biUnion C := by
      classical
      ext c
      simp only [Finset.mem_biUnion, Finset.mem_map]
      constructor
      · rintro ⟨_, ⟨a, ha, rfl⟩, hc⟩
        exact ⟨a, ha, by simpa [op869_splice_colors_at] using hc⟩
      · rintro ⟨a, ha, hc⟩
        exact ⟨op869_offset_emb offset h a, ⟨a, ha, rfl⟩,
          by simpa [op869_splice_colors_at] using hc⟩
    
  13. Spliced predecessors for vertices beyond offset + i are empty when future base and local predecessors are empty.

    For x ≥ offset + i, if x falls in the gadget block, its local index a satisfies a ≥ i, so P(a) = ∅. If x lies beyond the block, base x = ∅ by hypothesis. In both cases, the spliced predecessor set is empty.

    lines 200–216

    theorem op869_spliced_future_predecessors_empty {n m : ℕ} (offset : ℕ) (h : offset+n ≤ m)
        (base : Fin m → Finset (Fin m)) (P : Fin n → Finset (Fin n)) (i : ℕ)
        (hbase : ∀ x, offset ≤ x.val → base x = ∅)
        (hlocal : ∀ a, i ≤ a.val → P a = ∅) :
        ∀ x, offset+i ≤ x.val → op869_splice_preds offset h base (fun _ => ∅) P x = ∅ := by
      classical
      intro x hx
      unfold op869_splice_preds
      split_ifs with hrange
      · let a : Fin n := ⟨x.val-offset, by omega⟩
        have ha : i ≤ a.val := by dsimp [a]; omega
        change (∅ : Finset (Fin m)) ∪ (P a).map (op869_offset_emb offset h) = ∅
        rw [hlocal a ha]
        simp
      · exact hbase x (by omega)
    
    /-- Color updates and response transport for a spliced gadget interval. -/
  14. It suffices to verify that the updated spliced colorings agree at every vertex x.

    By functional extensionality (`funext`), two color assignments on Fin m are equal if and only if they assign identical color sets to every vertex x.

    lines 217–222

    theorem op869_spliced_colors_update {n m : ℕ} (offset : ℕ) (h : offset+n ≤ m)
        (base : Fin m → Finset ℕ) (C : Fin n → Finset ℕ) (i : Fin n) (colors : Finset ℕ) :
        op869_splice_colors offset h base (Function.update C i colors) =
          Function.update (op869_splice_colors offset h base C) (op869_offset_emb offset h i) colors := by
      classical
      funext x
  15. When x is the embedded vertex emb(i), both sides evaluate to colors.

    If x = emb(i), the right-hand side is an update at x evaluated at x, giving colors by Function.update_self. The left-hand side evaluates the spliced coloring of C[i ↦ colors] at emb(i), which by op869_splice_colors_at yields (C[i ↦ colors])(i) = colors, also by Function.update_self.

    lines 223–225

    uses Function.update_self, op869_splice_colors_at

      by_cases hx : x = op869_offset_emb offset h i
      · subst x
        simp only [Function.update_self, op869_splice_colors_at]
  16. When x ≠ emb(i), the right-hand side simplifies to the original spliced coloring, and we case-split on whether x lies in the gadget interval.

    Because x ≠ emb(i), rewriting with Function.update_of_ne removes the outer update on the right-hand side. Unfolding op869_splice_colors introduces a conditional on offset ≤ x < offset + n, which split_ifs branches into two cases.

    lines 226–228

    uses Function.update_of_ne

      · rw [Function.update_of_ne hx]
        unfold op869_splice_colors
        split_ifs with hrange
  17. Inside the gadget interval, the local vertex a = x - offset is distinct from i, so updating at i leaves C(a) unaffected.

    Let a = ⟨x - offset, …⟩ in Fin n. If a = i, applying congrArg with Fin.val yields x - offset = i, so x = offset + i = emb(i) by Fin.ext, contradicting x ≠ emb(i). Thus a ≠ i, and Function.update_of_ne ensures (C[i ↦ colors])(a) = C(a).

    lines 229–239

    uses Fin.ext, congrArg, Function.update_of_ne

        · let a : Fin n := ⟨x.val-offset, by omega⟩
          have hai : a ≠ i := by
            intro heq
            apply hx
            apply Fin.ext
            have hv := congrArg Fin.val heq
            change x.val-offset = i.val at hv
            change x.val = offset+i.val
            omega
          change Function.update C i colors a = C a
          exact Function.update_of_ne hai _ _
  18. Outside the gadget interval, both sides reduce to base x.

    When x is outside the gadget interval, the condition fails on both sides, so both evaluate definitionally to base x, closing the proof by reflexivity (rfl).

    line 240

        · rfl
congrArg
Applying a function to equal arguments yields equal results (if a₁ = a₂, then f a₁ = f a₂).
dif_pos
When the condition c holds, the dependent if-then-else expression simplifies to the then-branch.
false_or
Disjunction with False simplifies to the other disjunct (False ∨ p ↔ p).
Fin.ext
Two elements of Fin n are equal if and only if their underlying natural number values are equal.
Finset.mem_biUnion
An element belongs to a finset union over s if and only if it belongs to t a for some a ∈ s.
Finset.mem_filter
An element belongs to the filtered finset if and only if it belongs to the original finset and satisfies the predicate p.
Finset.mem_map
An element belongs to the image under an embedding f if and only if it is the image of some element in the domain finset.
Finset.mem_union
An element belongs to the union of two finsets if and only if it belongs to at least one of them.
Finset.mem_union_right
If an element belongs to t, then it belongs to the union s ∪ t.
Finset.mem_univ
Every element of a finite type belongs to its universal finset Finset.univ.
Function.update_of_ne
Evaluating an updated function Function.update f a' v at a point a distinct from a' yields the original value f a.
Function.update_self
Evaluating an updated function Function.update f a v at the modified point a yields the new value v.
le_of_lt
Strict inequality implies non-strict inequality (a < b → a ≤ b).
not_lt_of_ge
If a ≤ b, then b cannot be strictly less than a.
op869_splice_colors_at
Evaluating the spliced coloring at the embedded vertex op869_offset_emb offset h a yields the local color set C a.
op869_splice_preds_at
Evaluating the spliced predecessor function at the embedded vertex op869_offset_emb offset h a yields the union of external predecessors ext a and mapped local predecessors P a.

Written by a model (gemini-3.8-flash) from the Lean proof and the goal states Lean reported at each step. Lean verified the proof; this explanation is a reading aid and is not itself machine-checked.

Lean source view module on GitHub

def op869_offset_emb {n m : ℕ} (offset : ℕ) (h : offset+n ≤ m) : Fin n ↪ Fin m where  toFun x := ⟨offset+x.val, by omega⟩  inj' := by    intro x y he    apply Fin.ext    have hv := congrArg Fin.val he    simp only at hv    omegadef op869_splice_preds {n m : ℕ} (offset : ℕ) (h : offset+n ≤ m)    (base : Fin m → Finset (Fin m)) (ext : Fin n → Finset (Fin m))    (P : Fin n → Finset (Fin n)) (x : Fin m) : Finset (Fin m) :=  if hx : offset ≤ x.val ∧ x.val < offset+n then    let a : Fin n := ⟨x.val-offset, by omega⟩    ext a ∪ (P a).map (op869_offset_emb offset h)  else base xlemma op869_splice_preds_at {n m : ℕ} (offset : ℕ) (h : offset+n ≤ m)    (base : Fin m → Finset (Fin m)) (ext : Fin n → Finset (Fin m))    (P : Fin n → Finset (Fin n)) (a : Fin n) :    op869_splice_preds offset h base ext P (op869_offset_emb offset h a) =      ext a ∪ (P a).map (op869_offset_emb offset h) := by  classical  unfold op869_splice_preds  have ha : offset ≤ (op869_offset_emb offset h a).val ∧      (op869_offset_emb offset h a).val < offset+n := by    change offset ≤ offset+a.val ∧ offset+a.val < offset+n    omega  simp only [dif_pos ha]  have heq : (⟨(op869_offset_emb offset h a).val - offset, by      change offset+a.val-offset < n      omega⟩ : Fin n) = a := by    apply Fin.ext    change offset+a.val-offset = a.val    omega  rw [heq]theorem op869_spliced_block_induced_graph {n m : ℕ} (offset : ℕ) (h : offset+n ≤ m)    (base : Fin m → Finset (Fin m)) (ext : Fin n → Finset (Fin m))    (P : Fin n → Finset (Fin n))    (hexternal : ∀ a x, x ∈ ext a → x.val < offset) :    ∀ a b, (op869_graph_from_predecessors (op869_splice_preds offset h base ext P)).Adj      (op869_offset_emb offset h a) (op869_offset_emb offset h b) ↔      (op869_graph_from_predecessors P).Adj a b := by  classical  intro a b  have hmem (a b : Fin n) :      op869_offset_emb offset h a ∈        op869_splice_preds offset h base ext P (op869_offset_emb offset h b) ↔ a ∈ P b := by    rw [op869_splice_preds_at]    simp only [Finset.mem_union, Finset.mem_map]    have hn : op869_offset_emb offset h a ∉ ext b := by      intro ha      have hx := hexternal b _ ha      change offset+a.val < offset at hx      omega    simp only [hn, false_or]    constructor    · rintro ⟨x,hx,he⟩      have hxa : x = a := (op869_offset_emb offset h).injective he      simpa [hxa] using hx    · intro ha      exact ⟨a,ha,rfl⟩  have hlt (a b : Fin n) : op869_offset_emb offset h a < op869_offset_emb offset h b ↔ a < b := by    change offset+a.val < offset+b.val ↔ a.val < b.val    omega  change ((op869_offset_emb offset h a < op869_offset_emb offset h b ∧      op869_offset_emb offset h a ∈ op869_splice_preds offset h base ext P (op869_offset_emb offset h b)) ∨    (op869_offset_emb offset h b < op869_offset_emb offset h a ∧      op869_offset_emb offset h b ∈ op869_splice_preds offset h base ext P (op869_offset_emb offset h a))) ↔    ((a < b ∧ a ∈ P b) ∨ (b < a ∧ b ∈ P a))  rw [hlt, hlt, hmem, hmem]theorem op869_spliced_predecessors_update {n m : ℕ} (offset : ℕ) (h : offset+n ≤ m)    (base : Fin m → Finset (Fin m)) (ext : Fin n → Finset (Fin m))    (P : Fin n → Finset (Fin n)) (i : Fin n) (T : Finset (Fin m)) (S : Finset (Fin n)) :    op869_splice_preds offset h base (Function.update ext i T) (Function.update P i S) =      Function.update (op869_splice_preds offset h base ext P) (op869_offset_emb offset h i)        (T ∪ S.map (op869_offset_emb offset h)) := by  classical  funext x  by_cases hx : x = op869_offset_emb offset h i  · subst x    simp only [Function.update_self, op869_splice_preds_at]  · rw [Function.update_of_ne hx]    unfold op869_splice_preds    split_ifs with hrange    · let a : Fin n := ⟨x.val-offset, by omega⟩      have hai : a ≠ i := by        intro heq        apply hx        apply Fin.ext        have hv := congrArg Fin.val heq        change x.val-offset = i.val at hv        change x.val = offset+i.val        omega      change (Function.update ext i T a) ∪ (Function.update P i S a).map (op869_offset_emb offset h) =        ext a ∪ (P a).map (op869_offset_emb offset h)      simp [Function.update_of_ne hai]    · rfltheorem op869_spliced_predecessors_outside {n m : ℕ} (offset : ℕ) (h : offset+n ≤ m)    (base : Fin m → Finset (Fin m)) (ext : Fin n → Finset (Fin m))    (P : Fin n → Finset (Fin n)) (x : Fin m)    (hx : x.val < offset ∨ offset+n ≤ x.val) :    op869_splice_preds offset h base ext P x = base x := by  unfold op869_splice_preds  split_ifs with hr  · omega  · rfltheorem op869_spliced_earlier_edges {n m : ℕ} (offset : ℕ) (h : offset+n ≤ m)    (base : Fin m → Finset (Fin m)) (ext : Fin n → Finset (Fin m))    (P : Fin n → Finset (Fin n)) (x : Fin m) (a : Fin n) (hx : x.val < offset) :    (op869_graph_from_predecessors (op869_splice_preds offset h base ext P)).Adj      x (op869_offset_emb offset h a) ↔ x ∈ ext a := by  classical  have hlt : x < op869_offset_emb offset h a := by    change x.val < offset+a.val    omega  have hmap : x ∉ (P a).map (op869_offset_emb offset h) := by    intro hm    obtain ⟨y,hy,he⟩ := Finset.mem_map.mp hm    have heq := congrArg Fin.val he    change offset+y.val = x.val at heq    omega  change ((x < op869_offset_emb offset h a ∧      x ∈ op869_splice_preds offset h base ext P (op869_offset_emb offset h a)) ∨    (op869_offset_emb offset h a < x ∧      op869_offset_emb offset h a ∈ op869_splice_preds offset h base ext P x)) ↔ x ∈ ext a  simp only [hlt, not_lt_of_ge (le_of_lt hlt), false_and, or_false, true_and]  rw [op869_splice_preds_at]  simp [hmap]def op869_splice_colors {n m : ℕ} (offset : ℕ) (h : offset+n ≤ m)    (base : Fin m → Finset ℕ) (C : Fin n → Finset ℕ) (x : Fin m) : Finset ℕ :=  if hx : offset ≤ x.val ∧ x.val < offset+n then C ⟨x.val-offset, by omega⟩ else base xlemma op869_splice_colors_at {n m : ℕ} (offset : ℕ) (h : offset+n ≤ m)    (base : Fin m → Finset ℕ) (C : Fin n → Finset ℕ) (a : Fin n) :    op869_splice_colors offset h base C (op869_offset_emb offset h a) = C a := by  classical  unfold op869_splice_colors  have ha : offset ≤ (op869_offset_emb offset h a).val ∧      (op869_offset_emb offset h a).val < offset+n := by    change offset ≤ offset+a.val ∧ offset+a.val < offset+n    omega  simp only [dif_pos ha]  have heq : (⟨(op869_offset_emb offset h a).val - offset, by      change offset+a.val-offset < n      omega⟩ : Fin n) = a := by    apply Fin.ext    change offset+a.val-offset = a.val    omega  rw [heq]theorem op869_spliced_prefix_palette_contains {n m : ℕ} (offset : ℕ) (h : offset+n ≤ m)    (base : Fin m → Finset ℕ) (C : Fin n → Finset ℕ) (i : ℕ) :    ((Finset.univ.filter (fun a : Fin n => a.val < i)).biUnion C) ⊆      ((Finset.univ.filter (fun x : Fin m => x.val < offset+i)).biUnion        (op869_splice_colors offset h base C)) := by  classical  intro c hc  obtain ⟨a, ha, hca⟩ := Finset.mem_biUnion.mp hc  have hai : a.val < i := (Finset.mem_filter.mp ha).2  apply Finset.mem_biUnion.mpr  refine ⟨op869_offset_emb offset h a, ?_, ?_⟩  · simp only [Finset.mem_filter, Finset.mem_univ, true_and]    change offset+a.val < offset+i    omega  · simpa [op869_splice_colors_at] using hcatheorem op869_spliced_valid_response {n m : ℕ} (offset : ℕ) (h : offset+n ≤ m)    (base : Fin m → Finset ℕ) (C : Fin n → Finset ℕ)    (S : Finset (Fin n)) (T : Finset (Fin m)) (colors : Finset ℕ)    (hvalid : ∀ x ∈ T ∪ S.map (op869_offset_emb offset h),      Disjoint (op869_splice_colors offset h base C x) colors) :    ∀ a ∈ S, Disjoint (C a) colors := by  intro a ha  have hx : op869_offset_emb offset h a ∈ T ∪ S.map (op869_offset_emb offset h) :=    Finset.mem_union_right T (Finset.mem_map.mpr ⟨a,ha,rfl⟩)  simpa [op869_splice_colors_at] using hvalid (op869_offset_emb offset h a) hxtheorem op869_spliced_colors_biUnion {n m : ℕ} (offset : ℕ) (h : offset+n ≤ m)    (base : Fin m → Finset ℕ) (C : Fin n → Finset ℕ) (A : Finset (Fin n)) :    ((A.map (op869_offset_emb offset h)).biUnion (op869_splice_colors offset h base C)) =      A.biUnion C := by  classical  ext c  simp only [Finset.mem_biUnion, Finset.mem_map]  constructor  · rintro ⟨_, ⟨a, ha, rfl⟩, hc⟩    exact ⟨a, ha, by simpa [op869_splice_colors_at] using hc⟩  · rintro ⟨a, ha, hc⟩    exact ⟨op869_offset_emb offset h a, ⟨a, ha, rfl⟩,      by simpa [op869_splice_colors_at] using hc⟩theorem op869_spliced_future_predecessors_empty {n m : ℕ} (offset : ℕ) (h : offset+n ≤ m)    (base : Fin m → Finset (Fin m)) (P : Fin n → Finset (Fin n)) (i : ℕ)    (hbase : ∀ x, offset ≤ x.val → base x = ∅)    (hlocal : ∀ a, i ≤ a.val → P a = ∅) :    ∀ x, offset+i ≤ x.val → op869_splice_preds offset h base (fun _ => ∅) P x = ∅ := by  classical  intro x hx  unfold op869_splice_preds  split_ifs with hrange  · let a : Fin n := ⟨x.val-offset, by omega⟩    have ha : i ≤ a.val := by dsimp [a]; omega    change (∅ : Finset (Fin m)) ∪ (P a).map (op869_offset_emb offset h) = ∅    rw [hlocal a ha]    simp  · exact hbase x (by omega)/-- Color updates and response transport for a spliced gadget interval. -/theorem op869_spliced_colors_update {n m : ℕ} (offset : ℕ) (h : offset+n ≤ m)    (base : Fin m → Finset ℕ) (C : Fin n → Finset ℕ) (i : Fin n) (colors : Finset ℕ) :    op869_splice_colors offset h base (Function.update C i colors) =      Function.update (op869_splice_colors offset h base C) (op869_offset_emb offset h i) colors := by  classical  funext x  by_cases hx : x = op869_offset_emb offset h i  · subst x    simp only [Function.update_self, op869_splice_colors_at]  · rw [Function.update_of_ne hx]    unfold op869_splice_colors    split_ifs with hrange    · let a : Fin n := ⟨x.val-offset, by omega⟩      have hai : a ≠ i := by        intro heq        apply hx        apply Fin.ext        have hv := congrArg Fin.val heq        change x.val-offset = i.val at hv        change x.val = offset+i.val        omega      change Function.update C i colors a = C a      exact Function.update_of_ne hai _ _    · rfl
See it in the graphDiscuss this resultChallenge it