AFTD Auto-Formalizing Theoretical Domains

tef1_nonexistence_nine_chores_three_agents

theoremverifiedformalization

There exists a cost matrix d : Fin 3 → Fin 9 → ℝ with all costs nonnegative (∀ i c, 0 ≤ d i c) such that for every allocation π : Fin 9 → Fin 3, π is not temporal EF1 (¬ is_tef1 3 9 d π).

Statement

theorem tef1_nonexistence_nine_chores_three_agents :
    ∃ (d : Fin 3 → Fin 9 → ℝ), (∀ i c, 0 ≤ d i c) ∧ ∀ π : Fin 9 → Fin 3, ¬ is_tef1 3 9 d π
Formalizes
arXiv:2611.25892 Thm. 3.1
Verified
22 Nov 2026
Axioms
Classical.choiceQuot.soundpropext
Built on 3
  • is_tef1An allocation π : Fin m → Fin n of m chores to n agents is temporal EF1 (TEF1) with respect to additive costs d : Fin n → Fin m → ℝ if for…
  • additive_valuationThe additive valuation with item values u: a bundle is worth the sum of its items' values.
  • chore_prefix_bundleFor an allocation π : Fin m → Fin n assigning m chores (identified with their arrival rounds in Fin m) to n agents in Fin n, agent i's…
Used by 1

Read back from the Lean

There exists a disutility profile d : Fin 3 → Fin 9 → ℝ of non-negative chore costs (i.e., 0 ≤ d i c for every agent i and chore c) such that no chore assignment π : Fin 9 → Fin 3 satisfies the prefix envy-freeness up to one chore property (is_tef1 3 9 d π).

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 establish that no temporal EF1 (TEF1) allocation exists for 9 chores and 3 agents, the proof constructs an explicit 3 × 9 non-negative integer cost matrix. It then defines a certified decision tree search: internal nodes branch on which agent receives the next chore, and leaves witness a round t and agent pair (i, j) where agent i envies agent j by more than the cost of any single chore in i's bundle. Lean's kernel verifies by reflexivity (`rfl`) that this finite tree covers all possible allocations without exception, and structural induction on the tree proves that every allocation violates temporal EF1.

  1. Definitions of the chore cost matrix, prefix valuations, counterexample witness finder, and decision tree verification procedure.

    A 3 × 9 integer cost matrix is specified giving the cost of each chore to each of the 3 agents. For partial allocations represented as lists of agent indices, prefix bundles and cumulative costs are defined. A leaf checker verifies whether a prefix exhibits a TEF1 violation between agents i and j at round t, and a tree generator recursively branches on assigning each chore to agent 0, 1, or 2, terminating a branch whenever a violation witness is found. Linear integer arithmetic (`omega`) verifies on line 27 that round indices stay within bounds.

    lines 1–54

    inductive tef1_nonexistence_nine_chores_three_agents_FailTree where
      | fail (t : Fin 9) (i j : Fin 3) : tef1_nonexistence_nine_chores_three_agents_FailTree
      | branch (f0 f1 f2 : tef1_nonexistence_nine_chores_three_agents_FailTree) : tef1_nonexistence_nine_chores_three_agents_FailTree
    
    def tef1_nonexistence_nine_chores_three_agents_d_costs : Fin 3 → Fin 9 → ℕ
      | 0 => ![2, 1, 2, 2, 8, 8, 4, 8, 8]
      | 1 => ![2, 3, 1, 3, 3, 5, 5, 5, 5]
      | 2 => ![5, 2, 1, 2, 10, 5, 10, 10, 10]
    
    def tef1_nonexistence_nine_chores_three_agents_d_real (i : Fin 3) (c : Fin 9) : ℝ :=
      (tef1_nonexistence_nine_chores_three_agents_d_costs i c : ℝ)
    
    def tef1_nonexistence_nine_chores_three_agents_p_bundle (p : List (Fin 3)) (t : Fin 9) (a : Fin 3) : Finset (Fin 9) :=
      Finset.filter (fun c : Fin 9 => c ≤ t ∧ p[c.val]? = some a) Finset.univ
    
    def tef1_nonexistence_nine_chores_three_agents_p_val (p : List (Fin 3)) (t : Fin 9) (i a : Fin 3) : ℕ :=
      ∑ c ∈ tef1_nonexistence_nine_chores_three_agents_p_bundle p t a, tef1_nonexistence_nine_chores_three_agents_d_costs i c
    
    def tef1_nonexistence_nine_chores_three_agents_check_leaf (p : List (Fin 3)) (t : Fin 9) (i j : Fin 3) : Bool :=
      decide (i ≠ j ∧ t.val < p.length ∧
        let vi := tef1_nonexistence_nine_chores_three_agents_p_val p t i i
        let vj := tef1_nonexistence_nine_chores_three_agents_p_val p t i j
        vj < vi ∧ ∀ c ∈ tef1_nonexistence_nine_chores_three_agents_p_bundle p t i, vj < vi - tef1_nonexistence_nine_chores_three_agents_d_costs i c)
    
    def tef1_nonexistence_nine_chores_three_agents_find_witness (p : List (Fin 3)) : Option (Fin 9 × Fin 3 × Fin 3) :=
      if h : p.length > 0 ∧ p.length ≤ 9 then
        let t : Fin 9 := ⟨p.length - 1, by omega⟩
        let pairs : List (Fin 3 × Fin 3) := [(0, 1), (0, 2), (1, 0), (1, 2), (2, 0), (2, 1)]
        pairs.findSome? (fun (i, j) => if tef1_nonexistence_nine_chores_three_agents_check_leaf p t i j then some (t, i, j) else none)
      else none
    
    def tef1_nonexistence_nine_chores_three_agents_make_tree : ℕ → List (Fin 3) → tef1_nonexistence_nine_chores_three_agents_FailTree
      | n, p =>
        match tef1_nonexistence_nine_chores_three_agents_find_witness p with
        | some (t, i, j) => tef1_nonexistence_nine_chores_three_agents_FailTree.fail t i j
        | none =>
          match n with
          | 0 => tef1_nonexistence_nine_chores_three_agents_FailTree.fail 0 0 1
          | n + 1 => tef1_nonexistence_nine_chores_three_agents_FailTree.branch
              (tef1_nonexistence_nine_chores_three_agents_make_tree n (p ++ [0]))
              (tef1_nonexistence_nine_chores_three_agents_make_tree n (p ++ [1]))
              (tef1_nonexistence_nine_chores_three_agents_make_tree n (p ++ [2]))
    
    def tef1_nonexistence_nine_chores_three_agents_the_tree : tef1_nonexistence_nine_chores_three_agents_FailTree :=
      tef1_nonexistence_nine_chores_three_agents_make_tree 9 []
    
    def tef1_nonexistence_nine_chores_three_agents_verify_tree : tef1_nonexistence_nine_chores_three_agents_FailTree → List (Fin 3) → Bool
      | tef1_nonexistence_nine_chores_three_agents_FailTree.fail t i j, p => tef1_nonexistence_nine_chores_three_agents_check_leaf p t i j
      | tef1_nonexistence_nine_chores_three_agents_FailTree.branch f0 f1 f2, p =>
        decide (p.length < 9) &&
        tef1_nonexistence_nine_chores_three_agents_verify_tree f0 (p ++ [0]) &&
        tef1_nonexistence_nine_chores_three_agents_verify_tree f1 (p ++ [1]) &&
        tef1_nonexistence_nine_chores_three_agents_verify_tree f2 (p ++ [2])
    
  2. An envious pair at some round that cannot be reconciled by removing any single chore certifies that an allocation is not temporal EF1.

    Assume for contradiction that the allocation π is TEF1. By definition, at any round t and for any pair of agents i ≠ j, agent i must either not envy j, or envy j by at most the cost of some chore in i's bundle. Since the witness provides that agent i strictly envies agent j and this strict envy persists even after subtracting the cost of any single chore in i's bundle, both disjuncts of the TEF1 definition are contradicted, which `linarith` refutes.

    lines 55–67

    lemma tef1_nonexistence_nine_chores_three_agents_not_is_tef1_of_witness {d : Fin 3 → Fin 9 → ℝ} {π : Fin 9 → Fin 3}
        (t : Fin 9) (i j : Fin 3) (hij : i ≠ j)
        (h1 : additive_valuation (d i) (chore_prefix_bundle π t j) < additive_valuation (d i) (chore_prefix_bundle π t i))
        (h2 : ∀ c ∈ chore_prefix_bundle π t i,
          additive_valuation (d i) (chore_prefix_bundle π t j) < additive_valuation (d i) (chore_prefix_bundle π t i) - d i c) :
        ¬ is_tef1 3 9 d π := by
      intro htef1
      have h := htef1 t i j hij
      rcases h with hle | ⟨c, hc, hle⟩
      · linarith
      · have hc2 := h2 c hc
        linarith
    
  3. The prefix bundle of an allocation π matches the prefix bundle computed from a list that agrees with π.

    By set extensionality, a chore c belongs to agent a's bundle up to round t under allocation π if and only if c ≤ t and π(c) = a. Since t < |p|, any such chore satisfies c < |p|, so looking up c in the prefix list p returns some(π(c)), which equals some(a) if and only if π(c) = a.

    lines 68–85

    uses Finset.mem_filter, Finset.mem_univ, true_and, lt_of_le_of_lt, Fin.le_iff_val_le_val.mp, Option.some.inj

    lemma tef1_nonexistence_nine_chores_three_agents_chore_prefix_bundle_eq_p_bundle
        (π : Fin 9 → Fin 3) (p : List (Fin 3)) (t : Fin 9) (a : Fin 3)
        (ht : t.val < p.length)
        (hp : ∀ c : Fin 9, c.val < p.length → p[c.val]? = some (π c)) :
        chore_prefix_bundle π t a = tef1_nonexistence_nine_chores_three_agents_p_bundle p t a := by
      ext c
      simp only [chore_prefix_bundle, tef1_nonexistence_nine_chores_three_agents_p_bundle, Finset.mem_filter, Finset.mem_univ, true_and]
      constructor
      · rintro ⟨hct, hcπ⟩
        have hclt : c.val < p.length := lt_of_le_of_lt (Fin.le_iff_val_le_val.mp hct) ht
        rw [hp c hclt, hcπ]
        exact ⟨hct, rfl⟩
      · rintro ⟨hct, hcp⟩
        have hclt : c.val < p.length := lt_of_le_of_lt (Fin.le_iff_val_le_val.mp hct) ht
        have := hp c hclt
        rw [hcp] at this
        exact ⟨hct, Option.some.inj this.symm⟩
    
  4. The real additive valuation of a prefix bundle equals the cast of its natural-valued valuation.

    Unfolding the definitions of additive valuation and bundle costs, the real sum of costs equals the integer sum cast to ℝ via `Nat.cast_sum`.

    lines 86–91

    uses Nat.cast_sum

    lemma tef1_nonexistence_nine_chores_three_agents_additive_valuation_eq_p_val (p : List (Fin 3)) (t : Fin 9) (i a : Fin 3) :
        additive_valuation (tef1_nonexistence_nine_chores_three_agents_d_real i) (tef1_nonexistence_nine_chores_three_agents_p_bundle p t a) =
        (tef1_nonexistence_nine_chores_three_agents_p_val p t i a : ℝ) := by
      simp only [additive_valuation, tef1_nonexistence_nine_chores_three_agents_d_real,
                 tef1_nonexistence_nine_chores_three_agents_p_val, Nat.cast_sum]
    
  5. If a < b - c in ℕ, then (a : ℝ) < (b : ℝ) - (c : ℝ).

    The inequality a < b - c implies c ≤ b. Using `Nat.cast_sub` to rewrite the difference of casts and `Nat.cast_lt.mpr`, the strict inequality on natural numbers lifts to the real numbers.

    lines 92–96

    uses Nat.cast_sub, Nat.cast_lt.mpr

    lemma tef1_nonexistence_nine_chores_three_agents_nat_cast_sub_lt {a b c : ℕ} (h : a < b - c) : (a : ℝ) < (b : ℝ) - (c : ℝ) := by
      have hcb : c ≤ b := by omega
      rw [← Nat.cast_sub hcb]
      exact Nat.cast_lt.mpr h
    
  6. Extending a prefix list by the true assignment of the next chore preserves agreement with the allocation.

    Let p agree with π on all chores strictly before |p|. Appending a = π(|p|) produces a list of length |p| + 1. For any chore c < |p| + 1, either c < |p| (in which case the entry is found in p and agrees with π by hypothesis) or c = |p| (in which case the entry is the newly appended element a = π(c)).

    lines 97–110

    uses List.length_append, List.length_singleton, lt_or_eq_of_le, Nat.le_of_lt_add_one, List.getElem?_append_left, Fin.ext, List.getElem?_append_right, le_refl

    lemma tef1_nonexistence_nine_chores_three_agents_prefix_extend (π : Fin 9 → Fin 3) (p : List (Fin 3)) (hlen : p.length < 9)
        (hp : ∀ c : Fin 9, c.val < p.length → p[c.val]? = some (π c))
        (a : Fin 3) (h_ext : π ⟨p.length, hlen⟩ = a) :
        ∀ c : Fin 9, c.val < (p ++ [a]).length → (p ++ [a])[c.val]? = some (π c) := by
      intro c hc
      rw [List.length_append, List.length_singleton] at hc
      rcases lt_or_eq_of_le (Nat.le_of_lt_add_one hc) with hlt | heq
      · rw [List.getElem?_append_left hlt]
        exact hp c hlt
      · have hc_eq : c = ⟨p.length, hlen⟩ := Fin.ext heq
        subst hc_eq
        rw [List.getElem?_append_right (le_refl _)]
        simp [h_ext]
    
  7. A verified leaf node in the failure tree soundly certifies that the allocation is not TEF1.

    For a leaf `fail t i j`, boolean verification confirms that round t < |p| witnesses a TEF1 violation between agents i and j in the prefix list p. By the bundle equivalence and valuation cast lemmas, this translates directly to the real prefix bundles under π, and `tef1_nonexistence_nine_chores_three_agents_not_is_tef1_of_witness` concludes that π cannot be TEF1.

    lines 111–134

    uses of_decide_eq_true, tef1_nonexistence_nine_chores_three_agents_chore_prefix_bundle_eq_p_bundle, tef1_nonexistence_nine_chores_three_agents_not_is_tef1_of_witness, tef1_nonexistence_nine_chores_three_agents_additive_valuation_eq_p_val, Nat.cast_lt.mpr, tef1_nonexistence_nine_chores_three_agents_nat_cast_sub_lt

    theorem tef1_nonexistence_nine_chores_three_agents_tree_sound
        (tree : tef1_nonexistence_nine_chores_three_agents_FailTree) (p : List (Fin 3))
        (h_tree : tef1_nonexistence_nine_chores_three_agents_verify_tree tree p = true)
        (π : Fin 9 → Fin 3)
        (hp : ∀ c : Fin 9, c.val < p.length → p[c.val]? = some (π c)) :
        ¬ is_tef1 3 9 tef1_nonexistence_nine_chores_three_agents_d_real π := by
      induction tree generalizing p with
      | fail t i j =>
        dsimp [tef1_nonexistence_nine_chores_three_agents_verify_tree] at h_tree
        have h_dec := of_decide_eq_true h_tree
        rcases h_dec with ⟨hij, ht, hlt, hall⟩
        have hbi := tef1_nonexistence_nine_chores_three_agents_chore_prefix_bundle_eq_p_bundle π p t i ht hp
        have hbj := tef1_nonexistence_nine_chores_three_agents_chore_prefix_bundle_eq_p_bundle π p t j ht hp
        apply tef1_nonexistence_nine_chores_three_agents_not_is_tef1_of_witness t i j hij
        · rw [hbi, hbj]
          repeat rw [tef1_nonexistence_nine_chores_three_agents_additive_valuation_eq_p_val]
          exact Nat.cast_lt.mpr hlt
        · intro c hc
          rw [hbi] at hc
          rw [hbi, hbj]
          repeat rw [tef1_nonexistence_nine_chores_three_agents_additive_valuation_eq_p_val]
          dsimp [tef1_nonexistence_nine_chores_three_agents_d_real]
          exact tef1_nonexistence_nine_chores_three_agents_nat_cast_sub_lt (hall c hc)
      | branch f0 f1 f2 ih0 ih1 ih2 =>
  8. A verified branch node in the failure tree soundly certifies that the allocation is not TEF1.

    For a branch node with subtrees f0, f1, f2, verification ensures that each child tree is verified on the prefix list extended by 0, 1, and 2, respectively. Case analysis on the assignment of the next chore π(|p|) ∈ {0, 1, 2} shows via the prefix extension lemma that the corresponding child tree's induction hypothesis applies, proving π is not TEF1 in all cases.

    lines 135–148

    uses Bool.and_eq_true, decide_eq_true_eq, tef1_nonexistence_nine_chores_three_agents_prefix_extend

        dsimp [tef1_nonexistence_nine_chores_three_agents_verify_tree] at h_tree
        simp only [Bool.and_eq_true, decide_eq_true_eq] at h_tree
        rcases h_tree with ⟨⟨⟨hlen, h0⟩, h1⟩, h2⟩
        let k : Fin 9 := ⟨p.length, hlen⟩
        generalize h : π k = val
        revert h
        fin_cases val
        · intro h
          exact ih0 (p ++ [0]) h0 (tef1_nonexistence_nine_chores_three_agents_prefix_extend π p hlen hp 0 h)
        · intro h
          exact ih1 (p ++ [1]) h1 (tef1_nonexistence_nine_chores_three_agents_prefix_extend π p hlen hp 1 h)
        · intro h
          exact ih2 (p ++ [2]) h2 (tef1_nonexistence_nine_chores_three_agents_prefix_extend π p hlen hp 2 h)
    
  9. The counterexample decision tree for 9 chores and 3 agents is successfully verified by computation.

    Evaluating `verify_tree the_tree []` reduces to `true` by reflexivity (`rfl`), as Lean's kernel computes the exhaustive search tree and verifies every leaf.

    lines 149–153

    theorem tef1_nonexistence_nine_chores_three_agents_the_tree_verified :
        tef1_nonexistence_nine_chores_three_agents_verify_tree tef1_nonexistence_nine_chores_three_agents_the_tree [] = true := by
      rfl
    
    /-- Nine chores suffice for nonexistence of a TEF1 allocation with three agents. -/
  10. There exists a non-negative cost matrix for 3 agents and 9 chores admitting no temporal EF1 allocation.

    The real cost matrix defined from the integer table has non-negative entries because each entry is a natural number cast to ℝ (`Nat.cast_nonneg`). For any allocation π, applying tree soundness to the verified decision tree starting at the empty prefix (which vacuously agrees with π) proves that π is not temporal EF1.

    lines 154–164

    uses Nat.cast_nonneg, tef1_nonexistence_nine_chores_three_agents_tree_sound, tef1_nonexistence_nine_chores_three_agents_the_tree_verified

    theorem tef1_nonexistence_nine_chores_three_agents :
        ∃ (d : Fin 3 → Fin 9 → ℝ), (∀ i c, 0 ≤ d i c) ∧ ∀ π : Fin 9 → Fin 3, ¬ is_tef1 3 9 d π := by
      use tef1_nonexistence_nine_chores_three_agents_d_real
      refine ⟨?_, ?_⟩
      · intros i c
        exact Nat.cast_nonneg _
      · intro π
        exact tef1_nonexistence_nine_chores_three_agents_tree_sound
          tef1_nonexistence_nine_chores_three_agents_the_tree []
          tef1_nonexistence_nine_chores_three_agents_the_tree_verified π
          (by intro c hc; contradiction)
Bool.and_eq_true
A boolean conjunction a && b is true if and only if both a and b are true.
decide_eq_true_eq
Evaluating a decidable proposition with `decide` equals true if and only if the proposition holds.
Fin.ext
Two elements of Fin n are equal if their underlying natural numbers are equal.
Fin.le_iff_val_le_val.mp
If a ≤ b in Fin n, then their underlying natural values satisfy a.val ≤ b.val.
Finset.mem_filter
An element is in a filtered finite set if and only if it is in the original set and satisfies the filter predicate.
Finset.mem_univ
Every element of a finite type belongs to the universal finite set `Finset.univ`.
le_refl
Ordering is reflexive: a ≤ a for any element a.
List.getElem?_append_left
Accessing index i in the concatenation l₁ ++ l₂ returns l₁[i]? whenever i < |l₁|.
List.getElem?_append_right
Accessing index i in the concatenation l₁ ++ l₂ returns l₂[i - |l₁|]? whenever i ≥ |l₁|.
List.length_append
The length of the concatenation of two lists is the sum of their lengths.
List.length_singleton
The length of a singleton list [a] is 1.
lt_of_le_of_lt
Strict inequality is transitive over weak inequality: if a ≤ b and b < c, then a < c.
lt_or_eq_of_le
In a partial order, a ≤ b implies a < b or a = b.
Nat.cast_lt.mpr
For natural numbers, a < b implies their real casts satisfy a < b.
Nat.cast_nonneg
The cast of any natural number into an ordered semiring is non-negative.
Nat.cast_sub
For natural numbers m ≤ n, the real cast of n - m equals the real cast of n minus the real cast of m.
Nat.cast_sum
The real cast of a sum of natural numbers equals the sum of their real casts.
Nat.le_of_lt_add_one
For natural numbers, n < m + 1 implies n ≤ m.
of_decide_eq_true
If `decide P = true`, then the proposition P holds.
Option.some.inj
The `some` constructor of Option is injective: some x = some y implies x = y.
tef1_nonexistence_nine_chores_three_agents_additive_valuation_eq_p_val
The real additive valuation of a prefix bundle equals the sum of integer costs cast to ℝ.
tef1_nonexistence_nine_chores_three_agents_chore_prefix_bundle_eq_p_bundle
The chore prefix bundle under allocation π equals the bundle computed from a list prefix p that agrees with π.
tef1_nonexistence_nine_chores_three_agents_nat_cast_sub_lt
If a < b - c in ℕ, then their real casts satisfy (a : ℝ) < (b : ℝ) - (c : ℝ).
tef1_nonexistence_nine_chores_three_agents_not_is_tef1_of_witness
An allocation is not TEF1 if at some prefix round t, agent i strictly envies agent j and no single chore removal from i's bundle can eliminate the envy.
tef1_nonexistence_nine_chores_three_agents_prefix_extend
Extending an allocation prefix list by assigning the next chore to its true recipient preserves agreement with the full allocation.
tef1_nonexistence_nine_chores_three_agents_the_tree_verified
The exhaustive counterexample search tree for 9 chores and 3 agents evaluates to verified at the empty prefix.
tef1_nonexistence_nine_chores_three_agents_tree_sound
Any allocation agreeing with the prefix at the root of a verified failure tree is not temporal EF1.
true_and
The proposition True ∧ P is logically equivalent to P.

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

inductive tef1_nonexistence_nine_chores_three_agents_FailTree where  | fail (t : Fin 9) (i j : Fin 3) : tef1_nonexistence_nine_chores_three_agents_FailTree  | branch (f0 f1 f2 : tef1_nonexistence_nine_chores_three_agents_FailTree) : tef1_nonexistence_nine_chores_three_agents_FailTreedef tef1_nonexistence_nine_chores_three_agents_d_costs : Fin 3 → Fin 9 → ℕ  | 0 => ![2, 1, 2, 2, 8, 8, 4, 8, 8]  | 1 => ![2, 3, 1, 3, 3, 5, 5, 5, 5]  | 2 => ![5, 2, 1, 2, 10, 5, 10, 10, 10]def tef1_nonexistence_nine_chores_three_agents_d_real (i : Fin 3) (c : Fin 9) : ℝ :=  (tef1_nonexistence_nine_chores_three_agents_d_costs i c : ℝ)def tef1_nonexistence_nine_chores_three_agents_p_bundle (p : List (Fin 3)) (t : Fin 9) (a : Fin 3) : Finset (Fin 9) :=  Finset.filter (fun c : Fin 9 => c ≤ t ∧ p[c.val]? = some a) Finset.univdef tef1_nonexistence_nine_chores_three_agents_p_val (p : List (Fin 3)) (t : Fin 9) (i a : Fin 3) : ℕ :=  ∑ c ∈ tef1_nonexistence_nine_chores_three_agents_p_bundle p t a, tef1_nonexistence_nine_chores_three_agents_d_costs i cdef tef1_nonexistence_nine_chores_three_agents_check_leaf (p : List (Fin 3)) (t : Fin 9) (i j : Fin 3) : Bool :=  decide (i ≠ j ∧ t.val < p.length ∧    let vi := tef1_nonexistence_nine_chores_three_agents_p_val p t i i    let vj := tef1_nonexistence_nine_chores_three_agents_p_val p t i j    vj < vi ∧ ∀ c ∈ tef1_nonexistence_nine_chores_three_agents_p_bundle p t i, vj < vi - tef1_nonexistence_nine_chores_three_agents_d_costs i c)def tef1_nonexistence_nine_chores_three_agents_find_witness (p : List (Fin 3)) : Option (Fin 9 × Fin 3 × Fin 3) :=  if h : p.length > 0 ∧ p.length ≤ 9 then    let t : Fin 9 := ⟨p.length - 1, by omega⟩    let pairs : List (Fin 3 × Fin 3) := [(0, 1), (0, 2), (1, 0), (1, 2), (2, 0), (2, 1)]    pairs.findSome? (fun (i, j) => if tef1_nonexistence_nine_chores_three_agents_check_leaf p t i j then some (t, i, j) else none)  else nonedef tef1_nonexistence_nine_chores_three_agents_make_tree : ℕ → List (Fin 3) → tef1_nonexistence_nine_chores_three_agents_FailTree  | n, p =>    match tef1_nonexistence_nine_chores_three_agents_find_witness p with    | some (t, i, j) => tef1_nonexistence_nine_chores_three_agents_FailTree.fail t i j    | none =>      match n with      | 0 => tef1_nonexistence_nine_chores_three_agents_FailTree.fail 0 0 1      | n + 1 => tef1_nonexistence_nine_chores_three_agents_FailTree.branch          (tef1_nonexistence_nine_chores_three_agents_make_tree n (p ++ [0]))          (tef1_nonexistence_nine_chores_three_agents_make_tree n (p ++ [1]))          (tef1_nonexistence_nine_chores_three_agents_make_tree n (p ++ [2]))def tef1_nonexistence_nine_chores_three_agents_the_tree : tef1_nonexistence_nine_chores_three_agents_FailTree :=  tef1_nonexistence_nine_chores_three_agents_make_tree 9 []def tef1_nonexistence_nine_chores_three_agents_verify_tree : tef1_nonexistence_nine_chores_three_agents_FailTree → List (Fin 3) → Bool  | tef1_nonexistence_nine_chores_three_agents_FailTree.fail t i j, p => tef1_nonexistence_nine_chores_three_agents_check_leaf p t i j  | tef1_nonexistence_nine_chores_three_agents_FailTree.branch f0 f1 f2, p =>    decide (p.length < 9) &&    tef1_nonexistence_nine_chores_three_agents_verify_tree f0 (p ++ [0]) &&    tef1_nonexistence_nine_chores_three_agents_verify_tree f1 (p ++ [1]) &&    tef1_nonexistence_nine_chores_three_agents_verify_tree f2 (p ++ [2])lemma tef1_nonexistence_nine_chores_three_agents_not_is_tef1_of_witness {d : Fin 3 → Fin 9 → ℝ} {π : Fin 9 → Fin 3}    (t : Fin 9) (i j : Fin 3) (hij : i ≠ j)    (h1 : additive_valuation (d i) (chore_prefix_bundle π t j) < additive_valuation (d i) (chore_prefix_bundle π t i))    (h2 : ∀ c ∈ chore_prefix_bundle π t i,      additive_valuation (d i) (chore_prefix_bundle π t j) < additive_valuation (d i) (chore_prefix_bundle π t i) - d i c) :    ¬ is_tef1 3 9 d π := by  intro htef1  have h := htef1 t i j hij  rcases h with hle | ⟨c, hc, hle⟩  · linarith  · have hc2 := h2 c hc    linarithlemma tef1_nonexistence_nine_chores_three_agents_chore_prefix_bundle_eq_p_bundle    (π : Fin 9 → Fin 3) (p : List (Fin 3)) (t : Fin 9) (a : Fin 3)    (ht : t.val < p.length)    (hp : ∀ c : Fin 9, c.val < p.length → p[c.val]? = some (π c)) :    chore_prefix_bundle π t a = tef1_nonexistence_nine_chores_three_agents_p_bundle p t a := by  ext c  simp only [chore_prefix_bundle, tef1_nonexistence_nine_chores_three_agents_p_bundle, Finset.mem_filter, Finset.mem_univ, true_and]  constructor  · rintro ⟨hct, hcπ⟩    have hclt : c.val < p.length := lt_of_le_of_lt (Fin.le_iff_val_le_val.mp hct) ht    rw [hp c hclt, hcπ]    exact ⟨hct, rfl⟩  · rintro ⟨hct, hcp⟩    have hclt : c.val < p.length := lt_of_le_of_lt (Fin.le_iff_val_le_val.mp hct) ht    have := hp c hclt    rw [hcp] at this    exact ⟨hct, Option.some.inj this.symm⟩lemma tef1_nonexistence_nine_chores_three_agents_additive_valuation_eq_p_val (p : List (Fin 3)) (t : Fin 9) (i a : Fin 3) :    additive_valuation (tef1_nonexistence_nine_chores_three_agents_d_real i) (tef1_nonexistence_nine_chores_three_agents_p_bundle p t a) =    (tef1_nonexistence_nine_chores_three_agents_p_val p t i a : ℝ) := by  simp only [additive_valuation, tef1_nonexistence_nine_chores_three_agents_d_real,             tef1_nonexistence_nine_chores_three_agents_p_val, Nat.cast_sum]lemma tef1_nonexistence_nine_chores_three_agents_nat_cast_sub_lt {a b c : ℕ} (h : a < b - c) : (a : ℝ) < (b : ℝ) - (c : ℝ) := by  have hcb : c ≤ b := by omega  rw [← Nat.cast_sub hcb]  exact Nat.cast_lt.mpr hlemma tef1_nonexistence_nine_chores_three_agents_prefix_extend (π : Fin 9 → Fin 3) (p : List (Fin 3)) (hlen : p.length < 9)    (hp : ∀ c : Fin 9, c.val < p.length → p[c.val]? = some (π c))    (a : Fin 3) (h_ext : π ⟨p.length, hlen⟩ = a) :    ∀ c : Fin 9, c.val < (p ++ [a]).length → (p ++ [a])[c.val]? = some (π c) := by  intro c hc  rw [List.length_append, List.length_singleton] at hc  rcases lt_or_eq_of_le (Nat.le_of_lt_add_one hc) with hlt | heq  · rw [List.getElem?_append_left hlt]    exact hp c hlt  · have hc_eq : c = ⟨p.length, hlen⟩ := Fin.ext heq    subst hc_eq    rw [List.getElem?_append_right (le_refl _)]    simp [h_ext]theorem tef1_nonexistence_nine_chores_three_agents_tree_sound    (tree : tef1_nonexistence_nine_chores_three_agents_FailTree) (p : List (Fin 3))    (h_tree : tef1_nonexistence_nine_chores_three_agents_verify_tree tree p = true)    (π : Fin 9 → Fin 3)    (hp : ∀ c : Fin 9, c.val < p.length → p[c.val]? = some (π c)) :    ¬ is_tef1 3 9 tef1_nonexistence_nine_chores_three_agents_d_real π := by  induction tree generalizing p with  | fail t i j =>    dsimp [tef1_nonexistence_nine_chores_three_agents_verify_tree] at h_tree    have h_dec := of_decide_eq_true h_tree    rcases h_dec with ⟨hij, ht, hlt, hall⟩    have hbi := tef1_nonexistence_nine_chores_three_agents_chore_prefix_bundle_eq_p_bundle π p t i ht hp    have hbj := tef1_nonexistence_nine_chores_three_agents_chore_prefix_bundle_eq_p_bundle π p t j ht hp    apply tef1_nonexistence_nine_chores_three_agents_not_is_tef1_of_witness t i j hij    · rw [hbi, hbj]      repeat rw [tef1_nonexistence_nine_chores_three_agents_additive_valuation_eq_p_val]      exact Nat.cast_lt.mpr hlt    · intro c hc      rw [hbi] at hc      rw [hbi, hbj]      repeat rw [tef1_nonexistence_nine_chores_three_agents_additive_valuation_eq_p_val]      dsimp [tef1_nonexistence_nine_chores_three_agents_d_real]      exact tef1_nonexistence_nine_chores_three_agents_nat_cast_sub_lt (hall c hc)  | branch f0 f1 f2 ih0 ih1 ih2 =>    dsimp [tef1_nonexistence_nine_chores_three_agents_verify_tree] at h_tree    simp only [Bool.and_eq_true, decide_eq_true_eq] at h_tree    rcases h_tree with ⟨⟨⟨hlen, h0⟩, h1⟩, h2⟩    let k : Fin 9 := ⟨p.length, hlen⟩    generalize h : π k = val    revert h    fin_cases val    · intro h      exact ih0 (p ++ [0]) h0 (tef1_nonexistence_nine_chores_three_agents_prefix_extend π p hlen hp 0 h)    · intro h      exact ih1 (p ++ [1]) h1 (tef1_nonexistence_nine_chores_three_agents_prefix_extend π p hlen hp 1 h)    · intro h      exact ih2 (p ++ [2]) h2 (tef1_nonexistence_nine_chores_three_agents_prefix_extend π p hlen hp 2 h)theorem tef1_nonexistence_nine_chores_three_agents_the_tree_verified :    tef1_nonexistence_nine_chores_three_agents_verify_tree tef1_nonexistence_nine_chores_three_agents_the_tree [] = true := by  rfl/-- Nine chores suffice for nonexistence of a TEF1 allocation with three agents. -/theorem tef1_nonexistence_nine_chores_three_agents :    ∃ (d : Fin 3 → Fin 9 → ℝ), (∀ i c, 0 ≤ d i c) ∧ ∀ π : Fin 9 → Fin 3, ¬ is_tef1 3 9 d π := by  use tef1_nonexistence_nine_chores_three_agents_d_real  refine ⟨?_, ?_⟩  · intros i c    exact Nat.cast_nonneg _  · intro π    exact tef1_nonexistence_nine_chores_three_agents_tree_sound      tef1_nonexistence_nine_chores_three_agents_the_tree []      tef1_nonexistence_nine_chores_three_agents_the_tree_verified π      (by intro c hc; contradiction)
See it in the graphDiscuss this resultChallenge it