dk r logics for data and knowledge representation languages for data representation originally by...
TRANSCRIPT
Logics for DData and KKnowledge RRepresentation
Languages for Data Representation
Originally by Alessandro Agostini and Fausto GiunchigliaModified by Fausto Giunchiglia, Rui Zhang and Vincenzo Maltese
2
Outline Key notions Model Language
Natural Language ER UML
Formal models Using Languages: Specification & Automation Theory: data and knowledge
Key notions
3
THEWORLD
MODELLANGUAGE
+THEORY
(Abstraction)
Modeling
Realization
Representation
Interpretation
Monkey
Banana
MonkeyEatsBanana
Semantic Gap
KEY NOTIONS :: MODEL :: LANGUAGE :: FORMAL MODELS :: SPECIFICATION & AUTOMATION :: THEORY
4
Model for the world
DOMAIN(e.g. the girls in foreground)
INDIVIDUAL
SET
RELATION(e.g. Near, Sister)
A model is an abstraction of a part of the world
KEY NOTIONS :: MODEL :: LANGUAGE :: FORMAL MODELS :: SPECIFICATION & AUTOMATION :: THEORY
5
A (usually finite) set of words (the alphabet) and rules to compose them to build “correct sentences” e.g. Monkey and GetBanana are words e.g. Monkey GetBanana is a sentence (rule: A B)
A tool for codifying our (mental) model (what we have in mind): Sentences (syntax) with an intended meaning
(semantics) e.g. with the word Monkey we mean
Language
KEY NOTIONS :: MODEL :: LANGUAGE :: FORMAL MODELS :: SPECIFICATION & AUTOMATION :: THEORY
6
We need an algorithm for checking correctness of the sentences in a language
Language and correctness
PARSERs, LYes, correct!
No
We say that a language is decidable if it is possible to create such a tool that in finite time can take the decision
KEY NOTIONS :: MODEL :: LANGUAGE :: FORMAL MODELS :: SPECIFICATION & AUTOMATION :: THEORY
Syntax and Semantics Syntax: the way a language is written:
Syntax is determined by a set of rules saying how to construct the expressions of the language from the set of atomic tokens (i.e., terms, characters, symbols).
The set of atomic tokens is called alphabet of symbols, or simply the alphabet).
Semantics: the way a language is interpreted: It determines the meaning of the syntactic constructs
(expressions), that is, the relationship between syntactic constructs and the elements of some universe of meanings (the intended model).
Such relationship is called interpretation.
KEY NOTIONS :: MODEL :: LANGUAGE :: FORMAL MODELS :: SPECIFICATION & AUTOMATION :: THEORY
Example of Syntax and Semantics Suppose we want to represent the fact that
Mary and Sara are near each other.
ENGLISH
Mary is near Sara.
formal syntax, informal semantics
‘SYMBOLIZED’ ENGLISH
near(M,S)
near(Mary, Sara)
formal syntax, informal semantics
LOGICS with an interpretation function I
“near” by I means near as spatial relation
“M” by I means Mary the girl
“S” by I means Sara the girl
formal syntax, formal semantics
KEY NOTIONS :: MODEL :: LANGUAGE :: FORMAL MODELS :: SPECIFICATION & AUTOMATION :: THEORY
9
Formal vs. Informal languages Language = Syntax (what we write) + Semantics (what we
mean)
Formal syntax Infinite/finite (always recognizable) alphabet Finite set of formal constructors and building rules for
phrase construction Algorithm for correctness checking (a phrase in a language)
Formal Semantics The relationship between syntactic constructs in a
language L and the elements of an universe of meanings D is a (mathematical) function I: L pow(D)
Informal syntax/semantics the opposite of formal, namely the absence of the elements
above.
KEY NOTIONS :: MODEL :: LANGUAGE :: FORMAL MODELS :: SPECIFICATION & AUTOMATION :: THEORY
Levels of Formalization
LogicsDiagramsNLProgramming
Languages
EnglishItalian
RussianHindi
...
ERUML...
SQL...
PLFOLDL...
Both Syntax and Semantics can be formal or informal.
Level1 Leveln
FORMALITY
informal semi-formal formal
10
KEY NOTIONS :: MODEL :: LANGUAGE :: FORMAL MODELS :: SPECIFICATION & AUTOMATION :: THEORY
11
Natural Language Let us try to recognize relevant entities, relations
and properties in the NL text below
The Monkey-Bananas (MB) problem by McCarthy, 1969“ There is a monkey in a laboratory with some bananas hanging out of reach from the ceiling. A box is available that will enable the monkey to reach the bananas if he climbs on it. The monkey and box have height Low, but if the monkey climbs onto the box he will have height High, the same as the bananas. [...]”
Question:How shall the monkey reach the bananas?
KEY NOTIONS :: MODEL :: LANGUAGE :: FORMAL MODELS :: SPECIFICATION & AUTOMATION :: THEORY
12
Possible mental models“ There is a monkey in a laboratory with some bananas hanging out of reach from the ceiling. A box is available that will enable the monkey to reach the bananas if he climbs on it. The monkey and box have height Low, …
… but if the monkey climbs onto the box he will have height High, the same as the bananas. [...]”
NOTE: each picture is a different model
KEY NOTIONS :: MODEL :: LANGUAGE :: FORMAL MODELS :: SPECIFICATION & AUTOMATION :: THEORY
13
E-R Schemas Data representation models for databases design
under the Entity-Relationship Model [Chen 1976].
In E-R the “alphabet “ is a set of graphical objects, that are used to construct schemas (the sentences): Entity (or Class) Relation (or Association) Attribute (simple and composed) … + arrows and various notation
Entity Relation Attribute
KEY NOTIONS :: MODEL :: LANGUAGE :: FORMAL MODELS :: SPECIFICATION & AUTOMATION :: THEORY
14
The E-R Constructs (1) Entity: class of objects with same
properties. These denote/contain individuals
Relation: relations among entities.
Attribute: properties of entities
Entity Identificator: ID which provides unique identification of an entity.
14
Monkey
Climb
Height
KEY NOTIONS :: MODEL :: LANGUAGE :: FORMAL MODELS :: SPECIFICATION & AUTOMATION :: THEORY
15
The E-R Constructs (2) Cardinality of Relation: min/max number of
objects in an entity that may be related by a relation to an object in a different entity.
Cardinality of Attribute: range of values of an attribute of an entity or a relation.
Monkey Box
Climb
0..1 0..n
Banana Height
KEY NOTIONS :: MODEL :: LANGUAGE :: FORMAL MODELS :: SPECIFICATION & AUTOMATION :: THEORY
16
The E-R Constructs (3) Generalization: logical
relationship between an entity E (father entity) and a set of entities E1...Ei...En (child entities).
For each i, E generalizes Ei and Ei specializes E.
Ei is a subset of E (IS-A relation).
Properties of E are also of Ei (inheritance), but not necessarily vice versa.
E
E1 Ei En
Animal
Monkey Dog Tiger
KEY NOTIONS :: MODEL :: LANGUAGE :: FORMAL MODELS :: SPECIFICATION & AUTOMATION :: THEORY
17
Example of Monkey and Bananas in ER
Monkey
Banana
Box
Climb
Height
Height
The squares represent monkeys, bananas and boxes. The attribute “height” may have either value “high” or “low”. The diamonds “Climb” and “Get” are binary relations.
NOTE: here the syntax is formal, semantics is not
Get
Height
KEY NOTIONS :: MODEL :: LANGUAGE :: FORMAL MODELS :: SPECIFICATION & AUTOMATION :: THEORY
18
UML (Unified Modeling Language)Representation language to model data,
operations, processes, architectures.
From software engineering under the paradigm of object-oriented programming.
UML class diagrams useful in database design as well as the E-R schemas.
KEY NOTIONS :: MODEL :: LANGUAGE :: FORMAL MODELS :: SPECIFICATION & AUTOMATION :: THEORY
19
UML Class DiagramsBasic components of an UML class diagram
Class Association.
Classes and associations correspond to entities and relations in the E-R schemas.
The elements in a class are called instances.The world here is a set of instances.
Class A
Attribute
Method
Class B
Attribute
Method
1 0..*
KEY NOTIONS :: MODEL :: LANGUAGE :: FORMAL MODELS :: SPECIFICATION & AUTOMATION :: THEORY
20
Example of Monkey and Bananas in UML
Monkey
Height
…
Box
Height
…
Banana
Height
…
Climb
1
0..1
Get
1
0..*
A monkey can climb from 0 to 1 box. A monkey can get 0 or more bananas.
NOTE: here the syntax is formal, semantics is not
KEY NOTIONS :: MODEL :: LANGUAGE :: FORMAL MODELS :: SPECIFICATION & AUTOMATION :: THEORY
“The author of Romeo and Juliet is Shakespeare”author(R&G, Shakespeare)GirlsPlaying = {Mary, Sara, Julie}
“Bananas are yellow” “Bananas have a curve shape”“All men are mortal” man mortalGirlsPlaying = True
Intensional vs Extensional semantics Intensional: I can only express the fact that a
given proposition is true or false
Extensional: I provide the objects of the domain corresponding to the proposition
KEY NOTIONS :: MODEL :: LANGUAGE :: FORMAL MODELS :: SPECIFICATION & AUTOMATION :: THEORY
22
Logic Logics has two fundamental components:
L is a formal language I is an interpretation function which maps sentences into
a formal model M (over all possible ones) with a domain D
Language L = {A,,,} Domain D = {T, F} or D’ = {o1, …, on}
I: L D is intensional or I: L pow(D’) is extensional
Theory A set of sentences which are true in the language It can be seen a set of constraints on possible models to
filter out all undesired ones
KEY NOTIONS :: MODEL :: LANGUAGE :: FORMAL MODELS :: SPECIFICATION & AUTOMATION :: THEORY
23
Formal Extensional Model A (formal) model is an abstraction of a part of the
world
An extensional model is a triple M = <D, A, R>D = domain (a is in D). The set of objects of interest.A = set of attributes (a has attribute A). Subsets of D.R = set of relations (a is in relation with b).
Subset of Cartesian products A×B, with A and B subsets of D, r = <a, b> is a pair of objects.
In other words, M is an assignment over all possible ones which satisfies the theory T
NOTE: we can easily extend to n-ary relations
KEY NOTIONS :: MODEL :: LANGUAGE :: FORMAL MODELS :: SPECIFICATION & AUTOMATION :: THEORY
24
Example of a formal (extensional) modelD = {Cita, box1, box2, B1, B2, B3}
L = {Monkey, Banana, High, Box, Climbs, Gets, , , }
A = {Monkey, Banana, High, Box} R = {Climbs, Gets}
I (Monkey) = {Cita}I (Box) = {box1, box2}I (Banana) = {B1, B2, B3}
I (High) = {Cita, B1, B2, B3}I (Climbs) = {<Cita, box2>}I (Gets) = {<Cita, B3>}
Cita
B1 B2 B3
box1 box2
KEY NOTIONS :: MODEL :: LANGUAGE :: FORMAL MODELS :: SPECIFICATION & AUTOMATION :: THEORY
25
Formal Intensional Model A (formal) model is an abstraction of a part of the
world
An intensional model is a pair M = <D, P>D = domain (a is in D). The set of objects of interest.P = set of propositions (P is true/false).
In other words, M is an assignment over all possible ones which satisfies the theory T
NOTE: we do not have relations in intensional models
KEY NOTIONS :: MODEL :: LANGUAGE :: FORMAL MODELS :: SPECIFICATION & AUTOMATION :: THEORY
26
Example of a formal (intensional) modelD = {T, F}
L = {Monkey, Banana, High, Box, Climbs, Gets , , }
P(Monkey) = “there exists a monkey”
I (Monkey) = TI (Banana) = TI (Box) = T
I (High) = TI (Climbs) = TI (Gets) = T
Cita
B1 B2 B3
box1 box2
PROPOSITION
KEY NOTIONS :: MODEL :: LANGUAGE :: FORMAL MODELS :: SPECIFICATION & AUTOMATION :: THEORY
27
Formal semantics for diagrams (e.g. E-R)
Monkey
Banana
BoxClimb
Height
HeightGet
Height
MonkeyDomain = {
Attribute = {
Relation = {
Banana, Box, }
Height }
Get , Climb }
The domain contains the instances of the classes here
NOTE: We have made both the syntax and the semantics formal
KEY NOTIONS :: MODEL :: LANGUAGE :: FORMAL MODELS :: SPECIFICATION & AUTOMATION :: THEORY
28
Uses of Data Representation Languages The two purposes in modeling
Specification: Representation of the problem at the proper level of
abstraction Allow informal/formal syntax and informal/formal semantics
Automated Reasoning (Automation) Computing consequences or properties of the chosen
specifications It requires formal semantics.
Logics have formal syntax and formal semantics!
KEY NOTIONS :: MODEL :: LANGUAGE :: FORMAL MODELS :: SPECIFICATION & AUTOMATION :: THEORY
29
Why Natural Languages?
Used for Advantages Disadvantages
For informal specification
Often used at the very beginning of problem solving, when we need a direct, “flexible”, well-understood language and the problem is still largely unclear
Useful to interact with users
Semantics is informal, largely ambiguous
Pragmatically inefficient for automation
KEY NOTIONS :: MODEL :: LANGUAGE :: FORMAL MODELS :: SPECIFICATION & AUTOMATION :: THEORY
30
Why Diagrams?
Used for Advantages Disadvantages
To provide more structured and organized specification than natural languages
Informal/formal syntax (depends on the kind of diagram)
Largely structured and organized; usually used in representation with unified languages when things are non-trivial or more precision is required w.r.t. Natural Language
Useful to interact with users
Semantics is informal, largely ambiguous
Pragmatically inefficient for automation
KEY NOTIONS :: MODEL :: LANGUAGE :: FORMAL MODELS :: SPECIFICATION & AUTOMATION :: THEORY
31
Why Logic?
Used for Advantages Disadvantages
Formal specification
Automation
Well-understood with formal syntax and formal semantics: we can better specify and prove correctness
Pragmatically efficient for automation exploiting the explicitly codified semantics: reasoning services
It cannot be used to interact with users
An exponential grow in cost (computational, man power)
KEY NOTIONS :: MODEL :: LANGUAGE :: FORMAL MODELS :: SPECIFICATION & AUTOMATION :: THEORY
32
Logics, formal syntax and formal semanticA logic is a representation language with
a formal syntax a formal semantics
Any language can have these characteristics eg., using mathematical notation, textual, graphical,
…
As formal languages, logics are suitable for: representing (specification) reasoning (automation) about data and knowledge.
KEY NOTIONS :: MODEL :: LANGUAGE :: FORMAL MODELS :: SPECIFICATION & AUTOMATION :: THEORY
33
Logics for SpecificationLogic as a formal language
is good for the specification (representation) of knowledge
Logic as a formal semantics is good for specification of declarative data and
knowledge (as different from programs)
The meaning of sentences is declaratively defined, i.e. with logic we describe what holds without caring about how it can be computed.
KEY NOTIONS :: MODEL :: LANGUAGE :: FORMAL MODELS :: SPECIFICATION & AUTOMATION :: THEORY
34
Specification / Representation 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
KEY NOTIONS :: MODEL :: LANGUAGE :: FORMAL MODELS :: SPECIFICATION & AUTOMATION :: THEORY
35
Logics for ReasoningLogics provides a notion of deduction
axioms, deductive machinery, theorem
Deduction can be used to implement reasoners
Reasoners allow inferring conclusions from a given knowledge base (i.e, a set of “premises”, premises can be axioms or theorems).
From implicit knowledge to explicit knowledge
KEY NOTIONS :: MODEL :: LANGUAGE :: FORMAL MODELS :: SPECIFICATION & AUTOMATION :: THEORY
36
Reasoning / Automation L = {MonkeyLow, BananaHigh, MonkeyClimbBox,
MonkeyGetBanana, , , }
T = { (MonkeyLow BananaHigh MonkeyGetBanana)
(MonkeyLow MonkeyClimbBox)
( MonkeyLow BananaHigh MonkeyGetBanana)}
MODEL#1
Given that:
MonkeyLow = T
BananaHigh = T
We derive that:
MonkeyGetBanana = F
KEY NOTIONS :: MODEL :: LANGUAGE :: FORMAL MODELS :: SPECIFICATION & AUTOMATION :: THEORY
Theory, data and knowledge Theory: A set of statements which describe the (part of
the) world as abstracted in the (mental) model Data: Factual information from which conclusions
may be drawn Useful irrelevant or redundant facts, which must be
processed to be meaningful. Used as a basis for reasoning, discussion or calculation
(Merriam-Webster). Knowledge: How to use a language to represent and
structure the facts. The sum of what is known.Knowledge is data in context, or organized data, or also data in relationship.
KEY NOTIONS :: MODEL :: LANGUAGE :: FORMAL MODELS :: SPECIFICATION & AUTOMATION :: THEORY
English:“There are 3 girls playing on the snow. Their names are Mary, Julie and Sara.”
Java:G1 = new Girl(“Mary”); G2 = new Girl(“Julie”); G3 = new Girl(“Sara)”;
Diagram:
FOL:Girl(Mary) Girl(Julie) Girl(Sara)
Data in the Example
GIRL
MaryJulieSara
KEY NOTIONS :: MODEL :: LANGUAGE :: FORMAL MODELS :: SPECIFICATION & AUTOMATION :: THEORY
Knowledge in the Example English
“There are 3 girls playing on the snow. Their names are Mary...”
JavaClass Girl(String name); G1 = new Girl(“Mary”);
G1.Playing(G2); …
Diagram
FOL x,y Girl(x) Girl(y) Play(x,y)
GIRL PLAY
KEY NOTIONS :: MODEL :: LANGUAGE :: FORMAL MODELS :: SPECIFICATION & AUTOMATION :: THEORY
Data vs. Knowledge in different aspects
Data A factual output of
physical device Bare facts Isolated facts Direct facts …
Observed
Knowledge Statement on how a
class is related to another
Organized facts Related facts Processed facts …
Axioms + theorems (inference/deduction/
reasoning)
KEY NOTIONS :: MODEL :: LANGUAGE :: FORMAL MODELS :: SPECIFICATION & AUTOMATION :: THEORY
Using logics in practice: a summary What is a logic for?
Specification Automation
Why logic? Advantages of a logical framework:
Precise Syntax Precise Semantics Reasoning mechanisms
Which logic? Tradeoff Expressiveness ↔ Complexity Different problems, different logics
How to represent?
42
Appendix: Greek lettersΑα Alpha Νν Nu
Ββ Beta Ξξ Xi
Γγ Gamma Οο Omicron
Δδ Delta Ππ Pi
Εε Epsilon Ρρ Rho
Ζζ Zeta Σσς Sigma
Ηη Eta Ττ Tau
Θθ Theta Υυ Upsilon
Ιι Iota Φφ Phi
Κκ Kappa Χχ Chi
Λλ Lamdba Ψψ Psi
Μμ Mu Ωω Omega