comparison_decision_tree_eval
Evaluation of a comparison decision tree on an input sequence v : Fin n → α over a linear order α, branching left if v i < v j and right otherwise until reaching a leaf.
Statement
def comparison_decision_tree_eval {n : ℕ} {β : Type} {α : Type*} [LinearOrder α] (v : Fin n → α) : ComparisonDecisionTree n β → β
- Defined in
- arXiv:2611.26297
- Verified
- 22 Nov 2026
- Axioms
- none listed
- Built on 3
- LinearOrder.toTotalPreorderEvery
LinearOrderis aTotalPreorder. - ComparisonDecisionTreeA binary comparison decision tree on n elements whose leaves return a value of type β.
- TotalPreorderA total preorder: a preorder where
≤is total (complete). This is weaker thanLinearOrder— it does NOT require antisymmetry or…
- LinearOrder.toTotalPreorderEvery
- Used by 1
- comparison_tree_finds_guaranteed_rollercoasterA comparison decision tree T on n elements correctly finds a guaranteed-length k-rollercoaster if for every permutation σ of Fin n, the…
Read back from the Lean
Given a natural number n, a type β, a linearly ordered type α, an input vector v : Fin n → α, and a ComparisonDecisionTree n β T, comparison_decision_tree_eval v T evaluates T on v to return a value in β:
- If T is a leaf node .leaf ans, it returns ans.
- If T is an internal node .branch i j l r (with index variables i, j : Fin n and subtrees l, r), it tests whether v i < v j (strictly less than); if true, it recursively evaluates l on v, and if false, it recursively evaluates r on v.
Written by a model that saw only the Lean, never the English above. If the two disagree, that is worth a challenge.
Lean source view module on GitHub
/-- Evaluates a comparison decision tree on a linearly ordered sequence of values. -/ def comparison_decision_tree_eval {n : ℕ} {β : Type} {α : Type*} [LinearOrder α] (v : Fin n → α) : ComparisonDecisionTree n β → β := fun | .leaf ans => ans | .branch i j l r => if v i < v j then comparison_decision_tree_eval v l else comparison_decision_tree_eval v r