Sunteți pe pagina 1din 9

A Formal Language

„ Predicate Logic provides a way to


Predicate Logic formalize natural language so that
ambiguity is removed.
„ Mathematical arguments (proofs) are
usually written in pseudo logic.
„ Many programming languages involve
elements of predicate logic. e.g. if..then

Predicate vs Propositional
Logic Propositional Logic Revised
„ Predicate logic uses the same connectives „ Propositional Logic is a formal approach to
as propositional logic but allows you to reasoning with or about declarative
refer to different elements of the sentences.
universe.
„ It also introduces quantifiers…so you can If David likes Mary then Mary likes David
say things like.. David likes Mary
„ It always rains in England. Mary likes David
„ Sometimes it is sunny in Bristol.

1
Semantics vs Proof Theory Truth-Tables
The truth value of compound sentences can then be
„ There are two approaches to reasoning in „

determined by application of truth tables defined for


propositional logic. each connective
A ¬A A B A∧B A B A→B
Semantics = truth tables and valuations t f t t t t t t
f t f t f f t t etc
t f f t f f
Proof theory = formal notion of proof from
f f f f f t
axioms and inference rule
A sentence B truth-functionally follows from sentence A if
for every row of the truth-table in which A is true B is also
true. Denoted A|=B

Formal Proof Relating Semantics and Proof


T=set of assumptions (sentences) then T|-A if we can Soundness
generate a sequence of sentences
Axioms for propositional logic Proof theory ⊆ Semantics
S1,S2,…,Si-1,Si,…,Sn=A 1. A→(B →A)
Completeness
2. (A →(B →C)) →((A →B)
Where either →(A →C))
Semantics ⊆ Proof theory
Si=axiom 3. (¬B → ¬A) →((¬B →A)
= a sentence in T (an assumption) →B)
Propositional logic is sound and complete
or Inference Rule: Modus
S1,…,Si-1→ (inference rule) Si Ponens Semantics = Proof theory
From A,A→B infer B

2
Predicate Logic: Introducing
Decidability Quantifiers
„ A formal logic is decidable if there is a mechanical „ Predicate logic allows for quantified statements by
(algorithmic) way of determining whether A follows introducing the quantifiers ∀ “for all” and ∃ “there
from T. exists”.
T|=A ? „ Why do we need quantifiers ? Consider
Propositional logic is
decidable: at worst we All birds have wings
need only consider Tweety is a bird
every row of the truth- Therefore, Tweety has wings
yes
table for which T is Propositional logic: All birds have wings= (Robins have
true, and there are only wings)∧(Crows have wings)∧(Eagles have wings)
finitely many. ∧..........etc.
No This is impractical.

Quantifiers 2: Functions
„ In predicate logic this translates to „ It is also desirable to be able to represent functional
relationships in predicate logic. Consider
∀x(B(x ) → W (x ))
• Unlike propositional logic,
predicate logic has variables- in
this case x.
Blue eyed people have blue eyed fathers
B(Tweety ) • It also has constants – in this Some people have blue eyes
case Tweety Therefore, some people’s fathers have blue eyes
∴W (Tweety ) • Tweety is an instantiation of
the predicates B and W. Translates to x is a variable ranging across all people

B(x)= x is a Bird, W(x)=x has wings,


( (
∀x BE(x ) → BE F (x ))) BE(x) -means “person x has blue eyes”
∀x (B(x)→W(x)) = For all x, if x is a bird then x has wings ∃xBE(x )
F is a function mapping from one
B(Tweety)=Tweety is a bird.
W(Tweety)=Tweety has wings
(
∴∃xBE F (x ) ) person x to another person F(x), where
F(x) is the father of x

3
Syntax: Building Blocks for
Predicate Logic Syntax (2)
„ (2) Functions: FNL is a set of n-ary
„ Formula in predicate are built up from the functions.
following elements
„ F(x)=Father of x, D(x,y,z)=Day of the
„ (1) Predicates: PL is a set of n-ary weeks falling on the date x/y/z.
predicates. e.g. „ (3) Constants: CL is a set of constants
„ B(x)=x is a bird –unary e.g. Tweety, numbers, Aunty Ethel
„ M(x,y)=x is married to y –binary „ (4) Variables: a set of variables, x,y,z etc
„ BT(x,y,z)=y is between x and z –tertiary „ (5) Connectives, Quantifiers and
Brackets: ∀,∃,¬,∧,∨, (,),[,]

Terms Formula in Predicate Logic


„ Terms are possible instantiations of predicates.
„ Atomic Formula: The atomic formula ATL, have the
„ The set of terms TL is defined recursively in the form P(t1,...., tn) where P is an n-ary relation in PL
following way: and ti are terms for i=1,...,n
(i) All variables and constants are terms „ E.g. PNL={Rich,Happy},
(ii) If f is an n - ary function symbols and t1....tn are FNL={father,mother},CL={jim, fred, mary},
terms then f(t1....tn) is a term. VL={x,y}
FNL={father, mother, first-child}, CL={bill}, VL={x} - „ Atomic formula include…Rich(x), Happy(y), Rich(bill),
ranging across parents Happy(father(y)), Rich(mother(mary)),
Happy(father(mother(x))) etc
x, bill, father(x), mother(x), first-child(x), father(bill), mother(bill),
first-child(bill), father(father(x)), father(mother(x)), first-child(father(x))
father(father(bill)), father(mother(bill)),.......etc

4
Translating from Logic to
Formula 2 English
„ Well-Formed Formula: The set of well-formed „ Example: PL ={married, younger-than, equal} all binary
VL={x,y,z} ranging over all parents
formula WFL is defined recursively as follows: CL={bill, john, george, mary}
FNL={father, mother, first-child} -all unary
(i) all atomic formula are well-formed formula Connectives ∧,∨,¬,→,↔
(ii) If F and G are well-formed formula so are (¬F), Quantifiers ∀,∃, Brackets
(F∧G), (F∨G), (F→G), (F↔G)
married(mary,john) translates to ”Mary is married to John”
(iii) If F is a well-formed formula and x∈VL then equal(father(bill),george) translates to ”George is the father of Bill”
(∀xF) and (∃xF) are well-formed formula. equal(mother(mother(bill)),mary) translates to ”Mary is the maternal
grandmother of Bill”
E.g. Rich(x)∧Happy(x), Rich(x)→Happy(y), (equal(mother(x),y)∨equal(father(x),y)) translates to ”y is a parent of x”
∀x∀y(married(x,y)→ married(y,x)) translates to ”for any parents x and y
Rich(bill)∨Happy(father(fred)),
if x is married to y then y is married to x”
(∀x¬ Happy(x))∧ ∃yRich(y)), ∀x(Rich(x) →Happy(x)) ∀x∃y(equal(mother(x),y) translates to ”everyone has a mother”

Translating from English to


Logic Removing Ambiguity
„ “Anyone who is persistent can learn logic” translates „ Bertrand Russell gave the following example of how
to ∀x(persistent(x)→learn(x, logic)) translating to logic can remove ambiguity.
„ “All blocks which are on top of or attached to blocks
which have been moved, have also been moved” „ Consider the sentence “The current king of France is
translates to ∀x∀y((block(x)∧block(y)∧(ontop(x,y)∨ bald”. Is this sentence true?
attached(x,y))∧moved(y))→moved(x)) „ Translating to logic gives:
„ “You can fool some of the people all of the time, and
you can fool all the people some of the time, but you „ ∃x(KF(x)∧B(x))
can’t fool all the people all the time” translates to „ KF(x)= x is the current king of France.
∃x∀y(person(x)∧time(y)∧fool-at(y,x)) ∧
∃y∀x(person(x)∧time(y)∧fool-at(y,x)) ∧ „ B(x)= x is bald.
¬(∀x ∀y (person(x)∧time(y)∧fool-at(y,x))) „ This is clearly false! Why?

5
Whoops-Missed a bit Declarative Formula
„ Some formula have a truth-value while others don’t.
Its only me!
So the correct translation is „ ∀x∃y(equal(mother(x),y) has a truth-value
∃xKF(x)∧ „ So does ∀x(Rich(x)→Happy(x))
∀x(KF(x)→∀y(KF(y)→equals(x,y)))∧
∀x(KF(x)→B(x)) „ But neither Rich(x) nor married(x,y)→ married(y,x)
have truth values.
Still false though! „ In predicate logic declarative formula are closed.
Non-declarative form are open.

What about “the current king of France is not bald” – is it


true or false?

Open and Closed Formula Open and Closed:2


„ Scope of a Quantifier: The scope of ∀x (resp. ∃x) in ∀x „ Example: In the formula (∃xP(x,y))∧Q(x) the
F (resp ∃x F) is F occurrence of x in P(x,y) is bound but the occurrence
„ E.g. In ∀x(Rich(x)→Happy(x)) the scope of ∀x is of x in Q(x) is free.
(Rich(x)→Happy(x)) „ All occurrences of x in ∃x(P(x,y)∧Q(x)) are bound.
„ In ∀x∃y(equal(mother(x),y) the scope of ∀x is „ Open and Closed Formula: A closed formula is a
∃y(equal(mother(x),y) and the scope of ∃y is well-formed formula with no free occurrences of any
(equal(mother(x),y) variable. An open formula is a formula that is not
„ Free and Bound Occurrence of a Variable: A bound closed
occurrence of a variable in a formula is an occurrence „ Example: ∀x∃y(equal(mother(x),y) is closed since
immediately following a quantifier or an occurrence within all occurrences of x fall within the cope of ∀x and all
the scope of a quantifier, which has the same variable occurrences of y fall within the sope of ∃y.
immediately after the quantifier.
„ Any other variable is free.

6
Interpretations Interpretations:2
„ Really a language of predicate logic is only a set of U1 U2
symbols which can be interpreted in different ways. Formal Logic
„ Consider the formula: ∃y∀xP(x,y) I
PL={P,Q,R,..}
J PLJ={PJ,QJ,RJ,..}
PLI={PI,QI,RI,..} FLJ={fJ,gJ,hJ,..}
„ Quantification over natural numbers, P(x,y) means FLI={fI,gI,hI,..} FL={f,g,h,..}
CLJ={aJ,bJ,cJ,..}
CL={a,b,c,..}
x≥y then interpretation is `for all natural numbers x CLI={aI,bI,cI,..}
there is some natural y for which x≥y’
„ Quantification over people, P(x,y) means `y is the
father of x’ then interpretation is `there is some who
is the father of everyone’

Theories and Models Satisfiability


„ Theory: A theory of a language of „ A theory of L, is satisfiable if it has at
predicate logic L is any finite set of least one model.
closed well-formed formula of L. „ Any theory that is not satisfiable is said
„ Model: A model of a theory T is an to be inconsistent.
interpretation of L under which all the „ Any theory for which every possible
formula in T are true. interpretation is a model is said to be
valid.

7
Satisfiability: 2 Example
Consider the following theories:
„ The theory consisting of the single „

formula ∃x(P(x)∧¬ P(x)) is inconsistent. T1 = {∀x∃yP( x, y ) → P(c, f (c ))}


„ The theory {∀x (P(x)→ P(x))} is valid. T2 = {∀xP( x, f ( x )) → ∃yP(c, y )}

„ Also consider the following two interpretations


Interpretation I: Let U1 be the set of all integers, cI=0,
fI is the successor function, PI is >

Interpretation J: Let U2 be the set of all integers,


cJ=0, fJ is the predecessor function, PI is ≠

Example: 2 Example: 3
Under I Under J
T1 means T1 means
If for every integer x there is some integer y such that x>y If for every integer x there is some integer y such that x≠y
then 0>0+1 then 0 ≠ 0-1
Clearly this is false since the antecedent is true and the Clearly this is true since both the antecedent and
consequence is false - I is not a model of T1 consequence are true - J is a model of T1
T2 means T2 means
If for every integer x x>x+1 then there exists an integer y If for every integer x, x ≠x-1 then there exists an integer y
such that 0>y such that 0≠y
This is true since the antecedent is false - I is a model of T2 This is true since, again, both antecedent and consequence
are true - J is a model of T2

8
Example: 4 Example: 5
„ We see that T1 is not a valid theory since I „ Two possibilities
is not a model of T1. „ Antecedent false -in this case the
„ Both I and J are models of T2. Is T2 valid? conditional is automatically true.
„ Let K be any interpretation of L then T2 „ Antecedent true -in this case since cK∈U
means we have PK (cK, fK(cK)) and hence the
„ If for every element x∈U PK (x, fK(x)) then consequence of the conditional must
there exists some element y∈U such that also be true since we can select y to be
PK(cK, y ). fK(cK).

Semantic Entailment Decidability


„ A theory T is said to entail a closed formula F is F is true T =F T ≠F
in every model of T.
T =F T =¬F
Proof Proof
models of F models of ¬F models of F models of ¬F Procedure Procedure Predicate logic is only
Query: does F Query: does F semi-decidable
models of T models of T
follow from T follow from T

models of F models of ¬F T ≠F
Algorithm terminate Algorithm may or
models of T T ≠¬F
and answers “yes” may not terminate
and answers “no”

S-ar putea să vă placă și