AFTD Auto-Formalizing Theoretical Domains

even_linked_double_star_dense_spanning

theoremverified

In a host graph take a set C of exactly 2p+n+m vertices, p≥2, such that every vertex of C misses at most p−2 edges to other vertices of C. Each ordered pair of distinct members of C can be the first and last centers of a spanning copy of the linked double star of path order 2p and arms n,m.

Statement

theorem even_linked_double_star_dense_spanning {V : Type*} [DecidableEq V]
    (G : SimpleGraph V) (p n m : ℕ) (hp : 2 ≤ p) (C : Finset V) (hc : C.card=2*p+n+m)
    (hMiss : ∀ v ∈ C, (C.filter (Gᶜ.Adj v)).card ≤ p-2)
    (x y : V) (hx : x ∈ C) (hy : y ∈ C) (hxy : x ≠ y) :
    ∃ f : (even_linked_double_star p n m).Copy G, (∀ v, f v ∈ C) ∧
      f (.inl ⟨0,by omega⟩)=x ∧ f (.inl ⟨2*p-1,by omega⟩)=y
Source
https://arxiv.org/abs/2611.19632; structural lemma for OP-1853.
Verified
29 Nov 2026
Axioms
Classical.choiceQuot.soundpropext
Built on 1
  • even_linked_double_starFor natural numbers p, n, and m, the even-linked double star S_{2p}(n, m) is the simple graph on vertex set Fin(2p) ⊕ Fin(n) ⊕ Fin(m)…
Used by 1

The proof, explained

To construct a spanning copy of the linked double star with given centers x and y in C, we first allocate two disjoint sets of leaves L (of size n) adjacent to x and R (of size m) adjacent to y from C \ {x, y}; this is possible because each vertex misses at most p - 2 edges in C, providing sufficiently large neighborhoods. Removing these leaves leaves a set S = C \ (L ∪ R) of exactly 2p vertices containing x and y, in which every vertex still misses at most p - 2 edges. We then find a Hamiltonian path in S from x to y by an induction on forbidden non-edges, repairing any consecutive non-edge along the ordering by reversing an intermediate subsegment between available cross-edges. Attaching the leaf sets L and R to the endpoints of this Hamiltonian path yields the desired spanning linked double star.

  1. Reversing the subsegment (l, r] defines an involution of Fin N.

    For any indices l < r < N, the function ds1310_dense_spanning_rev maps an index i satisfying l < i ≤ r to l + r + 1 - i and leaves all other indices fixed. Applying this map twice yields l + r + 1 - (l + r + 1 - i) = i on the reversed interval and fixes elements outside it, so it is an involution and thus a permutation ds1310_dense_spanning_rev_equiv of Fin N.

    lines 4–16

    uses Fin.ext, ds1310_dense_spanning_rev_val

    private def ds1310_dense_spanning_rev {N : ℕ} (l r : ℕ) (hr : r < N) (i : Fin N) : Fin N :=
      if h : l < i.val ∧ i.val ≤ r then ⟨l+r+1-i.val,by omega⟩ else i
    
    private theorem ds1310_dense_spanning_rev_val {N l r : ℕ} (hr : r < N) (i : Fin N) :
        (ds1310_dense_spanning_rev l r hr i).val = if l < i.val ∧ i.val ≤ r then l+r+1-i.val else i.val := by
      dsimp [ds1310_dense_spanning_rev]; split <;> rfl
    
    private def ds1310_dense_spanning_rev_equiv {N : ℕ} (l r : ℕ) (hr : r < N) : Fin N ≃ Fin N where
      toFun := ds1310_dense_spanning_rev l r hr
      invFun := ds1310_dense_spanning_rev l r hr
      left_inv i := by apply Fin.ext; simp only [ds1310_dense_spanning_rev_val]; split_ifs <;> omega
      right_inv i := by apply Fin.ext; simp only [ds1310_dense_spanning_rev_val]; split_ifs <;> omega
    
  2. Reversing the subsegment (l, r] uncrosses the path, eliminating non-edges while preserving both endpoints.

    Given an ordering P : Fin N ≃ V and a symmetric relation R where all consecutive pairs satisfy R except possibly at l and r, suppose cross-relations R(P l, P r) and R(P (l+1), P (r+1)) hold. We precompose P with the subsegment reversal f. The endpoints 0 and N - 1 are outside (l, r] because 0 ≤ l < r < r + 1 < N, so their values are fixed. For any consecutive pair (i, i+1), if i = l the new pair is (l, r); if i = r it is (l+1, r+1); if l < i < r the step is reversed along the existing path and holds by symmetry of R; and outside [l, r] the steps are unchanged. Thus all consecutive pairs in the new ordering satisfy R.

    lines 17–46

    uses ds1310_dense_spanning_rev_equiv, ds1310_dense_spanning_rev_val, Fin.ext

    private theorem ds1310_dense_spanning_uncross {V : Type*} {N : ℕ} (P : Fin N ≃ V) (R : V → V → Prop)
        (hs : Symmetric R) (l r : ℕ) (hl : l < r) (hr : r+1 < N)
        (hold : ∀ i j : Fin N, i.val+1=j.val → i.val ≠ l → i.val ≠ r → R (P i) (P j))
        (h1 : R (P ⟨l,by omega⟩) (P ⟨r,by omega⟩))
        (h2 : R (P ⟨l+1,by omega⟩) (P ⟨r+1,by omega⟩)) :
        ∃ Q : Fin N ≃ V, (∀ i : Fin N, i.val=0 ∨ i.val+1=N → Q i=P i) ∧
          ∀ i j : Fin N, i.val+1=j.val → R (Q i) (Q j) := by
      let f := ds1310_dense_spanning_rev_equiv l r (by omega : r < N)
      have hval (i : Fin N) : (f i).val = if l < i.val ∧ i.val ≤ r then l+r+1-i.val else i.val :=
        ds1310_dense_spanning_rev_val (by omega) i
      refine ⟨f.trans P,?_,?_⟩
      · intro i hi
        change P (f i)=P i
        congr 1; apply Fin.ext; rw [hval]; split <;> omega
      · intro i j hij
        change R (P (f i)) (P (f j))
        by_cases he : i.val=l
        · have hi : f i = ⟨l,by omega⟩ := Fin.ext (by rw [hval]; dsimp; split <;> omega)
          have hj : f j = ⟨r,by omega⟩ := Fin.ext (by rw [hval]; dsimp; split <;> omega)
          rw [hi,hj]; exact h1
        by_cases hf : i.val=r
        · have hi : f i = ⟨l+1,by omega⟩ := Fin.ext (by rw [hval]; dsimp; split <;> omega)
          have hj : f j = ⟨r+1,by omega⟩ := Fin.ext (by rw [hval]; dsimp; split <;> omega)
          rw [hi,hj]; exact h2
        by_cases hin : l < i.val ∧ i.val < r
        · apply hs; apply hold
          all_goals simp only [hval]; split_ifs <;> omega
        · apply hold
          all_goals simp only [hval]; split_ifs <;> omega
    
  3. There exists a bijection between Fin N and V that places any two chosen distinct vertices at two specified distinct indices.

    Starting from an arbitrary bijection e : Fin N ≃ V, we first transpose the image of index a with vertex x, ensuring that a maps to x. We then transpose the resulting image of index b with vertex y. Since x ≠ y and the first transposition preserved injectivity, the second transposition preserves the mapping of a to x while placing y at index b.

    lines 47–57

    uses Fintype.equivFinOfCardEq, Equiv.swap, Equiv.trans_apply, Equiv.swap_apply_of_ne_of_ne

    private theorem ds1310_dense_spanning_initial_order {V : Type*} [Fintype V] {N : ℕ} (hN : Fintype.card V=N)
        (a b : Fin N) (hab : a ≠ b) (x y : V) (hxy : x ≠ y) :
        ∃ P : Fin N ≃ V, P a=x ∧ P b=y := by
      classical
      let e := (Fintype.equivFinOfCardEq hN).symm
      let Q := e.trans (Equiv.swap (e a) x)
      have ha : Q a=x := by simp [Q]
      have hne : x ≠ Q b := fun h => hab (Q.injective (ha.trans h))
      refine ⟨Q.trans (Equiv.swap (Q b) y),?_,by simp⟩
      simpa only [Equiv.trans_apply,ha] using Equiv.swap_apply_of_ne_of_ne hne hxy
    
  4. For each shift δ ∈ {0, 1}, the number of indices j such that P(i+δ) is not adjacent to P(j+δ) is at most p - 1.

    Let e_δ(j) = P(j+δ) be the shifted embedding. An index j is bad if e_δ(i) is not adjacent to e_δ(j). In a simple graph, a vertex is not adjacent to its non-neighbors and to itself. Since the complement degree of e_δ(i) is at most p - 2, the image under the embedding e_δ of the set of bad indices is contained in the union of the non-neighbors of e_δ(i) and {e_δ(i)}. Thus there are at most (p - 2) + 1 = p - 1 such indices.

    lines 58–79

    uses Fin.ext, congrArg, Finset.card_le_card, Finset.card_map, Finset.card_insert_le

    private theorem ds1310_dense_spanning_dense_reconnect {V : Type*} [Fintype V] [DecidableEq V] (G : SimpleGraph V)
        (p : ℕ) (hp : 2 ≤ p) (hMiss : ∀ v, (Finset.univ.filter (Gᶜ.Adj v)).card ≤ p-2)
        (P : Fin (2*p) ≃ V) (i : Fin (2*p-1)) :
        ∃ j : Fin (2*p-1), G.Adj (P ⟨i.val,by omega⟩) (P ⟨j.val,by omega⟩) ∧
          G.Adj (P ⟨i.val+1,by omega⟩) (P ⟨j.val+1,by omega⟩) := by
      classical
      let e (δ : ℕ) (hδ : δ ≤ 1) : Fin (2*p-1) ↪ V :=
        ⟨fun j => P ⟨j.val+δ,by omega⟩,fun _ _ h => Fin.ext (by have hh := congrArg Fin.val (P.injective h); dsimp at hh; omega)⟩
      let bad (δ) (hδ : δ ≤ 1) := Finset.univ.filter (fun j => ¬G.Adj (e δ hδ i) (e δ hδ j))
      have bound (δ) (hδ : δ ≤ 1) : (bad δ hδ).card ≤ p-1 := by
        let x := e δ hδ i
        let S := Finset.univ.filter (Gᶜ.Adj x)
        have hsub : (bad δ hδ).map (e δ hδ) ⊆ insert x S := by
          intro v hv; obtain ⟨j,hj,rfl⟩ := Finset.mem_map.mp hv
          by_cases h : e δ hδ j=x
          · exact Finset.mem_insert.mpr (Or.inl h)
          · exact Finset.mem_insert.mpr (Or.inr (Finset.mem_filter.mpr ⟨Finset.mem_univ _,Ne.symm h,(Finset.mem_filter.mp hj).2⟩))
        have h1 := Finset.card_le_card hsub
        rw [Finset.card_map] at h1
        have h2 := Finset.card_insert_le x S
        have h3 : S.card ≤ p-2 := hMiss x
        omega
  5. There exists an index j providing simultaneous cross-edges between P(i), P(i+1) and P(j), P(j+1).

    The total number of indices j that fail to be adjacent to either P(i) at shift 0 or P(i+1) at shift 1 is bounded by the sum of the bad sets, which is at most (p - 1) + (p - 1) = 2p - 2. Since the domain Fin(2p - 1) has cardinality 2p - 1 > 2p - 2, by the pigeonhole principle there exists at least one index j that is bad for neither shift, providing the desired simultaneous cross-edges.

    lines 80–90

    uses Finset.card_union_le, Finset.card_univ, Fintype.card_fin, Finset.exists_mem_notMem_of_card_lt_card, Finset.mem_union_left, Finset.mem_union_right

      let B := bad 0 (by decide) ∪ bad 1 (by decide)
      have hB : B.card < (Finset.univ : Finset (Fin (2*p-1))).card := by
        have h := Finset.card_union_le (bad 0 (by decide)) (bad 1 (by decide))
        have h0 := bound 0 (by decide); have h1 := bound 1 (by decide)
        simp only [Finset.card_univ,Fintype.card_fin]; dsimp only [B]; omega
      obtain ⟨j,_,hj⟩ := Finset.exists_mem_notMem_of_card_lt_card hB
      have h0 : j ∉ bad 0 (by decide) := fun h => hj (Finset.mem_union_left _ h)
      have h1 : j ∉ bad 1 (by decide) := fun h => hj (Finset.mem_union_right _ h)
      simp only [bad,Finset.mem_filter,Finset.mem_univ,true_and,not_not] at h0 h1
      exact ⟨j,by simpa [e] using h0,h1⟩
    
  6. An initial ordering with endpoints x and y satisfies the relaxed path condition when no pairs are forbidden.

    We define a relation ok(F, u, v) stating that u and v are adjacent in G, or the pair (u, v) is not in the forbidden set F. We proceed by induction on the finite set F ⊆ V × V. For the base case F = ∅, every pair is absent from F, so any bijection P : Fin(2p) ≃ V with P(0) = x and P(2p - 1) = y satisfies the condition trivially.

    lines 91–106

    uses Finset.induction_on, ds1310_dense_spanning_initial_order, congrArg

    private theorem ds1310_dense_spanning_dense_hamilton {V : Type*} [Fintype V] [DecidableEq V] (G : SimpleGraph V)
        (p : ℕ) (hp : 2 ≤ p) (hN : Fintype.card V=2*p)
        (hMiss : ∀ v, (Finset.univ.filter (Gᶜ.Adj v)).card ≤ p-2)
        (x y : V) (hxy : x ≠ y) :
        ∃ P : Fin (2*p) ≃ V, P ⟨0,by omega⟩=x ∧ P ⟨2*p-1,by omega⟩=y ∧
          ∀ i j : Fin (2*p), i.val+1=j.val → G.Adj (P i) (P j) := by
      classical
      let a : Fin (2*p) := ⟨0,by omega⟩
      let b : Fin (2*p) := ⟨2*p-1,by omega⟩
      let ok (F : Finset (V×V)) (u v : V) := G.Adj u v ∨ ((u,v) ∉ F ∧ (v,u) ∉ F)
      have build (F : Finset (V×V)) : ∃ P : Fin (2*p) ≃ V, P a=x ∧ P b=y ∧
          ∀ i j : Fin (2*p), i.val+1=j.val → ok F (P i) (P j) := by
        induction F using Finset.induction_on with
        | empty =>
          obtain ⟨P,hP,hQ⟩ := ds1310_dense_spanning_initial_order hN a b (by intro he; have := congrArg Fin.val he; dsimp [a,b] at this; omega) x y hxy
          exact ⟨P,hP,hQ,by simp [ok]⟩
  7. When a forbidden pair z is added, any violation of the path condition occurs at a non-edge corresponding to z.

    Given an ordering P satisfying the condition for F, consider adding a new pair z to F. If all consecutive steps still satisfy ok(insert z F), P remains valid. Otherwise, any failing consecutive step (u, v) cannot be an edge in G and must have either (P u, P v) = z or (P v, P u) = z. Since z is uniquely identified with this step, all other consecutive steps along the path remain valid under the new relation.

    lines 107–138

    uses Or.inl, Or.inr, Finset.mem_insert, Ne.symm, Prod.mk.inj, congrArg

        | @insert z F hz ih =>
          obtain ⟨P,hPa,hPb,hpath⟩ := ih
          let R := ok (insert z F)
          have rs : Symmetric R := by
            intro u v h
            exact h.elim (fun h => Or.inl h.symm) (fun h => Or.inr h.symm)
          by_cases allok : ∀ i j : Fin (2*p), i.val+1=j.val → R (P i) (P j)
          · exact ⟨P,hPa,hPb,allok⟩
          push Not at allok
          obtain ⟨u,v,huv,hu⟩ := allok
          have noedge : ¬G.Adj (P u) (P v) := fun h => hu (Or.inl h)
          have zid : z=(P u,P v) ∨ z=(P v,P u) := by
            by_contra! h
            obtain h'|h' := hpath u v huv
            · exact noedge h'
            · apply hu; right; simp only [Finset.mem_insert,not_or]
              exact ⟨⟨Ne.symm h.1,h'.1⟩,⟨Ne.symm h.2,h'.2⟩⟩
          have old (i j : Fin (2*p)) (hij : i.val+1=j.val) (hi : i.val ≠ u.val) : R (P i) (P j) := by
            obtain hg|hf := hpath i j hij
            · exact Or.inl hg
            right; simp only [Finset.mem_insert,not_or]
            have hne1 : (P i,P j) ≠ z := by
              rcases zid with h|h <;> rw [h] <;> intro he
              all_goals have h1 := congrArg Fin.val (P.injective (Prod.mk.inj he).1)
              all_goals have h2 := congrArg Fin.val (P.injective (Prod.mk.inj he).2)
              all_goals omega
            have hne2 : (P j,P i) ≠ z := by
              rcases zid with h|h <;> rw [h] <;> intro he
              all_goals have h1 := congrArg Fin.val (P.injective (Prod.mk.inj he).1)
              all_goals have h2 := congrArg Fin.val (P.injective (Prod.mk.inj he).2)
              all_goals omega
            exact ⟨⟨hne1,hf.1⟩,⟨hne2,hf.2⟩⟩
  8. Every graph on 2p vertices with complement degree at most p - 2 contains a Hamiltonian path between any two distinct vertices.

    At the failing step u, we apply ds1310_dense_spanning_dense_reconnect to find an index j ≠ u with cross-edges to u and u+1. Applying ds1310_dense_spanning_uncross reverses the segment between u and j, repairing the non-edge while fixing the endpoints x and y. When F is the complete relation Finset.univ, the relaxed condition ok(univ) coincides with adjacency in G, yielding a genuine Hamiltonian path from x to y.

    lines 139–153

    uses ds1310_dense_spanning_dense_reconnect, Fin.ext, ds1310_dense_spanning_uncross, Or.inl

          obtain ⟨j,ha,hb⟩ := ds1310_dense_spanning_dense_reconnect G p hp hMiss P ⟨u.val,by omega⟩
          have hj : j.val ≠ u.val := by
            intro h
            have he : (⟨j.val,by omega⟩ : Fin (2*p))=u := Fin.ext h
            rw [he] at ha; exact ha.ne rfl
          have get : ∃ Q : Fin (2*p) ≃ V, (∀ i : Fin (2*p), i.val=0 ∨ i.val+1=2*p → Q i=P i) ∧
              ∀ i j : Fin (2*p), i.val+1=j.val → R (Q i) (Q j) := by
            by_cases h : u.val < j.val
            · exact ds1310_dense_spanning_uncross P R rs u.val j.val h (by omega) (fun i j he hi _ => old i j he hi) (Or.inl ha) (Or.inl hb)
            · exact ds1310_dense_spanning_uncross P R rs j.val u.val (by omega) (by omega) (fun i j he _ hi => old i j he hi) (Or.inl ha.symm) (Or.inl hb.symm)
          obtain ⟨Q,hQ,hq⟩ := get
          exact ⟨Q,(hQ a (Or.inl rfl)).trans hPa,(hQ b (Or.inr (by dsimp [b]; omega))).trans hPb,hq⟩
      obtain ⟨P,hx,hy,hp'⟩ := build Finset.univ
      exact ⟨P,hx,hy,fun i j h => by simpa [ok] using hp' i j h⟩
    
  9. Both x and y have at least n + m neighbors in S = C \ {x, y}.

    Since |C| = 2p + n + m, the set S = C \ {x, y} has size 2p + n + m - 2. Each vertex in C misses at most p - 2 edges to other vertices of C. Therefore, the number of neighbors of z ∈ {x, y} in S is at least |S| - (p - 2) = (2p + n + m - 2) - (p - 2) = p + n + m. Since p ≥ 2, this is at least n + m.

    lines 154–181

    uses Finset.card_erase_add_one, Finset.Subset.trans, Finset.erase_subset, Finset.card_le_card, Finset.le_card_sdiff

    private theorem ds1310_dense_spanning_dense_leaf_bank {V : Type*} [DecidableEq V] (G : SimpleGraph V)
        (p n m : ℕ) (hp : 2 ≤ p) (C : Finset V) (hC : C.card=2*p+n+m)
        (hMiss : ∀ v ∈ C, (C.filter (Gᶜ.Adj v)).card ≤ p-2)
        (x y : V) (hx : x ∈ C) (hy : y ∈ C) (hxy : x ≠ y) :
        ∃ L R : Finset V, L ⊆ C ∧ R ⊆ C ∧ Disjoint L R ∧ L.card=n ∧ R.card=m ∧
          x ∉ L ∧ x ∉ R ∧ y ∉ L ∧ y ∉ R ∧ (∀ l ∈ L, G.Adj x l) ∧ (∀ r ∈ R, G.Adj y r) := by
      classical
      let S := (C.erase x).erase y
      have hy' : y ∈ C.erase x := Finset.mem_erase.mpr ⟨hxy.symm,hy⟩
      have hc : S.card+2=C.card := by
        have h1 := Finset.card_erase_add_one hx
        have h2 := Finset.card_erase_add_one hy'
        dsimp [S]; omega
      have hSC : S ⊆ C := Finset.Subset.trans (Finset.erase_subset _ _) (Finset.erase_subset _ _)
      have hnS (v) (hv : v ∈ S) : v ≠ x ∧ v ≠ y :=
        ⟨(Finset.mem_erase.mp (Finset.mem_erase.mp hv).2).1,(Finset.mem_erase.mp hv).1⟩
      have pool (z : V) (hz : z=x ∨ z=y) : n+m ≤ (S.filter (G.Adj z)).card := by
        have hzC : z ∈ C := hz.elim (fun h => h ▸ hx) (fun h => h ▸ hy)
        have sub : S \ (C.filter (Gᶜ.Adj z)) ⊆ S.filter (G.Adj z) := by
          intro v hv
          obtain ⟨hs,hn⟩ := Finset.mem_sdiff.mp hv
          refine Finset.mem_filter.mpr ⟨hs,?_⟩
          by_contra h
          have hne : z ≠ v := hz.elim (fun he => he ▸ (hnS v hs).1.symm) (fun he => he ▸ (hnS v hs).2.symm)
          exact hn (Finset.mem_filter.mpr ⟨hSC hs,hne,h⟩)
        have hh := Finset.card_le_card sub
        have hb := Finset.le_card_sdiff (C.filter (Gᶜ.Adj z)) S
        have hm := hMiss z hzC; omega
  10. There exist disjoint sets of leaves L of size n and R of size m in C \ {x, y} adjacent to x and y respectively.

    Since x has at least n + m neighbors in S, we choose a subset L of neighbors of size n. Then the remaining neighbors of y in S \ L have cardinality at least (n + m) - n = m, allowing us to choose a disjoint subset R of size m. Both subsets avoid x and y and lie in C.

    lines 182–193

    uses Finset.exists_subset_card_eq, le_trans, Finset.le_card_sdiff, Finset.filter_subset, Finset.sdiff_subset, Finset.disjoint_left

      obtain ⟨L,hL,hl⟩ := Finset.exists_subset_card_eq (le_trans (by omega : n ≤ n+m) (pool x (Or.inl rfl)))
      have hr : m ≤ ((S.filter (G.Adj y)) \ L).card := by
        have h := Finset.le_card_sdiff L (S.filter (G.Adj y))
        have h' := pool y (Or.inr rfl); omega
      obtain ⟨R,hR,hr'⟩ := Finset.exists_subset_card_eq hr
      have hLS : L ⊆ S := hL.trans (Finset.filter_subset _ _)
      have hRS : R ⊆ S := hR.trans (Finset.sdiff_subset.trans (Finset.filter_subset _ _))
      exact ⟨L,R,hLS.trans hSC,hRS.trans hSC,Finset.disjoint_left.mpr (fun _ hl hr => (Finset.mem_sdiff.mp (hR hr)).2 hl),
        hl,hr',fun h => (hnS _ (hLS h)).1 rfl,fun h => (hnS _ (hRS h)).1 rfl,
        fun h => (hnS _ (hLS h)).2 rfl,fun h => (hnS _ (hRS h)).2 rfl,
        fun _ h => (Finset.mem_filter.mp (hL h)).2,fun _ h => (Finset.mem_filter.mp (Finset.mem_sdiff.mp (hR h)).1).2⟩
    
  11. A central path and two attached sets of leaves form a copy of the linked double star.

    Given a path of length 2p and leaf sets of sizes n and m, where the endpoints of the path connect to all respective leaves, their combined injective map into V preserves all graph edges by case analysis on the definition of even_linked_double_star.

    lines 194–214

    uses Sum.elim

    private def ds1310_dense_spanning_exact_copy {V : Type*} {G : SimpleGraph V} {p n m : ℕ}
        (path : Fin (2*p) → V) (left : Fin n → V) (right : Fin m → V)
        (hinj : Function.Injective (Sum.elim path (Sum.elim left right)))
        (hp : ∀ i j : Fin (2*p), i.val+1=j.val → G.Adj (path i) (path j))
        (hl : ∀ i : Fin (2*p), i.val=0 → ∀ l, G.Adj (path i) (left l))
        (hr : ∀ i : Fin (2*p), i.val+1=2*p → ∀ l, G.Adj (path i) (right l)) :
        (even_linked_double_star p n m).Copy G := by
      let f := Sum.elim path (Sum.elim left right)
      refine ⟨⟨f,?_⟩,hinj⟩
      intro x y h
      rcases h.2 with h | h <;>
        rcases h with ⟨i,j,rfl,rfl,h|h⟩ | ⟨i,j,h,⟨rfl,rfl⟩|⟨rfl,rfl⟩⟩ | ⟨i,j,h,⟨rfl,rfl⟩|⟨rfl,rfl⟩⟩
      all_goals dsimp [f]
      all_goals first
        | exact hp _ _ (by assumption)
        | exact (hp _ _ (by assumption)).symm
        | exact hl _ (by assumption) _
        | exact (hl _ (by assumption) _).symm
        | exact hr _ (by assumption) _
        | exact (hr _ (by assumption) _).symm
    
  12. Combining two injective functions with disjoint ranges yields an injective function on the sum type.

    If f and g are injective and no element of the range of f equals any element of the range of g, then Sum.elim f g is injective on the direct sum.

    lines 215–223

    uses congrArg, Sum.inl, Sum.inr

    private theorem ds1310_dense_spanning_sum_inj {α β γ : Type*} {f : α → γ} {g : β → γ}
        (hf : Function.Injective f) (hg : Function.Injective g) (h : ∀ i j, f i ≠ g j) :
        Function.Injective (Sum.elim f g) := by
      rintro (x|x) (y|y) he
      · exact congrArg Sum.inl (hf he)
      · exact (h x y he).elim
      · exact (h y x he.symm).elim
      · exact congrArg Sum.inr (hg he)
    
  13. Removing the leaf sets leaves a set S ⊆ C of exactly 2p vertices containing x and y.

    Using ds1310_dense_spanning_dense_leaf_bank, we set aside disjoint leaf sets L and R. Removing them from C leaves S = C \ (L ∪ R) of cardinality (2p + n + m) - (n + m) = 2p. Since neither L nor R contains x or y, both x and y belong to S.

    lines 224–240

    uses ds1310_dense_spanning_dense_leaf_bank, Finset.sdiff_subset, Finset.union_subset, Fintype.card_coe, Finset.card_sdiff_of_subset, Finset.card_union_of_disjoint

    theorem even_linked_double_star_dense_spanning {V : Type*} [DecidableEq V]
        (G : SimpleGraph V) (p n m : ℕ) (hp : 2 ≤ p) (C : Finset V) (hc : C.card=2*p+n+m)
        (hMiss : ∀ v ∈ C, (C.filter (Gᶜ.Adj v)).card ≤ p-2)
        (x y : V) (hx : x ∈ C) (hy : y ∈ C) (hxy : x ≠ y) :
        ∃ f : (even_linked_double_star p n m).Copy G, (∀ v, f v ∈ C) ∧
          f (.inl ⟨0,by omega⟩)=x ∧ f (.inl ⟨2*p-1,by omega⟩)=y := by
      classical
      obtain ⟨L,R,hLC,hRC,hdis,hl,hr,hxl,hxr,hyl,hyr,hL,hR⟩ := ds1310_dense_spanning_dense_leaf_bank G p n m hp C hc hMiss x y hx hy hxy
      let S := C \ (L∪R)
      have hSC : S ⊆ C := Finset.sdiff_subset
      have hN : Fintype.card ↥S=2*p := by
        have hu := Finset.union_subset hLC hRC
        simp only [Fintype.card_coe]
        change (C \ (L ∪ R)).card = _
        rw [Finset.card_sdiff_of_subset hu,Finset.card_union_of_disjoint hdis,hl,hr,hc]; omega
      let X : ↥S := ⟨x,Finset.mem_sdiff.mpr ⟨hx,fun h => (Finset.mem_union.mp h).elim hxl hxr⟩⟩
      let Y : ↥S := ⟨y,Finset.mem_sdiff.mpr ⟨hy,fun h => (Finset.mem_union.mp h).elim hyl hyr⟩⟩
  14. The induced subgraph on S contains a Hamiltonian path connecting x and y.

    In the induced subgraph H = G[S], any missing edge from v ∈ S to another vertex of S was already a missing edge in C, so every vertex misses at most p - 2 edges in H. By ds1310_dense_spanning_dense_hamilton applied to H on 2p vertices, there is a Hamiltonian path P in S starting at x and ending at y.

    lines 241–254

    uses Finset.card_le_card, ds1310_dense_spanning_dense_hamilton, congrArg, Finset.equivFinOfCardEq

      let H := G.induce (S : Set V)
      have miss (v : ↥S) : (Finset.univ.filter (Hᶜ.Adj v)).card ≤ p-2 := by
        let e := Function.Embedding.subtype (fun z : V => z ∈ S)
        have sub : (Finset.univ.filter (Hᶜ.Adj v)).map e ⊆ C.filter (Gᶜ.Adj v.val) := by
          intro z hz; obtain ⟨j,hj,rfl⟩ := Finset.mem_map.mp hz
          obtain ⟨hne,hna⟩ := (H.compl_adj _ _).mp (Finset.mem_filter.mp hj).2
          exact Finset.mem_filter.mpr ⟨hSC j.property,fun h => hne (Subtype.ext h),hna⟩
        simpa using (Finset.card_le_card sub).trans (hMiss _ (hSC v.property))
      obtain ⟨P,ha,hb,hpath⟩ := ds1310_dense_spanning_dense_hamilton H p hp hN miss X Y (fun h => hxy (congrArg Subtype.val h))
      let A := (Finset.equivFinOfCardEq hl).symm
      let B := (Finset.equivFinOfCardEq hr).symm
      let path (i) : V := (P i).val
      let left (i) : V := (A i).val
      let right (i) : V := (B i).val
  15. The combined embedding forms a spanning copy of the linked double star in C with centers x and y.

    We identify L with Fin n and R with Fin m via bijections A and B, and assemble the path P and leaf sets into a map f from Fin(2p) ⊕ Fin n ⊕ Fin m to C. Since S, L, and R partition C, repeated application of ds1310_dense_spanning_sum_inj shows f is injective. By ds1310_dense_spanning_exact_copy, f is a graph embedding with first center x and last center y that spans C.

    lines 255–278

    uses ds1310_dense_spanning_sum_inj, Finset.disjoint_left, Fin.ext, congrArg, ds1310_dense_spanning_exact_copy

      have hi : Function.Injective (Sum.elim path (Sum.elim left right)) := by
        apply ds1310_dense_spanning_sum_inj (Subtype.val_injective.comp P.injective)
        · apply ds1310_dense_spanning_sum_inj (Subtype.val_injective.comp A.injective) (Subtype.val_injective.comp B.injective)
          intro i j he
          change (A i).val=(B j).val at he
          exact Finset.disjoint_left.mp hdis (A i).property (he ▸ (B j).property)
        · rintro i (j|j) he
          · change (P i).val=(A j).val at he
            exact (Finset.mem_sdiff.mp (P i).property).2 (Finset.mem_union_left _ (he ▸ (A j).property))
          · change (P i).val=(B j).val at he
            exact (Finset.mem_sdiff.mp (P i).property).2 (Finset.mem_union_right _ (he ▸ (B j).property))
      have hfirst (i : Fin (2*p)) (h : i.val=0) : path i=x := by
        have he : i=⟨0,by omega⟩ := Fin.ext h
        rw [he]; exact congrArg Subtype.val ha
      have hlast (i : Fin (2*p)) (h : i.val+1=2*p) : path i=y := by
        have he : i=⟨2*p-1,by omega⟩ := Fin.ext (by dsimp; omega)
        rw [he]; exact congrArg Subtype.val hb
      let f := ds1310_dense_spanning_exact_copy path left right hi hpath (fun i h j => (hfirst i h) ▸ hL _ (A j).property)
        (fun i h j => (hlast i h) ▸ hR _ (B j).property)
      refine ⟨f,?_,hfirst _ rfl,hlast _ (by dsimp; omega)⟩
      rintro (i|j|j)
      · exact hSC (P i).property
      · exact hLC (A j).property
      · exact hRC (B j).property
Fin.ext
Two elements of Fin n are equal if and only if their underlying natural number values are equal.
ds1310_dense_spanning_rev_val
The value of the subsegment reversal at index i is l + r + 1 - i if l < i ≤ r, and i otherwise.
ds1310_dense_spanning_rev_equiv
Reversing the half-open interval (l, r] defines an equivalence (permutation) of Fin N.
Fintype.equivFinOfCardEq
A finite type with cardinality n is in bijection with Fin n.
Equiv.swap
The permutation swapping two given elements and leaving all other elements unchanged.
Equiv.trans_apply
The value of the composition of two equivalences on an input is obtained by applying the second to the image under the first.
Equiv.swap_apply_of_ne_of_ne
Swapping two elements a and b leaves any element distinct from both a and b fixed.
congrArg
Functions preserve equality: if a = b, then f(a) = f(b).
Finset.card_le_card
If a finite set s is a subset of t, then the cardinality of s is at most that of t.
Finset.card_map
The cardinality of the image of a finite set under an embedding equals the cardinality of the original set.
Finset.card_insert_le
Inserting an element into a finite set increases its cardinality by at most 1.
Finset.card_union_le
The cardinality of the union of two finite sets is at most the sum of their cardinalities.
Finset.card_univ
The cardinality of the universe finite set of a finite type equals the cardinality of the type.
Fintype.card_fin
The cardinality of Fin n is n.
Finset.exists_mem_notMem_of_card_lt_card
If the cardinality of s is strictly less than that of t, there exists an element in t not in s.
Finset.mem_union_left
An element of s is also an element of the union s ∪ t.
Finset.mem_union_right
An element of t is also an element of the union s ∪ t.
Finset.induction_on
Principle of induction for finite sets: a property holding for the empty set and preserved under inserting fresh elements holds for all finite sets.
ds1310_dense_spanning_initial_order
For any two distinct indices and two distinct vertices in a finite type of size N, there is a bijection mapping the chosen indices to the chosen vertices.
Or.inl
Constructs a proof of A ∨ B from a proof of A.
Or.inr
Constructs a proof of A ∨ B from a proof of B.
Finset.mem_insert
An element belongs to insert b s if and only if it equals b or belongs to s.
Ne.symm
Inequality is symmetric: if a ≠ b, then b ≠ a.
Prod.mk.inj
Two pairs are equal if and only if their respective first and second components are equal.
ds1310_dense_spanning_dense_reconnect
In a graph on 2p vertices with complement degree at most p - 2, any position along an ordering admits an index with simultaneous cross-edges.
ds1310_dense_spanning_uncross
Reversing a subsegment between cross-edges eliminates a non-edge while preserving the endpoints of the ordering.
Finset.card_erase_add_one
Erasing an element from a finite set and adding 1 gives the cardinality of the original set.
Finset.Subset.trans
The subset relation on finite sets is transitive.
Finset.erase_subset
Erasing an element from a finite set produces a subset of the original set.
Finset.le_card_sdiff
The difference of cardinalities |t| - |s| is at most the cardinality of the set difference |t \ s|.
Finset.exists_subset_card_eq
A finite set has a subset of any cardinality up to its own.
le_trans
The order relation ≤ is transitive.
Finset.filter_subset
Filtering a finite set by a predicate produces a subset of the original set.
Finset.sdiff_subset
The set difference s \ t is a subset of s.
Finset.disjoint_left
Two finite sets are disjoint if and only if no element of the first belongs to the second.
Sum.elim
Defines a function from a disjoint union α ⊕ β by case analysis on the components.
Sum.inl
The left injection from α into the disjoint union α ⊕ β.
Sum.inr
The right injection from β into the disjoint union α ⊕ β.
ds1310_dense_spanning_dense_leaf_bank
In C, any two distinct vertices x and y have disjoint sets of neighbors of sizes n and m respectively in C \ {x, y}.
Finset.union_subset
If two subsets are each contained in u, then their union is contained in u.
Fintype.card_coe
The cardinality of a subtype coerced from a finite set equals the cardinality of the finite set.
Finset.card_sdiff_of_subset
If s ⊆ t, then |t \ s| = |t| - |s|.
Finset.card_union_of_disjoint
If s and t are disjoint finite sets, then |s ∪ t| = |s| + |t|.
ds1310_dense_spanning_dense_hamilton
In a graph on 2p vertices with complement degree at most p - 2, any two distinct vertices are connected by a Hamiltonian path.
ds1310_dense_spanning_sum_inj
Combining two injective functions with disjoint ranges yields an injective function on the sum type.
ds1310_dense_spanning_exact_copy
Constructs an embedding of the linked double star from a central path and two sets of leaves at its endpoints.

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

Lean’s trace was cut to the first 400 of 467 tactics.

open SimpleGraph Classicalopen scoped BigOperatorsprivate def ds1310_dense_spanning_rev {N : ℕ} (l r : ℕ) (hr : r < N) (i : Fin N) : Fin N :=  if h : l < i.val ∧ i.val ≤ r then ⟨l+r+1-i.val,by omega⟩ else iprivate theorem ds1310_dense_spanning_rev_val {N l r : ℕ} (hr : r < N) (i : Fin N) :    (ds1310_dense_spanning_rev l r hr i).val = if l < i.val ∧ i.val ≤ r then l+r+1-i.val else i.val := by  dsimp [ds1310_dense_spanning_rev]; split <;> rflprivate def ds1310_dense_spanning_rev_equiv {N : ℕ} (l r : ℕ) (hr : r < N) : Fin N ≃ Fin N where  toFun := ds1310_dense_spanning_rev l r hr  invFun := ds1310_dense_spanning_rev l r hr  left_inv i := by apply Fin.ext; simp only [ds1310_dense_spanning_rev_val]; split_ifs <;> omega  right_inv i := by apply Fin.ext; simp only [ds1310_dense_spanning_rev_val]; split_ifs <;> omegaprivate theorem ds1310_dense_spanning_uncross {V : Type*} {N : ℕ} (P : Fin N ≃ V) (R : V → V → Prop)    (hs : Symmetric R) (l r : ℕ) (hl : l < r) (hr : r+1 < N)    (hold : ∀ i j : Fin N, i.val+1=j.val → i.val ≠ l → i.val ≠ r → R (P i) (P j))    (h1 : R (P ⟨l,by omega⟩) (P ⟨r,by omega⟩))    (h2 : R (P ⟨l+1,by omega⟩) (P ⟨r+1,by omega⟩)) :    ∃ Q : Fin N ≃ V, (∀ i : Fin N, i.val=0 ∨ i.val+1=N → Q i=P i) ∧      ∀ i j : Fin N, i.val+1=j.val → R (Q i) (Q j) := by  let f := ds1310_dense_spanning_rev_equiv l r (by omega : r < N)  have hval (i : Fin N) : (f i).val = if l < i.val ∧ i.val ≤ r then l+r+1-i.val else i.val :=    ds1310_dense_spanning_rev_val (by omega) i  refine ⟨f.trans P,?_,?_⟩  · intro i hi    change P (f i)=P i    congr 1; apply Fin.ext; rw [hval]; split <;> omega  · intro i j hij    change R (P (f i)) (P (f j))    by_cases he : i.val=l    · have hi : f i = ⟨l,by omega⟩ := Fin.ext (by rw [hval]; dsimp; split <;> omega)      have hj : f j = ⟨r,by omega⟩ := Fin.ext (by rw [hval]; dsimp; split <;> omega)      rw [hi,hj]; exact h1    by_cases hf : i.val=r    · have hi : f i = ⟨l+1,by omega⟩ := Fin.ext (by rw [hval]; dsimp; split <;> omega)      have hj : f j = ⟨r+1,by omega⟩ := Fin.ext (by rw [hval]; dsimp; split <;> omega)      rw [hi,hj]; exact h2    by_cases hin : l < i.val ∧ i.val < r    · apply hs; apply hold      all_goals simp only [hval]; split_ifs <;> omega    · apply hold      all_goals simp only [hval]; split_ifs <;> omegaprivate theorem ds1310_dense_spanning_initial_order {V : Type*} [Fintype V] {N : ℕ} (hN : Fintype.card V=N)    (a b : Fin N) (hab : a ≠ b) (x y : V) (hxy : x ≠ y) :    ∃ P : Fin N ≃ V, P a=x ∧ P b=y := by  classical  let e := (Fintype.equivFinOfCardEq hN).symm  let Q := e.trans (Equiv.swap (e a) x)  have ha : Q a=x := by simp [Q]  have hne : x ≠ Q b := fun h => hab (Q.injective (ha.trans h))  refine ⟨Q.trans (Equiv.swap (Q b) y),?_,by simp⟩  simpa only [Equiv.trans_apply,ha] using Equiv.swap_apply_of_ne_of_ne hne hxyprivate theorem ds1310_dense_spanning_dense_reconnect {V : Type*} [Fintype V] [DecidableEq V] (G : SimpleGraph V)    (p : ℕ) (hp : 2 ≤ p) (hMiss : ∀ v, (Finset.univ.filter (Gᶜ.Adj v)).card ≤ p-2)    (P : Fin (2*p) ≃ V) (i : Fin (2*p-1)) :    ∃ j : Fin (2*p-1), G.Adj (P ⟨i.val,by omega⟩) (P ⟨j.val,by omega⟩) ∧      G.Adj (P ⟨i.val+1,by omega⟩) (P ⟨j.val+1,by omega⟩) := by  classical  let e (δ : ℕ) (hδ : δ ≤ 1) : Fin (2*p-1) ↪ V :=    ⟨fun j => P ⟨j.val+δ,by omega⟩,fun _ _ h => Fin.ext (by have hh := congrArg Fin.val (P.injective h); dsimp at hh; omega)⟩  let bad (δ) (hδ : δ ≤ 1) := Finset.univ.filter (fun j => ¬G.Adj (e δ hδ i) (e δ hδ j))  have bound (δ) (hδ : δ ≤ 1) : (bad δ hδ).card ≤ p-1 := by    let x := e δ hδ i    let S := Finset.univ.filter (Gᶜ.Adj x)    have hsub : (bad δ hδ).map (e δ hδ) ⊆ insert x S := by      intro v hv; obtain ⟨j,hj,rfl⟩ := Finset.mem_map.mp hv      by_cases h : e δ hδ j=x      · exact Finset.mem_insert.mpr (Or.inl h)      · exact Finset.mem_insert.mpr (Or.inr (Finset.mem_filter.mpr ⟨Finset.mem_univ _,Ne.symm h,(Finset.mem_filter.mp hj).2⟩))    have h1 := Finset.card_le_card hsub    rw [Finset.card_map] at h1    have h2 := Finset.card_insert_le x S    have h3 : S.card ≤ p-2 := hMiss x    omega  let B := bad 0 (by decide) ∪ bad 1 (by decide)  have hB : B.card < (Finset.univ : Finset (Fin (2*p-1))).card := by    have h := Finset.card_union_le (bad 0 (by decide)) (bad 1 (by decide))    have h0 := bound 0 (by decide); have h1 := bound 1 (by decide)    simp only [Finset.card_univ,Fintype.card_fin]; dsimp only [B]; omega  obtain ⟨j,_,hj⟩ := Finset.exists_mem_notMem_of_card_lt_card hB  have h0 : j ∉ bad 0 (by decide) := fun h => hj (Finset.mem_union_left _ h)  have h1 : j ∉ bad 1 (by decide) := fun h => hj (Finset.mem_union_right _ h)  simp only [bad,Finset.mem_filter,Finset.mem_univ,true_and,not_not] at h0 h1  exact ⟨j,by simpa [e] using h0,h1⟩private theorem ds1310_dense_spanning_dense_hamilton {V : Type*} [Fintype V] [DecidableEq V] (G : SimpleGraph V)    (p : ℕ) (hp : 2 ≤ p) (hN : Fintype.card V=2*p)    (hMiss : ∀ v, (Finset.univ.filter (Gᶜ.Adj v)).card ≤ p-2)    (x y : V) (hxy : x ≠ y) :    ∃ P : Fin (2*p) ≃ V, P ⟨0,by omega⟩=x ∧ P ⟨2*p-1,by omega⟩=y ∧      ∀ i j : Fin (2*p), i.val+1=j.val → G.Adj (P i) (P j) := by  classical  let a : Fin (2*p) := ⟨0,by omega⟩  let b : Fin (2*p) := ⟨2*p-1,by omega⟩  let ok (F : Finset (V×V)) (u v : V) := G.Adj u v ∨ ((u,v) ∉ F ∧ (v,u) ∉ F)  have build (F : Finset (V×V)) : ∃ P : Fin (2*p) ≃ V, P a=x ∧ P b=y ∧      ∀ i j : Fin (2*p), i.val+1=j.val → ok F (P i) (P j) := by    induction F using Finset.induction_on with    | empty =>      obtain ⟨P,hP,hQ⟩ := ds1310_dense_spanning_initial_order hN a b (by intro he; have := congrArg Fin.val he; dsimp [a,b] at this; omega) x y hxy      exact ⟨P,hP,hQ,by simp [ok]⟩    | @insert z F hz ih =>      obtain ⟨P,hPa,hPb,hpath⟩ := ih      let R := ok (insert z F)      have rs : Symmetric R := by        intro u v h        exact h.elim (fun h => Or.inl h.symm) (fun h => Or.inr h.symm)      by_cases allok : ∀ i j : Fin (2*p), i.val+1=j.val → R (P i) (P j)      · exact ⟨P,hPa,hPb,allok⟩      push Not at allok      obtain ⟨u,v,huv,hu⟩ := allok      have noedge : ¬G.Adj (P u) (P v) := fun h => hu (Or.inl h)      have zid : z=(P u,P v) ∨ z=(P v,P u) := by        by_contra! h        obtain h'|h' := hpath u v huv        · exact noedge h'        · apply hu; right; simp only [Finset.mem_insert,not_or]          exact ⟨⟨Ne.symm h.1,h'.1⟩,⟨Ne.symm h.2,h'.2⟩⟩      have old (i j : Fin (2*p)) (hij : i.val+1=j.val) (hi : i.val ≠ u.val) : R (P i) (P j) := by        obtain hg|hf := hpath i j hij        · exact Or.inl hg        right; simp only [Finset.mem_insert,not_or]        have hne1 : (P i,P j) ≠ z := by          rcases zid with h|h <;> rw [h] <;> intro he          all_goals have h1 := congrArg Fin.val (P.injective (Prod.mk.inj he).1)          all_goals have h2 := congrArg Fin.val (P.injective (Prod.mk.inj he).2)          all_goals omega        have hne2 : (P j,P i) ≠ z := by          rcases zid with h|h <;> rw [h] <;> intro he          all_goals have h1 := congrArg Fin.val (P.injective (Prod.mk.inj he).1)          all_goals have h2 := congrArg Fin.val (P.injective (Prod.mk.inj he).2)          all_goals omega        exact ⟨⟨hne1,hf.1⟩,⟨hne2,hf.2⟩⟩      obtain ⟨j,ha,hb⟩ := ds1310_dense_spanning_dense_reconnect G p hp hMiss P ⟨u.val,by omega⟩      have hj : j.val ≠ u.val := by        intro h        have he : (⟨j.val,by omega⟩ : Fin (2*p))=u := Fin.ext h        rw [he] at ha; exact ha.ne rfl      have get : ∃ Q : Fin (2*p) ≃ V, (∀ i : Fin (2*p), i.val=0 ∨ i.val+1=2*p → Q i=P i) ∧          ∀ i j : Fin (2*p), i.val+1=j.val → R (Q i) (Q j) := by        by_cases h : u.val < j.val        · exact ds1310_dense_spanning_uncross P R rs u.val j.val h (by omega) (fun i j he hi _ => old i j he hi) (Or.inl ha) (Or.inl hb)        · exact ds1310_dense_spanning_uncross P R rs j.val u.val (by omega) (by omega) (fun i j he _ hi => old i j he hi) (Or.inl ha.symm) (Or.inl hb.symm)      obtain ⟨Q,hQ,hq⟩ := get      exact ⟨Q,(hQ a (Or.inl rfl)).trans hPa,(hQ b (Or.inr (by dsimp [b]; omega))).trans hPb,hq⟩  obtain ⟨P,hx,hy,hp'⟩ := build Finset.univ  exact ⟨P,hx,hy,fun i j h => by simpa [ok] using hp' i j h⟩private theorem ds1310_dense_spanning_dense_leaf_bank {V : Type*} [DecidableEq V] (G : SimpleGraph V)    (p n m : ℕ) (hp : 2 ≤ p) (C : Finset V) (hC : C.card=2*p+n+m)    (hMiss : ∀ v ∈ C, (C.filter (Gᶜ.Adj v)).card ≤ p-2)    (x y : V) (hx : x ∈ C) (hy : y ∈ C) (hxy : x ≠ y) :    ∃ L R : Finset V, L ⊆ C ∧ R ⊆ C ∧ Disjoint L R ∧ L.card=n ∧ R.card=m ∧      x ∉ L ∧ x ∉ R ∧ y ∉ L ∧ y ∉ R ∧ (∀ l ∈ L, G.Adj x l) ∧ (∀ r ∈ R, G.Adj y r) := by  classical  let S := (C.erase x).erase y  have hy' : y ∈ C.erase x := Finset.mem_erase.mpr ⟨hxy.symm,hy⟩  have hc : S.card+2=C.card := by    have h1 := Finset.card_erase_add_one hx    have h2 := Finset.card_erase_add_one hy'    dsimp [S]; omega  have hSC : S ⊆ C := Finset.Subset.trans (Finset.erase_subset _ _) (Finset.erase_subset _ _)  have hnS (v) (hv : v ∈ S) : v ≠ x ∧ v ≠ y :=    ⟨(Finset.mem_erase.mp (Finset.mem_erase.mp hv).2).1,(Finset.mem_erase.mp hv).1⟩  have pool (z : V) (hz : z=x ∨ z=y) : n+m ≤ (S.filter (G.Adj z)).card := by    have hzC : z ∈ C := hz.elim (fun h => h ▸ hx) (fun h => h ▸ hy)    have sub : S \ (C.filter (Gᶜ.Adj z)) ⊆ S.filter (G.Adj z) := by      intro v hv      obtain ⟨hs,hn⟩ := Finset.mem_sdiff.mp hv      refine Finset.mem_filter.mpr ⟨hs,?_⟩      by_contra h      have hne : z ≠ v := hz.elim (fun he => he ▸ (hnS v hs).1.symm) (fun he => he ▸ (hnS v hs).2.symm)      exact hn (Finset.mem_filter.mpr ⟨hSC hs,hne,h⟩)    have hh := Finset.card_le_card sub    have hb := Finset.le_card_sdiff (C.filter (Gᶜ.Adj z)) S    have hm := hMiss z hzC; omega  obtain ⟨L,hL,hl⟩ := Finset.exists_subset_card_eq (le_trans (by omega : n ≤ n+m) (pool x (Or.inl rfl)))  have hr : m ≤ ((S.filter (G.Adj y)) \ L).card := by    have h := Finset.le_card_sdiff L (S.filter (G.Adj y))    have h' := pool y (Or.inr rfl); omega  obtain ⟨R,hR,hr'⟩ := Finset.exists_subset_card_eq hr  have hLS : L ⊆ S := hL.trans (Finset.filter_subset _ _)  have hRS : R ⊆ S := hR.trans (Finset.sdiff_subset.trans (Finset.filter_subset _ _))  exact ⟨L,R,hLS.trans hSC,hRS.trans hSC,Finset.disjoint_left.mpr (fun _ hl hr => (Finset.mem_sdiff.mp (hR hr)).2 hl),    hl,hr',fun h => (hnS _ (hLS h)).1 rfl,fun h => (hnS _ (hRS h)).1 rfl,    fun h => (hnS _ (hLS h)).2 rfl,fun h => (hnS _ (hRS h)).2 rfl,    fun _ h => (Finset.mem_filter.mp (hL h)).2,fun _ h => (Finset.mem_filter.mp (Finset.mem_sdiff.mp (hR h)).1).2⟩private def ds1310_dense_spanning_exact_copy {V : Type*} {G : SimpleGraph V} {p n m : ℕ}    (path : Fin (2*p) → V) (left : Fin n → V) (right : Fin m → V)    (hinj : Function.Injective (Sum.elim path (Sum.elim left right)))    (hp : ∀ i j : Fin (2*p), i.val+1=j.val → G.Adj (path i) (path j))    (hl : ∀ i : Fin (2*p), i.val=0 → ∀ l, G.Adj (path i) (left l))    (hr : ∀ i : Fin (2*p), i.val+1=2*p → ∀ l, G.Adj (path i) (right l)) :    (even_linked_double_star p n m).Copy G := by  let f := Sum.elim path (Sum.elim left right)  refine ⟨⟨f,?_⟩,hinj⟩  intro x y h  rcases h.2 with h | h <;>    rcases h with ⟨i,j,rfl,rfl,h|h⟩ | ⟨i,j,h,⟨rfl,rfl⟩|⟨rfl,rfl⟩⟩ | ⟨i,j,h,⟨rfl,rfl⟩|⟨rfl,rfl⟩⟩  all_goals dsimp [f]  all_goals first    | exact hp _ _ (by assumption)    | exact (hp _ _ (by assumption)).symm    | exact hl _ (by assumption) _    | exact (hl _ (by assumption) _).symm    | exact hr _ (by assumption) _    | exact (hr _ (by assumption) _).symmprivate theorem ds1310_dense_spanning_sum_inj {α β γ : Type*} {f : α → γ} {g : β → γ}    (hf : Function.Injective f) (hg : Function.Injective g) (h : ∀ i j, f i ≠ g j) :    Function.Injective (Sum.elim f g) := by  rintro (x|x) (y|y) he  · exact congrArg Sum.inl (hf he)  · exact (h x y he).elim  · exact (h y x he.symm).elim  · exact congrArg Sum.inr (hg he)theorem even_linked_double_star_dense_spanning {V : Type*} [DecidableEq V]    (G : SimpleGraph V) (p n m : ℕ) (hp : 2 ≤ p) (C : Finset V) (hc : C.card=2*p+n+m)    (hMiss : ∀ v ∈ C, (C.filter (Gᶜ.Adj v)).card ≤ p-2)    (x y : V) (hx : x ∈ C) (hy : y ∈ C) (hxy : x ≠ y) :    ∃ f : (even_linked_double_star p n m).Copy G, (∀ v, f v ∈ C) ∧      f (.inl ⟨0,by omega⟩)=x ∧ f (.inl ⟨2*p-1,by omega⟩)=y := by  classical  obtain ⟨L,R,hLC,hRC,hdis,hl,hr,hxl,hxr,hyl,hyr,hL,hR⟩ := ds1310_dense_spanning_dense_leaf_bank G p n m hp C hc hMiss x y hx hy hxy  let S := C \ (L∪R)  have hSC : S ⊆ C := Finset.sdiff_subset  have hN : Fintype.card ↥S=2*p := by    have hu := Finset.union_subset hLC hRC    simp only [Fintype.card_coe]    change (C \ (L ∪ R)).card = _    rw [Finset.card_sdiff_of_subset hu,Finset.card_union_of_disjoint hdis,hl,hr,hc]; omega  let X : ↥S := ⟨x,Finset.mem_sdiff.mpr ⟨hx,fun h => (Finset.mem_union.mp h).elim hxl hxr⟩⟩  let Y : ↥S := ⟨y,Finset.mem_sdiff.mpr ⟨hy,fun h => (Finset.mem_union.mp h).elim hyl hyr⟩⟩  let H := G.induce (S : Set V)  have miss (v : ↥S) : (Finset.univ.filter (Hᶜ.Adj v)).card ≤ p-2 := by    let e := Function.Embedding.subtype (fun z : V => z ∈ S)    have sub : (Finset.univ.filter (Hᶜ.Adj v)).map e ⊆ C.filter (Gᶜ.Adj v.val) := by      intro z hz; obtain ⟨j,hj,rfl⟩ := Finset.mem_map.mp hz      obtain ⟨hne,hna⟩ := (H.compl_adj _ _).mp (Finset.mem_filter.mp hj).2      exact Finset.mem_filter.mpr ⟨hSC j.property,fun h => hne (Subtype.ext h),hna⟩    simpa using (Finset.card_le_card sub).trans (hMiss _ (hSC v.property))  obtain ⟨P,ha,hb,hpath⟩ := ds1310_dense_spanning_dense_hamilton H p hp hN miss X Y (fun h => hxy (congrArg Subtype.val h))  let A := (Finset.equivFinOfCardEq hl).symm  let B := (Finset.equivFinOfCardEq hr).symm  let path (i) : V := (P i).val  let left (i) : V := (A i).val  let right (i) : V := (B i).val  have hi : Function.Injective (Sum.elim path (Sum.elim left right)) := by    apply ds1310_dense_spanning_sum_inj (Subtype.val_injective.comp P.injective)    · apply ds1310_dense_spanning_sum_inj (Subtype.val_injective.comp A.injective) (Subtype.val_injective.comp B.injective)      intro i j he      change (A i).val=(B j).val at he      exact Finset.disjoint_left.mp hdis (A i).property (he ▸ (B j).property)    · rintro i (j|j) he      · change (P i).val=(A j).val at he        exact (Finset.mem_sdiff.mp (P i).property).2 (Finset.mem_union_left _ (he ▸ (A j).property))      · change (P i).val=(B j).val at he        exact (Finset.mem_sdiff.mp (P i).property).2 (Finset.mem_union_right _ (he ▸ (B j).property))  have hfirst (i : Fin (2*p)) (h : i.val=0) : path i=x := by    have he : i=⟨0,by omega⟩ := Fin.ext h    rw [he]; exact congrArg Subtype.val ha  have hlast (i : Fin (2*p)) (h : i.val+1=2*p) : path i=y := by    have he : i=⟨2*p-1,by omega⟩ := Fin.ext (by dsimp; omega)    rw [he]; exact congrArg Subtype.val hb  let f := ds1310_dense_spanning_exact_copy path left right hi hpath (fun i h j => (hfirst i h) ▸ hL _ (A j).property)    (fun i h j => (hlast i h) ▸ hR _ (B j).property)  refine ⟨f,?_,hfirst _ rfl,hlast _ (by dsimp; omega)⟩  rintro (i|j|j)  · exact hSC (P i).property  · exact hLC (A j).property  · exact hRC (B j).property
See it in the graphDiscuss this resultChallenge it