Documentation

CslibFrontier.Computability.Circuit.Arithmetic.Separation.Interpreter.Comp

Weighted functions computed by formulas #

Interpreter.Does θ F x Q c says four things:

Interpreter.Gives θ F x o c is the case Q = [(1, o)]. Its rules follow the formulas, so the evaluation of compound programs can be bounded compositionally.

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

Main definitions #

Main results #

Weighted sums over a list of pairs (weight, value).

@[simp]
theorem Cslib.Circuits.Arithmetic.Separation.Interpreter.wsum_cons {A : Type} [CommRing A] (q : A × Tree) (Q : List (A × Tree)) (φ : Tree → A) :
wsum (q :: Q) φ = q.1 * φ q.2 + wsum Q φ
theorem Cslib.Circuits.Arithmetic.Separation.Interpreter.wsum_append {A : Type} [CommRing A] (Q Q' : List (A × Tree)) (φ : Tree → A) :
wsum (Q ++ Q') φ = wsum Q φ + wsum Q' φ
theorem Cslib.Circuits.Arithmetic.Separation.Interpreter.wsum_congr {A : Type} [CommRing A] {Q : List (A × Tree)} {φ φ' : Tree → A} (h : ∀ q ∈ Q, φ q.2 = φ' q.2) :
wsum Q φ = wsum Q φ'

First Q, then R at the value.

theorem Cslib.Circuits.Arithmetic.Separation.Interpreter.wsum_bindW {A : Type} [CommRing A] (Q : List (A × Tree)) (R : Tree → List (A × Tree)) (φ : Tree → A) :
wsum (bindW Q R) φ = wsum Q fun (o : Tree) => wsum (R o) φ
theorem Cslib.Circuits.Arithmetic.Separation.Interpreter.mem_bindW {A : Type} [CommRing A] {Q : List (A × Tree)} {R : Tree → List (A × Tree)} {p : A × Tree} (h : p ∈ bindW Q R) :
∃ q ∈ Q, ∃ r ∈ R q.2, p.2 = r.2 ∧ p.1 = q.1 * r.1
theorem Cslib.Circuits.Arithmetic.Separation.Interpreter.mem_bindW_of {A : Type} [CommRing A] {Q : List (A × Tree)} {R : Tree → List (A × Tree)} {q r : A × Tree} (hq : q ∈ Q) (hr : r ∈ R q.2) :
(q.1 * r.1, r.2) ∈ bindW Q R
def Cslib.Circuits.Arithmetic.Separation.Interpreter.Does {A : Type} [CommRing A] (θ : List Bool → A) (F : Fm) (x : Tree) (Q : List (A × Tree)) (c : ℕ) :

The formula computes the weighted list Q at x.

The formula has the value o at x, with weight 1.

theorem Cslib.Circuits.Arithmetic.Separation.Interpreter.Does.mono {A : Type} [CommRing A] {θ : List Bool → A} {F : Fm} {x : Tree} {Q : List (A × Tree)} {c d : ℕ} (h : Does θ F x Q c) (hc : c ≤ d) :
Does θ F x Q d
theorem Cslib.Circuits.Arithmetic.Separation.Interpreter.Does.congr {A : Type} [CommRing A] {θ : List Bool → A} {F : Fm} {x : Tree} {Q : List (A × Tree)} {c : ℕ} {Q' : List (A × Tree)} (h : Does θ F x Q c) (h1 : ∀ q ∈ Q, ∃ q' ∈ Q', q'.2 = q.2) (h2 : ∀ (φ : Tree → A), wsum Q φ = wsum Q' φ) :
Does θ F x Q' c

Replace the list by an equivalent one.

theorem Cslib.Circuits.Arithmetic.Separation.Interpreter.Does.hl {A : Type} [CommRing A] {θ : List Bool → A} {F : Fm} {x : Tree} {Q : List (A × Tree)} {c : ℕ} (h : Does θ F x Q c) :
Hl θ F x
theorem Cslib.Circuits.Arithmetic.Separation.Interpreter.Does.evl {A : Type} [CommRing A] {θ : List Bool → A} {F : Fm} {x : Tree} {Q : List (A × Tree)} {c : ℕ} (h : Does θ F x Q c) :
(∀ r ∈ Interpreter.evl θ F x, r.bill = [] ∧ r.cost ≤ c ∧ ∃ q ∈ Q, q.2 = r.out) ∧ ∀ (φ : Tree → A), (List.map (fun (r : Run A) => r.th * φ r.out) (Interpreter.evl θ F x)).sum = wsum Q φ
theorem Cslib.Circuits.Arithmetic.Separation.Interpreter.Does.plain {A : Type} [CommRing A] {θ : List Bool → A} {F : Fm} {x : Tree} {Q : List (A × Tree)} {c : ℕ} (h : Does θ F x Q c) :
Plain θ c (F.code.cons x) ∧ pv θ (F.code.cons x) = (List.map Prod.fst Q).sum

A computation is a plain sum.

theorem Cslib.Circuits.Arithmetic.Separation.Interpreter.Does.of_dt {A : Type} [CommRing A] {θ : List Bool → A} {F : Fm} {x : Tree} {c : ℕ} {o : Tree} (h : Dt θ F x o c) :
Does θ F x [(1, o)] c
theorem Cslib.Circuits.Arithmetic.Separation.Interpreter.Does.cons {A : Type} [CommRing A] {θ : List Bool → A} {F G : Fm} {x : Tree} {Q : List (A × Tree)} {c d : ℕ} {R : List (A × Tree)} (hF : Does θ F x Q c) (hG : Does θ G x R d) :
Does θ (F.cons G) x (List.flatMap (fun (q : A × Tree) => List.map (fun (r : A × Tree) => (q.1 * r.1, q.2.cons r.2)) R) Q) (c + d + 1)

Pairs.

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

Apply a fixed program to the value.

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

let.

theorem Cslib.Circuits.Arithmetic.Separation.Interpreter.Does.letk {A : Type} [CommRing A] {θ : List Bool → A} {F G : Fm} {x : Tree} {Q : List (A × Tree)} {c d : ℕ} {R : Tree → List (A × Tree)} (hF : Does θ F x Q c) (hG : ∀ q ∈ Q, Does θ G (x.cons q.2) (R q.2) d) :
Does θ (Interpreter.lett (Fm.id.cons F) G) x (bindW Q R) (c + d + 4)

let, with the argument kept.

theorem Cslib.Circuits.Arithmetic.Separation.Interpreter.Does.out_eq {A : Type} [CommRing A] {c : ℕ} {o : Tree} {l : List (Run A)} (e2 : ∀ r ∈ l, r.bill = [] ∧ r.cost ≤ c ∧ ∃ q ∈ [(1, o)], q.2 = r.out) (r : Run A) :
r ∈ l → r.out = o

The runs of a formula with the one value o (with weight 1) all have the value o.

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

Apply a program that is the value of a formula.

theorem Cslib.Circuits.Arithmetic.Separation.Interpreter.Does.ite_of {A : Type} [CommRing A] {θ : List Bool → A} {F G H : Fm} {x : Tree} {Q : List (A × Tree)} {c d : ℕ} {K : Fm} {o : Tree} (hF : Gives θ F x o c) (hK : Does θ K x Q d) (hev : ∀ {l l' : List (Run A)}, Ev θ F x l → (∀ r ∈ l, r.out = o) → Ev θ K x l' → Ev θ (F.ite G H) x (List.flatMap (fun (r : Run A) => List.map (fun (s : Run A) => (r.seq s).tick s.out) l') l)) :
Does θ (F.ite G H) x Q (c + d + 1)

A branch K of an ite whose condition has the one value o: the branch that o selects.

theorem Cslib.Circuits.Arithmetic.Separation.Interpreter.Does.ite_true {A : Type} [CommRing A] {θ : List Bool → A} {F G H : Fm} {x : Tree} {Q : List (A × Tree)} {c d : ℕ} {o : Tree} (hF : Gives θ F x o c) (ho : o ≠ Tree.nil) (hG : Does θ G x Q d) :
Does θ (F.ite G H) x Q (c + d + 1)
theorem Cslib.Circuits.Arithmetic.Separation.Interpreter.Does.ite_false {A : Type} [CommRing A] {θ : List Bool → A} {F G H : Fm} {x : Tree} {Q : List (A × Tree)} {c d : ℕ} (hF : Gives θ F x Tree.nil c) (hH : Does θ H x Q d) :
Does θ (F.ite G H) x Q (c + d + 1)
theorem Cslib.Circuits.Arithmetic.Separation.Interpreter.Does.either {A : Type} [CommRing A] {θ : List Bool → A} {G H : Fm} {x : Tree} {Q : List (A × Tree)} {c d : ℕ} {R : List (A × Tree)} (hG : Does θ G x Q c) (hH : Does θ H x R d) :
Does θ (Fm.guess.ite G H) x (Q ++ R) (max c d + 2)

Guess between two formulas.

theorem Cslib.Circuits.Arithmetic.Separation.Interpreter.Does.theta {A : Type} [CommRing A] {θ : List Bool → A} {F : Fm} {x : Tree} {c : ℕ} {o : Tree} (h : Gives θ F x o c) :
Does θ F.theta x [(θ o.path, Tree.nil)] (c + 1)

Multiply by a constant of A.

theorem Cslib.Circuits.Arithmetic.Separation.Interpreter.Does.tick {A : Type} [CommRing A] {θ : List Bool → A} {F : Fm} {x : Tree} {c : ℕ} {G : Fm} {f : Tree → Tree} {o : Tree} (h : Gives θ F x o c) (hG : ∀ {l : List (Run A)}, Ev θ F x l → Ev θ G x (List.map (fun (r : Run A) => r.tick (f r.out)) l)) :
Gives θ G x (f o) (c + 1)

A step that maps the value of every run by f (as hd and tl do) maps a value o to f o.

theorem Cslib.Circuits.Arithmetic.Separation.Interpreter.Gives.mono {A : Type} [CommRing A] {θ : List Bool → A} {F : Fm} {x o : Tree} {c d : ℕ} (h : Gives θ F x o c) (hc : c ≤ d) :
Gives θ F x o d
theorem Cslib.Circuits.Arithmetic.Separation.Interpreter.Gives.hd {A : Type} [CommRing A] {θ : List Bool → A} {F : Fm} {x o : Tree} {c : ℕ} (h : Gives θ F x o c) :
Gives θ F.hd x o.hd (c + 1)
theorem Cslib.Circuits.Arithmetic.Separation.Interpreter.Gives.tl {A : Type} [CommRing A] {θ : List Bool → A} {F : Fm} {x o : Tree} {c : ℕ} (h : Gives θ F x o c) :
Gives θ F.tl x o.tl (c + 1)
theorem Cslib.Circuits.Arithmetic.Separation.Interpreter.Gives.cons {A : Type} [CommRing A] {θ : List Bool → A} {F G : Fm} {x o o' : Tree} {c d : ℕ} (h : Gives θ F x o c) (h' : Gives θ G x o' d) :
Gives θ (F.cons G) x (o.cons o') (c + d + 1)
theorem Cslib.Circuits.Arithmetic.Separation.Interpreter.Gives.app {A : Type} [CommRing A] {θ : List Bool → A} {F : Fm} {x o o' : Tree} {c d : ℕ} {p : Tree} (h : Gives θ F x o c) (h' : Gives θ (Fm.ofTree p) o o' d) :
Gives θ (Interpreter.app p F) x o' (c + d + 2)
theorem Cslib.Circuits.Arithmetic.Separation.Interpreter.Gives.lett {A : Type} [CommRing A] {θ : List Bool → A} {F G : Fm} {x o o' : Tree} {c d : ℕ} (h : Gives θ F x o c) (h' : Gives θ G o o' d) :
Gives θ (Interpreter.lett F G) x o' (c + d + 2)
theorem Cslib.Circuits.Arithmetic.Separation.Interpreter.Gives.letk {A : Type} [CommRing A] {θ : List Bool → A} {F G : Fm} {x o o' : Tree} {c d : ℕ} (h : Gives θ F x o c) (h' : Gives θ G (x.cons o) o' d) :
Gives θ (Interpreter.lett (Fm.id.cons F) G) x o' (c + d + 4)
theorem Cslib.Circuits.Arithmetic.Separation.Interpreter.Gives.run {A : Type} [CommRing A] {θ : List Bool → A} {F G : Fm} {x o : Tree} {c d : ℕ} {p y : Tree} {e : ℕ} (hF : Gives θ F x p c) (hG : Gives θ G x y d) (h : Gives θ (Fm.ofTree p) y o e) :
Gives θ (F.run G) x o (c + d + e + 1)
theorem Cslib.Circuits.Arithmetic.Separation.Interpreter.Gives.ite_true {A : Type} [CommRing A] {θ : List Bool → A} {F G H : Fm} {x o o' : Tree} {c d : ℕ} (hF : Gives θ F x o c) (ho : o ≠ Tree.nil) (hG : Gives θ G x o' d) :
Gives θ (F.ite G H) x o' (c + d + 1)
theorem Cslib.Circuits.Arithmetic.Separation.Interpreter.Gives.ite_false {A : Type} [CommRing A] {θ : List Bool → A} {F G H : Fm} {x o' : Tree} {c d : ℕ} (hF : Gives θ F x Tree.nil c) (hH : Gives θ H x o' d) :
Gives θ (F.ite G H) x o' (c + d + 1)
theorem Cslib.Circuits.Arithmetic.Separation.Interpreter.Gives.after {A : Type} [CommRing A] {θ : List Bool → A} {F G : Fm} {x : Tree} {c d : ℕ} {Q : List (A × Tree)} (h : Does θ F x Q c) {f : Tree → Tree} (h' : ∀ q ∈ Q, Gives θ G q.2 (f q.2) d) :
Does θ (Interpreter.lett F G) x (List.map (fun (q : A × Tree) => (q.1, f q.2)) Q) (c + d + 2)

A computation, then a deterministic one.

theorem Cslib.Circuits.Arithmetic.Separation.Interpreter.Does.of_gives {A : Type} [CommRing A] {θ : List Bool → A} {F G : Fm} {x o : Tree} {Q : List (A × Tree)} {c d : ℕ} (h : Gives θ F x o c) (h' : Does θ G o Q d) :
Does θ (Interpreter.lett F G) x Q (c + d + 2)

The weighted list of a deterministic computation followed by another one.