KonkurStudy
همه کارت‌ها

Counting Satisfying Assignments of a Propositional Formula

Count the truth assignments that make a formula true by exploiting free variables, shared-head case splits, and the 2^r - 1 rule for a single clause.

کارت مفهوم کنکور ارشد علوم کامپیوتر

اهمیت
۰/۵

A propositional formula over nn atomic variables x1,…,xnx_1,\ldots,x_n has 2n2^{n} possible truth assignments. Counting how many make the formula true is the heart of many konkur logic problems. You rarely need the full truth table — exploit structure.

Three counting strategies

  1. Independence / product rule. If the truth value of one sub‑formula is independent of a set of kk variables, those kk variables are free: each fixed satisfying pattern of the rest spreads over 2k2^{k} assignments. Multiply.
  2. Case split on a shared sub‑formula. When a formula is ⋀i( H∨Li )\bigwedge_i (\,H \vee L_i\,) — every clause shares a head HH — split on HH:
    • HH true ⇒\Rightarrow every clause is automatically true (the other literals are free).
    • HH false ⇒\Rightarrow each clause collapses to its remaining part LiL_i, which must all hold. Add the two disjoint counts.
  3. Complement (count the falsifying ones). For a single clause (a big OR) it is easier to count the one assignment of its literals that makes it false, then subtract.

Key formulas

For a disjunction (clause) of rr distinct literals over its own rr variables, exactly one of the 2r2^{r} literal‑patterns is false (every literal false), so

#{satisfying}=2r−1(over those r variables).\#\{\text{satisfying}\} = 2^{r}-1 \quad(\text{over those } r \text{ variables}).

If jj of the nn variables don't appear in the (sub)formula, multiply any count by 2j2^{j} for the free variables.

Worked mini‑example

Count the satisfying assignments of (x1∨x2)∧(∼x1∨x3)(x_1 \vee x_2)\wedge(\sim x_1 \vee x_3) over x1,x2,x3x_1,x_2,x_3 (so 23=82^3=8 total). Split on x1x_1:

x1x_1 clause 1   x1∨x2\;x_1\vee x_2 clause 2   ∼x1∨x3\;\sim x_1\vee x_3 satisfying (x2,x3)(x_2,x_3)
true always true forces x3=Tx_3=\text{T} x2x_2 free ⇒2\Rightarrow 2
false forces x2=Tx_2=\text{T} always true x3x_3 free ⇒2\Rightarrow 2

The cases are disjoint, so 2+2=42+2=4 assignments are satisfying (and indeed 44 of 88 — this formula is "x1⇒x3x_1\Rightarrow x_3 and ¬x1⇒x2\neg x_1 \Rightarrow x_2").

Exam trick: when every clause of a CNF shares a common head HH, never expand the whole truth table — split once on HH. The H=trueH=\text{true} branch frees all the other variables (×2k\times 2^{k}), and only the small H=falseH=\text{false} branch needs real work. Adding two disjoint cases beats checking 2n2^{n} rows.

فرمول‌های کلیدی

Total assignments
2n2^{n}

Number of truth assignments to n atomic propositions; the whole sample space.

Satisfying assignments of one clause
2r−12^{r}-1

A disjunction of r distinct literals is false in exactly one of its 2^r literal patterns (all literals false).

Free-variable multiplier
N=N0⋅2jN = N_0 \cdot 2^{j}

If j of the variables do not affect the formula's value, every satisfying pattern N_0 of the rest spreads over 2^j assignments.

Shared-head case split
#(⋀i(H∨Li))=#(H=T)+#(H=F∧⋀iLi)\#\Big(\bigwedge_i (H \vee L_i)\Big) = \#(H=\mathrm{T}) + \#\big(H=\mathrm{F}\wedge \textstyle\bigwedge_i L_i\big)

Split a CNF whose clauses share head H into two disjoint counts and add them.

#logic#propositional-logic#counting#satisfiability#truth-assignment#case-analysis#cnf

سوالات تمرینی