数理逻辑导论 学习笔记
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 represents a property (common characteristics), then 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:
Proper Subset 真子集:
Power Set 幂集:
- The set of all subsets of , i.e., .
Set Operations:
-
Union: .
-
Intersection: .
-
Difference: .
Relation
-tuples 有序 元组:
Binary Relation 二元关系:
- Cartesian Product (笛卡尔积): .
- A Binary relation over sets and is a subset of Cartesian product , denoted as .
- reads “ is -related to ”, and is denoted by or .
- Let’s define ,. When , we call is a relation over .
-ary Relation:
-
Cartesian product of sets : .
-
Denoted as if .
-
If , is denoted as an -ary relation over .
We also have Unary Relation (一元关系), Ternary Relation(三元关系), etc.
Equivalence Relation 等价关系:
-
Reflexive (自反): , .
-
Sysmmetric (对称): , if , then .
-
Transitive (传递): , if and , then .
-
A binary relation on a nonempty set is an equivalence relation if and only if is reflexive, sysmmetric and transitive.
Equivalence Class 等价类:
-
is the set of all elements of that are equivalent to . ( is an equivalence relation over a set )
-
Every element belongs to exactly one equivalence class.
-
Different equivalence classes are disjoint.
-
The set of all equivalence classes forms a partition of .
Partial Order Relation 偏序关系:
-
Antisymmetric (反对称): , if and , then .
-
A binary relation on a nonempty set is a partial order if and only if is reflexive, antisysmmetric and transitive.
-
Minimal Element: For , no that satisfys exists.
-
Maximal Element: For , no that satisfys exists.
Total Order Relation 全序关系 / Linear Order Relation:
-
A partial order relation on a set is a total order (linear order), iff , either or .
-
Intuitively, ant two elements are comparable.
Mathematical structures are defined with sets, plus various relations (e.g., ) and functions (e.g., ).
Function
Definition:
- 每个 都能找到唯一一个确定的 与之对应。
Denoted by . We use to denote .
-
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 .
-ary Function:
-
The domain of is the Cartesian product .
-
An -ary function maps ordered -tuples from its domain to elements in its codomain.
-
is called an -ary function in .
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 of natural numbers:
-
.
-
, .
-
Only generated by (finite iterations of) the previous two steps, .
-
-
The above definition can be equivalently stated as:
is the smallest inductive subset of that satisfies:
-
.
-
, .
-
-
Let be a property, and denotes that has property . If
-
.
-
, if , then ( is the successor of )
Then, for any , .
-
Proof by Induction 归纳证明:
-
Base Case: We need to show that is true for the smallest possible value of . e.g., is true.
-
Inductive Hypothesis: Assume that the statement is true for any positive integer .
-
Inductive Step: Show that the statement is true.
Recursive Definition 递归定义:
- , the value of can be computed from the above definition using .
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., is a proposition, while 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 |
---|---|---|---|
and | 合取 | conjunction | |
or | 析取 | disjunction | |
not | 否定 | negation | |
if…then… | 蕴含 | implication | |
if and only if | 等价 | equivalence |
Language Components:
-
Alphabet
-
Syntax (语法)
-
Semantics (语义)
Syntax
Alphabet:
-
Atomic Proposition (Atom):
-
Logic Connectives:
-
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 is a WFF, then so is .
-
If and are WFF, then so are .
-
Nothing else is a WFF.
e.g., is not a WFF.
Formulas:
-
: the set of expressions of consisting of an atom proposition symbol only.
-
: is the smallest set of expressions that satisfies:
-
.
-
If , then .
-
If , then , .
-
Some Definitions:
-
Segment (段, 子串): is a segment of if .
-
Proper Segment (真子段): is a segment of and .
-
Initial Segment / Prefix: , is an initial segment of . If is non-empty, is a proper prefix of .
-
Terminal Segment / Suffix: , is a terminal segment of . If is non-empty, is a proper suffix of .
Common Properties of WFF:
-
WFFs in are non-empty expressions.
-
Every WFF in has an equal number of opening and closing brackets.
-
Every proper prefix of WFF in has more opening brackets than closing brackets. Every proper suffix of WFF in has more closing brackets than opening brackets.
Hence, proper prefix and proper suffix are not WFF in .
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 a parse tree of it.
-
Subformula: If occurs within , then is a subformula of .
Proper Subformula: .
-
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., is the same as .
-
Precedence (优先级):
-
Parentheses take the highest precedence.
-
From highest to lowest: .
-
First group the rightmost occurrence. e.g., means .
-
Semantics
Truth Value:
-
There are only truth values of propositions: True () or False ().
-
Truth Table of .
-
Truth Table for : (maybe ?)
-
Truth Table for : (maybe ?)
Truth Valuation / Assignment:
-
Definition: a function .
We use or to denote the truth value of .
-
Theorem: Fix a truth valuation . Every formula has a value .
-
Tautology (永真式 / 重言式): , .
Contradiction (永假式 / 矛盾式): , .
Satisfiable: , .
Valuation Tree:

Logical Equivalence:
-
Definition: Two formulas and are logically equivalent iff they have the same value under any valuation.
i.e., and have the same final column in their truth tables.
i.e., is a tautology.
-
It’s an equivalence relation on .
Logical Identities:
-
Identity Laws (恒等率): , .
-
Domination Laws (支配律): , .
-
Idempotent Laws (幂等率) : , .
-
Double Negation Laws (双非率): .
-
Commutative Laws (交换律)
-
Associative Laws (结合律): , .
-
Distributive Laws (分配率): , .
-
De Morgan’s Laws (德摩根率): , .
-
Absorption Laws (吸收率): , .
-
Negation Laws (否定率): , .
-
Implication: .
-
Contrapositive (逆否): .
-
Equivalence: .
Substitution:
-
e.g., is a substitution instance of .
e.g., is a substitution instance of .
-
Theorem: If is a substitution instance of a tautology , then is again a tautology.
-
Substitution Theorem: Substitute in by () to get , then . (all WFF)
Semantic Entailment
Set of Formulas & its Satisfiability
-
Definition: Let . Define:
-
Satisfiable: is satisfiable iff , . And we say satisfies .
Entailment / Consequence:
-
Definition: We say:
-
is a logical consequence (逻辑推论) of , or
-
(semantically) entails (逻辑蕴含) , or
-
,
iff , if , then .
-
-
Proof:
-
Direct proof
-
Using a truth table
-
Proof by contradiction
-
-
Properties:
-
iff both and .
-
iff is a tautology.
-
iff is a tautology.
-
iff .
-
-ary Boolean Functions:
-
Definition: An -ary boolean function takes boolean inputs and returns a single boolean output.
-
There are different -ary boolean functions.
-
Notation:
More Binary Connectives:
-
Joint Denial (或非词): neither…nor…, denoted by .
-
Alternative Denial (与非词): not both…, denoted by .
-
Exclusive Disjunction (异或词): either…or…, denoted by .
Adequate Set:
-
Redundancy (累赘): is said to be definable in terms of and , because .
-
Definition: Every WFF is logically equivalent to a WFF using only connectives from an adequate (完备的) set.
-
Theorem 1: is adequate.
Theorem 2: Each of the sets , , is adequate.
-
Claim: Every -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: means that there is a proof premises (前提) and conclusion .
Types:
-
Hilbert-style System
-
Natural Deduction System
-
Resolution
Key Properties:
-
Soundness (可靠性): If , then .
-
Completioness (完备性): If , then .
Hilbert-style Proof System
Language:
-
Alphabet:
-
Formulas: WFF (connectives only and )
Axioms 公理:
Inference Rule:
-
Modus Ponens (MP, 分离规则): and imply .
Formal Proof:
-
Definition: A proof of formula is a finite sequence of formulas such that , is either
-
an axiom in , or
-
(), or
-
derived from () by the MP rule.
is provable, denoted by .
-
-
Theorem H1: .
-
Soundness (可靠性): If , then , which means is a tautology.
Proof from Assumptions:
-
Definition: can also be a formula in .
If , then is simply .
-
Theorem 6.2: Monotonicity (单调性): If and , then .
Derived Rules:
-
Deduction Rule: iff .
Theorem H2: .
-
Contrapositive Rule: iff .
Theorem H3: .
-
Transitivity Rule: If and , then .
-
Exchange of Antecedent Rule: If , then .
Theorem H4: and .
-
Double Negation Rule: iff .
Theorem H5: and (introduced as derived concepts just for convenience)
-
Ratio ad Adsurdum: If , then .
Theorem H6: .
Natural Deduction Proof System
Language:
-
Alphabet:
-
Formulas: WFF
Inference Rules:
-
Reflexivity (Premise): .
-
-introduction & -elimination:
-
-introduction & -elimination:
This box denotes a sub-proof. Assumptions inside a sub-proof cannot be used outside. e.g.:
-
-introduction & -elimination:
-
-introduction & -elimination:
where represents any contradiction.
-
-elimination:
Derived Rules:
-
Contradiction Elimination:
-
Modus Tollens (MT, 否定后件):
-
-introduction:
-
Proof by Contradiction (PBC):
-
Law of Excluded Middle (tertiam non datur, LEM, 排中律):
Soundness & Completeness:
-
Soundness (可靠性): If , then .
-
Completeness (完备性): If , then .
-
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.
Disjunctive Normal Form (DNF, 析取范式): A disjunction of conjunctive clauses.
Properties:
-
If is a formula in CNF, then is logically equivalent to a formula in DNF.
If is a formula in DNF, then is logically equivalent to a formula in CNF.
-
Every formula 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., .
Resolution proof system applies only to formulas in CNF. It is used to prove contradictions ().
Inference Rule:
-
Resolution Inference Rule:
Each step of the proof produces one clause (Resolvent, 消解子句) from two previous clauses by applying the resolution rule.
Special cases:
-
Unit Resolution:
-
Contradiction:
-
Proof Procedure:
-
To prove , we prove instead.
-
First, convert each formula in and to CNF.
-
Next, split CNF formulas at the s.
-
A CNF can be split to a set of disjunctive clauses. e.g., can be split to .
-
We treat as a clause containing no literal, i.e., the empty set . Since it contains no true literal, it is false.
-
-
Then, keep applying the resolution inference rule until either:
-
we have the empty clause , which means we have proved that , or
-
the rule can no longer be appiled to give a new formula, which means cannot be proven from .
-
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 (全称量词)
-
Existential Quantifier (存在量词)
Propositions:
-
Universal Proposition (全称命题): .
-
Existentail Proposition (存在命题): .
-
-
Functions: A function with arity (元数) is denoted as .
Syntax
Alphabet:
-
Non-Logical Symbols:
-
Constant Symbols (个体常元):
-
Predicates:
-
Function Symbols (函词):
-
-
Logical Symbols:
-
Quantifiers:
-
Variables (个体变元):
-
Connectives:
-
Punctuation: & comma
-
Equality (a special binary relation):
-
Formulas:
-
includes:
-
Constant Symbols , or
-
Variables , or
-
Function Symbols , where .
-
-
includes:
-
, where .
-
(also denoted as ), where .
-
-
can be generated by:
-
.
-
If , then .
-
If , then , where representes .
-
If and is a variable, then .
Conventions: Parentheses can be omitted as in PL. Parentheses around quantifiers can be also omitted.
Precedence: and have the same precedence level as , 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: is not within the scope of a quantified variable .
Bound Variables: The occurrence of is lies in the scope of some quantifier of .
-
An occurrence of is free if it is a leaf node in the parse tree such that there is no path upwards from that node to a node or .
Sentences / Closed Formula:
- Formulas with no free variables.
Interpretation / Structure :
An interpreattion consists of:
-
Domain / Universe: A domain , which must be a non-empty set.
-
Every constant / function / predicate is something of .
Environment :
- Assigns a value in the domain to every variable symbol in the language. (similar to assignment in PL)
Values:
-
, its value is
-
, if is a constant ; or
-
, if is a variable ; or
-
, if is a function .
-
-
,
-
;
-
iff .
-
-
, its truth value…
Logical Equivalence:
-
Duality (二元性): , .
-
Substitution: logical equivalence in PL still hold.
-
Commutativity: , .
-
Distributivity: , .
-
Quantifier Removal: , .
Sementic Entailment
Satisfiability & Validity:
-
and satisfy a formula , denoted by , iff .
-
If , , then satisfies , denoted by .
-
For a set of formulas , if , , then .
-
A formula is:
-
valid, if , ; (denoted by )
-
satisfiable, if , ;
-
unsatisfiable, if , .
-
Entailment:
-
Definition: We say:
-
semantically entails / logically implys , or
-
,
iff , if , then .
-
Undecidability:
- PL is decidable, but FOL is undecidable.
Natural Deduction Proof System
Substitution:
-
denotes the resulting formula by replacing each free occurrence of variable in with term .
Term must be “fresh” to avoid capture.
Inference Rule:
-
-introduction & -elimination:
-
-introduction & -elimination:
Soundness & Completeness:
- The natrual deduction proof system is sound and complete.
Normal Form:
-
Prenex Normal Form (前束范式): , where is a quantifier, and 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 :
-
Precondition: (FOL formula)
-
Code to be verified:
-
Postcondition: (FOL formula)
-
Correctness
Partial Correctness:
-
Hoare triple is satisfied under partial correctness iff
- for every state that satisfies ,
- if execution of starting from state terminates in a state ,
- then state satisfies condition .
- (if execution of does not terminate, it’s ok)
which is denoted as
Total Correctness:
-
Hoare triple is satisfied under total correctness iff
- for every state that satisfies ,
- execution of starting from state terminates in a state ,
- then state satisfies condition .
- (execution of must terminate)
which is denoted as
Hoare Logic
Presentation of a Proof:

Axioms:
-
Assignment:
-
Implied Rule: Precondition Strengthening:
-
Implied Rule: Postcondition Weakening:
-
Composition:
-
If Statements:
-
While Statements / Partial-While: (do not yet require termination)
where is a loop invariant which holds both before we execute and after 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.