Logics for D ata and K nowledge R epresentation

42
Logics for D Data and K Knowledge R Representation Languages for Data Representation Originally by Alessandro Agostini and Fausto Giunchiglia Modified by Fausto Giunchiglia, Rui Zhang and Vincenzo Maltese

description

Logics for D ata and K nowledge R epresentation. Languages for Data Representation. Originally by Alessandro Agostini and Fausto Giunchiglia Modified by Fausto Giunchiglia, Rui Zhang and Vincenzo Maltese. Outline. Key notions Model Language Natural Language ER UML Formal models - PowerPoint PPT Presentation

Transcript of Logics for D ata and K nowledge R epresentation

Page 1: Logics for  D ata and  K nowledge  R epresentation

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

Page 2: Logics for  D ata and  K nowledge  R epresentation

2

Outline Key notions Model Language

Natural Language ER UML

Formal models Using Languages: Specification & Automation Theory: data and knowledge

Page 3: Logics for  D ata and  K nowledge  R epresentation

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

Page 4: Logics for  D ata and  K nowledge  R epresentation

4

Model for the world

DOMAIN(e.g. the girls in foreground)

INDIVIDUALSET

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

Page 5: Logics for  D ata and  K nowledge  R epresentation

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

LanguageKEY NOTIONS :: MODEL :: LANGUAGE :: FORMAL MODELS :: SPECIFICATION & AUTOMATION :: THEORY

Page 6: Logics for  D ata and  K nowledge  R epresentation

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

Page 7: Logics for  D ata and  K nowledge  R epresentation

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

Page 8: Logics for  D ata and  K nowledge  R epresentation

Example of Syntax and Semantics Suppose we want to represent the fact that Mary

and Sara are near each other.ENGLISHMary is near Sara.

formal syntax, informal semantics

‘SYMBOLIZED’ ENGLISHnear(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

Page 9: Logics for  D ata and  K nowledge  R epresentation

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

Page 10: Logics for  D ata and  K nowledge  R epresentation

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 formal10

KEY NOTIONS :: MODEL :: LANGUAGE :: FORMAL MODELS :: SPECIFICATION & AUTOMATION :: THEORY

Page 11: Logics for  D ata and  K nowledge  R epresentation

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

Page 12: Logics for  D ata and  K nowledge  R epresentation

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

Page 13: Logics for  D ata and  K nowledge  R epresentation

13

E-R SchemasData 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

Page 14: Logics for  D ata and  K nowledge  R epresentation

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

Page 15: Logics for  D ata and  K nowledge  R epresentation

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

Page 16: Logics for  D ata and  K nowledge  R epresentation

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

Page 17: Logics for  D ata and  K nowledge  R epresentation

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

Page 18: Logics for  D ata and  K nowledge  R epresentation

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

Page 19: Logics for  D ata and  K nowledge  R epresentation

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 AAttributeMethod

Class BAttributeMethod

1 0..*

KEY NOTIONS :: MODEL :: LANGUAGE :: FORMAL MODELS :: SPECIFICATION & AUTOMATION :: THEORY

Page 20: Logics for  D ata and  K nowledge  R epresentation

20

Example of Monkey and Bananas in UML

MonkeyHeight…

BoxHeight…

BananaHeight…

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

Page 21: Logics for  D ata and  K nowledge  R epresentation

“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

Page 22: Logics for  D ata and  K nowledge  R epresentation

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

Page 23: Logics for  D ata and  K nowledge  R epresentation

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

Page 24: Logics for  D ata and  K nowledge  R epresentation

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

Page 25: Logics for  D ata and  K nowledge  R epresentation

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

Page 26: Logics for  D ata and  K nowledge  R epresentation

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

Page 27: Logics for  D ata and  K nowledge  R epresentation

27

Formal semantics for diagrams (e.g. E-R)

Monkey

Banana

BoxClimb

Height

HeightGet

Height

MonkeyDomain = {

Attribute = {

Relation = {

Banana, Box, }Heigh

t }Get , Clim

b }

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

Page 28: Logics for  D ata and  K nowledge  R epresentation

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

Page 29: Logics for  D ata and  K nowledge  R epresentation

29

Why Natural Languages?Used for Advantages DisadvantagesFor 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

Page 30: Logics for  D ata and  K nowledge  R epresentation

30

Why Diagrams?Used for Advantages DisadvantagesTo 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

Page 31: Logics for  D ata and  K nowledge  R epresentation

31

Why Logic?Used for Advantages DisadvantagesFormal 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

Page 32: Logics for  D ata and  K nowledge  R epresentation

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

Page 33: Logics for  D ata and  K nowledge  R epresentation

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

Page 34: Logics for  D ata and  K nowledge  R epresentation

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) = TI(BananaHigh) = T I(MonkeyClimbBox) = FI(MonkeyGetBanana) = F

MODEL#1

KEY NOTIONS :: MODEL :: LANGUAGE :: FORMAL MODELS :: SPECIFICATION & AUTOMATION :: THEORY

Page 35: Logics for  D ata and  K nowledge  R epresentation

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

Page 36: Logics for  D ata and  K nowledge  R epresentation

36

Reasoning / Automation L = {MonkeyLow, BananaHigh, MonkeyClimbBox,

MonkeyGetBanana, , , } T = { (MonkeyLow BananaHigh MonkeyGetBanana) (MonkeyLow MonkeyClimbBox) ( MonkeyLow BananaHigh MonkeyGetBanana)}

MODEL#1

Given that: MonkeyLow = TBananaHigh = T

We derive that:MonkeyGetBanana = F

KEY NOTIONS :: MODEL :: LANGUAGE :: FORMAL MODELS :: SPECIFICATION & AUTOMATION :: THEORY

Page 37: Logics for  D ata and  K nowledge  R epresentation

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

Page 38: Logics for  D ata and  K nowledge  R epresentation

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

GIRLMaryJulieSara

KEY NOTIONS :: MODEL :: LANGUAGE :: FORMAL MODELS :: SPECIFICATION & AUTOMATION :: THEORY

Page 39: Logics for  D ata and  K nowledge  R epresentation

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

Page 40: Logics for  D ata and  K nowledge  R epresentation

Data vs. Knowledge in different aspectsData 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

Page 41: Logics for  D ata and  K nowledge  R epresentation

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?

Page 42: Logics for  D ata and  K nowledge  R epresentation

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