Logics for Data and Knowledge Representation Languages for Data Representation First version by...

44
Logics for Data and Knowledge Representation Languages for Data Representation First version by Alessandro Agostini and Fausto Giunchiglia Second version by Fausto Giunchiglia and Rui Zhang 9/2009

Transcript of Logics for Data and Knowledge Representation Languages for Data Representation First version by...

Logics for Data and Knowledge Representation

Languages for Data Representation

First version by Alessandro Agostini and Fausto Giunchiglia Second version by Fausto Giunchiglia and Rui Zhang 9/2009

OutlineModelLanguage

Natural Language ER UML Logic

Using LanguagesSpecification & AutomationServicesUsing logics

First version by Alessandro Agostini and Fausto Giunchiglia Second version by Fausto Giunchiglia and Rui Zhang

9/2009

Model

A model is an abstraction of a part of the world

First version by Alessandro Agostini and Fausto Giunchiglia Second version by Fausto Giunchiglia and Rui Zhang

9/2009

OutlineModelLanguage

Natural Language ER UML Logic

Using LanguagesSpecification & AutomationServicesUsing logics

First version by Alessandro Agostini and Fausto Giunchiglia Second version by Fausto Giunchiglia and Rui Zhang

9/2009

LanguageLanguage : A (usually infinite) set of expressions

(phrases), and rules to form expressions, with a notion of “correct phrase” (a phrase member of a language). Often an algorithm for checking correctness

A tool for codifying the (mental) model (what we have in mind)

Expressions Meaning

Syntax

Semantics

BossBoss

First version by Alessandro Agostini and Fausto Giunchiglia Second version by Fausto Giunchiglia and Rui Zhang

9/2009

Formal vs. Informal languages Recall the composition of a language

Language = Syntax + Semantics 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 and the elements of an universe of meanings is a (mathematical) function

Informal syntax/ semantics: the opposite of formal

First version by Alessandro Agostini and Fausto Giunchiglia Second version by Fausto Giunchiglia and Rui Zhang

9/2009

Levels of Formalization (update)Both Syntax and Semantics can be formal or informal.

NOTE: formal Semantics only with formal syntax.

7

LogicsDiagramsNLsProgrammingLanguages

EnglishItalianRussianHindi...

ERUML...

SQL...

PLFOLDL...

0 1

First version by Alessandro Agostini and Fausto Giunchiglia Second version by Fausto Giunchiglia and Rui Zhang

9/2009

Natural LanguageMonkey-Bananas (MB) 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?

First version by Alessandro Agostini and Fausto Giunchiglia Second version by Fausto Giunchiglia and Rui Zhang

9/2009

E-R SchemasData representation models for databases

design under the Entity-Relationship Model [Chen 1976].

It provides basic “alphabet “ (constructs for schemas: Entity (or Class) Relation (or Association) Attribute (simple and composed) … + arrows and various notation

9

Entity Relation Attribute

First version by Alessandro Agostini and Fausto Giunchiglia Second version by Fausto Giunchiglia and Rui Zhang

9/2009

The E-R Constructs (1)

Entity: class of objects with same properties. These are individuals (objects)

Relation: relations among entities.

Attribute: properties of entities

10First version by Alessandro Agostini and Fausto Giunchiglia Second version by Fausto Giunchiglia and Rui Zhang

Bananas

Climb

Height

9/2009

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.

Entity Identificator: Id which provides unique identification of an entity.

11First version by Alessandro Agostini and Fausto Giunchiglia Second version by Fausto Giunchiglia and Rui Zhang

Monkeys

Boxes

Climb

0..1 0..n

Bananas

Height

9/2009

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.

12

E

E1 Ei En

There are other representations for ER diagrams

First version by Alessandro Agostini and Fausto Giunchiglia Second version by Fausto Giunchiglia and Rui Zhang

9/2009

Example of Monkey and Bananas in ER

Monkeys

Bananas

Boxes

Climb

Height

Height

The squares represent monkey, bananas and box. The attribute “height” may has either value of “high” or “low”. The diamonds “Climb” and “Get” are binary relations

Get

Height

First version by Alessandro Agostini and Fausto Giunchiglia Second version by Fausto Giunchiglia and Rui Zhang

9/2009

UMLUnified Modeling Language UML.

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 an “alternative” to the E-R schemas.

14First version by Alessandro Agostini and Fausto Giunchiglia Second

version by Fausto Giunchiglia and Rui Zhang

9/2009

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.

15

Class A

Attribute

Method

Class B

Attribute

Method

1 0..*

First version by Alessandro Agostini and Fausto Giunchiglia Second

version by Fausto Giunchiglia and Rui Zhang

9/2009

Example of Monkey and Bananas in UML

Monkeys

Height

Boxes

Height

Bananas

Height

Climb

1

0..1

Get

1

0..*

“A monkey can climb onto 0 to 1 box. A monkey can get 0 or more bananas.”

First version by Alessandro Agostini and Fausto Giunchiglia Second

version by Fausto Giunchiglia and Rui Zhang

9/2009

Logic: eg. Propositional LogicLanguage

L={A,,,,}Example MonkeyLow, BananaHigh,

MonkeyLow BananaHigh MonkeyGetBanana

MonkeyLow MonkeyClimbBox MonkeyHigh

MonkeyHigh BananaHigh MonkeyGetBananaSemantics:

“Originally, the monkey is low and bananas are high in position. The monkey cannot get the bananas. If the monkey climbs onto the box, it becomes high in position and can get the bananas.”

First version by Alessandro Agostini and Fausto Giunchiglia Second version by Fausto Giunchiglia and Rui Zhang

9/2009

Formal Model

A (formal) model is an abstraction of a part of the world

A model : a Triple= <D,A,R> D= domain (a is in A): set of objects of interest A= set of attributes (a has attribute P): subsets of D R= set of relations (a is in relation with b): subset of

Cartesian products A×B, with A,B subsets of D, r=<a,b> is a pair of objects.

Note: we can easily extend to n-ary relationsFirst version by Alessandro Agostini and Fausto Giunchiglia

Second version by Fausto Giunchiglia and Rui Zhang9/2009

Formal semantics (example)

Domain

{monkey1, banana3, box11, leaf0}

Attribute

High={banana3},Low={monkey1, box11}

Relation

Climb={<monkey1, box11>}

Get={<monkey1, banana3>, <monkey,1 leaf0>}

First version by Alessandro Agostini and Fausto Giunchiglia Second version by Fausto Giunchiglia and Rui Zhang

9/2009

Formal semantics )(example)

Domain

{True, False} (the same as: {1, 0} )

Attribute

HighBanana=1, LowMonkey=0

Relation

ClimbLowBox= 1

First version by Alessandro Agostini and Fausto Giunchiglia Second version by Fausto Giunchiglia and Rui Zhang

9/2009

Formal semantics for ER and UML

Domain{monkey, banana, box}

AttributeHigh={banana},Low={monkey, box}

RelationClimb= …

Get= …

First version by Alessandro Agostini and Fausto Giunchiglia Second version by Fausto Giunchiglia and Rui Zhang

Monkeys

Bananas

BoxesClimb

Height

HeightGet

Height

Monkeys

Height

… Boxes

Height

Bananas

Height

Climb

1

0..1

Get

1

0..*

Same

9/2009

OutlineModelLanguage

Natural Language ER UML Logic

Using LanguagesSpecification & AutomationServicesUsing logics

First version by Alessandro Agostini and Fausto Giunchiglia Second version by Fausto Giunchiglia and Rui Zhang

9/2009

First version by Alessandro Agostini and Fausto Giunchiglia Second version by Fausto Giunchiglia and Rui Zhang

Uses of Data Representation LanguagesThe two purposes in modeling:

Specification and Automation (Automated Reasoning)

Specification: representation of the problem at the proper level of abstraction Allow informal/formal syntax and informal/formal

semantics.

Automated Reasoning: computing consequences or properties of the chosen specifications. Requires formal semantics.

9/2009

First version by Alessandro Agostini and Fausto Giunchiglia Second version by Fausto Giunchiglia and Rui Zhang

Why Natural Languages?Used as 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

semantics is informal, largely ambiguous

Pragmatically inefficient for automation

9/2009

First version by Alessandro Agostini and Fausto Giunchiglia Second version by Fausto Giunchiglia and Rui Zhang

Why Diagrams?Used to provide more structured/organized

specification than natural languages Informal/formal syntax (depends on the kind of

diagram) Informal semantics Largely structured and organized; usually used

better in representation with unified languages. When things are non-trivial More precision

Example: NL to UML

Pragmatically inefficient for automation

9/2009

First version by Alessandro Agostini and Fausto Giunchiglia Second version by Fausto Giunchiglia and Rui Zhang

Used as formal specification languages formal syntax, formal semantics well-understood

Used as (formal) languages for automation “reasoning services” (see the next slides)

Pragmatically efficient for automation exploiting the explicitly codified semantics.

Why Logic?

9/2009

Informal and Formal specification tradeoffThe more you specify, the more cost grows (e.g., man

power)

First version by Alessandro Agostini and Fausto Giunchiglia Second version by Fausto Giunchiglia and Rui Zhang

Cost &Precision of specification

NaturalLanguage Diagram Logics

Formalization

9/2009

OutlineModelLanguage

Natural Language ER UML Logic

Using LanguagesSpecification & AutomationServicesUsing logics

First version by Alessandro Agostini and Fausto Giunchiglia Second version by Fausto Giunchiglia and Rui Zhang

9/2009

First version by Alessandro Agostini and Fausto Giunchiglia Second version by Fausto Giunchiglia and Rui Zhang

Logics

A logic is a representation language with a formal syntax; a formal semantics.

… any language (eg., using mathematical notation, textual, graphical, …)

As formal languages, logics are suitable for representing (specification) of and reasoning (automation) about data and knowledge.

9/2009

First version by Alessandro Agostini and Fausto Giunchiglia Second version by Fausto Giunchiglia and Rui Zhang

Logics for Specification Logic as a formal language: is good for the

specification (representation) of knowledge. it provides a formal syntax.

Starting from a precise syntax logic provides a formal (i.e., unambiguous) semantics.

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.

9/2009

First version by Alessandro Agostini and Fausto Giunchiglia Second version by Fausto Giunchiglia and Rui Zhang

Logics for Reasoning

Logics provides a notion of deduction (axioms, deductive machinery, theorem) that can be used to implement “reasoners” which allow to infer conclusions from a given knowledge base (i.e, a set of “premises”, premises can be axioms or theorems).

From implicit knowledge to explicit knowledge.

9/2009

OutlineModelLanguage

Natural Language ER UML Logic

Using LanguagesSpecification & AutomationServicesUsing logics

First version by Alessandro Agostini and Fausto Giunchiglia Second version by Fausto Giunchiglia and Rui Zhang

9/2009

First version by Alessandro Agostini and Fausto Giunchiglia Second version by Fausto Giunchiglia and Rui Zhang

Logics for Automated Reasoning

Recall the MB story…

MonkeyHigh BananaHigh MonkeyGetBanana

MonkeyLow BoxLow MonkeyCanClimbBox

MonkeyCanClimbBox MonkeyClimbBox MonkeyHigh

MonkeyLow MonkeyClimbBox BananaHigh

MonkeyGetBanana

9/2009

Tools for Automated Reasoning

SATDescription Logic reasonersLCF (Robin Milner @ Edinburgh & Stanford)Prover9 (William McCune)… many many others ….

To list updated automated reasoning tools

First version by Alessandro Agostini and Fausto Giunchiglia Second version by Fausto Giunchiglia and Rui Zhang

9/2009

First version by Alessandro Agostini and Fausto Giunchiglia Second version by Fausto Giunchiglia and Rui Zhang

Reasoning Services (1)The basic reasoning tasks (or “services”) we

would like to compute are the following: Model Checking (EVAL): Is a sentence ψ true in

model M? Satisfiability (SAT): Is there a model M where ψ

is true? Validity(VAL): Is ψ true according to all possible

models M? Entailment(ENT): ψ1 true in M (all models)

implies ψ2 is true in M (all models).

9/2009

EVAL Is a sentence ψ true according to a model M?Given that ∆={T,F},andMonkeyHigh BananaHigh MonkeyGetBanana

MonkeyLow BoxLow MonkeyCanClimbBox

MonkeyCanClimbBox MonkeyClimbBox MonkeyHigh

MonkeyLow MonkeyClimbBox BananaHigh MonkeyGetBanana

And a model MMonkeyLow=T MonkeyClimbBox=F

BananaHigh=T BoxLow=T

Evaluate whether ψ1 = MonkeyCanClimbBox is true ψ2 = MonkeyGetBanana is false.

First version by Alessandro Agostini and Fausto Giunchiglia Second version by Fausto Giunchiglia and Rui Zhang

9/2009

SAT Is there existing model M that is ψ true?Given that ∆={T,F},ψ = MonkeyGetBananaMonkeyHigh BananaHigh MonkeyGetBanana

MonkeyLow BoxLow MonkeyCanClimbBox

MonkeyCanClimbBox MonkeyClimbBox MonkeyHigh

MonkeyLow MonkeyClimbBox BananaHigh MonkeyGetBanana

Look for a model M

MonkeyLow=T MonkeyClimbBox=T

BananaHigh=T BoxLow=T

Where ψ = MonkeyGetBanana is true.

First version by Alessandro Agostini and Fausto Giunchiglia Second version by Fausto Giunchiglia and Rui Zhang

9/2009

VAL Is a sentence ψ true according to every

possible model M?Given a theory as MonkeyHigh BananaHigh MonkeyGetBanana

MonkeyLow BoxLow MonkeyCanClimbBox

MonkeyCanClimbBox MonkeyClimbBox MonkeyHigh

MonkeyLow MonkeyClimbBox BananaHigh MonkeyGetBanana

ψ1 = MonkeyGetBanana is true for the model in the previous slide;

First version by Alessandro Agostini and Fausto Giunchiglia Second version by Fausto Giunchiglia and Rui Zhang

9/2009

ENTGiven a theory as MonkeyHigh BananaHigh MonkeyGetBanana

MonkeyLow BoxLow MonkeyCanClimbBox

MonkeyCanClimbBox MonkeyClimbBox MonkeyHigh

MonkeyLow MonkeyClimbBox BananaHigh MonkeyGetBanana

ψ1 = BoxLow MonkeyClimbBox

ψ2 = MonkeyGetBanana

We have ψ1 entails ψ2.

First version by Alessandro Agostini and Fausto Giunchiglia Second version by Fausto Giunchiglia and Rui Zhang

9/2009

First version by Alessandro Agostini and Fausto Giunchiglia Second version by Fausto Giunchiglia and Rui Zhang

Reasoning Services (2)

Other services: consistency subsumption,

instance checking, equivalence, concept

coherence, ...

NB: not all reasoning services are provided by

a single logic (e.g., instance checking).

9/2009

OutlineModelLanguage

Natural Language ER UML Logic

Using LanguagesSpecification & AutomationServicesUsing logics

First version by Alessandro Agostini and Fausto Giunchiglia Second version by Fausto Giunchiglia and Rui Zhang

9/2009

First version by Alessandro Agostini and Fausto Giunchiglia Second version by Fausto Giunchiglia and Rui Zhang

What does a logic allow to do?

To specify the knowledge formally

To derive new knowledge automatically

Must be efficient

9/2009

The thread of the logics (substitute)Syllogism and Class?PLFOLMLs,DefL,DLsOWLCxLC-OWL

Syllogism

Classification

PL

FOL

MLs

Syllogism

Definition L???

DLs

OWL

CxL C-OWL

We will see all these in this course

First version by Alessandro Agostini and Fausto Giunchiglia Second version by Fausto Giunchiglia and Rui Zhang

9/2009

E-R Semantics (Exercise)Complete the definition of the formal, set-theoretic semantics for the E-R schema given in the foregoing example.

Represent the formal semantics of the previous slide informally by using natural language (English).

First version by Alessandro Agostini and Fausto Giunchiglia Second version by Fausto Giunchiglia and Rui Zhang

9/2009