L17 – Logic II: Propositional logic

Discrete Mathematics2026年5月19日发布 芮和
5.4K 490
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).

© 版权声明

相关文章

49 条评论

  • 网络炼金术士
    网络炼金术士 读者

    Tableau算法里的α规则和β规则具体是怎么区分优先级的?🤔

    中国台湾
    回复
  • 漫天星
    漫天星 游客

    没错,逻辑这块基础打牢了后面学形式化验证也容易不少。

    中国广西
    回复
  • 赤霄使
    赤霄使 游客

    当年学逻辑的时候,老师让我们手动证明分配律,写了两页纸才搞完。现在看到这些证明步骤又PTSD了😂

    中国北京
    回复
  • 尬场制造机
    尬场制造机 游客

    确实,命题逻辑是基础,搞懂这些后面一阶逻辑才好理解

    日本
    回复
  • 袜子总失踪
    袜子总失踪 读者

    那归结原理(Resolution)和这个语义tableau有啥关系?后续会讲吗?

    中国
    回复
  • 小熊壮壮
    小熊壮壮 游客

    自动化定理证明真的用这些规则吗?感觉好原始

    日本
    回复
  • 光影诗人
    光影诗人 游客

    这些符号看得我脑壳疼

    日本
    回复
  • 星际架构师
    星际架构师 读者

    硬核,我是来看热闹的,告辞👋

    韩国
    回复
  • 星魂吟游者
    星魂吟游者 游客

    说Gentzen复杂的,其实它和tableau是对偶的😂

    中国安徽
    回复
  • 优雅的孔雀
    优雅的孔雀 游客

    之前学数理逻辑的时候,对Hilbert系统的证明真的无语,一个简单的定理要写一堆

    中国云南
    回复
  • 麋鹿邮差
    麋鹿邮差 游客

    真值表算法复杂度O(2^n)吧?语义tableau能好多少?

    中国山东
    回复
  • 巧克力热饮
    巧克力热饮 读者

    比我们老师讲得清楚多了hhh

    越南
    回复
  • 虚拟之光
    虚拟之光 游客

    硬核内容,看得我头皮发麻😂

    中国浙江
    回复
  • 毛峰初雪
    毛峰初雪 游客

    Hilbert系统就三个公理一个规则?那证明A→A都那么长…真实用吗?

    中国北京
    回复
  • 孤独的牧星人
    孤独的牧星人 读者

    语义表和真值表比起来确实省事多了

    智利
    回复
  • 旧时风月
    旧时风月 读者

    Hilbert系统那三条公理看着简单,真用起来头都大了

    中国广东
    回复
  • 冥界之瞳
    冥界之瞳 读者

    归结算法蛮巧妙的

    美国
    回复
  • 愤怒的画家
    愤怒的画家 读者

    古希腊就开始研究逻辑了啊

    美国
    回复
  • 山路诗人
    山路诗人 读者

    感觉这些证明写起来比算数累多了

    中国
    回复
    • 农夫田七
      农夫田七 读者

      证明真的比算术费脑子多了

      中国北京@ 山路诗人
      回复
  • 懒人日记本
    懒人日记本 读者

    逻辑符号多了以后太容易看花眼了

    中国北京
    回复
  • 黯夜猎魂
    黯夜猎魂 读者

    CNF转换那块挺绕的,得慢慢看

    丹麦
    回复
  • 蝴蝶梦
    蝴蝶梦 读者

    语义表比真值表快不少

    南非
    回复
  • 纸面具幻想家
    纸面具幻想家 读者

    DP算法简化了不少

    日本
    回复
  • 暴力小熊
    暴力小熊 读者

    甜豆浆那个例子笑到了

    日本
    回复
    • 小猪猪猪
      小猪猪猪 读者

      甜豆浆这个例子我也get到了

      中国江苏@ 暴力小熊
      回复
  • 黑洞边缘
    黑洞边缘 读者

    Hilbert系统公理少但推导真麻烦

    中国辽宁
    回复
  • 翠微亭
    翠微亭 读者

    盖茨系统和语义表倒过来看,有意思

    中国福建
    回复
    • 永夜之瞳
      永夜之瞳 读者

      反向思考确实有启发

      日本@ 翠微亭
      回复
  • NightshadeWhisper
    NightshadeWhisper 读者

    命题逻辑的语法树表示挺直观

    中国辽宁
    回复
  • 幽梦织影
    幽梦织影 读者

    消解法步骤清晰,比真值表靠谱多了

    美国
    回复
    • 智鸦谜语
      智鸦谜语 读者

      真值表变量一多就爆炸了

      中国福建@ 幽梦织影
      回复
  • 逐风客
    逐风客 读者

    置换定理这块挺直观的,替换就完事了

    中国安徽
    回复
  • 凌霄
    凌霄 读者

    归结法那块终于讲清楚了,之前一直懵

    中国河南
    回复
    • 绘画艺术家
      绘画艺术家 读者

      同感,这块确实容易绕进去

      中国河北@ 凌霄
      回复
  • 董明珠
    董明珠 读者

    希尔伯特系统证明也太多了吧

    中国湖北
    回复
    • 白绫吊死鬼
      白绫吊死鬼 读者

      同感,推演起来头大

      中国上海@ 董明珠
      回复
  • 午夜独行者
    午夜独行者 读者

    真值表太慢,还是归结法香

    中国台湾
    回复
  • 柴火生活
    柴火生活 读者

    SAT求解器作用大吗

    美国
    回复
  • Blackout Poet
    Blackout Poet 读者

    命题逻辑的语法定义挺清晰的,就是证明部分有点烧脑

    中国山东
    回复
    • 黑曜石贤者
      黑曜石贤者 读者

      同感,证明部分容易绕进去

      韩国@ Blackout Poet
      回复
  • 猎户追风
    猎户追风 游客

    这Gentzen系统看着比真值表还复杂啊🤔

    日本
    回复