AFTD Auto-Formalizing Theoretical Domains

comparison_decision_tree_eval

def

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 LinearOrder is a TotalPreorder.
  • 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 than LinearOrder — it does NOT require antisymmetry or…
Used by 1

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
See it in the graphDiscuss this resultChallenge it