ldk r logics for data and knowledge representation first order logics (fol) originally by alessandro...

36
L Logics for D Data and K Knowledge R Representation First Order Logics (FOL) Originally by Alessandro Agostini and Fausto Giunchiglia Modified by Fausto Giunchiglia, Rui Zhang and Vincenzo Maltese

Upload: molly-perry

Post on 01-Jan-2016

231 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: LDK R Logics for Data and Knowledge Representation First Order Logics (FOL) Originally by Alessandro Agostini and Fausto Giunchiglia Modified by Fausto

LLogics for DData and KKnowledgeRRepresentation

First Order Logics (FOL)

Originally by Alessandro Agostini and Fausto GiunchigliaModified by Fausto Giunchiglia, Rui Zhang and Vincenzo Maltese

Page 2: LDK R Logics for Data and Knowledge Representation First Order Logics (FOL) Originally by Alessandro Agostini and Fausto Giunchiglia Modified by Fausto

2

Outline Introduction Syntax Semantics Reasoning Services

2

Page 3: LDK R Logics for Data and Knowledge Representation First Order Logics (FOL) Originally by Alessandro Agostini and Fausto Giunchiglia Modified by Fausto

Propositions All knowledge representation languages deal with

sentences

Sentences denote propositions (by definition), namely they express something true or false (the mental image of what you mean when you write the sentence)

Logic languages deal with propositions

Logic languages have different expressiveness, i.e. they have different expressive power.

3

“All men are mortals” “Obama is the president of the USA”

INTRODUCTION :: SYNTAX :: SEMANTICS :: REASONING SERVICES

Page 4: LDK R Logics for Data and Knowledge Representation First Order Logics (FOL) Originally by Alessandro Agostini and Fausto Giunchiglia Modified by Fausto

What we can express with PL and ClassL (I) PL

“There is a monkey” Monkey

We use Intensional Interpretation: the truth valuation ν of the proposition Monkey determines a truth-value ν(Monkey).

ν tells us if a proposition P “holds” or not.

ClassL

“Fausto is a Professor” Fausto ∈ σ(Professor)

We use Extensional Interpretation: the interpretation function σ of Professor determines a class of objects σ(Professor) that includes Fausto. In other words, given x ∈ P:

“x belongs to P” or “x in P” or “x is an instance of P”4

INTRODUCTION :: SYNTAX :: SEMANTICS :: REASONING SERVICES

Page 5: LDK R Logics for Data and Knowledge Representation First Order Logics (FOL) Originally by Alessandro Agostini and Fausto Giunchiglia Modified by Fausto

What we can express with PL and ClassL (II) PL

Monkey ∧ Banana

We mean that there is a monkey and there is a banana.

ClassL

Monkey ⊓ Banana

We mean that there is an x ∈ σ(Monkey) ∩ σ(Banana)

5

INTRODUCTION :: SYNTAX :: SEMANTICS :: REASONING SERVICES

Page 6: LDK R Logics for Data and Knowledge Representation First Order Logics (FOL) Originally by Alessandro Agostini and Fausto Giunchiglia Modified by Fausto

What we cannot express in PL and ClassL n-ary relations

They express objects in Dn

Near(Kimba,Simba) LessThan(x,3) Connects(x,y,z)

Functions

They return a value of the domain, Dn → D

Sum(2,3) Multiply(x,y) Exp(3,6)

Universal quantification

∀x Man(x) → Mortal(x) “All men are mortal”

Existential quantification

∃x (Dog(x) ∧ Black(x)) “There exists a dog which is black”

6

INTRODUCTION :: SYNTAX :: SEMANTICS :: REASONING SERVICES

Page 7: LDK R Logics for Data and Knowledge Representation First Order Logics (FOL) Originally by Alessandro Agostini and Fausto Giunchiglia Modified by Fausto

The need for greater expressive power We need FOL for a greater expressive power. In FOL we

have: constants/individuals (e.g. 2) variables (e.g. x) Unary predicates (e.g. Man) N-ary predicates (eg. Near) functions (e.g. Sum, Exp) quantifiers (∀, ∃) equality symbol = (optional)

NOTE: P(a) → ∃x P(x)∀x P(x) → ∃x P(x)∀x P(x) → P(x)

7

INTRODUCTION :: SYNTAX :: SEMANTICS :: REASONING SERVICES

Page 8: LDK R Logics for Data and Knowledge Representation First Order Logics (FOL) Originally by Alessandro Agostini and Fausto Giunchiglia Modified by Fausto

Example of what we can express in FOL

8

Kimba Simba

Cita

Hunts Eats

Monkey

LionNear

constants1-ary predicatesn-ary predicates

INTRODUCTION :: SYNTAX :: SEMANTICS :: REASONING SERVICES

Page 9: LDK R Logics for Data and Knowledge Representation First Order Logics (FOL) Originally by Alessandro Agostini and Fausto Giunchiglia Modified by Fausto

The use of FOL in mathematics

9

FOL has being introduced to express mathematical properties

The set of axioms describing the properties of equality between natural numbers (by Peano):

Axioms about equality1. ∀x1 (x1 = x1) reflexivity

2. ∀x1 ∀x2 (x1 = x2 → x2 = x1) symmetricity

3. ∀x1 ∀x2 ∀x3 (x1 = x2 x2 = x3 → x1 = x3) transitivity

4. ∀x1 ∀x2 (x1 = x2 → S(x1) = S(x2)) successor

NOTE: Other axioms can be given for the properties of the successor, the addition (+) and the multiplication (x).

INTRODUCTION :: SYNTAX :: SEMANTICS :: REASONING SERVICES

Page 10: LDK R Logics for Data and Knowledge Representation First Order Logics (FOL) Originally by Alessandro Agostini and Fausto Giunchiglia Modified by Fausto

Alphabet of symbols Variables x1, x2, …, y, z

Constants a1, a2, …, b, c

Predicate symbols A11, A1

2, …, Anm

Function symbols f11, f1

2, …, fnm

Logical symbols ∧, ∨, , → , ∀, ∃ Auxiliary symbols ( )

Indexes on top are used to denote the number of arguments, called arity, in predicates and functions.

Indexes on the bottom are used to disambiguate between symbols having the same name.

Predicates of arity =1 correspond to properties or concepts

10

INTRODUCTION :: SYNTAX :: SEMANTICS :: REASONING SERVICES

Page 11: LDK R Logics for Data and Knowledge Representation First Order Logics (FOL) Originally by Alessandro Agostini and Fausto Giunchiglia Modified by Fausto

Terms Terms can be defined using the following BNF grammar:

<term> ::= <variable> | <constant> |

<function sym> (<term> {,<term>}*)

A term is called a closed term iff it does not contain variables

11

x, 2, SQRT(x), Sum(2, 3), Sum(2, x), Average(x1, x2, x3)

Sum(2, 3)

INTRODUCTION :: SYNTAX :: SEMANTICS :: REASONING SERVICES

Page 12: LDK R Logics for Data and Knowledge Representation First Order Logics (FOL) Originally by Alessandro Agostini and Fausto Giunchiglia Modified by Fausto

Well formed formulas Well formed formulas (wff) can be defined as follows:

<atomic formula> ::= <predicate sym> (<term> {,<term>}*) |

<term> = <term>

<wff> ::= <atomic formula> | ¬<wff> | <wff> ∧ <wff> | <wff> ∨ <wff> |

<wff> → <wff> | ∀ <variable> <wff> | ∃ <variable> <wff>

NOTE: <term> = <term> is optional. If it is included, we have a FO language with equality.

NOTE: We can also write ∃x.P(x) or ∃x:P(x) as notation (with ‘.’ or “:”)

12

INTRODUCTION :: SYNTAX :: SEMANTICS :: REASONING SERVICES

Page 13: LDK R Logics for Data and Knowledge Representation First Order Logics (FOL) Originally by Alessandro Agostini and Fausto Giunchiglia Modified by Fausto

Well formed formulas

13

INTRODUCTION :: SYNTAX :: SEMANTICS :: REASONING SERVICES

NL FOL

“x is a man” Man(x)

“3 is an odd number”

Odd(3)

“Each number is odd or even”

∀x (Odd(x) Even(x))

“Each even number greater than 2 is the sum of two prime numbers”

∀x ( Even(x) GreaterThan(x,2) →

∃y ∃z (Prime(y) Prime(z) x = Sum(y,z)) )

There is (at least) a white dog

∃x (Dog(x) White(x))

There are (at least) two dogs

∃x ∃y (Dog(x) Dog(y) (x = y))

Page 14: LDK R Logics for Data and Knowledge Representation First Order Logics (FOL) Originally by Alessandro Agostini and Fausto Giunchiglia Modified by Fausto

Scope and index of logical operatorsGiven two wff α and β

Unary operators

In ¬α, ∀xα and∃xα,

α is the scope and x is the index of the operator

Binary operators

In α β, α β and α β,

α and β are the scope of the operator

NOTE: in the formula ∀x1 A(x2), x1 is the index but x1 is not in the scope, therefore the formula can be simplified to A(x2).

14

INTRODUCTION :: SYNTAX :: SEMANTICS :: REASONING SERVICES

Page 15: LDK R Logics for Data and Knowledge Representation First Order Logics (FOL) Originally by Alessandro Agostini and Fausto Giunchiglia Modified by Fausto

Free and bound variables A variable x is bound in a formula γ if it is γ = ∀x α(x) or

∃x α(x) that is x is both in the index and in the scope of the operator.

A variable is free otherwise.

A formula with no free variables is said to be a sentence or closed formula.

A FO theory is any set of FO-sentences.

NOTE: we can substitute the bound variables without changing the meaning of the formula, while it is in general not true for free variables.

15

INTRODUCTION :: SYNTAX :: SEMANTICS :: REASONING SERVICES

Page 16: LDK R Logics for Data and Knowledge Representation First Order Logics (FOL) Originally by Alessandro Agostini and Fausto Giunchiglia Modified by Fausto

Interpretation function An interpretation I for a FO language L over a domain D

is a function such that:

I(ai) = ai for each constant ai

I(An) Dn for each predicate A of arity n

I(fn) is a function f: Dn D Dn +1 for each function f of arity n

16

INTRODUCTION :: SYNTAX :: SEMANTICS :: REASONING SERVICES

Page 17: LDK R Logics for Data and Knowledge Representation First Order Logics (FOL) Originally by Alessandro Agostini and Fausto Giunchiglia Modified by Fausto

Assignment An assignment for the variables {x1, …, xn} of a FO

language L over a domain D is a mapping function a: {x1, …, xn} D

a(xi) = di ∈ D

NOTE: In countable domains (finite and enumerable) the elements of the domain D are given in an ordered sequence <d1,…,dn> such that the assignment of the variables xi

follows the sequence.

NOTE: the assignment a can be defined on free variables only.

17

INTRODUCTION :: SYNTAX :: SEMANTICS :: REASONING SERVICES

Page 18: LDK R Logics for Data and Knowledge Representation First Order Logics (FOL) Originally by Alessandro Agostini and Fausto Giunchiglia Modified by Fausto

Interpretation over an assignment a An interpretation Ia for a FO language L over an

assignment a and a domain D is an extended interpretation where:

Ia(x) = a(x) for each variable x

Ia(c) = I(c) for each constant c

Ia(fn(t1,…, tn)) = I(fn)(Ia(t1),…, Ia(tn)) for each function f of arity n

NOTE: Ia is defined on terms only

18

INTRODUCTION :: SYNTAX :: SEMANTICS :: REASONING SERVICES

Page 19: LDK R Logics for Data and Knowledge Representation First Order Logics (FOL) Originally by Alessandro Agostini and Fausto Giunchiglia Modified by Fausto

Interpretation over an assignment a D = the set N of natural numbers Succ(x) = the function that returns the successor x+1 zero = we could assign the value 0 to it.

Ia(xi) = a(xi) = i ∈ N

Ia(zero) = I(zero) = 0 ∈ N

Ia(Succ(x)) = I(Succ)(Ia(x)) = S(a(x)) such that S(a(x)) = a(x)+1

Ia(Succ(xi)) = I(Succ)(Ia(xi)) = S(i) = i+1

19

INTRODUCTION :: SYNTAX :: SEMANTICS :: REASONING SERVICES

Page 20: LDK R Logics for Data and Knowledge Representation First Order Logics (FOL) Originally by Alessandro Agostini and Fausto Giunchiglia Modified by Fausto

Satisfaction relation We are now ready to provide the notion of satisfaction

relation:

M ⊨ γ [a]

(to be read: M satisfies γ under a or γ is true in M under a)

where: M is an interpretation function I over D

M is a mathematical structure <D, I> a is an assignment {x1, …, xn} D γ is a FO-formula

NOTE: if γ is a sentence with no free variables, we can simply write: M ⊨ γ (without the assignment a)

20

INTRODUCTION :: SYNTAX :: SEMANTICS :: REASONING SERVICES

Page 21: LDK R Logics for Data and Knowledge Representation First Order Logics (FOL) Originally by Alessandro Agostini and Fausto Giunchiglia Modified by Fausto

Satisfaction relation for well formed formulas γ atomic formula:

γ: t1= t2 M ⊨ (t1= t2) [a] iff Ia(t1) = Ia(t2)

γ: An(t1,…, tn) M ⊨ An(t1,…, tn) [a] iff (Ia(t1), …, Ia(tn)) ∈ I(An)

21

INTRODUCTION :: SYNTAX :: SEMANTICS :: REASONING SERVICES

Page 22: LDK R Logics for Data and Knowledge Representation First Order Logics (FOL) Originally by Alessandro Agostini and Fausto Giunchiglia Modified by Fausto

Satisfaction relation for well formed formulas γ well formed formula:

γ: α M ⊨ α [a] iff M ⊭ α [a]

γ: α β M ⊨ α β [a] iff M ⊨ α [a] and M ⊨ β [a]

γ: α β M ⊨ α β [a] iff M ⊨ α [a] or M ⊨ β [a]

γ: α β M ⊨ α β [a] iff M ⊭ α [a] or M ⊨ β [a]

γ: ∀xiα M ⊨ ∀xiα [a] iff M ⊨ α [s] for all assignments

s = <d1,…, d’i,…, dn> where s varies from a only

for the i-th element (s is called an i-th variant of a)

γ: ∃xiα M ⊨ ∃xiα [a] iff M ⊨ α [s] for some assignment s = <d1,…, d’i,…, dn> i-th variant of a

22

INTRODUCTION :: SYNTAX :: SEMANTICS :: REASONING SERVICES

Page 23: LDK R Logics for Data and Knowledge Representation First Order Logics (FOL) Originally by Alessandro Agostini and Fausto Giunchiglia Modified by Fausto

Satisfaction relation for a set of formulas We say that a formula γ is true (w.r.t. an interpretation I) iff

every assignment

s = <d1,…, dn> satisfies γ, i.e. M ⊨ γ [s] for all s.

NOTE: under this definition, a formula γ might be neither true nor false w.r.t. an interpretation I (it depends on the assignment)

If γ is true under I we say that I is a model for γ.

Given a set of formulas Γ, M satisfies Γ iff M ⊨ γ for all γ in Γ

23

INTRODUCTION :: SYNTAX :: SEMANTICS :: REASONING SERVICES

Page 24: LDK R Logics for Data and Knowledge Representation First Order Logics (FOL) Originally by Alessandro Agostini and Fausto Giunchiglia Modified by Fausto

Satisfiability and Validity We say that a formula γ is satisfiable iff there is a

structure

M = <D, I> and an assignment a such that M ⊨ γ [a]

We say that a set of formulas Γ is satisfiable iff there is a structure M = <D, I> and an assignment a such that

M ⊨ γ [a] for all γ in Γ

We say that a formula γ is valid iff it is true for any structure and assignment, in symbols ⊨ γ

A set of formulas Γ is valid iff all formulas in Γ are valid.

24

INTRODUCTION :: SYNTAX :: SEMANTICS :: REASONING SERVICES

Page 25: LDK R Logics for Data and Knowledge Representation First Order Logics (FOL) Originally by Alessandro Agostini and Fausto Giunchiglia Modified by Fausto

Example of satisfiability D = {0, 1, 2, 3}

constants = {zero} variables = {x}

predicate symbols = {even, odd} functions = {succ}

γ1 : ∀x (even(x) odd(succ(x)))

γ2 : even(zero)

γ3 : odd(zero)

Is there any M and a such that M ⊨ γ1 γ2 [a]?

Ia(zero) = I(zero) = 0

Ia(succ(x)) = I(succ)(Ia(x)) = S(n) = {1 if n=0, n+1 otherwise}

I(even) = {0, 2} I(odd) = {1, 3}

Is there any M and a such that M ⊨ γ1 γ3 [a]?

Yes! Just invert the interpretation of even and odd.

25

INTRODUCTION :: SYNTAX :: SEMANTICS :: REASONING SERVICES

Page 26: LDK R Logics for Data and Knowledge Representation First Order Logics (FOL) Originally by Alessandro Agostini and Fausto Giunchiglia Modified by Fausto

Example of valid formulas ∀x1 (P(x1) Q(x1)) ∀x1 P(x1) ∀x1 Q(x1)

∃x1 (P(x1) Q(x1)) ∃x1 P(x1) ∃x1 Q(x1)

∀x1 P(x1) ∃x1 P(x1)

∀x1 ∃x1 P(x1) ∃x1 P(x1)

∃x1 ∀x1 P(x1) ∀x1 P(x1)

26

INTRODUCTION :: SYNTAX :: SEMANTICS :: REASONING SERVICES

Page 27: LDK R Logics for Data and Knowledge Representation First Order Logics (FOL) Originally by Alessandro Agostini and Fausto Giunchiglia Modified by Fausto

Entailment Let be a set of FO- formulas, γ a FO- formula, we say

that

⊨ γ

(to be read entails γ)

iff for all the interpretations M and assignments a,

if M ⊨ [a] then M ⊨ γ [a].

27

INTRODUCTION :: SYNTAX :: SEMANTICS :: REASONING SERVICES

Page 28: LDK R Logics for Data and Knowledge Representation First Order Logics (FOL) Originally by Alessandro Agostini and Fausto Giunchiglia Modified by Fausto

Reasoning Services: EVAL Model Checking (EVAL)

Is a FO-formula γ true under a structure M = <D, I> and an assignment a?

Check M ⊨ γ [a]

EVALγ , M, aYes

No

INTRODUCTION :: SYNTAX :: SEMANTICS :: REASONING SERVICES

Undecidable in infinite domains (in general)Decidable in finite domains

Page 29: LDK R Logics for Data and Knowledge Representation First Order Logics (FOL) Originally by Alessandro Agostini and Fausto Giunchiglia Modified by Fausto

Reasoning Services: SAT Satisfiability (SAT)

Given a FO-formula γ, is there any structure M = <D, I> and an assignment a such that M ⊨ γ [a]?

Theorem (Church, 1936): SAT is undecidable

However, it is decidable in finite domains.

SATγM, a

No

INTRODUCTION :: SYNTAX :: SEMANTICS :: REASONING SERVICES

Page 30: LDK R Logics for Data and Knowledge Representation First Order Logics (FOL) Originally by Alessandro Agostini and Fausto Giunchiglia Modified by Fausto

Reasoning Services: VAL Validity (VAL)

Given a FO-formula γ, is γ true for all the interpretations M and assignments a, i.e. ⊨ γ?

Theorem (Church, 1936): VAL is undecidable

However, it is decidable in finite domains.

VALγYes

No

INTRODUCTION :: SYNTAX :: SEMANTICS :: REASONING SERVICES

Page 31: LDK R Logics for Data and Knowledge Representation First Order Logics (FOL) Originally by Alessandro Agostini and Fausto Giunchiglia Modified by Fausto

How to reason on finite domains (I) ⊨ ∀x P(x) [a] D = {a, b, c}

we have only 3 possible assignments a(x) = a, a(x) = b, a(x) = c

we translate in ⊨ P(a) P(b) P(c)

⊨ ∃x P(x) [a] D = {a, b, c}

we have only 3 possible assignments a(x) = a, a(x) = b, a(x) = c

we translate in ⊨ P(a) P(b) P(c)

INTRODUCTION :: SYNTAX :: SEMANTICS :: REASONING SERVICES

Page 32: LDK R Logics for Data and Knowledge Representation First Order Logics (FOL) Originally by Alessandro Agostini and Fausto Giunchiglia Modified by Fausto

How to reason on finite domains (II) ⊨ ∀x ∃y R(x,y) [a] D = {a, b, c}

we have 9 possible assignments, e.g. a(x) = a, a(y) = b

we translate in ⊨ ∃y R(a,y) ∃y R(b,y) ∃y R(c,y)

and then in ⊨ (R(a,a) R(a,b) R(a,c) ) (R(b,a) R(b,b) R(b,c) ) (R(c,a) R(c,b) R(c,c) )

INTRODUCTION :: SYNTAX :: SEMANTICS :: REASONING SERVICES

Page 33: LDK R Logics for Data and Knowledge Representation First Order Logics (FOL) Originally by Alessandro Agostini and Fausto Giunchiglia Modified by Fausto

Calculus Semantic tableau is a decision

procedure to determine the satisfiability of finite sets of formulas.

There are rules for handling each of the logical connectives thus generating a truth tree.

A branch in the tree is closed if a contradiction is present along the path (i.e. of an atomic formula, e.g. B and B)

If all branches close, the proof is complete and the set of formulas are unsatisfiable, otherwise are satisfiable.

With refutation tableaux the objective is to show that the negation of a formula is unsatisfiable.

33

Γ = {(A B), B}

B

A B

A

B

closed

INTRODUCTION :: SYNTAX :: SEMANTICS :: REASONING SERVICES

Page 34: LDK R Logics for Data and Knowledge Representation First Order Logics (FOL) Originally by Alessandro Agostini and Fausto Giunchiglia Modified by Fausto

Rules of the semantic tableaux in FOL (I) The initial set of formulas are

considered in conjunction and are put in the same branch of the tree

Conjunctions lie on the same branch Disjunctions generate new branches Propositional rules:

() A B () A B --------- ---------

A A | B

B

() A A

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

A A

34

(A B) B

B

A B

A

closed

B

(A B)

INTRODUCTION :: SYNTAX :: SEMANTICS :: REASONING SERVICES

Page 35: LDK R Logics for Data and Knowledge Representation First Order Logics (FOL) Originally by Alessandro Agostini and Fausto Giunchiglia Modified by Fausto

Rules of the semantic tableaux in FOL (II) Universal quantifiers are

instantiated with a terminal t.

Existential quantifiers are instantiated with a new constant symbol c.

(∀) ∀x.P(x)

---------

P(t)

(∃) ∃x.P(x)

---------

P(c)

NOTE: a constant is a terminal

NOTE: Multiple applications of the ∀ rule might be necessary (as in the example)

35

{∀x.P(x), ∃x.(¬P(x) ¬P(f(x)))

∀x.P(x)

P(c)

¬P(c)

closed ¬P(f(c))

∃x.(¬P(x) ¬P(f(x))

INTRODUCTION :: SYNTAX :: SEMANTICS :: REASONING SERVICES

P(f(c))

(∀)

(∃) ¬P(c) ¬P(f(c))

()

(∀)

closed

Page 36: LDK R Logics for Data and Knowledge Representation First Order Logics (FOL) Originally by Alessandro Agostini and Fausto Giunchiglia Modified by Fausto

Rules of the semantic tableaux in FOL (III) Correctness: the two rules for universal and existential

quantifiers together with the propositional rules are correct:

closed tableau → unsatisfiable set of formulas Completeness: it can also be proved:

unsatisfiable set of formulas → ∃ closed tableau

However, the problem is finding such a closed tableau. An unsatisfiable set can in fact generate an infinite-growing tableau.

∀ rule is non-deterministic: it does not specify which term to instantiate with. It also may require multiple applications.

In tableaux with unification, the choice of how to instantiate the ∀ is delayed until all the other formulas have been expanded. At that point the ∀ is applied to all unbounded formulas.

36

INTRODUCTION :: SYNTAX :: SEMANTICS :: REASONING SERVICES