Predicate Logic Jason Filippou CMSC250 @ UMCP 06-06-2016 Jason - - PowerPoint PPT Presentation

predicate logic
SMART_READER_LITE
LIVE PREVIEW

Predicate Logic Jason Filippou CMSC250 @ UMCP 06-06-2016 Jason - - PowerPoint PPT Presentation

Predicate Logic Jason Filippou CMSC250 @ UMCP 06-06-2016 Jason Filippou (CMSC250 @ UMCP) Predicates 06-06-2016 1 / 42 Outline 1 Propositional logic falls short 2 Predicate Logic Syntax Semantics Proof theory Jason Filippou (CMSC250 @


slide-1
SLIDE 1

Predicate Logic

Jason Filippou

CMSC250 @ UMCP

06-06-2016

Jason Filippou (CMSC250 @ UMCP) Predicates 06-06-2016 1 / 42

slide-2
SLIDE 2

Outline

1 Propositional logic falls short 2 Predicate Logic

Syntax Semantics Proof theory

Jason Filippou (CMSC250 @ UMCP) Predicates 06-06-2016 2 / 42

slide-3
SLIDE 3

Propositional logic falls short

Propositional logic falls short

Jason Filippou (CMSC250 @ UMCP) Predicates 06-06-2016 3 / 42

slide-4
SLIDE 4

Propositional logic falls short

Modelling worlds

The goal of logic has, is, and will be to model domain knowledge about the world, and make certain inferences, based on a certain theory of proof. So, for every scenario, we have an agreement on what our world is.

E.g CSIC, CS department, State of Maryland

Consider how the world affects the truth value of certain propositional logic statements!

freshman ∨ sophomore ∨ junior ∨ senior motorcycle ∧ red light ⇒ wait for green

Jason Filippou (CMSC250 @ UMCP) Predicates 06-06-2016 4 / 42

slide-5
SLIDE 5

Propositional logic falls short

Semantic simplicity of propositional symbols

Suppose we already have the propositional symbol charlie. How do we express the fact that Charlie is a unicorn?

Jason Filippou (CMSC250 @ UMCP) Predicates 06-06-2016 5 / 42

slide-6
SLIDE 6

Propositional logic falls short

Semantic simplicity of propositional symbols

Suppose we already have the propositional symbol charlie. How do we express the fact that Charlie is a unicorn?

1 Insert a new symbol, charlie the unicorn, retract (?) symbol

charlie.

2 Insert rule charlie ∧ horned charlie ⇒ charlie the unicorn and the

symbol horned charlie, use modus ponens.

What about the pink and gray unicorns?

Jason Filippou (CMSC250 @ UMCP) Predicates 06-06-2016 5 / 42

slide-7
SLIDE 7

Propositional logic falls short

Semantic simplicity of propositional symbols

Manually curated knowledge is time-consuming, error-prone, and sometimes contradicting.

Stable modeling example (whiteboard).

Beats the point of inference rules: Why did we even come up with the automated construction of new knowledge if we end up putting stuff in ourselves?

Jason Filippou (CMSC250 @ UMCP) Predicates 06-06-2016 6 / 42

slide-8
SLIDE 8

Propositional logic falls short

Semantic simplicity of propositional symbols

Modeling properties of an element of our world is virtually impossible in propositional logic. For every object in our world, we need to replicate every property! (whiteboard) How do we relate objects to one another? E.g siblings, coworkers,...

Jason Filippou (CMSC250 @ UMCP) Predicates 06-06-2016 7 / 42

slide-9
SLIDE 9

Propositional logic falls short

The need for more symbols

How can I write a statement that says “Every CS250 student will sit for a midterm”?

Need a symbol to express the notion of “every item x that satisfies some property P”...

How about “There’s at least two people in this classroom who share a birth month?”

Jason Filippou (CMSC250 @ UMCP) Predicates 06-06-2016 8 / 42

slide-10
SLIDE 10

Propositional logic falls short

Propositional Logic is not enough...

Expressiveness - tractability trade-off.

Jason Filippou (CMSC250 @ UMCP) Predicates 06-06-2016 9 / 42

slide-11
SLIDE 11

Propositional logic falls short

Propositional Logic is not enough...

Expressiveness - tractability trade-off.

Tracta-what?

Propositional logic is the most basic kind of logic. Excellent for:

Modeling hardware (boolean gates). The study of computational complexity (SAT problem).

Not-so-excellent for:

Translating language into computer-readable format. Building deductive databases. Efficient inference on large domains.

The next-step: First-Order logic!

Jason Filippou (CMSC250 @ UMCP) Predicates 06-06-2016 9 / 42

slide-12
SLIDE 12

Propositional logic falls short

Propositional Logic is not enough...

Expressiveness - tractability trade-off.

Tracta-what?

Propositional logic is the most basic kind of logic. Excellent for:

Modeling hardware (boolean gates). The study of computational complexity (SAT problem).

Not-so-excellent for:

Translating language into computer-readable format. Building deductive databases. Efficient inference on large domains.

The next-step: First-Order logic!

Only we won’t do full FOL

Jason Filippou (CMSC250 @ UMCP) Predicates 06-06-2016 9 / 42

slide-13
SLIDE 13

Predicate Logic

Predicate Logic

Jason Filippou (CMSC250 @ UMCP) Predicates 06-06-2016 10 / 42

slide-14
SLIDE 14

Predicate Logic

What is predicate logic?

An extension of propositional logic we have come up with.

A subset of FOL suitable for introducing formal proofs.

“The logic of quantified statements” is another suitable characterization (Epp).

Jason Filippou (CMSC250 @ UMCP) Predicates 06-06-2016 11 / 42

slide-15
SLIDE 15

Predicate Logic

A hierarchy of logics

Propositional Logic First- Order Logic Second-Order Logic Type Theory Infinitary Logic

Jason Filippou (CMSC250 @ UMCP) Predicates 06-06-2016 12 / 42

slide-16
SLIDE 16

Predicate Logic

A hierarchy of logics

Propositional Logic First- Order Logic

Predicates, quantifiers, functors, backward / forward chaning, undecidability of inference

Second-Order Logic Type Theory Infinitary Logic

Jason Filippou (CMSC250 @ UMCP) Predicates 06-06-2016 13 / 42

slide-17
SLIDE 17

Predicate Logic

A hierarchy of logics

Only aspects

  • f FOL

included in “Predicate Logic”.

Propositional Logic First- Order Logic

Predicates, quantifiers, functors, backward / forward chaning, undecidability of inference

Second-Order Logic Type Theory Infinitary Logic

Jason Filippou (CMSC250 @ UMCP) Predicates 06-06-2016 14 / 42

slide-18
SLIDE 18

Predicate Logic Syntax

Syntax

Jason Filippou (CMSC250 @ UMCP) Predicates 06-06-2016 15 / 42

slide-19
SLIDE 19

Predicate Logic Syntax

Variables and Constants

Our syntax has some crucial additions over Propositional Logic. Variables (denoted lowercase) and their (sometimes implicit)

  • domains. E.g:

E.g x ∈ R (Dom(c) = R) E.g c, with Dom(c) = {green, red, blue}

Constants (denoted uppercase): Unique identifiers of objects in

  • ur database (similar to Propositional Logic’s “propositional

symbols”).

Sun, Earth, Benedict Cumberbatch, Jason Filippou

Jason Filippou (CMSC250 @ UMCP) Predicates 06-06-2016 16 / 42

slide-20
SLIDE 20

Predicate Logic Syntax

Predicates

Predicate Symbols: typically used to denote properties of

  • bjects, like adverbs or adjectives in language.

Written with uppercase first letter: P, Q, Father, Rainy

Predicates (denoted uppercase): consist of a predicate symbol followed by at least one constant and variable as an “argument” within parentheses. E.g:

Odd(x), Even(y), Father(q, r), with Dom(x) = Dom(y) = N, Dom(q) = {s | s is a MD resident under 18} and Dom(r) = {s | s is a male PA resident over 22}, King(Charlie, Bananas), Enrolled(x, CMSC 250), with Dom(x) = CS UMD Undergraduates.

Arity of a predicate: The number of its arguments.

We constrain predicates to have arity at least 1, otherwise (a) They make no sense and (b) They are undistinguishable from constants.

Jason Filippou (CMSC250 @ UMCP) Predicates 06-06-2016 17 / 42

slide-21
SLIDE 21

Predicate Logic Syntax

Quantifiers

The symbols “exists”: ∃ and “forall”: ∀, followed by at least one variable and one predicate.

(∃ x)(Prime(x)) (∀x)(Politician(x) ⇒ Liar(x))

Parentheses can be used to define the scope of a quantifier. When the scope is obvious, they can be ommitted (e.g above).

Jason Filippou (CMSC250 @ UMCP) Predicates 06-06-2016 18 / 42

slide-22
SLIDE 22

Predicate Logic Syntax

Quantifiers

The symbols “exists”: ∃ and “forall”: ∀, followed by at least one variable and one predicate.

(∃ x)(Prime(x)) (∀x)(Politician(x) ⇒ Liar(x))

Parentheses can be used to define the scope of a quantifier. When the scope is obvious, they can be ommitted (e.g above). Can I have more than 1 predicate on the right of a quantifier?

Jason Filippou (CMSC250 @ UMCP) Predicates 06-06-2016 18 / 42

slide-23
SLIDE 23

Predicate Logic Syntax

Quantified Statements

Absolutely! We will call those quantified statements, and they are somewhat equivalent to propositional logic’s “compound statements”

1 Existential statements follow ∃. 2 Universal statements follow ∀. 3 Mixed statements follow both:

(∀x)(Person(x) ⇒ (∃z)(Loves(z, x))). (∀p1, p2 ∈ R2)(∃p3 ∈ R2)dist(p3, p1) = dist(p3, p2) (∀q)(Prime(q) ⇒ (∃p)(Prime(p) ∧ p > q))

We can also have regular, non-quantified statements that involve constants instead of variables (ground statements), or statements that involve both:

Hates(Jason, Artichokes) ∧ Hates(Jason, Brussel Sprouts), Form Triangle(P1, P2, P3) ∨ Colinear(P1, P2, P3) (∀x)(Lives(x, North America) ⇔ Lives(x, Canada) ∨ Lives(x, USA) ∨ Lives(x, Mexico))

Jason Filippou (CMSC250 @ UMCP) Predicates 06-06-2016 19 / 42

slide-24
SLIDE 24

Predicate Logic Syntax

Bound / Free variables in statements

Bound variable: A variable that is quantified. E.g:

(∃z) Unicorn(z) ∧ Nuts(z) (∀x, y ∈ N)Divides(x, y) ⇔ (∃z ∈ N)y = x ∗ z

Free variable: A variable that isn’t bound. E.g:

(∀x)P(x, y) (∃z)(R(z, s) ∨ Q(z)) ⇒ F(z) Q(x) ⇒ (∀x)Q(x)

Use parentheses when necessary! Sentence: A quantified statement with only bound variables.

Jason Filippou (CMSC250 @ UMCP) Predicates 06-06-2016 20 / 42

slide-25
SLIDE 25

Predicate Logic Semantics

Semantics

Jason Filippou (CMSC250 @ UMCP) Predicates 06-06-2016 21 / 42

slide-26
SLIDE 26

Predicate Logic Semantics

Knowledge Bases / Grounding

Knowledge base (KB): A set of ground (variable-free) predicates1 that represent what we know about the world. Grounding: The substitution of variables in quantified statements with constants corresponding to predicate arguments.

Groundings can be true or false with respect to the KB.

Closed world assumption: Anything not mentioned in our knowledge base is assumed to be false!

1We technically call those ground atoms. Jason Filippou (CMSC250 @ UMCP) Predicates 06-06-2016 22 / 42

slide-27
SLIDE 27

Predicate Logic Semantics

Predicate truth

Semantics in Predicate Logic will be tied to the notion of the truth

  • f a - possibly quantified - statement.

Ground statement: Similar to propositional logic. Consists of a non-quantified statement that can be either true or false given

  • ur knowledge base.

Sentence: Have to introduce the notions of universal and existential instantiation / generalization.

Jason Filippou (CMSC250 @ UMCP) Predicates 06-06-2016 23 / 42

slide-28
SLIDE 28

Predicate Logic Semantics

Universal instantiation

Rule of Universal Instantiation (∀x ∈ D)P(x) ∴ P(A) for any particular A ∈ D

Jason Filippou (CMSC250 @ UMCP) Predicates 06-06-2016 24 / 42

slide-29
SLIDE 29

Predicate Logic Semantics

Universal instantiation

Rule of Universal Instantiation (∀x ∈ D)P(x) ∴ P(A) for any particular A ∈ D Examples: (∀x ∈ R) x2 ≥ 0 (∀p ∈ UMD Undergrads) Smart(p)

Jason Filippou (CMSC250 @ UMCP) Predicates 06-06-2016 24 / 42

slide-30
SLIDE 30

Predicate Logic Semantics

Existential instantiation

Rule of Existential instantiation (∃x ∈ D)P(x) ∴ P(A) for a specific A ∈ D Examples: (∃z ∈ Classroom) Name(z, Jason) (∃c ∈ USA) NameContains(y, “Truth”) ∧ NameContains(y, “Consequences”)

Jason Filippou (CMSC250 @ UMCP) Predicates 06-06-2016 25 / 42

slide-31
SLIDE 31

Predicate Logic Semantics

Existential instantiation

Rule of Existential instantiation (∃x ∈ D)P(x) ∴ P(A) for a specific A ∈ D Examples: (∃z ∈ Classroom) Name(z, Jason) (∃c ∈ USA) NameContains(y, “Truth”) ∧ NameContains(y, “Consequences”) Can I have more > 1 “A”’s?

Jason Filippou (CMSC250 @ UMCP) Predicates 06-06-2016 25 / 42

slide-32
SLIDE 32

Predicate Logic Semantics

Universal generalization

Rule of Universal Generalization P(A) for some A ∈ D selected arbitrarily. ∴ (∀x)P(x)

Jason Filippou (CMSC250 @ UMCP) Predicates 06-06-2016 26 / 42

slide-33
SLIDE 33

Predicate Logic Semantics

Universal generalization

Rule of Universal Generalization P(A) for some A ∈ D selected arbitrarily. ∴ (∀x)P(x) A is then often called the generic particular.

Jason Filippou (CMSC250 @ UMCP) Predicates 06-06-2016 26 / 42

slide-34
SLIDE 34

Predicate Logic Semantics

Universal generalization

Rule of Universal Generalization P(A) for some A ∈ D selected arbitrarily. ∴ (∀x)P(x) A is then often called the generic particular. Compare and contrast: Let A ∈ N Let A ∈ Neven . . . . . . P(A) P(A) ∴ (∀n ∈ N)P(n) ∴ (∀n ∈ N)P(n)

Jason Filippou (CMSC250 @ UMCP) Predicates 06-06-2016 26 / 42

slide-35
SLIDE 35

Predicate Logic Semantics

Existential generalization

Rule of existential generalization P(A) for any A ∈ D. ∴ (∃x)P(x) Good practice: Pay attention to the usages of “any” and “some”.

Jason Filippou (CMSC250 @ UMCP) Predicates 06-06-2016 27 / 42

slide-36
SLIDE 36

Predicate Logic Semantics

Modeling Example: Family tree

Jill Phil Steven Keegan Hailey Bailey Cathy Sarge Marge Wesley Lesley

Jason Filippou (CMSC250 @ UMCP) Predicates 06-06-2016 28 / 42

slide-37
SLIDE 37

Predicate Logic Semantics

Example: Family tree

Female(Marge) Male(Sarge) Female(Lesley) Male(Phil) Female(Jill) Male(Wesley) Female(Hailey) Male(Bailey) Female(Cathy) Male(Steven) Male(Keegan)

Jill Phil Steven Keegan Hailey Bailey Cathy Sarge Marge Wesley Lesley

Jason Filippou (CMSC250 @ UMCP) Predicates 06-06-2016 29 / 42

slide-38
SLIDE 38

Predicate Logic Semantics

Example: Family tree

Female(Marge) Male(Sarge) Couple(Marge, Sarge) Female(Lesley) Male(Phil) Couple(Lesley, Wesley) Female(Jill) Male(Wesley) Couple(Jill, Phil) Female(Hailey) Male(Bailey) Couple(Hailey, Bailey) Female(Cathy) Male(Steven) Male(Keegan)

Jill Phil Steven Keegan Hailey Bailey Cathy Sarge Marge Wesley Lesley

Jason Filippou (CMSC250 @ UMCP) Predicates 06-06-2016 30 / 42

slide-39
SLIDE 39

Predicate Logic Semantics

Example: Family tree

Female(Marge) Male(Sarge) Couple(Marge, Sarge) Female(Lesley) Male(Phil) Couple(Lesley, Wesley) Female(Jill) Male(Wesley) Couple(Jill, Phil) Female(Hailey) Male(Bailey) Couple(Hailey, Bailey) Female(Cathy) Male(Steven) Mother(Marge, Jill) Male(Keegan) Mother(Lesley, Phil) Mother(Lesley, Hailey) Mother(Jill, Steven) Mother(Jill, Keegan) Mother(Hailey, Cathy)

Jill Phil Steven Keegan Hailey Bailey Cathy Sarge Marge Wesley Lesley

Jason Filippou (CMSC250 @ UMCP) Predicates 06-06-2016 31 / 42

slide-40
SLIDE 40

Predicate Logic Semantics

Negated quantifiers

For variable set x and quantified statement P(x), the following hold: (∄x)P(x) ≡ (∀x) ∼P(x) (∃x)P(x) ≡ ∼(∀x)∼P(x) This applies recursively to nested quantifiers! (whiteboard examples)

Jason Filippou (CMSC250 @ UMCP) Predicates 06-06-2016 32 / 42

slide-41
SLIDE 41

Predicate Logic Semantics

Vacuous truth of quantified statements

Critique the following quantified statement: (∀x)(Marker(x) ∧ Location(x, WhiteBoard) ⇒ Blue(x)) What truth value would you attach to it?

Jason Filippou (CMSC250 @ UMCP) Predicates 06-06-2016 33 / 42

slide-42
SLIDE 42

Predicate Logic Proof theory

Proof theory

Jason Filippou (CMSC250 @ UMCP) Predicates 06-06-2016 34 / 42

slide-43
SLIDE 43

Predicate Logic Proof theory

Major and Minor premises

Major premise: A universally quantified implication, i.e of form (∀x) P(x) ⇒ Q(x) Minor premise: The association of an object with the domain of the quantified variable, i.e P(A) for some A. Conclusion: Q(A).

Jason Filippou (CMSC250 @ UMCP) Predicates 06-06-2016 35 / 42

slide-44
SLIDE 44

Predicate Logic Proof theory

Universal modus ponens

The quantified version of modus ponens. Universal Modus Ponens (∀x)P(x) ⇒ Q(x) P(A) for some A ∈ Dom(x) ∴ Q(A)

Jason Filippou (CMSC250 @ UMCP) Predicates 06-06-2016 36 / 42

slide-45
SLIDE 45

Predicate Logic Proof theory

Universal modus ponens

The quantified version of modus ponens. Universal Modus Ponens (∀x)P(x) ⇒ Q(x) P(A) for some A ∈ Dom(x) ∴ Q(A) Theorem Universal Modus Ponens is a valid rule of inference.

Jason Filippou (CMSC250 @ UMCP) Predicates 06-06-2016 36 / 42

slide-46
SLIDE 46

Predicate Logic Proof theory

Universal modus ponens

The quantified version of modus ponens. Universal Modus Ponens (∀x)P(x) ⇒ Q(x) P(A) for some A ∈ Dom(x) ∴ Q(A) Theorem Universal Modus Ponens is a valid rule of inference. Proof. Diagramatic (whiteboard)

Jason Filippou (CMSC250 @ UMCP) Predicates 06-06-2016 36 / 42

slide-47
SLIDE 47

Predicate Logic Proof theory

Universal modus tollens

Universal Modus Tollens (∀x)P(x) ⇒ Q(x)

∼Q(A) for some A ∈ Dom(x)

∴ ∼P(A)

Jason Filippou (CMSC250 @ UMCP) Predicates 06-06-2016 37 / 42

slide-48
SLIDE 48

Predicate Logic Proof theory

Quantified converse error

Quantified Converse Error (∀x)P(x) ⇒ Q(x) Q(A) for some A ∈ Dom(x) ∴ P(A)

Jason Filippou (CMSC250 @ UMCP) Predicates 06-06-2016 38 / 42

slide-49
SLIDE 49

Predicate Logic Proof theory

Quantified inverse error

Quantified inverse error (∀x)P(x) ⇒ Q(x)

∼P(A) for some A ∈ Dom(x)

∴ ∼Q(A)

Jason Filippou (CMSC250 @ UMCP) Predicates 06-06-2016 39 / 42

slide-50
SLIDE 50

Predicate Logic Proof theory

Complex inferences

Assume a simplified version of 250, called Mini250. 2 midterms, 1 final. We want to author rules that dictate when a student passes a course, and formally prove that a student called Trisha will, in fact, pass 250.

Jason Filippou (CMSC250 @ UMCP) Predicates 06-06-2016 40 / 42

slide-51
SLIDE 51

Predicate Logic Proof theory

Complex inferences

We will use the following predicates: Predicate Meaning Midterm(n, s, g) The grade of student s in midterm number n (1 or 2) was g (A, B or C). Final(s, g) The grade of student s in midterm in the final was g (A, B, or C). Present(s) Student s was consistently present in lecture. Studies(s, l) Student s studies in mode l (Lazily, Well or Hard) Passes(s, g) Student s passed the course with grade g. Fails(s) Student s failed the course.

Jason Filippou (CMSC250 @ UMCP) Predicates 06-06-2016 41 / 42

slide-52
SLIDE 52

Predicate Logic Proof theory

Complex inferences

Let’s translate the following statements into Predicate Logic:

1 Every student who studies hard will get As in both midterms and

at least a B in the final.

2 Any student who is consistently present in lecture will score at

least a B in both midterms and at least a C in the final.

3 One will pass the course if, and only if, one scores at least a C

in the final, and a C or B in either one of the two midterms.

4 Any student who studies well or hard will score at least a B in

both midterms and the final.

5 One cannot pass and fail the course at the same time. Jason Filippou (CMSC250 @ UMCP) Predicates 06-06-2016 42 / 42

slide-53
SLIDE 53

Predicate Logic Proof theory

Complex inferences

Let’s translate the following statements into Predicate Logic:

1 Every student who studies hard will get As in both midterms and

at least a B in the final.

2 Any student who is consistently present in lecture will score at

least a B in both midterms and at least a C in the final.

3 One will pass the course if, and only if, one scores at least a C

in the final, and a C or B in either one of the two midterms.

4 Any student who studies well or hard will score at least a B in

both midterms and the final.

5 One cannot pass and fail the course at the same time.

Now, assume that Trisha is a student who studies well and is consistently present in lecture. Prove that Trisha will pass the course (with any grade)

Jason Filippou (CMSC250 @ UMCP) Predicates 06-06-2016 42 / 42