AFTD Auto-Formalizing Theoretical Domains

matroid_indep_query_tree_eval_eq_of_agree

theoremverified

On an oracle o, an independence-query tree T asks at most depth(T) sets: there is a family L of at most depth(T) finite sets such that every oracle agreeing with o on L gives the same output.

Statement

theorem matroid_indep_query_tree_eval_eq_of_agree {α : Type*} (o : Finset α → Bool) (T : MatroidIndepQueryTree α) :
    ∃ L : Finset (Finset α), L.card ≤ T.depth ∧
      ∀ o' : Finset α → Bool, (∀ S ∈ L, o' S = o S) → T.eval o' = T.eval o
Source
Sanity lemma / helper for the statements of OP-1998 (arXiv:2611.23624 (Matroid Connectedness and Component Decomposition: Breaking the Quadratic Barrier))
Verified
19 Nov 2026
Axioms
Classical.choiceQuot.soundpropext
Built on 3
  • MatroidIndepQueryTreeA deterministic independence-query algorithm on a ground set α, as a rooted binary decision tree: a leaf leaf b outputs the Boolean b;…
  • MatroidIndepQueryTree.depthThe depth (height) of an independence-query decision tree on a ground set α, a natural number defined by recursion on the tree: a leaf…
  • MatroidIndepQueryTree.evalThe Boolean output of an independence-query decision tree T on a ground set α when the queries are answered by an oracle o : Finset α →…
Used by 2

The proof, explained

The proof proceeds by structural induction on the query tree T. For a leaf node, no queries are needed, so the empty set of queries L = ∅ trivially works. For a query node on set S with subtrees no and yes, the induction hypothesis gives query families Ln and Ly bounded by the depths of the subtrees. Depending on whether the oracle value o(S) is true or false, we choose {S} ∪ Ly or {S} ∪ Ln; in both cases, the size increases by at most 1 (staying within depth(T)), and any oracle agreeing on this set follows the same branch at S and evaluates identically on the corresponding subtree by induction.

  1. The theorem holds when T is a leaf node leaf b.

    We enable classical logic and proceed by structural induction on T. For a leaf node T = leaf b, the evaluation is constantly b for every oracle, so no queries are required: we choose the empty set L = ∅. Its cardinality is 0, which is at most depth(leaf b) = 0, and T.eval o' = T.eval o holds trivially by reflexivity for any oracle o'.

    lines 4–6

    uses MatroidIndepQueryTree.depth

      classical
      induction T with
      | leaf b => exact ⟨∅, by simp [MatroidIndepQueryTree.depth], fun o' _ => rfl⟩
  2. For a query node, the induction hypotheses provide query families for both subtrees, and we split into cases according to whether the oracle query o(S) is true.

    For an internal query node T = query S no yes, the induction hypotheses provide finite families of sets Ln and Ly with |Ln| ≤ depth(no) and |Ly| ≤ depth(yes) that determine the evaluations on the subtrees. We then split into two cases based on whether the oracle evaluation o(S) is true or false.

    lines 7–10

      | query S no yes ihn ihy =>
        obtain ⟨Ln, hLn, hn⟩ := ihn
        obtain ⟨Ly, hLy, hy⟩ := ihy
        by_cases hc : o S = true
  3. When o(S) = true, the query family {S} ∪ Ly has cardinality at most depth(T) and forces identical evaluation for any agreeing oracle.

    In the case o(S) = true, we choose L = {S} ∪ Ly as the witness. By Finset.card_insert_le, |L| ≤ |Ly| + 1 ≤ depth(yes) + 1 ≤ 1 + max(depth(no), depth(yes)) = depth(T), which is verified by linear arithmetic (omega). For any oracle o' agreeing with o on L, since S ∈ L by Finset.mem_insert_self, we have o'(S) = o(S) = true. By if_true, evaluating T under both o' and o reduces to evaluating the 'yes' subtree. Since every set S' ∈ Ly is also in L by Finset.mem_insert_of_mem, o' agrees with o on all of Ly, so the induction hypothesis for the 'yes' subtree ensures yes.eval o' = yes.eval o.

    lines 11–17

    uses Finset.card_insert_le, MatroidIndepQueryTree.depth, Finset.mem_insert_self, MatroidIndepQueryTree.eval, if_true, Finset.mem_insert_of_mem

        · refine ⟨insert S Ly, ?_, fun o' h => ?_⟩
          · have := Finset.card_insert_le S Ly
            simp only [MatroidIndepQueryTree.depth]
            omega
          · have hS : o' S = o S := h S (Finset.mem_insert_self S Ly)
            simp only [MatroidIndepQueryTree.eval, hS, hc, if_true]
            exact hy o' fun S' hS' => h S' (Finset.mem_insert_of_mem hS')
  4. When o(S) ≠ true, the query family {S} ∪ Ln has cardinality at most depth(T) and forces identical evaluation for any agreeing oracle.

    When o(S) ≠ true (so o(S) = false), we witness L with {S} ∪ Ln. By Finset.card_insert_le, its size is at most |Ln| + 1 ≤ depth(no) + 1 ≤ depth(T), which is closed by omega using the definition of depth. If an oracle o' agrees with o on L, then o'(S) = o(S) = false by Finset.mem_insert_self, so both evaluations route to the 'no' subtree. Since o' agrees with o on Ln by Finset.mem_insert_of_mem, the induction hypothesis for the 'no' subtree establishes no.eval o' = no.eval o, completing the proof.

    lines 18–24

    uses Finset.card_insert_le, MatroidIndepQueryTree.depth, Finset.mem_insert_self, MatroidIndepQueryTree.eval, Finset.mem_insert_of_mem

        · refine ⟨insert S Ln, ?_, fun o' h => ?_⟩
          · have := Finset.card_insert_le S Ln
            simp only [MatroidIndepQueryTree.depth]
            omega
          · have hS : o' S = o S := h S (Finset.mem_insert_self S Ln)
            simp only [MatroidIndepQueryTree.eval, hS, hc]
            exact hn o' fun S' hS' => h S' (Finset.mem_insert_of_mem hS')
MatroidIndepQueryTree.depth
The depth of a query tree, defined as 0 for a leaf and 1 + max(depth(no), depth(yes)) for a query node.
Finset.card_insert_le
Inserting an element into a finite set increases its cardinality by at most 1: |insert a s| ≤ |s| + 1.
Finset.mem_insert_self
An element is always a member of the set obtained by inserting it: a ∈ insert a s.
MatroidIndepQueryTree.eval
Evaluation of a query tree on an oracle: returns the leaf boolean for a leaf, and queries the oracle on S to choose between the yes and no subtrees.
if_true
A conditional expression if True then t else e simplifies to the 'then' branch t.
Finset.mem_insert_of_mem
If an element belongs to s, it also belongs to insert b s: a ∈ s → a ∈ insert b s.

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 matroid_indep_query_tree_eval_eq_of_agree {α : Type*} (o : Finset α → Bool) (T : MatroidIndepQueryTree α) :    ∃ L : Finset (Finset α), L.card ≤ T.depth ∧      ∀ o' : Finset α → Bool, (∀ S ∈ L, o' S = o S) → T.eval o' = T.eval o := by  classical  induction T with  | leaf b => exact ⟨∅, by simp [MatroidIndepQueryTree.depth], fun o' _ => rfl⟩  | query S no yes ihn ihy =>    obtain ⟨Ln, hLn, hn⟩ := ihn    obtain ⟨Ly, hLy, hy⟩ := ihy    by_cases hc : o S = true    · refine ⟨insert S Ly, ?_, fun o' h => ?_⟩      · have := Finset.card_insert_le S Ly        simp only [MatroidIndepQueryTree.depth]        omega      · have hS : o' S = o S := h S (Finset.mem_insert_self S Ly)        simp only [MatroidIndepQueryTree.eval, hS, hc, if_true]        exact hy o' fun S' hS' => h S' (Finset.mem_insert_of_mem hS')    · refine ⟨insert S Ln, ?_, fun o' h => ?_⟩      · have := Finset.card_insert_le S Ln        simp only [MatroidIndepQueryTree.depth]        omega      · have hS : o' S = o S := h S (Finset.mem_insert_self S Ln)        simp only [MatroidIndepQueryTree.eval, hS, hc]        exact hn o' fun S' hS' => h S' (Finset.mem_insert_of_mem hS')
See it in the graphDiscuss this resultChallenge it