AFTD Auto-Formalizing Theoretical Domains

dtDepth

defimported Lean

The decision-tree depth of $f : (\mathrm{Fin}\,n \to \mathrm{Bool}) \to \mathrm{Bool}$ is the least $d$ such that some decision tree of depth at most $d$ computes $f$; it is well defined since the full tree computes $f$ at depth $n$.

Statement

set_option relaxedAutoImplicit false in
set_option autoImplicit false in
noncomputable def dtDepth {n : ℕ} (f : (Fin n → Bool) → Bool) : ℕ
Defined in
TCSlib, `dtDepth`
Lean proof
By Hydroxyi, from github.com/Shilun-Allan-Li/tcslib at c8a02591b1e5 (Copyright (c) 2026 TCSlib contributors. All rights reserved, 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
none listed
Built on 6
  • DecisionTree.buildFullBuild a complete decision tree querying variables 0, 1, …, n−1 in order.
  • DecisionTree.buildFull_evalThe complete tree computes f on every input it is consistent with. Proof sketch. Induction on the number of variables still to be…
  • 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…
  • DecisionTree.buildFull_depthThe complete tree started at level k has depth at most n - k.
  • 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 2
  • DecisionTree.exists_dtree_of_dtDepthAttainment of the decision-tree depth. For every Boolean function $f : (\mathrm{Fin}\,n \to \mathrm{Bool}) \to \mathrm{Bool}$, there is a…
  • 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 relaxedAutoImplicit false in
set_option autoImplicit false in
/-- The minimum decision-tree depth to compute `f : (Fin n → Bool) → Bool`. [OD14, §3.2] Formally: `min { T.depth | T computes f }` = `Nat.sInf {d | ∃ T : DecisionTree n, T.depth ≤ d ∧ ∀ x, T.eval x = f x}`. -/
noncomputable def dtDepth {n : ℕ} (f : (Fin n → Bool) → Bool) : ℕ := by
  classical
  exact Nat.find (p := fun d => ∃ T : DecisionTree n, T.depth ≤ d ∧ ∀ x, T.eval x = f x)
    ⟨n, DecisionTree.buildFull f 0 (fun _ => false),
     DecisionTree.buildFull_depth f 0 (Nat.zero_le n) _,
     fun x => DecisionTree.buildFull_eval f 0 (Nat.zero_le n) _ x (fun _ hi => by omega)⟩
See it in the graphDiscuss this resultChallenge it