Documentation

CslibFrontier.Computability.Circuit.Arithmetic.Separation.Interpreter.Lists

Lists, equality and tries as programs #

A library of programs, with their weighted values (Interpreter.Does, Interpreter.Gives):

From VP ≠ VNP over every field [Ant26], module NS1.Lists.

Main definitions #

Main results #

theorem Cslib.Circuits.Arithmetic.Separation.Interpreter.Does.runW {A : Type} [CommRing A] {θ : List Bool → A} {F G : Fm} {x p : Tree} {Q : List (A × Tree)} {R : Tree → List (A × Tree)} {c d e : ℕ} (hF : Gives θ F x p c) (hG : Does θ G x Q d) (h : ∀ q ∈ Q, Does θ (Fm.ofTree p) q.2 (R q.2) e) :
Does θ (F.run G) x (bindW Q R) (c + d + e + 1)

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

Fold over a list with a state. The argument is (this program, (state, list)); step is applied to (element, state).

Fold: s gives the state at the beginning, l the list.

The weighted list of a fold.

theorem Cslib.Circuits.Arithmetic.Separation.Interpreter.foldB_does {A : Type} [CommRing A] {θ : List Bool → A} {step : Fm} {f : Tree → Tree → List (A × Tree)} {Inv : List Tree → Tree → Prop} {d : Tree → ℕ} {xs : List Tree} (h : ∀ (x : Tree) (ys : List Tree) (σ : Tree), x ∈ xs → Inv (x :: ys) σ → Does θ step (x.cons σ) (f x σ) (d x) ∧ ∀ q ∈ f x σ, Inv ys q.2) {σ : Tree} (hσ : Inv xs σ) :
Does θ (foldB step) ((foldB step).code.cons (σ.cons (listT xs))) (foldW f xs σ) ((List.map (fun (x : Tree) => d x + 30) xs).sum + 10)
theorem Cslib.Circuits.Arithmetic.Separation.Interpreter.foldF_does {A : Type} [CommRing A] {θ : List Bool → A} {step s l : Fm} {x σ : Tree} {cs cl : ℕ} {f : Tree → Tree → List (A × Tree)} {Inv : List Tree → Tree → Prop} {d : Tree → ℕ} {xs : List Tree} (hs : Gives θ s x σ cs) (hl : Gives θ l x (listT xs) cl) (h : ∀ (x : Tree) (ys : List Tree) (σ : Tree), x ∈ xs → Inv (x :: ys) σ → Does θ step (x.cons σ) (f x σ) (d x) ∧ ∀ q ∈ f x σ, Inv ys q.2) (hσ : Inv xs σ) :
Does θ (foldF step s l) x (foldW f xs σ) (cs + cl + (List.map (fun (x : Tree) => d x + 30) xs).sum + 20)
theorem Cslib.Circuits.Arithmetic.Separation.Interpreter.foldW_det {A : Type} [CommRing A] (g : Tree → Tree → Tree) (xs : List Tree) (σ : Tree) :
foldW (fun (x σ : Tree) => [(1, g x σ)]) xs σ = [(1, List.foldl (fun (σ x : Tree) => g x σ) σ xs)]
theorem Cslib.Circuits.Arithmetic.Separation.Interpreter.foldF_gives {A : Type} [CommRing A] {θ : List Bool → A} {step s l : Fm} {x σ : Tree} {cs cl : ℕ} {g : Tree → Tree → Tree} {Inv : List Tree → Tree → Prop} {d : Tree → ℕ} {xs : List Tree} (hs : Gives θ s x σ cs) (hl : Gives θ l x (listT xs) cl) (h : ∀ (x : Tree) (ys : List Tree) (σ : Tree), x ∈ xs → Inv (x :: ys) σ → Gives θ step (x.cons σ) (g x σ) (d x) ∧ Inv ys (g x σ)) (hσ : Inv xs σ) :
Gives θ (foldF step s l) x (List.foldl (fun (σ x : Tree) => g x σ) σ xs) (cs + cl + (List.map (fun (x : Tree) => d x + 30) xs).sum + 20)

A deterministic fold.

Reverse a list onto another one.

theorem Cslib.Circuits.Arithmetic.Separation.Interpreter.rev_gives {A : Type} [CommRing A] {θ : List Bool → A} {s l : Fm} {x : Tree} {cs cl : ℕ} {xs ys : List Tree} (hs : Gives θ s x (listT ys) cs) (hl : Gives θ l x (listT xs) cl) :
Gives θ (foldF Fm.id s l) x (listT (xs.reverse ++ ys)) (cs + cl + xs.length * 31 + 20)
theorem Cslib.Circuits.Arithmetic.Separation.Interpreter.appF_gives {A : Type} [CommRing A] {θ : List Bool → A} {a b : Fm} {x : Tree} {ca cb : ℕ} {xs ys : List Tree} (ha : Gives θ a x (listT xs) ca) (hb : Gives θ b x (listT ys) cb) :
Gives θ (appF a b) x (listT (xs ++ ys)) (ca + cb + xs.length * 62 + 41)

Apply step to (parameter, element) for all elements of a list. The argument is (this program, (parameter, list)).

Map: e gives the parameter, l the list.

theorem Cslib.Circuits.Arithmetic.Separation.Interpreter.mapB_gives {A : Type} [CommRing A] {θ : List Bool → A} {step : Fm} {e : Tree} {g : Tree → Tree} {d : Tree → ℕ} {xs : List Tree} (h : ∀ x ∈ xs, Gives θ step (e.cons x) (g x) (d x)) :
Gives θ (mapB step) ((mapB step).code.cons (e.cons (listT xs))) (listT (List.map g xs)) ((List.map (fun (x : Tree) => d x + 40) xs).sum + 10)
theorem Cslib.Circuits.Arithmetic.Separation.Interpreter.mapF_gives {A : Type} [CommRing A] {θ : List Bool → A} {step ef l : Fm} {x e : Tree} {ce cl : ℕ} {g : Tree → Tree} {d : Tree → ℕ} {xs : List Tree} (he : Gives θ ef x e ce) (hl : Gives θ l x (listT xs) cl) (h : ∀ x ∈ xs, Gives θ step (e.cons x) (g x) (d x)) :
Gives θ (mapF step ef l) x (listT (List.map g xs)) (ce + cl + (List.map (fun (x : Tree) => d x + 40) xs).sum + 20)

Equality of trees: 1 if equal, else empty. The argument is (this program, (a, b)).

theorem Cslib.Circuits.Arithmetic.Separation.Interpreter.eqF_gives {A : Type} [CommRing A] {θ : List Bool → A} {a b : Fm} {x u v : Tree} {ca cb : ℕ} (ha : Gives θ a x u ca) (hb : Gives θ b x v cb) :
Gives θ (eqF a b) x (Tree.bit (decide (u = v))) (ca + cb + 60 * u.size + 10)

Choose an element of a list. The argument is (this program, list).

theorem Cslib.Circuits.Arithmetic.Separation.Interpreter.pickB_does {A : Type} [CommRing A] {θ : List Bool → A} (xs : List Tree) :
Does θ pickB (pickB.code.cons (listT xs)) (List.map (fun (x : Tree) => (1, x)) xs) (20 * xs.length + 10)
theorem Cslib.Circuits.Arithmetic.Separation.Interpreter.pickF_does {A : Type} [CommRing A] {θ : List Bool → A} {l : Fm} {x : Tree} {cl : ℕ} {xs : List Tree} (hl : Gives θ l x (listT xs) cl) :
Does θ (pickF l) x (List.map (fun (x : Tree) => (1, x)) xs) (cl + 20 * xs.length + 20)

Tries: (value, (left, right)); the empty tree is the empty trie.

Read a value. The argument is (this program, (path, trie)).

Read a value: p gives the path, t the trie.

theorem Cslib.Circuits.Arithmetic.Separation.Interpreter.getF_gives {A : Type} [CommRing A] {θ : List Bool → A} {pf tf : Fm} {x p t : Tree} {cp ct : ℕ} (hp : Gives θ pf x p cp) (ht : Gives θ tf x t ct) :
Gives θ (getF pf tf) x (tget p.path t) (cp + ct + 30 * p.len + 20)

Write a value. The argument is (this program, (path, (value, trie))).

Write a value: p gives the path, v the value, t the trie.

theorem Cslib.Circuits.Arithmetic.Separation.Interpreter.setB_gives {A : Type} [CommRing A] {θ : List Bool → A} (p v t : Tree) :
Gives θ setB (setB.code.cons (p.cons (v.cons t))) (tset p.path v t) (60 * p.len + 20)
theorem Cslib.Circuits.Arithmetic.Separation.Interpreter.setF_gives {A : Type} [CommRing A] {θ : List Bool → A} {pf vf tf : Fm} {x p v t : Tree} {cp cv ct : ℕ} (hp : Gives θ pf x p cp) (hv : Gives θ vf x v cv) (ht : Gives θ tf x t ct) :
Gives θ (setF pf vf tf) x (tset p.path v t) (cp + cv + ct + 60 * p.len + 30)

Formulas for elements of A.

Multiply the weight by an element of A.

theorem Cslib.Circuits.Arithmetic.Separation.Interpreter.WE.exists_of_adjoin {A : Type} [CommRing A] {θ : List Bool → A} {p₀ : List Bool} (h : θ p₀ = -1) {a : A} (ha : a ∈ Subring.closure (Set.range θ)) :
∃ (e : WE), val θ e = a

Every element of the subring generated by the constants has a formula, if −1 is a constant.