Zack Lane ReCAP Coordinator February 16, 2011 ReCAP Columbia University.
Logic - recap - Portland State Universityweb.cecs.pdx.edu/.../LECTURES479/009.basicLogic.pdf ·...
Transcript of Logic - recap - Portland State Universityweb.cecs.pdx.edu/.../LECTURES479/009.basicLogic.pdf ·...
![Page 1: Logic - recap - Portland State Universityweb.cecs.pdx.edu/.../LECTURES479/009.basicLogic.pdf · Logic - recap So far, we have ... One useful technique for answering questions about](https://reader031.fdocuments.us/reader031/viewer/2022020413/5b4f9a327f8b9a2a6e8ca678/html5/thumbnails/1.jpg)
![Page 2: Logic - recap - Portland State Universityweb.cecs.pdx.edu/.../LECTURES479/009.basicLogic.pdf · Logic - recap So far, we have ... One useful technique for answering questions about](https://reader031.fdocuments.us/reader031/viewer/2022020413/5b4f9a327f8b9a2a6e8ca678/html5/thumbnails/2.jpg)
Logic - recap
● So far, we have seen that:● Logic is a “language” which can be used
to describe:● Statements about the real world● The simplest pieces of data in an automatic
processing system such as a computer
![Page 3: Logic - recap - Portland State Universityweb.cecs.pdx.edu/.../LECTURES479/009.basicLogic.pdf · Logic - recap So far, we have ... One useful technique for answering questions about](https://reader031.fdocuments.us/reader031/viewer/2022020413/5b4f9a327f8b9a2a6e8ca678/html5/thumbnails/3.jpg)
Logic - recap
● The key characteristic of a statement, ora piece of data, in logic is its truth value.There are two possible truth values:● True● False
![Page 4: Logic - recap - Portland State Universityweb.cecs.pdx.edu/.../LECTURES479/009.basicLogic.pdf · Logic - recap So far, we have ... One useful technique for answering questions about](https://reader031.fdocuments.us/reader031/viewer/2022020413/5b4f9a327f8b9a2a6e8ca678/html5/thumbnails/4.jpg)
Logic - recap
● Simple statements, or simple pieces ofdata, can be joined together to givemore complicated structures usinglogical connectives.
● The most important of these are “and”,“or”, “implies”, “equivalent to” and “not”,for which we use the symbols ∧, ∨, ⇒,⇔, and ¬ respectively.
![Page 5: Logic - recap - Portland State Universityweb.cecs.pdx.edu/.../LECTURES479/009.basicLogic.pdf · Logic - recap So far, we have ... One useful technique for answering questions about](https://reader031.fdocuments.us/reader031/viewer/2022020413/5b4f9a327f8b9a2a6e8ca678/html5/thumbnails/5.jpg)
Logic - recap
● Each of these logical connectives isdefined by a truth table.
● It is often possible to convert an Englishsentence into a logical formula – thereare simple techniques for doing this.
![Page 6: Logic - recap - Portland State Universityweb.cecs.pdx.edu/.../LECTURES479/009.basicLogic.pdf · Logic - recap So far, we have ... One useful technique for answering questions about](https://reader031.fdocuments.us/reader031/viewer/2022020413/5b4f9a327f8b9a2a6e8ca678/html5/thumbnails/6.jpg)
Logic - recap● Questions:
● “when is this formula true?”● “are these two formulae essentially the same?”
● One useful technique for answeringquestions about logical formula (such asabove) is to draw up a large truth tabledescribing the formula/formulae in question.
![Page 7: Logic - recap - Portland State Universityweb.cecs.pdx.edu/.../LECTURES479/009.basicLogic.pdf · Logic - recap So far, we have ... One useful technique for answering questions about](https://reader031.fdocuments.us/reader031/viewer/2022020413/5b4f9a327f8b9a2a6e8ca678/html5/thumbnails/7.jpg)
What is low-level logic usedfor?
● To specify the way in whichindividual bits of information areprocessed in order to perform thearithmetic, and all the other forms ofsymbolic processing, that goes onin the circuits of a computer.
![Page 8: Logic - recap - Portland State Universityweb.cecs.pdx.edu/.../LECTURES479/009.basicLogic.pdf · Logic - recap So far, we have ... One useful technique for answering questions about](https://reader031.fdocuments.us/reader031/viewer/2022020413/5b4f9a327f8b9a2a6e8ca678/html5/thumbnails/8.jpg)
What is high-level logic usedfor?
● Used as an unambiguouslanguage,
● i.e. as a medium for knowledgerepresentation.
![Page 9: Logic - recap - Portland State Universityweb.cecs.pdx.edu/.../LECTURES479/009.basicLogic.pdf · Logic - recap So far, we have ... One useful technique for answering questions about](https://reader031.fdocuments.us/reader031/viewer/2022020413/5b4f9a327f8b9a2a6e8ca678/html5/thumbnails/9.jpg)
What is high-level logic usedfor?
● Used as a rigorous form of reasoning.● Deductions which follow the rules of logic
are guaranteed to be correct.● This is not necessarily true of other
representation schemes.● So logic can act as a "gold standard""gold standard"
against which other forms orrepresentation and reasoning can beassessed.
![Page 10: Logic - recap - Portland State Universityweb.cecs.pdx.edu/.../LECTURES479/009.basicLogic.pdf · Logic - recap So far, we have ... One useful technique for answering questions about](https://reader031.fdocuments.us/reader031/viewer/2022020413/5b4f9a327f8b9a2a6e8ca678/html5/thumbnails/10.jpg)
What is high-level logic usedfor?
● Logic is available for establishingwhether a complicated argument, e.g. alegal case, makes sense or not.
![Page 11: Logic - recap - Portland State Universityweb.cecs.pdx.edu/.../LECTURES479/009.basicLogic.pdf · Logic - recap So far, we have ... One useful technique for answering questions about](https://reader031.fdocuments.us/reader031/viewer/2022020413/5b4f9a327f8b9a2a6e8ca678/html5/thumbnails/11.jpg)
What is high-level logic used for?● Logic is a tool for mathematical research.● The mathematician has available a set of
propositions which have been established astrue -● these are referred to as "the axioms".
● He/she has a proposition, or set of propositions,that he/she wants to prove to be true -● referred to as "the theorem".
● Both sets can be written as statements in logic:● the problem is to find a set of sound logical
manipulations to convert one into the other.
![Page 12: Logic - recap - Portland State Universityweb.cecs.pdx.edu/.../LECTURES479/009.basicLogic.pdf · Logic - recap So far, we have ... One useful technique for answering questions about](https://reader031.fdocuments.us/reader031/viewer/2022020413/5b4f9a327f8b9a2a6e8ca678/html5/thumbnails/12.jpg)
More on processing logicalformulae
● The “build a truth table” techniquedescribed earlier always works,● at least for the simple form of logic we’ve
been using so far.● However, sometimes it isn’t necessary.
Instead, to solve a problem in logic, wecan use:● Rules of inference● Logical equivalencies
![Page 13: Logic - recap - Portland State Universityweb.cecs.pdx.edu/.../LECTURES479/009.basicLogic.pdf · Logic - recap So far, we have ... One useful technique for answering questions about](https://reader031.fdocuments.us/reader031/viewer/2022020413/5b4f9a327f8b9a2a6e8ca678/html5/thumbnails/13.jpg)
Rules of inference
● These are well-established ways ofproving an argument in logic.
![Page 14: Logic - recap - Portland State Universityweb.cecs.pdx.edu/.../LECTURES479/009.basicLogic.pdf · Logic - recap So far, we have ... One useful technique for answering questions about](https://reader031.fdocuments.us/reader031/viewer/2022020413/5b4f9a327f8b9a2a6e8ca678/html5/thumbnails/14.jpg)
The most useful are:● modus ponens: P ⇒ Q. P. ∴ Q.● modus tolens: P ⇒ Q. ¬Q. ∴ ¬P.● disjunctive syllogism:P ∨ Q. ¬P. ∴ Q.● hypothetical syllogism: P ⇒ Q. Q ⇒ R.
∴ P ⇒ R.● contraposition: P ⇒ Q. ∴ ¬Q ⇒ ¬P.● In English, the first of these would read “If you
know that P implies Q, and you know that P istrue, then you know that Q is true.”
● These can be used to establish the truth ofarguments involving complicated formulae.
![Page 15: Logic - recap - Portland State Universityweb.cecs.pdx.edu/.../LECTURES479/009.basicLogic.pdf · Logic - recap So far, we have ... One useful technique for answering questions about](https://reader031.fdocuments.us/reader031/viewer/2022020413/5b4f9a327f8b9a2a6e8ca678/html5/thumbnails/15.jpg)
Logical equivalences:
● these are well-established ways of turninga logical statement containing one set oflogical connectives into a statementcontaining a different set.
![Page 16: Logic - recap - Portland State Universityweb.cecs.pdx.edu/.../LECTURES479/009.basicLogic.pdf · Logic - recap So far, we have ... One useful technique for answering questions about](https://reader031.fdocuments.us/reader031/viewer/2022020413/5b4f9a327f8b9a2a6e8ca678/html5/thumbnails/16.jpg)
Logical equivalences
● Here are some of the more important ones.● IdempotencyP is logically equivalent to (P ∧ P)● Double negationP is logically equivalent to ¬¬P● Commutative laws(P ∧ Q) is logically equivalent to (Q ∧ P)(P ∨ Q) is logically equivalent to (Q ∨ P)
![Page 17: Logic - recap - Portland State Universityweb.cecs.pdx.edu/.../LECTURES479/009.basicLogic.pdf · Logic - recap So far, we have ... One useful technique for answering questions about](https://reader031.fdocuments.us/reader031/viewer/2022020413/5b4f9a327f8b9a2a6e8ca678/html5/thumbnails/17.jpg)
Logical equivalencies
● Associative laws(P ∧ (Q ∧ R) is logically equivalent to ((P ∧ Q) ∧ R)(P ∨ (Q ∨ R)) is logically equivalent to ((P ∨ Q) ∨ R)
● Distributive laws(P ∧ (Q ∨ R) is logically equivalent to ((P ∧ Q) ∨ (P ∧ R))(P ∨ (Q ∧ R)) is logically equivalent to ((P ∨ Q) ∧ (P ∨ R))
![Page 18: Logic - recap - Portland State Universityweb.cecs.pdx.edu/.../LECTURES479/009.basicLogic.pdf · Logic - recap So far, we have ... One useful technique for answering questions about](https://reader031.fdocuments.us/reader031/viewer/2022020413/5b4f9a327f8b9a2a6e8ca678/html5/thumbnails/18.jpg)
Logical equivalences● De Morgan’s laws
¬(P ∧ Q) is logically equivalent to (¬P ∨ ¬Q)¬(P ∨ Q) is logically equivalent to (¬P ∧ ¬Q)
● Contraposition(P ⇒ Q) is logically equivalent to (¬Q ⇒ ¬P)
![Page 19: Logic - recap - Portland State Universityweb.cecs.pdx.edu/.../LECTURES479/009.basicLogic.pdf · Logic - recap So far, we have ... One useful technique for answering questions about](https://reader031.fdocuments.us/reader031/viewer/2022020413/5b4f9a327f8b9a2a6e8ca678/html5/thumbnails/19.jpg)
Logical equivalences
● Redefining material conditional as adisjunction or conjunction
(P ⇒ Q) is logically equivalent to (¬P ∨ Q)(P ⇒ Q) is logically equivalent to ¬(P ∧ ¬Q)
● Exportation(P ⇒ (Q ⇒ R)) is logically equivalent to
((P ∧ Q) ⇒ R))
![Page 20: Logic - recap - Portland State Universityweb.cecs.pdx.edu/.../LECTURES479/009.basicLogic.pdf · Logic - recap So far, we have ... One useful technique for answering questions about](https://reader031.fdocuments.us/reader031/viewer/2022020413/5b4f9a327f8b9a2a6e8ca678/html5/thumbnails/20.jpg)
Logical equivalencies
● It's not necessary to remember theelaborate names, or the exact details ofthese equivalences.
● It is important to appreciate that, by usingone of these equivalences, a logicalformula can be turned into a formulawhich looks quite different, but whichactually has exactly the same truth value.
![Page 21: Logic - recap - Portland State Universityweb.cecs.pdx.edu/.../LECTURES479/009.basicLogic.pdf · Logic - recap So far, we have ... One useful technique for answering questions about](https://reader031.fdocuments.us/reader031/viewer/2022020413/5b4f9a327f8b9a2a6e8ca678/html5/thumbnails/21.jpg)
Tautologies and contradictions
• A logical statement which is always true(no matter what values you give to theparts that make it up) is called atautology.
• A statement which is always false iscalled a contradiction.
• All other logical statements are knownas contingent statements.
![Page 22: Logic - recap - Portland State Universityweb.cecs.pdx.edu/.../LECTURES479/009.basicLogic.pdf · Logic - recap So far, we have ... One useful technique for answering questions about](https://reader031.fdocuments.us/reader031/viewer/2022020413/5b4f9a327f8b9a2a6e8ca678/html5/thumbnails/22.jpg)
Tautologies and contradictions
● example: Consider the statement(¬P ⇒ ((P ∨ Q) ⇔ Q)).
P could be true and Q could be true.P could be false and Q could be false.P could be true and Q could be false.P could be false and Q could be true.● In every one of these cases, the whole
statement would be true.● So the statement is a tautology.
![Page 23: Logic - recap - Portland State Universityweb.cecs.pdx.edu/.../LECTURES479/009.basicLogic.pdf · Logic - recap So far, we have ... One useful technique for answering questions about](https://reader031.fdocuments.us/reader031/viewer/2022020413/5b4f9a327f8b9a2a6e8ca678/html5/thumbnails/23.jpg)
Propositional calculus
● The simple form of logic whichwe have been using so far, in whichthe symbols stand for ideas whichcan be expressed as wholesentences, is known asPropositionalPropositional Calculus Calculus.
![Page 24: Logic - recap - Portland State Universityweb.cecs.pdx.edu/.../LECTURES479/009.basicLogic.pdf · Logic - recap So far, we have ... One useful technique for answering questions about](https://reader031.fdocuments.us/reader031/viewer/2022020413/5b4f9a327f8b9a2a6e8ca678/html5/thumbnails/24.jpg)
Propositional calculus
● Propositional calculus is decidable:● it's always possible to decide whether
an argument in propositional calculusis valid or not.
● You can either use the logicalequivalence rules, and the rules ofinference, described above, or youcan build a big truth table.
![Page 25: Logic - recap - Portland State Universityweb.cecs.pdx.edu/.../LECTURES479/009.basicLogic.pdf · Logic - recap So far, we have ... One useful technique for answering questions about](https://reader031.fdocuments.us/reader031/viewer/2022020413/5b4f9a327f8b9a2a6e8ca678/html5/thumbnails/25.jpg)
Propositional calculus
● Propositional calculus:● is the simplest form of logic,● and also the weakest,
in terms of its power to express ideas.● Other forms of logic have been invented
to express more complex ideas.
![Page 26: Logic - recap - Portland State Universityweb.cecs.pdx.edu/.../LECTURES479/009.basicLogic.pdf · Logic - recap So far, we have ... One useful technique for answering questions about](https://reader031.fdocuments.us/reader031/viewer/2022020413/5b4f9a327f8b9a2a6e8ca678/html5/thumbnails/26.jpg)
Predicate calculus
● Another form of logic: first orderpredicate calculus.
● There are many fairly simple, obviousarguments that propositional calculuscannot handle at all.
e.g. All lawyers are scoundrels. Sir JamesThames is a lawyer. Therefore Sir JamesThames is a scoundrel.
![Page 27: Logic - recap - Portland State Universityweb.cecs.pdx.edu/.../LECTURES479/009.basicLogic.pdf · Logic - recap So far, we have ... One useful technique for answering questions about](https://reader031.fdocuments.us/reader031/viewer/2022020413/5b4f9a327f8b9a2a6e8ca678/html5/thumbnails/27.jpg)
Predicate calculus● 1st order predicate calculus has some extra
features: the statements joined by the logicalconnectives can be predicates. e.g.
a(b) a(b, c) lawyer(Sir_James_Thames) owes(Jim, Sid, 500pounds)
These can convey ideas such as "b is an a", “bhas the quality a”, or "b & c are connected bythe property a". A predicate can have any number of places, i.e.
items in brackets.
![Page 28: Logic - recap - Portland State Universityweb.cecs.pdx.edu/.../LECTURES479/009.basicLogic.pdf · Logic - recap So far, we have ... One useful technique for answering questions about](https://reader031.fdocuments.us/reader031/viewer/2022020413/5b4f9a327f8b9a2a6e8ca678/html5/thumbnails/28.jpg)
Predicate calculus
● The items inside the brackets of a predicatecan be constants (names of things orrelationships) or variables.● If they're variables, they don't refer to
specific things; specific items can besubstituted for them.
● When this happens, all variables with thesame name will refer to the same thing.
![Page 29: Logic - recap - Portland State Universityweb.cecs.pdx.edu/.../LECTURES479/009.basicLogic.pdf · Logic - recap So far, we have ... One useful technique for answering questions about](https://reader031.fdocuments.us/reader031/viewer/2022020413/5b4f9a327f8b9a2a6e8ca678/html5/thumbnails/29.jpg)
Predicate calculus - the universalquantifier
● 1st order predicate calculus has asymbol ∀∀∀∀ called the universalquantifier.
● ∀ x means "for every x".
![Page 30: Logic - recap - Portland State Universityweb.cecs.pdx.edu/.../LECTURES479/009.basicLogic.pdf · Logic - recap So far, we have ... One useful technique for answering questions about](https://reader031.fdocuments.us/reader031/viewer/2022020413/5b4f9a327f8b9a2a6e8ca678/html5/thumbnails/30.jpg)
Predicate calculus - the universalquantifier
● Thus, if lawyer(x) means "x is a lawyer"and scoundrel(x) means "x is ascoundrel",
∀ x ( lawyer(x) ⇒ scoundrel(x) )means "for every x, if that x is a lawyer,then that x is a scoundrel".Which is the predicate calculus way ofsaying "All lawyers are scoundrels."
![Page 31: Logic - recap - Portland State Universityweb.cecs.pdx.edu/.../LECTURES479/009.basicLogic.pdf · Logic - recap So far, we have ... One useful technique for answering questions about](https://reader031.fdocuments.us/reader031/viewer/2022020413/5b4f9a327f8b9a2a6e8ca678/html5/thumbnails/31.jpg)
Predicate calculus - the existentialquantifier
● 1st order predicate calculus has a
symbol ∃∃∃∃ called the existentialquantifier.
● ∃ x means "there is an x such that".
![Page 32: Logic - recap - Portland State Universityweb.cecs.pdx.edu/.../LECTURES479/009.basicLogic.pdf · Logic - recap So far, we have ... One useful technique for answering questions about](https://reader031.fdocuments.us/reader031/viewer/2022020413/5b4f9a327f8b9a2a6e8ca678/html5/thumbnails/32.jpg)
Predicate calculus - the existentialquantifier
● If lawyer(x) means "x is a lawyer" andscoundrel(x) means "x is a scoundrel",
∃ x ( lawyer(x) ∧ scoundrel(x) )means "There is an x such that x is a lawyer,and x is a scoundrel".Which means that there is at least one lawyerwho is a scoundrel, and is the predicatecalculus way of saying "Some lawyers arescoundrels."
![Page 33: Logic - recap - Portland State Universityweb.cecs.pdx.edu/.../LECTURES479/009.basicLogic.pdf · Logic - recap So far, we have ... One useful technique for answering questions about](https://reader031.fdocuments.us/reader031/viewer/2022020413/5b4f9a327f8b9a2a6e8ca678/html5/thumbnails/33.jpg)
Predicate calculus
● Predicate calculus uses the samelogical connectives as propositionalcalculus.
![Page 34: Logic - recap - Portland State Universityweb.cecs.pdx.edu/.../LECTURES479/009.basicLogic.pdf · Logic - recap So far, we have ... One useful technique for answering questions about](https://reader031.fdocuments.us/reader031/viewer/2022020413/5b4f9a327f8b9a2a6e8ca678/html5/thumbnails/34.jpg)
Logic and ambiguity
● One of the problems with converting statementsin English into statements in some otherknowledge representation is that Englishstatements are often ambiguous. e.g.
"Someone is mugged in Soho every day."[Could mean: "a particular person goes to Sohoevery day, and gets mugged"; or "A muggingtakes place in Soho every day (not necessarilywith the same victim)".]
![Page 35: Logic - recap - Portland State Universityweb.cecs.pdx.edu/.../LECTURES479/009.basicLogic.pdf · Logic - recap So far, we have ... One useful technique for answering questions about](https://reader031.fdocuments.us/reader031/viewer/2022020413/5b4f9a327f8b9a2a6e8ca678/html5/thumbnails/35.jpg)
Logic and ambiguity
● Statements in predicate calculus aren'tambiguous, so translating English intopredicate calculus forces the ambiguity to beironed out. The previous statement translatesinto:
∃ x( person(x) ∧ ∀ y( day(y) ⇒(mugged_on(x, y) ∧ mugged_in(x, Soho))))
or ∀ x( day(x) ⇒ ∃ y( person(y) ∧mugged_on(y, x) ∧ mugged_in(y, Soho))))
![Page 36: Logic - recap - Portland State Universityweb.cecs.pdx.edu/.../LECTURES479/009.basicLogic.pdf · Logic - recap So far, we have ... One useful technique for answering questions about](https://reader031.fdocuments.us/reader031/viewer/2022020413/5b4f9a327f8b9a2a6e8ca678/html5/thumbnails/36.jpg)
Predicate calculus
● Establishing whether an argument isvalid or not, in First Order PredicateCalculus:
● this is harder than in propositionalcalculus.
● You can't use truth tables.
![Page 37: Logic - recap - Portland State Universityweb.cecs.pdx.edu/.../LECTURES479/009.basicLogic.pdf · Logic - recap So far, we have ... One useful technique for answering questions about](https://reader031.fdocuments.us/reader031/viewer/2022020413/5b4f9a327f8b9a2a6e8ca678/html5/thumbnails/37.jpg)
Predicate calculus
● There are some rules of inference (i.e. waysof proving an argument) which correspond tothose found in propositional calculus;e.g. universal instantiation:
∀∀∀∀ x( p(x) ⇒⇒⇒⇒ c(x) ) p(a). ∴ c(a).
and the rules already established forpropositional calculus apply here too.
![Page 38: Logic - recap - Portland State Universityweb.cecs.pdx.edu/.../LECTURES479/009.basicLogic.pdf · Logic - recap So far, we have ... One useful technique for answering questions about](https://reader031.fdocuments.us/reader031/viewer/2022020413/5b4f9a327f8b9a2a6e8ca678/html5/thumbnails/38.jpg)
Predicate calculus
● There are techniques for proving anargument in FOPC - sequences of stepswhich will always show that an argument istrue, if it is true.
● If it isn't true, the sequence of steps is liableto go on for ever, without producing a result.
● For this reason, FOPC is said to be semi-decidable.
![Page 39: Logic - recap - Portland State Universityweb.cecs.pdx.edu/.../LECTURES479/009.basicLogic.pdf · Logic - recap So far, we have ... One useful technique for answering questions about](https://reader031.fdocuments.us/reader031/viewer/2022020413/5b4f9a327f8b9a2a6e8ca678/html5/thumbnails/39.jpg)
Problems and Assignments
● Read Chapter 2 in the Luger/Stubblefieldbook.
● Read chapter 3.3 in the Luger/Stubblefieldbook.
● Read chapter 5.4 in the Luger/Stubblefieldbook.
● Create a robot planner using predicatecalculus, next program it in Prolog.
![Page 40: Logic - recap - Portland State Universityweb.cecs.pdx.edu/.../LECTURES479/009.basicLogic.pdf · Logic - recap So far, we have ... One useful technique for answering questions about](https://reader031.fdocuments.us/reader031/viewer/2022020413/5b4f9a327f8b9a2a6e8ca678/html5/thumbnails/40.jpg)
Sources
● John Platts