Documentation

CslibFrontier.Logics.Propositional.CSP.RandomizedAssignment

The value of an assignment and of a randomized assignment #

The value of an assignment σ : V → D for a CSP instance F, read as a list (multiset) of constraints, is the fraction of the constraints of F that σ satisfies (Logic.PL.CSP.satFraction) O'Donnell, Definition 7.26; it is also the probability that the tester which checks a uniformly random constraint of F accepts σ.

Over the Boolean domain, a randomized assignment labels each variable v with a random sign of mean g v ∈ [-1, 1], so true, the sign -1, with probability (1 - g v) / 2. A constraint is satisfied with the probability that its relation holds at independent random bits with the means g of the variables of its scope (Logic.PL.Constraint.satProb), position by position, so a variable that is repeated in a scope is drawn afresh at each position O'Donnell, Exercise 7.22. This is the multilinear (Fourier) expansion of the relation evaluated at those means (Logic.PL.Constraint.satProb_eq_sum_fourierCoeff) O'Donnell, Exercise 7.20(c), or equivalently its multilinearExtension at the probabilities of true (Logic.PL.Constraint.satProb_eq_eval_multilinearExtension). The value of the randomized assignment is the average of these probabilities over the constraints (Logic.PL.CSP.expectedSatFraction). Labelling every variable with the sign of an ordinary assignment σ recovers its value (Logic.PL.CSP.expectedSatFraction_signVal). Signs read the Boolean true as -1, so σ is labelled with means signVal (σ v). For means in [-1, 1] both values lie in [0, 1] (Logic.PL.CSP.expectedSatFraction_mem_Icc, Logic.PL.CSP.satFraction_mem_Icc).

Both values are one minus the fraction of the constraints that fail, so an empty instance has value 1, as for Complexity.GapTwoCSP, whose value is 1 - unsatVal. On a nonempty instance they are the satisfied fractions (Logic.PL.CSP.satFraction_of_ne_nil, Logic.PL.CSP.expectedSatFraction_of_ne_nil).

Usage #

Open Cslib.Logic.PL. F.satFraction sem σ and F.expectedSatFraction sem g take the truth tables sem : Rel → List Bool → Bool of the constraint language; for a constraint with a concrete relation, compute satProb from the multilinear expansion of its predicate (Logic.PL.Constraint.satProb_eq_sum_fourierCoeff), as Logic.PL.CSP.satProb_paritySem does for linear equations. An instance listing one constraint for each outcome of a uniform choice over a nonempty Finset (s.toList.map c) has value the expectation over that choice (Logic.PL.CSP.satFraction_map_toList, Logic.PL.CSP.expectedSatFraction_map_toList). The checked clients in CslibFrontierTests/BooleanAnalysisHastadTest.lean evaluate a constraint whose scope repeats a variable, which is read position by position, so x₀ + x₀ + x₂ = false at means 1/2, 1/2, 1 holds with probability 5/8, not 1.

Main definitions #

Main results #

References #

noncomputable def Cslib.Logic.PL.Constraint.satProb {Rel : Type u_1} {V : Type u_2} (sem : Rel → List Bool → Bool) (g : V → ℝ) (c : Constraint Rel V) :

The probability that the constraint c is satisfied by the randomized assignment g: each position i of the scope gets an independent random bit whose sign has mean g of the variable at that position, so true with probability (1 - g v) / 2, and the relation is evaluated at the list of these bits O'Donnell, Exercises 7.20 and 7.22. It is a probability when g takes values in [-1, 1] (satProb_nonneg, satProb_le_one).

theorem Cslib.Logic.PL.Constraint.satProb_def {Rel : Type u_1} {V : Type u_2} (sem : Rel → List Bool → Bool) (g : V → ℝ) (c : Constraint Rel V) :
satProb sem g c = ∑ a : Fin c.scope.length → Bool, BitString.meanWeight (fun (i : Fin c.scope.length) => g c.scope[i]) a * if sem c.rel (List.ofFn a) = true then 1 else 0

The defining formula of satProb.

theorem Cslib.Logic.PL.Constraint.satProb_eq_sum_fourierCoeff {Rel : Type u_1} {V : Type u_2} (sem : Rel → List Bool → Bool) (g : V → ℝ) (c : Constraint Rel V) :
satProb sem g c = ∑ S : Finset (Fin c.scope.length), BitString.fourierCoeff (fun (a : Fin c.scope.length → Bool) => if sem c.rel (List.ofFn a) = true then 1 else 0) S * ∏ i ∈ S, g c.scope[i]

The multilinear expansion O'Donnell, Exercise 7.20(c): the probability that a constraint is satisfied by a randomized assignment is the Fourier expansion of its relation, read on bit strings of the length of its scope, evaluated at the means of the scope.

theorem Cslib.Logic.PL.Constraint.satProb_eq_eval_multilinearExtension {Rel : Type u_1} {V : Type u_2} (sem : Rel → List Bool → Bool) (g : V → ℝ) (c : Constraint Rel V) :
satProb sem g c = (MvPolynomial.eval fun (i : Fin c.scope.length) => (1 - g c.scope[i]) / 2) (BitString.multilinearExtension fun (a : Fin c.scope.length → Bool) => if sem c.rel (List.ofFn a) = true then 1 else 0)

The probability that a constraint is satisfied by a randomized assignment is the multilinearExtension of its relation at the probabilities (1 - g v) / 2 that the positions of its scope are true.

theorem Cslib.Logic.PL.Constraint.satProb_signVal {Rel : Type u_1} {V : Type u_2} (sem : Rel → List Bool → Bool) (σ : V → Bool) (c : Constraint Rel V) :
satProb sem (fun (v : V) => BitString.signVal (σ v)) c = if eval sem σ c = true then 1 else 0

At the signs of an assignment σ, the probability that a constraint is satisfied is 1 if σ satisfies it and 0 otherwise.

theorem Cslib.Logic.PL.Constraint.satProb_nonneg {Rel : Type u_1} {V : Type u_2} (sem : Rel → List Bool → Bool) {g : V → ℝ} (hg : ∀ (v : V), |g v| ≤ 1) (c : Constraint Rel V) :
0 ≤ satProb sem g c

For a randomized assignment with values in [-1, 1], the probability that a constraint is satisfied is nonnegative.

theorem Cslib.Logic.PL.Constraint.satProb_le_one {Rel : Type u_1} {V : Type u_2} (sem : Rel → List Bool → Bool) {g : V → ℝ} (hg : ∀ (v : V), |g v| ≤ 1) (c : Constraint Rel V) :
satProb sem g c ≤ 1

For a randomized assignment with values in [-1, 1], the probability that a constraint is satisfied is at most one.

noncomputable def Cslib.Logic.PL.CSP.satFraction {Rel : Type u_1} {V : Type u_2} {D : Type u_3} (sem : Rel → List D → Bool) (σ : V → D) (F : CSP Rel V) :

The value of the assignment σ for the instance F: the fraction of the constraints of F, counted with multiplicity, that σ satisfies O'Donnell, Definition 7.26, written as one minus the fraction that σ fails, so that it is 1 for the empty instance.

theorem Cslib.Logic.PL.CSP.satFraction_def {Rel : Type u_1} {V : Type u_2} {D : Type u_3} (sem : Rel → List D → Bool) (σ : V → D) (F : CSP Rel V) :
satFraction sem σ F = 1 - ↑(List.countP (fun (c : Constraint Rel V) => !Constraint.eval sem σ c) F) / ↑(List.length F)

The defining formula of satFraction.

noncomputable def Cslib.Logic.PL.CSP.expectedSatFraction {Rel : Type u_1} {V : Type u_2} (sem : Rel → List Bool → Bool) (g : V → ℝ) (F : CSP Rel V) :

The value of the randomized assignment g for the instance F: the average, over the constraints of F counted with multiplicity, of the probability that g satisfies them O'Donnell, Exercise 7.20, written as one minus the average probability that they fail, so that it is 1 for the empty instance.

theorem Cslib.Logic.PL.CSP.expectedSatFraction_def {Rel : Type u_1} {V : Type u_2} (sem : Rel → List Bool → Bool) (g : V → ℝ) (F : CSP Rel V) :
expectedSatFraction sem g F = 1 - (List.map (fun (c : Constraint Rel V) => 1 - Constraint.satProb sem g c) F).sum / ↑(List.length F)

The defining formula of expectedSatFraction.

@[simp]
theorem Cslib.Logic.PL.CSP.satFraction_nil {Rel : Type u_1} {V : Type u_2} {D : Type u_3} (sem : Rel → List D → Bool) (σ : V → D) :
satFraction sem σ [] = 1

The empty instance has value 1.

@[simp]
theorem Cslib.Logic.PL.CSP.expectedSatFraction_nil {Rel : Type u_1} {V : Type u_2} (sem : Rel → List Bool → Bool) (g : V → ℝ) :

The empty instance has value 1.

theorem Cslib.Logic.PL.CSP.satFraction_of_ne_nil {Rel : Type u_1} {V : Type u_2} {D : Type u_3} (sem : Rel → List D → Bool) (σ : V → D) {F : CSP Rel V} (hF : F ≠ []) :
satFraction sem σ F = ↑(List.countP (Constraint.eval sem σ) F) / ↑(List.length F)

On a nonempty instance, the value of an assignment is the fraction of the constraints it satisfies.

theorem Cslib.Logic.PL.CSP.expectedSatFraction_of_ne_nil {Rel : Type u_1} {V : Type u_2} (sem : Rel → List Bool → Bool) (g : V → ℝ) {F : CSP Rel V} (hF : F ≠ []) :

On a nonempty instance, the value of a randomized assignment is the average probability that the constraints are satisfied.

theorem Cslib.Logic.PL.CSP.expectedSatFraction_signVal {Rel : Type u_1} {V : Type u_2} (sem : Rel → List Bool → Bool) (σ : V → Bool) (F : CSP Rel V) :
expectedSatFraction sem (fun (v : V) => BitString.signVal (σ v)) F = satFraction sem σ F

At the signs of an assignment σ, the value of the randomized assignment is the value of σ.

theorem Cslib.Logic.PL.CSP.expectedSatFraction_mem_Icc {Rel : Type u_1} {V : Type u_2} (sem : Rel → List Bool → Bool) {g : V → ℝ} (hg : ∀ (v : V), |g v| ≤ 1) (F : CSP Rel V) :

For a randomized assignment with values in [-1, 1], the value is a probability.

theorem Cslib.Logic.PL.CSP.satFraction_mem_Icc {Rel : Type u_1} {V : Type u_2} {D : Type u_3} (sem : Rel → List D → Bool) (σ : V → D) (F : CSP Rel V) :
satFraction sem σ F ∈ Set.Icc 0 1

The value of an assignment is a probability.

theorem Cslib.Logic.PL.CSP.expectedSatFraction_map_toList {Rel : Type u_1} {V : Type u_2} {ι : Type u_4} (sem : Rel → List Bool → Bool) (g : V → ℝ) {s : Finset ι} (hs : s.Nonempty) (c : ι → Constraint Rel V) :
expectedSatFraction sem g (List.map c s.toList) = s.expect fun (i : ι) => Constraint.satProb sem g (c i)

An instance listing one constraint per outcome of a random choice: the value of a randomized assignment is the expectation, over a uniformly random element s of a nonempty finite set, of the probability that it satisfies the constraint c s.

theorem Cslib.Logic.PL.CSP.satFraction_map_toList {Rel : Type u_1} {V : Type u_2} {D : Type u_3} {ι : Type u_4} (sem : Rel → List D → Bool) (σ : V → D) {s : Finset ι} (hs : s.Nonempty) (c : ι → Constraint Rel V) :
satFraction sem σ (List.map c s.toList) = s.expect fun (i : ι) => if Constraint.eval sem σ (c i) = true then 1 else 0

An instance listing one constraint per outcome of a random choice: the value of an assignment is the probability, over a uniformly random element s of a nonempty finite set, that it satisfies the constraint c s.