DatalogDatalog S. Costantini. S. Costantini / Logical Query Languages 2 Logic As a Query Language If-then logical rules have been used in many systems.

Slides:



Advertisements
Presentazioni simili
Primary Italian Saying How You Are.
Advertisements

Marina Fumagalli- Liceo Arnaldo
Each student will be able to ask an adult or stranger: What do you like to do? and What dont you like to …?
Raffaele Cirullo Head of New Media Seconda Giornata italiana della statistica Aziende e bigdata.
BRISCOLA GO ON AVANTI. Storia I giochi di carte hanno le origini più disparate e vengono collocati in differenti epoche, la Briscola risale al La.
Queuing or Waiting Line Models
11 1 Roma, 11 dicembre 2006 Laura Gasparini Garanzia su Portafogli Estero.
Guardate le seguenti due frasi:
Fate Adesso: Al ristorante. Cosa fai quando vai al ristorante
Metodi Quantitativi per Economia, Finanza e Management Lezione n°8.
Distribuzione del numero di alleli condivisi da coppie di fratelli e di non-parenti tipizzati rispettivamente per 5, 9 e 13 markers.
Teoremi di Lieb Permette di stabilire l’esistenza di
Che ora e’/ Che ore sono?.
Oggi è il due marzo LO SCOPO: Usiamo il passato prossimo. FATE ADESSO: Tirate fuori il compito.
Da Fare Adesso: 1.Dove vai a provare l’abbigliamento quando sei al negozio? 2.Quando una donna va ad una festa elegante che cosa usa per mettere il rossetto?
I giorni della settimana
PINK FLOYD DOGS You gotta be crazy, you gotta have a real need. You gotta sleep on your toes. And when you're on the street. You gotta be able to pick.
Demonstrating Possession
Ontologia AA F. Orilia. Lez. 16 Discussione dell'approccio controfattualista di lewis condotta da Antonio De Grandis.
Talking about yourself
4/20/20151 Metodi formali dello sviluppo software a.a.2013/2014 Prof. Anna Labella.
Love, Love, Love. Love, Love, Love. Love, Love, Love. There's nothing you can do that can't be done. Nothing you can sing that can't be sung. Nothing.
SCOPA Avanti.
Metodi Quantitativi per Economia, Finanza e Management Lezioni n° 7-8.
Successione degli Stati nei trattati Successione di Stati = mutamento di sovranità territoriale. Conseguenze di tale mutamento sui diritti ed obblighi.
Chapter Eighteen1 CHAPTER 3 Distribution of national income A PowerPoint  Tutorial To Accompany MACROECONOMICS, 7th. ed. N. Gregory Mankiw Tutorial written.
MyEconLab_Univerità degli studi di Milano, corso Prof.ssa Valentina Raimondi How to Access MyEconLab 1.
Capitolo 14 Il presente del congiuntivo (the present subjunctive)
ANNUNCIO DI SEMINARIO Il giorno Venerdi' 21 Maggio 2004 alle ore 11:30 presso l'Aula C3.4 della Facolta' di Scienze Matematiche Fisiche e Naturali dell'Universita'
Un problema multi impianto Un’azienda dispone di due fabbriche A e B. Ciascuna fabbrica produce due prodotti: standard e deluxe Ogni fabbrica, A e B, gestisce.
Accoppiamento scalare
SUMMARY Time domain and frequency domain RIEPILOGO Dominio del tempo e della frequenza RIEPILOGO Dominio del tempo e della frequenza.
Viruses.
Each student will be able to ask an adult or stranger: What do you like to do? and What don’t you like to …?
SUMMARY Quadripoles and equivalent circuits RIEPILOGO Quadripoli e circuiti equivalenti RIEPILOGO Quadripoli e circuiti equivalenti.
Mobilità tra i Paesi del Programma KA103 A.A. 2014/2015 (KA103) Mobility Tool+ e il Rapporto Finale Claudia Peritore Roma luglio 2015.
L A R OUTINE D EL M ATTINO Ellie B.. Io mi sono svegliata alle cinque del mattino.
Passato prossimo dei verbi riflessivi con Essere
Summary Module 1 – Unit 1 (Current, potential difference, resistance) RIEPILOGO Modulo 1 – Unità 1 (Corrente, tensione, resistenza)
SUMMARY Different classes and distortions RIEPILOGO Le diverse classi e le distorsioni RIEPILOGO Le diverse classi e le distorsioni.
Click to continue. “Abbiamo sentito dire d’una speciale disposizione della marina inglese. Tutti i sartiami della regia flotta, dal più robusto al più.
SUMMARY Applications of synchronous motors and stepper motors RIEPILOGO Applicazioni dei motori sincroni e dei motori passo-passo RIEPILOGO Applicazioni.
Filtri del secondo ordine e diagrammi di Bode
Progetti 2015/2016. Proj1: Traduzione di regole snort in regole iptables Snort: – analizza i pacchetti che transitano in rete, confrontandoli con un database.
Simple Sentences in Italian
La governance europea. Governance without government J. N. Rosenau e E. O. Czempiel, Governance without government: order and change in world politics,
Language of Algebra.
Language of Algebra. Basic concepts Key words Practice exercises Basic concepts Key words Practice exercises.
LE PREPOSIZIONI. Le Preposizioni semplici (Simple prepositions) A preposition describes a relationship between other words in a sentence. In itself, a.
It’s easy to know when we have to put emphasis on the last syllable of words with two or more syllables! These words have an accent on the last letter!
Buon giorno, ragazzi oggi è il quattro aprile duemilasedici.
Ci and ne. Ci Ci is used to replace nouns or expressions that refer to places or locations that have just been mentioned. Ci is roughly equivalent to.
ETWINNING XMAS C’era una volta Ed esiste ancora.
PROGETTO COMENIUS Partenariato Scolastico Multilaterale Anno 2012/2013 CIRCOLO DIDATTICO S.G. BOSCO- BIANCAVILLA- CT.
La Pace vera True Peace Vi lascio la pace, vi do la mia pace. Non come la dà il mondo, io la do a voi. (Gv 14, 27) Peace be with you; I give you my peace.
STMan Advanced Graphics Controller. What is STMan  STMan is an advanced graphic controller for Etere automation  STMan is able to control multiple graphics.
Inglese Lezione 11, 9/3/15. Annunci Non si terranno le lezioni del 16 Marzo La lezione del 18 Marzo (ore 13) sarà tenuta dal prof. Gregory Landini.
MSc in Communication Sciences Program in Technologies for Human Communication Davide Eynard Facoltà di scienze della comunicazione Università della.
Do You Want To Pass Actual Exam in 1 st Attempt?.
Oggi è giovedì il dodici settembre 2013
WRITING – EXERCISE TYPES
L’orario – the time Anno 8.
AusTel by taha.a.
Clusters, bundles, lexical sets, priming Visual sets Translation
Adolf Luther Born 1912 in Krefeld, Germany. Died 1990 Krefeld.
Studente : Andrea Cassarà Classe: 5AII A.S. 2014/2015 Link Sito
Il condizionale.
La Grammatica Italiana Avanti! p
Service Level The Service Level is defined as the percentage of orders cycles in which inventory is sufficient to cover demands, or.
Transcript della presentazione:

DatalogDatalog S. Costantini

S. Costantini / Logical Query Languages 2 Logic As a Query Language If-then logical rules have been used in many systems. Recursive rules extend relational algebra --- have been used to add recursion to SQL-99.

S. Costantini / Logical Query Languages 3 Datalog A language for Deductive Databases –Extensional part: tables –Intensional part: rules

S. Costantini / Logical Query Languages 4 Logic: Intuition

S. Costantini / Logical Query Languages 5 Datalog Terminology: Atoms An atom is a predicate, or relation name with variables or constants as arguments. E.g., in(alan,r123) part_of(r123,cs_building) p(X,a)

S. Costantini / Logical Query Languages 6 Datalog Terminology: Atoms Conventions: –Databases: Predicates begin with a capital, variables begin with lower-case. Example: P(x,’a’) where ‘a’ is a constant, i.e., a data item. –Logic Programming: Variables begin with a capital, predicates and constants begin with lower-case. Example: p(X,a).

S. Costantini / Logical Query Languages 7 Datalog Terminology: Rules The head of a rule is an atom; the body of a rule is the AND of one or more atoms. E.g., in(X,Y):- part_of(Z,Y), in(X,Z). where “:-” stands for “  ”

S. Costantini / Logical Query Languages 8 Datalog Terminology: Facts Rules without body called “facts”: E.g., in(alan,r123). Facts constitute the extensional part of a deductive database, i.e., define tables.

S. Costantini / Logical Query Languages 9 Alternative notation Explicitly list attributes E.g., facts: in(Object:alan,Place:r123) E.g., rules: in(Object:X,Place:Y):- part_of(Place: Z, Place:Y), in(Object:X, Place:Z).

S. Costantini / Logical Query Languages 10 Datalog semantics Least Herbrand Model –The head of a rule is in the Least Herbrand Model only if the body is in the Least Herbrand Model.

S. Costantini / Logical Query Languages 11 Least Herbrand Model: How to find it p  g,h. g  r,s. m  p,q. r  f. s. f. h. Step 1: facts M 0 = {s,f,h} Step 2: M 1 = M 0 plus what I can derive from facts M 1 = {s,f,h,r} Step 3: M 2 = M 1 plus what I can derive from M 1 M 2 = {s,f,h,r,g} Step 4: M 3 = M 2 plus what I can derive from M 2 M 3 = {s,f,h,r,g,p} If you try to go on, no more added conclusions: fixpoint

S. Costantini / Logical Query Languages 12 Least Herbrand Model: Intuition

S. Costantini / Logical Query Languages 13 Least Herbrand Model: Intuition In the example: Least Herbrand Model M0 = {in(alan,r123), part_of(r123,cs_building)} M1= {in(alan,r123), part_of(r123,cs_building), in(alan,cs_building)}

S. Costantini / Logical Query Languages 14 Datalog and Transitivity Rule in(X,Y):- part_of(X,Z),in(Z,Y) defines in as the transitive closure of part_of

S. Costantini / Logical Query Languages 15 Arithmetic Subgoals In addition to relations as predicates, a predicate of the body can be an arithmetic comparison. –We write such atoms in the usual way, e.g.: x < y.

S. Costantini / Logical Query Languages 16 Example: Arithmetic A beer is “cheap” if there are at least two bars that sell it for under $2. Cheap(beer) <- Sells(bar1,beer,p1) AND Sells(bar2,beer,p2) AND p1 < 2.00 AND p2 bar2

S. Costantini / Logical Query Languages 17 Negated Subgoals We may put NOT in front of an atom, to negate its meaning. Example: at_home(alan):- not at_work(alan)

S. Costantini / Logical Query Languages 18 Negated Subgoals: Intuition Given atom A, not A holds if A cannot be proved Negation as finite failure

S. Costantini / Logical Query Languages 19 Safe Rules A rule is safe if: 1.Each variable in the head 2.Each variable in an arithmetic subgoal, 3.Each variable in a negated subgoal, also appears in a nonnegated, subgoal in the body. We allow only safe rules.

S. Costantini / Logical Query Languages 20 Example: Unsafe Rules Each of the following is unsafe and not allowed: 1.S(x) <- R(y) 2.S(x) <- R(y) AND NOT R(x) 3.S(x) <- R(y) AND x < y In each case, an infinity of x ’s can satisfy the rule, even if R is a finite relation.

S. Costantini / Logical Query Languages 21 Datalog Programs A Datalog program is a collection of rules. In a program, predicates can be either 1.EDB = Extensional Database = stored table. 2.IDB = Intensional Database = relation defined by rules.

S. Costantini / Logical Query Languages 22 Expressive Power of Datalog Without recursion, Datalog can express all and only the queries of core relational algebra. But with recursion, Datalog can express more than these languages. Yet still not Turing-complete.

S. Costantini / Logical Query Languages 23 Datalog semantics With negation: several proposals, in deductive databases answer set semantics.

S. Costantini / Logical Query Languages 24 Minimal Models When there is no negation, a Datalog program has a unique minimal model (one that does not contain any other model). But with negation, there can be several minimal models.

S. Costantini / Logical Query Languages 25 Non-Monotonicità Aggiungere nuove conoscenze può portare a ritrarre precedenti conclusioni. Vi possono essere conclusioni alternative tramite cicli sulla negazione.

S. Costantini / Logical Query Languages 26 Non-Monotonicità = Problema? No, se gestita con opportuni strumenti semantici Non-Monotonic Reasoning (NMR) = campo di ricerca in – Intelligenza Artificiale –Database deduttivi si propone di sfruttare la non- monotonicità

S. Costantini / Logical Query Languages 27 DATALOG senza Negazione Semantica del Least Herbrand Model Paradigma procedurale della ricerca per tentativi ripetuti Linguaggio Prolog (numerosi interpreti fra i quali SICSTUS-Prolog, SWI- Prolog)

S. Costantini / Logical Query Languages 28 DATALOG + Negazione Semantica degli Answer Sets Paradigma dell’Answer Set Programming (ASP) Negazione, insiemi-risposta alternativi Numerosi solver

S. Costantini / Logical Query Languages 29 Esempio NMR persona(anna). persona(carlo). persona(giorgio). malato(giorgio). a_casa(X):- persona(X), not in_ufficio(X). in_ufficio(X):- persona(X), not a_casa(X). :- in_ufficio(X),malato(X). % constraint

S. Costantini / Logical Query Languages 30 Risultato atteso Anna e Carlo sono o a casa oppure in ufficio. Giorgio non può essere in ufficio perchè è malato e quindi sarà a casa.

S. Costantini / Logical Query Languages 31 NMR in pratica Vi sono vari linguaggi logici che consentono non-monotonicità. Sono dotati di motori inferenziali (inference engines, o solvers) in grado di gestirla. Possibili soluzioni inesistenti o altrernative. Uno di essi: smodels

S. Costantini / Logical Query Languages 32 Risultato di smodels (inference engine per NMR) Answer: 1 malato(giorgio) a_casa(giorgio) a_casa(carlo) in_ufficio(anna) Answer: 2 malato(giorgio) a_casa(giorgio) in_ufficio(carlo) in_ufficio(anna)

S. Costantini / Logical Query Languages 33 Risultato di smodels (inference engine per NMR) Answer: 3 malato(giorgio) a_casa(giorgio) in_ufficio(carlo) a_casa(anna) Answer: 4 malato(giorgio) a_casa(giorgio) a_casa(carlo) a_casa(anna)