AFTD Auto-Formalizing Theoretical Domains

DecisionTree.exists_dtree_of_dtDepth

theoremverifiedimported Lean

Attainment of the decision-tree depth. For every Boolean function $f : (\mathrm{Fin}\,n \to \mathrm{Bool}) \to \mathrm{Bool}$, there is a decision tree $T$ on the $n$ Boolean variables whose depth is at most the decision-tree depth of $f$ and which computes $f$, meaning $T$ evaluates to $f(x)$ on every input $x$.

Statement

set_option autoImplicit true in
set_option relaxedAutoImplicit true in
variable {n : ℕ} in
lemma DecisionTree.exists_dtree_of_dtDepth (f : (Fin n → Bool) → Bool) :
    ∃ T : DecisionTree n, T.depth ≤ dtDepth f ∧ ∀ x, T.eval x = f x
Source
TCSlib, `DecisionTree.exists_dtree_of_dtDepth`
Lean proof
By Hydroxyi, Owen McGinty, Seyoon Ragavan (from the file's git history), from github.com/Shilun-Allan-Li/tcslib at c8a02591b1e5 (Apache-2.0). Compiled here against leanprover/lean4:v4.33.1, Mathlib v4.33.1; written for leanprover/lean4:v4.25.0.
Verified
07 Oct 2026
Axioms
Classical.choiceQuot.soundpropext
Built on 4
  • dtDepthThe decision-tree depth of $f : (\mathrm{Fin}\,n \to \mathrm{Bool}) \to \mathrm{Bool}$ is the least $d$ such that some decision tree of…
  • DecisionTree.depthThe depth of a decision tree (maximum path length to a leaf): a leaf has depth $0$ and a branch has depth $1$ plus the maximum of its two…
  • DecisionTreeA decision tree on $n$ Boolean variables: a leaf $\mathtt{leaf}\,b$ outputs $b$, and a branch $\mathtt{branch}\,i\,lo\,hi$ queries…
  • DecisionTree.evalEvaluates a decision tree on an input $x$: a leaf returns its stored bit, and a branch on variable $i$ follows the high subtree when $x_i$…
Used by 1
  • DecisionTree.degree_le_dtDepthDegree bounded by decision-tree depth. Let $f : \{0,1\}^n \to \{0,1\}$ be a Boolean-valued function, and let $D(f)$ denote its…

Lean source view module on GitHub

set_option autoImplicit true inset_option relaxedAutoImplicit true invariable {n : ℕ} in/-- Specification of `dtDepth`: some tree of depth `≤ dtDepth f` computes `f`. -/lemma DecisionTree.exists_dtree_of_dtDepth (f : (Fin n → Bool) → Bool) :    ∃ T : DecisionTree n, T.depth ≤ dtDepth f ∧ ∀ x, T.eval x = f x := by  classical  unfold dtDepth  exact Nat.find_spec    (p := fun d => ∃ T : DecisionTree n, T.depth ≤ d ∧ ∀ x, T.eval x = f x) _
See it in the graphDiscuss this resultChallenge it