Documentation

CslibFrontier.Algorithms.Lean.Query.FreeM.MOfFn

Evaluation and cost of List.Vector.mOfFn in query programs #

List.Vector.mOfFn f runs the programs f 0, …, f (n - 1) in order and collects their results in a vector. Mathlib defines it by structural recursion on n, so concrete instances reduce in the kernel and decide can check them. This module records how FreeM.eval and FreeM.cost act on it: evaluation is pointwise, and cost is the sum of the costs of the n programs.

Main results #

@[simp]
theorem Cslib.FreeM.eval_mOfFn {F : Type u → Type v} {α : Type u} (oracle : {ι : Type u} → F ι → ι) {n : ℕ} (f : Fin n → FreeM F α) :
eval (fun {ι : Type u} => oracle) (List.Vector.mOfFn f) = List.Vector.ofFn fun (i : Fin n) => eval (fun {ι : Type u} => oracle) (f i)

Evaluating List.Vector.mOfFn f evaluates each program f i.

@[simp]
theorem Cslib.FreeM.cost_mOfFn {F : Type u → Type v} {α : Type u} {T : Type u_1} [AddCommMonoid T] (oracle : {ι : Type u} → F ι → ι) (weight : {ι : Type u} → F ι → T) {n : ℕ} (f : Fin n → FreeM F α) :
cost (fun {ι : Type u} => oracle) (fun {ι : Type u} => weight) (List.Vector.mOfFn f) = ∑ i : Fin n, cost (fun {ι : Type u} => oracle) (fun {ι : Type u} => weight) (f i)

The cost of List.Vector.mOfFn f is the total cost of the programs f i.