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 #
Cslib.FreeM.eval_mOfFn:(mOfFn f).eval oracle = ofFn fun i => (f i).eval oracle.Cslib.FreeM.cost_mOfFn:(mOfFn f).cost oracle weight = ∑ i, (f i).cost oracle weight.
@[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 α) :
The cost of List.Vector.mOfFn f is the total cost of the programs f i.