A declarative sentence that can be judged as either true or false is called Proposition.
1.1.1 Atomic Proposition 原子命题
The proposition can’t be devided into a smaller one.
Typically symbolized as p,q,r,…
1.1.2 Compound Proposition 复合命题
The proposition is built by two or more atomic proposition is called composition proposition.
Typically symbolized as A,B,C,…
1.2 Logical Connectives 逻辑连接词
Connectives
Meaning
Term
∧
and
conjuction
∨
or
disjunction
¬
not
negation
→
if…then…
implication
↔
if and only if
equivalence
1.3 Alphabet 符号系统
Atomic proposition: p,q,r,…
Logic connectives: ∧,∨,¬,→,↔
Punctuations: ( , )
1.4 Expressions 表达式
Finite strings of symbols is called expression.
Empty expression is denoted by λ.
1.5 Formulas 公式
Definition for Atom(LP): A set of expressions consisting of one symbol only.
Induction definition for Form(LP):
Atom(LP)⊆Form(LP).
If A∈Form(LP), then (¬A)∈Form(LP).
If A,B∈Form(LP), then (A∧B),(A∨B),(A→B),(A↔B)∈Form(LP).
A well-formed formula(WFF) can be and only be derived by this way.
1.5.1 Parse Tree 解析树
A parse tree for Form(LP) is a tree satisfying:
The root is the formula.
Leaves are atomic formulas.
Each internal node is formed by applying some formation rule on its children.
e.g. The parse tree for p∨q→¬p∧r is:
An expression of LP is a WFF if and only if there is a parse tree of it.
Each well-formed formula of LP has a unique parsing tree.
From this, we can verify whether an expression is WFF programmably by building a parse tree for it.This is a sample Python program used to verify the validity of an input formula.
# define a binary tree as the parse tree classparseTree:
# initialize the a leaf of the parse tree def__init__(self, char = ''): self.char = char self.left = None self.right = None self.parent = None self.flag = False# flag to check if this leaf is valid
# insert a character at the current leaf definsert(self, char): self.char = char
# visit the left child of the current leaf defvisit_left_child(self): if self.left == None: self.left = parseTree('') self.left.parent = self return self.left # visit the right child of the current leaf defvisit_right_child(self): if self.right == None: self.right = parseTree('') self.right.parent = self return self.right
# visit the parent of the current leaf defvisit_parent(self): if self.parent != None: return self.parent else: self.flag = True# if the current leaf is the root, then it is invalid return self
# build the parse tree from the input string defbuild_parse_tree(string): root = parseTree() # the root of the parse tree cur = root alphabet = "abcdefghijklmnopqrstuvwxyz"# the set of all possible atomic propositions
for c in string: if c == '(': cur = cur.visit_left_child() # '(' means the a branch of the parse tree is needed elif c == ')': cur = cur.visit_parent() # ')' means the current branch of the parse tree is finished else: if cur.char == ''and c in alphabet: # if the current leaf is empty and the character is an atomic proposition cur.char = c elif c == '¬': # if the character is a negation cur = cur.visit_parent() cur.insert(c) cur = cur.visit_left_child() elif c == '∧'or c == '∨'or c == '→'or c == '↔': # if the character is a binary connective cur = cur.visit_parent() cur.insert(c) cur = cur.visit_right_child() elif c == ' ': # if the character is a space, then skip continue else: cur.flag = True# if the character is invalid, then the current leaf is invalid return root
defcheck_parse_tree(parse_tree): if parse_tree.flag: returnFalse if parse_tree.char == '': returnFalse
# check if the parse tree is valid, using preorder traversal method # A parse tree is of an well-formed formula if and only if all of its leaves are valid and non-empty if parse_tree.left != None: ifnot check_parse_tree(parse_tree.visit_left_child()): returnFalse if parse_tree.right != None: ifnot check_parse_tree(parse_tree.visit_right_child()): returnFalse returnTrue
# Main function if __name__ == '__main__': s = input() parse_tree = build_parse_tree(s) if check_parse_tree(parse_tree): print(True) else: print(False)
1.5.2 Subformula 子公式
A formula G is a subformula of F if G occurs within F. Specially we called G a proper subformula when G=F.
Immediate formula are the branch of a formula in parse tree, and leading connectives is the connective that is used to join the branch.
1.5.3 Structure 结构
Lemma 1: Well-formed formulas of LP are non-empty expressions.
Lemma 2 : Every well-formed formula of LP has an equal number of opening and closing brackets.
Given a non-empty expression u=w1vw2
Segment: v is a segment of u.
Proper Segment: v is non-empty and v=u.
Prefix (Initial Segment): v is a prefix of u if w2=λ, specially v is called proper prefix if v=u.
Suffix (Terminal Segment): v is a suffix of u if w1=λm specially v is called proper suffix if v¬u.
Lemma 3:
Every proper prefix of a well-formed formula in LP has more opening brackets than closing brackets.
Similarly, every proper suffix of a well-formed formula in LP has more closing brackets than opening brackets.
UniqueReadabilityTheorem: There is a unique way to construct every well-formed formula.
1.6 Precendence 优先顺序
Connectives: ¬,∧,∨,→,↔ (Less priority from left to right).
Parentheses (with punctuations"()") take the highest precendence.
With connectives of the same precedence, the rightmost occurrence have more priority (e.g. p→q→r≡p→(q→r) ).
2. Semantics 语义
2.1 Truth Table 真值表
2.2 Truth Valuation 真值指派
A truth valuation is a function v:Atom(LP)→{0,1}.
For p∈Atom(LP), we use pv to denote the truth value of p under the truth valuation v,pv∈{0,1}
Atomic proposition: p∈{0,1}
Negation:
(¬A)v={10 if Av=0 else
Conjuction:
(A∧B)v={10 if Av=Bv=1 else
Disjunction:
(A∨B)v={10 if Av=1 or Bv=1 else
Implication:
(A→B)v={10 if Av=0 or Bv=1 else
Equivalence:
(A↔B)v={10 if Av=Bv else
Fix a truth valuation v. Every formula α∈Form(LP) has a value av∈{0,1}.
Proof :
Initial Condition: If α∈Atom(LP), then there must exist αv∈{0,1} (definition).
Inductive Step:
If av∈{0,1}, then (¬a)v∈{0,1} according to the truth table.
If α,β∈{0,1}, then (α⋆β) also does for every binary connetives ⋆.
Conclusion: By this induction, every formula in LP has a truth value in {0,1}; and by the Unique Readablitity Theorem we proved that α has only one value under a fixed v.
2.3 Truth Properties of Formulas 公式的性质
Let A∈Form(LP)
A is tautogy(永真式) when ∀v,Av=1.
A is contradiction(矛盾式) or unsatisfiable when ∀v,Av=0.
A is satisfiable(可满足的) when ∃x,AV=1.
2.4 Logic Equivalence 逻辑等价
Formulas A,B are logically equivalent iff ∀v,Av=Bv.
2.4.1 Laws for Logic Equivalence 逻辑等价律
Identity laws:
p∧T≡p
p∨F≡p
Domination laws:
p∨T≡T
p∧F≡F
Idempotent laws:
p∨p≡p
p∧p≡p
Double negation laws:
¬(¬p)≡p
Commutative laws:
p∨q≡q∨p
p∧q≡q∧p
Associative laws:
(p∨q)∨r≡p∨(q∨r)
(p∧q)∧r≡p∧(q∧r)
Distributive laws:
p∨(q∧r)≡(p∨q)∧(p∨r)
p∧(q∨r)≡(p∧q)∨(p∧r)
De Morgan’s law:
¬(p∨q)≡¬p∧¬q
¬(p∧q)≡¬p∨¬q
Absorption laws:
p∨(p∧q)≡p
p∧(p∨q)≡p
Negation laws:
p∨¬p≡T
p∧¬p≡F
Implicative laws:
p→q≡¬p∨q
Contrapositive laws:
p→q≡¬q→¬p
Equivalence laws:
p↔q≡(p→q)∧(q→p)
2.4.2 Substitution 代换
B is a substitution instance of A iff B may be obtained from A by substituting formulas for propositional variables in A, replacing each occurrence of the same variable by an occurrence of the same formula.
e.g. (p→p)↔(p→p) is a substitution instance of q↔q
Theorem 1: A,B∈(LP). If A is a tautology and B is a susbtitution instance of A, then B is again a tautology.
Theorem 2: A∈Form(LP). A contain a subformula C (i.e., C is a segment of A and is itself a well-formed formula). If C≡D, then replacing some occurrences (not necessarily all) of the subformula C in A with D to obtain the formula B, then A≡B.
3. Entailment 蕴涵
Let Σ⊆Form(LP),A∈Form(LP). We say:
A is a logical consequence of Σ
ΣentailsA
Σ⊨A
Iff for all truth valuation v if Σv=1 then Av=1
Also, Σ⊨A denotes there exists a truth valuation v such that Σv=1 and Av=0.
3.1 Prove Entailment 蕴涵证明
Direct Proof: For every truth valuation under which all of the premises are true, show that the conclusion is also true under this valuation.
Using Truth Table: Consider all rows of the truth table in which all of the formulas in Σ are true. Verify that A is true in all of these rows.
Proof by Contradiction Assume that the entailment does not hold, which means that there is a truth valuation under which all of the premises are true and the conclusion is false. Derive a contradiction.
4. Proof 形式化证明
A formal proof system (deductive system, 形式推演系统) consists of the language part and the inference part.
Language part
Symbols and alphbet
Set of formulas
Inference part
Set of axioms(公理)
Inference rules
4.1 Notation 记号
Σ⊢A
denotes that "there is a proof with premises Σ and conclusion A.