Slides adapted from

37
Slides adapted from Michael P. Frank's course based on the text Discrete Mathematics & Its Applications (5 th Edition) by Kenneth H. Rosen University of Aberdeen, Computing Science CS2013 Mathematics for Computing Science Adam Wyner

description

University of Aberdeen, Computing Science CS2013 Mathematics for Computing Science Adam Wyner. Slides adapted from Michael P. Frank ' s course based on the text Discrete Mathematics & Its Applications (5 th Edition) by Kenneth H. Rosen. Predicate Logic. - PowerPoint PPT Presentation

Transcript of Slides adapted from

Page 1: Slides adapted from

Slides adapted fromMichael P. Frank's course based on the textDiscrete Mathematics & Its Applications

(5th Edition)by Kenneth H. Rosen

University of Aberdeen, Computing Science

CS2013Mathematics for Computing

ScienceAdam Wyner

Page 2: Slides adapted from

Predicate Logic

Rosen 5th ed., §§1.3-1.4 (but much extended)

Page 3: Slides adapted from

Fall 2013 Frank / van Deemter / Wyner 3

Agenda

• Why Predicate Logic?• Applications• Syntax and semantics – informal to formal• Work thorough examples• Bound and free variables• Complex expressions (quantifiers with logical connectives;

nested quantifiers)• Quantifier equivalences• Vacuous quantification and false antecedents• Defining (or not) other quantifiers

Page 4: Slides adapted from

Fall 2013 Frank / van Deemter / Wyner 4

To Predicate Logic

• We can use propositional logic to prove that certain real-life inferences are valid.– If it’s cold then it snows. – If it snows there are accidents– There are no accidents.– Therefore, it’s not cold

• In propositional logic:((cs sa a) c) is a tautology

Page 5: Slides adapted from

Fall 2013 Frank / van Deemter / Wyner 5

Predicate Logic

• In propositional logic:(((cs) (sa) a) c) is a tautology

• Alternatively, it follows by propositional logic:(cs) (sa) a (premise) that c (conclusion).

Page 6: Slides adapted from

Fall 2013 Frank / van Deemter / Wyner 6

Predicate Logic

• How to understand why Everyone is happy is false where the people are {bill, jill, mary} and Mary is not happy is true.

• How to prove valid inferences that cannot be proven valid in propositional logic– Every human is mortal. Socrates is human. Therefore,

Socrates is mortal.• We need a more expressive logic for quantifiers

and predicates.

Page 7: Slides adapted from

Fall 2013 Frank / van Deemter / Wyner 7

Predicate Logic

• In propositional logic, we have simple propositions (atomic statements) and complex propositions (formed using truth functional operators).

• In propositional logic, we have truth tables that represent alternative contexts.

Page 8: Slides adapted from

Fall 2013 Frank / van Deemter / Wyner 8

Predicate Logic

• Predicate logic extends propositional logic– Keeps the truth functional operators and truth tables.– Adds constants, variables and quantification over

classes of entities.– Adds a distinction between the arguments of a sentence

(e.g. subject, object, etc) and the predicates of a sentence (e.g. verbs).

– Has models arguments and predicates of a domain.

Page 9: Slides adapted from

Fall 2013 Frank / van Deemter / Wyner 9

Applications of Predicate Logic

It is one of the most-used formal notations for writing mathematical definitions, axioms, and theorems.

For example, in linear algebra, a partial order is introduced saying that a relation R is reflexive and transitive – and these notions are defined using predicate logic.

Page 10: Slides adapted from

Fall 2013 Frank / van Deemter / Wyner 10

Applications of Predicate Logic

• Basis for many Artificial Intelligence systems.– Automatic program verification systems– Real world rule engines with NL interfaces

• Oracle Policy Automationhttp://www.youtube.com/OraclePAVideos

• Predicate-logic like statements are supported by some database query engines.

• Limitations (more later)

Page 11: Slides adapted from

Fall 2013 Frank / van Deemter / Wyner 11

A Bit of Grammar

• In The dog is sleeping:– The dog is an argument, the subject.– is sleeping is a one-place predicate (an intransitive

verb), a property that is ascribed to the subject.• In The girl hit the ball:

– The girl is the subject and the ball is the object.– hit is a two-place predicate (a transitive verb), a

relation that is ascribed between the subject and object.• Predicate logic follows a similar form.

Page 12: Slides adapted from

Fall 2013 Frank / van Deemter / Wyner 12

Constants and Variables (informal)

• Individual constants that denote individuals/objects: a,b,c,…

Constants are a bit like proper names (e.g. names for things such as Bill, Jill, IBM). The meaning is fixed.

• Individual variables that range over objects: x, y, z , …

Variables are like pronouns (e.g. he, she, it). The meaning varies, depending on what is indicated.

Page 13: Slides adapted from

Fall 2013 Frank / van Deemter / Wyner 13

Predicates and Arguments (informal)

• A predicate P applied to constant a is the proposition P(a).– Meaning: the object denoted by a has the property P.

P(a) is T or F.• A predicate P applied to a variable x is a

propositional form P(x).– Meaning: given an object that denotes a value of x, the

object has the property P. P(x) is T or F depending on the value of x.

Page 14: Slides adapted from

Fall 2013 Frank / van Deemter / Wyner 14

Forms and Evaluations (informal)

• Jill is happy (NL)– is_happy'(jill').– True if in the model the denotation of jill' is an element

of the denotation of is_happy' (jill cannot vary).• He is happy (NL)

– is_happy'(x). No gender on variables!– True if in the model given a denotation of x, that object

is an element of the denotation of is_happy' (x can vary)

Page 15: Slides adapted from

Fall 2013 Frank / van Deemter / Wyner 15

Models and Evaluation (informal)

• A model, M, is a "toy" representation of a "world" has– a Domain (Universe) of Discourse D, which is the set

of things that the predicates of the logic relate to and nothing else.

– denotations for constants and predicates. Constants are related to a particular thing in D. The denotation (extension) of a predicate is the set of objects (set of relations) from D for which the predicate holds.

– a manipulation on variables

Page 16: Slides adapted from

Fall 2013 Frank / van Deemter / Wyner 16

Models and Evaluation (informal)

• M1:– D = {jill, bill, phil, will, mary}– is_happy' denotes {jill, bill, phil}– jill' denotes jill

• Evaluation (of Jill is happy)– is_happy'(jill') is T in m1 iff jill {jill, bill, phil}

Page 17: Slides adapted from

Fall 2013 Frank / van Deemter / Wyner 17

Models and Evaluation (informal)

• M1: D = {jill, bill, phil, will, mary}, is_happy' denotes {jill, bill, phil}, jill' denotes jill

• Evaluation (of It is happy)– is_happy(x) is T in m1 iff x {jill, bill, phil}??– Depends on what x is:

• is F where x = mary, for mary {jill, bill, phil}• is T where x = phil, for phil {jill, bill, phil}

– Say where x is assigned the value mary....

Page 18: Slides adapted from

Fall 2013 Frank / van Deemter / Wyner 18

Quantifiers (informal)

• Someone is happy.– Is True iff for some value of y wrt D, is_happy'(y) is

True.– y is_happy'(y)

• Everyone is hungry.– Is True iff for every value of x wrt D, is_hungry'(x) is

True.– x is_hungry'(x)

• Everyone is happy.

Quantifiers provide a notation to express 'some' and 'all'.

Page 19: Slides adapted from

Fall 2013 Frank / van Deemter / Wyner 19

Models and Evaluation (informal)

• M2: where D = {jill, bill, phil, will, mary}, is_happy' denotes {jill, bill, phil}, is_hungry' denotes {jill, bill, phil, will, mary}, jill' denotes jill (and so on).

• Evaluation (of Someone is happy)– y is_happy'(y) is T iff there is an assignment of a

value from D to y such that is_happy'(y) is true.– is_happy'(y) is: T where y = jill; F where y = mary; F

where y = will; T where y = phil; T where y = bill.– y is_happy'(y) is T for there is an assignment such that

is_happy'(y) is true.

Page 20: Slides adapted from

Fall 2013 Frank / van Deemter / Wyner 20

Models and Evaluation (informal)

• M2: where D = {jill, bill, phil, will, mary}, is_happy' denotes {jill, bill, phil}, is_hungry' denotes {jill, bill, phil, will, mary}, jill' denotes jill (and so on).

• Evaluation (of Everyone is happy)– y is_happy'(y) is T iff for every assignment of a value

from D to y, is_happy'(y) is true.– is_happy'(y) is: T where y = jill; F where y = mary; F

where y = will; T where y = phil; T where y = bill.– y is_happy'(y) is F for it is false that for every

assignment of a value to y, is_happy'(y) is true.

Page 21: Slides adapted from

Fall 2013 Frank / van Deemter / Wyner 21

Models and Evaluation (informal)

• M2: where D = {jill, bill, phil, will, mary}, is_happy' denotes {jill, bill, phil}, is_hungry' denotes {jill, bill, phil, will, mary}, jill' denotes jill (and so on).

• Evaluation (of Everyone is hungry)– x is_hungry'(x) is T iff for every assignment of a

value from D to x, is_hungry'(x) is true.– is_hungry'(x) is: T where x = jill; T where x = mary; T

where x = will; T where x = phil; T where x = bill.– y is_hungry'(x) is T for every assignment of a value to

x, is_hungry'(x) is true.

Page 22: Slides adapted from

Fall 2013 Frank / van Deemter / Wyner 22

Models and Evaluation (informal)

• Questions:– Are x is_hungry'(x) and z is_hungry'(z) equivalent

(true/false in the same models)? So, does the selection of variable matter?

– Are x is_happy'(x) and z is_happy'(z) equivalent?– Does x is_hungry'(x) entail z is_hungry'(z)?– Are is_happy'(bill') and is_happy'(mary') equivalent?– Are is_happy'(x) and is_happy'(z) equivalent?– x is_happy'(x) and x is_hungry'(x) relate variables?

Page 23: Slides adapted from

Fall 2013 Frank / van Deemter / Wyner 23

Formal SyntaxVariables, Constants, Predicates

• Variable: x,y,z,… Constants: a,b,c,…• 1-place predicates: P,Q,…• 2-place predicates: R,S,…• 3-place, ... , n-place predicates: so on...

Page 24: Slides adapted from

Fall 2013 Frank / van Deemter / Wyner 24

Formal SyntaxAtomic Formulae

Atomic formulas:• If is a 1-place predicate and a variable or

constant then () is an atomic formula.• If is a 2-place predicate and and are

variables or constants then (,) is an atomic formula.

• And so on for 3-place, etc.

Page 25: Slides adapted from

Fall 2013 Frank / van Deemter / Wyner 25

Formal SyntaxWell-formed Formulas

(Well-formed) Formulas:• All atomic formulas are formulas.• If and are formulas then , ( ), ( ),

( ) are formulas.• If is a formula then x and y are

formulas.• Lots of comments to make about quantified well-

formed formulas – variable binding, vacuous quantification, nested quantifiers...

Page 26: Slides adapted from

Fall 2013 Frank / van Deemter / Wyner 26

SyntaxQuantified Expressions

• Some well-formed expressions: xP(x) yQ(x) xy R(x,y) xP(b)• P(x) is a (atomic) formula, hence xP(x) is a formula• Q(x) is a (atomic) formula, hence yQ(x) is a formula• R(x,y) is a (atomic) formula, hence y R(x,y) is a

formula, hence xy R(x,y) is a formula (nested quantifiers)

• P(b) is a (atomic) formula, hence xP(b) is a formula (vacuous quantification).

Page 27: Slides adapted from

Fall 2013 Frank / van Deemter / Wyner 27

Formal SemanticsModel

• A model M is an ordered pair <D,I>, where D is a set of entities, and I is an interpretation function. M defines gives a specific ‘meaning’ to the non-logical symbols (logical symbols are ).

• If a is an individual constant then I(a) D. Assume for every entity in D there is a constant.

• If P is a 1-place predicate then I(P) D • If R is a 2-place predicate, then

I(R) {(,): D and D}• So on for 3-place predicates etc.

Page 28: Slides adapted from

Fall 2013 Frank / van Deemter / Wyner 28

An Example of a Model

• Suppose M = (D,I) where D={bill, jill, mary}• I(john') = john, I(mary') = mary, I(bill') = bill;

I(B)={bill, jill}I(G)={mary}I(A)={(bill, jill) , (mary,bill)}

• Note: bill is a person (i.e., a part of the world)bill' is an individual constant (i.e., a part of the language of predicate logic). In a sentence, we would use the proper name "Bill".

Page 29: Slides adapted from

Fall 2013 Frank / van Deemter / Wyner 29

Formal SemanticsTruth Definition

Given a formula and a model, we want a systematic way to calculate whether (or not) the formula is true (or false) with respect to the model.

The Truth Definitions are of the form formula is true iff....

Page 30: Slides adapted from

Fall 2013 Frank / van Deemter / Wyner 30

Formal SemanticsTruth of Predicate Formulae

• A formula of the form P(a) is true with respect to M iff I(a) I(P).

• A formula of the form R(a,b) is true with respect to M iff (I(a),I(b)) I(R).

Page 31: Slides adapted from

Fall 2013 Frank / van Deemter / Wyner 31

Formal SemanticsTruth for Functional Connectives

• A formula of the form is true wrt M iff is false wrt M.

• A formula of the form is true wrt M iff is true wrt M or is true wrt M or both.

• A formula of the form is true wrt M iff is true wrt M and is true wrt M.

• A formula of the form is true wrt M iff is false wrt M or is true wrt M.

Recall the Truth Tables

Page 32: Slides adapted from

Fall 2013 Frank / van Deemter / Wyner 32

Formal SemanticsTruth with Variables and Quantifiers

• Notation: where is a formula, (x:=a) is the result of substituting all free occurrences of the variable x in by the constant a.

• More to say about 'free occurrences'.• A formula of the form x is true wrt M iff there

is an I(a) D such that (x:=a) is true wrt M.• A formula of the form x is true wrt M iff for

every I(a) D, (x:=a) is true wrt M.

Page 33: Slides adapted from

Fall 2013 Frank / van Deemter / Wyner 33

Examples - Simple

• Suppose M = (D,I) where D={bill, jill, mary}I(jill') = jill, I(mary') = mary, I(bill') = bill,I(B)={bill, jill}I(G)={mary}I(A)={(bill, jill) , (mary,bill)}

• Is B(jill') true in M?• Is A(mary',bill') true in M?• Is A(jill',bill') true in M?

Page 34: Slides adapted from

Fall 2013 Frank / van Deemter / Wyner 34

Examples - Connectives

• Suppose M = (D,I) where D={bill, jill, mary}I(jill') = jill, I(mary') = mary, I(bill') = bill,I(B)={bill, jill}I(G)={mary}I(A)={(bill, jill) , (mary,bill)}

• Is [B(jill') G(bill')] true in M?• Is [A(mary',bill') G(mary')] true in M?

Page 35: Slides adapted from

Fall 2013 Frank / van Deemter / Wyner 35

Examples - Quantifiers

• Suppose M = (D,I) where D={bill, jill, mary}I(jill') = jill, I(mary') = mary, I(bill') = bill,I(B)={bill, jill}I(G)={mary}I(A)={(bill, jill) , (mary,bill)}

• Is y B(y) true in M?• Is y [B(y) G(y)] true in M?• Is y [B(y) A(y,bill')] true in M?

Page 36: Slides adapted from

Fall 2013 Frank / van Deemter / Wyner 36

Examples - Quantifiers

• Suppose M = (D,I) where D={bill, jill, mary}I(jill') = jill, I(mary') = mary, I(bill') = bill,I(B)={bill, jill}I(G)={mary}I(A)={(bill, jill), (mary,bill), (jill, jill)}

• Is y B(y) true in M?• Is y [B(y) G(y)] true in M?• Is y [B(y) A(y,bill')] true in M?• Is x [B(x) A(x,jill)] true in M?

Page 37: Slides adapted from

Fall 2013 Frank / van Deemter / Wyner 37

Next

• Work thorough examples• Bound and free variables• Complex expressions (quantifiers with logical connectives;

nested quantifiers)• Quantifier equivalences• Vacuous quantification and false antecedents• Defining (or not) other quantifiers• Other