AFTD Auto-Formalizing Theoretical Domains

digraph_residual_total_expansion_le_of_tournament

theoremverifiedformalization

For a finite type V with decidable equality and directed graphs G and H of type Digraph V with decidable adjacency relations, if G is oriented (digraph_is_oriented G), H is an extension of G (digraph_is_extension G H), and H is a tournament (digraph_is_tournament H), then the sum over all vertices v : V of digraph_expansion G (digraph_residual_at G H v) is at most the sum over all vertices v : V of digraph_expansion G (digraph_closed_out_nbr H {v}).

Statement

theorem digraph_residual_total_expansion_le_of_tournament {V : Type*} [Fintype V] [DecidableEq V]
    (G H : Digraph V) [DecidableRel G.Adj] [DecidableRel H.Adj]
    (hG : digraph_is_oriented G) (hH_ext : digraph_is_extension G H)
    (hH_tourn : digraph_is_tournament H) :
    ∑ v : V, digraph_expansion G (digraph_residual_at G H v) ≤
      ∑ v : V, digraph_expansion G (digraph_closed_out_nbr H {v})
Formalizes
arXiv:2611.32872 Lemma 2
Verified
26 Nov 2026
Axioms
Classical.choiceQuot.soundpropext
Built on 9
  • digraph_closed_out_nbrFor a finite directed graph G and a vertex subset X, the closed out-neighborhood N_G^+[X] is the union of X and all vertices y such that…
  • digraph_expansionFor a finite directed graph G and a vertex subset X, the expansion b(X) is the cardinality of the out-boundary ∂^+ X.
  • digraph_is_extensionA directed graph H is an extension of a directed graph G if H is oriented and G is a subgraph of H.
  • digraph_residual_atFor a finite type V with decidable equality, directed graphs G and H of type Digraph V with decidable adjacency relations, and a vertex v…
  • digraph_is_tournamentA digraph is a tournament when it has no loops and between any two distinct vertices there is exactly one arc.
  • digraph_is_orientedA digraph G : Digraph V on vertex type V is oriented (digraph_is_oriented G) if for all vertices u v : V, G.Adj u v implies ¬ G.Adj v u.
  • digraph_residual_subset_out_nbrFor a finite type V with decidable equality, directed graphs G and H of type Digraph V with decidable adjacency relations, and any vertex…
  • digraph_residual_contains_selfFor a finite type V with decidable equality, directed graphs G and H of type Digraph V with decidable adjacency relations, if G ≤ H, then…
  • digraph_out_boundaryFor a finite directed graph G and a vertex subset X, the out-boundary ∂^+ X is the set difference between the closed out-neighborhood…

Read back from the Lean

Let V be a finite type with decidable equality, and let G and H be directed graphs on V with decidable adjacency relations. Assume: 1. G is oriented (for all u, v : V, if G.Adj u v, then ¬ G.Adj v u). 2. H is an extension of G (that is, H is oriented and G ≤ H, so every edge of G is an edge of H). 3. H is a tournament (for all x : V, ¬ H.Adj x x, and for all distinct x, y : V, H.Adj x y ↔ ¬ H.Adj y x). Then the sum over all v : V of the expansion in G of the residual set digraph_residual_at G H v is less than or equal to the sum over all v : V of the expansion in G of the closed out-neighborhood of {v} in H.

Written by a model that saw only the Lean, never the English above. If the two disagree, that is worth a challenge.

The proof, explained

To bound the sum of the residual out-expansions by the sum of the closed neighborhood out-expansions in a tournament extension H of an oriented graph G, the proof expresses each sum as the cardinality of a set of pairs: s = {(v, y) | y ∈ ∂_G^+(R_v)} and t = {(v, y) | y ∈ ∂_G^+(N_H^+[v])}. It then constructs an explicit injection f from s to t that maps (v, y) to (v, y) if y →_H v and to (y, v) otherwise. Injectivity holds because a collision would force two vertices to mutually lie in each other's residual out-boundary, which tournament and orientation properties rule out.

  1. A vertex y is in the out-boundary of X iff y ∉ X and y has an in-neighbor in X.

    Unfolding out-boundary and closed neighborhood, y ∈ N^+[X] \ X means y ∉ X and (y ∈ X or y has an in-neighbor in X). Since y ∉ X, the first disjunct is impossible, leaving exactly y ∉ X and the existence of an in-neighbor in X.

    lines 4–11

      simp only [digraph_out_boundary, digraph_closed_out_nbr, Finset.mem_sdiff, Finset.mem_union, Finset.mem_filter, Finset.mem_univ,
        true_and]
      constructor
      · rintro ⟨h1 | ⟨x, hx, hadj⟩, h2⟩
        · exact (h2 h1).elim
        · exact ⟨h2, x, hx, hadj⟩
      · rintro ⟨h2, x, hx, hadj⟩
        exact ⟨Or.inr ⟨x, hx, hadj⟩, h2⟩
  2. A vertex y is in the closed out-neighborhood of {v} iff y = v or there is an edge from v to y.

    Unfolding closed out-neighborhood of {v}, y is either in {v} (meaning y = v) or an out-neighbor of some vertex in {v} (meaning an out-neighbor of v).

    lines 16–23

      simp only [digraph_closed_out_nbr, Finset.mem_union, Finset.mem_singleton, Finset.mem_filter, Finset.mem_univ, true_and]
      constructor
      · rintro (rfl | ⟨x, rfl, hadj⟩)
        · left; rfl
        · right; exact hadj
      · rintro (rfl | hadj)
        · left; rfl
        · right; exact ⟨v, rfl, hadj⟩
  3. Unpacking the boundary hypotheses for a and b and eliminating trivial disjuncts.

    Assuming b is in the out-boundary of R_a and a is in the out-boundary of R_b, we unfold the boundary definitions. Since b ∉ R_a and a ∉ R_b, the disjuncts asserting membership in the residual sets are immediately contradictory, leaving witnesses x ∈ R_a with an edge x → b and z ∈ R_b with an edge z → a.

    lines 33–40

      have hGH : G ≤ H := hH_ext.2
      have hH_or : digraph_is_oriented H := hH_ext.1
      simp only [digraph_out_boundary, digraph_closed_out_nbr, Finset.mem_sdiff, Finset.mem_union, Finset.mem_filter, Finset.mem_univ,
        true_and] at ha hb
      rcases ha with ⟨h1a | ⟨x, hx_Ra, hxb⟩, hnb_Ra⟩
      · exact (hnb_Ra h1a).elim
      rcases hb with ⟨h1b | ⟨z, hz_Rb, hza⟩, hna_Rb⟩
      · exact (hna_Rb h1b).elim
  4. Deducing that z and x must either be equal or have edges between them in H.

    By definition of the residual set R_a, any in-neighbor of a in G must be equal to x or have an H-edge to x; since z →_G a, z = x or z →_H x. Symmetrically, since x →_G b and z ∈ R_b, x = z or x →_H z.

    lines 41–48

      have hx_spec : ∀ u, u = a ∨ G.Adj u a → u = x ∨ H.Adj u x := by
        simp only [digraph_residual_at, Finset.mem_filter, Finset.mem_univ, true_and] at hx_Ra
        exact hx_Ra
      have hz_spec : ∀ u, u = b ∨ G.Adj u b → u = z ∨ H.Adj u z := by
        simp only [digraph_residual_at, Finset.mem_filter, Finset.mem_univ, true_and] at hz_Rb
        exact hz_Rb
      have hzx_or := hx_spec z (Or.inr hza)
      have hxz_or := hz_spec x (Or.inr hxb)
  5. The case z = x leads to a contradiction.

    If z = x, the edge z →_G a implies x →_H a. But x ∈ R_a ⊆ N_H^+[a], so either x = a (contradicting irreflexivity of the tournament H) or a →_H x (contradicting orientation of H).

    lines 49–58

      by_cases hzx : z = x
      · have hHxa : H.Adj x a := by
          rw [← hzx]
          exact hGH hza
        have hx_Ha : x ∈ digraph_closed_out_nbr H {a} :=
          digraph_residual_subset_out_nbr G H a hx_Ra
        simp only [digraph_closed_out_nbr, Finset.mem_union, Finset.mem_singleton, Finset.mem_filter, Finset.mem_univ, true_and] at hx_Ha
        rcases hx_Ha with rfl | ⟨_, rfl, hHax⟩
        · exact hH_tourn.1 _ hHxa
        · exact hH_or _ _ hHxa hHax
  6. The case z ≠ x leads to a contradiction.

    If z ≠ x, the disjunctions force both z →_H x and x →_H z, which contradicts the orientation of H. This concludes the proof that a and b cannot mutually lie in each other's residual out-boundaries.

    lines 59–63

      · rcases hzx_or with rfl | hHzx
        · exact (hzx rfl).elim
        · rcases hxz_or with rfl | hHxz
          · exact (hzx rfl.symm).elim
          · exact hH_or z x hHzx hHxz
  7. Setup and non-equality of endpoints.

    Extracting that H is oriented and G ≤ H, we unpack y ∈ ∂_G^+(R_v) into y ∉ R_v and the existence of x ∈ R_v with x →_G y. Since v ∈ R_v and y ∉ R_v, we have v ≠ y.

    lines 75–82

      have hH_or : digraph_is_oriented H := hH_ext.1
      have hGH : G ≤ H := hH_ext.2
      rw [digraph_residual_total_expansion_le_of_tournament_mem_digraph_out_boundary_iff] at hy
      rcases hy with ⟨hny_Rv, x, hx_Rv, hxy⟩
      have hv_Rv : v ∈ digraph_residual_at G H v := digraph_residual_contains_self G H hGH v
      have hvy : v ≠ y := by
        rintro rfl
        exact hny_Rv hv_Rv
  8. When there is an edge y →_H v, y belongs to the out-boundary of N_H^+[v].

    Since x ∈ R_v ⊆ N_H^+[v], x provides the required G-edge x →_G y from N_H^+[v]. Furthermore, y ∉ N_H^+[v] because y = v contradicts irreflexivity of H and v →_H y contradicts orientation of H given y →_H v.

    lines 83–90

      split_ifs with hHyv
      · -- Case 1: H.Adj y v
        rw [digraph_residual_total_expansion_le_of_tournament_mem_digraph_out_boundary_iff]
        refine ⟨?_, x, digraph_residual_subset_out_nbr G H v hx_Rv, hxy⟩
        rw [digraph_residual_total_expansion_le_of_tournament_mem_digraph_closed_out_nbr_singleton]
        rintro (rfl | hHvy)
        · exact hH_tourn.1 _ hHyv
        · exact hH_or y v hHyv hHvy
  9. When there is no edge y →_H v, tournament completeness gives v →_H y, and negating y ∈ R_v yields an in-neighbor u of v.

    By tournament completeness on v ≠ y, ¬(y →_H v) implies v →_H y. Since y ∉ R_v, there must exist some u such that u ∈ N_G^-[v] but u ∉ N_H^-[y]. If u = v, this contradicts v →_H y, so u must be a proper G-in-neighbor u →_G v with u ≠ y. Then completeness gives y →_H u.

    lines 91–108

      · -- Case 2: ¬ H.Adj y v
        have hHvy : H.Adj v y := by
          have ht := hH_tourn.2 v y hvy
          tauto
        simp only [digraph_residual_at, Finset.mem_filter, Finset.mem_univ, true_and] at hny_Rv
        have h_ex : ∃ u, (u = v ∨ G.Adj u v) ∧ u ≠ y ∧ ¬ H.Adj u y := by
          by_contra hc
          apply hny_Rv
          intro u hu
          by_contra hc2
          push Not at hc2
          exact hc ⟨u, hu, hc2⟩
        rcases h_ex with ⟨u, hu_in, huy, hHuy⟩
        rcases hu_in with rfl | hGuv
        · exact (hHuy hHvy).elim
        have hHyu : H.Adj y u := by
          have ht := hH_tourn.2 y u (Ne.symm huy)
          tauto
  10. Verifying that v belongs to the out-boundary of N_H^+[y].

    Since y →_H u, u is in N_H^+[y], and u →_G v provides the required boundary edge. Moreover v ∉ N_H^+[y] because v = y is false and y →_H v contradicts our case assumption.

    lines 109–117

        rw [digraph_residual_total_expansion_le_of_tournament_mem_digraph_out_boundary_iff]
        refine ⟨?_, u, ?_, hGuv⟩
        · rw [digraph_residual_total_expansion_le_of_tournament_mem_digraph_closed_out_nbr_singleton]
          rintro (rfl | hHyv')
          · exact hvy rfl
          · exact hHyv hHyv'
        · rw [digraph_residual_total_expansion_le_of_tournament_mem_digraph_closed_out_nbr_singleton]
          right
          exact hHyu
  11. Summing fiber cardinalities equals the cardinality of the filtered product set.

    Expressing the cardinality of each fiber F(v) as a sum of indicator functions and exchanging the order of summation over the product type V × V shows that the sum of |F(v)| over all v equals the number of pairs (v, y) with y ∈ F(v).

    lines 122–129

      rw [Finset.card_filter]
      rw [Fintype.sum_prod_type]
      simp_rw [← Finset.card_filter]
      congr 1
      ext v
      congr 1
      ext y
      simp
  12. The sum inequality reduces to comparing the sizes of two sets of pairs, connected by a map f.

    Unfolding the definition of expansion and applying the double-counting lemma, the target inequality becomes |s| ≤ |t|, where s consists of pairs (v, y) with y ∈ ∂_G^+(R_v) and t consists of pairs (v, y) with y ∈ ∂_G^+(N_H^+[v]). We define f(v, y) to be (v, y) if y →_H v and (y, v) otherwise.

    lines 138–143

      unfold digraph_expansion
      rw [digraph_residual_total_expansion_le_of_tournament_card_filter_prod_eq_sum,
          digraph_residual_total_expansion_le_of_tournament_card_filter_prod_eq_sum]
      let s : Finset (V × V) := (Finset.univ : Finset (V × V)).filter (fun p => p.2 ∈ digraph_out_boundary G (digraph_residual_at G H p.1))
      let t : Finset (V × V) := (Finset.univ : Finset (V × V)).filter (fun p => p.2 ∈ digraph_out_boundary G (digraph_closed_out_nbr H {p.1}))
      let f : (V × V) → (V × V) := fun (v, y) => if H.Adj y v then (v, y) else (y, v)
  13. The map f sends s into t.

    For any pair (v, y) ∈ s, the maps-to helper established that if y →_H v then y ∈ ∂_G^+(N_H^+[v]), so (v, y) ∈ t; otherwise v ∈ ∂_G^+(N_H^+[y]), so (y, v) ∈ t. In both cases, f(v, y) ∈ t.

    lines 144–155

      have h_maps : Set.MapsTo f ↑s ↑t := by
        rintro ⟨v, y⟩ hp
        simp only [s, Finset.mem_coe, Finset.mem_filter, Finset.mem_univ, true_and] at hp
        simp only [f]
        have hm := digraph_residual_total_expansion_le_of_tournament_maps_to_helper G H hH_ext hH_tourn v y hp
        split_ifs with hHyv
        · simp only [t, Finset.mem_coe, Finset.mem_filter, Finset.mem_univ, true_and]
          rw [if_pos hHyv] at hm
          exact hm
        · simp only [t, Finset.mem_coe, Finset.mem_filter, Finset.mem_univ, true_and]
          rw [if_neg hHyv] at hm
          exact hm
  14. The map f is injective on s.

    Given two pairs in s with f(v₁, y₁) = f(v₂, y₂), if both had the same orientation condition then the pairs are equal. If one condition was true and the other false, then (v₁, y₁) = (y₂, v₂), meaning y₁ ∈ ∂_G^+(R_{v₁}) and v₁ ∈ ∂_G^+(R_{y₁}). But the no-collision helper proved this is impossible, ruling out mixed cases.

    lines 156–174

      have h_inj : Set.InjOn f ↑s := by
        rintro ⟨v1, y1⟩ hp1 ⟨v2, y2⟩ hp2 heq
        simp only [s, Finset.mem_coe, Finset.mem_filter, Finset.mem_univ, true_and] at hp1 hp2
        simp only [f] at heq
        split_ifs at heq with h1 h2
        · injection heq with hv hy
          rw [hv, hy]
        · injection heq with hv hy
          have h_False := digraph_residual_total_expansion_le_of_tournament_no_collision_helper G H hH_ext hH_tourn v1 y1 hp1 (by
            rw [hv, hy]
            exact hp2)
          exact h_False.elim
        · injection heq with hv hy
          have h_False := digraph_residual_total_expansion_le_of_tournament_no_collision_helper G H hH_ext hH_tourn v2 y2 hp2 (by
            rw [← hv, ← hy]
            exact hp1)
          exact h_False.elim
        · injection heq with hv hy
          rw [hv, hy]
  15. The sum of residual expansions is bounded by the sum of neighborhood expansions.

    Since f is an injection from the finite set s to t, |s| ≤ |t|, which yields the desired inequality.

    line 175

    uses Finset.card_le_card_of_injOn

      exact Finset.card_le_card_of_injOn f h_maps h_inj
Finset.card_le_card_of_injOn
If f maps a finite set s into a finite set t and is injective on s, then |s| ≤ |t|.

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

theorem digraph_residual_total_expansion_le_of_tournament_mem_digraph_out_boundary_iff {V : Type*} [Fintype V] [DecidableEq V]    (G : Digraph V) [DecidableRel G.Adj] (X : Finset V) (y : V) :    y ∈ digraph_out_boundary G X ↔ y ∉ X ∧ ∃ x ∈ X, G.Adj x y := by  simp only [digraph_out_boundary, digraph_closed_out_nbr, Finset.mem_sdiff, Finset.mem_union, Finset.mem_filter, Finset.mem_univ,    true_and]  constructor  · rintro ⟨h1 | ⟨x, hx, hadj⟩, h2⟩    · exact (h2 h1).elim    · exact ⟨h2, x, hx, hadj⟩  · rintro ⟨h2, x, hx, hadj⟩    exact ⟨Or.inr ⟨x, hx, hadj⟩, h2⟩theorem digraph_residual_total_expansion_le_of_tournament_mem_digraph_closed_out_nbr_singleton {V : Type*} [Fintype V] [DecidableEq V]    (H : Digraph V) [DecidableRel H.Adj] (v y : V) :    y ∈ digraph_closed_out_nbr H {v} ↔ y = v ∨ H.Adj v y := by  simp only [digraph_closed_out_nbr, Finset.mem_union, Finset.mem_singleton, Finset.mem_filter, Finset.mem_univ, true_and]  constructor  · rintro (rfl | ⟨x, rfl, hadj⟩)    · left; rfl    · right; exact hadj  · rintro (rfl | hadj)    · left; rfl    · right; exact ⟨v, rfl, hadj⟩theorem digraph_residual_total_expansion_le_of_tournament_no_collision_helper {V : Type*} [Fintype V] [DecidableEq V]    (G H : Digraph V) [DecidableRel G.Adj] [DecidableRel H.Adj]    (hH_ext : digraph_is_extension G H)    (hH_tourn : digraph_is_tournament H)    (a b : V)    (ha : b ∈ digraph_out_boundary G (digraph_residual_at G H a))    (hb : a ∈ digraph_out_boundary G (digraph_residual_at G H b)) :    False := by  have hGH : G ≤ H := hH_ext.2  have hH_or : digraph_is_oriented H := hH_ext.1  simp only [digraph_out_boundary, digraph_closed_out_nbr, Finset.mem_sdiff, Finset.mem_union, Finset.mem_filter, Finset.mem_univ,    true_and] at ha hb  rcases ha with ⟨h1a | ⟨x, hx_Ra, hxb⟩, hnb_Ra⟩  · exact (hnb_Ra h1a).elim  rcases hb with ⟨h1b | ⟨z, hz_Rb, hza⟩, hna_Rb⟩  · exact (hna_Rb h1b).elim  have hx_spec : ∀ u, u = a ∨ G.Adj u a → u = x ∨ H.Adj u x := by    simp only [digraph_residual_at, Finset.mem_filter, Finset.mem_univ, true_and] at hx_Ra    exact hx_Ra  have hz_spec : ∀ u, u = b ∨ G.Adj u b → u = z ∨ H.Adj u z := by    simp only [digraph_residual_at, Finset.mem_filter, Finset.mem_univ, true_and] at hz_Rb    exact hz_Rb  have hzx_or := hx_spec z (Or.inr hza)  have hxz_or := hz_spec x (Or.inr hxb)  by_cases hzx : z = x  · have hHxa : H.Adj x a := by      rw [← hzx]      exact hGH hza    have hx_Ha : x ∈ digraph_closed_out_nbr H {a} :=      digraph_residual_subset_out_nbr G H a hx_Ra    simp only [digraph_closed_out_nbr, Finset.mem_union, Finset.mem_singleton, Finset.mem_filter, Finset.mem_univ, true_and] at hx_Ha    rcases hx_Ha with rfl | ⟨_, rfl, hHax⟩    · exact hH_tourn.1 _ hHxa    · exact hH_or _ _ hHxa hHax  · rcases hzx_or with rfl | hHzx    · exact (hzx rfl).elim    · rcases hxz_or with rfl | hHxz      · exact (hzx rfl.symm).elim      · exact hH_or z x hHzx hHxztheorem digraph_residual_total_expansion_le_of_tournament_maps_to_helper {V : Type*} [Fintype V] [DecidableEq V]    (G H : Digraph V) [DecidableRel G.Adj] [DecidableRel H.Adj]    (hH_ext : digraph_is_extension G H)    (hH_tourn : digraph_is_tournament H)    (v y : V)    (hy : y ∈ digraph_out_boundary G (digraph_residual_at G H v)) :    if H.Adj y v then      y ∈ digraph_out_boundary G (digraph_closed_out_nbr H {v})    else      v ∈ digraph_out_boundary G (digraph_closed_out_nbr H {y}) := by  have hH_or : digraph_is_oriented H := hH_ext.1  have hGH : G ≤ H := hH_ext.2  rw [digraph_residual_total_expansion_le_of_tournament_mem_digraph_out_boundary_iff] at hy  rcases hy with ⟨hny_Rv, x, hx_Rv, hxy⟩  have hv_Rv : v ∈ digraph_residual_at G H v := digraph_residual_contains_self G H hGH v  have hvy : v ≠ y := by    rintro rfl    exact hny_Rv hv_Rv  split_ifs with hHyv  · -- Case 1: H.Adj y v    rw [digraph_residual_total_expansion_le_of_tournament_mem_digraph_out_boundary_iff]    refine ⟨?_, x, digraph_residual_subset_out_nbr G H v hx_Rv, hxy⟩    rw [digraph_residual_total_expansion_le_of_tournament_mem_digraph_closed_out_nbr_singleton]    rintro (rfl | hHvy)    · exact hH_tourn.1 _ hHyv    · exact hH_or y v hHyv hHvy  · -- Case 2: ¬ H.Adj y v    have hHvy : H.Adj v y := by      have ht := hH_tourn.2 v y hvy      tauto    simp only [digraph_residual_at, Finset.mem_filter, Finset.mem_univ, true_and] at hny_Rv    have h_ex : ∃ u, (u = v ∨ G.Adj u v) ∧ u ≠ y ∧ ¬ H.Adj u y := by      by_contra hc      apply hny_Rv      intro u hu      by_contra hc2      push Not at hc2      exact hc ⟨u, hu, hc2⟩    rcases h_ex with ⟨u, hu_in, huy, hHuy⟩    rcases hu_in with rfl | hGuv    · exact (hHuy hHvy).elim    have hHyu : H.Adj y u := by      have ht := hH_tourn.2 y u (Ne.symm huy)      tauto    rw [digraph_residual_total_expansion_le_of_tournament_mem_digraph_out_boundary_iff]    refine ⟨?_, u, ?_, hGuv⟩    · rw [digraph_residual_total_expansion_le_of_tournament_mem_digraph_closed_out_nbr_singleton]      rintro (rfl | hHyv')      · exact hvy rfl      · exact hHyv hHyv'    · rw [digraph_residual_total_expansion_le_of_tournament_mem_digraph_closed_out_nbr_singleton]      right      exact hHyutheorem digraph_residual_total_expansion_le_of_tournament_card_filter_prod_eq_sum {V : Type*} [Fintype V] [DecidableEq V]    (F : V → Finset V) :    ∑ v : V, (F v).card = ((Finset.univ : Finset (V × V)).filter (fun p => p.2 ∈ F p.1)).card := by  rw [Finset.card_filter]  rw [Fintype.sum_prod_type]  simp_rw [← Finset.card_filter]  congr 1  ext v  congr 1  ext y  simp/-- Residual Total Expansion Bound for Tournament Extensions of Oriented Graphs (Lemma 2). -/theorem digraph_residual_total_expansion_le_of_tournament {V : Type*} [Fintype V] [DecidableEq V]    (G H : Digraph V) [DecidableRel G.Adj] [DecidableRel H.Adj]    (hG : digraph_is_oriented G) (hH_ext : digraph_is_extension G H)    (hH_tourn : digraph_is_tournament H) :    ∑ v : V, digraph_expansion G (digraph_residual_at G H v) ≤      ∑ v : V, digraph_expansion G (digraph_closed_out_nbr H {v}) := by  unfold digraph_expansion  rw [digraph_residual_total_expansion_le_of_tournament_card_filter_prod_eq_sum,      digraph_residual_total_expansion_le_of_tournament_card_filter_prod_eq_sum]  let s : Finset (V × V) := (Finset.univ : Finset (V × V)).filter (fun p => p.2 ∈ digraph_out_boundary G (digraph_residual_at G H p.1))  let t : Finset (V × V) := (Finset.univ : Finset (V × V)).filter (fun p => p.2 ∈ digraph_out_boundary G (digraph_closed_out_nbr H {p.1}))  let f : (V × V) → (V × V) := fun (v, y) => if H.Adj y v then (v, y) else (y, v)  have h_maps : Set.MapsTo f ↑s ↑t := by    rintro ⟨v, y⟩ hp    simp only [s, Finset.mem_coe, Finset.mem_filter, Finset.mem_univ, true_and] at hp    simp only [f]    have hm := digraph_residual_total_expansion_le_of_tournament_maps_to_helper G H hH_ext hH_tourn v y hp    split_ifs with hHyv    · simp only [t, Finset.mem_coe, Finset.mem_filter, Finset.mem_univ, true_and]      rw [if_pos hHyv] at hm      exact hm    · simp only [t, Finset.mem_coe, Finset.mem_filter, Finset.mem_univ, true_and]      rw [if_neg hHyv] at hm      exact hm  have h_inj : Set.InjOn f ↑s := by    rintro ⟨v1, y1⟩ hp1 ⟨v2, y2⟩ hp2 heq    simp only [s, Finset.mem_coe, Finset.mem_filter, Finset.mem_univ, true_and] at hp1 hp2    simp only [f] at heq    split_ifs at heq with h1 h2    · injection heq with hv hy      rw [hv, hy]    · injection heq with hv hy      have h_False := digraph_residual_total_expansion_le_of_tournament_no_collision_helper G H hH_ext hH_tourn v1 y1 hp1 (by        rw [hv, hy]        exact hp2)      exact h_False.elim    · injection heq with hv hy      have h_False := digraph_residual_total_expansion_le_of_tournament_no_collision_helper G H hH_ext hH_tourn v2 y2 hp2 (by        rw [← hv, ← hy]        exact hp1)      exact h_False.elim    · injection heq with hv hy      rw [hv, hy]  exact Finset.card_le_card_of_injOn f h_maps h_inj
See it in the graphDiscuss this resultChallenge it