Title: Logics for Data and Knowledge Representation
1Logics for Data and KnowledgeRepresentation
Originally by Alessandro Agostini and Fausto
Giunchiglia Modified by Fausto Giunchiglia, Rui
Zhang and Vincenzo Maltese
2Outline
- Introduction
- Syntax
- Semantics
- Reasoning Services
2
3Propositions
INTRODUCTION SYNTAX SEMANTICS REASONING
SERVICES
- 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.
All men are mortals Obama is the president of
the USA
4What we can express with PL and ClassL (I)
INTRODUCTION SYNTAX SEMANTICS REASONING
SERVICES
- 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 ?
s(Professor) - We use Extensional Interpretation the
interpretation function s of Professor determines
a class of objects s(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
5What we can express with PL and ClassL (II)
INTRODUCTION SYNTAX SEMANTICS REASONING
SERVICES
- 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 ? s(Monkey) n
s(Banana)
5
6What we cannot express in PL and ClassL
INTRODUCTION SYNTAX SEMANTICS REASONING
SERVICES
- 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
7The need for greater expressive power
INTRODUCTION SYNTAX SEMANTICS REASONING
SERVICES
- 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
8Example of what we can express in FOL
INTRODUCTION SYNTAX SEMANTICS REASONING
SERVICES
constants
Cita
Monkey
1-ary predicates
n-ary predicates
Eats
Hunts
Kimba
Simba
Lion
Near
8
9The use of FOL in mathematics
INTRODUCTION SYNTAX SEMANTICS REASONING
SERVICES
- FOL has being introduced to express mathematical
properties - The set of axioms describing the properties of
equality between natural numbers (by Peano) - Axioms about equality
- ?x1 (x1 x1) reflexivity
- ?x1 ?x2 (x1 x2 ? x2 x1) symmetricity
- ?x1 ?x2 ?x3 (x1 x2 ? x2 x3 ? x1
x3) transitivity - ?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).
9
10Alphabet of symbols
INTRODUCTION SYNTAX SEMANTICS REASONING
SERVICES
- Variables x1, x2, , y, z
- Constants a1, a2, , b, c
- Predicate symbols A11, A12, , Anm
- Function symbols f11, f12, , 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
11Terms
INTRODUCTION SYNTAX SEMANTICS REASONING
SERVICES
- Terms can be defined using the following BNF
grammar -
- lttermgt ltvariablegt ltconstantgt
- ltfunction symgt (lttermgt ,lttermgt)
-
-
-
- A term is called a closed term iff it does not
contain variables
x, 2, SQRT(x), Sum(2, 3), Sum(2, x),
Average(x1, x2, x3)
Sum(2, 3)
12Well formed formulas
INTRODUCTION SYNTAX SEMANTICS REASONING
SERVICES
- Well formed formulas (wff) can be defined as
follows -
- ltatomic formulagt ltpredicate symgt (lttermgt
,lttermgt) - lttermgt lttermgt
-
- ltwffgt ltatomic formulagt ltwffgt ltwffgt ?
ltwffgt ltwffgt ? ltwffgt - ltwffgt ? ltwffgt ? ltvariablegt ltwffgt ?
ltvariablegt ltwffgt - NOTE lttermgt lttermgt is optional. If it is
included, we have a FO language with equality. - NOTE We can also write ?x.P(x) or ?xP(x) as
notation (with . or )
13Well formed formulas
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))
13
14Scope and index of logical operators
INTRODUCTION SYNTAX SEMANTICS REASONING
SERVICES
- Given two wff a and ß
- Unary operators
- In a, ?xa and?xa,
- a is the scope and x is the index of the
operator - Binary operators
- In a ? ß, a ? ß and a ? ß,
- a 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
15Free and bound variables
INTRODUCTION SYNTAX SEMANTICS REASONING
SERVICES
- A variable x is bound in a formula ? if it is ?
?x a(x) or ?x a(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
16Interpretation function
INTRODUCTION SYNTAX SEMANTICS REASONING
SERVICES
- 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
17Assignment
INTRODUCTION SYNTAX SEMANTICS REASONING
SERVICES
- 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 ltd1,,dngt such that
the assignment of the variables xi follows the
sequence. - NOTE the assignment a can be defined on free
variables only.
17
18Interpretation over an assignment a
INTRODUCTION SYNTAX SEMANTICS REASONING
SERVICES
- 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
19Interpretation over an assignment a
INTRODUCTION SYNTAX SEMANTICS REASONING
SERVICES
- D the set N of natural numbers
- Succ(x) the function that returns the successor
x1 - 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) i1
19
20Satisfaction relation
INTRODUCTION SYNTAX SEMANTICS REASONING
SERVICES
- 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 ltD, Igt
- 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
21Satisfaction relation for well formed formulas
INTRODUCTION SYNTAX SEMANTICS REASONING
SERVICES
- ? 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
22Satisfaction relation for well formed formulas
INTRODUCTION SYNTAX SEMANTICS REASONING
SERVICES
- ? well formed formula
- ? ? a M ? ? a a iff M ? a a
- ? a ? ß M ? a ? ß a iff M ? a a and M ?
ß a - ? a ? ß M ? a ? ß a iff M ? a a or M ?
ß a - ? a ? ß M ? a ? ß a iff M ? a a or M ? ß
a - ? ?xia M ? ?xia a iff M ? a s for all
assignments - s ltd1,, di,, dngt where s varies from a
only - for the i-th element (s is called an i-th
variant of a) - ? ?xia M ? ?xia a iff M ? a s for some
assignment s ltd1,, di,, dngt i-th variant
of a
22
23Satisfaction relation for a set of formulas
INTRODUCTION SYNTAX SEMANTICS REASONING
SERVICES
- We say that a formula ? is true (w.r.t. an
interpretation I) iff every assignment - s ltd1,, dngt 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 G, M satisfies G iff M ?
? for all ? in G -
23
24Satisfiability and Validity
INTRODUCTION SYNTAX SEMANTICS REASONING
SERVICES
- We say that a formula ? is satisfiable iff there
is a structure - M ltD, Igt and an assignment a such that M ? ?
a - We say that a set of formulas G is satisfiable
iff there is a structure M ltD, Igt and an
assignment a such that - M ? ? a for all ? in G
- We say that a formula ? is valid iff it is true
for any structure and assignment, in symbols ? ? - A set of formulas G is valid iff all formulas in
G are valid.
24
25Example of satisfiability
INTRODUCTION SYNTAX SEMANTICS REASONING
SERVICES
- 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 n0,
n1 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
26Example of valid formulas
INTRODUCTION SYNTAX SEMANTICS REASONING
SERVICES
- ?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
27Entailment
INTRODUCTION SYNTAX SEMANTICS REASONING
SERVICES
- 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
28Reasoning Services EVAL
INTRODUCTION SYNTAX SEMANTICS REASONING
SERVICES
- Model Checking (EVAL)
- Is a FO-formula ? true under a structure M ltD,
Igt and an assignment a? - Check M ? ? a
- Undecidable in infinite domains (in general)
- Decidable in finite domains
29Reasoning Services SAT
INTRODUCTION SYNTAX SEMANTICS REASONING
SERVICES
- Satisfiability (SAT)
- Given a FO-formula ?, is there any structure M
ltD, Igt and an assignment a such that M ? ? a? -
-
- Theorem (Church, 1936) SAT is undecidable
- However, it is decidable in finite domains.
30Reasoning Services VAL
INTRODUCTION SYNTAX SEMANTICS REASONING
SERVICES
- 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.
31How to reason on finite domains (I)
INTRODUCTION SYNTAX SEMANTICS REASONING
SERVICES
- ? ?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)
32How to reason on finite domains (II)
INTRODUCTION SYNTAX SEMANTICS REASONING
SERVICES
- ? ?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)
)
33Calculus
INTRODUCTION SYNTAX SEMANTICS REASONING
SERVICES
- 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.
G (A ??B), B
B
A ? ?B
A
?B
closed
33
34Rules of the semantic tableaux in FOL (I)
INTRODUCTION SYNTAX SEMANTICS REASONING
SERVICES
- 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
??(A ??B) ? B
B
??(A ? ?B)
A ? ?B
A
?B
closed
34
35Rules of the semantic tableaux in FOL (II)
INTRODUCTION SYNTAX SEMANTICS REASONING
SERVICES
- 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)
?x.P(x), ?x.(P(x) ? P(f(x)))
?x.P(x)
?x.(P(x) ? P(f(x))
(?)
P(c) ? P(f(c))
P(c)
(?)
P(c)
P(f(c))
(?)
closed
(?)
P(f(c))
closed
35
36Rules of the semantic tableaux in FOL (III)
INTRODUCTION SYNTAX SEMANTICS REASONING
SERVICES
- 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