Word Problem Consider the following problem: To register, you will need either a yellow card or a...

18
Word Problem Consider the following problem: To register, you will need either a yellow card or a note from the Dean. To obtain a note from the Dean you must apply to the Associate Dean. Yellow cards can only be obtained if you current in your payments and are a registered student. Registered students are never current with there payments. Therefore, to register you will need to apply to the Associate

Transcript of Word Problem Consider the following problem: To register, you will need either a yellow card or a...

Page 1: Word Problem Consider the following problem: To register, you will need either a yellow card or a note from the Dean. To obtain a note from the Dean you.

Word Problem

Consider the following problem:

To register, you will need either a yellow card or a

note from the Dean. To obtain a note from the Dean

you must apply to the Associate Dean. Yellow cards

can only be obtained if you current in your

payments and are a registered student. Registered

students are never current with there payments.

Therefore, to register you will need to apply to the

Associate Dean.

Page 2: Word Problem Consider the following problem: To register, you will need either a yellow card or a note from the Dean. To obtain a note from the Dean you.

Solution

We will use the following proposition symbols:

R = Can register

N = Has note from Dean

A = Applied to the Associate Dean

Y = Has a yellow card

C = Is current in payments

S = Is a registered student

Page 3: Word Problem Consider the following problem: To register, you will need either a yellow card or a note from the Dean. To obtain a note from the Dean you.

Problem in Propositional Logic

R -> Y v N

N -> A

Y -> C & S

S ->~ C

-------------------

R -> A

Page 4: Word Problem Consider the following problem: To register, you will need either a yellow card or a note from the Dean. To obtain a note from the Dean you.

Predicate Calculus

Propositional calculus is not powerful enough to

represent all the problems that we may want.

Consider the following argument:

All men are mortal

Socrates is a man

------------------------

Socrates is mortal

Page 5: Word Problem Consider the following problem: To register, you will need either a yellow card or a note from the Dean. To obtain a note from the Dean you.

Using Propositional Calculua

Representing this as a propositional calculus theorem

doesn't work:

M: All men are mortal M

S: Socrates is a man S

N: Socrates is mortal ---------

N

Page 6: Word Problem Consider the following problem: To register, you will need either a yellow card or a note from the Dean. To obtain a note from the Dean you.

What's the Problem

The problem is that we're not adequately representing

the fact that all men are mortal. We need to quantify

our predicate over a range of objects. For that

reason, we need to beef up propositional calculus

into a fuller representational system, predicate

calculus.

Page 7: Word Problem Consider the following problem: To register, you will need either a yellow card or a note from the Dean. To obtain a note from the Dean you.

Terms: Constants and Variables

First, we need to something to represent objects, such

as Socrates, in the world under discussion. For that

reason, we introduce constants. Constants can be

people, places, numbers, concrete objects, concepts,

whatever. Examples are Socrates, Bob, MyDog,

four, and blue.

In addition to constants, we will need variables, such

as x, y, and w, which can range over a variety of

objects.

Page 8: Word Problem Consider the following problem: To register, you will need either a yellow card or a note from the Dean. To obtain a note from the Dean you.

Terms: Compound Terms

Constants can represent objects directly. In predicate

calculus, we have the ability to construct more

complex terms, such as “Bob's father” or “the sum

of 1 and 3”. To do so, we have function symbols

which like functions in C++ take a number of

arguments and return a value. Examples would be

father, plus. When applied to the appropriate

number of arguments, these yield terms:

father(Bob), plus(one,three).

Page 9: Word Problem Consider the following problem: To register, you will need either a yellow card or a note from the Dean. To obtain a note from the Dean you.

Terms

The following are terms in predicate calculus: Constants, e.g., Socrates, Bob, one, threeVariables, e.g., x,y, w Function symbols applied to the appropriate

number of arguments, e.g., father(Bob),

plus(one,three), square(seven)These are the only way to form terms in predicate

calculus

Page 10: Word Problem Consider the following problem: To register, you will need either a yellow card or a note from the Dean. To obtain a note from the Dean you.

Atomic Sentences

In addition to terms, we will also need predicates –

expression that evaluate to true or false. The

simplest kind of predicates are atomic sentences. To

form an atomic sentence, we apply a predicate

symbol to the appropriate number of arguments

which are terms. An example of a predicate is

loves which takes two arguments. loves(Bob,Sally)

is true assuming that Bob loves Sally.

Page 11: Word Problem Consider the following problem: To register, you will need either a yellow card or a note from the Dean. To obtain a note from the Dean you.

Examples of Atomic Sentences

loves (John, Susan) // John loves Susanparent(John, Mary) // a parent of John is Maryequals(three,plus(one,two)) // 3 = 1 + 2isPresident(GeorgeWBush) // GWB is the Prez.greaterThan(three,two)loves(John,father(John))

Page 12: Word Problem Consider the following problem: To register, you will need either a yellow card or a note from the Dean. To obtain a note from the Dean you.

Sentences (or Predicates)

We form more complex sentences by using the

Boolean operators and by using quantification. The

operators are the same as for propositional calculus,

~, ^, v, ->, <->, xor. So, atomic sentences are

sentences (or predicates), the negation operator

applied to a sentence is a sentence, and a binary

Boolean operator applied to two sentences is a

sentence.

Page 13: Word Problem Consider the following problem: To register, you will need either a yellow card or a note from the Dean. To obtain a note from the Dean you.

Examples of Sentences

loves(John, Mary)^ loves(Mary, John)parent(x,y) ^ parent(y,z) -> grandparent(x,z)parent(x,father(x))witch(Glenda) v mortal(Glenda)

Page 14: Word Problem Consider the following problem: To register, you will need either a yellow card or a note from the Dean. To obtain a note from the Dean you.

Quantification

Another way to form sentences is by using

quantification. In predicate calculus, there are two

quantifiers, ∃ and ∀. ∃ means “there exists” and ∀ means “for all.” Each quantifier is followed by a

variable and then a sentence, e.g., ∀ x P(x). The

meaning is that “for all x, P(x) is true. For

examples, ∀ x loves(x, father(x)) means “every

x loves x's father” or in English, “everyone loves

his/her father.”

Page 15: Word Problem Consider the following problem: To register, you will need either a yellow card or a note from the Dean. To obtain a note from the Dean you.

Quantification (cont'd)

∃ x loves(x, father(x)) means “someone loves his or her father.” Quantifiers may be nested, and the order is important. For example,

∀ x ∃ y greaterThan(y,x) means that for all x, there is a y greater than x (which is true for the reals), but

∃ y ∀ x greater(y,x) means that there is a (single) y greater than every x (which is not true for the reals).

Page 16: Word Problem Consider the following problem: To register, you will need either a yellow card or a note from the Dean. To obtain a note from the Dean you.

Sentences (Definition)

The following are ways to form sentences:An atomic sentence (a predicate symbol applied to

the appropriate number of terms) is a sentenceNegation applied to a sentence is a sentenceA binary operator applied to two sentences is a

sentenceA quantifier followed by a variable applied to a

sentence is a sentence

These are the only sentences.

Page 17: Word Problem Consider the following problem: To register, you will need either a yellow card or a note from the Dean. To obtain a note from the Dean you.

Arity

Both function symbols and predicate symbols have a

given arity, that is, that number of arguments that

they take. This is similar to C++ functions. Just like

C++, we will try not to overload our symbols, that

is, use the same name but different arities, but on

occasion, we will. For example, loves(x,y) is

different than loves(x,y,t) (where t is meant to be a

time). Some books use subscripts to differentiate

the symbols.

Page 18: Word Problem Consider the following problem: To register, you will need either a yellow card or a note from the Dean. To obtain a note from the Dean you.

Practice Sentences

Write the following English sentences as predicate

calculus sentences:Every body loves his/her mother.Every body loves somebody sometime.You can fool all of the people some of the time, and

some of the people all of the time, but you can fool

all of the people all of the time.Brown dogs are friendly.