sept 18, 2003© vadim bulitko : cmput 272, fall 2003, uofa1 cmput 272 formal systems logic in cs i....
Post on 21-Dec-2015
219 views
TRANSCRIPT
Sept 18, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 1
CMPUT 272CMPUT 272Formal Systems Logic in Formal Systems Logic in
CSCS
CMPUT 272CMPUT 272Formal Systems Logic in Formal Systems Logic in
CSCS
I. E. LeonardUniversity of Alberta
http://www.cs.ualberta.ca/~isaac/cmput272/f03
Sept 18, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 2
TodayTodayTodayToday
Chapter 2.1Formal FOPC introClean-up
Chapter 2.2
Chapter 2.3
All
imag
es
are
cop
yri
gh
ted
to t
heir
resp
ect
ive c
op
yri
gh
t h
old
ers
an
d r
ep
rod
uce
d h
ere
for
aca
dem
ic p
urp
ose
s u
nd
er
the c
on
dit
ion
of
“fair
usi
ng
”.
Sept 18, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 3
AnnouncementsAnnouncementsAnnouncementsAnnouncements
Assignment #1 is due Thursday, September 25
Sept 18, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 4
The PlanThe PlanThe PlanThe Plan
Last time considered an informal introduction to predicate logic
We will introduce predicate logic formally today and dwell on some subtle issues
Sept 18, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 5
Predicate Logic Predicate Logic (simplified)(simplified)
Predicate Logic Predicate Logic (simplified)(simplified)
Boolean variablesP, Q, R, … can be T/FE.g., P=“5 is a prime number”
Connectives:&, v, , , ~
Domain variablesA,B,C,… draw values from a domain setsE.g., j is a variable over integer numbers
Predicates:P(X1,…,XN),… map from domain inputs to T/FE.g., P(j) = “j is a prime number”
Quantifiers:For all , Exists E.g., [j prime(j)] = “any number is a prime number”
Statements/formulae:Atomic, unit, negated, conjunctive, …, universally/existentially quantifiedE.g., [j [even(j) & ~equal(j,2) ~prime(j) ]] = “no even numbers are prime except 2”
Sept 18, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 6
NoteNoteNoteNote
Notice that we did away with 0-arity predicates such as P(), etc.
Any Boolean variable is a 0-arity predicate so we will just drop the parentheses…
Sept 18, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 7
Questions?Questions?Questions?Questions?
Sept 18, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 8
Def : Well-formed Def : Well-formed FormulaeFormulae
Def : Well-formed Def : Well-formed FormulaeFormulae
A well-formed formula/sentence (wff) is a construction defined recursively:
Any Boolean variable is a wffAny predicate is a wffFor any wff X, ~(X) is a wffTwo wffs parenthesized and connected by v,&,, form a wff. For any wff X and a domain variable k:
k (X) is a wffk (X) is a wffHere X is within the scope of k (or k)
Sept 18, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 9
Find wffs…Find wffs…Find wffs…Find wffs…
x [man(X) mortal(x)]x [sandwich(x) better-than(x,Nothing)]x [duck(x) flies(x)]~[x [man(x) & lives-forever(x)]]x [man(x) ~lives-forever(x)]x [person(x) [Knave(x) v Knight(x)]]x [person(x) [Knave(x) v Knight(x)] & ~[Knave(x) & Knight(x)]]
Sept 18, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 10
Questions?Questions?Questions?Questions?
Sept 18, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 11
Def : InterpretationsDef : InterpretationsDef : InterpretationsDef : Interpretations
Interpretation for a wff :Assigns T/F values to all Boolean variablesDefines a single domain set for all domain variablesDefines all predicates
Example: consider wff = (j prime(j)) & P
A possible interpretation:Boolean variable P=TDomain variable j runs over integer numbersPredicate prime(x) holds iff x is a prime number
Sept 18, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 12
Interpretation ExampleInterpretation ExampleInterpretation ExampleInterpretation Example
Consider wff:x y Likes(x,y)
Does it hold?Depends on the interpretation!
Interpretation: Domain set for x,y is {Angela,Belinda,Jean}Define predicate Likes(liker,liked) as:
Likes(Angela,Belinda)Likes(Belinda,Angela)Likes(Jean,Belinda)Likes(Jean,Angela)
Does it hold in this interpretation?Yes
Sept 18, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 13
Questions?Questions?Questions?Questions?
Sept 18, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 14
Model / CountermodelModel / CountermodelModel / CountermodelModel / Countermodel
Formula holds given an interpretation I:
is satisfied by IThen is satisfiableThen I is a model for
Formula doesn’t hold given I: is not satisfied (or falsified) by IThen I is a countermodel for
Sept 18, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 15
Tautologies & Tautologies & ContradictionsContradictionsTautologies & Tautologies & ContradictionsContradictions
Formula holds under any interpretation I
is valid
is a tautology
Formula doesn’t hold under any I is a contradiction
is unsatisfiable
Sept 18, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 16
ExampleExampleExampleExample
Define Predicate P(X) as “person X is having a drink”
Considerxy [P(x) P(y)]“There exists a person such that when he is having a drink then everyone is having a drink”
True or false?TRUE – it is a tautology!
Sept 18, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 17
ContingenciesContingenciesContingenciesContingencies
holds under any interpretation tautology does NOT hold under any interpretation contradictionWhat if holds under some interpretations but not others?
Then is a contingency
Sept 18, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 18
Classify…Classify…Classify…Classify…
P & QP & ~PP v ~Px P(x)x ((P(x) Q(x)) & P(x)) Q(x)x (P(x) v ~P(x)) (P(x) & ~P(x))
Sept 18, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 19
Questions?Questions?Questions?Questions?
Sept 18, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 20
Bindings & ScopeBindings & ScopeBindings & ScopeBindings & Scope
A variable can be free:Sharp(X)
…or bound to a quantifierx P(x)
If variable X is bound to a quantifier then there is a binding between themThen X is said to be in the quantifier’s scopeHow about:
x y P(x) & Q(x,y) v R(y)x y (equal(x,y) v P(z) & (y B(X,Y)))
CMPUT 272 is case-sensitive! X is not the same as x
Sept 18, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 21
Free variables Free variables Free variables Free variables
Given an interpretation we can evaluate a formula, e.g.:
x y Likes(x,y)
Consider the following formula:y Likes(x,y)
Suppose you are given the interpretation I:Domain set for x,y is {Angela,Belinda,Jean}Define predicate Likes(liker,liked) as:
Likes(Angela,Belinda)Likes(Jean,Belinda)Likes(Jean,Angela)
Is y Likes(x,y) satisfied by I ?Cannot tell – x is a free variable…
Sept 18, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 22
SubstitutionsSubstitutionsSubstitutionsSubstitutions
A wff that can be evaluated to T/F given an interpretation is called a statementFormulae with free variables may not be statements
That is so because an interpretation doesn’t touch free domain variables
A substitution “complements” an interpretation by assigning (substituting) all free domain variables
Sept 18, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 23
Example Example Example Example
Revisit the formula:y Likes(x,y)
Suppose you are given the interpretation I:Domain set for x,y is {Angela,Belinda,Jean}Define predicate Likes(liker,liked) as:
Likes(Angela,Belinda)Likes(Jean,Belinda)Likes(Jean,Angela)
Additionally you have a substitution S:Free domain variable x is set to Angela
Is y Likes(x,y) satisfied by I and S?Yes…
Sept 18, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 24
Updated DefinitionUpdated DefinitionUpdated DefinitionUpdated Definition
Formula holds given an interpretation I and a substitution S:
is satisfied by I and SThen is satisfiableThen I and S form a model for
Formula doesn’t hold given I and S : is not satisfied (or falsified) by I and SThen I and S form a countermodel for
Sept 18, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 25
Updated DefinitionUpdated DefinitionUpdated DefinitionUpdated Definition
Formula holds under every interpretation I and substitution S
is valid
is a tautology
Formula doesn’t hold under any I and substitution S
is a contradiction
is unsatisfiable
Sept 18, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 26
Updated DefinitionUpdated DefinitionUpdated DefinitionUpdated Definition
holds under some interpretations and substitutions but not others?
Then is a contingency
Sept 18, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 27
Note 1Note 1Note 1Note 1
Many formulae with free variables cannot be tautologies or contradictions
Their value depends on the substitution
However, some can:Likes(x,y) v ~Likes(x,y)… is a tautology despite two free variables
Sept 18, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 28
Questions?Questions?Questions?Questions?
Sept 18, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 29
Implicit QuantifiersImplicit QuantifiersImplicit QuantifiersImplicit Quantifiers
If x > 2 then x2 > 4
Textbook: real numbers x, if x>2 then x2 > 4
More formally:x [x>2 y square(x,y) & y>4]where predicates square(a,b) and c>d are defined over the set of real numbers
Implicit Implicit quantifierquantifier
ss
Implicit Implicit quantifierquantifier
ss
Implicit Implicit quantifierquantifier
ss
Implicit Implicit quantifierquantifier
ss
Sept 18, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 30
Domain FunctionsDomain FunctionsDomain FunctionsDomain Functions
Consider the last statement again: real numbers x, if x>2 then x2 > 4Is it a wff? No! Why?
Well x2 is not a predicate and is not a variableIt is a domain function (square)!
We have not formally introduced domain functions
But we will use them anyway for the sake of:
SimplicityConsistency with the text book
Sept 18, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 31
Conversion to Conversion to PredicatesPredicates
Conversion to Conversion to PredicatesPredicates
The use of domain functions is justified:Because they can be expressed through domain predicates
Example:let function f map numbers to numbers:
f(n)=m
Then whenever we see f(x) in our wffWe will change it (with some care) to:
y Pf(x,y)
Where Pf(n,m) holds iff f(n)=m
Sept 18, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 32
Questions?Questions?Questions?Questions?
Sept 18, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 33
Evaluating FormulaeEvaluating FormulaeEvaluating FormulaeEvaluating Formulae
Boolean variablesInterpretation directly
Predicate with variables : Likes(x)Use the assignment of x and the semantics of Likes()
Universally quantified formula : x P(x)Evaluates to true iff P(x) holds on all possible values of x
Existentially quantified formulae : x P(x)Evaluates to true iff P(x) holds on at least one possible value of x
Sept 18, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 34
ExamplesExamplesExamplesExamples
Consider formula S:x (x2 > x)
Assume the standard algebraic interpretationSuppose the domain set for variable x is {2,3,4}Does S hold or not?
Yes : 4>2, 9>3, 16>4
Suppose the domain set for variable x is the set of real numbersDoes S hold or not?
No : ~(0 > 0)
Sept 18, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 35
ExamplesExamplesExamplesExamplesConsider formula S:
x (x2 > x)
Assume the standard algebraic interpretation
Suppose the domain set for variable x is {2,3,4}Does S hold or not?
Yes : 4>2
Suppose the domain set for variable x is the segment [0,1]Does S hold or not?
No : all numbers between 0 and 1 have their squares not greater than the number itself
Sept 18, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 36
SummarySummarySummarySummaryGIVEN a particular interpretation
To show that a -quantified formula holds:Exhaust all possibilities – show that all examples satisfy the formula
To show that a -quantified formula does NOT hold:
Find a falsifying example
To show that a -quantified formula holds:Find a satisfying example
To show that a -quantified formula does NOT hold:
Exhaust all possibilities and show that all examples falsify the formula
Sept 18, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 37
SummarySummarySummarySummary
How about classifying a formula:Tautology / Contradiction / Contingency
Contingencies are, perhaps, the easiest:
Need to find a model and a counter-model
Tautologies / contradictions:Need to show that all possible interpretations satisfy/falsify the formulaMore difficult
Sept 18, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 38
Questions?Questions?Questions?Questions?
Sept 18, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 39
Restricted Restricted --QuantifiersQuantifiers
Restricted Restricted --QuantifiersQuantifiers
Informal: Any number greater than 2 is positive
Formal: x [x>2 x>0]
Formal shorthand (“syntactic sugar”): x>2 [x>0]
Common mistake:Use of & instead of x [x>2 & x>0]“Any number is greater than 2 and greater 0”How about 1?
Sept 18, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 40
Restricted Restricted -Quantifiers-QuantifiersRestricted Restricted -Quantifiers-Quantifiers
Informal: There is a positive solution to x2=1
Formal: x [x>0 & x2=1]
Formal shorthand (“syntactic sugar”): x>0 [x2=1]
Common mistake:Use of instead of &x [x>0 x2=1]“There exists a number such that if it is positive then it is a solution to x2=1”This formula is satisfied by any interpretation that contains 0 among the numbers
Sept 18, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 41
Restricted Restricted -Quantifiers-QuantifiersRestricted Restricted -Quantifiers-Quantifiers
Another example of…Common mistake: use of instead of &
“There exists an immortal man”
Correct:x [man(x) & ~mortal(x)]
Incorrect:x [man(x) ~mortal(x)]“There exists something such that if it is a man then it is immortal”
The latter formula is satisfied by any interpretation that allows x to run over non-man objects
E.g., x can be a duck satisfying the formula
Sept 18, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 42
LimitationsLimitationsLimitationsLimitations
It is Ok to use the shorthand with:Algebraic predicates: e.g., x>0Set membership: e.g., xD
Why?Because it is clear that your quantifiers is applied to the variable which follows it immediately:
x>0 [x2=1]
It is not Ok to use such shorthands with other predicates:
E.g., P(x) [x2=1]
Sept 18, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 43
Questions?Questions?Questions?Questions?
Sept 18, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 44
Special cases : finite Special cases : finite domainsdomains
Special cases : finite Special cases : finite domainsdomains
Suppose you have a formula over a single variable x
If the domain of variable x is finite:{x1,…,xN}
Then x P(x) is equivalent to:P(x1) & … & P(xN)
And x P(x) is equivalent to:P(x1) v … v P(xN)
Sept 18, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 45
Questions?Questions?Questions?Questions?
Sept 18, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 46
Satisfying Satisfying // statementsstatements
Satisfying Satisfying // statementsstatements
To show that x P(x) we need to:Prove that every x satisfies P(x)
To show that x P(x) we need to:Prove that there exists at least one x that satisfies P(x)
Sept 18, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 47
De Morgan again…De Morgan again…De Morgan again…De Morgan again…
To show that ~(x P(x)) we need to:Prove that not every x satisfies P(x)In other words, we need to find at least one x that does not satisfy P(X)But that is the same as proving that x ~P(x)
Therefore:~(x P(x)) x (~P(x))
are logically equivalentDe Morgan’s law for quantifiers
Sept 18, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 48
And again…And again…And again…And again…
To show that ~(x P(x)) we need to:Prove that there does not exists a single x satisfies P(x)In other words, we need to show that all x do not satisfy P(X)But that is the same as proving that x ~P(x)
Therefore:~(x P(x)) x (~P(x))
are logically equivalentDe Morgan’s law for quantifiers
Sept 18, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 49
ExamplesExamplesExamplesExamples
Statement:“Everyone snoozes in CMPUT 272”
Negation:“Not every one snoozes in CMPUT272”“There is someone who doesn’t snooze in CMPUT 272”
A common mistake:“Everyone does NOT snooze in CMPUT 272”
Sept 18, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 50
ExamplesExamplesExamplesExamples
Statement:“Professors don’t make much money”
Negation:“There is a professor who makes much money”
A common mistake:“Professors make much money”
Sept 18, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 51
ExamplesExamplesExamplesExamples
Statement:There is a secret agent who appeals to all women
Negation:For every secret agent there is a woman that the agent doesn’t appeal to
A common mistake:There is a secret agent who doesn’t appeal to all women
Sept 18, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 52
In a nutshell…In a nutshell…In a nutshell…In a nutshell…
When negating a quantified formula:Quantifier1 x1… QuantifierN xN P(x1,..,xN)
Do this:Change all to Change all to Negate the innermost formula P(…)
Be careful with scoping and connectives!
Sept 18, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 53
Questions?Questions?Questions?Questions?
Sept 18, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 54
Vacuous Truth of UQSVacuous Truth of UQSVacuous Truth of UQSVacuous Truth of UQS
Suppose I say:“Presently, all men on the moon are happy”
Is it true or false?Think of it this way:
x [OnTheMoon(x) Happy(x)]
So, is it true or false?The internal implication is always vacuously true for there is presently no man on the MoonThus, the entire statement holds for any x
The entire statement holds
Sept 18, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 55
Questions?Questions?Questions?Questions?
Sept 18, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 56
Logical ImplicationLogical ImplicationLogical ImplicationLogical Implication
In propositional logic formula A logically implies formula B iff:
Every interpretation that satisfies A also satisfies B
In predicate logic?The same!
Sept 18, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 57
Validity of ArgumentsValidity of ArgumentsValidity of ArgumentsValidity of Arguments
Hence validity of arguments is defined in the same way
The difference is: in predicate logic it is not always possible to go through all interpretations to prove that A logically implies B
Why?The number of interpretations can be infinite
Sept 18, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 58
Inference RulesInference RulesInference RulesInference Rules
Thus, proving arguments with inference rules becomes the method of choice
We can also derive new inference rules for our toolbox
Sept 18, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 59
Universal InstantiationUniversal InstantiationUniversal InstantiationUniversal Instantiation
Consider a universally quantified statement:
xD [P(x)]
Suppose you have a particular x0D
What can you say about P(x0)?It holds!
Why? Because predicate P(…) holds for all members of set DExample: “mortal Socrates” argument
Sept 18, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 60
Universal Modus Universal Modus PonensPonens
Universal Modus Universal Modus PonensPonens
Propositional modus ponens PQPThus, Q
Universal modus ponensx [P(x)Q(x)]P(a)Thus, Q(a)
Sept 18, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 61
Diagrams for Validity (p. Diagrams for Validity (p. 104)104)
Diagrams for Validity (p. Diagrams for Validity (p. 104)104)
Diagrams can sometimes be used to:support a validity of an argumentor, show that an argument is invalid
Diagrams are not a formal proof!Use them to illustrate your reasoning ONLYExamples:
Valid : Modus PonensInvalid : abduction
mortalmortal
human
SocrateSocratess
SocrateSocratess
pneumoniapneumonia
fever
patientpatientpatientpatient
Sept 18, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 62
Questions?Questions?Questions?Questions?