Documente Academic
Documente Profesional
Documente Cultură
(R1 R2).
Conciele synlax:
Relation1 zjoin Condition Relation2
LxanpIe:
a zjoin a.a<b.b b;
NaluiaI (innei) join R1 R2. Reluin lupIes of R1 joined vilh R2 such lhal connon
alliilules aie paii vise equaI and occui onIy once in oulpul ieIalion.
Conciele synlax:
Relation1 njoin Relation2
LxanpIe:
a njoin c;
Division R1 R2. Reluin iesliiclions of lupIes in R1 lo lhe alliilule nanes of R1
vhich aie nol in lhe schena of R2, foi vhich il hoIds lhal aII lheii conlinalions
vilh lupIes in R2 aie piesenl in R1. The alliilules in R2 foin a piopei sulsel of
alliilules in R1.
Conciele synlax:
Relation1 division Relation2
LxanpIe:
a division c;
4.3.1.3 E)tended o&erators
These opeialois can not le expiessed in leins of foinei opeialois, and incIude:
Lxlended piojeclion (expiessions and ienanings) #1 A1!"""!#n An(R). Reluin lupIes of R
vilh a nev schena R(A1!"""!An) vilh coIunns #1!"""!#n vheie each #i is an expiession
Fernando Senz-Prez 7/234
Univeisidad ConpIulense de Madiid
DalaIog LducalionaI Syslen
luiIl fion conslanls, alliilules of R, and luiIl-in opeialois. If a given Ai is nol
piovided, lhe nane foi lhe coIunn is eilhei lhe coIunn #i, if il is a coIunn, oi il is
given an aililiaiy nev nane.
Conciele synlax:
project E1 A1,...,En An (Relation)
LxanpIes:
:-type(d(a:string,b:int)).
project b+1 (d);
project incb (project b+1 incb (d))
DupIicale eIininalion (R). Reluin lupIes in R, discaiding dupIicales.
Conciele synlax:
distinct (Relation)
LxanpIe:
distinct (project a (c));
Nole: As distinct is aIso a DalaIog (nela)piedicale, lhe queiy distinct (c)
fion lhe DalaIog pionpl vouId le soIved as a DalaIog queiy, inslead of a RA one.
Then, if you have lo ensuie youi queiy viII le evaIualed ly lhe RA piocessoi, you
can eilhei svilch lo RA vilh /ra, oi piepend lhe queiy vilh /ra, as foIIovs:
DES> % Either switch to RA:
DES>/ra
DES-RA> distinct (project a (c));
DES> /datalog
DES> % Or simply add /ra
DES>/ra distinct (project a (c));
Lefl oulei join R1
R2. LquivaIenl lo R2
R1. R1
R2
Conciele synlax:
Relation1 rjoin Condition Relation2
LxanpIe:
Fernando Senz-Prez 8/234
Univeisidad ConpIulense de Madiid
DalaIog LducalionaI Syslen
a rjoin a=b b;
IuII oulei join R1
R2. LquivaIenl lo R1
R2 R1
R2.
Conciele synlax:
Relation1 fjoin Condition Relation2
LxanpIe:
a fjoin a=b b;
Ciouping vilh aggiegalions $1!"""!$n
#1!"""!#n
lhe
cuiienl caII. Theie aie lvo possiliIilies: 1) lheie is such a pievious caII: lhen, use lhe
iesuIl in lhe ansvei lalIe, if any. Il is possilIe lhal lheie is no such a iesuIl (foi
inslance, vhen conpuling lhe goaI p in lhe piogian p :- p) and ve cannol deiive
any infoinalion, 2) olheivise, piocess lhe nev caII knoving lhal lheie is no caII oi
ansvei lo lhis caII in lhe exlension lalIe. So, fiislIy sloie lhe cuiienl caII and lhen, soIve
lhe goaI vilh lhe piogian iuIes (iecuisiveIy appIying lhis aIgoiilhn). Once lhe goaI
has leen soIved (if succeeded), sloie lhe conpuled ansvei if lheie is no any pievious
ansvei sulsuning lhe cuiienl one (nole lhal, lhiough iecuision, ve can deIivei nev
ansveis foi lhe sane caII). This so-caIIed nenoizalion piocess is inpIenenled vilh
lhe piedicale memo/1 in lhe fiIe des.pl of lhe disliilulion, and viII aIso le iefeiied lo
as a neno funclion in lhe iesl of lhis nanuaI.
Negalive facls aie pioduced vhen a negalive goaI is pioved ly neans of
negalion as faiIuie (cIosed voiId assunplion). In lhis silualion, a goaI as not(p)
8
Ioi a conpIenenlaiy undeislanding of lhis seclion, lhe ieadei is advised lo iead
|Diel87j.
A lein T1 sulsunes a lein T2 if T1 is noie geneiaI lhan T2 and lolh leins aie
unifialIe. Lg: p(X,Y) sulsunes p(a,Z), p(X,Y) sulsunes p(U,V), p(X,Y) sulsunes
p(U,U), lul p(U,U) neilhei sulsunes p(a,b), noi p(X,Y).
Fernando Senz-Prez 186/234
Univeisidad ConpIulense de Madiid
DalaIog LducalionaI Syslen
vhich succeeds pioduces lhe facl not(p) vhich is added lo lhe ansvei lalIe, jusl lhe
sane as pioving a posilive goaI.
The connand /list_et shovs lhe cuiienl slale of lhe exlension lalIe, lolh
foi ansveis and caIIs aIieady ollained ly soIving one oi noie queiies (incidenlaIIy,
iecaII lhal you can focus on lhe conlenls of lhe exlension lalIe foi a given piedicale, cf.
Seclion 5.14.4). This connand is usefuI foi lhe usei vhen asking foi lhe neaning of
ieIalions, and foi lhe deveIopei foi exanining lhe Iasl caIIs leing peifoined. efoie
execuling any queiy, lhe exlension lalIe is enply, aflei execuling a queiy, al Ieasl lhe
caII is nol enply. AIso, lhe exlension lalIe is enply aflei lhe execulion of a lenpoiaiy
viev.
1!
The exlension lalIe conlains lhe caIIs nade duiing lhe Iasl fixpoinl ileialion
(see nexl seclion foi delaiIs), lhe caIIs aie cIeaied lefoie each ileialion vheieas lhe
ansveis aie kepl. The connand /clear_et cIeais lhe exlension lalIe conlenls, lolh
foi caIIs and ansveis.
%.1(.2 .i)&oint Com&utation
The lalIing nechanisn is insufficienl in ilseIf foi conpuling aII of lhe possilIe
ansveis lo a queiy. The ialionaIe lehind lhis cones fion lhe facl lhal lhe conpuled
infoinalion is nol conpIele vhen soIving a given goaI, lecause il can use inconpIele
infoinalion fion lhe goaIs in ils defining iuIes (lhese goaIs can le nuluaIIy iecuisive).
Theiefoie, ve have lo ensuie lhal ve pioduce aII lhe possilIe infoinalion ly finding a
fixpoinl of lhe neno funclion. The aIgoiilhn inpIenenling lhis is depicled nexl:
solve_star(Q,St) :-
repeat,
(remove_calls, % Clear CT
et_not_changed, % Flag ET as not changed
solve(Q,St), % Solve the call to Q using memoization at stratum St
fail % Request all alternatives
;
no_change, % If no more alternatives, start a new iteration
!, fail). % Otherwise, fail and exit
Iiisl, lhe caII lalIe is enplied in oidei lo aIIov lhe syslen lo liy lo ollain nev
ansveis foi a given caII, pieseiving lhe pievious conpuled ansveis. Then, lhe neno
funclion is appIied, possilIy pioviding nev ansveis. If lhe ansvei lalIe ienains lhe
sane as lefoie aflei lhis Iasl neno funclion appIicalion, ve aie done. Olheivise, lhe
neno funclion is ieappIied as nany lines as needed unliI ve find a slalIe ansvei
lalIe (vilh no changes in lhe ansvei lalIe). The ansvei lalIe conlains lhe slalIe nodeI
of lhe queiy (pIus peihaps olhei slalIe nodeIs foi lhe ieIalions used in lhe
conpulalion of lhe given queiy).
The fixpoinl is found in finile line lecause lhe neno funclion is nonolonic in
lhe sense lhal ve onIy add nev enliies each line il is caIIed vhiIe keeping lhe oId
ones. RepealedIy appIying lhe neno funclion lo lhe ansvei lalIe deIiveis a finile
ansvei lalIe since lhe nunlei of nev facls lhal can le deiived fion a DalaIog
piogian is finile (iecaII lhal lheie aie no conpound leins such as s
-
(z)). On lhe one
hand, lhe nunlei of posilive facls vhich can le infeiied aie finile lecause lheie is a
finile nunlei of giound facls vhich can le used in a given pioof, and pioofs have
1!
The conlenls of lhe exlension lalIe in lhis case shouId le iesloied inslead of leing
cIeaied, Iefl foi fuilhei inpiovenenls.
Fernando Senz-Prez 187/234
Univeisidad ConpIulense de Madiid
DalaIog LducalionaI Syslen
finile deplh piovided lhal lalIing pievenls ieconpulalions of oIdei nodes in lhe pioof
liee. On lhe olhei hand, lhe nunlei of negalive facls vhich can le infeiied is aIso
finile lecause lhey aie pioved using negalion as faiIuie. (IaiIuies aie aIvays finile
lecause lhey aie pioved liying lo gel a success.) IinaIIy, lheie aie facls lhal cannol le
pioved lo le liue oi faIse lecause of iecuision. These cases aie delecled ly lhe lalIing
nechanisn vhich pievenl infinile iecuision such as in p :- p.
Il is aIso possilIe lhal lolh a posilive and a negalive facl have leen infeiied foi
a given caII. Then, an undefined facl iepIaces lhe conliadicloiy infoinalion. The
inpIenenlalion sinpIy ienoves lhe conliadicloiy facls and infoins aloul lhe
undefinedness. As aIieady indicaled (see Seclion 6.8.1), lhe aIgoiilhn foi deleinining
undefinedness is inconpIele.
%.1(.3 De&endency !ra&/s and Strati:icationH 1egationI =uter BoinsI and
2ggregates
Lach line a piogian is consuIled oi nodified (i.e., via sulnilling a lenpoiaiy
viev oi changing lhe dalalase), a piedicale dependency giaph is luiIl |ZCI+97j. This
giaph shovs lhe dependencies, lhiough posilive and negalive alons, anong
piedicales in lhe piogian. AIso, a negalive dependency is added foi each oulei join
goaI and aggiegale goaI.
This dependency giaph is usefuI foi finding a slialificalion foi lhe piogian
|ZCI+97j. A slialificalion coIIecls piedicales inlo nunleied sliala (1..N). A lasic
lollon-up conpulalion vouId soIve aII of lhe piedicales in slialun 1, lhen 2, and so
on, unliI lhe neaning of lhe vhoIe piogian is found. Wilh oui appioach, ve onIy
iesoil lo conpule ly slialun vhen a negalive dependency occuis in lhe piedicale
dependency giaph iesliicled lo lhe queiy, neveilheIess, each piedicale lhal is acluaIIy
needed is soIved ly neans of lhe exlension lalIe nechanisn desciiled in lhe pievious
seclion. As a consequence, nany conpulalions aie avoided v.i.l. a nave lollon-up
inpIenenlalion. See aIso nexl seclion on oplinizalions.
Oulei join and aggiegale goaIs aie aIso coIIecled inlo sliala as if lhey veie
negalive alons in oidei lo have lheii ansvei sel conpIeleIy defined and lheiefoie
ensuie leininalion of lhe conpulalion aIgoiilhn in piesence of nuII vaIues (foi oulei
joins) and inconpIele sel of vaIues (foi aggiegales).
%.1(.4 =&timiJations
DLS is nol laigeled al peifoinance ly any neans: il is inpIenenled on lop of
IioIog, il uses lhe (sIovei in nosl syslens) IioIog dynanic dalalase, il does nol aIIov
usei-defined indexes, inpIenenled aIgoiilhns aie nol lhe lesl ones, seveiaI lasks aie
iedone spaiingIy (aIlhough lhey can le acluaIIy saved), and so on. Once lhal said,
lheie has leen sliII a ninoi ioon foi oplinizing peifoinance so lhal piojecls of lhe
size DLS is inlended foi can le successfuIIy achieved. eIov, ve Iisl sone of such
oplinizalions lhal can le enalIed oi disalIed al usei iequesl (lhis fealuie is noie
oiienled lo lhe syslen inpIenenlois foi knoving lhe inpacl on peifoinance of such
oplinizalions). Lach oplinizalion is Iisled in a sulseclion aIong vilh lhe connand
(lelveen liackels) lhal is used foi disalIing oi enalIing il (vilh lhe svilch off and
on, iespecliveIy).
Fernando Senz-Prez 188/234
Univeisidad ConpIulense de Madiid
DalaIog LducalionaI Syslen
%.1(.4.1 Com&lete Com&utations D/optimize_ccE
Lach caII duiing lhe conpulalion of a slialun (slialun saluialion) is
ienenleied in addilion lo ils oulcone (in lhe ansvei lalIe). Lven vhen lhe caIIs aie
ienoved in each fixpoinl ileialion (iecaII Seclion 5.17.2), nosl geneiaI ones do peisisl
as a coIIaleiaI dala sliucluie lo le used foi saving conpulalions shouId any of lhen is
caIIed again duiing eilhei conpuling a highei slialun oi a sulsequenl queiy soIving.
'cc' slands foi conpIeled conpulalion, so lhal if a caII is naiked as a conpIeled
conpulalion, il is nol even liied if caIIed again. This neans lhe foIIoving lvo poinls: 1)
Duiing lhe conpulalion of lhe neno funclion, caIIs aIieady conpuled aie nol liied lo
le soIved again, and onIy lhe enliies in lhe neno lalIe aie ieluined. 2) Moieovei,
conpuling lhe neno funclion is conpIeleIy avoided if a sulsuning aIieady-conpuled
caII can le found. In lhe fiisl case, lhal saves soIving goaIs in conpuling lhe neno
funclion. In lhe second case, lhal conpIeleIy saves fixpoinl conpulalion.
The foIIoving syslen session shovs hov lhis oplinizalion voiks. Iiisl, ve
enalIe slalislics coIIeclion, enalIe veilose oulpul lo aulonalicaIIy dispIay slalislics
iesuIls, disalIe aII lhe oplinizalions, asseil lhe facl p(1) and sulnil lhe queiy p(X):
DES> /statistics on
DES> /verbose on
DES> /optimize_cc off
Info: Complete computations optimization is off.
DES> /optimize_ep off
Info: Extensional predicate optimization is off.
DES> /optimize_nrp off
Info: Non-recursive predicates optimization is off.
DES> /optimize_st off
Info: Stratum optimization is already disabled.
DES> /optimize_sn off
Info: Differential semi-naive optimization is already disabled.
DES> /assert p(1)
Info: Computing predicate dependency graph...
Info: Computing strata...
Info: Rule asserted.
DES> p(X)
Info: Parsing query...
Info: Query successfully parsed.
Info: Solving query p(X)...
Info: Displaying query answer...
Info: Sorting answer...
{
p(1)
}
Info: 1 tuple computed.
Info: Fixpoint iterations: 2
Info: EDB retrievals : 2
Info: IDB retrievals : 0
Info: ET retrievals : 4
Info: ET look-ups : 6
Info: CT look-ups : 2
Info: CF look-ups : 0
Fernando Senz-Prez 18/234
Univeisidad ConpIulense de Madiid
DalaIog LducalionaI Syslen
As lhe slalislics shov, 2 fixpoinl ileialions have leen needed lo deduce lhe
oulpul. In lhe fiisl one, lhe iuIe p(1) is iead foi lhe fiisl line. Then, in lhe second
ileialion, il is iead again and as lhe ansvei lalIe has nol changed, lhen lhis neans lhal
lhe fixpoinl has leen ieached. The dispIay "LD ieliievaIs" shovs lhose lvo facl ieads
(LD slands foi LxlensionaI Dalalase).
If lhe sane queiy is sulnilled again:
DES> p(X)
Info: Parsing query...
Info: Query successfully parsed.
Info: Solving query p(X)...
Info: Displaying query answer...
Info: Sorting answer...
{
p(1)
}
Info: 1 tuple computed.
Info: Fixpoint iterations: 1
Info: EDB retrievals : 1
Info: IDB retrievals : 0
Info: ET retrievals : 4
Info: ET look-ups : 4
Info: CT look-ups : 1
Info: CF look-ups : 0
lhen onIy 1 ileialion is needed lo ieach lhe fixpoinl, and onIy one LD ieliievaI is
done, as lhe ansvei lalIe conlained an enliy foi p(1) aIieady foi lhe sane caII. This
iIIusliales poinl 1 alove.
Nov Iel's enalIe lhe oplinizalion, pieviousIy deIeling lhe conlenls of lhe
ansvei lalIe so lhal ve aie in lhe sane slailing silualion again:
DES> /clear_et
Info: Extension table cleared.
DES> /optimize_cc on
Info: Complete flag optimization is on.
DES> p(X)
Info: Parsing query...
Info: Query successfully parsed.
Info: Solving query p(X)...
Info: Displaying query answer...
Info: Sorting answer...
{
p(1)
}
Info: 1 tuple computed.
Info: Fixpoint iterations: 2
Info: EDB retrievals : 2
Info: IDB retrievals : 0
Info: ET retrievals : 4
Info: ET look-ups : 6
Info: CT look-ups : 2
Info: CF look-ups : 1
Fernando Senz-Prez 1!/234
Univeisidad ConpIulense de Madiid
DalaIog LducalionaI Syslen
As lefoie, 2 fixpoinl ileialions and 2 LD ieliievaIs aie needed. ul, if ve
sulnil again lhe queiy:
DES> p(X)
Info: Parsing query...
Info: Query successfully parsed.
Info: Solving query p(X)...
Info: Displaying query answer...
Info: Sorting answer...
{
p(1)
}
Info: 1 tuple computed.
Info: Fixpoint iterations: 0
Info: EDB retrievals : 0
Info: IDB retrievals : 0
Info: ET retrievals : 2
Info: ET look-ups : 2
Info: CT look-ups : 0
Info: CF look-ups : 1
lhen, as lhe conpulalion foi lhe goaI p(X) is conpIele, lhen no fixpoinl ileialions aie
needed. Ioi lhe sane ieason, no LD ieliievaIs aie needed, as jusl lhe conlenls of lhe
neno lalIe aie ieluined. This iIIusliales poinl 2 alove.
%.1(.4.2 E)tensional ?redicates D/optimize_epE
LxlensionaI piedicales aie nol needed lo le ileialiveIy conpuled. So, no
fixpoinl conpulalion is needed foi lhen. They aie knovn fion lhe piedicale
dependency giaph sinpIy lecause lhey occui in lhe giaph vilhoul inconing aics. Ioi
lhen, a Iineai felching is enough lo deiive lheii neanings. 'ep' slands foi 'exlensionaI
piedicales'.
In lhe foIIoving syslen session ve iIIusliale lhis vilh lhe facl p(1):
DES> p(X)
Info: Parsing query...
Info: Query successfully parsed.
Info: Solving query p(X)...
Info: Displaying query answer...
Info: Sorting answer...
{
p(1)
}
Info: 1 tuple computed.
Info: Fixpoint iterations: 1
Info: EDB retrievals : 1
Info: IDB retrievals : 0
Info: ET retrievals : 2
Info: ET look-ups : 3
Info: CT look-ups : 0
Info: CF look-ups : 0
vheie lheie aie 1 fixpoinl ileialion and onIy one LD ieliievaI. This oplinizalion is
independenl fion lhe conpIeled conpulalions oplinizalion.
Fernando Senz-Prez 11/234
Univeisidad ConpIulense de Madiid
DalaIog LducalionaI Syslen
Successive caIIs viII iendei lhe sane lehavioi, unIess lhe conpIele
conpulalions oplinizalion is enalIed:
DES> p(X)
Info: Parsing query...
Info: Query successfully parsed.
Info: Solving query p(X)...
Info: Displaying query answer...
Info: Sorting answer...
{
p(1)
}
Info: 1 tuple computed.
Info: Fixpoint iterations: 0
Info: EDB retrievals : 0
Info: IDB retrievals : 0
Info: ET retrievals : 2
Info: ET look-ups : 2
Info: CT look-ups : 0
Info: CF look-ups : 1
vheie no fixpoinl ileialions and no LD ieliievaIs aie needed.
%.1(.4.4 1onGrecursi0e ?redicates D/optimize_nrpE
Lach non-iecuisive piedicale can le exliacled oul fion lhe fixpoinl ileialive
cycIe lecause ils neaning can le conpuled ly iequesling aII ils soIulions al once.
Iuilhei fixpoinl ileialions von'l deveIop nev lupIes, so lhis vouId le useIess. In facl,
lhis is liue foi each non-iecuisive iuIe of a given piedicale. Though, lhis oplinizalion
is nol avaiIalIe yel.
The foIIoving exanpIe shovs lhe piedicale p as conposed of a facl and a iuIe.
Iiisl, il is conpuled vilh aII oplinizalions disalIed:
DES> /assert p(1)
DES> /assert p(X):-X=1+1
DES> p(X)
{
p(1),
p(2)
}
Info: 2 tuples computed.
Info: Fixpoint iterations: 2
Info: EDB retrievals : 2
Info: IDB retrievals : 2
Info: ET retrievals : 8
Info: ET look-ups : 8
Info: CT look-ups : 2
Info: CF look-ups : 0
Then, enalIing non-iecuisive piedicales oplinizalion and sulnilling lhe sane
queiy:
DES> /optimize_nrp on
Info: Non-recursive predicates optimization is on.
DES> /clear_et
Fernando Senz-Prez 12/234
Univeisidad ConpIulense de Madiid
DalaIog LducalionaI Syslen
DES> p(X)
{
p(1),
p(2)
}
Info: 2 tuples computed.
Info: Fixpoint iterations: 1
Info: EDB retrievals : 1
Info: IDB retrievals : 1
Info: ET retrievals : 4
Info: ET look-ups : 4
Info: CT look-ups : 0
Info: CF look-ups : 0
In onIy one fixpoinl ileialion lhe neaning is conpuled foi vhich 1 LD and 1
ID ieliievaIs aie needed (lhe facl and iuIe, iespecliveIy).
%.1(.4.% Stratum D/optimize_stE
A piedicales vhich conlain no iecuisive iuIes lul caIIs lo iecuisive piedicales
do nol need lo le conpuled in lhe sane ileialive fixpoinl conpulalion. If lhis
oplinizalion is enalIed, such piedicales aie isoIaled fion iecuisive ones in anolhei
slialun, so lhal ileialive cycIes aie saved foi lhen. This silualion occuis, foi inslance,
vhen conpiIing SQL queiies lo DalaIog, as lhe inleinediale ieIalion answer is
inlioduced. Nexl syslen session iIIusliales lhis:
DES> :-type(p(a:int))
DES> /display_answer off
DES> /display_nbr_of_tuples off
DES> /timing on
DES> /assert p(1)
DES> /assert p(X):-p(Y),X=Y+1,Y<500
DES> select * from p
Info: Solving query answer(A)...
answer(p.a:number(integer)) ->
Info: Fixpoint iterations: 500
Info: EDB retrievals : 500
Info: IDB retrievals : 1000
Info: ET retrievals : 627246
Info: ET look-ups : 252999
Info: CT look-ups : 1500
Info: CF look-ups : 0
Info: Total elapsed time: 02.755 s.
DES> /optimize_st on
DES> select * from p
Info: Solving query answer(A)...
Info: Computing by stratum of [p(A)].
answer(p.a:number(integer)) ->
Info: Fixpoint iterations: 2
Info: EDB retrievals : 502
Info: IDB retrievals : 504
Info: ET retrievals : 381248
Info: ET look-ups : 128757
Info: CT look-ups : 1006
Fernando Senz-Prez 13/234
Univeisidad ConpIulense de Madiid
DalaIog LducalionaI Syslen
Info: CF look-ups : 0
Info: Total elapsed time: 01.888 s.
Wilh lhis oplinizalion enalIed, Iess exlension lalIe Iookups aie needed and lhe
iesuIl is lheiefoie conpuled faslei. Hovevei, nole lhal non-leininalion nighl iaise
vhen lieaking sliala if using lhe nelapiedicale top: This is lecause top iequiies lhe
anounl of lupIes as indicaled fion ils goaI aigunenl. If lhis goaI is isoIaled in a highei
slialun, no lop consliainl is piopagaled lo lhe Iovei slialun, as in:
DES> :- type(p(a:int))
DES> /assert p(1)
DES> /assert p(X):-p(Y),X=Y+1
DES> select top 2 * from p
answer(p.a:number(integer)) ->
{
answer(1),
answer(2)
}
Info: 2 tuples computed.
DES> /optimize_st on
DES> select top 2 * from p
... non-terminating query
Thal is, as lhe SQL queiy has leen conpiIed lo:
answer(A) :-
top(10,p(A)).
lhen, piedicale answer/1 is Iocaled al slialun 2 and piedicale p/1 al slialun 1:
DES> /strata
[(p/1,1),(answer/1,2)]
and DLS liies lo soIve fiisl lhe goaI p(X) (nol top(10,p(A)))
11
vhich pioves lo le
non-leininaling as lheie is no lop consliainl on p. Iuilhei ieIeases nighl cope vilh
lhis issue.
%.1(.% Inde)ing D/indexingE
Theie is no piovision foi usei indexes up lo nov. Hovevei, indexing on neno
lalIes can le enalIed oi disalIed al usei iequesl. Theie aie lhiee lalIes vhich aie
indexed: lhe ansvei lalIe, lhe caII lalIe, and lhe conpIele conpulalion lalIe. The fiisl
one sloies lhe conpuled iesuIls foi lhe caIIs duiing queiy soIving and il is used in lhe
lalIing schene foi avoiding lo ieconpule aIieady knovn goaIs. The second one sloies
lhe caIIs so lhal il is possilIe lo knov vhelhei a sulsuning caII has leen done aIieady.
The lhiid lalIe sloies foi each caII vhelhei ils conpulalion has leen eilhei conpIeled
oi nol.
The nexl syslen session shovs a speed-up of aInosl 3 vhen enalIing
indexing.
11
And secondIy il vouId liy lhe goaI answer(X), aIlhough in lhis case il is unalIe
lecause of lhe non-leininaling fiisl goaI.
Fernando Senz-Prez 14/234
Univeisidad ConpIulense de Madiid
DalaIog LducalionaI Syslen
DES> /timing on
DES> /indexing off
DES> /pretty_print off
DES> /display_answer off
DES> p(X):-X=1;p(Y),Y<500,X=Y+1
Info: Processing:
p(X)
in the program context of the exploded query:
p(X) :- X=1.
p(X) :- p(Y),Y<500,X=Y+1.
Info: 500 tuples computed.
Info: Total elapsed time: 03.540 s.
DES> p(X):-X=1;p(Y),Y<500,X=Y+1
Info: Processing:
p(X)
in the program context of the exploded query:
p(X) :- X=1.
p(X) :- p(Y),Y<500,X=Y+1.
Info: 500 tuples computed.
Info: Total elapsed time: 01.279 s.
%.1(." ?orting to Unsu&&orted Systems
DLS is inpIenenled vilh seveiaI IioIog fiIes: des.pl, des_dcg.pl,
des_sql.pl, des_ra.pl, des_sql_debug.pl, des_dl_debug.pl,
des_types.pl, des_tc.pl, and des_glue.pl. The fiisl fiIe conlains lhe connon
piedicales foi aII of lhe pIalfoins (lolh IioIog inleipieleis and opeialing syslens)
foIIoving lhe IioIog ISO slandaid. IiIe des_dcg.pl, conlains lhe definilion of DCC
expansion (vhich vaiies fion one syslen lo anolhei). IiIes des_sql.pl and
des_ra.pl conlain lhe SQL and RA piocessoi, iespecliveIy. IiIes
des_sql_debug.pl and des_dl_debug.pl conlain lhe SQL and DalaIog
decIaialive deluggeis. IiIe des_types.pl, conlains lhe lype checking and infeience
syslen. IiIe des_tc.pl conlains lhe SQL lesl case geneialoi code. The Iasl fiIe
des_glue.pl conlains IioIog syslen specific code, vhich vaiy fion a syslen lo
anolhei. Adapling lhe piedicales found lheie shouId nol pose piolIens, piovided lhal
lhe IioIog inleipielei and opeialing syslen fealuie sone lasic chaiacleiislics (nainIy
aloul lhe fiIe syslen connands). In pailicuIai, finile donain consliainls is a nusl foi
suppoiling seveiaI fealuies of DLS, such as lype infeience and lesl case geneialion. If
you pIan lo poil DLS lo olhei syslens nol desciiled heie, you viII have lo nodify lhe
syslen specific IioIog fiIe lo suil youi syslen. If so, and if you vanl lo figuie as one of
lhe syslen conliilulois, pIease send an e-naiI nessage vilh lhe code and iefeience
infoinalion lo: fernan@sip.ucm.es, accepling lhal youi conliilulion viII le undei
lhe CNU Lessei CeneiaI IulIic License. (See lhe appendix foi delaiIs.)
". E)am&les
The DLS disliilulion conlains lhe diiecloiy examples vhich shovs seveiaI
fealuies of lhe syslen. UnIess expIicilIy noled, aII queiies have leen soIved aflei lhe
connands /verbose off and /pretty_print off have leen execuled.
Fernando Senz-Prez 15/234
Univeisidad ConpIulense de Madiid
DalaIog LducalionaI Syslen
".1 +elational =&erations D:iles relop.{dl,sql,ra}E
The piogian relop.dl is inlended lo shov hov lo ninic vilh DalaIog iuIes
lhe lasic ieIalionaI opeialions lhal can le found in lhe fiIe relop.sql. Il conlains
lhiee ieIalions (a, b, and c), vhich aie used as aigunenls of ieIalionaI opeialions. In
oidei lo have Ioaded lhis piogian and le alIe lo sulnil queiies you can consuIl il
vilh /c relop. In lhe ienaiks leIov, ieIalionaI opeialoi synloIs aie iepiesenled
vilh ASCII chaiacleis, as =|x| lo denole lhe Iefl oulei join , lhe Iellei x lo sinpIy
denole lhe Cailesian pioducl, and lhe Iellei U foi lhe sel union.
% (Extended) Relational Algebra Operations
% pi(X)(c(X,Y)) : Projection of the first argument of c
projection(X) :- c(X,Y).
% sigma(X=a2)(a) : Selecting tuples from a such that its first
argument is a2
selection(X) :- a(X), X=a2.
% a x b : Cartesian product of relations a and b
cartesian(X,Y) :- a(X), b(Y).
% a |x| b : Natural inner join of relations a and b
inner_join(X) :- a(X), b(X).
% a =|x| b : Left outer join of relations a and b
left_join(X,Y) :- lj(a(X), b(Y), X=Y).
% a |x|= b : Right outer join of relations a and b
right_join(X,Y) :- rj(a(X), b(Y), X=Y).
% a =|x|= b : Full outer join of relations a and b
full_join(X,Y) :- fj(a(X), b(Y), X=Y).
% a U b : Set union of relations a and b
union(X) :- a(X) ; b(X).
% a - b: Set difference of relations a and b
difference(X) :- a(X), not(b(X)).
Once lhe piogian is consuIled, you can queiy il ly, foi exanpIe:
DES> projection(X)
{
projection(a1),
projection(a2)
}
Info: 2 tuples computed.
The iesuIl of a queiy is lhe neaning of lhe viev, i.e., lhe facl sel foi lhe queiy
deiived fion lhe piogian vhelhei inlensionaIIy oi exlensionaIIy. In lhe alove
exanpIe, projection(X) coiiesponds lo lhe piojeclion of lhe fiisl aigunenl of
ieIalion c.
Fernando Senz-Prez 16/234
Univeisidad ConpIulense de Madiid
DalaIog LducalionaI Syslen
The second viev in Seclion 4.1.5 ieluins:
Info: Processing:
a(X) :- b(X).
{
a(a1),
a(a2),
a(a3),
a(b1),
a(b2)
}
Info: 5 tuples computed.
Ioi aloIishing lhis piogian and execule lhe SQL slalenenls in relop.sql,
you can lype /abolish and /process relop.sql. Nole lhal lhe exlension can le
onilled in lhe process connand.
Heie, ve depail fion lhe DalaIog inleipielei and, if you aie lo sulnil SQL
queiies, il is usefuI lo svilch lo lhe SQL inleipielei via lhe connand /sql as inpuls
viII le paised onIy ly lhe SQL paisei. Olheivise, il viII le liied lo le idenlified as a
DalaIog inpul, and lhen as an SQL inpul.
Nole lhal in lhe fiIe relop.sql Iisled leIov, sliings aie encIosed lelveen
aposliophes. This is nol needed in lhe DalaIog Ianguage. In oidei lo execule lhe
conlenls of lhis fiIe, lype /process relop.sql.
% Switch to SQL interpreter
/sql
% Creating tables
create or replace table a(a);
create or replace table b(b);
create or replace table c(a,b);
% Listing the database schema
/dbschema
% Inserting values into tables
insert into a values ('a1');
insert into a values ('a2');
insert into a values ('a3');
insert into b values ('b1');
insert into b values ('b2');
insert into b values ('a1');
insert into c values ('a1','b2');
insert into c values ('a1','a1');
insert into c values ('a2','b2');
% Testing the just inserted values
select * from a;
select * from b;
select * from c;
% Projection
select a from c;
% Selection
select a from a where a='a2';
% Cartesian product
select * from a,b;
Fernando Senz-Prez 17/234
Univeisidad ConpIulense de Madiid
DalaIog LducalionaI Syslen
% Inner Join
select a from a inner join b on a.a=b.b;
% Left Join
select * from a left join b on a.a=b.b;
% Right Join
select * from a right join b on a.a=b.b;
% Full Join
select * from a full join b on a.a=b.b;
% Union
select * from a union select * from b;
% Difference
select * from a except select * from b;
If ve have ciealed lhe ieIalions in DalaIog, ve cannol access lhen fion SQL
unIess lhey had leen eilhei defined as lalIes oi vievs oi decIaied vilh lypes. Ioi
exanpIe, foIIoving lhe fiisl aIleinalive and aflei consuIling lhe fiIe relop.dl, ve can
sulnil:
create table a(a varchar);
And, lhen, accessing vilh an SQL slalenenl lhe lupIes lhal veie asseiled in
DalaIog:
DES-SQL> select * from a;
answer(a.a) ->
{
answer(a1),
answer(a2),
answer(a3)
}
Info: 3 tuples computed.
Olheivise, an eiioi is sulnilled:
Error: Unknown table or view "a"
IoIIoving lhe second aIleinalive and aflei consuIling lhe fiIe relop.dl, ve
can decIaie lypes foi a:
DES-SQL> /datalog :-type(a,[a:varchar])
DES-SQL> select * from a
answer(a.a) ->
{
answer(a1),
answer(a2),
answer(a3)
}
Info: 3 tuples computed.
Fernando Senz-Prez 18/234
Univeisidad ConpIulense de Madiid
DalaIog LducalionaI Syslen
".2 ?at/s in a !ra&/ D:iles paths.{dl,sql,ra}E
This piogian
12
inlioduces lhe use of iecuision in DLS ly defining lhe giaph in
Iiguie 1 and lhe sel of lupIes <oiigin, deslinalion> such lhal lheie is a palh fion oiigin
lo deslinalion.
b
c
a d
Iiguie 1. Ialhs in a Ciaph
The fiIe paths.dl conlains lhe foIIoving DalaIog code, vhich can le consuIled
vilh /c paths:
% Paths in a Graph
edge(a,b).
edge(a,c).
edge(b,a).
edge(b,d).
path(X,Y) :- path(X,Z), edge(Z,Y).
path(X,Y) :- edge(X,Y).
The queiy path(X,Y) yieIds lhe foIIoving ansvei:
{
path(a,a),
path(a,b),
path(a,c),
path(a,d),
path(b,a),
path(b,b),
path(b,c),
path(b,d)
}
Info: 8 tuples computed.
The fiIe paths.sql conlains lhe SQL counleipail code, vhich can le execuled
vilh /process paths.sql:
create table edge(origin,destination);
insert into edge values('a','b');
insert into edge values('a','c');
insert into edge values('b','a');
insert into edge values('b','d');
create view paths(origin,destination) as
with
recursive path(origin,destination) as
12
Adapled fion |TS86j.
Fernando Senz-Prez 1/234
Univeisidad ConpIulense de Madiid
DalaIog LducalionaI Syslen
(select * from edge)
union
(select path.origin,edge.destination
from path,edge
where path.destination =edge.origin)
select * from path;
So, you can gel lhe sane ansvei as lefoie vilh lhe SQL slalenenl:
DES-SQL> select * from paths;
answer(paths.origin, paths.destination) ->
{
answer(a,a),
answer(a,b),
answer(a,c),
answer(a,d),
answer(b,a),
answer(b,b),
answer(b,c),
answer(b,d)
}
Info: 8 tuples computed.
Anolhei shoilei foinuIalion is aIIoved in DLS vilh lhe foIIoving viev
definilion:
create view path(origin,destination) as
select * from
(select * from edge)
union
(select path.origin,edge.destination
from path,edge
where path.destination=edge.origin)
You can finaIIy conpaie lhis vilh lhe RA foinuIalion:
paths(origin,destination) :=
select true (edge)
union
project paths.origin,edge.destination
(edge zjoin paths.destination=edge.origin paths);
".3 S/ortest ?at/s D:ile spaths.{dl,sql,ra}E
Thanks lo aggiegale piedicales, one can code lhe foIIoving veision of lhe
shoilesl palhs piolIen (fiIe spaths.dl), vhich uses lhe sane definilion of edge as lhe
pievious exanpIe:
path(X,Y,1) :-
edge(X,Y).
path(X,Y,L) :-
path(X,Z,L0),
edge(Z,Y),
count(edge(A,B),Max),
Fernando Senz-Prez 2!!/234
Univeisidad ConpIulense de Madiid
DalaIog LducalionaI Syslen
L0<Max,
L is L0+1.
sp(X,Y,L) :-
min(path(X,Y,Z),Z,L).
Nole lhal lhe infinile conpulalion lhal nay iaise fion using lhe luiIl-in is/2 is
avoided ly Iiniling lhe lolaI Ienglh of a palh lo lhe nunlei of edges in lhe giaph.
The foIIoving queiy ieluins aII lhe possilIe palhs and lheii coiiesponding
nininaI dislances:
DES> sp(X,Y,L)
{
sp(a,a,2),
sp(a,b,1),
sp(a,c,1),
sp(a,d,2),
sp(b,a,1),
sp(b,b,2),
sp(b,c,2),
sp(b,d,1)
}
Info: 8 tuples computed.
eIov is lhe SQL foinuIalion foi lhe sane piolIen (fiIe spaths.sql) :
DES-SQL> create or replace view
spaths(origin,destination,length) as with recursive
path(origin,destination,length) as
(select edge.*,1 from edge)
union
(select path.origin,edge.destination,path.length+1
from path,edge
where path.destination=edge.origin and
path.length<(select count(*) from edge))
select origin,destination,min(length) from path group by
origin,destination;
DES-SQL> select * from spaths
answer(spaths.origin, spaths.destination, spaths.length) ->
{
answer(a,a,2),
answer(a,b,1),
answer(a,c,1),
answer(a,d,2),
answer(b,a,1),
answer(b,b,2),
answer(b,c,2),
answer(b,d,1)
}
Info: 8 tuples computed.
A possilIe RA foinuIalion foIIovs:
max_length(max_length) :=
Fernando Senz-Prez 2!1/234
Univeisidad ConpIulense de Madiid
DalaIog LducalionaI Syslen
group_by [] count(*) true (edge);
path(origin,destination,length) :=
project origin,destination,1 (edge)
union
project path.origin,edge.destination,path.length+1
(
path
zjoin path.destination=edge.origin and
path.length<max_length
(edge product max_length)
);
spaths(origin,destination,length) :=
group_by origin,destination origin,destination,min(length)
true
(path);
And ils queiy:
/ra select true (spaths);
".4 .amily Aree D:iles family.{dl,sql,ra}E
This (yel anolhei cIassic) piogian defines lhe faniIy liee shovn in Iiguie 2, lhe
sel of lupIes <parent,child> such lhal parent is a paienl of child (lhe ieIalion
parent), lhe sel of lupIes <ancestor,descendant> such lhal ancestor is an
ancesloi of descendant (lhe ieIalion ancestor), lhe sel of lupIes <father,child>
such lhal father is lhe falhei of child (lhe ieIalion father), and lhe sel of lupIes
<mother,child> such lhal mother is lhe nolhei of child (lhe ieIalion mother).
amy
t om
grace
fr ed
*ac+
car ol,,,
car ol,,
t ony
car ol,
Iiguie 2. IaniIy Tiee
The fiIe family.dl conlains lhe foIIoving DalaIog code, vhich can le
consuIled vilh /c family:
father(tom,amy).
father(jack,fred).
father(tony,carolII).
father(fred,carolIII).
mother(grace,amy).
mother(amy,fred).
Fernando Senz-Prez 2!2/234
Univeisidad ConpIulense de Madiid
DalaIog LducalionaI Syslen
mother(carolI,carolII).
mother(carolII,carolIII).
parent(X,Y) :- father(X,Y).
parent(X,Y) :- mother(X,Y).
ancestor(X,Y) :- parent(X,Y).
ancestor(X,Y) :- parent(X,Z), ancestor(Z,Y).
The queiy ancestor(tom,X) yieIds lhe foIIoving ansvei (lhal is, il conpules
lhe sel of descendanls of tom):
{
ancestor(tom,amy),
ancestor(tom,carolIII),
ancestor(tom,fred)
}
Info: 3 tuples computed.
SoIving lhe viev:
son(S,F,M) :- father(F,S),mother(M,S).
yieIds lhe foIIoving ansvei, conpuling lhe sel of sons:
Info: Processing:
son(S,F,M) :- father(F,S),mother(M,S).
{
son(amy,tom,grace),
son(carolII,tony,carolI),
son(carolIII,fred,carolII),
son(fred,jack,amy)
}
Info: 4 tuples computed.
The fiIe family.sql conlains lhe SQL counleipail code, vhich can le
execuled vilh /process family.sql:
create table father(father,child);
insert into father values('tom','amy');
insert into father values('jack','fred');
insert into father values('tony','carolII');
insert into father values('fred','carolIII');
create table mother(mother,child);
insert into mother values('grace','amy');
insert into mother values('amy','fred');
insert into mother values('carolI','carolII');
insert into mother values('carolII','carolIII');
create view parent(parent,child) as
select * from father
union
select * from mother;
create or replace view ancestor(ancestor,descendant) as
select parent,child from parent
union
select parent,descendant from parent,ancestor
where parent.child=ancestor.ancestor;
Fernando Senz-Prez 2!3/234
Univeisidad ConpIulense de Madiid
DalaIog LducalionaI Syslen
The lvo exanpIe queiies alove can le foinuIaled in SQL as:
select * from ancestor where ancestor='tom';
select child,father,mother
from father,mother
where father.child=mother.child;
And aIso as RA queiies as:
/ra select ancestor='tom' (ancestor);
project child,father,mother
(father zjoin father.child=mother.child mother);
".% 4asic +ecursion ?ro*lem D:ile recursion.dlE
This exanpIe is inlended lo shov lhal queiies invoIving iecuisive piedicales do
leininale lhanks lo DLS fixpoinl soIving, ly conliasl vilh IioIogs usuaI SLD
iesoIulion.
p(0).
p(X) :- p(X).
p(1).
The queiy p(X) ieluins lhe infeiied facls fion lhe piogian iiiespeclive of lhe
appaienl infinile iecuision in lhe second iuIe. (Nole lhal lhe IioIog goaI p(1) does nol
leininale. You can easiIy check il oul vilh /prolog p(1).)
"." Aransiti0e Closure D:iles tranclosure.{dl,sql,ra}E
Wilh lhis exanpIe, ve shov a possilIe use of nuluaI iecuision ly neans of a
DalaIog piogian lhal defines lhe liansilive cIosuie of lhe ieIalions p and q
13
. Il can le
consuIled vilh /c tranclosure.
p(a,b).
p(c,d).
q(b,c).
q(d,e).
pqs(X,Y) :- p(X,Y).
pqs(X,Y) :- q(X,Y).
pqs(X,Y) :- pqs(X,Z),p(Z,Y).
pqs(X,Y) :- pqs(X,Z),q(Z,Y).
The queiy pqs(X,Y) ieluins lhe vhoIe sel of infeiied facls lhal nodeI lhe
liansilive cIosuie.
IiIe tranclosure.sql conlains lhe SQL counleipail code, vhich can le
execuled vilh /process tranclosure.sql:
create table p(x,y);
insert into p values ('a','b');
13
Taken fion |Diel87j.
Fernando Senz-Prez 2!4/234
Univeisidad ConpIulense de Madiid
DalaIog LducalionaI Syslen
insert into p values ('c','d');
create table q(x,y);
insert into q values ('b','c');
insert into q values ('d','e');
create view pqs(x,y) as
select * from p
union
select * from q
union select pqs.x,p.y from pqs,p where pqs.y=p.x
union select pqs.x,q.y from pqs,q where pqs.y=q.x;
The queiy select * from pqs ieluins lhe sane ansvei as lefoie.
IiIe tranclosure.ra conlains lhe RA foinuIalion:
pqs(x,y) :=
p
union
q
union
project pqs.x,p.y (pqs zjoin pqs.y=p.x p)
union
project pqs.x,q.y (pqs zjoin pqs.y=q.x q);
/ra select true (pqs)
".( Mutual +ecursion D:iles mutrecursion.{dl,sql,ra}E
The foIIoving piogian shovs a lasic exanpIe aloul nuluaI iecuision:
p(a).
p(b).
q(c).
q(d).
p(X) :- q(X).
q(X) :- p(X).
Sulnilling lhe goaI p(X), ve gel:
{
p(a),
p(b),
p(c),
p(d)
}
Info: 4 tuples computed.
vhich is lhe sane sel of vaIues foi aigunenls foi lhe queiy q(X). The fiIe
mrtc.dl is a conlinalion of lhis exanpIe and lhal of lhe pievious seclion.
The fiIe mutrecursion.sql conlains lhe SQL counleipail code, vhich can le
execuled vilh /process mutrecursion.sql:
/sql
/assert p(a)
/assert p(b)
/assert q(c)
/assert q(d)
Fernando Senz-Prez 2!5/234
Univeisidad ConpIulense de Madiid
DalaIog LducalionaI Syslen
-- View q must be given a prototype for view p to be defined
create view q(x) as select * from q;
create or replace view p(x) as select * from q;
create or replace view q(x) as select * from p;
Nole lhal il is needed lo luiId a void viev foi q in oidei lo have il decIaied
vhen defining lhe viev p. The void viev is lhen iepIaced ly ils acluaI definilion. The
conlenls of lolh vievs can le lesled lo le equaI vilh:
select * from p;
select * from q;
IiIe mutrecursion.ra conlains lhe RA foinuIalion:
-- View q must be given a prototype for view p to be defined
q(x) := select true (q);
p(x) := select true (q);
q(x) := select true (p);
select true (p);
select true (q);
".8 .armerG,ol:G!oatGCa**age ?uJJle D:ile puzzle.dlE
This exanpIe
14
shovs lhe cIassic Iainei-WoIf-Coal-Callage puzzIe (aIso
Missionaiies and CannilaIs as anolhei ieviillen foin). The fainei, voIf, goal, and
callage aie aII on lhe noilh shoie of a iivei and lhe piolIen is lo liansfei lhen lo lhe
soulh shoie. The fainei has a loal vhich he can iov laking al nosl one passengei al a
line. The goal cannol le Iefl vilh lhe voIf unIess lhe fainei is piesenl. The callage,
vhich counls as a passengei, cannol le Iefl vilh lhe goal unIess lhe fainei is piesenl.
The foIIoving piogian nodeIs lhe soIulion lo lhis puzzIe. The ieIalion state/4
defines lhe vaIid slales undei lhe specificalion (i.e., lhose silualions in vhich lheie is
no dangei foi any of lhe chaiacleis in oui sloiy, a slale in vhich lhe goal is Iefl aIone
vilh lhe callage nay iesuIl in an ealen callage) and inposes lhal lheie is a pievious
vaIid slale fion vhich ve depail fion. The aigunenls of lhis ieIalion aie inlended lo
iepiesenl (fion Iefl lo iighl) lhe posilion (noilh -n- oi soulh -s- shoie) of lhe fainei,
voIf, goal, and callage. We use lhe ieIalion safe/4 lo veiify lhal a given
configuialion of posilions is vaIid. The ieIalion opp/2 sinpIy slales lhal noilh is lhe
opposile shoie of soulh and vice veisa.
% Initial state
state(n,n,n,n).
% Farmer takes Wolf
state(X,X,U,V) :-
safe(X,X,U,V),
opp(X,X1),
state(X1,X1,U,V).
% Farmer takes Goat
state(X,Y,X,V) :-
safe(X,Y,X,V),
14
Adapled fion |Diel87j.
Fernando Senz-Prez 2!6/234
Univeisidad ConpIulense de Madiid
DalaIog LducalionaI Syslen
opp(X,X1),
state(X1,Y,X1,V).
% Farmer takes Cabbage
state(X,Y,U,X) :-
safe(X,Y,U,X),
opp(X,X1),
state(X1,Y,U,X1).
% Farmer goes by himself
state(X,Y,U,V) :-
safe(X,Y,U,V),
opp(X,X1),
state(X1,Y,U,V).
% Opposite shores (n/s)
opp(n,s).
opp(s,n).
% Farmer is with Goat
safe(X,Y,X,V).
% Farmer is not with Goat
safe(X,X,X1,X) :- opp(X,X1).
If ve sulnil lhe queiy state(s,s,s,s), ve gel lhe expecled iesuIl:
{
state(s,s,s,s)
}
Info: 1 tuple computed.
Thal is, lhe syslen has pioved lhal lheie is a seiiaI of liansfeis lelveen shoies
vhich finaIIy end vilh lhe asked configuialion (lhis piolIen is nol nodeIed lo shov
lhis seiiaI). If ve ask foi lhe exlension lalIe conlenls iegaiding lhe ieIalion state/4
(vilh lhe connand /list_et state/4), ve gel foi lhe ansveis:
{
state(n,n,n,n),
state(n,n,n,s),
state(n,n,s,n),
state(n,s,n,n),
state(n,s,n,s),
state(s,n,s,n),
state(s,n,s,s),
state(s,s,n,s),
state(s,s,s,n),
state(s,s,s,s)
}
Info: 10 tuples in the answer set.
This is lhe conpIele sel of vaIid slales vhich incIudes aII of lhe vaIid palhs fion
state(n,n,n,n) lo state(s,s,s,s). Hovevei, lhe oidei of slales lo ieach lhe
Iallei is nol given, lul ve can find il ly olseiving lhis ieIalion, i.e.:
state(n,n,n,n) Farmer takes Goat to south shore
state(s,n,s,n) Farmer returns to north shore
state(n,n,s,n) Farmer takes Wolf to south shore
state(s,s,s,n) Farmer takes Goat to north shore
Fernando Senz-Prez 2!7/234
Univeisidad ConpIulense de Madiid
DalaIog LducalionaI Syslen
state(n,s,n,n) Farmer takes Cabbage to south shore
state(s,s,n,s) Farmer returns to north shore
state(n,s,n,s) Farmer takes Goat to south shore
state(s,s,s,s) Final safe state
Olseive lhal lheie is lvo slales in lhe ieIalion state/4 vhich do nol foin pail
of lhe pievious palh:
state(s,n,s,s)
state(n,n,n,s)
These slales cone fion anolhei possilIe palh:
15
state(n,n,n,n) Farmer takes Goat to south shore
state(s,n,s,n) Farmer returns to north shore
state(n,n,s,n) Farmer takes Cabbage to south shore
state(s,n,s,s) Farmer takes Goat to north shore
state(n,n,n,s) Farmer takes Wolf to south shore
state(s,s,s,n) Farmer takes Goat to north shore
state(s,s,n,s) Farmer returns to north shore
state(n,s,n,s) Farmer takes Goat to south shore
state(s,s,s,s) Final safe state
".8.1 Dealing 3it/ &at/s D:ile puzzle1.dlE
As jusl iIIuslialed, lhe sequence of novenenls needed lo find a feasilIe
soIulion can le infeiied fion lhe ansvei lalIe. NonelheIess, il is possilIe lo oulcone
such sequences even vhen lheie is no piovision foi dala sliucluies. The idea is lo code
sequences of novenenls inlo a singIe pIain lype, as an inlegei. We can iesoil, foi
inslance, lo luiId a decinaI nunlei vhose digils, as iead fion right to left, indicale lhe
seIecled novenenl in lhe sequence. If ve nunlei lhe novenenl aIleinalives fion 1 lo
4 (in lhe sane oidei as iuIes occui al lhe piogian lexl) lhe fiisl soIulion alove can le
coded as 2412342, and lhe second one as 2432142.
ModeIing in lhis vay, ve can ieviile lhe piedicale slale ly adding a fiisl
aigunenl as lhe sequence needed lo ieach a given slale, and lhe slelps aIieady
peifoined. This is usefuI lo luiId lhe code as adding a nunlei (idenlifying lhe
aIleinalive iuIe) nuIlipIied ly lhe n-lh povei of len, vheie n is lhe nunlei of sleps
aIieady done. The foIIoving lvo exanpIe iuIes iIIusliales lhis:
% 0. Initial state
state(0,0,n,n,n,n).
% 1. Farmer takes Wolf
state(C,S,X,X,U,V) :-
safe(X,X,U,V),
opp(X,X1),
state(C1,S1,X1,X1,U,V),
S is S1+1,
bound(B),
S<B,
15
Renenlei lhal lhe syslen ieluins all of lhe possilIe soIulions.
Fernando Senz-Prez 2!8/234
Univeisidad ConpIulense de Madiid
DalaIog LducalionaI Syslen
C is C1+1*10**S1.
SoIving lhe nev piogian yieIds:
DES> state(C,S,s,s,s,s)
{
state(2412342.0,7,s,s,s,s),
state(2432142.0,7,s,s,s,s)
}
Info: 2 tuples computed.
Which is expIained as foIIovs:
* Solution 1: state(2412342.0,7,s,s,s,s)
0: Initial state
North: Farmer,Goat,Cabbage,Wolf
South: empty
2: Farmer takes goat to the South shore
North: Cabbage,Wolf
South: Farmer,Goat
4: Farmer returns to North shore
North: Farmer,Cabbage,Wolf
South: Goat
3: Farmer takes cabbage to the South shore
North: Wolf
South: Farmer,Cabbage,Goat
2: Farmer takes goat to the North shore
North: Farmer,Goat,Wolf
South: Cabbage
1: Farmer takes wolf to the South shore
North: Goat
South: Farmer,Cabbage,Wolf
4: Farmer returns to North shore
North: Farmer,Goat
South: Cabbage,Wolf
2: Farmer takes goat to the South shore
North: empty
South: Farmer,Goat,Cabbage,Wolf
* Solution 2: state(2432142.0,7,s,s,s,s)
0: Initial state
North: Farmer,Goat,Cabbage,Wolf
South: empty
2: Farmer takes goat to the South shore
North: Cabbage,Wolf
South: Farmer,Goat
4: Farmer returns to North shore
North: Farmer,Cabbage,Wolf
South: Goat
1: Farmer takes wolf to the South shore
North: Cabbage
South: Farmer,Goat,Wolf
2: Farmer takes goat to the North shore
North: Farmer,Goat,Cabbage
South: Wolf
Fernando Senz-Prez 2!/234
Univeisidad ConpIulense de Madiid
DalaIog LducalionaI Syslen
3: Farmer takes cabbage to the South shore
North: Goat
South: Farmer,Cabbage,Wolf
4: Farmer returns to North shore
North: Farmer,Goat
South: Cabbage,Wolf
2: Farmer takes goat to the South shore
North: empty
South: Farmer,Goat,Cabbage,Wolf
". ?arado)es D:iles russell.{dl,sql,ra}E
When negalion is used, ve can find paiadoxes, such as lhe RusseIIs paiadox
(lhe lailei in a lovn shaves eveiy peison vho does nol shave hinseIf) shovn in lhe
nexl exanpIe (pIease nole lhal lhis exanpIe is nol slialified and, in geneiaI, ve cannol
ensuie coiieclness foi non-slialifialIe piogians):
DES> /verbose on
Info: Verbose output is on.
DES> /c russell
Info: Consulting russell...
shaves(barber,M) :-
man(M),
not(shaves(M,M)).
man(barber).
man(mayor).
shaved(M) :-
shaves(barber,M).
end_of_file.
Info: 4 rules consulted.
Info: Computing predicate dependency graph...
Info: Computing strata...
Warning: Non stratifiable program.
If ve sulnil lhe queiy shaves(X,Y), ve gel lhe posilive facls as veII as a sel
of undefined infeiied infoinalion (in oui exanpIe, vhelhei lhe lailei shaves hinseIf),
as foIIovs (heie, veilose oulpul is enalIed):
DES> shaves(X,Y)
Warning: Unable to ensure correctness for this query.
{
shaves(barber,mayor)
}
Info: 1 tuple computed.
Undefined:
{
shaves(barber,barber)
}
Info: 1 tuple undefined.
If ve Iook al lhe exlension lalIe conlenls ly sulnilling lhe connand
/list_et, ve gel as ansveis:
Fernando Senz-Prez 21!/234
Univeisidad ConpIulense de Madiid
DalaIog LducalionaI Syslen
Answers:
{
man(barber),
man(mayor),
not(shaves(mayor,mayor)),
shaves(barber,mayor)
}
Info: 4 tuples in the answer set.
We can see lhal, in pailicuIai, ve have pioved addilionaI negalive infoinalion
(lhe nayoi does nol shaves hinseIf) and lhal no infoinalion is given foi lhe undefined
facls. The cuiienl inpIenenlalion uses an inconpIele aIgoiilhn foi finding such
undefined facls. We can see lhis inconpIeleness ly adding lhe foIIoving iuIe:
shaved(M) :- shaves(barber,M).
The queiy shaved(M) ieluins:
Warning: Unable to ensure correctness for this query.
{
shaved(mayor)
}
Info: 1 tuple computed.
Thal is, lhe syslen is unalIe lo piove lhal shaved(barber) is undefined.
If you Iook al lhe piedicale dependency giaph and lhe slialificalion of lhe
piogian:
DES> /pdg
Nodes: [man/1,shaved/1,shaves/2]
Arcs : [shaves/2-shaves/2,shaves/2+man/1,shaved/1+shaves/2]
DES> /strata
[non-stratifiable]
you gel lhe piedicale dependency giaph shovn in Iiguie 4, and you aie infoined lhal
lhe piogian is non-slialifialIe. This figuie shovs a negalion in a cycIe, so lhal lhe
piogian is nol slialifialIe. (The syslen vained of lhis silualion vhen lhe piogian vas
Ioaded.)
+
shaves
man shaved
+
-
Iiguie 4. Iiedicale Dependency Ciaph foi russell.dl
Hovevei, even vhen a piogian is non-slialifialIe, lheie nay exisl a queiy vilh
an associaled piedicale dependency sulgiaph so lhal negalion does nol occui in any
cycIe. Ioi inslance, lhis occuis vilh lhe queiy man(X) in lhis piogian:
Fernando Senz-Prez 211/234
Univeisidad ConpIulense de Madiid
DalaIog LducalionaI Syslen
DES> man(X)
Info: Stratifiable subprogram found for the given query.
{
man(barber),
man(mayor)
}
Info: 2 tuples computed.
Heie, lhe syslen ieconpuled lhe sliala foi lhe piedicale dependency sulgiaph,
and infoined lhal il found a slialifialIe sulpiogian foi such a queiy. In lhis sinpIe
case, no noie negalions veie invoIved in lhe sulgiaph, lul noie eIaloialed
dependencies can le found in olhei exanpIes (cf. Seclions 6.1O and 6.11).
Slialificalion nay le needed foi piogians vilhoul negalion as Iong as a
lenpoiaiy viev conlains a negaled goaI. Considei lhe foIIoving viev undei lhe
piogian relop.dl (iuIes in lhe piogian vilh negalion aie nol piesenl in lhe
sulgiaph foi lhe queiy d(X)):
DES> d(X) :- a(X), not(b(X))
Info: Processing:
d(X) :- a(X),not(b(X)).
{
d(a2),
d(a3)
}
Info: 2 tuples computed.
In lhis viev, lhe queiy d(X) is soIved vilh a soIve-ly-slialun aIgoiilhn,
desciiled in Seclion 5.17.3. In lhis case, lhis neans lhal lhe goaI b(X) is soIved lefoie
ollaining lhe neaning of d(X) lecause b is in a Iovei slialun lhan d and il is needed
foi lhe conpulalion of d.
The lasic paiadox p:-not(p) can le found in lhe fiIe paiadox.dI, vhose
nodeI is undefined as you can lesl vilh lhe queiy p.
".1' ?arity D:ile parity.dlE
This exanpIe piogian
16
is inlended lo conpule lhe paiily of a given lase
ieIalion br(X), i.e., il can deleinine vhelhei lhe nunlei of eIenenls in lhe ieIalion
(caidinaIily) is even oi odd ly neans of lhe piedicales br_is_even, and br_is_odd,
iespecliveIy. The piedicale next defines an ascending chain of eIenenls in br lased
on lheii lexluaI oideiing, vheie lhe fiisl Iink of lhe chain connecls lhe dislinguished
node nil lo lhe fiisl eIenenl in br. The piedicales even and odd define lhe even,
iesp. odd, eIenenls in lhe chain. The piedicale has_preceding defines lhe eIenenls
in br such lhal lheie aie pievious eIenenls lo a given one (lhe fiisl eIenenl in lhe
chain has no pieceding eIenenls). The iuIe defining lhis piedicale incIudes an
inlended eiioi (fouilh iuIe in lhe exanpIe) vhich viII le used in Seclion 6.13 lo shov
hov il is caughl ly lhe decIaialive deluggei.
% Pairs of non-consecutive elements in br
16
Adapled fion |ZCI+97j.
Fernando Senz-Prez 212/234
Univeisidad ConpIulense de Madiid
DalaIog LducalionaI Syslen
between(X,Z) :-
br(X), br(Y), br(Z), X<Y, Y<Z.
% Consecutive elements in the sequence, starting at nil
next(X,Y) :-
br(X), br(Y), X<Y, not(between(X,Y)).
next(nil,X) :-
br(X), not(has_preceding(X)).
% Values having preceding values in the sequence
has_preceding(X) :-
br(X), br(Y), Y>X. %error: Y>X should be Y<X
% Values in an even position of the sequence, including nil
even(nil).
even(Y) :-
odd(X), next(X,Y).
% Values in an odd position of the sequence
odd(Y) :-
even(X), next(X,Y).
% Succeeds if the cardinality of the sequence is even
br_is_even :-
even(X), not(next(X,Y)).
% Succeeds if the cardinality of the sequence is odd
br_is_odd :-
odd(X), not(next(X,Y)).
% Base relation
br(a).
br(b).
".11 !rammar D:ile grammar.dlE
Iaiseis can aIso le coded as DalaIog piogians. In lhis exanpIe
17
, a sinpIe Iefl-
iecuisive giannai anaIysei is coded foi lhe foIIoving giannai iuIes.
A -> a
A -> Al
A -> Aa
Il vas lesled vilh lhe inpul sliing alala, vhich is coded vilh lhe ieIalion
t(F,T,L), F foi lhe posilion of loken T lhal ends al posilion L.
t(1,a,2).
t(2,b,3).
t(3,a,4).
t(4,b,5).
t(5,a,6).
17
Taken fion |ID92j.
Fernando Senz-Prez 213/234
Univeisidad ConpIulense de Madiid
DalaIog LducalionaI Syslen
a(F,L) :- t(F,a,L).
a(F,L) :- a(F,M), t(M,b,L).
a(F,L) :- a(F,M), t(M,a,L).
DES> a(1,6)
{
a(1,6)
}
Info: 1 tuple computed.
".12 .i*onacci D:ile fib.{dl,sql,ra}E
The aII-line cIassics Iilonacci piogian
18
can le coded in DLS lhanks lo
aiilhnelic luiIl-ins. Il can le foinuIaled as foIIovs:
fib(0,1).
fib(1,1).
fib(N,F) :-
N>1,
N2 is N-2,
fib(N2,F2),
N1 is N-1,
fib(N1,F1),
F is F2+F1.
Since DLS is inpIenenled vilh exlension lalIes, conpuling high Iilonacci
nunleis is possilIe vilh Iineai conpIexily:
DES> fib(1000,F)
{
fib(1000,7033036771142281582183525487718354977018126983635873274
2604905087154537118196933579742249494562611733487750449241765991
0881863632654502236471060120533741212738673391111981393731255987
67690091902245245323403501)
}
Info: 1 tuple computed.
AIso, il is possilIe lo foinuIale lhis in SQL, even vhen lhe nexl viev fealuies
non-Iineai iecuision (fiIe fib.sql):
create view fib(n,f) as
select 0,1
union
select 1,1
union
select fib1.n+1,fib1.f+fib2.f
from fib fib1, fib fib2
where fib1.n=fib2.n+1 and fib1.n<10;
As veII, nexl lheie is a possilIe RA foinuIalion (fiIe fib.ra):
fib(n,f) :=
project 0,1 (dual)
18
Taken fion |ID92j.
Fernando Senz-Prez 214/234
Univeisidad ConpIulense de Madiid
DalaIog LducalionaI Syslen
union
project 1,1 (dual)
union
project fib1.n+1,fib1.f+fib2.f
(rename fib1(n1,f1) (fib)
zjoin
n1=n2+1 and n1<10
rename fib2(n2,f2) (fib));
".13 @anoi Ao3ers D:ile hanoi.dlE
Anolhei veII-knovn loy puzzIe is lhe loveis of Hanoi, vhich can le coded as:
hanoi(1,A,B,C).
hanoi(N,A,B,C) :-
N>1,
N1 is N-1,
hanoi(N1,A,C,B),
hanoi(N1,C,B,A).
We can sulnil lhe foIIoving queiy foi 1O discs:
DES> hanoi(10,a,b,c)
{
hanoi(10,a,b,c)
}
Info: 1 tuple computed.
Nole lhal lhe ansvei lo lhis queiy does nol iefIecl lhe novenenls of lhe discs,
vhich can le olheivise shovn as lhe inleinediale iesuIls kepl in lhe exlension lalIe:
DES> /list_et hanoi
Answers:
{
hanoi(1,a,c,b),
hanoi(1,b,a,c),
hanoi(1,c,b,a),
hanoi(2,a,b,c),
hanoi(2,b,c,a),
hanoi(2,c,a,b),
hanoi(3,a,c,b),
hanoi(3,b,a,c),
hanoi(3,c,b,a),
hanoi(4,a,b,c),
hanoi(4,b,c,a),
hanoi(4,c,a,b),
hanoi(5,a,c,b),
hanoi(5,b,a,c),
hanoi(5,c,b,a),
hanoi(6,a,b,c),
hanoi(6,b,c,a),
hanoi(6,c,a,b),
hanoi(7,a,c,b),
hanoi(7,b,a,c),
hanoi(7,c,b,a),
Fernando Senz-Prez 215/234
Univeisidad ConpIulense de Madiid
DalaIog LducalionaI Syslen
hanoi(8,a,b,c),
hanoi(8,b,c,a),
hanoi(8,c,a,b),
hanoi(9,a,c,b),
hanoi(9,c,b,a),
hanoi(10,a,b,c)
}
Info: 27 tuples in the answer set.
...
".14 =t/er E)am&les
Diiecloiy exanpIes incIude sone olhei exanpIes as lhe fiIes bom.dl (liII of
naleiiaIs) and trains.dl (liain conneclions) vhich shov noie exanpIe appIicalions
incIuding negalion. Olhei exanpIes aie orbits.dl (a cosnos liny dalalase), sg.dl
(sane geneialion foi a faniIy dalalase), tc.dl (liansilive cIosuie), and
empTraining.{ra,sql} (laken fion |DielO1j). AIso, lhe foIdei persistent
conlains exanpIes foi peisisling piedicales, lhe foIdei ontology incIudes exanpIes of
aulhoiing onloIogies, incIuding sone docunenlalion, and foIdeis DLDebugger and
SQLDebugger incIude exanpIes foi delugging DalaIog piogians and SQL vievs,
iespecliveIy.
(. Contri*utions
This seclion coIIecls lhe conliilulions fion exleinaI deveIopeis up lo nov:
Tesl Case Ceneialoi.
Authors: RafaeI CalaIIeio-RoIdn, YoIanda Caica-Ruiz, and Ieinando Senz-Ieiez
.ate: 1O/2OO9 (upgiaded veision suppoiled since DLS 1.8.O)
.escription: TooI foi geneialing lesl cases foi SQL vievs
/icense: LCIL
0ontact: YoIanda Caica-Ruiz (InpIenenloi)
DalaIog DecIaialive Deluggei.
Authors: RafaeI CalaIIeio-RoIdn, YoIanda Caica-Ruiz, and Ieinando Senz-Ieiez
.ate: 5/2OO7
.escription: TooI foi lhe decIaialive delugging of DalaIog piogians
/icense: LCIL
0ontact: YoIanda Caica-Ruiz (InpIenenloi)
ACIDL (A ConfiguialIe DeveIopnenl Lnviionnenl).
Authors+ Diego CaidieI Iieiie, }uan }ose Oiliz Snchez, DeIfn Rupeiez Caas (SI
2OO6/2OO7), MigueI Mailn Lzaio (SI 2OO7/2OO8), and }aviei SaIcedo Cnez (SI
2O1O/2O11), IalIo Culieiiez Caica-Iaido, LIena Tejeiio Ieiez de gieda, Andies
Vicenle deI Cuia (SI 2O12/2O13) Ied ly Ieinando Senz.
.ate: 3/2OO7 (ACIDL O.1, fiisl veision), 11/2OO8 (ACIDL O.7), 7/2O11 (ACIDL O.8),
12/2O12 (ACIDL O.9, cuiienl veision)
.escription+ This piojecl is ained lo piovide a nuIlipIalfoin configuialIe
inlegialed deveIopnenl enviionnenl vhich can le configuied in oidei lo le used
vilh any deveIopnenl syslen such as inleipieleis, conpiIeis and dalalase
syslens. Iealuies of lhis syslen incIude: piojecl nanagenenl, nuIlifiIe ediling,
synlax coIouiing, and paising on-lhe-fIy (vhich infoins of synlax eiiois vhen
Fernando Senz-Prez 216/234
Univeisidad ConpIulense de Madiid
DalaIog LducalionaI Syslen
ediling piogians piioi lo lhe conpiIalion).
/icense: CIL.
Pro1ect 2eb Page: http://acide.sourceforge.net/
Lnacs deveIopnenl enviionnenl.
Author+ Maikus Tiiska.
.ate: 2/22/2OO7
.escription+ Iiovides an inlegialion of DLS inlo Lnacs. Once a DalaIog fiIe has
leen opened, you can consuIl il ly piessing I1 and sulnil queiies and connands
fion Lnacs. This voiks al Ieasl in conlinalion vilh SWI-IioIog (il depends on lhe
-s svilch), olhei syslens nay iequiie sIighl nodificalions.
/icense: CIL.
Pro1ect 2eb Page: http://stud4.tuwien.ac.at/~e0225855/index.html
0ontact: markus.triska@gmx.at
Installation: Copy des.el (in lhe conliilulois vel page) lo youi hone diiecloiy
and add lo youi .emacs:
(load "~/des")
; adapt the following path as necessary:
(setq des-prolog-file "~/des/systems/swi/des.pl")
(add-to-list 'auto-mode-alist '("\\.dl$" . des-mode))
Reslail Lnacs, open a *.dl fiIe lo Ioad il inlo a DLS piocess (lhis cuiienlIy onIy
voiks vilh SWI-IioIog). If lhe iegion is aclive, I1 consuIls lhe lexl in lhe iegion.
You can lhen inleiacl vilh DLS as on a leininaI.
8. +elated ,or-
Theie has leen a high anounl of voik aiound deduclive dalalases |RU95j (ils
inleiesl deIiveied nany voikshops and confeiences foi lhis suljecl) vhich deaIl lo
seveiaI syslens. Hovevei, lo lhe lesl of oui knovIedge, lheie is no a fiiendIy syslen
oiienled lo inlioducing deduclive dalalases vilh seveiaI queiy Ianguages lo sludenls.
NeveilheIess, on lhe one hand, ve can connenl sone iepiesenlalive deduclive
dalalase syslens. On lhe olhei hand, aIso sone lechnoIogicaI liansfeis lo face ieaI-
voiId piolIens.
8.1 Deducti0e Data*ase Systems
4QL |MS11j is a iecenl deveIopnenl of a iuIe-lased dalalase queiy Ianguage
vilh negalion aIIoved in lodies and heads of iuIes, vhich is founded on a foui-vaIued
senanlics vilh liulh vaIues: liue, faIse, inconsislenl and unknovn. Il piovides neans
foi a unifoin liealnenl of Open and LocaI CIosed WoiId, olhei
nonnonolonic/connonsense foinaIisns, incIuding vaiious vaiianls of defauIl
ieasoning, auloepislenic ieasoning and olhei foinaIisns appIicalion-specific
disanligualion of inconsislenl infoinalion, incIuding defeasilIe ieasoning.
Conceplase |}}NS98j is a nuIli-usei deduclive oljecl nanagei nainIy inlended
foi concepluaI nodeIing and cooidinalion in design enviionnenls. Il is nuIlipIalfoin,
oljecl-oiienled, il enjoys inlegiily consliainls, dalalase updales and seveiaI olhei
inleiesling fealuies.
The LDL piojecl al MCC Iead lo lhe LDL++ syslen |AOTWZO3j, a deduclive
dalalase syslen vilh fealuies such as X-Y slialificalion, sel and conpIex leins,
Fernando Senz-Prez 217/234
Univeisidad ConpIulense de Madiid
DalaIog LducalionaI Syslen
dalalase updales and aggiegales. Il can le cuiienlIy used lhiough Inleinel using a
}ava-enalIed cIienl.
DLV |II96j is a nuIlipIalfoin syslen foi disjunclive DalaIog vilh consliainls,
liue negalion (a Ia CeIfond & Lifschilz) and queiies. Il incIudes lhe K pIanning syslen,
a fionlend foi alduclive diagnosis and Reilei's diagnosis, suppoil foi inheiilance, and
an SQL fionl-end vhich piololypes sone noveI SQL3 fealuies. DLV
D
is an exlension
of DLV vhich piovides inleifaces vilh ieIalionaI dalalases, laking advanlage of lheii
efficienl inpIenenlalions lo speed-up conpulalions.
XS |RSSWI97j (http://xsb.sourceforge.net/) is an exlended IioIog
syslen lhal can le used foi deduclive dalalase appIicalions. Il enjoys a veII-founded
senanlics foi iuIes vilh negalive IileiaIs in iuIe lodies and inpIenenls lalIing
nechanisns. Il iuns lolh on Unix/Linux and Windovs opeialing syslens. DalaIog++
|Tang99j is a fionl-end foi lhe XS deduclive dalalase syslen.
lddlddl |WLO4j slands foi DD-ased Deduclive Dalaase. Il is an
inpIenenlalion of DalaIog lhal iepiesenls lhe ieIalions using linaiy decision diagians
(DDs). DDs aie a dala sliucluie lhal can efficienlIy iepiesenl Iaige ieIalions and
piovide efficienl sel opeialions. This aIIovs lddlddl lo efficienlIy iepiesenl and
opeiale on exlieneIy Iaige ieIalions.
IRIS (Inlegialed RuIe Infeience Syslen) |IRIS2OO8j is a }ava inpIenenlalion of
an exlensilIe ieasoning engine foi expiessive iuIe-lased Ianguages piovided as an
AII. Suppoils safe oi un-safe DalaIog vilh (IocaIIy) slialified oi veII-founded negalion
as faiIuie, funclion synloIs and lollon-up iuIe evaIualion.
CoiaI |RSSS94j is a deduclive syslen vilh a decIaialive queiy Ianguage lhal
suppoils geneiaI Hoin cIauses augnenled vilh conpIex leins, sel-giouping,
aggiegalion, negalion, and ieIalions vilh lupIes lhal conlain (univeisaIIy quanlified)
vaiialIes. Il onIy iuns undei Unix pIalfoins. Theie is aIso a veision vhich aIIovs
oljecl-oiienled fealuies, caIIed CoiaI++ |SRSS93j.
ILORID (I-LOgic Reasoning In Dalalases) |KLW95j is a deduclive oljecl-
oiienled dalalase syslen suppoiling I-Logic as dala definilion and queiy Ianguage.
Wilh lhe incieasing inleiesl in senisliucluied dala, IIoiid has leen exlended foi
handIing senisliucluied dala in lhe conlexl of Infoinalion Inlegialion fion lhe
Senanlic Wel.
The NAIL! piojecl deIiveied a piololype vilh slialified negalion, veII-founded
negalion, and noduIaiily slialified negalion. Lalei, il added lhe Ianguage CIue, vhich
is essenliaIIy singIe IogicaI iuIes, vilh SQL slalenenls viapped in an inpeialive
convenlionaI Ianguage |IDR91, DMI93j. The appioach of conlining lvo Ianguages is
siniIai lo lhe afoienenlioned CoiaI, vhich uses C++. Il does nol iun on Windovs
pIalfoins.
Anolhei deduclive dalalase foIIoving lhis conlinalion of decIaialive and
inpeialive Ianguages is Rock&RoII |IIWD94j.
ADITI 2 |VRK+91j is lhe Iasl veision of a deduclive dalalase syslen vhich uses
lhe Iogic/funclionaI piogianning Ianguage Meicuiy. Il does nol iun on Windovs
pIalfoins. Theie is no fuilhei deveIopnenl pIanned foi Adili.
See aIso lhe DalaIog enliy in Wikipedia (http://en.wikipedia.org/wiki/
Datalog).
Fernando Senz-Prez 218/234
Univeisidad ConpIulense de Madiid
DalaIog LducalionaI Syslen
8.2 Aec/nological Arans:ers
DalaIog has leen exlensiveIy sludied and is gaining a ienovned inleiesl lhanks
lo lheii appIicalion lo onloIogies |IHHO4j, senanlic vel |CCLO9j, sociaI nelvoiks
|RSO9j, poIicy Ianguages |ICO7j, and even foi oplinizalion |CTZO5j. Conpanies as
LogicIox, Lxeuia, SennIe, and Lixlo enlody DalaIog-lased deduclive dalalase
lechnoIogies in lhe soIulions lhey deveIop. The high-IeveI expiessivily of DalaIog and
ils exlensions has lheiefoie leen acknovIedged as a poveifuI fealuie lo deaI vilh
knovIedge-lased infoinalion.
The fiisl conneiciaI oiienled deduclive dalalase syslen vas lhe Snail Dala
Syslen (SDS) and ils decIaialive queiy Ianguage DecIaialive Reasoning (DLCLARL)
|KSSD94j, vilh suppoil foi slialified negalion and sels. CuiienlIy, XS and DLV have
leen piojecled lo spin-off conpanies and lhey deveIop deduclive soIulions lo ieaI-
voiId piolIens.
. .uture En/ancements
The foIIoving Iisl (in oidei of inpoilance) suggesls sone poinls lo addiess foi
enhancing DLS:
Disjunclive heads
Infoinalion aloul cycIes invoIving negalion in lhe Ioaded piogian
ConpIele aIgoiilhn foi finding undefined infoinalion
Consliainls (ieaIs, inlegeis, enuneialed lypes)
Iiecise eiioi iepoiling foi SQL and DalaIog synlax eiiois
If you find voilhvhiIe foi youi appIicalion eilhei sone of lhe poinls alove, oi
olheis nol Iisled, pIease infoin lhe aulhoi foi liying lo guide lhe inpIenenlalion lo lhe
nosl denanded poinls.
1'. Ca0eats and $imitations
DalaIog:
o No conpound leins as aigunenls in usei ieIalions
o Teininalion is ensuied up lo aiilhnelic and hypolheses. Theie is no
piovision foi nuneiicaI lounds
o No dalalase updales via DalaIog iuIes aie aIIoved
o RuIes in consuIled fiIes nusl end vilh a dol, in conliasl lo connand
pionpl inpuls in singIe-Iine node, vheie lhe dol is oplionaI. RuIes in a
consuIled fiIe nay span on nuIlipIe Iines and an ending dol is
nandaloiy, iiiespeclive lhe nuIli-Iine node
SQL:
o Usei idenlifieis (incIuding lalIes, vievs, coIunn nanes) aie case
sensilive
Fernando Senz-Prez 21/234
Univeisidad ConpIulense de Madiid
DalaIog LducalionaI Syslen
o ConpulalIe SQL slalenenls foIIov lhe giannai in Seclion 4.2.8 of lhis
nanuaI. The cuiienl giannai paises exlia cIauses vhich cannol le
conpuled yel (e.g., ANY, ...)
o alch updales and deIelions aie nol alonic
o Tiansaclions aie nol inpIenenled
o NuIIs and nuII-ieIaled opealions do nol exaclIy foIIov lhe SQL slandaid
o Viev definilions in a WITH cIause aie gIolaI, in conliasl lo lhe SQL
slandaid
o Sone DMS's as IM D2 via an ODC conneclion use uppeicase usei
idenlifieis, even vhen lhey aie decIaied in Ioveicase
o See aIso Seclion 5.1.7 iegaiding ODC conneclions
SQL deluggei:
o SQL delugging is nol suppoiled foi ODC conneclions, up lo nov
Tesl case geneialoi:
o Tesl case geneialion is nol suppoiled foi ODC conneclions, up lo nov
SQL liacei:
o SQL liacing is nol suppoiled foi ODC conneclions, up lo nov
MisceIIanea:
o LnalIing dupIicales can nolalIy hain peifoinance (cf. Iilonacci
exanpIe)
o Useis shouId nol viile piedicale idenlifieis slailing vilh lhe synloI '$'.
Olheivise, unexpecled lehavioui nighl happen
o alch piocessing cannol le nesled
IioIog syslens' specific issues:
o SWI-IioIog disliilulions do nol aIIov aiilhnelic expiessions invoIving
log/2
11. +elease 1otes
This seclion Iisls ieIease noles of lhe cuiienl DLS veision.
11.1 Version 3.4 o: DES Dreleased on Decem*erI 18t/I 2'13E
Lnhancenenls:
o Nev veision of ACIDL O.12, incIuding as upgiades:
Nev IDC paneI, dispIayed eilhei vhen a /pdg connand is issued
oi on denand in lhe Viev nenu. DispIay piopeilies of lhis paneI
have leen added lo lhe appIicalion nenu
ReIocalalIe paneIs. A paneI can le diagged lo anolhei paneI
posilion, inleichanging lolh paneIs Iocalions
Fernando Senz-Prez 22!/234
Univeisidad ConpIulense de Madiid
DalaIog LducalionaI Syslen
o RA exlended piojeclion incIudes aIso lhe possiliIily of ienanings
o Added Iisling of offending iuIes foi sel vaiialIes unsafely
o Added node infoinalion foi sel vaiialIes unsafely
o Ciealion of incoiiecl vievs no Iongei dispIays lhe geneiic eiioi nessage
o Sone incoiiecl SQL slalenenls due lo aggiegales aie calched
o Consliainls aie checked aIong updales
o DalaIog division opeialoi can le nesled
Changes:
o Sulnilling an oidei_ly ieIaled queiy oveiiides cuiienl /order_answer
fIag. Theie is no need lo sulnil /order_answer off lo nake soiled
Iislings voik
o DupIicale eIininalion (dupIicales disalIed and dislincl opeialoi) consideis
diffeienl nuIIs as lhe sane nuII, lheiefoie lehaving noie cIoseIy lo SQL
o VaiialIe oidei in conpiIed iuIes
Iixed lugs:
o The division opeialion vas incoiiecl in RA and SQL
o Aggiegales incIuded exlia lupIes aIong nesled hypolhelicaI assunplions
o Renoved undecIaied piedicale vaining foi true/O vhen occuiiing as a
condilion
o The piedicale group_by vas funclioning incoiieclIy in sone cases,
depending on pievious lalIed iesuIls
o Undefined piedicale vaining ienoved foi false/O
o SQL NOT EXISTS cIause vas incoiieclIy liansIaled ly adding a lop-1 goaI
o Conpuling lhe order_by piedicale vas onilled foi /order_answer on.
So, a queiy as top(1,order_by(t(X),[X])) nighl deIivei an incoiiecl
ansvei
o In nuIliIine node, vhen piocessing a fiIe conlaining a lal and an SQL Iine
ienaik (--), lhen lhe nexl Iine vas consideied as a pail of lhe ienaik
o uiIl-ins veie liied lo le nade peisislenl foi peisislenl iuIes incIuding
lhen
o Reliacling an ID iuIe foi a peisislenl piedicale did nol iefiesh lhe dalalase
schena
o Assuning ID iuIes in an hypolhelicaI inpIicalion Iead lo exceplions in
sone cases
o The conlinalion of lop and dislincl nelapiedicales pioduced exlia lupIes
o TiansIalion of lhe DalaIog division opeialoi Iead lo ienove head vaiialIes
nol invoIved in lhe opeialion
o Anonynous vaiialIes in consuIled iuIes veie given nanes
Fernando Senz-Prez 221/234
Univeisidad ConpIulense de Madiid
DalaIog LducalionaI Syslen
12. 2c-no3ledgements
The aulhoi vishes lo lhank }. WieIenakei foi pioviding such an anazing fiee
IioIog syslen and suppoiling heIp. Mals CaiIsson and Iei MiIdnei, al SICS,
suppoiled lhe deveIopnenl pioviding heIp and nev capaliIilies in lhe ODC Iiliaiy.
AIso, lhanks lo aII lhe peopIe pioviding feedlack, since lhey aie guiding DLS lo suil
noie denanded iequiienenls. Conliilulois aie speciaIIy acknovIedged: Maikus
Tiiska, foi deveIoping lhe Lnacs IDL and aIso aulhoi of lhe SWI-IioIog cIpfd Iiliaiy,
and lhe sludenls Diego CaidieI Iieiie, }uan }ose Oiliz Snchez, DeIfn Rupeiez Caas,
MigueI Mailn Lzaio, }aviei SaIcedo Cnez, IalIo Culieiiez Caica-Iaido, LIena
Tejeiio Ieiez de gieda, Andies Vicenle deI Cuia, Ieinando Oidas Loienle, }uan }ose
Maiques Oiliz, and Senianis Culieiiez Quinlana, vho deveIoped and inpioved
ACIDL. Thanks lo YoIanda Caica and RafaeI CalaIIeio foi naking possilIe lo
decIaialive delug DalaIog and SQL dalalases. They aie aIso key aulhois in lhe
incIusion of lesl case geneialion foi SQL vievs. In pailicuIai, YoIanda look lhe
inpIenenlalion effoil suppoiled ly RafaeI. CaliieI Aianda Lpez and Sonia Lslevez
Mailn geneialed Mac OSX Snov Leopaid and Leopaid execulalIes, iesp. foi veisions
up lo DLS 2.6. Lniique Mailn Mailn fixed lhe Linux disliilulion of DLS 1.5.O. IinaIIy,
lhanks lo lhe Spanish piojecls IAST-STAMI (TIN2OO8-O6622-CO3-O1), Iionelidos-CM
(S2OO9TIC-1465) and CID-UCM (UCM-SCH-CR35/1O-A-91O5O2) vhich suppoiled
lhis voik in lhe conlexl of lhe Univeisily ConpIulense of Madiid and lhe Depailnenl
of AilificiaI InleIIigence and Soflvaie Lngineeiing.
Fernando Senz-Prez 223/234
Univeisidad ConpIulense de Madiid
DalaIog LducalionaI Syslen
2&&endi) 2. $icense
A.1 Software License
DLS Iicensing cones fion lhe ideas of lhe Iiee Soflvaie Ioundalion. Since veision 3.O,
il is disliiluled undei veision 3 of lhe CNU Lessei CeneiaI IulIic License (LCIL),
vhich suppIenenls veision 3 of lhe CNU CeneiaI IulIic License.
DLS is fiee soflvaie: you can iedisliilule il and/oi nodify il undei lhe leins of lhe
CNU CeneiaI IulIic License as pulIished ly lhe Iiee Soflvaie Ioundalion, eilhei
veision 3 of lhe License, oi (al youi oplion) any Ialei veision.
DLS is disliiluled in lhe hope lhal il viII le usefuI, lul WITHOUT ANY WARRANTY,
vilhoul even lhe inpIied vaiianly of MLRCHANTAILITY oi IITNLSS IOR A
IARTICULAR IURIOSL. See lhe CNU CeneiaI IulIic License foi noie delaiIs.
You shouId have ieceived a copy of lhe CNU CeneiaI IulIic License aIong vilh lhis
piogian. If nol, see hllp://vvv.gnu.oig/Iicenses/.
DLS veisions piioi lo 3.O veie disliiluled undei CNU CeneiaI IulIic License (CIL).
A.2 Documentation License
!1U .ree Documentation $icense
Veision 1.3, 3 Novenlei 2OO8
Copyiighl 2OOO, 2OO1, 2OO2, 2OO7, 2OO8 Iiee Soflvaie Ioundalion, Inc.
<hllp://fsf.oig/>
Lveiyone is peinilled lo copy and disliilule veilalin copies of lhis Iicense docunenl,
lul changing il is nol aIIoved.
'. ?+E2M4$E
The puipose of lhis License is lo nake a nanuaI, lexllook, oi olhei funclionaI and
usefuI docunenl "fiee" in lhe sense of fieedon: lo assuie eveiyone lhe effeclive
fieedon lo copy and iedisliilule il, vilh oi vilhoul nodifying il, eilhei conneiciaIIy
oi nonconneiciaIIy. SecondaiiIy, lhis License pieseives foi lhe aulhoi and pulIishei a
vay lo gel ciedil foi lheii voik, vhiIe nol leing consideied iesponsilIe foi
nodificalions nade ly olheis.
This License is a kind of "copyIefl", vhich neans lhal deiivalive voiks of lhe
docunenl nusl lhenseIves le fiee in lhe sane sense. Il conpIenenls lhe CNU CeneiaI
IulIic License, vhich is a copyIefl Iicense designed foi fiee soflvaie.
We have designed lhis License in oidei lo use il foi nanuaIs foi fiee soflvaie, lecause
fiee soflvaie needs fiee docunenlalion: a fiee piogian shouId cone vilh nanuaIs
pioviding lhe sane fieedons lhal lhe soflvaie does. ul lhis License is nol Iiniled lo
soflvaie nanuaIs, il can le used foi any lexluaI voik, iegaidIess of suljecl nallei oi
vhelhei il is pulIished as a piinled look. We ieconnend lhis License piincipaIIy foi
voiks vhose puipose is insliuclion oi iefeience.
1. 2??$IC24I$IAK 21D DE.I1IAI=1S
Fernando Senz-Prez 224/234
Univeisidad ConpIulense de Madiid
DalaIog LducalionaI Syslen
This License appIies lo any nanuaI oi olhei voik, in any nediun, lhal conlains a
nolice pIaced ly lhe copyiighl hoIdei saying il can le disliiluled undei lhe leins of
lhis License. Such a nolice gianls a voiId-vide, ioyaIly-fiee Iicense, unIiniled in
duialion, lo use lhal voik undei lhe condilions slaled heiein. The "Docunenl", leIov,
iefeis lo any such nanuaI oi voik. Any nenlei of lhe pulIic is a Iicensee, and is
addiessed as "you". You accepl lhe Iicense if you copy, nodify oi disliilule lhe voik
in a vay iequiiing peinission undei copyiighl Iav.
A "Modified Veision" of lhe Docunenl neans any voik conlaining lhe Docunenl oi a
poilion of il, eilhei copied veilalin, oi vilh nodificalions and/oi liansIaled inlo
anolhei Ianguage.
A "Secondaiy Seclion" is a naned appendix oi a fionl-nallei seclion of lhe Docunenl
lhal deaIs excIusiveIy vilh lhe ieIalionship of lhe pulIisheis oi aulhois of lhe
Docunenl lo lhe Docunenl's oveiaII suljecl (oi lo ieIaled nalleis) and conlains
nolhing lhal couId faII diieclIy vilhin lhal oveiaII suljecl. (Thus, if lhe Docunenl is in
pail a lexllook of nalhenalics, a Secondaiy Seclion nay nol expIain any
nalhenalics.) The ieIalionship couId le a nallei of hisloiicaI conneclion vilh lhe
suljecl oi vilh ieIaled nalleis, oi of IegaI, conneiciaI, phiIosophicaI, elhicaI oi
poIilicaI posilion iegaiding lhen.
The "Invaiianl Seclions" aie ceilain Secondaiy Seclions vhose lilIes aie designaled, as
leing lhose of Invaiianl Seclions, in lhe nolice lhal says lhal lhe Docunenl is ieIeased
undei lhis License. If a seclion does nol fil lhe alove definilion of Secondaiy lhen il is
nol aIIoved lo le designaled as Invaiianl. The Docunenl nay conlain zeio Invaiianl
Seclions. If lhe Docunenl does nol idenlify any Invaiianl Seclions lhen lheie aie none.
The "Covei Texls" aie ceilain shoil passages of lexl lhal aie Iisled, as Iionl-Covei Texls
oi ack-Covei Texls, in lhe nolice lhal says lhal lhe Docunenl is ieIeased undei lhis
License. A Iionl-Covei Texl nay le al nosl 5 voids, and a ack-Covei Texl nay le al
nosl 25 voids.
A "Tianspaienl" copy of lhe Docunenl neans a nachine-ieadalIe copy, iepiesenled in
a foinal vhose specificalion is avaiIalIe lo lhe geneiaI pulIic, lhal is suilalIe foi
ievising lhe docunenl sliaighlfoivaidIy vilh geneiic lexl edilois oi (foi inages
conposed of pixeIs) geneiic painl piogians oi (foi diavings) sone videIy avaiIalIe
diaving ediloi, and lhal is suilalIe foi inpul lo lexl foinalleis oi foi aulonalic
liansIalion lo a vaiiely of foinals suilalIe foi inpul lo lexl foinalleis. A copy nade in
an olheivise Tianspaienl fiIe foinal vhose naikup, oi alsence of naikup, has leen
aiianged lo lhvail oi discouiage sulsequenl nodificalion ly ieadeis is nol
Tianspaienl. An inage foinal is nol Tianspaienl if used foi any sulslanliaI anounl of
lexl. A copy lhal is nol "Tianspaienl" is caIIed "Opaque".
LxanpIes of suilalIe foinals foi Tianspaienl copies incIude pIain ASCII vilhoul
naikup, Texinfo inpul foinal, LaTeX inpul foinal, SCML oi XML using a pulIicIy
avaiIalIe DTD, and slandaid-confoining sinpIe HTML, IoslSciipl oi IDI designed
foi hunan nodificalion. LxanpIes of lianspaienl inage foinals incIude INC, XCI
and }IC. Opaque foinals incIude piopiielaiy foinals lhal can le iead and ediled onIy
ly piopiielaiy void piocessois, SCML oi XML foi vhich lhe DTD and/oi piocessing
looIs aie nol geneiaIIy avaiIalIe, and lhe nachine-geneialed HTML, IoslSciipl oi IDI
pioduced ly sone void piocessois foi oulpul puiposes onIy.
Fernando Senz-Prez 225/234
Univeisidad ConpIulense de Madiid
DalaIog LducalionaI Syslen
The "TilIe Iage" neans, foi a piinled look, lhe lilIe page ilseIf, pIus such foIIoving
pages as aie needed lo hoId, IegilIy, lhe naleiiaI lhis License iequiies lo appeai in lhe
lilIe page. Ioi voiks in foinals vhich do nol have any lilIe page as such, "TilIe Iage"
neans lhe lexl neai lhe nosl pioninenl appeaiance of lhe voik's lilIe, pieceding lhe
leginning of lhe lody of lhe lexl.
The "pulIishei" neans any peison oi enlily lhal disliilules copies of lhe Docunenl lo
lhe pulIic.
A seclion "LnlilIed XYZ" neans a naned sulunil of lhe Docunenl vhose lilIe eilhei is
pieciseIy XYZ oi conlains XYZ in paienlheses foIIoving lexl lhal liansIales XYZ in
anolhei Ianguage. (Heie XYZ slands foi a specific seclion nane nenlioned leIov, such
as "AcknovIedgenenls", "Dedicalions", "Lndoisenenls", oi "Hisloiy".) To "Iieseive
lhe TilIe" of such a seclion vhen you nodify lhe Docunenl neans lhal il ienains a
seclion "LnlilIed XYZ" accoiding lo lhis definilion.
The Docunenl nay incIude Waiianly DiscIaineis nexl lo lhe nolice vhich slales lhal
lhis License appIies lo lhe Docunenl. These Waiianly DiscIaineis aie consideied lo le
incIuded ly iefeience in lhis License, lul onIy as iegaids discIaining vaiianlies: any
olhei inpIicalion lhal lhese Waiianly DiscIaineis nay have is void and has no effecl
on lhe neaning of lhis License.
2. VE+42AIM C=?KI1!
You nay copy and disliilule lhe Docunenl in any nediun, eilhei conneiciaIIy oi
nonconneiciaIIy, piovided lhal lhis License, lhe copyiighl nolices, and lhe Iicense
nolice saying lhis License appIies lo lhe Docunenl aie iepioduced in aII copies, and
lhal you add no olhei condilions vhalsoevei lo lhose of lhis License. You nay nol use
lechnicaI neasuies lo olsliucl oi conlioI lhe ieading oi fuilhei copying of lhe copies
you nake oi disliilule. Hovevei, you nay accepl conpensalion in exchange foi
copies. If you disliilule a Iaige enough nunlei of copies you nusl aIso foIIov lhe
condilions in seclion 3.
You nay aIso Iend copies, undei lhe sane condilions slaled alove, and you nay
pulIicIy dispIay copies.
3. C=?KI1! I1 #U21AIAK
If you pulIish piinled copies (oi copies in nedia lhal connonIy have piinled coveis)
of lhe Docunenl, nunleiing noie lhan 1OO, and lhe Docunenl's Iicense nolice
iequiies Covei Texls, you nusl encIose lhe copies in coveis lhal caiiy, cIeaiIy and
IegilIy, aII lhese Covei Texls: Iionl-Covei Texls on lhe fionl covei, and ack-Covei
Texls on lhe lack covei. olh coveis nusl aIso cIeaiIy and IegilIy idenlify you as lhe
pulIishei of lhese copies. The fionl covei nusl piesenl lhe fuII lilIe vilh aII voids of
lhe lilIe equaIIy pioninenl and visilIe. You nay add olhei naleiiaI on lhe coveis in
addilion. Copying vilh changes Iiniled lo lhe coveis, as Iong as lhey pieseive lhe lilIe
of lhe Docunenl and salisfy lhese condilions, can le liealed as veilalin copying in
olhei iespecls.
If lhe iequiied lexls foi eilhei covei aie loo voIuninous lo fil IegilIy, you shouId pul
lhe fiisl ones Iisled (as nany as fil ieasonalIy) on lhe acluaI covei, and conlinue lhe
iesl onlo adjacenl pages.
If you pulIish oi disliilule Opaque copies of lhe Docunenl nunleiing noie lhan 1OO,
you nusl eilhei incIude a nachine-ieadalIe Tianspaienl copy aIong vilh each Opaque
Fernando Senz-Prez 226/234
Univeisidad ConpIulense de Madiid
DalaIog LducalionaI Syslen
copy, oi slale in oi vilh each Opaque copy a conpulei-nelvoik Iocalion fion vhich
lhe geneiaI nelvoik-using pulIic has access lo dovnIoad using pulIic-slandaid
nelvoik piolocoIs a conpIele Tianspaienl copy of lhe Docunenl, fiee of added
naleiiaI. If you use lhe Iallei oplion, you nusl lake ieasonalIy piudenl sleps, vhen
you legin disliilulion of Opaque copies in quanlily, lo ensuie lhal lhis Tianspaienl
copy viII ienain lhus accessilIe al lhe slaled Iocalion unliI al Ieasl one yeai aflei lhe
Iasl line you disliilule an Opaque copy (diieclIy oi lhiough youi agenls oi ielaiIeis)
of lhal edilion lo lhe pulIic.
Il is iequesled, lul nol iequiied, lhal you conlacl lhe aulhois of lhe Docunenl veII
lefoie iedisliiluling any Iaige nunlei of copies, lo give lhen a chance lo piovide you
vilh an updaled veision of lhe Docunenl.
4. M=DI.IC2AI=1S
You nay copy and disliilule a Modified Veision of lhe Docunenl undei lhe
condilions of seclions 2 and 3 alove, piovided lhal you ieIease lhe Modified Veision
undei pieciseIy lhis License, vilh lhe Modified Veision fiIIing lhe ioIe of lhe
Docunenl, lhus Iicensing disliilulion and nodificalion of lhe Modified Veision lo
vhoevei possesses a copy of il. In addilion, you nusl do lhese lhings in lhe Modified
Veision:
A. Use in lhe TilIe Iage (and on lhe coveis, if any) a lilIe dislincl fion lhal of lhe
Docunenl, and fion lhose of pievious veisions (vhich shouId, if lheie veie any, le
Iisled in lhe Hisloiy seclion of lhe Docunenl). You nay use lhe sane lilIe as a pievious
veision if lhe oiiginaI pulIishei of lhal veision gives peinission.
. Lisl on lhe TilIe Iage, as aulhois, one oi noie peisons oi enlilies iesponsilIe foi
aulhoiship of lhe nodificalions in lhe Modified Veision, logelhei vilh al Ieasl five of
lhe piincipaI aulhois of lhe Docunenl (aII of ils piincipaI aulhois, if il has fevei lhan
five), unIess lhey ieIease you fion lhis iequiienenl.
C. Slale on lhe TilIe page lhe nane of lhe pulIishei of lhe Modified Veision, as lhe
pulIishei.
D. Iieseive aII lhe copyiighl nolices of lhe Docunenl.
L. Add an appiopiiale copyiighl nolice foi youi nodificalions adjacenl lo lhe olhei
copyiighl nolices.
I. IncIude, innedialeIy aflei lhe copyiighl nolices, a Iicense nolice giving lhe pulIic
peinission lo use lhe Modified Veision undei lhe leins of lhis License, in lhe foin
shovn in lhe Addendun leIov.
C. Iieseive in lhal Iicense nolice lhe fuII Iisls of Invaiianl Seclions and iequiied Covei
Texls given in lhe Docunenl's Iicense nolice.
H. IncIude an unaIleied copy of lhis License.
I. Iieseive lhe seclion LnlilIed "Hisloiy", Iieseive ils TilIe, and add lo il an ilen slaling
al Ieasl lhe lilIe, yeai, nev aulhois, and pulIishei of lhe Modified Veision as given on
lhe TilIe Iage. If lheie is no seclion LnlilIed "Hisloiy" in lhe Docunenl, cieale one
slaling lhe lilIe, yeai, aulhois, and pulIishei of lhe Docunenl as given on ils TilIe
Iage, lhen add an ilen desciiling lhe Modified Veision as slaled in lhe pievious
senlence.
Fernando Senz-Prez 227/234
Univeisidad ConpIulense de Madiid
DalaIog LducalionaI Syslen
}. Iieseive lhe nelvoik Iocalion, if any, given in lhe Docunenl foi pulIic access lo a
Tianspaienl copy of lhe Docunenl, and Iikevise lhe nelvoik Iocalions given in lhe
Docunenl foi pievious veisions il vas lased on. These nay le pIaced in lhe "Hisloiy"
seclion. You nay onil a nelvoik Iocalion foi a voik lhal vas pulIished al Ieasl foui
yeais lefoie lhe Docunenl ilseIf, oi if lhe oiiginaI pulIishei of lhe veision il iefeis lo
gives peinission.
K. Ioi any seclion LnlilIed "AcknovIedgenenls" oi "Dedicalions", Iieseive lhe TilIe of
lhe seclion, and pieseive in lhe seclion aII lhe sulslance and lone of each of lhe
conliiluloi acknovIedgenenls and/oi dedicalions given lheiein.
L. Iieseive aII lhe Invaiianl Seclions of lhe Docunenl, unaIleied in lheii lexl and in
lheii lilIes. Seclion nunleis oi lhe equivaIenl aie nol consideied pail of lhe seclion
lilIes.
M. DeIele any seclion LnlilIed "Lndoisenenls". Such a seclion nay nol le incIuded in
lhe Modified Veision.
N. Do nol ielilIe any exisling seclion lo le LnlilIed "Lndoisenenls" oi lo confIicl in lilIe
vilh any Invaiianl Seclion.
O. Iieseive any Waiianly DiscIaineis.
If lhe Modified Veision incIudes nev fionl-nallei seclions oi appendices lhal quaIify
as Secondaiy Seclions and conlain no naleiiaI copied fion lhe Docunenl, you nay al
youi oplion designale sone oi aII of lhese seclions as invaiianl. To do lhis, add lheii
lilIes lo lhe Iisl of Invaiianl Seclions in lhe Modified Veision's Iicense nolice. These
lilIes nusl le dislincl fion any olhei seclion lilIes.
You nay add a seclion LnlilIed "Lndoisenenls", piovided il conlains nolhing lul
endoisenenls of youi Modified Veision ly vaiious pailies~foi exanpIe, slalenenls of
peei ieviev oi lhal lhe lexl has leen appioved ly an oiganizalion as lhe aulhoiilalive
definilion of a slandaid.
You nay add a passage of up lo five voids as a Iionl-Covei Texl, and a passage of up
lo 25 voids as a ack-Covei Texl, lo lhe end of lhe Iisl of Covei Texls in lhe Modified
Veision. OnIy one passage of Iionl-Covei Texl and one of ack-Covei Texl nay le
added ly (oi lhiough aiiangenenls nade ly) any one enlily. If lhe Docunenl aIieady
incIudes a covei lexl foi lhe sane covei, pieviousIy added ly you oi ly aiiangenenl
nade ly lhe sane enlily you aie acling on lehaIf of, you nay nol add anolhei, lul you
nay iepIace lhe oId one, on expIicil peinission fion lhe pievious pulIishei lhal added
lhe oId one.
The aulhoi(s) and pulIishei(s) of lhe Docunenl do nol ly lhis License give peinission
lo use lheii nanes foi pulIicily foi oi lo asseil oi inpIy endoisenenl of any Modified
Veision.
%. C=M4I1I1! D=CUME1AS
You nay conline lhe Docunenl vilh olhei docunenls ieIeased undei lhis License,
undei lhe leins defined in seclion 4 alove foi nodified veisions, piovided lhal you
incIude in lhe conlinalion aII of lhe Invaiianl Seclions of aII of lhe oiiginaI docunenls,
unnodified, and Iisl lhen aII as Invaiianl Seclions of youi conlined voik in ils Iicense
nolice, and lhal you pieseive aII lheii Waiianly DiscIaineis.
Fernando Senz-Prez 228/234
Univeisidad ConpIulense de Madiid
DalaIog LducalionaI Syslen
The conlined voik need onIy conlain one copy of lhis License, and nuIlipIe idenlicaI
Invaiianl Seclions nay le iepIaced vilh a singIe copy. If lheie aie nuIlipIe Invaiianl
Seclions vilh lhe sane nane lul diffeienl conlenls, nake lhe lilIe of each such seclion
unique ly adding al lhe end of il, in paienlheses, lhe nane of lhe oiiginaI aulhoi oi
pulIishei of lhal seclion if knovn, oi eIse a unique nunlei. Make lhe sane adjuslnenl
lo lhe seclion lilIes in lhe Iisl of Invaiianl Seclions in lhe Iicense nolice of lhe conlined
voik.
In lhe conlinalion, you nusl conline any seclions LnlilIed "Hisloiy" in lhe vaiious
oiiginaI docunenls, foining one seclion LnlilIed "Hisloiy", Iikevise conline any
seclions LnlilIed "AcknovIedgenenls", and any seclions LnlilIed "Dedicalions". You
nusl deIele aII seclions LnlilIed "Lndoisenenls".
". C=$$ECAI=1S =. D=CUME1AS
You nay nake a coIIeclion consisling of lhe Docunenl and olhei docunenls ieIeased
undei lhis License, and iepIace lhe individuaI copies of lhis License in lhe vaiious
docunenls vilh a singIe copy lhal is incIuded in lhe coIIeclion, piovided lhal you
foIIov lhe iuIes of lhis License foi veilalin copying of each of lhe docunenls in aII
olhei iespecls.
You nay exliacl a singIe docunenl fion such a coIIeclion, and disliilule il
individuaIIy undei lhis License, piovided you inseil a copy of lhis License inlo lhe
exliacled docunenl, and foIIov lhis License in aII olhei iespecls iegaiding veilalin
copying of lhal docunenl.
(. 2!!+E!2AI=1 ,IA@ I1DE?E1DE1A ,=+FS
A conpiIalion of lhe Docunenl oi ils deiivalives vilh olhei sepaiale and independenl
docunenls oi voiks, in oi on a voIune of a sloiage oi disliilulion nediun, is caIIed
an "aggiegale" if lhe copyiighl iesuIling fion lhe conpiIalion is nol used lo Iinil lhe
IegaI iighls of lhe conpiIalion's useis leyond vhal lhe individuaI voiks peinil. When
lhe Docunenl is incIuded in an aggiegale, lhis License does nol appIy lo lhe olhei
voiks in lhe aggiegale vhich aie nol lhenseIves deiivalive voiks of lhe Docunenl.
If lhe Covei Texl iequiienenl of seclion 3 is appIicalIe lo lhese copies of lhe
Docunenl, lhen if lhe Docunenl is Iess lhan one haIf of lhe enliie aggiegale, lhe
Docunenl's Covei Texls nay le pIaced on coveis lhal liackel lhe Docunenl vilhin
lhe aggiegale, oi lhe eIeclionic equivaIenl of coveis if lhe Docunenl is in eIeclionic
foin. Olheivise lhey nusl appeai on piinled coveis lhal liackel lhe vhoIe aggiegale.
8. A+21S$2AI=1
TiansIalion is consideied a kind of nodificalion, so you nay disliilule liansIalions of
lhe Docunenl undei lhe leins of seclion 4. RepIacing Invaiianl Seclions vilh
liansIalions iequiies speciaI peinission fion lheii copyiighl hoIdeis, lul you nay
incIude liansIalions of sone oi aII Invaiianl Seclions in addilion lo lhe oiiginaI
veisions of lhese Invaiianl Seclions. You nay incIude a liansIalion of lhis License, and
aII lhe Iicense nolices in lhe Docunenl, and any Waiianly DiscIaineis, piovided lhal
you aIso incIude lhe oiiginaI LngIish veision of lhis License and lhe oiiginaI veisions of
lhose nolices and discIaineis. In case of a disagieenenl lelveen lhe liansIalion and
lhe oiiginaI veision of lhis License oi a nolice oi discIainei, lhe oiiginaI veision viII
pievaiI.
Fernando Senz-Prez 22/234
Univeisidad ConpIulense de Madiid
DalaIog LducalionaI Syslen
If a seclion in lhe Docunenl is LnlilIed "AcknovIedgenenls", "Dedicalions", oi
"Hisloiy", lhe iequiienenl (seclion 4) lo Iieseive ils TilIe (seclion 1) viII lypicaIIy
iequiie changing lhe acluaI lilIe.
. AE+MI12AI=1
You nay nol copy, nodify, sulIicense, oi disliilule lhe Docunenl excepl as expiessIy
piovided undei lhis License. Any allenpl olheivise lo copy, nodify, sulIicense, oi
disliilule il is void, and viII aulonalicaIIy leininale youi iighls undei lhis License.
Hovevei, if you cease aII vioIalion of lhis License, lhen youi Iicense fion a pailicuIai
copyiighl hoIdei is ieinslaled (a) piovisionaIIy, unIess and unliI lhe copyiighl hoIdei
expIicilIy and finaIIy leininales youi Iicense, and (l) peinanenlIy, if lhe copyiighl
hoIdei faiIs lo nolify you of lhe vioIalion ly sone ieasonalIe neans piioi lo 6O days
aflei lhe cessalion.
Moieovei, youi Iicense fion a pailicuIai copyiighl hoIdei is ieinslaled peinanenlIy if
lhe copyiighl hoIdei nolifies you of lhe vioIalion ly sone ieasonalIe neans, lhis is lhe
fiisl line you have ieceived nolice of vioIalion of lhis License (foi any voik) fion lhal
copyiighl hoIdei, and you cuie lhe vioIalion piioi lo 3O days aflei youi ieceipl of lhe
nolice.
Teininalion of youi iighls undei lhis seclion does nol leininale lhe Iicenses of pailies
vho have ieceived copies oi iighls fion you undei lhis License. If youi iighls have
leen leininaled and nol peinanenlIy ieinslaled, ieceipl of a copy of sone oi aII of lhe
sane naleiiaI does nol give you any iighls lo use il.
1'. .UAU+E +EVISI=1S =. A@IS $ICE1SE
The Iiee Soflvaie Ioundalion nay pulIish nev, ievised veisions of lhe CNU Iiee
Docunenlalion License fion line lo line. Such nev veisions viII le siniIai in spiiil lo
lhe piesenl veision, lul nay diffei in delaiI lo addiess nev piolIens oi conceins. See
hllp://vvv.gnu.oig/copyIefl/.
Lach veision of lhe License is given a dislinguishing veision nunlei. If lhe Docunenl
specifies lhal a pailicuIai nunleied veision of lhis License "oi any Ialei veision"
appIies lo il, you have lhe oplion of foIIoving lhe leins and condilions eilhei of lhal
specified veision oi of any Ialei veision lhal has leen pulIished (nol as a diafl) ly lhe
Iiee Soflvaie Ioundalion. If lhe Docunenl does nol specify a veision nunlei of lhis
License, you nay choose any veision evei pulIished (nol as a diafl) ly lhe Iiee
Soflvaie Ioundalion. If lhe Docunenl specifies lhal a pioxy can decide vhich fuluie
veisions of lhis License can le used, lhal pioxy's pulIic slalenenl of acceplance of a
veision peinanenlIy aulhoiizes you lo choose lhal veision foi lhe Docunenl.
11. +E$ICE1SI1!
"Massive MuIliaulhoi CoIIaloialion Sile" (oi "MMC Sile") neans any WoiId Wide Wel
seivei lhal pulIishes copyiighlalIe voiks and aIso piovides pioninenl faciIilies foi
anylody lo edil lhose voiks. A pulIic viki lhal anylody can edil is an exanpIe of
such a seivei. A "Massive MuIliaulhoi CoIIaloialion" (oi "MMC") conlained in lhe sile
neans any sel of copyiighlalIe voiks lhus pulIished on lhe MMC sile.
"CC-Y-SA" neans lhe Ciealive Connons Alliilulion-Shaie AIike 3.O Iicense
pulIished ly Ciealive Connons Coipoialion, a nol-foi-piofil coipoialion vilh a
piincipaI pIace of lusiness in San Iiancisco, CaIifoinia, as veII as fuluie copyIefl
veisions of lhal Iicense pulIished ly lhal sane oiganizalion.
Fernando Senz-Prez 23!/234
Univeisidad ConpIulense de Madiid
DalaIog LducalionaI Syslen
"Incoipoiale" neans lo pulIish oi iepulIish a Docunenl, in vhoIe oi in pail, as pail of
anolhei Docunenl.
An MMC is "eIigilIe foi ieIicensing" if il is Iicensed undei lhis License, and if aII voiks
lhal veie fiisl pulIished undei lhis License sonevheie olhei lhan lhis MMC, and
sulsequenlIy incoipoialed in vhoIe oi in pail inlo lhe MMC, (1) had no covei lexls oi
invaiianl seclions, and (2) veie lhus incoipoialed piioi lo Novenlei 1, 2OO8.
The opeialoi of an MMC Sile nay iepulIish an MMC conlained in lhe sile undei CC-
Y-SA on lhe sane sile al any line lefoie Augusl 1, 2OO9, piovided lhe MMC is
eIigilIe foi ieIicensing.
2DDE1DUMH @o3 to use t/is $icense :or your documents
To use lhis License in a docunenl you have viillen, incIude a copy of lhe License in
lhe docunenl and pul lhe foIIoving copyiighl and Iicense nolices jusl aflei lhe lilIe
page:
Copyright (C) YEAR YOUR NAME.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3
or any later version published by the Free Software Foundation;
with no Invariant Sections, no Front-Cover Texts, and no Back-Cover
Texts.
A copy of the license is included in the section entitled "GNU
Free Documentation License".
If you have Invaiianl Seclions, Iionl-Covei Texls and ack-Covei Texls, iepIace lhe
"vilh . Texls." Iine vilh lhis:
with the Invariant Sections being LIST THEIR TITLES, with the
Front-Cover Texts being LIST, and with the Back-Cover Texts being
LIST.
If you have Invaiianl Seclions vilhoul Covei Texls, oi sone olhei conlinalion of lhe
lhiee, neige lhose lvo aIleinalives lo suil lhe silualion.
If youi docunenl conlains nonliiviaI exanpIes of piogian code, ve ieconnend
ieIeasing lhese exanpIes in paiaIIeI undei youi choice of fiee soflvaie Iicense, such as
lhe CNU CeneiaI IulIic License, lo peinil lheii use in fiee soflvaie.
Fernando Senz-Prez 231/234
Univeisidad ConpIulense de Madiid
DalaIog LducalionaI Syslen
4i*liogra&/y
|Agia88j R. AgiavaI, "AIpha: An Lxlension of ReIalionaI AIgelia lo Lxpiess a
CIass of Recuisive Queiies", ILLL Tiansaclions on Soflvaie
Lngineeiing aichive, VoIune 14 Issue 7, }uIy 1988.
|AOO8j I. Annann and }. Offull, Inlioduclion lo Soflvaie Tesling,
Canliidge Univeisily Iiess, 2OO8.
|AOTWZO3j I. Aini, K. Ong, S. Tsui, H. Wang, and C. ZanioIo, The deduclive
dalalase syslen LDL++, TILI, 3(1):61-94, 2OO3.
|ICO7j M. eckei, C. Iouinel, and A. Coidon. Design and Senanlics of a
DecenliaIized Aulhoiizalion Language. In CSI O7: Iioceedings of lhe
2Olh ILLL Conpulei Secuiily Ioundalions Synposiun, pages 3-15,
Washinglon, DC, USA, 2OO7. ILLL Conpulei Sociely.
|IIWD94j M.L. aija, N.W. Ialon, A. Ieinandes, M.H. WiIIians, A. Dinn, An
Lffeclive Deduclive Oljecl-Oiienled Dalalase Thiough Language
Inlegialion, In Iioc. of lhe 2O
lh
VLD Confeience, 1994.
|CalaO5j CalaIIeio, R., A decIaialive deluggei of incoiiecl ansveis foi
consliainl funclionaI-Iogic piogians, in: WCILI O5: Iioceedings of
lhe 2OO5 ACM SICILAN voikshop on Cuiiy and funclionaI Iogic
piogianning (2OO5), pp. 8-13.
|CCLO9j A. CaI, C. CollIol, and T. Lukasievicz. DalaIog+-: a unified appioach
lo onloIogies and inlegiily consliainls. In ICDT O9: Iioceedings of lhe
12lh InleinalionaI Confeience on Dalalase Theoiy, pages 14-3O, Nev
Yoik, NY, USA, 2OO9. ACM.
|CCSO6lj R. CalaIIeio, Y. Caica-Ruiz, and I. Senz-Ieiez, Tovaids a Sel
Oiienled CaIcuIus foi Logic Iiogianning, Iiogianacin y
Lenguajes, I. Lucio y I. Oiejas (edilois), CIMNL, pp. 41-5O, aiceIona,
Spain, Seplenlei, 2OO6.
|CCSO7j R. CalaIIeio, Y. Caica-Ruiz, and I. Senz-Ieiez, A Nev IioposaI foi
Delugging DalaIog Iiogians, 16lh InleinalionaI Woikshop on
IunclionaI and (Consliainl) Logic Iiogianning, 2OO7.
|CCSO8j R. CalaIIeio, Y. Caica-Ruiz and I. Senz-Ieiez, " #$eoretica%
Frame&or' (or t$e Dec%arati)e De*u++in+ o( Data%o+ Pro+rams In
InleinalionaI Woikshop on Senanlics in Dala and KnovIedge ases
(SDK 2OO8), L,-S 425. //0 143-15, S/rin+er. 2!!80
|CCS1Oaj R. CalaIIeio, Y. Caica-Ruiz and I. Senz-Ieiez, "//%1in+ -onstraint
Lo+ic Pro+rammin+ to S2L #est -ase 3eneration, 4n 1!t$
4nternationa% S1m/osium on Functiona% and Lo+ic Pro+rammin+
5FL6PS 2!1!7. 2O1O0
|CCS11lj R. CalaIIeio, Y. Caica-Ruiz and I. Senz-Ieiez, AIgoiilhnic
Delugging of SQL Vievs, Liglh Lishov Infoinalics Confeience,
ISI11, Novosiliisk, Akadengoiodok, Russia, }une, 2O11.
Fernando Senz-Prez 232/234
Univeisidad ConpIulense de Madiid
DalaIog LducalionaI Syslen
|CCS12aj R. CalaIIeio, Y. Caica-Ruiz, and I. Senz-Ieiez, "DecIaialive
Delugging of Wiong and Missing Ansveis foi SQL Vievs", In 11lh
InleinalionaI Synposiun on IunclionaI and Logic Iiogianning
(ILOIS 2O12), Spiingei, Lecluie Noles in Conpulei Science, Kole,
}apan, May, 2O12.
|Chan78j C.L. Chang, Deduce 2: Iuilhei Invesligalions of Deduclion in
ReIalionaI Dalalases, H. CaIIaiie and }. Minkei (eds.), Logic and
Dalalases, IIenun Iiess, 1978.
|Diel87j S.W. Dieliich, Lxlension TalIes: Meno ReIalions in Logic
Iiogianning, IV ILLL Synposiun on Logic Iiogianning, 1987.
|DielO1j S.W. Dieliich, Undeislanding ReIalionaI Dalalase Queiy
Languages,, Iienlice HaII, 2OO1.
|DMI93j M. Deii, S. Moiishila, and C. Ihipps, Design and InpIenenlalion of
lhe CIue-NAIL Dalalase Syslen, In Iioc. of lhe ACM SICMOD
InleinalionaI Confeience on Managenenl of Dala, pp. 147-167, 1993.
|Diax92j DiaxIei, Chi., A IoveifuI IioIog lo SQL ConpiIei, CIS-eiichl-92-61,
Cenliun fi Infoinalions und Spiachveiaileilung, Ludvig-
MaxiniIians-Univeisill Mnchen, 1992.
|ID92j C. Ian and S. W. Dieliich, "Lxlension TalIe uiIl-ins foi IioIog",
Soflvaie - Iiaclice and Lxpeiience VoI. 22 (7), pp. 573-597, }uIy 1992.
|IHHO4j R. Iikes, I.}. Hayes, and I. Hoiiocks. OWL-QL - a Ianguage foi
deduclive queiy ansveiing on lhe Senanlic Wel. }. Wel Sen., 2(1):19-
29, 2OO4.
|II96j WoIfgang Ialei and CeiaId Ifeifei. DLV honepage, since 1996. uiI
http://www.dlvsystem.com/.
|CR68j C.C. Cieen and . RaphaeI, The Use of Theoien-Iioving Techniques
in Queslion-Ansveiing Syslens, Iioceedings of lhe 23
id
ACM
NalionaI Confeience, Washinglon D.C., 1968.
|CTZO5j S. Cieco, I. Tiulilsyna, and L. Zunpano. NI DalaIog: A Logic
Language foi NI Seaich and Oplinizalion Queiies. Dalalase
Lngineeiing and AppIicalions Synposiun, InleinalionaI, O:344-353,
2OO5.
|CUWO2j H. Caicia-MoIina, }. D. UIInan, }. Widon, Dalalase Syslens: The
ConpIele ook, Iienlice-HaII, 2OO2.
|HA92j M. A. W. Houlsna and I. M. C. Apeis, " AIgeliaic oplinizalion of
iecuisive queiies", Dala & KnovIedge Lngineeiing, VoIune 7 Issue 4,
Maich 1992.
|IRIS2OO8j IRIS-Reasonei, http://iris-reasoner.org.
|ISOOOj ISO/ILC. ISO/ILC 132111-2: IioIog Slandaid. 2OOO.
|}C}+95j M. }aike, R. CaIIeisdifei, M.A. }eusfeId, M. Slaudl, S. Lheiei:
Conceplase - a deduclive oljecl lase foi nela dala nanagenenl. In
}ouinaI of InleIIigenl Infoinalion Syslens, SpeciaI Issue on Advances
in Deduclive Oljecl-Oiienled Dalalases, VoI. 4, No. 2, 167-192, 1995.
Fernando Senz-Prez 233/234
Univeisidad ConpIulense de Madiid
DalaIog LducalionaI Syslen
Syslen avaiIalIe al: http://www-i5.informatik.rwth-
aachen.de/CBdoc/
|KLW95j M. Kifei, C. Lausen, }. Wu, "LogicaI Ioundalions of Oljecl Oiienled
and Iiane ased Languages", }ouinaI of lhe ACM, voI. 42, p. 741-843,
1995.
|KSSD94j W. KiessIing, H. Schnidl, W. Sliauss, and C. Dnzingei, DLCLARL
and SDS: LaiIy Lffoils lo ConneiciaIize Deduclive Dalalase
TechnoIogy, VLD }ouinaI, 3, pp. 211-243, 1994.
|KT81j C. KeIIogg and L. Tiavis, Reasoning vilh Dala in a DeducliveIy
Augnenled Dala Managenenl Syslen, H. CaIIaiie, }. Minkei, and }.
NicoIas (eds.), Advances in Dala ase Theoiy, VoIune 1, IIenun
Iiess, 1981.
|LIoy87j }. LIoyd, Ioundalions of Logic Iiogianning, Spiingei VeiIag, 1987.
|Mink87j }. Minkei, Ieispeclives in Deduclive Dalalases, TechnicaI Repoil
CS-TR-1799, Univeisily of MaiyIand al CoIIege Iaik, Maich 1987.
|MN82j }. Minkei and }.-M. NicoIas, On Recuisive Axions in Deduclive
Dalalases, Infoinalion Syslens, 16(4):67O-7O2, 1991.
|MS11j }. MaIuszynski and A. SzaIas: Living vilh Inconsislency and Taning
Nonnonolonicily. To appeai in DalaIog 2.O, C. CollIol, C. Ciasso, O.
de Mooi, and A. SeIIeis, eds., LNCS 67O2, 334-398, Spiingei-VeiIag,
2O11.
|IDR91j C. Ihipps, M. A. Deii, and K.A. Ross, CIue-NAIL!: A Deduclive
Dalalase Syslen. In Iioc. of lhe ACM SICMOD Confeience on
Managenenl of Dala, pp. 3O8-317, 1991.
|Roli65j }.A. Rolinson, A Machine-Oiienled Logic ased on lhe ResoIulion
IiincipIe, }ouinaI of lhe ACM, 12:23-41, 1965.
|RSO9j R. Ronen and O. ShnueIi. LvaIualing veiy Iaige DalaIog queiies on
sociaI nelvoiks. In LDT O9: Iioceedings of lhe 12lh InleinalionaI
Confeience on Lxlending Dalalase TechnoIogy, pages 577-587, Nev
Yoik, NY, USA, 2OO9. ACM.
|RSSS94j R. Ranakiishnan, D. Siivaslava, S. Sudaishan, and I. Seshadii. The
CoiaI deduclive syslen. VLD }ouinaI, 3(2):161-21O, 1994.
|RSSWI97j I. Rao, Konslanlinos I. Sagonas, Teiiance Svifl, David Scoll Waiien,
and }uIiana Iieiie, XS: A Syslen foi LfficienlIy Conpuling WIS",
Logic Iiogianning and Non-nonolonic Reasoning, 1997.
|RU95j R. Ranakiishnan and }.D UIInan, A Suivey of Reseaich on Deduclive
Dalalase Syslens, }ouinaI of Logic Iiogianning, 23(2): 125-149,
1995.
|SD91j C. Shih and S. W. Dieliich, "Lxlension TalIe LvaIualion of DalaIog
Iiogians vilh Negalion", Iioceedings of lhe ILLL InleinalionaI
Ihoenix Confeience on Conpuleis and Connunicalions, ScollsdaIe,
AZ, Maich 1991, pp. 792-798.
Fernando Senz-Prez 234/234
Univeisidad ConpIulense de Madiid
DalaIog LducalionaI Syslen
|SaeO7j I. Senz-Ieiez, ACIDL: An Inlegialed DeveIopnenl Lnviionnenl
ConfiguialIe foi LaTeX, The IiacTeX }ouinaI, 2OO7, Nunlei 3, ISSN
1556-6994, Augusl, 2OO7.
|Shap83j Shapiio, L., AIgoiilhnic Iiogian Deugging, ACM Dislinguished
Disseilalion, MIT Iiess, 1983.
|SICSlusj SICS, http://www.sics.se/sicstus.
|SiIvO7j SiIva, }., A Conpaialive Sludy of AIgoiilhnic Delugging Slialegies,
in: Iioc. of InleinalionaI Synposiun on Logic-lased Iiogian
Synlhesis and Tiansfoinalion LOISTR 2OO6, 2OO7, pp. 134-14O.
|SRSS93j D. Siivaslava, R. Ranakiishnan, S. Sudaishan, and I. Seshadii,
CoiaI++: Adding Oljecl-Oiienlalion lo a Logic Dalalase Language,
Iioceedings of lhe InleinalionaI Confeience on Veiy Laige Dalalases,
1993.
|Tang99j Z. Tang, "DalaIog++: An Oljecl-Oiienled Iionl-Lnd Ioi The Xsl
Deduclive Dalalase Managenenl Syslen", hllp://cileseei.isl.psu.
edu/lang99dalaIog.hlnI.
|TS86j H. Tanaki and T. Salo, OLD ResoIulion vilh TaluIalion,
Iioceedings of ICLI86, Lecluie Noles on Conpulei Science 225,
Spiingei-VeiIag, 1986.
|UIIn95j }.D. UIInan. Dalalase and KnovIedge-ase Syslens, VoIs. I (CIassicaI
Dalalase Syslens) and II (The Nev TechnoIogies), Conpulei Science
Iiess, 1995.
|VRK+91j }. Vaghani, K. Rananohanaiao, D.. Kenp, Z. Sonogyi, and I.}.
Sluckey, Design Oveiviev of lhe Adili Deduclive Dalalase Syslen,
In Iioc. of lhe 7lh InlI. Conf. on Dala Lngineeiing, pp. 24O-247, 1991.
|WieIej }. WieIenakei, http://www.SWI-Prolog.org.
|WLO4j }. WhaIey and M. Lan, CIoning-lased conlexl-sensilive poinlei aIias
anaIyses using linaiy decision diagians. In: Iiog. Lang. Design and
InpI., 2OO4.
|ZCI+97j C. ZanioIo, S. Ceii, C. IaIoulsos, T.T. Snodgiass, V.S. Suliahnanian,
and R. Zicaii, "Advanced Dalalase Syslens", Moigan Kauffnann
IulIisheis, 1997.
|ZI97j U. Zukovski and . Iieilag, The Deduclive Dalalase Syslen LOLA,
In: }. Dix and U. Iuilach and A. Neiode (Lds.). Logic Iiogianning
and Nonnonolonic Reasoning. LNAI 1265, pp. 375-386. Spiingei,
1997.