83
Relational Logic

Relational Logiclogic.stanford.edu/intrologic/lectures/lecture_06.pdf · q(a,y) Relational sentences are not terms and cannot be nested in relational sentences. No! q(a,q(a,y)) No!

  • Upload
    others

  • View
    8

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Relational Logiclogic.stanford.edu/intrologic/lectures/lecture_06.pdf · q(a,y) Relational sentences are not terms and cannot be nested in relational sentences. No! q(a,q(a,y)) No!

Relational Logic

Page 2: Relational Logiclogic.stanford.edu/intrologic/lectures/lecture_06.pdf · q(a,y) Relational sentences are not terms and cannot be nested in relational sentences. No! q(a,q(a,y)) No!

Premises: If Jack knows Jill, then Jill knows Jack. Jack knows Jill.

Conclusion: Is it the case that Jill knows Jack?

Propositional Logic

Page 3: Relational Logiclogic.stanford.edu/intrologic/lectures/lecture_06.pdf · q(a,y) Relational sentences are not terms and cannot be nested in relational sentences. No! q(a,q(a,y)) No!

Premises: If one person knows another, then the second person knows the first. Jack knows Jill.

Conclusion: Is it the case that Jill knows Jack?

How do we represent the first premise in a way that allows us to derive the desired conclusion?

Problem

Page 4: Relational Logiclogic.stanford.edu/intrologic/lectures/lecture_06.pdf · q(a,y) Relational sentences are not terms and cannot be nested in relational sentences. No! q(a,q(a,y)) No!

New Linguistic Features: Variables Quantifiers

Sample Sentence:

∀x.∀y.(knows(x,y) ⇒ knows(y,x))

Relational Logic

Page 5: Relational Logiclogic.stanford.edu/intrologic/lectures/lecture_06.pdf · q(a,y) Relational sentences are not terms and cannot be nested in relational sentences. No! q(a,q(a,y)) No!

Syntax

Semantics

Examples, Examples, Examples

Properties of Sentences

Logical Entailment

Decidability

Programme

Page 6: Relational Logiclogic.stanford.edu/intrologic/lectures/lecture_06.pdf · q(a,y) Relational sentences are not terms and cannot be nested in relational sentences. No! q(a,q(a,y)) No!

Syntax

Page 7: Relational Logiclogic.stanford.edu/intrologic/lectures/lecture_06.pdf · q(a,y) Relational sentences are not terms and cannot be nested in relational sentences. No! q(a,q(a,y)) No!

Wordsa, b, g, p

Termsg(a,a)

Sentences∀x.(p(x) ⇒ p(x,g(x,x)))

Components of Language

Page 8: Relational Logiclogic.stanford.edu/intrologic/lectures/lecture_06.pdf · q(a,y) Relational sentences are not terms and cannot be nested in relational sentences. No! q(a,q(a,y)) No!

Words are strings of letters, digits, and occurrences of the underscore character.

Variables begin with characters from the end of the alphabet (from u through z).

u, v, w, x, y, z

Constants begin with digits or letters from the beginning of the alphabet (from a through t).

a, b, c, 123, comp225, barack_obama

Words

Page 9: Relational Logiclogic.stanford.edu/intrologic/lectures/lecture_06.pdf · q(a,y) Relational sentences are not terms and cannot be nested in relational sentences. No! q(a,q(a,y)) No!

Object constants represent objects.

joe, stanford, usa, 2345

Relation constants represent relations.

knows, loves

Constants

Page 10: Relational Logiclogic.stanford.edu/intrologic/lectures/lecture_06.pdf · q(a,y) Relational sentences are not terms and cannot be nested in relational sentences. No! q(a,q(a,y)) No!

The arity of a relation constant is the number of arguments it takes.

Unary relation constant - 1 argument

Binary relation constant - 2 arguments

Ternary relation constant - 3 arguments

n-ary relation constant - n arguments

Arity

Page 11: Relational Logiclogic.stanford.edu/intrologic/lectures/lecture_06.pdf · q(a,y) Relational sentences are not terms and cannot be nested in relational sentences. No! q(a,q(a,y)) No!

A signature consist of a set of object constants and a set of relation constants together with a specification of arity for the relation constants.

Object Constants: a, b

Unary Relation Constant: pBinary Relation Constant: q

Signatures

Page 12: Relational Logiclogic.stanford.edu/intrologic/lectures/lecture_06.pdf · q(a,y) Relational sentences are not terms and cannot be nested in relational sentences. No! q(a,q(a,y)) No!

A term is either a variable or an object constant,.

Terms represent objects.

Terms are analogous to noun phrases in natural language.

Terms

Page 13: Relational Logiclogic.stanford.edu/intrologic/lectures/lecture_06.pdf · q(a,y) Relational sentences are not terms and cannot be nested in relational sentences. No! q(a,q(a,y)) No!

Three types of sentences in Relational Logic:

Relational sentences - analogous to the simple sentences in natural language

Logical sentences - analogous to the logical sentences in natural language

Quantified sentences - sentences that express the significance of variables

Sentences

Page 14: Relational Logiclogic.stanford.edu/intrologic/lectures/lecture_06.pdf · q(a,y) Relational sentences are not terms and cannot be nested in relational sentences. No! q(a,q(a,y)) No!

A relational sentence is an expression formed from an n-ary relation constant and n terms enclosed in parentheses and separated by commas.

q(a,y)

Relational sentences are not terms and cannot be nested in relational sentences.

No! q(a,q(a,y)) No!

Relational Sentences

Page 15: Relational Logiclogic.stanford.edu/intrologic/lectures/lecture_06.pdf · q(a,y) Relational sentences are not terms and cannot be nested in relational sentences. No! q(a,q(a,y)) No!

Logical sentences in Herbrand Logic are analogous to those in Propositional Logic.

(¬q(a,b))(p(a) ∧ p(b))(p(a) ∨ p(b))(q(x,y) ⇒ q(y,x))(q(x,y) ⇔ q(y,x))

Logical Sentences

Page 16: Relational Logiclogic.stanford.edu/intrologic/lectures/lecture_06.pdf · q(a,y) Relational sentences are not terms and cannot be nested in relational sentences. No! q(a,q(a,y)) No!

Universal sentences assert facts about all objects.

(∀x.(p(x) ⇒ q(x,x)))

Existential sentence assert the existence of objects with given properties.

(∃x.(p(x) ∧ q(x,x)))

Quantified sentences can be nested within other sentences.

(∀x.p(x)) ∨ (∃x.q(x,x))(∀x.(∃y.q(x,y)))

Quantified Sentences

Page 17: Relational Logiclogic.stanford.edu/intrologic/lectures/lecture_06.pdf · q(a,y) Relational sentences are not terms and cannot be nested in relational sentences. No! q(a,q(a,y)) No!

Parentheses can be removed when precedence allows us to reconstruct sentences correctly.

Precedence relations same as in Propositional Logic with quantifiers being of higher precedence than logical operators.

∀x.p(x) ⇒ q(x,x) → (∀x.p(x)) ⇒ q(x,x)∃x.p(x) ∧ q(x,x) → (∃x.p(x)) ∧ q(x,x)

Parentheses

Page 18: Relational Logiclogic.stanford.edu/intrologic/lectures/lecture_06.pdf · q(a,y) Relational sentences are not terms and cannot be nested in relational sentences. No! q(a,q(a,y)) No!

An expression is ground if and only if it contains no variables.

Ground sentence:p(a)

Non-Ground Sentence:∀x.p(x)

Ground and Non-Ground Expressions

Page 19: Relational Logiclogic.stanford.edu/intrologic/lectures/lecture_06.pdf · q(a,y) Relational sentences are not terms and cannot be nested in relational sentences. No! q(a,q(a,y)) No!

An occurrence of a variable is bound if and only if it lies in the scope of a quantifier of that variable. Otherwise, it is free.

∃y.q(x,y)

In this example, x is free and y is bound.

Bound and Free Variables

Page 20: Relational Logiclogic.stanford.edu/intrologic/lectures/lecture_06.pdf · q(a,y) Relational sentences are not terms and cannot be nested in relational sentences. No! q(a,q(a,y)) No!

A sentence is open if and only if it has free variables. Otherwise, it is closed.

Open sentence:∃y.q(x,y)

Closed Sentence:∀x.∃y.q(x,y)

Open and Closed Sentences

Page 21: Relational Logiclogic.stanford.edu/intrologic/lectures/lecture_06.pdf · q(a,y) Relational sentences are not terms and cannot be nested in relational sentences. No! q(a,q(a,y)) No!

Semantics

Page 22: Relational Logiclogic.stanford.edu/intrologic/lectures/lecture_06.pdf · q(a,y) Relational sentences are not terms and cannot be nested in relational sentences. No! q(a,q(a,y)) No!

The Herbrand base for a Relational language is the set of all ground relational sentences that can be formed from the vocabulary of the language.

Herbrand Base

Page 23: Relational Logiclogic.stanford.edu/intrologic/lectures/lecture_06.pdf · q(a,y) Relational sentences are not terms and cannot be nested in relational sentences. No! q(a,q(a,y)) No!

Object Constants: a, bUnary Relation Constant: pBinary Relation Constant: q

Herbrand Base:

{p(a), p(b), q(a,a), q(a,b), q(b,a), q(b,b)}

Example

Page 24: Relational Logiclogic.stanford.edu/intrologic/lectures/lecture_06.pdf · q(a,y) Relational sentences are not terms and cannot be nested in relational sentences. No! q(a,q(a,y)) No!

A truth assignment is an association between ground atomic sentences and the truth values true or false. As with Propositional Logic, we use 1 as a synonym for true and 0 as a synonym for false.

p(a)i = 1 p(b)i = 0 q(a,a)i = 1 q(a,b)i = 0 q(b,a)i = 1 q(b,b)i = 0

Truth Assignment

Page 25: Relational Logiclogic.stanford.edu/intrologic/lectures/lecture_06.pdf · q(a,y) Relational sentences are not terms and cannot be nested in relational sentences. No! q(a,q(a,y)) No!

A sentential truth assignment is an association between arbitrary sentences in a Herbrand language and the truth values 1 and 0.

Truth Assignment Sentential Truth Assignmentp(a)i = 1 (p(a) ∨ p(b))i = 1p(b)i = 0 (p(a) ∧ ¬p(b))i = 1

Each base truth assignment leads to a particular sentential truth assignment based on the type of sentence.

Sentential Truth Assignment

Page 26: Relational Logiclogic.stanford.edu/intrologic/lectures/lecture_06.pdf · q(a,y) Relational sentences are not terms and cannot be nested in relational sentences. No! q(a,q(a,y)) No!

(¬ϕ)i = 1 if and only if ϕi = 0

(ϕ ∧ ψ)i = 1 if and only if ϕi = 1 and ψi = 1

(ϕ ∨ ψ)i = 1 if and only if ϕ i = 1 or ψi = 1

(ϕ ⇒ ψ)i = 1 if and only if ϕi = 0 or ψi = 1

(ϕ ⇔ ψ)i = 1 if and only if ϕi = ψi

Logical Sentences

Page 27: Relational Logiclogic.stanford.edu/intrologic/lectures/lecture_06.pdf · q(a,y) Relational sentences are not terms and cannot be nested in relational sentences. No! q(a,q(a,y)) No!

An instance of an expression is an expression in which all free variables have been consistently replaced by ground terms.

Consistent replacement here means that, if one occurrence of a variable is replaced by a ground term, then all occurrences of that variable are replaced by the same ground term.

Instances

Page 28: Relational Logiclogic.stanford.edu/intrologic/lectures/lecture_06.pdf · q(a,y) Relational sentences are not terms and cannot be nested in relational sentences. No! q(a,q(a,y)) No!

A universally quantified sentence is true for a truth assignment if and only if every instance of the scope of the quantified sentence is true for that assignment.

An existentially quantified sentence is true for a truth assignment if and only if some instance of the scope of the quantified sentence is true for that assignment.

Quantified Sentences

Page 29: Relational Logiclogic.stanford.edu/intrologic/lectures/lecture_06.pdf · q(a,y) Relational sentences are not terms and cannot be nested in relational sentences. No! q(a,q(a,y)) No!

Truth Assignment:p(a)i = 1 q(a,a)i = 1p(b)i = 0 q(a,b)i = 0

q(b,a)i = 1 q(b,b)i = 0

Sentence:∀x.(p(x) ⇒ q(x,x))

Instances:p(a) ⇒ q(a,a)p(b) ⇒ q(b,b)

Example

Page 30: Relational Logiclogic.stanford.edu/intrologic/lectures/lecture_06.pdf · q(a,y) Relational sentences are not terms and cannot be nested in relational sentences. No! q(a,q(a,y)) No!

Truth Assignment:p(a)i = 1 q(a,a)i = 1p(b)i = 0 q(a,b)i = 0

q(b,a)i = 1 q(b,b)i = 0

Sentence:∀x.(p(x) ⇒ q(x,x))

Instances:p(a) ⇒ q(a,a) √p(b) ⇒ q(b,b)

Example

Page 31: Relational Logiclogic.stanford.edu/intrologic/lectures/lecture_06.pdf · q(a,y) Relational sentences are not terms and cannot be nested in relational sentences. No! q(a,q(a,y)) No!

Truth Assignment:p(a)i = 1 q(a,a)i = 1p(b)i = 0 q(a,b)i = 0

q(b,a)i = 1 q(b,b)i = 0

Sentence:∀x.(p(x) ⇒ q(x,x))

Instances:p(a) ⇒ q(a,a) √p(b) ⇒ q(b,b) √

Example

Page 32: Relational Logiclogic.stanford.edu/intrologic/lectures/lecture_06.pdf · q(a,y) Relational sentences are not terms and cannot be nested in relational sentences. No! q(a,q(a,y)) No!

Truth Assignment:p(a)i = 1 q(a,a)i = 1p(b)i = 0 q(a,b)i = 0

q(b,a)i = 1 q(b,b)i = 0

Sentence:∀x.(p(x) ⇒ q(x,x)) √

Instances:p(a) ⇒ q(a,a) √p(b) ⇒ q(b,b) √

Example

Page 33: Relational Logiclogic.stanford.edu/intrologic/lectures/lecture_06.pdf · q(a,y) Relational sentences are not terms and cannot be nested in relational sentences. No! q(a,q(a,y)) No!

Truth Assignment:p(a)i = 1 q(a,a)i = 1p(b)i = 0 q(a,b)i = 0

q(b,a)i = 1 q(b,b)i = 0

Sentence:∀x.∃y.q(x,y)

Instances: ∃y.q(a,y) ∃y.q(b,y)

q(a,a) q(b,a) q(a,b) q(b,b)

Example

Page 34: Relational Logiclogic.stanford.edu/intrologic/lectures/lecture_06.pdf · q(a,y) Relational sentences are not terms and cannot be nested in relational sentences. No! q(a,q(a,y)) No!

A truth assignment satisfies a sentence with free variables if and only if it satisfies every instance of that sentence. (In other words, we can think of all free variables as being universally quantified.)

(∃y.q(x,y))i = (∀x.∃y.q(x,y))i

A truth assignment satisfies a set of sentences if and only if it satisfies every sentence in the set.

Open Sentences

Page 35: Relational Logiclogic.stanford.edu/intrologic/lectures/lecture_06.pdf · q(a,y) Relational sentences are not terms and cannot be nested in relational sentences. No! q(a,q(a,y)) No!

Example - Sorority World

Page 36: Relational Logiclogic.stanford.edu/intrologic/lectures/lecture_06.pdf · q(a,y) Relational sentences are not terms and cannot be nested in relational sentences. No! q(a,q(a,y)) No!

Sorority World

Page 37: Relational Logiclogic.stanford.edu/intrologic/lectures/lecture_06.pdf · q(a,y) Relational sentences are not terms and cannot be nested in relational sentences. No! q(a,q(a,y)) No!

Object Constants: abby, bess, cody, dana

Binary Relation Constant: likes

Herbrand base has 16 ground relational sentences.

Signature

Page 38: Relational Logiclogic.stanford.edu/intrologic/lectures/lecture_06.pdf · q(a,y) Relational sentences are not terms and cannot be nested in relational sentences. No! q(a,q(a,y)) No!

¬likes(abby,abby) ¬likes(bess,abby)¬likes(abby,bess ¬likes(bess,bess) likes(abby,cody) likes(bess,cody)¬likes(abby,dana) ¬likes(bess,dana)

likes(cody,abby) ¬likes(dana,abby) likes(cody,bess) ¬likes(dana,bess)¬likes(cody,cody) likes(dana,cody) likes(cody,dana) ¬likes(dana,dana)

Data

Page 39: Relational Logiclogic.stanford.edu/intrologic/lectures/lecture_06.pdf · q(a,y) Relational sentences are not terms and cannot be nested in relational sentences. No! q(a,q(a,y)) No!

Abby likes everyone Bess likes.If Bess likes a girl, then Abby also likes her.

∀y.(likes(bess,y) ⇒ likes(abby,y))

Cody likes everyone who likes her.If some girl likes Cody, then Cody likes that girl.

∀x.(likes(x,cody) ⇒ likes(cody,x))

Sentences

Page 40: Relational Logiclogic.stanford.edu/intrologic/lectures/lecture_06.pdf · q(a,y) Relational sentences are not terms and cannot be nested in relational sentences. No! q(a,q(a,y)) No!

Cody likes somebody who likes her.There is someone who likes cody and is liked by Cody.

∃y.(likes(cody,y) ∧ likes(y,cody))

Nobody likes herself.It is not the case that someone likes herself.

¬∃x.likes(x,x)

Sentences

Page 41: Relational Logiclogic.stanford.edu/intrologic/lectures/lecture_06.pdf · q(a,y) Relational sentences are not terms and cannot be nested in relational sentences. No! q(a,q(a,y)) No!

Everybody likes somebody.

∀x.∃y.likes(x,y)

There is somebody whom everybody likes.

∃y.∀x.likes(x,y)

Sentences

Page 42: Relational Logiclogic.stanford.edu/intrologic/lectures/lecture_06.pdf · q(a,y) Relational sentences are not terms and cannot be nested in relational sentences. No! q(a,q(a,y)) No!

Abby Bess

Cody Dana

Example

Page 43: Relational Logiclogic.stanford.edu/intrologic/lectures/lecture_06.pdf · q(a,y) Relational sentences are not terms and cannot be nested in relational sentences. No! q(a,q(a,y)) No!

Abby Bess

Cody Dana

Everybody Likes Somebody

Page 44: Relational Logiclogic.stanford.edu/intrologic/lectures/lecture_06.pdf · q(a,y) Relational sentences are not terms and cannot be nested in relational sentences. No! q(a,q(a,y)) No!

Abby Bess

Cody Dana

Everybody Likes Somebody

Page 45: Relational Logiclogic.stanford.edu/intrologic/lectures/lecture_06.pdf · q(a,y) Relational sentences are not terms and cannot be nested in relational sentences. No! q(a,q(a,y)) No!

Abby Bess

Cody Dana

Everybody Likes Somebody

Page 46: Relational Logiclogic.stanford.edu/intrologic/lectures/lecture_06.pdf · q(a,y) Relational sentences are not terms and cannot be nested in relational sentences. No! q(a,q(a,y)) No!

Abby Bess

Cody Dana

Everybody Likes Somebody

Page 47: Relational Logiclogic.stanford.edu/intrologic/lectures/lecture_06.pdf · q(a,y) Relational sentences are not terms and cannot be nested in relational sentences. No! q(a,q(a,y)) No!

Abby Bess

Cody Dana

Everybody Likes Somebody

Page 48: Relational Logiclogic.stanford.edu/intrologic/lectures/lecture_06.pdf · q(a,y) Relational sentences are not terms and cannot be nested in relational sentences. No! q(a,q(a,y)) No!

Abby Bess

Cody Dana

There is Somebody Whom Everyone Likes

Page 49: Relational Logiclogic.stanford.edu/intrologic/lectures/lecture_06.pdf · q(a,y) Relational sentences are not terms and cannot be nested in relational sentences. No! q(a,q(a,y)) No!

Example - Blocks World

Page 50: Relational Logiclogic.stanford.edu/intrologic/lectures/lecture_06.pdf · q(a,y) Relational sentences are not terms and cannot be nested in relational sentences. No! q(a,q(a,y)) No!

Blocks World

Page 51: Relational Logiclogic.stanford.edu/intrologic/lectures/lecture_06.pdf · q(a,y) Relational sentences are not terms and cannot be nested in relational sentences. No! q(a,q(a,y)) No!

Object Constants: a, b, c, d, e

Unary Relation Constants: clear - blocks with no blocks on top. table - blocks on the table.

Binary Relation Constants: on - pairs of blocks in which first is on the second. above - pairs in which first block is above the second.

Ternary Relation Constant: stack - triples of blocks arranged in a stack.

Signature

Page 52: Relational Logiclogic.stanford.edu/intrologic/lectures/lecture_06.pdf · q(a,y) Relational sentences are not terms and cannot be nested in relational sentences. No! q(a,q(a,y)) No!

¬on(a,a) ¬on(b,a) ¬on(c,a) on(a,b) ¬on(b,b) ¬on(c,b)¬on(a,c) on(b,c) ¬on(c,c)¬on(a,d) ¬on(b,d) ¬on(c,d)¬on(a,e) ¬on(b,e) ¬on(c,e)

¬on(d,a) ¬on(e,a) ¬on(d,b) ¬on(e,b) ¬on(d,c) ¬on(e,c) ¬on(d,d) ¬on(e,d) on(d,e) ¬on(e,e)

Data

Page 53: Relational Logiclogic.stanford.edu/intrologic/lectures/lecture_06.pdf · q(a,y) Relational sentences are not terms and cannot be nested in relational sentences. No! q(a,q(a,y)) No!

Definition of clear:

∀y.(clear(y) ⇔ ¬∃x.on(x,y))

Definition of table:

∀x.(table(x) ⇔ ¬∃y.on(x,y))

Definitions

Page 54: Relational Logiclogic.stanford.edu/intrologic/lectures/lecture_06.pdf · q(a,y) Relational sentences are not terms and cannot be nested in relational sentences. No! q(a,q(a,y)) No!

Definition of stack:

∀x.∀y.∀z.(stack(x,y,z) ⇔ on(x,y) ∧ on(y,z))

Definition of above:

∀x.∀z.(above(x,z) ⇔ on(x,z) ∨ ∃y.(on(x,y) ∧ above(y,z)))

∀x.¬above(x,x)

Definitions

Page 55: Relational Logiclogic.stanford.edu/intrologic/lectures/lecture_06.pdf · q(a,y) Relational sentences are not terms and cannot be nested in relational sentences. No! q(a,q(a,y)) No!

Example - Modular Arithmetic

Page 56: Relational Logiclogic.stanford.edu/intrologic/lectures/lecture_06.pdf · q(a,y) Relational sentences are not terms and cannot be nested in relational sentences. No! q(a,q(a,y)) No!

In Modular Arithmetic of modulus 4 there are just 4 numbers (0,1, 2, 3).

0+0=01+0=1 2+0=2 3+0=30+1=11+1=2 2+1=3 3+1=00+2=21+2=3 2+2=0 3+2=10+3=31+3=0 2+3=1 3+3=2

Modular Arithmetic

Page 57: Relational Logiclogic.stanford.edu/intrologic/lectures/lecture_06.pdf · q(a,y) Relational sentences are not terms and cannot be nested in relational sentences. No! q(a,q(a,y)) No!

Object Constants: 0, 1, 2, 3

Binary Relation Constants: same - the first and second arguments are identical next - the second argument is number after the first

Ternary Relation Constant: plus - the third argument is the sum of the first two

plus(1,2,3)

Signature

Page 58: Relational Logiclogic.stanford.edu/intrologic/lectures/lecture_06.pdf · q(a,y) Relational sentences are not terms and cannot be nested in relational sentences. No! q(a,q(a,y)) No!

Ground Relational Data:

same(0,0) ¬same(1,0) ¬same(2,0) ¬same(3,0)¬same(0,1) same(1,1) ¬same(2,1) ¬same(3,1)¬same(0,2) ¬same(1,2) same(2,2) ¬same(3,2)¬same(0,3) ¬same(1,3) ¬same(2,3) same(3,3)

Same

Page 59: Relational Logiclogic.stanford.edu/intrologic/lectures/lecture_06.pdf · q(a,y) Relational sentences are not terms and cannot be nested in relational sentences. No! q(a,q(a,y)) No!

Ground Relational Data:

¬next(0,0) ¬next(1,0) ¬next(2,0) next(3,0) next(0,1) ¬next(1,1) ¬next(2,1) ¬next(3,1)¬next(0,2) next(1,2) ¬next(2,2) ¬next(3,2)¬next(0,3) ¬next(1,3) next(2,3) ¬next(3,3)

Next

Page 60: Relational Logiclogic.stanford.edu/intrologic/lectures/lecture_06.pdf · q(a,y) Relational sentences are not terms and cannot be nested in relational sentences. No! q(a,q(a,y)) No!

Ground Relational Data:

next(0,1)next(1,2)next(2,3)next(3,0)

Deal with negative literals by saying that all other cases are false. How do we do this?

Next

Page 61: Relational Logiclogic.stanford.edu/intrologic/lectures/lecture_06.pdf · q(a,y) Relational sentences are not terms and cannot be nested in relational sentences. No! q(a,q(a,y)) No!

For every x, there is just one y such that next(x,y):

∀x.∀y.∀z.(next(x,y) ∧ next(x,z) ⇒ same(y,z)

Logically equivalent formulation:

∀x.∀y.∀z.(next(x,y) ∧ ¬same(y,z) ⇒ ¬next(x,z))

Functionality Axiom

Page 62: Relational Logiclogic.stanford.edu/intrologic/lectures/lecture_06.pdf · q(a,y) Relational sentences are not terms and cannot be nested in relational sentences. No! q(a,q(a,y)) No!

Ground Relational Data:

plus(0,0,0) plus(1,0,1) plus(2,0,2) plus(3,0,3)plus(0,1,1) plus(1,1,2) plus(2,1,3) plus(3,1,0)plus(0,2,2) plus(1,2,3) plus(2,2,0) plus(3,2,1)plus(0,3,3) plus(1,3,0) plus(2,3,1) plus(3,3,2)

Functionality Axiom:

∀x.∀y. ∀z.∀w.(plus(x,y,z) ∧ plus(x,y,w) ⇒ same(z,w)

Addition

Page 63: Relational Logiclogic.stanford.edu/intrologic/lectures/lecture_06.pdf · q(a,y) Relational sentences are not terms and cannot be nested in relational sentences. No! q(a,q(a,y)) No!

Identity:

∀y.plus(0,y,y)

Successor:

∀x.∀y.∀z.(plus(x,y,z) ∧ next(x,x2) ∧ next(z,z2) ⇒ plus(x2,y,z2))

Functionality:

∀x.∀y.∀z.∀w.(plus(x,y,z) ∧ plus(x,y,w) ⇒ same(z,w)

Alternative Definition of Addition

Page 64: Relational Logiclogic.stanford.edu/intrologic/lectures/lecture_06.pdf · q(a,y) Relational sentences are not terms and cannot be nested in relational sentences. No! q(a,q(a,y)) No!

Properties of Sentences

Page 65: Relational Logiclogic.stanford.edu/intrologic/lectures/lecture_06.pdf · q(a,y) Relational sentences are not terms and cannot be nested in relational sentences. No! q(a,q(a,y)) No!

A sentence is valid if and only ifevery interpretation satisfies it.

A sentence is contingent if and only ifsome interpretation satisfies it andsome interpretation falsifies it.

A sentence is unsatisfiable if andonly if no interpretation satisfies it.

Valid

Contingent

Unsatisfiable

Properties of Sentences

Page 66: Relational Logiclogic.stanford.edu/intrologic/lectures/lecture_06.pdf · q(a,y) Relational sentences are not terms and cannot be nested in relational sentences. No! q(a,q(a,y)) No!

A sentences is satisfiable if and onlyif it is either valid or contingent.

A sentences is falsifiable if and onlyif it is contingent or unsatisfiable.

Valid

Contingent

Unsatisfiable

}

}

Properties of Sentences

Page 67: Relational Logiclogic.stanford.edu/intrologic/lectures/lecture_06.pdf · q(a,y) Relational sentences are not terms and cannot be nested in relational sentences. No! q(a,q(a,y)) No!

Law of the Excluded Middle:p(a) ∨ ¬p(a)

Double Negation:p(a) ⇔ ¬¬p(a)

deMorgan's Laws:¬(p(a) ∧ q(a,b)) ⇔ (¬p(a) ∨¬q(a,b))¬(p(a) ∨ q(a,b)) ⇔ (¬p(a) ∧¬q(a,b))

Logical Validities

Page 68: Relational Logiclogic.stanford.edu/intrologic/lectures/lecture_06.pdf · q(a,y) Relational sentences are not terms and cannot be nested in relational sentences. No! q(a,q(a,y)) No!

Common Quantifier Reversal:∀x.∀y.q(x,y) ⇔ ∀y.∀x.q(x,y)∃x.∃y.q(x,y) ⇔ ∃y.∃x.q(x,y)

Existential Distribution:∃y.∀x.q(x,y) ⇒ ∀x.∃y.q(x,y)

Negation Distribution:¬∀x.p(x) ⇔ ∃x.¬p(x) ¬∃x.p(x) ⇔ ∀x.¬p(x)

Quantificational Validities

Page 69: Relational Logiclogic.stanford.edu/intrologic/lectures/lecture_06.pdf · q(a,y) Relational sentences are not terms and cannot be nested in relational sentences. No! q(a,q(a,y)) No!

Logical Entailment

Page 70: Relational Logiclogic.stanford.edu/intrologic/lectures/lecture_06.pdf · q(a,y) Relational sentences are not terms and cannot be nested in relational sentences. No! q(a,q(a,y)) No!

A set of premises Δ logically entails a conclusion ϕ (written as Δ |= ϕ) if and only if every interpretation that satisfies the premises also satisfies the conclusion.

{p(a)} |= (p(a) ∨ p(b))

{p(a)} |# (p(a) ∧ p(b))

{p(a), p(b)} |= (p(a) ∧ p(b))

Logical Entailment

Page 71: Relational Logiclogic.stanford.edu/intrologic/lectures/lecture_06.pdf · q(a,y) Relational sentences are not terms and cannot be nested in relational sentences. No! q(a,q(a,y)) No!

∃y.∀x.q(x,y) |= ∀x.∃y.q(x,y)

∀x.∀y.q(x,y) |= ∀y.∀x.q(x,y)

∀x.∀y.q(x,y) |= ∀x.∀y.q(y,x)

Examples with Quantification

Page 72: Relational Logiclogic.stanford.edu/intrologic/lectures/lecture_06.pdf · q(a,y) Relational sentences are not terms and cannot be nested in relational sentences. No! q(a,q(a,y)) No!

q(x,y) |= q(y,x)

∀x.∀y.q(x,y) |= ∀y.∀x.q(y,x)

Example with Free Variables

Page 73: Relational Logiclogic.stanford.edu/intrologic/lectures/lecture_06.pdf · q(a,y) Relational sentences are not terms and cannot be nested in relational sentences. No! q(a,q(a,y)) No!

Relational Logic and Propositional Logic

Page 74: Relational Logiclogic.stanford.edu/intrologic/lectures/lecture_06.pdf · q(a,y) Relational sentences are not terms and cannot be nested in relational sentences. No! q(a,q(a,y)) No!

There is a simple procedure for mapping RL sentences to equivalent PL sentences.

(1) Convert to Prenex form.

(2) Compute the grounding.

(3) Rewrite from FHL to PL.

Mapping

Page 75: Relational Logiclogic.stanford.edu/intrologic/lectures/lecture_06.pdf · q(a,y) Relational sentences are not terms and cannot be nested in relational sentences. No! q(a,q(a,y)) No!

A sentence is in prenex form if and only if (1) it is closed and (2) all of the quantifiers are outside of all logical operators.

Sentence in Prenex Form:∀x.∃y.∀z.(p(x,y) ∨ q(z))

Sentences not in Prenex Form:∀x.∃y.p(x,y) ∨ ∃y.q(y)∀x.(p(x,y) ∨ q(x))

Prenex Form

Page 76: Relational Logiclogic.stanford.edu/intrologic/lectures/lecture_06.pdf · q(a,y) Relational sentences are not terms and cannot be nested in relational sentences. No! q(a,q(a,y)) No!

Rename duplicate variables. ∀y.p(x,y) ∨ ∃y.q(y) → ∀y.p(x,y) ∨ ∃z.q(z)

Distribute logical operators over quantifiers. ∀y.p(x,y) ∨ ∃z.q(z) → ∀y.∃z.(p(x,y) ∨ q(z))

Quantify any free variables. ∀y.∃z.(p(x,y) ∨ q(z)) → ∀x.∀y.∃z.(p(x,y) ∨ q(z))

Conversion to Prenex Form

Page 77: Relational Logiclogic.stanford.edu/intrologic/lectures/lecture_06.pdf · q(a,y) Relational sentences are not terms and cannot be nested in relational sentences. No! q(a,q(a,y)) No!

Let Δ0=Δ and Γ0={}. On each step, process ϕ in Δ until Δ is empty.

If ϕ is ground, we remove from Δi and add to ΓiΔi+1= Δi - {ϕ}Γi+1= Γi ∪ {ϕ}

If ∀υ.ϕ[υ], replace on Δi with all instancesΔi+1= Δi - {∀υ.ϕ[υ]} ∪ {ϕ[τi] | τi a constant}Γi+1= Γi

If ∃υ.ϕ[υ], replace on Δi with disjunction of instancesΔi+1= Δi - {∃υ.ϕ[υ]} ∪ {ϕ[τ1]∨…∨ϕ[τn]}Γi+1= Γi

Grounding

Page 78: Relational Logiclogic.stanford.edu/intrologic/lectures/lecture_06.pdf · q(a,y) Relational sentences are not terms and cannot be nested in relational sentences. No! q(a,q(a,y)) No!

Δ0={p(a), ∀x.(p(x) ⇒ q(x)) , ∃x.q(x)}Γ0={}

Δ1={∀x.p(x) ⇒ q(x)) , ∃x.q(x)} Γ1={p(a)}

Δ2={p(a) ⇒ q(a), p(b) ⇒ q(b), ∃x.q(x)}Γ2={p(a)}

Δ3={p(b) ⇒ q(b), ∃x.q(x)} Γ3={p(a), p(a) ⇒ q(a)}

Δ4={∃x.q(x)}Γ4={p(a), p(a) ⇒ q(a), p(b) ⇒ q(b)}

Example 1

Page 79: Relational Logiclogic.stanford.edu/intrologic/lectures/lecture_06.pdf · q(a,y) Relational sentences are not terms and cannot be nested in relational sentences. No! q(a,q(a,y)) No!

Δ4={∃x.q(x)}Γ4={p(a), p(a) ⇒ q(a), p(b) ⇒ q(b)}

Δ5={q(a) ∨ q(b)} Γ5={p(a), p(a) ⇒ q(a), p(b) ⇒ q(b)}

Δ6={}Γ6={p(a), p(a) ⇒ q(a), p(b) ⇒ q(b), q(a) ∨ q(b)}

Example 2

Page 80: Relational Logiclogic.stanford.edu/intrologic/lectures/lecture_06.pdf · q(a,y) Relational sentences are not terms and cannot be nested in relational sentences. No! q(a,q(a,y)) No!

Select a proposition for each ground relational sentence and rewrite the grounding from FHL to PL.

FHL Grounding:{p(a), p(a) ⇒ q(a), p(b) ⇒ q(b), q(a) ∨ q(b)}

Corresponding PL:p(a) ↔ pa q(a) ↔ qap(b) ↔ pb q(b) ↔ qb

Corresponding PL:{pa, pa ⇒ qa, pb ⇒ qb, qa ∨ qb}

Renaming RL to PL

Page 81: Relational Logiclogic.stanford.edu/intrologic/lectures/lecture_06.pdf · q(a,y) Relational sentences are not terms and cannot be nested in relational sentences. No! q(a,q(a,y)) No!

Unsatisfiability and logical entailment for Propositional Logic (PL) is decidable.

Given our mapping, we also know that unsatisfiability logical entailment for Relational Logic (RL) is also decidable.

Decidability

Page 82: Relational Logiclogic.stanford.edu/intrologic/lectures/lecture_06.pdf · q(a,y) Relational sentences are not terms and cannot be nested in relational sentences. No! q(a,q(a,y)) No!

A logic is compact if and only if every unsatisfiable set of sentences (including infinite sets) has a finite subset that is unsatisfiable.

Propositional Logic is compact.

Given our mapping, we know that RL must also be compact.

Compactness

Page 83: Relational Logiclogic.stanford.edu/intrologic/lectures/lecture_06.pdf · q(a,y) Relational sentences are not terms and cannot be nested in relational sentences. No! q(a,q(a,y)) No!