Download A. Propositional Logic: syntax

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
Logic in Computer Science
Chapter 3
Propositional Logic
3.1. The syntax
Transparency No. 3.1-1
Propositional Logic: syntax
Key contents
 Vocabulary:
 Syntax:
 wffs(合法句式)
 subformulas
 occurrences of subformulas
 Semantics:(語意)
 Interpretations
 Truth conditions
 models, logical equivalence,
logical consequence
 validity, satisfiability.

Properties of PL0




 Normal forms:
 CNF, DNF, [clausal forms]
 Axiomatics: (公設化)




Calculus
An axiom system for PL0
Soundness(正確性)
Completeness(完備性)
 Compactness (緻密性)
 [Proof methods:
 Analytic tableaux method
 resolution ]
deduction theorem,
substitution theorem
some equivalences
functional completeness
Transparency No. 3.1-2
Propositional Logic: syntax
Propositional Logic PL0 (The language)
 the logic of 'or', 'and', 'not', 'if' (material implication)
and ‘iff’ etc.
 Vocabulary: (S = PV  LC where)
 1. PV= {p1,p2,...}: a (countable) set of symbols, each called
a propositional variable.
used to represent propositions of domains of interest.
e.g., p1 = "It is raining now"; p2 = " A1 is the father of A2"; etc.
 2. (LC is ) logical connectives:
1. ∧ (and), ∨ (or), ~ (not),  (if),  (iff; if and only if;
or equivalence),
[2. and more (XOR, NAND, NOR, False, True etc.) if
needed ]
3. Parentheses: (, ).
Transparency No. 3.1-3
Propositional Logic: syntax
Syntax: well-formed formulas(wff)
 Wff is a subset of S* and is defined inductively as follows:
1. Every propositional variable (also called atom) pi is a (wellformed) formula.
2. If A, B are wffs, then so are (A ∧ B), (A∨B), (A  B), (A  B)
and ~A.
 Some wffs and some non-wffs:
1. (p1 ∨ (p2 ∧ p1)),
2. (p1  (p2 ∨(p3  ( ~p1 ∧ p2)))
3. (p1 ∨ q),
4. (p1),
5. (~(p1 ∧ p2) )
Problem: Which of the above strings are wffs ?
Notes:
1. We use A,B,C,… for wffs and p,q,r, for propositional variables.
Transparency No. 3.1-4
Propositional Logic: syntax
Abbreviations and conventions about wffs
 Conventions:




wffs are also called sentences or simply formulas.
Wffs which are not atoms are called compound formulas.
use A,B, C,... to represent arbitrary wffs
use p, q, r,... to represent arbitrary propositional variables
 Parentheses are omitted if ambiguity cannot occur.
 A\/B\/C abbreviates ((A\/B)\/C)
 precedence of connectives:
 ~ > ∧>∨> >
 e.g.,
1. p ∧ q ∨ r means ((p ∧ q) ∨ r)
2. p ∨ q ∧ ~ r  p  q ∨ s means
((p ∨(q ∧ ~r))  (q ∨ s))
Transparency No. 3.1-5
Propositional Logic: syntax
Immediate subformulas and primary connecive
 Def: I-sub(A) = immediate subformulas of A, and
pconn(A) = primary connective of A are defined as
 1. I-sub(p) = {}, I-sub( (B @ C) ) = {B, C}, I-sub( ~B ) = {B}.
 2. pconn(p) is undefined, pconn((B@C)) = @, pconn(~B) =
~.
where @ is /\, \/,-> or <->.
Any wff in I-sub(A) is called an immediate subformula of A.
Example: What about ((p->(q->r))->((p->q)->(p->r))) ?
Theorem: [Unique readability of wffs:] Every compound wff
has a unique primary connective and [a unique set of]
immediate subformulas.
Transparency No. 3.1-6
Propositional Logic: syntax
Some lemmas about Wffs
1. Ever wff has the same number of ‘(‘ and ‘)’.
Pf: by structural ind.
base case: A = p is an atom: then #l(A) = 0 = #r(A).
ind. step: case 1. A = (B @C).
#l(A) = 1 + #l(B) + #l(C)
= 1 + #r(B) + #r(C) --- by ind. hyp.
= #r(A).
case 2. A = ~B. Similar to case 1.
Def: a, b: two strings.
 a is a prefix of b iff $ g s.t. b = a g.
 a is a proper prefix of b iff a  b and a is a prefix of b.
Transparency No. 3.1-7
Propositional Logic: syntax
some lemmas about wffs (cont’d)
2. If A is a wff and a is a proper prefix of A, then a either is
a (possibly empty) sequence of ~ or has more left
parentheses than right parentheses.
Pf: A = p. trivial.
 A = ~B. Suppose a = ~ b and B = bg, where g  e.
=> (by ind. hyp) b is either a seq of ~ or #l(b) > #r(b).
=> a is either a seq of ~ or #l(a) > #r(a).
 A = (B @ C). Four cases need to be considered.
 1. a = ‘(‘. ok!
2. a = ‘(b’. where b is a prefix of B.
 3. a = ‘(B@’.
4. a = ‘(B@ b’, where b is a prefix of C.
qed
Corollary: If A is a wff and a is a proper prefix of A, then a
is not a wff.
Transparency No. 3.1-8
Propositional Logic: syntax
Proof of unique readability
Pf: 1. [existence:] induction on the structure of wff A.
 Base case: A = p is an atom. Ok. Since A is not a compound wff.
 Ind. step: case 1: A = (B @ C), where @ is /\,\/,-> or <->.
Then {B, C} is a set of immediate subformulas of A, and @ is the
primary connective of A.
case 2: A = ~B, then {B} is a set of immediate subformula of A and ~ is a
primary connective of A. qed
2. [uniqueness:]
 base case: A = p. trivial.
 A is compound. case analysis:
 1. A = ~B = ~C. => B = C. ok.
 2. A = (B1 @1 C1) = (B2 @2 C2). if B1  B2, then B1 is a proper prefix of B2
or vice versa. => either B1 or B2 is not a wff.

if B1 = B2 => @1 = @2 and C1 = C2.
 3. A = ~B = (C @ D). impossible! since ~  (.
qed
Transparency No. 3.1-9
Propositional Logic: syntax
The Subformulas of wffs
 Definition: [subformulas]
 For each wff A, the set sub(A) of all subformulas of A is
defined inductively as follows:
 1. If A = p, where p is a propositional variable, then sub(p)
= {p}.
 2. If A = B @ C, where @ is either /\,\/,-> or , then

sub(A) = sub(B) U sub(C) U {A}.
 3. If A = ~B, then sub(A) = sub(B) U {A}.
 If B  sub(A), we say B is a subformula of A.
 If B  sub(A) but B  A, we say B is a proper subformula of
A.
 If G is a set of wffs, define sub(G) = U A  G sub(A)
Ex: Find subformulas of A = ((p \/ (q /\ ~r)) -> (q \/ s)).
Ex: What is the relationship between sub(A) and I-sub(A) ?
Transparency No. 3.1-10
Propositional Logic: syntax
Tree representation of wffs
 Examples:
 (x + 3) / (2 + 1) * y
 ((p \/ q) /\ ~ ( ~q /\ r))
Transparency No. 3.1-11
Propositional Logic: syntax
(x + 3) / (2 + 1) *y
(x+3)/(2+1)
(x+3)
x
y
2+1
3
*
2
/
y
+
1
x
+
3
2
1
parse tree for arithmetic expression
Transparency No. 3.1-12
Propositional Logic: syntax
root
(p \/ q) /\ ~ ( ~q /\ r)
leaf
internal node
(immediate)predecessor
(p \/ q)
~ ( ~q /\ r)
-- (parent) ancestor
(immediate)successor
-- (child) descendant
p
(~q /\ r)
q
degree, branch [factor]
n-ary tree
~q
r path
depth (of a tree)
level (of a node)
q
Formation tree for the formula (p\/q)/\~(~q /\ r)
Transparency No. 3.1-13
Propositional Logic: syntax
Assign addresses (id codes) to nodes of a tree
e
(p \/ q) /\ ~ ( ~q /\ r)
(p \/ q)
p
00
q
01
0
1
~ ( ~q /\ r)
(~q /\ r) 10
100 ~q
r
q
1000
101
Transparency No. 3.1-14
Propositional Logic: syntax
Formal definition of a Tree [domain]
 define [n] =def {0,1,…, n-1}.
[n]* =def {0,1,…,n-1}* be the set of all n-digit strings.
Any subset D of [n-1]* is a tree [domain] iff
 1. e  D, which is the root (address) of the tree.
 2. for all string x and digit i < n, xi  D implies xj  D for all
j < i.
 3. for all string x, and for all prefix y of x, x D implies y 
D.
Notes:
1. Every member of D is called a position (or place).
2. Tree domains can be infinite sets.
Transparency No. 3.1-15
Propositional Logic: syntax
More terminology for tree domain
 Some definitions:




depth(D) = max{ |x| | x  D }; degree(x) = |{i | xi  D}|;
level(x) = |x|.
arity(D) = branching(D) = max{ degree(x) | x  D}.
Arity(D) < 3 => binary tree domain.
 leaf(x) iff
x  D but x0  D.
 root(x) iff
?
 internal(x) iff
?
Transparency No. 3.1-16
Propositional Logic: syntax
Two natural ordering on tree domains (nodes)
 prefix ordering: (partial order)
 x,y: two nodes (or equivalently, strings) of a tree.
x <p y iff x is a proper prefix of y.
iff x is a proper predecessor of y
iff y is a proper successor of x.
 lexicographical ordering: (total order)
 x,y: two nodes (or equivalently, strings) on a tree.
 x <L y iff either
1. x <p y or
2. x = z a u and y = z b v with a < b.
Note: <L corresponds to Preorder traversal of the tree. I.e.,
x <L y iff X will be traversed before y in preorder traversal of
the tree.
Transparency No. 3.1-17
Propositional Logic: syntax
Some more definitions about tree domains
 D: a tree domain.
 A path of D is a possibly infinite sequence of nodes x1,
x2,…xn, s.t. xi+1 is an immediate successor of xi for all i =
1,2,…
 A branch of D is a miximal path of D.
Exercise: Every branch of a tree must begins at the root
node.
Theorem 1.4: (Konig’s lemma): If a finitely branching tree T
is infinite, it has an infinite path.
pf: An infinite path x0,x1,x2,… is generated as follows:
1. let x0 = e. let n = 0.
2. since xn has infinitely many successors and has only finitely many
immediate successors, it must has one child which has infinitely many
successors. let xn+1 be any such child. 3. increase n by 1, goto 2.
Obviously the procedure never terminates and we can generate an infinite
path.
Transparency No. 3.1-18
Propositional Logic: syntax
The pseudo program for producing an infinite path
1. k = 0;
2. let xk =e;
3. while true { // precondition: xk has infinitely many
successors.
3.1 choose a child j of xk which has infinitely many successors.
3.2 let x k+1 = xk j ;
3.3 k = k+1; // postcondition: xk has infinitely many successors.
}
Note: This program will not terminate and would produce an
infinite path.
Transparency No. 3.1-19
Propositional Logic: syntax
subtrees and operations on trees
 D: a tree domain, x : a node (place, address) of D
 S: a subset of N*, is said to be a subtree [domain] of D at
place x iff S = {y | xy  D }.
 S is a subtree domain of D iff S ia a subtree domain of D at
some place of D.
 notation:
 D: a tree domain, x : a node of D =>
D|x is the subtree of D rooted at place x.
example: if D is binary then left subtree of D = D|0
right subtree of D = D|1 = {x | 1x  D}.
lsubtree(x) = D|x0, rsubtree(x) = D|x1.
Transparency No. 3.1-20
Propositional Logic: syntax
Operations on trees
1. substitution:
 D: a tree, S: a tree, x a non-root place ==>
D[x<-S] is the resulting tree obtained by substituting S for
the subtree of D rooted at x, i.e.,
D[x <- S] = D - {x’y | y  D|x} U {x’z | z S}, where x is the
immediate predecessor of x.
2. appending:
 D: a tree, S: a tree, x a leaf ==>
 D[x/S] is the tree obtained by appending S to x [ as the
unique immediate subtree of D, i.e.
D[x/S] = D U {xy | y in S}.
3. join: D[x:S] = D U {xy | y in S - {e} }
Transparency No. 3.1-21
Propositional Logic: syntax
unlabeled trees and labeled trees
 An unlabeled tree is (or can be represented as ) a tree
domain.
 A labeled tree is a tree in which every node is
associated with a label, which can be anything of
interest.
 S: a nonempty (label) set.
An n-ary S-tree is a function T : DT --> S , where
DT is a tree domain with arity < n+1.
Example:
 A formula tree is a Binary Wff-tree T:DT-> Wff where DT
is a binary tree domain.
Transparency No. 3.1-22
Propositional Logic: syntax
Formation trees for wffs
 Def 2.2: A formation tree is a finite binary wff-tree T:DT-> Wff, whose nodes
are labeled with wffs. the labeling satisfies the following conditions: for all
node d in DT,
 1. T(d) = p is an atom => d is a leaf.
 2. T(d) = (A @ B), => d has two immediate successors d0 and
d1 and T(d0) = A and T(d1) = B.
 3. T(d) = ~A => d has one immediate successor d0 and
T(d0) = A.
 A formation tree for a wff A is a formation tree TA with TA(e) = A.
Def2.5: 1. depth of a wff: depth(A) = depth of the formation tree for A.

2. support(A) = the set of atoms appearing in A.
Exercise: give an inductive definition for the depth and support of a
wff
Example: What is the formation tree for (~(A/\B)->C) ?
Theorem 2.4: Every wff has a unique formation tree for it.
pf: left as an exercise.
Def: For each wff A, let its formation tree be the unique tree TA:
DA-> sub(A) with TA(e) = A.
Transparency No. 3.1-23
Propositional Logic: syntax
Occurrence and subformulas
 Each subformula B of a wff A may occur many times:
 Ex: In A = ( p /\ q) \/ (~p -> (p /\ q)),
 the subformula (p /\ q) occurs twice, one at place 0 and
one at 11 at the formation tree TA for A.

(i.e., TA(1)=TA(11) = (p /\ q)
 p occurs ? times, and ~p occurs ? time.
 Definition: A: a wff, B: a wff formula.
A subformula occurrence of B in A is a subtree rooted at
place x in the formation tree TA for A s.t. TA(x) = B.
Namely we can identify a subformula occurrence as a
subtree of A.
 Sometimes we may need to distinguish between
subformulas and occurrences of subformulas.
Transparency No. 3.1-24
Related documents