L17 – Logic II: Propositional logic

Discrete Mathematics2026年5月19日发布 芮和
24.9K 910
21,364字
90–136 分钟

Oversimplified history

Logic formalizes reasoning.

  • Since ancient Greek (until modern high school):
    • First subject taught to young people.
    • Logic rules are classified and named.
    • Goal: Reasoning and debating.
  • 19c Mathematicians:
    • Formalization of logic.
    • Goal: Clarifying foundation of mathematics.
    • Subjects: Consistency, independence, soundness, completeness.
    • Hilbert’s program “ended” by Gödel.
  • Modern days:
    • Applications of logic in computer sciences.
    • Propositional logic applied both in hardware and software.
    • First-order logic applied in automated theorem prover and logic programming.

Structure of the course

We will learn about propositional logic and first-order (predicate) logic. For each we will study

  • Syntax : Which strings are allowed?
  • Semantics : What does a string mean?
  • Deduction : Rules of inference between formulas.
  • Resolution : Algorithm for automated proving.
  • Application : SAT & logic programming.

Beginning today: propositional logic.


Section 1
Syntax

Atoms and operators

Definition: An atomic proposition is a sentence that is

  • declarative.
  • either true or false.
  • cannot be decomposed.

The symbols used in a formula in propositional logic are

  • Atomic propositions (atoms).
  • Boolean operators: ¬\neg, \land, \lor, …

Example

  • One plus one equals two.
  • The earth is flat.
  • Sweet soy milk is more delicious.

Example (Non-examples)

  • Shut up!
  • How are you?
  • bla bla bla …

Formula

Definition: A formula in propositional logic is generated by the following context-free grammar:

  • terminals are atoms and operators.
  • a nonterminal symbol fml.
  • production rules are:
    • fmlp\rightarrow p, pp is an atom.
    • fml¬\rightarrow\negfml.
    • fml\rightarrow(fml op fml).
    • op||||\rightarrow\land\mid\lor\mid\rightarrow\mid\leftrightarrow\mid\dots

Any formula FF that occurs in another formula GG is called a subformula of GG.

Example

((pq)(¬p¬q))((p \rightarrow q) \leftrightarrow (\neg p \rightarrow \neg q))

Or we can define recursively as follows:

  • An atom is a formula (atomic formula).
  • For every formula FF, ¬F\neg F is a formula.
  • For every two formulas FF and GG, (FG)(F \land G) and (FG)(F \lor G) and … are formulas.

Abbreviations
(FG)(F \rightarrow G) means (¬FG)(\neg F \lor G), (FG)(F \leftrightarrow G) means ((FG)(¬F¬G))((F \land G) \lor (\neg F \land \neg G))

Remark: All binary operators can be defined in terms of ¬\neg, \land, \lor.

Precedence to reduce (‘s and )‘s:

¬, , , , \neg,\ \land,\ \lor,\ \rightarrow,\ \leftrightarrow

A formula can be represented as a tree

  • The leaves are labeled by the atoms.
  • The nodes are labeled by operators.
  • The ¬\neg node has a single child.
  • Other operator nodes each have two children.
  • Subtrees are subformulas.

Example

pq¬p¬qp \rightarrow q \leftrightarrow \neg p \rightarrow \neg q

Induction on formula

To show that a statement 𝒮\mathcal{S} holds for every formula FF, we show

  • 𝒮\mathcal{S} holds for every atomic formula AA.
  • Under the hypothesis that 𝒮\mathcal{S} holds for formulas FF and GG, then 𝒮\mathcal{S} holds for ¬F\neg F, FGF \land G and FGF \lor G.

Section 2
Semantics

Interpretation

Definition: Let FF be a formula, and 𝒜\mathcal{A} be the set of atoms appearing in FF. An interpretation of FF is a function :𝒜{1,0}\mathcal{I} : \mathcal{A} \rightarrow \{1,0\}. In other words, an interpretation assigns a truth value (true for 11 or false for 00) to every atom in FF.

Definition: Given an interpretation \mathcal{I} of FF, the truth value of FF under \mathcal{I}, denoted (F)\mathcal{I}(F) is defined inductively as follows:

  • (¬A)={1if (A)=0,0if (A)=1.\mathcal{I}(\neg A) = \begin{cases} 1 & \text{if } \mathcal{I}(A) = 0, \\ 0 & \text{if } \mathcal{I}(A) = 1. \end{cases}
  • (AB)={1if (A)=(B)=1,0otherwise.\mathcal{I}(A \land B) = \begin{cases} 1 & \text{if } \mathcal{I}(A) = \mathcal{I}(B) = 1, \\ 0 & \text{otherwise.} \end{cases}
  • (AB)={0if (A)=(B)=0,1otherwise.\mathcal{I}(A \lor B) = \begin{cases} 0 & \text{if } \mathcal{I}(A) = \mathcal{I}(B) = 0, \\ 1 & \text{otherwise.} \end{cases}

Truth table

(p)\mathcal{I}(p)(q)\mathcal{I}(q)(¬p)\mathcal{I}(\neg p)(pq)\mathcal{I}(p \land q)(qp)\mathcal{I}(q \lor p)(pq)\mathcal{I}(p \rightarrow q)
110111
100010
011011
001001
  • ¬\neg is intended to model the word “not”.
  • \land is intended to model the word “and”.
  • \lor is intended to model the word “or”, but is inclusive or, not exclusive or.
  • PQP \rightarrow Q is defined as ¬PQ\neg P \lor Q.
  • \rightarrow is read “implies” but does not claim causation.

Model and satisfiability

Definition: Given an interpretation \mathcal{I} of a formula FF, if (F)=1\mathcal{I}(F) = 1, we say that FF holds under \mathcal{I}, and \mathcal{I} is a model of FF, and write F\mathcal{I} \models F.

Definition

  • A formula FF is satisfiable if FF has a model.
  • Otherwise FF is unsatisfiable.
  • A formula FF is valid or a tautology if every interpretation is a model, and we write F\models F.

Theorem: A formula FF is a tautology iff ¬F\neg F is unsatisfiable.


Decision procedure

  • We want an algorithm that decides satisfiability.
  • That is: given an arbitrary formula FF, it terminates and returns yes if FF is satisfiable, and no otherwise.
  • Such an algorithm, when applied to ¬F\neg F, can decide validity.

Example: The truth table is such an algorithm, but very inefficient.
Is there a better algorithm?


Logical equivalence

Definition: Let F1F_1 and F2F_2 be two formulas (on the same set of atoms). If (F1)=(F2)\mathcal{I}(F_1) = \mathcal{I}(F_2) for all interpretations \mathcal{I}, then F1F_1 and F2F_2 are logically equivalent, denoted by F1F2F_1 \equiv F_2.

Theorem (material equivalence vs logic equivalence)F1F2F_1 \equiv F_2 iff F1F2F_1 \leftrightarrow F_2 is true in every interpretation.

Theorem: Let FF be a subformula of GG and FFF’ \equiv F. Then GG{FF}G \equiv G\{F \leftarrow F’\}, the latter denotes the formula obtained by replacing all occurrences of FF by FF’.

  • Absorption of constants
    A11A \lor 1 \equiv 1, A1AA \land 1 \equiv A, 0A10 \rightarrow A \equiv 1, …
  • Identical operands
    A¬¬AA \equiv \neg\neg A, A¬A0A \land \neg A \equiv 0, AA1A \rightarrow A \equiv 1, …
  • Commutativity, Associativity, Distributivity
    ABBAA \lor B \equiv B \lor A, A(BC)(AB)CA \land (B \land C) \equiv (A \land B) \land C, ¬(AB)¬A¬B\neg(A \lor B) \equiv \neg A \land \neg B, A(BC)(AB)(AC)A \lor (B \land C) \equiv (A \lor B) \land (A \lor C), …
  • Defining operators
    AB¬ABA \rightarrow B \equiv \neg A \lor B, …

Set of formulas

Definition: Let ={F1,F2,,Fn}\mathcal{F} = \{F_1, F_2, \dots, F_n\} be a set of formulas, and 𝒜\mathcal{A} be the set of all atoms appearing in some formulas in \mathcal{F}. An interpretation of \mathcal{F} is a function :𝒜{1,0}\mathcal{I} : \mathcal{A} \rightarrow \{1,0\}. The truth value of FiF_i under \mathcal{I} is defined similarly as above.

Definition: A set of formulas ={F1,F2,,Fn}\mathcal{F} = \{F_1, F_2, \dots, F_n\} is (simultaneously) satisfiable if there is an interpretation \mathcal{I} such that (Fi)=1\mathcal{I}(F_i) = 1 for all ii. If this is the case, we say that \mathcal{I} is a model of \mathcal{F}. If this is not the case, we say that \mathcal{F} is unsatisfiable.


Logical consequence

Definition: Let ={F1,F2,,Fn}\mathcal{F} = \{F_1, F_2, \dots, F_n\} be a set of formulas and GG be a formula. GG is a logical consequence of \mathcal{F}, denoted G\mathcal{F} \models G, iff every model of \mathcal{F} is a model of .GG

Theorem (material implication vs logmical consequence)G\mathcal{F} \models G iff i=1nFiG\models \land_{i=1}^n F_i \rightarrow G.


Literals

Definition: A literal is an atom or the negation of an atom. For an atom pp, pp is called a positive literal, ¬p\neg p is a negative literal, and the pair {p,¬p}\{p, \neg p\} is a complementary pair of literals.

Theorem: A set of literals is satisfiable iff it does not contain a complementary pair of literals.


Semantic tableau

Given a formula FF, output a tree 𝒯\mathcal{T} all of whose leaves are marked closed×\times or open\odot.

  • Initially, the tree has a single node labeled with {F}\{F\} (not marked!)
  • Repeat: Choose an unmarked leaf vv labeled with a set of formulas U(v)U(v) (understood with \land).
    • If U(v)U(v) is a set of literals, mark vvclosed×\times if it contains a complementary pair, or open\odot otherwise.
    • Otherwise, choose a formula GG in U(v)U(v) which is not a literal in the following order of preference:
      • If GG has the form of ¬¬G\neg\neg G’, create a child ww of vv with label (U(v){G}){G}(U(v) \setminus \{G\}) \cup \{G’\}.
      • If GG1G2G \equiv G_1 \land G_2, create a child ww of vv with label (U(v){G}){G1,G2}(U(v) \setminus \{G\}) \cup \{G_1, G_2\}.
      • If GG1G2G \equiv G_1 \lor G_2, create two children w1,w2w_1, w_2 of vv with label (U(v){G}){Gi}(U(v) \setminus \{G\}) \cup \{G_i\} for wiw_i.

Example

Theorem

  • The algorithm terminates. After termination, all leaves are marked closed or open.
  • FF is unsatisfiable iff 𝒯\mathcal{T} is closed (meaning all leaves marked closed).
  • FF is satisfiable iff is open (meaning not closed).

Much better than truth tables.
Is there a better algorithm?


Sketched proofs

Sketched proof for termination.
Design an integer valued function W(v)W(v) related to the number of binary operators and the number of negations in U(v)U(v). Prove that W(v)W(v) is strictly decreasing, i.e. for a child vv’ of vv, W(v)<W(v)W(v’) < W(v).

Sketched proof for soundness.
Need to prove: If the tableau closes, then the formula is unsatisfiable. Induction on the height of the nodes.

Sketched proof for completeness.
Need to prove: If a tableau is open, then the formula is satisfiable. Let \ell be an open leaf, the union UU of U(v)U(v) for vv on the path from the root to \ell is a Hintikka set:

  • For all atom pp in a formula in UU, either pUp \notin U or ¬pU\neg p \notin U.
  • If UGG1G2U \ni G \equiv G_1 \land G_2, G1UG_1 \in U and G2UG_2 \in U.
  • If UGG1G2U \ni G \equiv G_1 \lor G_2, G1UG_1 \in U or G2UG_2 \in U.

Such a set satisfiable.


Section 3
Deduction

Deductive system

Definition: A deductive system consists of a set of formulas called axioms and a set of rules of inference. A proof in a deductive system is a (finite) sequence of formulas S={A1,A2,,An}S = \{A_1, A_2, \dots, A_n\}, where each AiA_i is either a theorem or a formula that can be inferred from previous formulas in the sequence using a rule of inference. The last formula AnA_n is called a theorem and the sequence SS is the proof of AnA_n. In this case, we say that AnA_n is provable, denoted An\vdash A_n.

A priori, no connection to semantics, purely syntactical.
In practice, hope to be semantically “meaningful”.


Gentzen system

  • Axioms (only one type): set of literals (understood with \lor) containing a complementary pair.
  • Rules of inference: infer a set of formulas UU from one or two sets of formulas U1U_1 and U2U_2.
  • If G1U1G_1 \in U_1, U=U1{G1}{¬¬G1}U = U_1 \setminus \{G_1\} \cup \{\neg\neg G_1\} can be inferred.
  • If G1,G2U1G_1, G_2 \in U_1, U=U1{G1,G2}{G1G2}U = U_1 \setminus \{G_1, G_2\} \cup \{G_1 \lor G_2\} can be inferred.
  • If G1U1G_1 \in U_1 and G2U2G_2 \in U_2, U=(U1{G1})(U2{G2}){G1G2}U = (U_1 \setminus \{G_1\}) \cup (U_2 \setminus \{G_2\}) \cup \{G_1 \land G_2\} can be inferred.
U1{G1}U1{¬¬G1}U1{G1,G2}U1{G1G2}U1{G1}U2{G2}U1U2{G1G2}\frac{\vdash U_1′ \cup \{G_1\}}{\vdash U_1′ \cup \{\neg\neg G_1\}}\quad\frac{\vdash U_1′ \cup \{G_1, G_2\}}{\vdash U_1′ \cup \{G_1 \lor G_2\}}\quad\frac{\vdash U_1′ \cup \{G_1\} \quad \vdash U_2′ \cup \{G_2\}}{\vdash U_1′ \cup U_2′ \cup \{G_1 \land G_2\}}

Prove (pq)(qp)\vdash (p \lor q) \rightarrow (q \lor p) in Gentzen system.

Proof.

  1. ¬p,q,p\vdash \neg p, q, p (Axiom)
  2. ¬q,q,p\vdash \neg q, q, p (Axiom)
  3. ¬(pq),q,p\vdash \neg(p \lor q), q, p (from 1 and 2, ¬p¬q¬(pq)\neg p \land \neg q \equiv \neg(p \lor q))
  4. ¬(pq),(qp)\vdash \neg(p \lor q), (q \lor p) (from 3)
  5. (pq)(qp)\vdash (p \lor q) \rightarrow (q \lor p) (from 4)

Prove p(qr)(pq)(pr)\vdash p \lor (q \land r) \rightarrow (p \lor q) \land (p \lor r) in Gentzen system.

Proof.

  1. ¬p,p,q\vdash \neg p, p, q (Axiom)
  2. ¬p,(pq)\vdash \neg p, (p \lor q) (from 1)
  3. ¬p,p,r\vdash \neg p, p, r (Axiom)
  4. ¬p,(pr)\vdash \neg p, (p \lor r) (from 3)
  5. ¬p,(pq)(pr)\vdash \neg p, (p \lor q) \land (p \lor r) (from 2, 4)
  6. ¬q,¬r,p,q\vdash \neg q, \neg r, p, q (Axiom)
  7. ¬q,¬r,(pq)\vdash \neg q, \neg r, (p \lor q) (from 6)
  8. ¬q,¬r,p,r\vdash \neg q, \neg r, p, r (Axiom)
  9. ¬q,¬r,(pr)\vdash \neg q, \neg r, (p \lor r) (from 8)
  10. ¬q,¬r,(pq)(pr)\vdash \neg q, \neg r, (p \lor q) \land (p \lor r) (from 7, 9)
  11. ¬(qr),(pq)(pr)\vdash \neg(q \land r), (p \lor q) \land (p \lor r) (from 10)
  12. ¬(p(qr)),(pq)(pr)\vdash \neg(p \lor (q \land r)), (p \lor q) \land (p \lor r) (from 5, 11)
  13. p(qr)(pq)(pr)\vdash p \lor (q \land r) \rightarrow (p \lor q) \land (p \lor r) (from 12)

Gentzen proof for AA corresponds to semantic tableau for ¬A\neg A upside down.

Theorem
A\models A iff A\vdash A in Gentzen system iff there is a closed semantic tableau for ¬A\neg A.


Hilbert system

  • Axioms:
    1. (A(BA))\vdash (A \rightarrow (B \rightarrow A))
    2. (A(BC))((AB)(AC))\vdash (A \rightarrow (B \rightarrow C)) \rightarrow ((A \rightarrow B) \rightarrow (A \rightarrow C))
    3. (¬B¬A)(AB)\vdash (\neg B \rightarrow \neg A) \rightarrow (A \rightarrow B)
  • Rule (only one): modus ponens, MP
AABB\frac{\vdash A \quad \vdash A \rightarrow B}{\vdash B}

Prove AA\vdash A \rightarrow A.

Proof.

  1. (A((AA)A))((A(AA))(AA))\vdash (A \rightarrow ((A \rightarrow A) \rightarrow A)) \rightarrow ((A \rightarrow (A \rightarrow A)) \rightarrow (A \rightarrow A)) (Axiom 2)
  2. A((AA)A)\vdash A \rightarrow ((A \rightarrow A) \rightarrow A) (Axiom 1)
  3. (A(AA))(AA)\vdash (A \rightarrow (A \rightarrow A)) \rightarrow (A \rightarrow A) (MP 1, 2)
  4. A(AA)\vdash A \rightarrow (A \rightarrow A) (Axiom 1)
  5. AA\vdash A \rightarrow A (MP 3, 4)

Definition: Let UU be a set of formulas and AA a formula. UAU \vdash A means that the formulas in UU are assumptions in a proof of AA. A proof under the assumptions UU is a sequence of lines UiϕiU_i \vdash \phi_i such that UiUU_i \subseteq U and ϕi\phi_i

  • is an axiom,
  • is a member of UU (assumption),
  • is a previously proved theorem,
  • can be inferred by MP from previous lines.

Derived rules in Hilbert system

  • U{A}BUAB\displaystyle\frac{U \cup \{A\} \vdash B}{U \vdash A \rightarrow B} (deduction rule).
  • U¬B¬AUAB, UABU¬B¬A\displaystyle\frac{U \vdash \neg B \rightarrow \neg A}{U \vdash A \rightarrow B},\ \frac{U \vdash A \rightarrow B}{U \vdash \neg B \rightarrow \neg A} (contraposition rule).
  • UABUBCUAC\displaystyle\frac{U \vdash A \rightarrow B\quad U \vdash B \rightarrow C}{U \vdash A \rightarrow C} (transitivity rule).
  • UA(BC)UB(AC)\displaystyle\frac{U \vdash A \rightarrow (B \rightarrow C)}{U \vdash B \rightarrow (A \rightarrow C)} (exchange of antecedents).
  • U¬¬AUA\displaystyle\frac{U \vdash \neg\neg A}{U \vdash A}, UAU¬¬A\displaystyle\frac{U \vdash A}{U \vdash \neg\neg A} (double negation).
  • U¬A0UA\displaystyle\frac{U \vdash \neg A \rightarrow 0}{U \vdash A} (reductio ad absurdum).

Prove (AB)((BC)(AC))\vdash (A \rightarrow B) \rightarrow ((B \rightarrow C) \rightarrow (A \rightarrow C)).

Proof.

  1. {AB,BC,A}A\{A \rightarrow B, B \rightarrow C, A\} \vdash A (Assumption)
  2. {AB,BC,A}AB\{A \rightarrow B, B \rightarrow C, A\} \vdash A \rightarrow B (Assumption)
  3. {AB,BC,A}B\{A \rightarrow B, B \rightarrow C, A\} \vdash B (MP 1, 2)
  4. {AB,BC,A}BC\{A \rightarrow B, B \rightarrow C, A\} \vdash B \rightarrow C (Assumption)
  5. {AB,BC,A}C\{A \rightarrow B, B \rightarrow C, A\} \vdash C (MP 3, 4)
  6. {AB,BC}AC\{A \rightarrow B, B \rightarrow C\} \vdash A \rightarrow C (Deduction 5)
  7. {AB}(BC)(AC)\{A \rightarrow B\} \vdash (B \rightarrow C) \rightarrow (A \rightarrow C) (Deduction 6)
  8. (AB)((BC)(AC))\vdash (A \rightarrow B) \rightarrow ((B \rightarrow C) \rightarrow (A \rightarrow C)) (Deduction 7)

Prove (A(BC))(B(AC))\vdash (A \rightarrow (B \rightarrow C)) \rightarrow (B \rightarrow (A \rightarrow C)).

Proof.

  1. {A(BC),B,A}A\{A \rightarrow (B \rightarrow C), B, A\} \vdash A (Assumption)
  2. {A(BC),B,A}A(BC)\{A \rightarrow (B \rightarrow C), B, A\} \vdash A \rightarrow (B \rightarrow C) (Assumption)
  3. {A(BC),B,A}BC\{A \rightarrow (B \rightarrow C), B, A\} \vdash B \rightarrow C (MP 1, 2)
  4. {A(BC),B,A}B\{A \rightarrow (B \rightarrow C), B, A\} \vdash B (Assumption)
  5. {A(BC),B,A}C\{A \rightarrow (B \rightarrow C), B, A\} \vdash C (MP 3, 4)
  6. {A(BC),B}AC\{A \rightarrow (B \rightarrow C), B\} \vdash A \rightarrow C (Deduction 5)
  7. {A(BC)}B(AC)\{A \rightarrow (B \rightarrow C)\} \vdash B \rightarrow (A \rightarrow C) (Deduction 6)
  8. (A(BC))(B(AC))\vdash (A \rightarrow (B \rightarrow C)) \rightarrow (B \rightarrow (A \rightarrow C)) (Deduction 7)

Prove ¬¬AA\vdash \neg\neg A \rightarrow A.

Proof.

  1. {¬¬A}¬¬A(¬¬¬A¬¬A)\{\neg\neg A\} \vdash \neg\neg A \rightarrow (\neg\neg\neg A \rightarrow \neg\neg A) (Axiom 1)
  2. {¬¬A}¬¬A\{\neg\neg A\} \vdash \neg\neg A (Assumption)
  3. {¬¬A}¬¬¬A¬¬A\{\neg\neg A\} \vdash \neg\neg\neg A \rightarrow \neg\neg A (MP 1, 2)
  4. {¬¬A}¬A¬¬¬A\{\neg\neg A\} \vdash \neg A \rightarrow \neg\neg\neg A (Contrapositive 3)
  5. {¬¬A}¬¬AA\{\neg\neg A\} \vdash \neg\neg A \rightarrow A (Contrapositive 4)
  6. {¬¬A}A\{\neg\neg A\} \vdash A (MP 2, 5)
  7. ¬¬AA\vdash \neg\neg A \rightarrow A (Deduction 6)

Prove (¬A0)A\vdash (\neg A \rightarrow 0) \rightarrow A.

Proof.

  1. {¬A0}¬A0\{\neg A \rightarrow 0\} \vdash \neg A \rightarrow 0 (Assumption)
  2. {¬A0}¬0¬¬A\{\neg A \rightarrow 0\} \vdash \neg 0 \rightarrow \neg\neg A (Contrapositive)
  3. {¬A0}¬0\{\neg A \rightarrow 0\} \vdash \neg 0 (0:=¬(BB)0 := \neg(B \rightarrow B))
  4. {¬A0}¬¬A\{\neg A \rightarrow 0\} \vdash \neg\neg A (MP 2, 3)
  5. {¬A0}A\{\neg A \rightarrow 0\} \vdash A (Double negation)
  6. (¬A0)A\vdash (\neg A \rightarrow 0) \rightarrow A (Deduction 5)

Theorem

  • Sound: If A\vdash A then A\models A.
  • Complete: If A\models A then A\vdash A.

Sketched proof for soundness and completeness.

  • Soundness:
    Axioms are valid, and MP is sound. That is, if AA and ABA \rightarrow B are valid, so is BB.
  • Completeness:
    For a set UU of formula, if U\vdash U in Gentzen system, then U\vdash \lor U in Hilbert system. Moreover, if UUU’ \subseteq U and U\vdash \lor U’ in Hilbert system, then U\vdash \lor U in Hilbert system. Finally, the rules of inference of Gentzen system can be simulated in Hilbert system.

formula \rightarrow semantic tableau \rightarrow Gentzen proof \rightarrow Hilbert proof

Definition: A set UU of formula is inconsistent iff for some formula AA, UAU \vdash A and U¬AU \vdash \neg A. UU is consistent iff it is not inconsistent. A deduction system is inconsistent if it contains an inconsistent set of formula.

Theorem
In the Hilbert system,

  • UU is inconsistent iff for all AA, UAU \vdash A.
  • UU is consistent iff for some AA, UAU \nvdash A.
  • UAU \vdash A iff U{¬A}U \cup \{\neg A\} is inconsistent.

Since the Hilbert system is sound and ⊭0\not\models 0, we have ⊬0\not\vdash 0 in the Hilbert system, so the Hilbert system is consistent.


Section 4
Resolution

Conjunctive normal form (CNF)

Definition: A formula is in conjunctive normal form (CNF) if it is a conjunction of disjunctions of literals.

Theorem: Every formula can be transformed into an equivalent formula in CNF.

  1. Express all operators in terms of ¬\neg, \land, \lor.
  2. Push negations inward.
  3. Delete double negations.
  4. Distribute disjunctions.

Example

(¬p¬q)(pq)(\neg p \rightarrow \neg q) \rightarrow (p \rightarrow q)
¬(¬¬p¬q)(¬pq)\equiv \neg(\neg\neg p \lor \neg q) \lor (\neg p \lor q)
(¬¬¬p¬¬q)(¬pq)\equiv (\neg\neg\neg p \land \neg\neg q) \lor (\neg p \lor q)
(¬pq)(¬pq)\equiv (\neg p \land q) \lor (\neg p \lor q)
(¬p¬pq)(q¬pq)\equiv (\neg p \lor \neg p \lor q) \land (q \lor \neg p \lor q)


Clausal form

Definition

  • A clause is a set of literals (seen as disjunction of the literals).
  • A formula in clausal form is a set of clauses (seen as conjunction of the clauses).

A clausal form is just another way to write a formula in CNF.

  • A clause with exactly one literal is a unit clause.
  • A clause with no literal is an empty clause, denoted \square.
    An empty clause is unsatisfiable.
  • A clause with a pair of clashing literals is trivial.
    A trivial clause is valid, and can be removed from a set of clauses.
  • An empty set of clauses is denoted \emptyset.
    An empty set of clauses is valid.

Resolvent

Definition: Let ll be a literal and C1,C2C_1, C_2 be clauses such that lC1l \in C_1 and lcC2l^c \in C_2. We say that C1C_1 and C2C_2 are clashing clauses, and they clash on the complementary pair of literals ll and lcl^c. The resolvent of C1C_1 and C2C_2 is the clause

C=Res(C1,C2)=(C1{l})(C2{lc}).C = \text{Res}(C_1, C_2) = (C_1 \setminus \{l\}) \cup (C_2 \setminus \{l^c\}).

C1C_1 and C2C_2 are called parent clauses of CC.

Theorem

  • If two clauses clash on more than one complementary pair, their resolvent is trivial.
  • The resolvent is satisfiable iff the parent clauses are both (simultaneously) satisfiable.

Resolution

  • Input: A set of clauses SS.
  • Output: Satisfiability of SS (yes or no).
  • Initially S0=SS_0 = S. Repeat the following to obtain Si+1S_{i+1} from SiS_i.
    • Choose a new clashing pair of clauses C1,C2SiC_1, C_2 \in S_i
    • Compute the resolvent CC.
    • If CC is trivial, Si+1=SiS_{i+1} = S_i.
    • If CC is not trivial, Si+1=Si{C}S_{i+1} = S_i \cup \{C\}.
  • Terminates if
    • C=C = \square.
    • No clashing pair.

Example
C={C1,C2,C3,C4}C = \{C_1, C_2, C_3, C_4\} where

  1. C1=pC_1 = p
  2. C2=pqC_2 = \bar{p}q
  3. C3=rC_3 = \bar{r}
  4. C4=pqrC_4 = \bar{p}\bar{q}r, then
  5. C5=pqC_5 = \bar{p}\bar{q} resolving C3C_3 and C4C_4
  6. C6=pC_6 = \bar{p} resolving C2C_2 and C5C_5
  7. C7=C_7 = \square resolving C1C_1 and C6C_6

A derivation of \square from SS is a refutation by resolution of SS.

Theorem

  • If there is a refutation by resolution of SS, then SS is unsatisfiable.
  • If SS is unsatisfiable, then \square will be derived by resolution.

Section 5
Application: SAT

Clauses

We write SSS \approx S’ to denote that SS is satisfiable iff SS’ is satisfiable.

Theorem (and definition) A pure literal in SS is a literal ll that appears in some clause but lcl^c does not appear in any clause. If this is the case, let SS’ be obtained from SS by deleting every clause containing ll. Then SSS \approx S’.

Theorem (and definition) Let {l}S\{l\} \in S be a unit clause and SS’ be obtained from SS by deleting every clause containing ll and deleting lcl^c from every remaining clause. Then SSS \approx S’.

Theorem (and definition) Let C1C2C_1 \subseteq C_2 be two clauses in SS. We say that C1C_1 subsumes C2C_2. If this is the case, let S=S{C2}S’ = S \setminus \{C_2\}. Then SSS \approx S’.

Theorem (and definition) Let UU be a set of atomic propositions. The renaming of SS by UU, denoted RU(S)R_U(S), is obtained from SS by replacing each literal ll on an atom pUp \in U by lcl^c. We have SRU(S)S \approx R_U(S).


Davis-Putnam Algorithm

  • Input: A formula FF in clausal form.
  • Output: FF is satisfiable or unsatisfiable.
  • Repeat the following:
    • If there is a unit clause {l}\{l\}, delete all clauses containing ll and delete lcl^c from all other clauses.
    • If there is a pure literal ll, delete all clauses containing ll.
    • Only when the previous two do not apply, choose an atom pp and perform all possible resolutions on clauses clashing on pp. Add these resolvents and delete all clauses containing pp or ¬p\neg p.
  • Terminate
    • If empty clause \square is produced, report unsatisfiable.
    • If no more rules applicable, report satisfiable.

Repeating the step about unit clauses until no longer applicable is called unit propagation.


Davis-Putnam-Logemann-Loveland Algorithm

  • Input: A formula FF in clausal form.
  • Output: FF is unsatisfiable or satisfiable with a partial interpretation that satisfies FF.
  • Call the following recursive function DPLL(B,)\operatorname{DPLL}(B, \mathcal{I}), where BB is a set of clauses and \mathcal{I} is a partial interpretation, initially with B=FB = F and \mathcal{I} empty.
    • Obtain BB’ from BB by unit propagation. Obtain \mathcal{I}’ from \mathcal{I} by adding all assignments during the propagation.
    • Evaluate BB’ under \mathcal{I}’.
      • If BB’ satisfied, return satisfiable and \mathcal{I}’.
      • If BB’ contains a clause CC such that (C)=0\mathcal{I}'(C) = 0, return unsatisfiable.
      • Otherwise, continue
    • Choose an atom pp in BB’, extend \mathcal{I}’ to 0\mathcal{I}_0 with 0(p)=0\mathcal{I}_0(p) = 0. Call DPLL(B,0)\operatorname{DPLL}(B’, \mathcal{I}_0). If result is satisfiable, return it. Otherwise continue.
    • Choose an atom pp in BB’, extend \mathcal{I}’ to 1\mathcal{I}_1 with 1(p)=1\mathcal{I}_1(p) = 1. Call DPLL(B,1)\operatorname{DPLL}(B’, \mathcal{I}_1). Return the result.

Linear time cases

The 2-SAT problem (satisfiability when each clause contains at most two literals) can be solved in linear time.

Definition: A formula FF in CNF is a Horn formula if every disjunction contains at most one positive literal.

A Horn formula can also be written in the form of conjunctions of implications.
The satisfiability of a Horn formula can be decided only by unit propagation (in linear time).

© 版权声明

相关文章

91 条评论

  • 幽影灵
    幽影灵 游客

    文中说的‘所有二元算子都能用¬∧∨表示’这个很关键,当年死活想不通

    日本
    回复
  • 迷糊的咖啡豆
    迷糊的咖啡豆 读者

    形式化验证里命题逻辑真的够用吗?感觉实际项目要处理的东西复杂多了

    中国上海
    回复
  • 孤影寒
    孤影寒 游客

    语法树那块例子再多点就好了

    中国上海
    回复
  • 石径分岔
    石径分岔 游客

    围观大佬讨论,我默默收藏了

    中国广东
    回复
  • 小彩虹糖
    小彩虹糖 游客

    命题逻辑确实是基础中的基础,理解透彻了后面才好走

    中国辽宁
    回复
  • 云端掠影
    云端掠影 游客

    救命,Hilbert系统证明A→A居然要五行!?🤯

    中国上海
    回复
  • 勤奋的蜜蜂
    勤奋的蜜蜂 游客

    之前用真值表做作业做到凌晨,后来发现语义tableau快多了

    中国河北
    回复
  • 量子旋律
    量子旋律 游客

    比教科书讲得清楚

    中国吉林
    回复
  • InstaFamous
    InstaFamous 读者

    Tableau里的α规则和β规则有优先级吗?感觉不好区分

    中国浙江
    回复
  • 竹影摇风
    竹影摇风 游客

    这证明看得人想摔书😤

    马来西亚
    回复
  • 影之歌
    影之歌 游客

    看得我眼花缭乱,逻辑学真是门玄学hhh

    中国甘肃
    回复
  • TwilightChaser
    TwilightChaser 游客

    学完这个直接想转行,太费脑子了😭

    中国北京
    回复
  • 核尘暴君
    核尘暴君 游客

    说Gentzen系统比真值表更抽象?其实更适合机器推理我觉得

    日本
    回复
  • 糖豆小软萌
    糖豆小软萌 游客

    逻辑课看得我眼皮打架,得整点咖啡☕

    中国湖北
    回复
  • 混沌主宰
    混沌主宰 游客

    这Tableau算法原理讲得清楚,但优化思路能多讲点就好了

    中国湖南
    回复
  • 香蕉皮侦探
    香蕉皮侦探 游客

    当年学命题逻辑,老师让手写分配律证明写了三页纸😂

    日本
    回复
  • 灵魂残响
    灵魂残响 读者

    语法树那块还不太理解,有例子吗🤔

    泰国
    回复
  • 樱桃小丸
    樱桃小丸 游客

    Hilbert那证明看得我直接放弃了,还是真值表香😤

    中国上海
    回复
    • 墨夜无声
      墨夜无声 游客

      确实,Hilbert那套证明太反直觉了,真值表虽然慢但至少能看懂

      中国北京@ 樱桃小丸
      回复