Documentation

CslibFrontier.Computability.DecisionTree.FreeM

Boolean decision trees as free query programs #

Each internal node asks for one Boolean reply. equivFreeM identifies decision trees with the free programs of this query interface. Evaluating the tree on an assignment folds the free program by reading that assignment at each query.

Ported from the PolyFunFrontier.PFunctor.Free.DecisionTree module of Verified-zkEVM/PolyFun at revision 713d8857e49d20927c1447b3ba7397acc5537319.

Main definitions #

Main results #

A decision tree as a free program: a leaf returns its output, and a node queries its variable and continues with the branch for the answer.

A free program over Boolean queries as a decision tree.

@[simp]
theorem Cslib.DecisionTree.toFreeM_leaf {ι : Type u} {β : Type v} (b : β) :
@[simp]
theorem Cslib.DecisionTree.toFreeM_node {ι : Type u} {β : Type v} (i : ι) (t₀ t₁ : DecisionTree ι β) :
(node i t₀ t₁).toFreeM = (PFunctor.FreeM.lift i).bind fun (b : (PFunctor.monomial ι Bool).B i) => bif b then t₁.toFreeM else t₀.toFreeM
@[simp]
theorem Cslib.DecisionTree.ofFreeM_pure {ι : Type u} {β : Type v} (b : β) :
@[simp]
theorem Cslib.DecisionTree.ofFreeM_lift_bind {ι : Type u} {β : Type v} (i : ι) (k : (PFunctor.monomial ι Bool).B i → (PFunctor.monomial ι Bool).FreeM β) :
@[simp]
@[simp]
theorem Cslib.DecisionTree.ofFreeM_toFreeM {ι : Type u} {β : Type v} (t : DecisionTree ι β) :
@[simp]

Decision trees over ι are exactly the free programs of the Boolean query interface monomial ι Bool.

@[simp]
theorem Cslib.DecisionTree.equivFreeM_apply {ι : Type u} {β : Type v} (t : DecisionTree ι β) :
theorem Cslib.DecisionTree.eval_toFreeM {ι : Type u} {β : Type v} (t : DecisionTree ι β) (x : ι → Bool) :
PFunctor.FreeM.foldFreeM id (fun (i : (PFunctor.monomial ι Bool).A) (k : (PFunctor.monomial ι Bool).B i → β) => k (x i)) t.toFreeM = t.eval x

Evaluating a decision tree on x folds its free program, answering each query i by x i.

theorem Cslib.DecisionTree.eval_ofFreeM {ι : Type u} {β : Type v} (p : (PFunctor.monomial ι Bool).FreeM β) (x : ι → Bool) :
(ofFreeM p).eval x = PFunctor.FreeM.foldFreeM id (fun (i : (PFunctor.monomial ι Bool).A) (k : (PFunctor.monomial ι Bool).B i → β) => k (x i)) p

A free program over Boolean queries, answered from x, returns what its decision tree returns on x.