sept 11, 2003© vadim bulitko : cmput 272, fall 2003, uofa1 cmput 272 formal systems & logic in...
Post on 20-Dec-2015
218 views
TRANSCRIPT
Sept 11, 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/s03
Sept 11, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 2
TodayTodayTodayToday
Refresher: Chapter 1.2
Chapter 1.3 : Arguments
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 11, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 3
InterpretationInterpretationInterpretationInterpretation
In propositional logic an interpretation is a mapping from variables in your formulae to {true, false}
Example:Formula: A v BInterpretation 1: A = true, B = falseInterpretation 2: A = false, B = false
Sept 11, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 4
InterpretationsInterpretationsInterpretationsInterpretations
How many interpretations do the following formulae allow?A B
4
(AB & A) B4
Why not 8 or 16?
The number of interpretations is 2N where N is the number of independent variables
Sept 11, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 5
Questions?Questions?Questions?Questions?
Sept 11, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 6
ConditionsConditionsConditionsConditionsSuppose we have a statement X
X = “this assignment is copied”
We want to evaluate X (true/false?)
Suppose we know a statement A such that AX
A is a sufficient conditionA=“the cheater is caught in the act”
Suppose we know B such that XBB is a necessary conditionB=“there was an original assignment to copy from”
Sept 11, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 7
CriteriaCriteriaCriteriaCriteria
Suppose we know C such that CXC is a criterionC=“someone has copied this assignment”
Graphically:
XXXX
AAAA
BBBB
CCCC
Sept 11, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 8
Wanted : CriteriaWanted : CriteriaWanted : CriteriaWanted : Criteria
Medical testsSoftware/hardware correctnessFraud/cheatingFinancial marketPsychology (e.g., in sales)Science : mathematics, physics, chemistry, etc.Logic :
If C is a criterion for X then C X !
Sept 11, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 9
PracticePracticePracticePractice
It is frequently non-trivial to derive a criterion for a real-life property X
Then we have to settle for:Sufficient conditions:
“If this quality test passes then the product is fine”
Necessary conditions:“If the patient breaks a leg they will be in pain”
Statistical validity : the condition works most of the timeIn logic : the condition works all the time!
Sept 11, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 10
Derivation of CriteriaDerivation of CriteriaDerivation of CriteriaDerivation of Criteria
Logic/Mathematics/Theoretical sciences:Equivalent transformationsProofs by contradiction
Empirical sciences:Statistical testsFunction approximation
Artificial Intelligence:Machine learning
These methods are
not guaranteed to produce
true criteria…
Sept 11, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 11
Questions?Questions?Questions?Questions?
Sept 11, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 12
Logic EquivalenceLogic EquivalenceLogic EquivalenceLogic Equivalence
Propositions/statements/formulae A and B are logically equivalent when:
A holds if and only if B holds
Notation: A BExamples:
A v A is equivalent to:A
A v ~A is equivalent to:true
Sept 11, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 13
ChallengeChallengeChallengeChallenge
Theorem 1.1.1 : Boolean AlgebraDerive the rest (e.g., #8) from the first 5 equivalences…
Sept 11, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 14
Use of EquivalencesUse of EquivalencesUse of EquivalencesUse of Equivalences
Deriving equivalent formulae!Of course, but why do we care?
Simplification of formula
Simplification of code
Simplification of hardware (e.g., circuits)
Derivation of criteria!
Sept 11, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 15
LimitationsLimitationsLimitationsLimitations
Not all statements are equivalent!Of course not, but what else is there?
Some formulae are stronger than others
They imply or entail other formula but not the other way around…
Equivalences cannot directly help us proving such entailments…
Sept 11, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 16
EntailmentEntailmentEntailmentEntailment
A collection of statements P1,…,Pn (premises) entails statement Q (conclusion) if and only if:
Whenever all premises hold the conclusion also holds
For every interpretation I that makes all Pj hold, I also makes Q hold
Example:Premises:
P1 = “If Socrates is human then Socrates is mortal”
P2 = “Socrates is human”
Conclusion:Q = “Socrates is mortal”
Sept 11, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 17
Valid/Invalid Valid/Invalid ArgumentsArguments
Valid/Invalid Valid/Invalid ArgumentsArguments
Suppose someone makes an argument:
P1,..,PN therefore Q
The argument is called valid iff:P1,…,PN logically entail Q
That is:if all Pi hold, then Q must hold
Otherwise the argument is called invalid
Sept 11, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 18
ExampleExampleExampleExample
Sample argument:P1 = “If Socrates is human then Socrates is mortal”P2 = “Socrates is human”
Therefore:Q = “Socrates is mortal”
Valid / invalid?
Sept 11, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 19
So you think it was simple, So you think it was simple, eh?eh?
So you think it was simple, So you think it was simple, eh?eh?
Then is the following argument valid?P1
P2
entailsQ
Yes?Very well, but what if my interpretation I sets P1 and P2 to true but Q to false?
Then by definition Q is not entailed by P1 and P2
So do P1,P2 entail Q or do they not?
Sept 11, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 20
What Happened…What Happened…What Happened…What Happened…
We considered P1, P2, and Q under a particular (common sense) interpretation:
P1 = “If Socrates is human then Socrates is mortal” trueP2 = “Socrates is human” trueQ = “Socrates is mortal” true
Thus, they were merely logical constants to us:P1=true
P2=trueQ=true
Sept 11, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 21
Generality…Generality…Generality…Generality…
Thus our argument was:TrueTrueentailsTrue
Well, this is not very useful because it doesn’t tell us anything about validity of other arguments. For example:
P1=“If J.B. broke his leg then J.B. is in pain”
P2=“J.B. broke his leg”
entailsQ=“J.B. is in pain”
Is this Is this argument argument
valid?valid?
Is this Is this argument argument
valid?valid?
Sept 11, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 22
Extracting the EssenceExtracting the EssenceExtracting the EssenceExtracting the Essence
How do we know it is valid?Because regardless of who J.B. is and what happened to him/her, we somehow know that:
If P1 and P2 hold
Then Q will hold
But how do we know that?How can we extract the essence of the “dead Socrates” and “J.B. in pain” arguments?
Sept 11, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 23
General Structure!General Structure!General Structure!General Structure!Recall both arguments:
P1 “If Socrates is human then Socrates is mortal” “If J.B. broke his leg then J.B. is in pain”P2 “Socrates is human” “J.B. broke his leg”entailsQ “Socrates is mortal” “J.B. is in pain”
Note that P1, P2, and Q are related!Both arguments share the same structure:
P1 If X then Y
P2 XentailsQ Y
Then for any interpretation I as long as I satisfies P1 and P2, interpretation I must satisfy Q
Sept 11, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 24
Modus PonensModus PonensModus PonensModus Ponens
The “generalized” argumentP1 = X Y
P2 = XentailsQ = Y
…is much more useful!Why?
Because it captures the essence of both arguments and can be used for infinitely many more
““method of method of affirming” affirming”
(Lat.)(Lat.)
““method of method of affirming” affirming”
(Lat.)(Lat.)
Sept 11, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 25
Valid Arguments Valid Arguments (Revisited)(Revisited)
Valid Arguments Valid Arguments (Revisited)(Revisited)
Suppose someone makes an argument:P1,..,PN therefore Q
The argument is called valid iff:P1,…,PN logically entail Q
That is:For any interpretation I that satisfies all Pj, interpretation I must necessarily satisfy Q
Usually: Pj and Q are somehow related formulae and P1 & … & PN can be true or false depending on the interpretation I
Sept 11, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 26
Logical FormLogical FormLogical FormLogical Form
Since:we consider all possible interpretationsthe conjunction of premises:
P1 & … & PN
is sometimes true and sometimes false
The conclusion Q must follow from / be entailed by the premises… …by logical form of Pj and Q alone (p. 29 in the text)
Sept 11, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 27
Questions?Questions?Questions?Questions?
Sept 11, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 28
How Do We:How Do We:How Do We:How Do We:Tell between a valid argument and an invalid argument:
People are mortal. Socrates is a man. Socrates is mortal.Ducks fly. F-16 flies. F-16 is a duck.
Prove that something logically follows from something else:
1: Everybody likes Santa Claus2: Everybody likes someone
Prove that something is logically equivalent to something else:
1: Everybody likes cream and sugar2: Everybody likes cream and everybody likes sugar
Prove that there is a contradiction?
Sept 11, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 29
Propositional LogicPropositional LogicPropositional LogicPropositional Logic
Method #1:Go through all possible interpretations and check the definition of valid argument
Method #2:Use derivation rules to get from the premises to the conclusion in a logically sound way
“derive the conclusions from premises”
Sept 11, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 30
Method #1Method #1Method #1Method #1
Section 1.3 in the text proves many arguments/inference rules using truth tables
Suppose the argument is:P1,…,PN therefore Q
Create a truth table for formulaF=(P1 & … & PN Q)
Check if F is a tautology
Sept 11, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 31
But Why? Recall:But Why? Recall:But Why? Recall:But Why? Recall:
Formula A entails formula B iff (A B) is a tautology
In general:premises P1,…,PN entail Q
iffformula F=(P1 & … & PN Q)
is a tautology
Sept 11, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 32
Example #1Example #1Example #1Example #1
P v Q v R~R entails P v Q
valid/invalid?
(example 1.3.1 in the book, p. 30)
Sept 11, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 33
Example #2Example #2Example #2Example #2
P v Q v R~R entails Q
valid/invalid?
Sept 11, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 34
Example #3Example #3Example #3Example #3
P QP entails Q
valid/invalid?Modus ponens
Sept 11, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 35
Example #4Example #4Example #4Example #4
P QQ entails P
valid/invalid?
Sept 11, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 36
Example #5Example #5Example #5Example #5
P Q~Q entails ~P
valid/invalid?Modus tollens
Sept 11, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 37
Example #6Example #6Example #6Example #6
P Qentails ~Q ~P
valid/invalid?
In fact, we proved last time that: (P Q) (~Q ~P)
Sept 11, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 38
Example #7Example #7Example #7Example #7
P v Q~P & ~Qentails P & Q
valid/invalid?
Any argument with a contradiction in its premises is valid by default…
Sept 11, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 39
Pros & ConsPros & ConsPros & ConsPros & Cons
Method #1:Pro: straight-forward, not much creativity machines can do
Con: the number of interpretations grows exponentially with the number of variables cannot do for many variables
Con: in predicate and some other logics even a small formula may have an infinite number of interpretations
Sept 11, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 40
Questions?Questions?Questions?Questions?
Sept 11, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 41
Method #2 : Method #2 : DerivationsDerivationsMethod #2 : Method #2 : DerivationsDerivations
To prove that an argument is valid:
Begin with the premises
Use valid/sound inference rules
Arrive at the conclusion
Sept 11, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 42
Inference RulesInference RulesInference RulesInference Rules
But what are these “inference rules”?They are simply…
… basic valid arguments!
Example:X & Y X & Y Z & WthereforeZ & W by modus ponens
Sept 11, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 43
Example #1Example #1Example #1Example #1
(X&Y Z&W) & KX&YthereforeZ&WHow?(X&Y Z&W) & KX&Y Z&W by conjunctive simplificationX&YZ&W by modus ponens
Sept 11, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 44
DerivationsDerivationsDerivationsDerivations
The chain of inference rules that starts with the premises and ends with the conclusion…is called a derivation:
The conclusion is derived from the premises
Such a derivation makes a proof of argument’s validity
Sept 11, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 45
Example #1Example #1Example #1Example #1
(X&Y Z&W) & KX&YthereforeZ&WHow?(X&Y Z&W) & KX&Y Z&W by conjunctive simplificationX&YZ&W by modus ponens
derivationderivation
Sept 11, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 46
Pros & ConsPros & ConsPros & ConsPros & Cons
Method #2:Pro: often can get a dramatic speed-up over truth tables.
Pro: requires creativity exercise your brain and be cool!
Con: requires creativity and intuition harder to do by machines
Con: semi-decidable : there is no algorithm that can prove any first-order predicate logic argument to be valid or invalid
Sept 11, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 47
Questions?Questions?Questions?Questions?
Sept 11, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 48
FallaciesFallaciesFallaciesFallacies
An error in derivation leading to an invalid argumentVague formulations of premises/conclusionMissing stepsUsing non-sound inference rules, e.g.:
Converse errorInverse error
Sept 11, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 49
Converse ErrorConverse ErrorConverse ErrorConverse Error
If John is smart then John makes a lot of moneyJohn makes a lot of moneyTherefore:John is smart
Tries to use this non-sound “inference rule”:
AB, BThus: A
Sept 11, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 50
Inverse ErrorInverse ErrorInverse ErrorInverse Error
If John is smart then John makes a lot of moneyJohn is not smartTherefore:John doesn’t make a lot of money
Tries to use this non-sound “inference rule”:
AB, ~AThus: ~B
Sept 11, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 51
Questions?Questions?Questions?Questions?
Sept 11, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 52
Truth of facts vs. Validity of Truth of facts vs. Validity of ArgumentsArguments
Truth of facts vs. Validity of Truth of facts vs. Validity of ArgumentsArguments
The premises are assumed to be true ONLY in the context of the argument
The following argument is valid:If John Lennon was a rock star then he was a womanJohn Lennon was a rock starThus:John Lennon was a woman
But the 1st premise doesn’t hold under the common sense interpretation
Sept 11, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 53
Inference RulesInference RulesInference RulesInference Rules
Table 1.3.1 on page 39
If practice with the rules then will be more fluent using them
If are more fluent using them then will be more likely to get a better mark on exams
Sept 11, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 54
SummarySummarySummarySummary
Equivalence:A BA holds iff B holdsA is a criterion for BB is a criterion for AA entails BB entails AA and B are “equivalently strong”Formula F=(AB) is a tautology
Sept 11, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 55
SummarySummarySummarySummary
Entailment:A entails BB follows from AAB is a valid argumentA is a sufficient condition for BB is a necessary condition for AIf A holds then B holdsA may be “stronger than” BFormula F=(AB) is a tautology
Sept 11, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 56
The Big PictureThe Big PictureThe Big PictureThe Big Picture
Logic is being used to verify validity of arguments
An argument is valid iff its conclusion logically follows from the premises
Derivations are used to prove validity
Inference rules are used as part of derivations
Sept 11, 2003 © Vadim Bulitko : CMPUT 272, Fall 2003, UofA 57
Questions?Questions?Questions?Questions?