Top Banner
From Propositional to Predicate Logic CSCI 2824, Fall 2012 http://l3d.cs.colorado.edu/~ctg/ classes/struct12/
25

From Propositional to Predicate Logicl3d.cs.colorado.edu/~ctg/classes/struct12/lecslides/struct12lect3.pdf · From Propositional! to Predicate Logic" CSCI 2824, ... Everybody loves

Mar 20, 2018

Download

Documents

LêKhánh
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: From Propositional to Predicate Logicl3d.cs.colorado.edu/~ctg/classes/struct12/lecslides/struct12lect3.pdf · From Propositional! to Predicate Logic" CSCI 2824, ... Everybody loves

From Propositional!to Predicate Logic"

CSCI 2824, Fall 2012"http://l3d.cs.colorado.edu/~ctg/

classes/struct12/ "

Page 2: From Propositional to Predicate Logicl3d.cs.colorado.edu/~ctg/classes/struct12/lecslides/struct12lect3.pdf · From Propositional! to Predicate Logic" CSCI 2824, ... Everybody loves

Assignments • To read by the end of the week: Sections 1.1-1.6

(Ensley/Crawley) "!!!!

Page 3: From Propositional to Predicate Logicl3d.cs.colorado.edu/~ctg/classes/struct12/lecslides/struct12lect3.pdf · From Propositional! to Predicate Logic" CSCI 2824, ... Everybody loves

Playing with Logic: Mastermind

Page 4: From Propositional to Predicate Logicl3d.cs.colorado.edu/~ctg/classes/struct12/lecslides/struct12lect3.pdf · From Propositional! to Predicate Logic" CSCI 2824, ... Everybody loves

Let’s See if We Can Represent Mastermind Ideas in

Propositional Logic… First, let’s make some proposition symbols. We’ll

say that BLUE1 stands for the proposition “In the correct code, the blue peg is in position 1”.

There are a bunch of these propositions: BLUE2,

BLUE3, BLUE4, ORANGE1, ORANGE2…

Page 5: From Propositional to Predicate Logicl3d.cs.colorado.edu/~ctg/classes/struct12/lecslides/struct12lect3.pdf · From Propositional! to Predicate Logic" CSCI 2824, ... Everybody loves

More Mastermind

•  “In the correct code, there is one peg (of some color) in position 1”: – BLUE1 OR ORANGE1 OR RED1 OR

WHITE1 OR YELLOW1 OR PURPLE1 But that’s not quite enough… The statement

above is consistent with the (incorrect) possibility that both a blue and orange (say) are in position 1.

Page 6: From Propositional to Predicate Logicl3d.cs.colorado.edu/~ctg/classes/struct12/lecslides/struct12lect3.pdf · From Propositional! to Predicate Logic" CSCI 2824, ... Everybody loves

•  So we need some additional statements: NOT (ORANGE1 AND BLUE1) NOT (ORANGE1 AND RED1) NOT (ORANGE1 AND PURPLE1) etc. These statements say “It is not the case that there are two distinct colors in position 1”

Page 7: From Propositional to Predicate Logicl3d.cs.colorado.edu/~ctg/classes/struct12/lecslides/struct12lect3.pdf · From Propositional! to Predicate Logic" CSCI 2824, ... Everybody loves

What do we learn from a guess? My guess: RED BLUE WHITE ORANGE

Answer: X,0

From the X, I get: RED1 OR BLUE2 OR WHITE3 OR ORANGE4 NOT (RED1 AND BLUE2) NOT (RED1 AND WHITE3) NOT (RED1 AND ORANGE4) NOT (BLUE2 AND WHITE3) NOT (BLUE2 AND ORANGE4) NOT (WHITE3 AND ORANGE4)

Page 8: From Propositional to Predicate Logicl3d.cs.colorado.edu/~ctg/classes/struct12/lecslides/struct12lect3.pdf · From Propositional! to Predicate Logic" CSCI 2824, ... Everybody loves

What do we learn from a guess? My guess: RED BLUE WHITE ORANGE

Answer: X,0

From the 0, I get: RED2 OR RED3 OR RED4 OR BLUE1 OR BLUE3 OR BLUE4 OR

WHITE1 OR WHITE2 OR WHITE4 OR ORANGE1 OR ORANGE2 OR ORANGE3

NOT (RED2 AND BLUE1)… many others of this form

Page 9: From Propositional to Predicate Logicl3d.cs.colorado.edu/~ctg/classes/struct12/lecslides/struct12lect3.pdf · From Propositional! to Predicate Logic" CSCI 2824, ... Everybody loves

How do we solve a code?

Suppose we know: ORANGE1 OR BLUE1 NOT ORANGE1 Then we can conclude: BLUE1

Page 10: From Propositional to Predicate Logicl3d.cs.colorado.edu/~ctg/classes/struct12/lecslides/struct12lect3.pdf · From Propositional! to Predicate Logic" CSCI 2824, ... Everybody loves

What have we learned about propositional logic from this?

•  One thing that we’ve learned–on the good side–is that propositions do allow us to represent situations like Mastermind.

•  On the not-so-good side, we’ve found that doing real tasks with propositional logic (if you want to call Mastermind a real task) can require a surprising amount of “infrastructure”.

Page 11: From Propositional to Predicate Logicl3d.cs.colorado.edu/~ctg/classes/struct12/lecslides/struct12lect3.pdf · From Propositional! to Predicate Logic" CSCI 2824, ... Everybody loves

Why (or why not?) Propositional Logic

•  It’s simple to understand •  … But it’s rather inexpressive • And “simple to understand” does not mean

that all problems are simple: (x1 OR ~x5 OR x3) AND (~x1 OR ~x2 OR x6) AND (x3 OR x5 OR ~x6) AND….

Page 12: From Propositional to Predicate Logicl3d.cs.colorado.edu/~ctg/classes/struct12/lecslides/struct12lect3.pdf · From Propositional! to Predicate Logic" CSCI 2824, ... Everybody loves

A Brief Aside: Illogical Humans?

•  Problems with Modus Ponens and Modus

Tollens •  When are we logical?

Page 13: From Propositional to Predicate Logicl3d.cs.colorado.edu/~ctg/classes/struct12/lecslides/struct12lect3.pdf · From Propositional! to Predicate Logic" CSCI 2824, ... Everybody loves

K E 4 7

If a card has a vowel on one side, then it has an even number on the other side.

Page 14: From Propositional to Predicate Logicl3d.cs.colorado.edu/~ctg/classes/struct12/lecslides/struct12lect3.pdf · From Propositional! to Predicate Logic" CSCI 2824, ... Everybody loves

Drinking Coke

Drinking Beer

21 years old

18 years old

If a person is drinking an alcoholic beverage, then that person is at least twenty years old.

Page 15: From Propositional to Predicate Logicl3d.cs.colorado.edu/~ctg/classes/struct12/lecslides/struct12lect3.pdf · From Propositional! to Predicate Logic" CSCI 2824, ... Everybody loves

Propositional Logic: Where We’ve Come So Far

•  Basic “objects” are sentences with T/F values •  Connectors (AND, OR, NOT, etc.) are used to make

compound sentences •  Basic rules of inference (Modus Ponens, etc.) are used to

derive new sentences from a “knowledge base” of existing sentences

Page 16: From Propositional to Predicate Logicl3d.cs.colorado.edu/~ctg/classes/struct12/lecslides/struct12lect3.pdf · From Propositional! to Predicate Logic" CSCI 2824, ... Everybody loves

First-Order Predicate Logic •  We introduce a world of objects. Our logical sentences

will refer to these objects. •  In many computer programs, the “objects” might refer to

elements of a finite set (think about a database for, say, a library, or a business payroll)

•  For our initial examples, we’ll mainly use numbers as our objects (and we’ll specify whether we mean a finite set, integers, rationals, reals, etc.)

Page 17: From Propositional to Predicate Logicl3d.cs.colorado.edu/~ctg/classes/struct12/lecslides/struct12lect3.pdf · From Propositional! to Predicate Logic" CSCI 2824, ... Everybody loves

Some Sample Predicates

•  Prime (n) is the predicate “n is a prime number” (defined over the infinite set of positive integers)

•  Even (n) is the predicate “n is an even number”

•  Rational (x) is the predicate “x is a rational number” (defined over the infinite set of real numbers)

Page 18: From Propositional to Predicate Logicl3d.cs.colorado.edu/~ctg/classes/struct12/lecslides/struct12lect3.pdf · From Propositional! to Predicate Logic" CSCI 2824, ... Everybody loves

Some statements about positive integers (note: we still have the

usual connectors):���

Prime (19) Even (7) OR Even (8) Prime(23) AND NOT(Even (23))

Page 19: From Propositional to Predicate Logicl3d.cs.colorado.edu/~ctg/classes/struct12/lecslides/struct12lect3.pdf · From Propositional! to Predicate Logic" CSCI 2824, ... Everybody loves

First-Order Predicate Logic: A Bit More Terminology

We allow predicates of two or more arguments: Greater-Than(5, 3)

Relatively-Prime (25, 6) Equal (2, 2) [often we just write 2 = 2 for simplicity]

We have two quantifiers: THERE-EXISTS and FOR-ALL

FOR-ALL(n) [(Prime(n) AND Greater-than(n, 2)) -> NOT (Even (n))]

THERE-EXISTS(n) [Even(n) AND Prime(n)]

Page 20: From Propositional to Predicate Logicl3d.cs.colorado.edu/~ctg/classes/struct12/lecslides/struct12lect3.pdf · From Propositional! to Predicate Logic" CSCI 2824, ... Everybody loves

Predicate Logic “Classics”

FOR-ALL(n)[ Prime(n) à THERE-EXISTS(q) [Greater-than(q, n) AND Prime(q)]]

Page 21: From Propositional to Predicate Logicl3d.cs.colorado.edu/~ctg/classes/struct12/lecslides/struct12lect3.pdf · From Propositional! to Predicate Logic" CSCI 2824, ... Everybody loves

Predicate Logic “Classics”

FOR-ALL(n) [(Even(n) AND Greater-than(n, 2)) –> THERE-EXISTS (p, q) [Prime(p) AND Prime(q) AND n = (p + q)]] “The Goldbach Conjecture”

Page 22: From Propositional to Predicate Logicl3d.cs.colorado.edu/~ctg/classes/struct12/lecslides/struct12lect3.pdf · From Propositional! to Predicate Logic" CSCI 2824, ... Everybody loves

Quantifiers in English: An Example

You can fool all of the people some of the time, and some of the people all of the time, but you can’t fool all of the people all of the time.

FOR-ALL (x) [Person(x) --> THERE-EXISTS(t)[Time(t) AND Fool-at-time(x, t)]]

THERE-EXISTS(x) [Person(x) AND (FOR-ALL(t)[Time(t) --> Fool-at-time(x, t)]]

NOT(FOR-ALL(x, t)[(Person(x) AND Time(t)) --> Fool-at-time(x,t)]

Page 23: From Propositional to Predicate Logicl3d.cs.colorado.edu/~ctg/classes/struct12/lecslides/struct12lect3.pdf · From Propositional! to Predicate Logic" CSCI 2824, ... Everybody loves

Quantifiers and Dean Martin Everybody loves somebody sometime. FOR-ALL(x)[Person(x) --> THERE-EXISTS(y, t) [Person(y) and Time(t) and Loves-at-time(x,y,t)]] THERE-EXISTS(t,y)[Time(t) AND Person(y) AND FOR-ALL(x)[Person(x) --> Loves-at-time(x,y, t)]]

Page 24: From Propositional to Predicate Logicl3d.cs.colorado.edu/~ctg/classes/struct12/lecslides/struct12lect3.pdf · From Propositional! to Predicate Logic" CSCI 2824, ... Everybody loves

THERE-EXISTS(t)[Time(t) AND FOR-ALL(x) [Person(x) --> THERE-EXISTS(y) [Person(y) AND Loves-at-time(x,y,t)]} THERE-EXISTS(y)[Person(y) AND FOR-ALL(x) [Person (x) --> THERE-EXISTS(t)[Time(t) AND Loves-at-time(x, y, t)]]

Page 25: From Propositional to Predicate Logicl3d.cs.colorado.edu/~ctg/classes/struct12/lecslides/struct12lect3.pdf · From Propositional! to Predicate Logic" CSCI 2824, ... Everybody loves

Mastermind Challenge Problem ���(due 9/11)

Colors: Blue, Orange, Red, Yellow, Purple, White Repeat colors in the code are allowed. Clues: “x” = “a peg in the right position” “o” = “a peg that has to be moved to be in the right position” W O B R ! ! !xo !P Y R B ! ! !xo!R R O Y ! ! !ooo!Y R R W ! ! !xx!