Intro

History

Reduction to Absurdity 归谬法:

  • 从一个主张推出了矛盾,则这个主张是错的。

Syllogism 三段论:

  • Major premise

  • Minor premise

  • Conclusion

The Validity of Reasoning:

  • Truth for statements

  • Validity for arguments / reasoning (推理过程)

Early Phase:

  • Natural language is not reliable for logical reasoning.

  • We need a “universal language”, “calculus of reasoning”

Development:

  • Propositional Logic (PL, 命题逻辑)

  • First-Order Logic (FOL, 一阶逻辑)

Introduction to Reasoning

Logic studies forms of reasoning.

Learning Goals:

  • How do we express ambiguous natural language reasoing formally?

    Formal Language (形式语言).

  • How do we prove that a reasoning is valid?

    Formal Deduction System (形式推演系统).

For PL and FOL:

  • Modeling

  • Syntax 语法

  • Semantics 语义

  • Deduction 推理


Prerequisite Knowledge

Set

Definition:

  • Extension (外延): define by listing all elements.

  • Intension (内涵): define by common characteristics.

    If φ(x)\varphi(x) represents a property (common characteristics), then {xφ(x)}\{x \mid \varphi(x)\} denotes the set of all elements that have this property.

Axiom (公理) of Extension:

  • Two sets are equal if and only if they have the same members.

Subset: \subseteq

Proper Subset 真子集: \subset

Power Set 幂集:

  • The set of all subsets of AA, i.e., P(A)\mathcal P(A).

Set Operations:

  • Union: AB={xxAxB}A \cup B = \{x \mid x \in A \lor x \in B\}.

  • Intersection: AB={xxAxB}A \cap B = \{x \mid x \in A \land x \in B\}.

  • Difference: AB={xxAx∉B}A - B = \{x \mid x \in A \land x \not\in B\}.

Relation

nn-tuples 有序 nn 元组: 1,2,3,2\langle 1, 2, 3, 2 \rangle

Binary Relation 二元关系:

  • Cartesian Product (笛卡尔积): A×B={x,yxAyB}A \times B = \{\langle x, y \rangle \mid x \in A \land y \in B\}.
  • A Binary relation RR over sets XX and YY is a subset of Cartesian product A×BA \times B, denoted as RA×BR \subseteq A \times B.
  • x,yR\langle x, y \rangle \in R reads “xx is RR-related to yy”, and is denoted by R(x,y)R(x, y) or xRyxRy.
  • Let’s define X={xx,yR}X = \{x \mid \langle x, y \rangle \in R\}Y={yx,yR}Y = \{y \mid \langle x, y \rangle \in R\}. When X=YX = Y, we call RR is a relation over XX.

nn-ary Relation:

  • Cartesian product of sets A1,A2,,AnA_1, A_2, \cdots, A_n: A1×A2××An={x1,x2,,xnx1A1,x2A2,,xnAn}A_1 \times A_2 \times \cdots \times A_n = \{\langle x_1, x_2, \cdots, x_n \rangle \mid x_1 \in A_1, x_2 \in A_2, \cdots, x_n \in A_n\}.

  • Denoted as AnA^n if A1=A2==An=AA_1 = A_2 = \cdots = A_n = A.

  • If RAnR \subseteq A^n, RR is denoted as an nn-ary relation over AA.

We also have Unary Relation (一元关系), Ternary Relation(三元关系), etc.

Equivalence Relation 等价关系:

  • Reflexive (自反): xA\forall x \in A, xRxxRx.

  • Sysmmetric (对称): xA\forall x \in A, if xRyxRy, then yRxyRx.

  • Transitive (传递): x,y,zA\forall x, y, z \in A, if xRyxRy and yRzyRz, then xRzxRz.

  • A binary relation RR on a nonempty set AA is an equivalence relation if and only if RR is reflexive, sysmmetric and transitive.

Equivalence Class 等价类:

  • [x]R={yAxRy}[x]_R = \{y \in A \mid xRy\} is the set of all elements of AA that are equivalent to xx. (RR is an equivalence relation over a set AA)

  • Every element belongs to exactly one equivalence class.

  • Different equivalence classes are disjoint.

  • The set of all equivalence classes forms a partition of AA.

Partial Order Relation 偏序关系:

  • Antisymmetric (反对称): x,yA\forall x, y \in A, if xRyxRy and yRxyRx, then x=yx = y.

  • A binary relation RR on a nonempty set AA is a partial order if and only if RR is reflexive, antisysmmetric and transitive.

  • Minimal Element: For xAx \in A, no yAy \in A that satisfys yRxyRx exists.

  • Maximal Element: For xAx \in A, no yAy \in A that satisfys xRyxRy exists.

Total Order Relation 全序关系 / Linear Order Relation:

  • A partial order relation RR on a set AA is a total order (linear order), iff x,yA\forall x, y \in A, either xRyxRy or yRxyRx.

  • Intuitively, ant two elements are comparable.

Mathematical structures are defined with sets, plus various relations (e.g., <<) and functions (e.g., ++).

Function

Definition:

  • 每个 xXx \in X 都能找到唯一一个确定的 yYy \in Y 与之对应。

Denoted by f:ABf: A \to B. We use f(x)=yf(x) = y to denote x,yf\langle x, y \rangle \in f.

  • Domain: the set of input values.

  • Codomain (陪域, 上域): the set of possible output values.

  • Range (值域): the set of actual output values, i.e., a subset of the BB.

nn-ary Function:

  • The domain of ff is the Cartesian product A1×A2××AnA_1 \times A_2 \times \cdots \times A_n.

  • An nn-ary function maps ordered nn-tuples from its domain to elements in its codomain.

  • f:AnAf : A^n \to A is called an nn-ary function in AA.

Injective, Surjective & Bijective:

  • Injective (one-to-one, 单射): Each element of the codomain is mapped to by at most one element of the domain.

  • Surjective (onto, 满射): Each element of the codomain is mapped to by at least one element of the domain.

  • Bijective (one-to-one correspondence, 双射): Each element of the codomain is mapped to by exactly one element of the domain. (both injective and surjective)

Mathematical Definitons & Proof

Inductive Definition 归纳定义:

  • Definition of the set N\N of natural numbers:

    • 0N0 \in \N.

    • nN\forall n \in \N, n+1Nn + 1 \in \N.

    • Only nn generated by (finite iterations of) the previous two steps, nNn \in \N.

  • The above definition can be equivalently stated as:

    N\N is the smallest inductive subset of SS that satisfies:

    • 0S0 \in S.

    • nS\forall n \in S, n+1Sn + 1 \in S.

  • Let PP be a property, and P(x)P(x) denotes that xx has property PP. If

    • P(0)P(0).

    • nS\forall n \in S, if P(n)P(n), then P(n)P(n') (nn' is the successor of nn)

    Then, for any nSn \in S, P(n)P(n).

Proof by Induction 归纳证明:

  • Base Case: We need to show that P(n)P(n) is true for the smallest possible value of nn. e.g., P(n0)P(n_0) is true.

  • Inductive Hypothesis: Assume that the statement P(k)P(k) is true for any positive integer kn0k \ge n_0.

  • Inductive Step: Show that the statement P(k+1)P(k + 1) is true.

Recursive Definition 递归定义:

  • nN\forall n \in \N, the value of f(n)f(n) can be computed from the above definition using f(0),f(1),,f(n1)f(0), f(1), \cdots, f(n − 1).

Proof by Contradiction


Propositional Logic

Propositions & Connectives & Language in General

Proposition 命题:

  • Proposition: A proposition is a declarative sentence that can be judged as either true or false.

    e.g., 2+2=52 + 2 = 5 is a proposition, while x+y<0x + y < 0 is not a proposition.

  • Atomic Proposition (原子命题): A proposition that does not contain any smaller part that is still a proposition is called an atomic proposition.

  • Compound Proposition (复合命题): A proposition that involves the assembly of multiple propositions is called a compound proposition.

Logical Connectives:

Connectives Read as 名称 Term
\land and 合取 conjunction
\lor or 析取 disjunction
¬\neg not 否定 negation
\to if…then… 蕴含 implication
\leftrightarrow if and only if 等价 equivalence

Language Components:

  • Alphabet

  • Syntax (语法)

  • Semantics (语义)

Syntax

Alphabet:

  • Atomic Proposition (Atom): p,q,r,,p1,r2,p, q, r, \cdots, p_1, r_2, \cdots

  • Logic Connectives: ,,¬,,\land, \lor, \neg, \to, \leftrightarrow

  • Punctuation: opening and closing brackets

Expressions:

  • Expressions are finite strings of symbols.

  • The length is the number of occurrences of symbols in it.

  • Order matters.

Well-Formed Formulas (WFF):

  • Every atom is a WFF.

  • If α\alpha is a WFF, then so is (¬α)(\neg \alpha).

  • If α\alpha and β\beta are WFF, then so are (αβ),(αβ),(αβ),(αβ)(\alpha \land \beta), (\alpha \lor \beta), (\alpha \to \beta), (\alpha \leftrightarrow \beta).

  • Nothing else is a WFF.

e.g., (p)(p) is not a WFF.

Formulas:

  • Atom(LP)\text{Atom}\left(\mathscr{L}^P\right): the set of expressions of LP\mathscr{L}^P consisting of an atom proposition symbol only.

  • Form(LP)\text{Form}\left(\mathscr{L}^P\right): is the smallest set of expressions that satisfies:

    • Atom(LP)Form(LP)\text{Atom}\left(\mathscr{L}^P\right) \subseteq \text{Form}\left(\mathscr{L}^P\right).

    • If αForm(LP)\alpha \in \text{Form}\left(\mathscr{L}^P\right), then (¬α)Form(LP)(\neg \alpha) \in \text{Form}\left(\mathscr{L}^P\right).

    • If α,βForm(LP)\alpha, \beta \in \text{Form}\left(\mathscr{L}^P\right), then (αβ),(αβ),(αβ)(\alpha \land \beta), (\alpha \lor \beta), (\alpha \to \beta), (αβ)Form(LP)(\alpha \leftrightarrow \beta) \in \text{Form}\left(\mathscr{L}^P\right).

Some Definitions:

  • Segment (段, 子串): vv is a segment of uu if u=w1vw2u = w_1 v w_2.

  • Proper Segment (真子段): vv is a segment of uu and uvu \ne v.

  • Initial Segment / Prefix: u=vwu = vw, vv is an initial segment of uu. If ww is non-empty, vv is a proper prefix of uu.

  • Terminal Segment / Suffix: u=vwu = vw, ww is a terminal segment of uu. If vv is non-empty, vv is a proper suffix of uu.

Common Properties of WFF:

  • WFFs in LP\mathscr{L}^P are non-empty expressions.

  • Every WFF in LP\mathscr{L}^P has an equal number of opening and closing brackets.

  • Every proper prefix of WFF in LP\mathscr{L}^P has more opening brackets than closing brackets. Every proper suffix of WFF in LP\mathscr{L}^P has more closing brackets than opening brackets.

    Hence, proper prefix and proper suffix are not WFF in LP\mathscr{L}^P.

Parse Tree 解析树:

  • Definition:

    • The root is the formula.

    • Leaves are atoms.

    • Each internal node is formed by applying some formation rule on its children.

  • WFF \leftrightarrow a parse tree of it.

  • Subformula: If GG occurs within FF, then GG is a subformula of FF.

    Proper Subformula: GFG \ne F.

  • Immediate Subformula: The children of a formula in its parse tree.

    Leading Connective: The connective that is used to join children.

Unique Readability Theorem:

  • There is a unique way to construct every WFF.

Simplification:

  • Convention (公约): We may drop the outermost parentheses, i.e., FF is the same as (F)(F).

  • Precedence (优先级):

    • Parentheses take the highest precedence.

    • From highest to lowest: ¬,,,,\neg, \land, \lor, \to, \leftrightarrow.

    • First group the rightmost occurrence. e.g., pqrp \to q \to r means p(qr)p \to (q \to r).

Semantics

Truth Value:

  • There are only 22 truth values of propositions: True (11) or False (00).

  • Truth Table of ¬,,\neg, \land, \lor.

  • Truth Table for pqp \to q: (maybe pqp \le q?)

    pp qq pqp\to q
    00 00 11
    00 11 11
    11 00 00
    11 11 11
  • Truth Table for pqp \leftrightarrow q: (maybe p=qp = q?)

    pp qq pqp\leftrightarrow q
    00 00 11
    00 11 00
    11 00 00
    11 11 11

Truth Valuation / Assignment:

  • Definition: a function v:Atom(LP){0,1}v: \text{Atom}(\mathscr{L}^P) \to \{0, 1\}.

    We use v(p)v(p) or pvp^v to denote the truth value of pp.

  • Theorem: Fix a truth valuation vv. Every formula αFrom(LP)\alpha \in \text{From}(\mathscr{L}^P) has a value αv{0,1}\alpha^v \in \{0, 1\}.

  • Tautology (永真式 / 重言式): v\forall v, Av=1A^v = 1.

    Contradiction (永假式 / 矛盾式): v\forall v, Av=0A^v = 0.

    Satisfiable: v\exists v, Av=1A^v = 1.

Valuation Tree:

Logical Equivalence:

  • Definition: Two formulas AA and BB are logically equivalent iff they have the same value under any valuation.

    i.e., AA and BB have the same final column in their truth tables.

    i.e., ABA \leftrightarrow B is a tautology.

  • It’s an equivalence relation on Form(LP)\text{Form}(\mathscr{L}^P).

Logical Identities:

  • Identity Laws (恒等率): pTpp \land T \equiv p, pFpp \lor F \equiv p.

  • Domination Laws (支配律): pFFp \land F \equiv F, pTTp \lor T \equiv T.

  • Idempotent Laws (幂等率) : pppp \land p \equiv p, pppp \lor p \equiv p.

  • Double Negation Laws (双非率): ¬(¬p)p\neg (\neg p) \equiv p.

  • Commutative Laws (交换律)

  • Associative Laws (结合律): (pq)rp(qr)(p \land q) \land r \equiv p \land (q \land r), (pq)rp(qr)(p \lor q) \lor r \equiv p \lor (q \lor r).

  • Distributive Laws (分配率): p(qr)(pq)(pr)p \lor (q \land r) \equiv (p \lor q) \land (p \lor r), p(qr)(pq)(pr)p \land (q \lor r) \equiv (p \land q) \lor (p \land r).

  • De Morgan’s Laws (德摩根率): ¬(pq)¬p¬q\neg (p \land q) \equiv \neg p \lor \neg q, ¬(pq)¬p¬q\neg (p \lor q) \equiv \neg p \land \neg q.

  • Absorption Laws (吸收率): p(pq)pp \lor (p \land q) \equiv p, p(pq)pp \land (p \lor q) \equiv p.

  • Negation Laws (否定率): p¬pFp \land \neg p \equiv F, p¬pTp \lor \neg p \equiv T.

  • Implication: pq¬pqp \to q \equiv \neg p \lor q.

  • Contrapositive (逆否): pq¬q¬pp \to q \equiv \neg q \to \neg p.

  • Equivalence: pq(pq)(qp)p \leftrightarrow q \equiv (p \to q) \land (q \to p).

Substitution:

  • e.g., (rs)(ts)(r \to s) \land (t \to s) is a substitution instance of pqp \land q.

    e.g., (pp)(pp)(p \leftrightarrow p) \leftrightarrow (p \leftrightarrow p) is a substitution instance of ppp \leftrightarrow p.

  • Theorem: If BB is a substitution instance of a tautology AA, then BB is again a tautology.

  • Substitution Theorem: Substitute CC in AA by DD (CDC \equiv D) to get BB, then ABA \equiv B. (all WFF)

Semantic Entailment

Set of Formulas & its Satisfiability

  • Definition: Let ΣForm(LP)\Sigma \subseteq \text{Form}(\mathscr{L}^P). Define:

    Σv={1BΣ,Bv=10otherwise\Sigma^v = \begin{cases} 1 & \forall B \in \Sigma, B^v = 1 \\ 0 & \text{otherwise} \end{cases}

  • Satisfiable: Σ\Sigma is satisfiable iff v\exists v, Σv=1\Sigma^v = 1. And we say vv satisfies Σ\Sigma.

Entailment / Consequence:

  • Definition: We say:

    • AA is a logical consequence (逻辑推论) of Σ\Sigma, or

    • Σ\Sigma (semantically) entails (逻辑蕴含) AA, or

    • ΣA\Sigma \models A,

    iff v\forall v, if Σv=1\Sigma^v = 1, then Av=1A^v = 1.

  • Proof:

    • Direct proof

    • Using a truth table

    • Proof by contradiction

  • Properties:

    • ABA \equiv B iff both ABA \models B and BAB \models A.

    • A\varnothing \models A iff AA is a tautology.

    • ABA \models B iff ABA \to B is a tautology.

    • {A1,,An}A\{A_1, \cdots, A_n\} \models A iff (A1AnA)\varnothing \models (A_1 \land \cdots \land A_n \to A).

nn-ary Boolean Functions:

  • Definition: An nn-ary boolean function takes nn boolean inputs and returns a single boolean output.

  • There are 22n2^{2^n} different nn-ary boolean functions.

  • Notation: fA1A2fA_1A_2\cdots

More Binary Connectives:

  • Joint Denial (或非词): neither…nor…, denoted by pq¬(pq)p \downarrow q \equiv \neg(p \lor q).

  • Alternative Denial (与非词): not both…, denoted by pq¬(pq)p \uparrow q \equiv \neg(p \land q).

  • Exclusive Disjunction (异或词): either…or…, denoted by pq¬(pq)p \otimes q \equiv \neg (p \leftrightarrow q).

Adequate Set:

  • Redundancy (累赘): \to is said to be definable in terms of ¬\neg and \lor, because (pq)((¬p)q)(p \to q) \equiv ((\neg p) \lor q).

  • Definition: Every WFF is logically equivalent to a WFF using only connectives from an adequate (完备的) set.

  • Theorem 1: {¬,,}\{\neg, \land, \lor\} is adequate.

    Theorem 2: Each of the sets {¬,}\{\neg, \land\}, {¬,}\{\neg, \lor\}, {¬,}\{\neg, \to\} is adequate.

  • Claim: Every nn-ary boolean function is definable in terms of only connectives from an adequate set.

Proof Systems

A formal proof is syntatic (语法上的), rather than semantic (语义上的).

Definition & Notation:

  • Definition: A formal proof system (deductive system, 形式推演系统) consists of the language part and the inference part.

  • Notation: ΣA\Sigma \vdash A means that there is a proof premises (前提) Σ\Sigma and conclusion AA.

Types:

  • Hilbert-style System

  • Natural Deduction System

  • Resolution

Key Properties:

  • Soundness (可靠性): If ΣA\Sigma \vdash A, then ΣA\Sigma \models A.

  • Completioness (完备性): If ΣA\Sigma \models A, then ΣA\Sigma \vdash A.

Hilbert-style Proof System

Language:

  • Alphabet: (,),¬,,p,q,r,(, ), \neg, \to, p, q, r, \cdots

  • Formulas: WFF (connectives only ¬\neg and \to)

Axioms 公理:

  • A1:A(BA)A_1 : A \to (B \to A)

  • A2:(A(BC))((AB)(AC))A_2 : (A \to (B \to C)) \to ((A \to B) \to (A \to C))

  • A3:(¬A¬B)(BA)A_3 : (\neg A \to \neg B) \to (B \to A)

Inference Rule:

  • Modus Ponens (MP, 分离规则): AA and ABA \to B imply BB.

    rmp:A,ABBr_{mp} : \frac{A, A \to B}{B}

Formal Proof:

  • Definition: A proof of formula AA is a finite sequence of formulas A1,A2,,AnA_1, A_2, \cdots, A_n such that in\forall i \le n, AiA_i is either

    • an axiom in H\mathscr{H}, or

    • AjA_j (j<ij < i), or

    • derived from Aj,AkA_j, A_k (j,k<ij, k < i) by the MP rule.

    AA is provable, denoted by A\vdash A.

  • Theorem H1: AA\vdash A \to A.

  • Soundness (可靠性): If α\vdash \alpha, then α\models \alpha, which means α\alpha is a tautology.

Proof from Assumptions:

  • Definition: AiA_i can also be a formula in Σ\Sigma.

    If Σ=\Sigma = \varnothing, then ΣA\Sigma \vdash A is simply A\vdash A.

  • Theorem 6.2: Monotonicity (单调性): If ΣA\Sigma \vdash A and ΣΣ\Sigma \subseteq \Sigma', then ΣA\Sigma' \vdash A.

Derived Rules:

  • Deduction Rule: Σ{A}B\Sigma \cup \{A\} \vdash B iff ΣAB\Sigma \vdash A \to B.

    Theorem H2: (AB)((BC)(AC))\vdash (A \to B) \to ((B \to C) \to (A \to C)).

  • Contrapositive Rule: Σ¬B¬A\Sigma \vdash \neg B \to \neg A iff ΣAB\Sigma \vdash A \to B.

    Theorem H3: ¬¬AA\vdash \neg \neg A \to A.

  • Transitivity Rule: If ΣAB\Sigma \vdash A \to B and ΣBC\Sigma \vdash B \to C, then ΣAC\Sigma \vdash A \to C.

  • Exchange of Antecedent Rule: If ΣA(BC)\Sigma \vdash A \to (B \to C), then ΣB(AC)\Sigma \vdash B \to (A \to C).

    Theorem H4: ¬A(AB)\vdash \neg A \to (A \to B) and A(¬AB)\vdash A \to (\neg A \to B).

  • Double Negation Rule: ΣA\Sigma \vdash A iff Σ¬¬A\Sigma \vdash \neg \neg A.

    Theorem H5: true\vdash \text{true} and ¬false\vdash \neg \text{false} (introduced as derived concepts just for convenience)

  • Ratio ad Adsurdum: If Σ¬Afalse\Sigma \vdash \neg A \to \text{false}, then ΣA\Sigma \vdash A.

    Theorem H6: (A¬A)¬A\vdash (A \to \neg A) \to \neg A.

Natural Deduction Proof System

Language:

  • Alphabet: (,),¬,,,,,p,q,r,(, ), \neg, \land, \lor, \to, \leftrightarrow, p, q, r, \cdots

  • Formulas: WFF

Inference Rules:

  • Reflexivity (Premise): Σ,αα\Sigma, \alpha \vdash \alpha.

  • \land-introduction & \land-elimination:

    αβ(αβ)(αβ)α,(αβ)β\frac{\alpha \quad \beta}{(\alpha \land \beta)} \quad \quad \frac{(\alpha \land \beta)}{\alpha}, \frac{(\alpha \land \beta)}{\beta}

  • \to-introduction & \to-elimination:

    αβ(αβ)(αβ)αβ\frac{\boxed{\begin{array}{c} \alpha \\ \vdots \\ \beta \end{array}}}{(\alpha \to \beta)} \quad \quad \frac{(\alpha \to \beta) \quad \alpha}{\beta}

    This box denotes a sub-proof. Assumptions inside a sub-proof cannot be used outside. e.g.:

  • \lor-introduction & \lor-elimination:

    α(αβ),α(βα)(α1α2)α1βα2ββ\frac{\alpha}{(\alpha \lor \beta)}, \frac{\alpha}{(\beta \lor \alpha)} \quad \quad \frac{(\alpha_1 \lor \alpha_2) \quad \boxed{\begin{array}{c} \alpha_1 \\ \vdots \\ \beta \end{array}} \quad \boxed{\begin{array}{c} \alpha_2 \\ \vdots \\ \beta \end{array}}}{\beta}

  • ¬\neg-introduction & ¬\neg-elimination:

    α(¬α)α(¬α)\frac{\boxed{\begin{array}{c} \alpha \\ \vdots \\ \bot \end{array}}}{(\neg \alpha)} \quad \quad \frac{\alpha \quad (\neg \alpha)}{\bot}

    where \bot represents any contradiction.

  • ¬¬\neg \neg-elimination:

    (¬(¬α))α\frac{(\neg (\neg \alpha))}{\alpha}

Derived Rules:

  • Contradiction Elimination:

    α\frac{\bot}{\alpha}

  • Modus Tollens (MT, 否定后件):

    (pq)(¬q)¬p\frac{(p \to q) \quad (\neg q)}{\neg p}

  • ¬¬\neg \neg-introduction:

    α(¬(¬α))\frac{\alpha}{(\neg (\neg \alpha))}

  • Proof by Contradiction (PBC):

    (¬α)α\frac{\boxed{\begin{array}{c} (\neg \alpha) \\ \vdots \\ \bot \end{array}}}{\alpha}

  • Law of Excluded Middle (tertiam non datur, LEM, 排中律):

    (α(¬α))\frac{}{(\alpha \lor (\neg \alpha))}

Soundness & Completeness:

  • Soundness (可靠性): If Σα\Sigma \vdash \alpha, then Σα\Sigma \models \alpha.

  • Completeness (完备性): If Σα\Sigma \models \alpha, then Σα\Sigma \vdash \alpha.

  • The natrual deduction proof system is sound and complete.

Resolution Proof System

aka. Refutation (反驳) System.

Normal Form:

  • This is a standardized representation of logical formulas.

  • Literal (单式, 文字): An atomic formula of the negation of that.

  • Conjunctive Clause (合取子句): A conjuction of literals.

    Disjunctive Clause (析取子句): A disjuction of literals.

  • Conjunctive Normal Form (CNF, 合取范式): A conjuction of disjunctive clauses.

    (ab)(cd)(a \lor \cdots \lor b) \land \cdots \land (c \lor \cdots \lor d)

    Disjunctive Normal Form (DNF, 析取范式): A disjunction of conjunctive clauses.

    (ab)(cd)(a \land \cdots \land b) \lor \cdots \lor (c \land \cdots \land d)

Properties:

  • If AA is a formula in CNF, then ¬A\neg A is logically equivalent to a formula in DNF.

    If AA is a formula in DNF, then ¬A\neg A is logically equivalent to a formula in CNF.

  • Every formula AForm(LP)A \in \text{Form}\left(\mathscr{L}^P\right) is logically equivalent to some formula in CNF and DNF.

  • Principal CNF / DNF: Each clause in a principal CNF / DNF contains all propositional variables exactly once, and no two clauses are the same. e.g., (p¬qr)(pq¬r)(p \lor \neg q \lor r) \land (p \lor q \lor \neg r).

Resolution proof system applies only to formulas in CNF. It is used to prove contradictions (\bot).

Inference Rule:

  • Resolution Inference Rule:

    (αp)((¬p)β)(αβ)\frac{(\alpha \lor p) \quad ((\neg p) \lor \beta)}{(\alpha \lor \beta)}

    Each step of the proof produces one clause (Resolvent, 消解子句) from two previous clauses by applying the resolution rule.

    Special cases:

    • Unit Resolution: (αp)(¬p)α\dfrac{(\alpha \lor p) \quad (\neg p)}{\alpha}

    • Contradiction: p(¬p)\dfrac{p \quad (\neg p)}{\bot}

Proof Procedure:

  • To prove Σφ\Sigma \vdash \varphi, we prove Σ{¬φ}\Sigma \cup \{\neg \varphi\} \vdash \bot instead.

  • First, convert each formula in Σ\Sigma and ¬φ\neg \varphi to CNF.

  • Next, split CNF formulas at the \lands.

    • A CNF can be split to a set of disjunctive clauses. e.g., (pq)(q¬r)s(p \lor q) \land (q \lor \neg r) \land s can be split to {p,q},{q,¬r},{s}\{p, q\}, \{q, \neg r\}, \{s\}.

    • We treat \bot as a clause containing no literal, i.e., the empty set \varnothing. Since it contains no true literal, it is false.

  • Then, keep applying the resolution inference rule until either:

    • we have the empty clause \bot, which means we have proved that Σφ\Sigma \vdash \varphi, or

    • the rule can no longer be appiled to give a new formula, which means φ\varphi cannot be proven from Σ\Sigma.

Soundness & Completeness:

  • The resolution proof system is sound and complete.

First-Order Logic

aka. Predicate Logic.

Basic Concepts of FOL:

  • Domain (论域): A non-empty set of objects.

  • Constants: Specific, concrete, individual objects in the domain.

  • Variables

  • Predicates (谓词): A predicate represents:

    • a property of a individual object in the domain, or

    • a relationship among multiple individuals.

  • Quantifiers (量词):

    • Universal Quantifier \forall (全称量词)

    • Existential Quantifier \exists (存在量词)

    Propositions:

    • Universal Proposition (全称命题): xP(x)\forall xP(x).

    • Existentail Proposition (存在命题): xP(x)\exists xP(x).

  • Functions: A function with nn arity (元数) is denoted as fnf^{n}.

Syntax

Alphabet:

  • Non-Logical Symbols:

    • Constant Symbols (个体常元): c1,c2,c3,c_1, c_2, c_3, \cdots

    • Predicates: P,Q,P1,P21,Q12,P, Q, P_1, P_2^1, Q_1^2, \cdots

    • Function Symbols (函词): f,g,f1,f21,g12,f, g, f_1, f_2^1, g_1^2, \cdots

  • Logical Symbols:

    • Quantifiers: ,\forall, \exists

    • Variables (个体变元): x,y,z,x1,x2,y1,x, y, z, x_1, x_2, y_1, \cdots

    • Connectives: ¬,,,,\neg, \land, \lor, \to, \leftrightarrow

    • Punctuation: (,)(, ) & comma

    • Equality (a special binary relation): ==

Formulas:

  • Term(L)\text{Term}(\mathscr{L}) includes:

    • Constant Symbols cc, or

    • Variables xx, or

    • Function Symbols fn(t1,t2,,tn)f^n(t_1, t_2, \cdots, t_n), where t1,t2,tnTerm(L)t_1, t_2, \cdots t_n \in \text{Term}(\mathscr{L}).

  • Atom(L)\text{Atom}(\mathscr{L}) includes:

    • P(t1,t2,,tn)P(t_1, t_2, \cdots, t_n), where t1,t2,tnTerm(L)t_1, t_2, \cdots t_n \in \text{Term}(\mathscr{L}).

    • =(t1,t2)= (t_1, t_2) (also denoted as t1=t2t_1 = t_2), where t1,t2Term(L)t_1, t_2 \in \text{Term}(\mathscr{L}).

  • Form(L)\text{Form}(\mathscr{L}) can be generated by:

    • Atom(L)Form(L)\text{Atom}(\mathscr{L}) \subseteq \text{Form}(\mathscr{L}).

    • If αForm(L)\alpha \in \text{Form}(\mathscr{L}), then (¬α)Form(L)(\neg \alpha) \in \text{Form}(\mathscr{L}).

    • If α,βForm(L)\alpha, \beta \in \text{Form}(\mathscr{L}), then (αβ)Form(L)(\alpha * \beta) \in \text{Form}(\mathscr{L}), where * representes ,,,\land, \lor, \to, \leftrightarrow.

    • If αForm(L)\alpha \in \text{Form}(\mathscr{L}) and xx is a variable, then (xα),(xα)Form(L)(\forall x \alpha), (\exists x \alpha) \in \text{Form}(\mathscr{L}).

    Conventions: Parentheses can be omitted as in PL. Parentheses around quantifiers can be also omitted.

    Precedence: \forall and \exists have the same precedence level as ¬\neg, which are higer than all binary connectives.

Parse Tree:

  • Similar to that in PL.

Semantics

Scope of Variables:

  • The formula adjacent to the quantifier.

Types of Variables:

  • Free Variables: xx is not within the scope of a quantified variable xx.

    Bound Variables: The occurrence of xx is lies in the scope of some quantifier of xx.

  • An occurrence of xx is free if it is a leaf node in the parse tree such that there is no path upwards from that node xx to a node x\forall x or x\exists x.

Sentences / Closed Formula:

  • Formulas with no free variables.

Interpretation / Structure I\mathcal{I}:

An interpreattion consists of:

  • Domain / Universe: A domain DD, which must be a non-empty set.

  • Every constant / function / predicate is something of I\mathcal{I}.

Environment EE:

  • Assigns a value in the domain to every variable symbol in the language. (similar to assignment in PL)

Values:

  • tTerm(L)\forall t \in \text{Term}(\mathscr{L}), its value t(I,E)t^{(\mathcal{I}, E)} is

    • cIc^{\mathcal{I}}, if tt is a constant cc; or

    • xEx^E, if tt is a variable xx; or

    • fI(t1(I,E),,tn(I,E))f^{\mathcal{I}}\left(t_1^{(\mathcal{I}, E)}, \cdots, t_n^{(\mathcal{I}, E)}\right), if tt is a function f(t1,,tn)f(t_1, \cdots, t_n).

  • PAtom(L)\forall P \in \text{Atom}(\mathscr{L}),

    • P(t1,,tn)(I,E)=PI(t1(I,E),,tn(I,E))P(t_1, \cdots, t_n)^{(\mathcal{I}, E)} = P^{\mathcal{I}}\left(t_1^{(\mathcal{I}, E)}, \cdots, t_n^{(\mathcal{I}, E)}\right);

    • (t1=t2)(I,E)=1(t_1 = t_2)^{(\mathcal{I}, E)} = 1 iff t1(I,E)=tn(I,E)t_1^{(\mathcal{I}, E)} = t_n^{(\mathcal{I}, E)}.

  • φForm(L)\forall \varphi \in \text{Form}(\mathscr{L}), its truth value…

Logical Equivalence:

  • Duality (二元性): ¬xA(x)x¬A(x)\neg \forall x A(x) \equiv \exists x \neg A(x), ¬xA(x)x¬A(x)\neg \exists x A(x) \equiv \forall x \neg A(x).

  • Substitution: logical equivalence in PL still hold.

  • Commutativity: xyA(x,y)yxA(x,y)\forall x \forall y A(x, y) \equiv \forall y \forall x A(x, y), xyA(x,y)yxA(x,y)\exists x \exists y A(x, y) \equiv \exists y \exists x A(x, y).

  • Distributivity: x(A(x)B(x))xA(x)xB(x)\forall x (A(x) \land B(x)) \equiv \forall x A(x) \land \forall x B(x), x(A(x)B(x))xA(x)xB(x)\exists x (A(x) \lor B(x)) \equiv \exists x A(x) \lor \exists x B(x).

  • Quantifier Removal: \forall \equiv \cdots \land \cdots, \exists \equiv \cdots \lor \cdots.

Sementic Entailment

Satisfiability & Validity:

  • I\mathcal{I} and EE satisfy a formula α\alpha, denoted by IEα\mathcal{I} \models_E \alpha, iff α(I,E)=1\alpha^{(\mathcal{I}, E)} = 1.

  • If E\forall E, IEα\mathcal{I} \models_E \alpha, then II satisfies α\alpha, denoted by Iα\mathcal{I} \models \alpha.

  • For a set of formulas Σ\Sigma, if φΣ\forall \varphi \in \Sigma, IEφI \models_E \varphi, then IEΣI \models_E \Sigma.

  • A formula α\alpha is:

    • valid, if I,E\forall I, E, IEαI \models_E \alpha; (denoted by α\varnothing \models \alpha)

    • satisfiable, if I,E\exists I, E, IEαI \models_E \alpha;

    • unsatisfiable, if I,E\forall I, E, I̸EαI \not\models_E \alpha.

Entailment:

  • Definition: We say:

    • Σ\Sigma semantically entails / logically implys α\alpha, or

    • Σα\Sigma \models \alpha,

    iff I,E\forall I, E, if IEΣI \models_E \Sigma, then IEαI \models_E \alpha.

Undecidability:

  • PL is decidable, but FOL is undecidable.

Natural Deduction Proof System

Substitution:

  • α[t/x]\alpha[t / x] denotes the resulting formula by replacing each free occurrence of variable xx in α\alpha with term tt.

    Term tt must be “fresh” to avoid capture.

Inference Rule:

  • \forall-introduction & \forall-elimination:

    y freshα[y/x](xα)(xα)α[t/x]\frac{\boxed{\begin{array}{c} y \text{ fresh} \\ \vdots \\ \alpha[y / x] \end{array}}}{(\forall x \alpha)} \quad \quad \frac{(\forall x \alpha)}{\alpha[t / x]}

  • \exists-introduction & \exists-elimination:

    α[t/x](xα)(xα)α[u/x],u freshββ\frac{\alpha[t / x]}{(\exists x \alpha)} \quad \quad \frac{(\exists x \alpha) \quad \boxed{\begin{array}{c} \alpha[u / x], u \text{ fresh} \\ \vdots \\ \beta \end{array}}}{\beta}

Soundness & Completeness:

  • The natrual deduction proof system is sound and complete.

Normal Form:

  • Prenex Normal Form (前束范式): Q1x1Q2x2QkxkBQ_1 x_1 Q_2 x_2 \cdots Q_k x_k B, where QiQ_i is a quantifier, and BB is quantifier free.

    Every formula in FOL is logically equivalent to a formula in prenex normal form.

Higher-Order Logic

Temporal Logic: for reasoning about how truths change over time.

Modal Logic: extends classical logic with operators for necessity and possibility.

Hoare Logic: for proving the correctness of computer programs.


Program Verification

Process of program verification:

  • Convert an inital description into a logical formula.

  • Write a program.

  • Prove the program satisfies the formula.

We will focus on the third part.

Formal Specification

Two important components of a specification:

  • Precondition: The state before the program executes.

  • Postcondition: The state after the program executes.

Our formal notation:

  • is based on FOL logic.

  • applies to imperative programs.

  • uses Hoare Triples.

Hoare Triple:

  • A Hoare triple (P) C (Q)(|P|) ~ C ~ (|Q|):

    • Precondition: PP (FOL formula)

    • Code to be verified: CC

    • Postcondition: QQ (FOL formula)

Correctness

Partial Correctness:

  • Hoare triple (P) C (Q)(|P|) ~ C ~ (|Q|) is satisfied under partial correctness iff

    • for every state s1s_1 that satisfies PP,
    • if execution of CC starting from state s1s_1 terminates in a state s2s_2,
    • then state s2s_2 satisfies condition QQ.
    • (if execution of CC does not terminate, it’s ok)

    which is denoted as

    par(P) C (Q)\models_{\text{par}} (|P|) ~ C ~ (|Q|)

Total Correctness:

  • Hoare triple (P) C (Q)(|P|) ~ C ~ (|Q|) is satisfied under total correctness iff

    • for every state s1s_1 that satisfies PP,
    • execution of CC starting from state s1s_1 terminates in a state s2s_2,
    • then state s2s_2 satisfies condition QQ.
    • (execution of CC must terminate)

    which is denoted as

    tot(P) C (Q)\models_{\text{tot}} (|P|) ~ C ~ (|Q|)

Hoare Logic

Presentation of a Proof:

Axioms:

  • Assignment:

    (Q[E/x]) x=E (Q)\frac{}{(|Q[E / x]|) ~ x = E ~ (|Q|)}

  • Implied Rule: Precondition Strengthening:

    PP(P) C (Q)(P) C (Q)\frac{P \to P' \quad (|P'|) ~ C ~ (|Q|)}{(|P|) ~ C ~ (|Q|)}

  • Implied Rule: Postcondition Weakening:

    (P) C (Q)QQ(P) C (Q)\frac{(|P|) ~ C ~ (|Q'|) \quad Q' \to Q}{(|P|) ~ C ~ (|Q|)}

  • Composition:

    (P) C1 (Q)(Q) C2 (R)(P) C1;C2 (R)\frac{(|P|) ~ C_1 ~ (|Q|) \quad (|Q|) ~ C_2 ~ (|R|)}{(|P|) ~ C_1; C_2 ~ (|R|)}

  • If Statements:

    (PB) C1 (Q)(P¬B) C2 (Q)(P) if B {C1} else {C2} (Q)\frac{(|P \land B|) ~ C_1 ~ (|Q|) \quad (|P \land \neg B|) ~ C_2 ~ (|Q|)}{(|P|) ~ \text{if } B ~ \{C_1\} \text{ else } \{C_2\} ~ (|Q|)}

  • While Statements / Partial-While: (do not yet require termination)

    (IB) C (I)(I) while B {C} (I¬B)\frac{(|I \land B|) ~ C ~ (|I|)}{(|I|) ~ \text{while } B ~ \{C\} ~ (|I \land \neg B|)}

    where II is a loop invariant which holds both before we execute CC and after CC terminates.

    To prove termination (total correcness), we need to find a variant, which is an integer expression that:

    • always stays non-negative, and
    • strictly decrease in every loop iteration.

    The automatic extraction of useful variants or termination expressions cannot be realized.

Decidability

Decision Problem:

  • The answer is yes or no.

Decidable:

  • If there exists an algorithm that always halts (停止) with a yes / no answer for every input.

e.g.

  • Collatz Conjecture: Algorithmically undecidable.
  • The Halting Problem: Undecidable.
  • The Partial Correctness Problem: Undecidable.