Documentation

CslibFrontier.Computability.Circuit.Arithmetic.Separation.Interpreter.Typed

Programs whose values are encodings of typed values #

The values of a formula of the tree machine are trees. A program that computes with states of a type β holds a state b as its encoding enc b : Tree, and its weighted list of values is l.map (Prod.map id enc) for a weighted list l : List (A × β) of typed values. This file has the rules of Interpreter.Does for such lists: the second part of a sequence is given at every typed value b, and the list of the sequence is l.weightedBind f (List.weightedBind). The encoding need not be injective.

The operations Interpreter.wsum, Interpreter.bindW, Interpreter.foldW of the interpreter are the operations List.weightedSum, List.weightedBind, List.weightedFoldl of weighted lists at the type of trees.

Main results #

References #

From VP ≠ VNP over every field [Ant26], Appendix J.3 (the evaluator in the proof of Theorem J.3); module Nc.Grp.Lang.

theorem Cslib.Circuits.Arithmetic.Separation.Interpreter.Does.wsum_unique {A : Type} [CommRing A] {θ : List Bool → A} {F : Fm} {x : Tree} {Q Q' : List (A × Tree)} {c d : ℕ} (h : Does θ F x Q c) (h' : Does θ F x Q' d) (φ : Tree → A) :
wsum Q φ = wsum Q' φ

The weighted sums are determined by the program.

theorem Cslib.Circuits.Arithmetic.Separation.Interpreter.Does.of_eq {A : Type} [CommRing A] {θ : List Bool → A} {F : Fm} {x : Tree} {Q Q' : List (A × Tree)} {c : ℕ} (h : Does θ F x Q c) (hQ : Q = Q') :
Does θ F x Q' c

Replace the list by an equal one.

theorem Cslib.Circuits.Arithmetic.Separation.Interpreter.Does.app_enc {A : Type} [CommRing A] {θ : List Bool → A} {β : Type u_1} {F : Fm} {x : Tree} {l : List (A × β)} {enc : β → Tree} {f : β → List (A × Tree)} {c d : ℕ} {p : Tree} (hF : Does θ F x (List.map (Prod.map id enc) l) c) (hG : ∀ b ∈ l, Does θ (Fm.ofTree p) (enc b.2) (f b.2) d) :
Does θ (Interpreter.app p F) x (l.weightedBind f) (c + d + 2)

Apply a fixed program to typed values.

theorem Cslib.Circuits.Arithmetic.Separation.Interpreter.Does.run_enc {A : Type} [CommRing A] {θ : List Bool → A} {β : Type u_1} {F G : Fm} {x : Tree} {l : List (A × β)} {enc : β → Tree} {f : β → List (A × Tree)} {c d : ℕ} {p : Tree} {e : ℕ} (hF : Gives θ F x p c) (hG : Does θ G x (List.map (Prod.map id enc) l) d) (h : ∀ b ∈ l, Does θ (Fm.ofTree p) (enc b.2) (f b.2) e) :
Does θ (F.run G) x (l.weightedBind f) (c + d + e + 1)

Apply a program that is the value of a formula to typed values.

theorem Cslib.Circuits.Arithmetic.Separation.Interpreter.Does.lett_enc {A : Type} [CommRing A] {θ : List Bool → A} {β : Type u_1} {F G : Fm} {x : Tree} {l : List (A × β)} {enc : β → Tree} {f : β → List (A × Tree)} {c d : ℕ} (hF : Does θ F x (List.map (Prod.map id enc) l) c) (hG : ∀ b ∈ l, Does θ G (enc b.2) (f b.2) d) :
Does θ (Interpreter.lett F G) x (l.weightedBind f) (c + d + 2)

let with typed values.

theorem Cslib.Circuits.Arithmetic.Separation.Interpreter.Does.lett_enc_enc {A : Type} [CommRing A] {θ : List Bool → A} {β : Type u_1} {γ : Type u_2} {F G : Fm} {x : Tree} {l : List (A × β)} {enc : β → Tree} {c d : ℕ} {enc' : γ → Tree} {f : β → List (A × γ)} (hF : Does θ F x (List.map (Prod.map id enc) l) c) (hG : ∀ b ∈ l, Does θ G (enc b.2) (List.map (Prod.map id enc') (f b.2)) d) :
Does θ (Interpreter.lett F G) x (List.map (Prod.map id enc') (l.weightedBind f)) (c + d + 2)

let with typed values and typed results.

theorem Cslib.Circuits.Arithmetic.Separation.Interpreter.Does.letk_enc {A : Type} [CommRing A] {θ : List Bool → A} {β : Type u_1} {F G : Fm} {x : Tree} {l : List (A × β)} {enc : β → Tree} {f : β → List (A × Tree)} {c d : ℕ} (hF : Does θ F x (List.map (Prod.map id enc) l) c) (hG : ∀ b ∈ l, Does θ G (x.cons (enc b.2)) (f b.2) d) :
Does θ (Interpreter.lett (Fm.id.cons F) G) x (l.weightedBind f) (c + d + 4)

let, with the argument kept, typed values.

theorem Cslib.Circuits.Arithmetic.Separation.Interpreter.Does.ite_nil {A : Type} [CommRing A] {θ : List Bool → A} {F G H : Fm} {x : Tree} {Q : List (A × Tree)} {c d : ℕ} {a : A} (hF : Does θ F x [(a, Tree.nil)] c) (hH : Does θ H x Q d) :
Does θ (F.ite G H) x (List.map (fun (r : A × Tree) => (a * r.1, r.2)) Q) (c + d + 1)

The first of two formulas has the empty value, with a weight: go on with the last one.

theorem Cslib.Circuits.Arithmetic.Separation.Interpreter.foldF_does_enc {A : Type} [CommRing A] {θ : List Bool → A} {β : Type u_1} {ε : Type u_3} {encE : ε → Tree} {enc : β → Tree} {Inv : List ε → β → Prop} {d : ε → ℕ} {xs : List ε} {step s l : Fm} {x : Tree} {f : ε → β → List (A × β)} {cs cl : ℕ} {s₀ : β} (hs : Gives θ s x (enc s₀) cs) (hl : Gives θ l x (listT (List.map encE xs)) cl) (h : ∀ (x : ε) (ys : List ε) (s : β), x ∈ xs → Inv (x :: ys) s → Does θ step ((encE x).cons (enc s)) (List.map (Prod.map id enc) (f x s)) (d x) ∧ ∀ q ∈ f x s, Inv ys q.2) (h0 : Inv xs s₀) :
Does θ (foldF step s l) x (List.map (Prod.map id enc) (List.weightedFoldl f xs s₀)) (cs + cl + (List.map (fun (x : ε) => d x + 30) xs).sum + 20)

A fold with a typed state over a list of typed elements.

theorem Cslib.Circuits.Arithmetic.Separation.Interpreter.foldF_gives_enc {A : Type} [CommRing A] {θ : List Bool → A} {β : Type u_1} {ε : Type u_3} {encE : ε → Tree} {enc : β → Tree} {Inv : List ε → β → Prop} {d : ε → ℕ} {xs : List ε} {step s l : Fm} {x : Tree} {g : ε → β → β} {cs cl : ℕ} {s₀ : β} (hs : Gives θ s x (enc s₀) cs) (hl : Gives θ l x (listT (List.map encE xs)) cl) (h : ∀ (x : ε) (ys : List ε) (s : β), x ∈ xs → Inv (x :: ys) s → Gives θ step ((encE x).cons (enc s)) (enc (g x s)) (d x) ∧ Inv ys (g x s)) (h0 : Inv xs s₀) :
Gives θ (foldF step s l) x (enc (List.foldl (fun (s : β) (x : ε) => g x s) s₀ xs)) (cs + cl + (List.map (fun (x : ε) => d x + 30) xs).sum + 20)

A deterministic fold with a typed state over a list of typed elements.