Logics for Data and KnowledgeRepresentation
Modeling
Originally by Alessandro Agostini and Fausto GiunchigliaModified by Fausto Giunchiglia, Rui Zhang and Vincenzo Maltese
2
Outline Modeling Logical Modeling (formal modeling)
Domain Language Interpretation Theory Model
How to use logical modeling What is a logic? Choosing the right logic and writing the theory
Reasoning services Expressiveness
Expressiveness, Efficiency, Complexity Decidability
2
3
Modeling
3
World
LanguageL
TheoryT
DomainD
ModelM
DataKnowledge
Meaning
MentalModel
SEMANTICGAP
MODELING :: LOGICAL MODELING :: HOW TO USE LOGICAL MODELING :: REASONING SERVICES :: EXPRESSIVENESS
4
Modeling World: the phenomenon we want to describe Domain: the abstract relevant elements in the real world Mental Model: what we have in mind. It is the first
abstraction of the world (subject to the semantic gap) Language: the set of words and rules we use to build
sentences used to express our mental model Model: the formalization of the mental model, i.e. the set
of true facts in the language, in agreement with the theory
Theory: the set of sentences (constraints) about the world expressed in the language that limit the possible models
NOTE: this does not necessarily need to be in formal semantics
4
MODELING :: LOGICAL MODELING :: HOW TO USE LOGICAL MODELING :: REASONING SERVICES :: EXPRESSIVENESS
5
Example of informal Modeling
5
World
MentalModel
SEMANTICGAP
ModelM
L: Informal description in NL
D: {monkey, banana, tree}
T: If the monkey climbs on the tree, he can get the banana
M: The monkey actually climbs on the tree and gets the banana
TheoryT
NOTE: a database can be seen as an informal model
LanguageL
DomainD
MODELING :: LOGICAL MODELING :: HOW TO USE LOGICAL MODELING :: REASONING SERVICES :: EXPRESSIVENESS
6
Logical Modeling
6
Modeling
Realization
World
LanguageL
TheoryT
DomainD
ModelM
DataKnowledge
Meaning
MentalModel
SEMANTICGAP
Inte
rpre
tatio
n
I
En
tailm
en
t⊨
NOTE: the key point is that in logical modeling we have formal semantics
MODELING :: LOGICAL MODELING :: HOW TO USE LOGICAL MODELING :: REASONING SERVICES :: EXPRESSIVENESS
7
Logical Modeling Elements Domain: relevant objects Logical Language: the set of formal words and rules we
use to build complex sentences Interpretation: the function that associates elements of
the language to the elements in the domain
Model: the set of true facts in the language describing the mental model, in agreement with the theory
Theory / Knowledge Base (KB): data and knowledge Truth-relation / logical entailment (⊨): deduction,
reasoning, inference
7
MODELING :: LOGICAL MODELING :: HOW TO USE LOGICAL MODELING :: REASONING SERVICES :: EXPRESSIVENESS
8
Example of formal (intentional) modeling
8
World
SEMANTICGAP
L = {Monkey, Climbs, GetBanana, , , }
D= {T, F}
T = { (Monkey Climbs) GetBanana}
A possible model M:I(Monkey) = TI(Climbs) = TI(GetBanana) = T
MentalModel
ModelM
TheoryT
LanguageL
DomainD
MODELING :: LOGICAL MODELING :: HOW TO USE LOGICAL MODELING :: REASONING SERVICES :: EXPRESSIVENESS
9
Domain Domain (D): the chosen objects from the world
We will deal only with finite domains! Question: what are we leaving out?
9
Example: the LDKR class The members of the LDKR class
define a domain D D is a finite set Two “kinds” of the elements in D:
Professor
Student
Both are specializations of Person
Fausto
Mary Paul Jane
HugoSaraRui
MODELING :: LOGICAL MODELING :: HOW TO USE LOGICAL MODELING :: REASONING SERVICES :: EXPRESSIVENESS
10
Language Language (L) = a logical language To each logical language we associate an
alphabet of symbols Σ (sigma)
For instance, Σ may contain the logical symbols: ∧ (and)∨ (or)¬ (not)→ (implication)∀ (for all, universal quantifier)∃ (exists, existential quantifier)
L has clear formation rules for formulas
10
MODELING :: LOGICAL MODELING :: HOW TO USE LOGICAL MODELING :: REASONING SERVICES :: EXPRESSIVENESS
11
Logical Language (Syntax) The first step in setting up a logical language is
to list the symbols the alphabet of (formal) symbols Σ formal symbol = a character, or group of characters
taken from some alphabet (it is formal because we specify the meaning)
Symbols in Σ can be divided in: descriptive (non-logical) non-descriptive (logical)
NOTE: English can be restricted to a propositional language, ...but it is not logical (informal syntax)
11
MODELING :: LOGICAL MODELING :: HOW TO USE LOGICAL MODELING :: REASONING SERVICES :: EXPRESSIVENESS
12
Logical language
12
The Language L for the LDKR class example with alphabet Σ
Logical symbols:
∧, ∨, ¬, →
Descriptive symbols:Person, Professor, Student
Fausto
Mary Paul Jane
HugoSaraRui
MODELING :: LOGICAL MODELING :: HOW TO USE LOGICAL MODELING :: REASONING SERVICES :: EXPRESSIVENESS
13
Formal Syntax The set of rules saying how to construct the
sentences of the language from the alphabet of symbols (i.e. the syntax) is a grammar (i.e., is formal)
Example: ¬A, A ∧ B, A → B¬Professor, Professor ∧ Student, Student → Person
Formal syntax is often called an abstract syntax, in contrast to the concrete syntax used, for instance in implementations.
Example: context-free grammars 13
MODELING :: LOGICAL MODELING :: HOW TO USE LOGICAL MODELING :: REASONING SERVICES :: EXPRESSIVENESS
14
Interpretation Interpretation (I) = a mapping of L into D
I must be effective (i.e., computable)
14
Intensional interpretation
I(Professor) = T
I(Student) = T
I(Person) = T
Extensional interpretation
I(Professor) = {Fausto}
I(Student) = {Mary, Paul, Jane, Rui, Sara, Hugo}
I(Person) = {Fausto, Mary, Paul, Jane, Rui, Sara, Hugo}
Fausto
Mary Paul Jane
HugoSaraRui
MODELING :: LOGICAL MODELING :: HOW TO USE LOGICAL MODELING :: REASONING SERVICES :: EXPRESSIVENESS
15
Theory Theory T (also L-Theory) = set of facts of L
A fact defines a piece of knowledge (about D), namely something true
A theory is a way to put constraints on the intended models
15
MODELING :: LOGICAL MODELING :: HOW TO USE LOGICAL MODELING :: REASONING SERVICES :: EXPRESSIVENESS
16
Theory A finite theory T is called:
An ontology if it contains knowledge only (T-BOX) A knowledge base (KB) if it contains knowledge (T-
BOX) and data (A-BOX) A database (DB) if it only contains data. A DB + its schema is the simplest kind of knowledge
base
NOTE: Sometimes the terms Ontology and Knowledge Base
are used interchangeably
16
MODELING :: LOGICAL MODELING :: HOW TO USE LOGICAL MODELING :: REASONING SERVICES :: EXPRESSIVENESS
17
Theory
17
The set of (true) facts T over L
Student → Person
Professor → Person
Student → ¬ Professor
Professor → ¬ Student
Fausto
Mary Paul Jane
HugoSaraRui
MODELING :: LOGICAL MODELING :: HOW TO USE LOGICAL MODELING :: REASONING SERVICES :: EXPRESSIVENESS
18
Model Model (M) = the abstract (in mathematical
sense) representation of the intended truths via interpretation I of the language L
M is called L-model of D: M ⊨ TM satisfies T
T holds in M T is TRUE in MM yields T
with T set of arbitrary complex formulas
18
MODELING :: LOGICAL MODELING :: HOW TO USE LOGICAL MODELING :: REASONING SERVICES :: EXPRESSIVENESS
19
Model
19
Intensional interpretation
I(Professor) = T
I(Student) = T
I(Person) = T
The I is a model for the theories below:
M ⊨ {Person}
M ⊨ {Professor ∨ Student}
M ⊨ {Person, Professor ∨ Student, Student → Person}
…
Fausto
Mary Paul Jane
HugoSaraRui
MODELING :: LOGICAL MODELING :: HOW TO USE LOGICAL MODELING :: REASONING SERVICES :: EXPRESSIVENESS
20
Theory and Model We have:
M ⊨ T iff M ⊨ A, for each formula A in T
A model M of a theory T is any interpretation function that satisfies all the facts in T
There can be many models satisfying the theory T. They are a subset of all possible interpretation functions over L.
In case there are no models for T, we say that the theory T is unsatisfiable.
20
MODELING :: LOGICAL MODELING :: HOW TO USE LOGICAL MODELING :: REASONING SERVICES :: EXPRESSIVENESS
21
Theory and Model
21
T
Student → Person
Professor → Person
Student → ¬ Professor
Professor → ¬ Student
Fausto
Mary Paul Jane
HugoSaraRuiM
I(Professor) = {Fausto}
I(Student) = {Mary, Paul, Jane, Rui, Sara, Hugo}
I(Person) = {Fausto, Mary, Paul, Jane, Rui, Sara, Hugo}
M is a model for T (M ⊨ T )
M’
I(Professor) = {Fausto, Mary}
I(Student) = {Mary, Paul, Jane, Rui, Sara, Hugo}
I(Person) = {Fausto, Mary, Paul, Jane, Rui, Sara, Hugo}
M’ is not, because Mary is both a student and a professor
MODELING :: LOGICAL MODELING :: HOW TO USE LOGICAL MODELING :: REASONING SERVICES :: EXPRESSIVENESS
22
Same theory, different models (MODEL#1) L = {MonkeyLow, BananaHigh, MonkeyClimbBox, MonkeyGetBanana,
, , }
T = { (MonkeyLow BananaHigh MonkeyGetBanana)
(MonkeyLow MonkeyClimbBox)
( MonkeyLow BananaHigh MonkeyGetBanana)}
Informal Semantics:
“If the monkey is low and the banana is high in position, then the monkey cannot get the banana. “
Formal Semantics:
I(MonkeyLow) = T
I(BananaHigh) = T I(MonkeyClimbBox) = F
I(MonkeyGetBanana) = F
MODEL#1
MODELING :: LOGICAL MODELING :: HOW TO USE LOGICAL MODELING :: REASONING SERVICES :: EXPRESSIVENESS
23
Same theory, different models (MODEL#2) L = {MonkeyLow, BananaHigh, MonkeyClimbBox,
MonkeyGetBanana, , , }
T = { (MonkeyLow BananaHigh MonkeyGetBanana)
(MonkeyLow MonkeyClimbBox)
( MonkeyLow BananaHigh MonkeyGetBanana)}
Informal Semantics:
“If the monkey climbs onto the box, he becomes high in position (not low anymore) and can get the banana.”
Formal Semantics:
I(MonkeyLow) = F
I(BananaHigh) = T I(MonkeyClimbBox)
= T
I(MonkeyGetBanana) = T
MODEL#2
MODELING :: LOGICAL MODELING :: HOW TO USE LOGICAL MODELING :: REASONING SERVICES :: EXPRESSIVENESS
24
Same theory, different models (MODEL#3) L = {MonkeyLow, BananaHigh, MonkeyClimbBox,
MonkeyGetBanana, , , }
T = { (MonkeyLow BananaHigh MonkeyGetBanana)
(MonkeyLow MonkeyClimbBox)
( MonkeyLow BananaHigh MonkeyGetBanana)}
Informal Semantics:
“If the monkey is low and the banana is also low, then the monkey can get the banana. “
Formal Semantics:
I(MonkeyLow) = T
I(BananaHigh) = F I(MonkeyClimbBox)
= F
I(MonkeyGetBanana) = T
MODEL#3
MODELING :: LOGICAL MODELING :: HOW TO USE LOGICAL MODELING :: REASONING SERVICES :: EXPRESSIVENESS
25
How to use logical modeling
25
1. Define a logic most often by reseachers once for all (not a trivial task!)
2. Choose the right logic for the problem Given a problem the computer scientist must choose
the right logic, most often one of the many available
3. Write the theory The computer scientist writes a theory T
4. Use reasoning services The computer scientist uses reasoning services to
solve her programs
MODELING :: LOGICAL MODELING :: HOW TO USE LOGICAL MODELING :: EXPRESSIVENESSMODELING :: LOGICAL MODELING :: HOW TO USE LOGICAL MODELING :: REASONING SERVICES :: EXPRESSIVENESS
26
What is a Logic? Logic = <L, I, ⊨ > where
L LanguageSet of phrases/sentences/formulas (alphabet + formation rules)
I Interpretation functionWhat phrases mean in a chosen domain Dwith I: L -> D
⊨ Satisfiability relation (over M)How to compute the fact that a formula A
is TRUE in M, notationally M ⊨ A
A ⊨ B in M iff M ⊨ A implies M ⊨ B
26
MODELING :: LOGICAL MODELING :: HOW TO USE LOGICAL MODELING :: REASONING SERVICES :: EXPRESSIVENESS
27
Choose the right logic for the problem
27
Problem: the LDKR class
Specification:
“In the LDKR class Fausto is the professor. There are 6 students. They are Mary, Paul, Jane, Rui, Hugo and Sara”.
Formalization: We want to represent both classes
of objects (Professor, Student) and individuals (Mary, Paul…)
Choose a logic that allows for them, e.g. ClassL with Individuals
Fausto
Mary Paul Jane
HugoSaraRui
L = {Professor, Student , ∧, ∨, ¬, →}
D = {Fausto, Mary, Paul, Jane, Rui, Sara, Hugo}
MODELING :: LOGICAL MODELING :: HOW TO USE LOGICAL MODELING :: REASONING SERVICES :: EXPRESSIVENESS
28
Define the theory for the problem
28
L = {Professor, Student , ∧, ∨, ¬, →}
D = {Fausto, Mary, Paul, Jane, Rui, Sara, Hugo}
In the theory we want to model the fact that the set of professors is always disjoint from the set of students…
Fausto
Mary Paul Jane
HugoSaraRui
T = {Student → ¬ Professor; Professor → ¬ Student}
M
I(Professor) = {Fausto}
I(Student) = {Mary, Paul, Jane, Rui, Sara, Hugo}
M ⊨T
Then we can use reasoning services to handle our problem
MODELING :: LOGICAL MODELING :: HOW TO USE LOGICAL MODELING :: REASONING SERVICES :: EXPRESSIVENESS
29
Reasoning Services: EVALModel Checking (EVAL)Is a sentence ψ true in model M?
Check M ⊨ ψ
EVALψ , MYes, M ⊨ ψ
No, M ⊭ ψ
MODELING :: LOGICAL MODELING :: HOW TO USE LOGICAL MODELING :: REASONING SERVICES :: EXPRESSIVENESS
3030
EVAL L = {MonkeyLow, BananaHigh, MonkeyClimbBox,
MonkeyGetBanana, , , }
T = { (MonkeyLow BananaHigh MonkeyGetBanana)
(MonkeyLow MonkeyClimbBox)
( MonkeyLow BananaHigh MonkeyGetBanana)}
I(MonkeyLow) = T
I(BananaHigh) = T I(MonkeyClimbBox)
= F
I(MonkeyGetBanana) = F
Evaluate ψ1 and ψ2 in M
ψ1 = MonkeyClimbBox is true in M (YES)
ψ2 = MonkeyGetBanana is false in M (NO)
M
MODELING :: LOGICAL MODELING :: HOW TO USE LOGICAL MODELING :: REASONING SERVICES :: EXPRESSIVENESS
31
Reasoning Services: SATSatisfiability (SAT)Is there a model M where ψ is true?
find M such that M ⊨ ψ
SATψM
No
MODELING :: LOGICAL MODELING :: HOW TO USE LOGICAL MODELING :: REASONING SERVICES :: EXPRESSIVENESS
3232
SAT L = {MonkeyLow, BananaHigh, MonkeyClimbBox,
MonkeyGetBanana, , , }
T = { (MonkeyLow BananaHigh MonkeyGetBanana)
(MonkeyLow MonkeyClimbBox)
( MonkeyLow BananaHigh MonkeyGetBanana)}
I(MonkeyLow) = F
I(BananaHigh) = T I(MonkeyClimbBox)
= T
I(MonkeyGetBanana) = T
ψ = MonkeyGetBanana
Is there a model M where ψ is true? (YES, the model on the left)
SAT is a search problem (find a model M)
MODELING :: LOGICAL MODELING :: HOW TO USE LOGICAL MODELING :: REASONING SERVICES :: EXPRESSIVENESS
33
Reasoning Services: VALValidity (VAL) Is ψ true according to all possible models?
Check whether for all M, M ⊨ ψ
VALψYes
No
MODELING :: LOGICAL MODELING :: HOW TO USE LOGICAL MODELING :: REASONING SERVICES :: EXPRESSIVENESS
3434
VAL L = {MonkeyLow, BananaHigh, MonkeyClimbBox,
MonkeyGetBanana, , , }
T = { (MonkeyLow BananaHigh MonkeyGetBanana)
(MonkeyLow MonkeyClimbBox)
( MonkeyLow BananaHigh MonkeyGetBanana)}
I(MonkeyLow) = F
I(BananaHigh) = T I(MonkeyClimbBox) = T
I(MonkeyGetBanana) = F
ψ = MonkeyLow MonkeyGetBananaIs ψ true according to all possible model M? (No, the monkey can be high without getting the banana)
VAL is a search problem (check ψ in all M)NOTE: It is enough to find a counterexample to conclude for non validity
MODELING :: LOGICAL MODELING :: HOW TO USE LOGICAL MODELING :: REASONING SERVICES :: EXPRESSIVENESS
35
Reasoning Services: ENTEntailment (ENT) ψ1 true in M (all models) implies ψ2 true in M (all models)
check A ⊨ B in M by checking M ⊨ A implies M ⊨ B
ENTψ1 , ψ2, MYes, ψ1 ⊨ ψ2
No
MODELING :: LOGICAL MODELING :: HOW TO USE LOGICAL MODELING :: REASONING SERVICES :: EXPRESSIVENESS
3636
ENT L = {MonkeyLow, BananaHigh, MonkeyClimbBox,
MonkeyGetBanana, , , }
T = { (MonkeyLow BananaHigh MonkeyGetBanana)
(MonkeyLow MonkeyClimbBox)
( MonkeyLow BananaHigh MonkeyGetBanana)}
ψ1 = MonkeyClimbBoxψ2 = MonkeyLowψ1 true in M (all models) implies ψ2 is true in M (all models). (Yes)
NOTE: ψ1 entails ψ2 in all models
MODELING :: LOGICAL MODELING :: HOW TO USE LOGICAL MODELING :: REASONING SERVICES :: EXPRESSIVENESS
37
An Important Trade-Off There is a trade-off between:
expressive power (expressiveness) and computational efficiency provided by a (logical)
language
This trade-off is a measure of the tension between specification and automation
To use logic for modeling, the modeler must find the right trade off between expressiveness in the language for more tractable forms of reasoning services.
37
MODELING :: LOGICAL MODELING :: HOW TO USE LOGICAL MODELING :: REASONING SERVICES :: EXPRESSIVENESS
38
Examples of Expressiveness
38
LANGUAGE NL SENTENCE FORMULA
Propositional logic
Fausto likes skiing
I like skiing
Fausto-likes-skiing
I-like-skiing
Modal logic I believe I like skiing B(I-like-skiing)
First-order logic Every person likes skiing
I like skiing
Fausto likes skiing
∀ person.like-skiing(person)
like-skiing(I)
like-skiing(Fausto)
Description Logic
Every person likes cars person ⊑ ∃ likes.Car
…
MODELING :: LOGICAL MODELING :: HOW TO USE LOGICAL MODELING :: REASONING SERVICES :: EXPRESSIVENESS
39
Efficiency VS. Complexity Efficiency
Performing in the best possible manner; satisfactory and economical to use [Webster]
In modeling it applies to reasoning We use the more specific term computational
complexity (time, space,...)
Complexity (or computational complexity) of reasoning It is the difficulty to compute a reasoning task
expressed by using a logic With degrees of expressiveness, we may classify the
logical languages according to some “degrees of complexity”
39
MODELING :: LOGICAL MODELING :: HOW TO USE LOGICAL MODELING :: REASONING SERVICES :: EXPRESSIVENESS
40
Degrees of Complexity
40
The more you specify, the more cost grows
CO
ST
& P
RE
CIS
ION
OF
TH
E
SP
EC
IFIC
AT
ION
Natural Language Diagram Logics
FORMALITY
0
1000000
2000000
3000000
4000000
5000000
6000000
7000000
8000000
9000000
10000000
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
MODELING :: LOGICAL MODELING :: HOW TO USE LOGICAL MODELING :: REASONING SERVICES :: EXPRESSIVENESS
4141
When is the use of logics appropriate?
When logic is used we always pay a performance price
We therefore use it when it is cost-effectiveTo prove correctness (offline use)To draw conclusions (online use)
MODELING :: LOGICAL MODELING :: HOW TO USE LOGICAL MODELING :: REASONING SERVICES :: EXPRESSIVENESS
4242
Examples of offline use (specification)For data and knowledge representation
In safety-critical applicationsTrainsPlanes…
In security critical applicationsbank transactions…
MODELING :: LOGICAL MODELING :: HOW TO USE LOGICAL MODELING :: REASONING SERVICES :: EXPRESSIVENESS
4343
Examples of online use (reasoning) To let programs interoperate
Web 1.0 Web 2.0
LET PEOPLE INTEROPERATE
(informal semantics)
Web 3.0
LET PROGRAMS INTEROPERATE
(formal semantics)
MODELING :: LOGICAL MODELING :: HOW TO USE LOGICAL MODELING :: REASONING SERVICES :: EXPRESSIVENESS
44
Decidability The existence of an effective method to
determine the validity of formulas in a logical language
A logic is decidable if there is an effective method to determine whether arbitrary formulas are included in a theory
A decision procedure is an algorithm that, given a decision problem, terminates with the correct yes/no answer.
In this course we focus on logics that are expressive enough to model real problems but are still decidable
44
MODELING :: LOGICAL MODELING :: HOW TO USE LOGICAL MODELING :: REASONING SERVICES :: EXPRESSIVENESS