Download The Ciao system 7 - Datu bāzes tehnoloģijas

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Open Database Connectivity wikipedia , lookup

Clusterpoint wikipedia , lookup

Relational model wikipedia , lookup

Database model wikipedia , lookup

Object-relational impedance mismatch wikipedia , lookup

Transcript
1
Prolog1 is a logical and a declarative programming
language
The name itself, Prolog, is short for PROgramming in LOGic.
Prolog's heritage includes the research on theorem provers and other
automated deduction systems developed in the 1960s and 1970s. The
inference mechanism of Prolog is based upon Robinson's resolution
principle (1965) together with mechanisms for extracting answers
proposed by Green (1968). These ideas came together forcefully with the
advent of linear resolution procedures. Explicit goal-directed linear
resolution procedures, such as those of Kowalski and Kuehner (1971) and
Kowalski (1974), gave impetus to the development of a general purpose
logic programming system.
The "first" Prolog was "Marseille Prolog" based on work by
Colmerauer (1970). The first detailed description of the Prolog language
was the manual for the Marseille Prolog interpreter (Roussel, 1975). The
other major influence on the nature of this first Prolog was that it was
designed to facilitate natural language processing.
Prolog is the major example of a fourth generation programming language
supporting the declarative programming paradigm. The Japanese FifthGeneration Computer Project, announced in 1981, adopted Prolog as a
development language, and thereby focused considerable attention on the
language and its capabilities. The programs in this tutorial are written in
"standard" (University of) Edinburgh Prolog, as specified in the classic
Prolog textbook by authors Clocksin and Mellish (1981,1992).
The other major kind of Prolog is the PrologII family of Prologs which
are the descendants of Marseille Prolog. The reference to Giannesini, et.al.
(1986) uses a version of PrologII. There are differences between these two
varieties of Prolog; part of the difference is syntax, and part is semantics.
However, students who learn either kind of Prolog can easily adapt to the
other kind.
1
https://www.cpp.edu/~jrfisher/www/prolog_tutorial/contents.html
2
Prolog sistēma ar savienojumu ar datu bāzes sistēmu
Prologa sistēma
Likumi
Izveduma
mehānisms
Lietotāja
interfeiss
Lietotājs
Savienojums
(SQL)
Datu bāzes
sistēma
Fakti
3
PrologSQL
tilts PROLOG sistēma  DBS
1. Import two tables from a database.
2. Create a nondeterministic query predicate as an join between two
tables.
3. Call the query predicate.
:- use_module(oracle).
go :db_open('Your Database Name', 'scott', 'tiger'),
db_import('DEPT'('DEPTNO', 'DNAME', 'LOC'), dept),
db_import('EMP'('EMPNO', 'ENAME', 'JOB', 'MGR', 'HIREDATE',
'SAL', 'COMM', 'DEPTNO'), emp),
%% Uncomment it, if you do not want to see SQL statements.
%% db_flag(show_query, _, off),
db_query(empinfo(EMPNO, ENAME, JOB, MGR, HIREDATE, SAL,
COMM, DEPTNO, DNAME, LOC),
(emp(EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM,
DEPTNO),
dept(DEPTNO, DNAME, LOC) ) ),
get_result,
db_close.
get_result:empinfo(EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM,
DEPTNO, DNAME, LOC),
write_ln([EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM,
DEPTNO, DNAME, LOC]),
fail.
get_result.
4
SWI-Prolog, 20132
Most implementations of the Prolog language are designed to serve a limited
set of use cases. SWI-Prolog is no exception to this rule. SWI-Prolog
positions itself primarily as a Prolog environment for `programming in the large' and use cases
where it plays a central role in an application, i.e., where it acts as `glue' between components. At
the same time, SWI-Prolog aims at providing a productive rapid prototyping environment. Its
orientation towards programming in the large is backed up by scalability, compiler speed, program
structuring (modules), support for multithreading to accommodate servers, Unicode and interfaces
to a large number of document formats, protocols and programming languages. Prototyping is
facilitated by good development tools, both for command line usage as for usage with graphical
development tools. Demand loading of predicates from the library and a `make' facility avoids the
requirement for using declarations and reduces typing.
SWI-Prolog offers some facilities that are widely appreciated by users:
Nice
environment
SWI-Prolog provides a good command line environment, including `Do What I Mean',
autocompletion, history and a tracer that operates on single key strokes. The system automatically
2
http://www.swi-prolog.org/pldoc/man?section=swiprolog
5
recompiles modified parts of the source code using the make/0 command. The system can be
instructed to open an arbitrary editor on the right file and line based on its source database. It ships
with various graphical tools and can be combined with the SWI-Prolog editor, PDT (Eclipse plugin
for Prolog) or GNU-Emacs.
Fast compiler
Even very large applications can be loaded in seconds on most machines. If this is not enough, there
is the Quick Load Format.
Transparent compiled code
SWI-Prolog compiled code can be treated just as interpreted code: you can list it, trace it, etc. This
implies you do not have to decide beforehand whether a module should be loaded for debugging or
not, and the performance of debugged code is close to that of normal operation.
Source level debugger
The source level debugger provides a good overview of your current location in the search tree,
variable bindings, your source code and open choice points. Choice point inspection provides
meaningful insight to both novices and experienced users. Avoiding unintended choice points often
provides a huge increase in performance and a huge saving in memory usage.
Profiling
SWI-Prolog offers an execution profiler with either textual output or graphical output. Finding and
improving hotspots in a Prolog program may result in huge speedups.
Flexibility
SWI-Prolog can easily be integrated with C, supporting non-determinism in Prolog calling C as
well as C calling Prolog. It can also be embedded in external programs. System predicates can be
redefined locally to provide compatibility with other Prolog systems.
Threads
Robust support for multiple threads may improve performance and is a key enabling factor for
deploying Prolog in server applications.
Interfaces
SWI-Prolog ships with many extension packages that provide robust interfaces to processes,
encryption, TCP/IP, TIPC, ODBC, SGML/XML/HTML, RDF, HTTP, graphics and much more.
In the long run, we want to move to an Integrated Development Environment (IDE) based on
XPCE. Various parts of this environment already exist and are actively being used.
PceEmacs is a GNU-Emacs clone in XPCE/Prolog, providing Prolog syntax highlighting based on
parsing and cross-referencing the editor buffer. Colouring highlights variables, quoted entities,
comments, goals (classified as built-in, imported, local, dynamic and undefined), predicates
6
(classified as local, public and unreferenced), and file references (classified as existend/nonexistend). PceEmacs is started using the predicate emacs/[0,1].
The graphical tracer provides source-level debugging, using three views: your source, variable
bindings, and the stack. The stack view includes choicepoints and visualises the effect of executing
the cut!
The Execution Profiler provides a graphical overview of call and time statistics.
The Cross Referencer analyzes dependencies in the loaded program and points out undefined and
unused code. It can also generate module headers and import directives based on the analysis.
The Prolog Navigator provides an explorer-like view on a directory holding Prolog source files.
Sources files can be expanded in the tree to show predicates, exports, XPCE classes and methods.
Can be used to edit entities or enable debugging them (spy).
The Windows Prolog console plwin.exe provides a menu to access many of these facilities directly.
7
Visual Prolog3
The Integrated Development Environment (aka IDE) allow you to create and manage Visual Prolog
project. It contains features for:
Editing source files
Designing dialogs/forms
Building/Compiling
Debugging
3
http://www.visual-prolog.com/vip/product/default.htm
8
ProLog – V8, 20124
It has been almost three years since our release of ProLog-V7 and now DataMatrix is proud to
announce the release of an all new ProLog-V8. The V8 system has so many new enhancements and
features that our entire website has to be restructured with new screenshots and technical
descriptions. Please be patient as we undertake this rather large task.
4
https://prologsystem.com/
9
YAP5
YAP is a high-performance Prolog compiler developed at
LIACC/Universidade do Porto and at COPPE Sistemas/UFRJ. Its Prolog
engine is based in the WAM (Warren Abstract Machine), with several
optimizations for better performance. YAP follows the Edinburgh
tradition, and is largely compatible with the ISO-Prolog standard and
with Quintus and SICStus Prolog. YAP has been developed since 1985.
The original version was written in assembly, C and Prolog, and achieved
high performance on m68k based machines. The assembly code was used to implement the WAM
emulators. Later emulators supported the VAX, SPARC, and MIPS architectures. Work on the
more recent version of YAP strives at several goals:
Portability: The whole system is now written in C. YAP compiles in popular 32 bit machines, such
as Suns and Linux PCs, and in a 64 bit machines, the Alphas running OSF Unix and Linux.
Performance: We have optimised the emulator to obtain performance comparable to or better than
well-known Prolog systems. In fact, the current version of YAP performs better than the original
one, written in assembly language.
Robustness: We have tested the system with a large array of Prolog applications.
Extensibility: YAP was designed internally from the beginning to encapsulate manipulation of
terms. These principles were used, for example, to implement a simple and powerful C-interface.
The new version of YAP extends these principles to accomodate extensions to the unification
algorithm, that we believe will be useful to implement extensions such as constraint programming.
Completeness: YAP has for a long time provided most builtins expected from a Edinburgh Prolog
implementation. These include I/O functionality, data-base operations, and modules. Work on YAP
aims now at being compatible with the Prolog standard.
Openess: We would like to make new development of YAP open to the user community.
Research: YAP has been a vehicle for research within and outside our group. Currently research is
going on on parallelisation and tabulation, and support for Bayesian Networks.
5
http://www.dcc.fc.up.pt/~vsc/Yap/
10
tuProlog6
tuProlog (also called 2P) is a Java-based light-weight
Prolog engine developed at the University of Bologna, and
maintained by the aliCE Research Group based in Cesena, at the Second
Faculty of Engineering, with some members working at the Faculty of
Engineering located in Bologna.
tuProlog has been designed to be one of the basic bricks of Internet
applications and infrastructures; this purpose has dictated its main characteristics, such as
deployability, lightness, dynamic configurability, integration with Java and ease of interoperability.
tuProlog is a light-weight Prolog system for distributed applications and infrastructures,
intentionally designed around a minimal core, to be later configured by (statically and dynamically)
loading/unloading libraries of predicates. tuProlog natively supports multi-paradigm programming,
providing a clean, seamless integration model between Prolog and mainstream object-oriented
languages -- namely Java, for tuProlog Java version, and any .NET-based language (C#, F#..), for
tuProlog .NET version.
6
http://en.wikipedia.org/wiki/TuProlog
11
THE CIAO SYSTEM7
Ciao is a general-purpose programming language which supports logic,
constraint, functional, higher-order, and object-oriented programming styles. Its main design
objectives are high expressive power, extensibility, safety, reliability, and efficient execution.
Ciao offers a complete Prolog system, supporting ISO-Prolog, but its novel modular design allows
both restricting and extending the language. As a result, it allows working with fully declarative
subsets of Prolog and also to extend these subsets (or ISO-Prolog) both syntactically and
semantically. Most importantly, these restrictions and extensions can be activated separately on
each program module so that several extensions can coexist in the same application for different
modules.
Ciao also supports (through such extensions) programming with functions, higher-order (with
predicate abstractions), constraints, and objects, as well as feature terms (records), persistence,
several control rules (breadth-first search, iterative deepening, ...), concurrency (threads/engines), a
good base for distributed execution (agents), and parallel execution. Libraries also support WWW
programming, sockets, external interfaces (C, Java, TclTk, relational databases, etc.), etc.
7
http://ciao-lang.org/
https://www.complang.tuwien.ac.at/ulrich/prolog_misc/systems.html
Name
Main Developer
ISO
Part I
CLP
CHR
Availability Source
dif FD Q R
Bcompl.
yes yes yes float
yes
Commercial
Applications,
References, Remarks
SICStus 3
SICS
full
commercial no
SWI
J. Wielemaker
full
LGPL
YAP
LIACC
full
artistic
Prolog IV
PrologIA
full
commercial
yes yes yes interval
IF/Prolog
IF Computer
full
commercial
yes yes yes
ECLiPSe
IC-Parc
Cisco-MPL
yes yes yes float
yes
applications
SICStus 4
SICS
commercial
yes yes
yes
merge of SICStus 3 and Quintus
Ciao
M. Hermenegildo partial GNU
GNU
yes
originally based on older SICStus
XSB
SUNY
LGPL
yes
yes
company: industries served
B-Prolog
Neng-Fa Zhou
partial commercial
yes yes
yes
Prolog II+
PrologIA
yes
yes
Nu
L. Naish
academic
CHIP
Cosytec
commercial
GNU Prolog D. Diaz
full
LGPL
full
yes
references, Clarissa, Edgarscan, Tacton
LGPL yes yes yes float
yes
applications
yes
yes
free
GNU
yes
GNU
yes yes yes float
yes
yes float
references
yes
applications!!!
yes
yes yes
applications!!!, references
yes
TOPS
Name
Main Developer
ISO
Part I
CLP
CHR
Availability Source
dif FD Q R
Bcompl.
Commercial
Applications,
References, Remarks
Prolog systems without constraints (with mostly many other extensions)
MINERVA
IF Computer
full
commercial
runs in Java browser!!!, showcase
Amzi!
full
commercial yes
applications
ALS
yes
commercial
applications
LPA
yes
commercial
applications, news
free
showcase
Arity/Prolog
Quintus
SICS
commercial
Inquizit
BinProlog
BinNet
commercial
demos
Trinc
Strawberry
full
D.D. Dobrev
commercial
commercial
Close-to-Prolog systems (mostly type or mode restricted)
Visual Prolog PDC
commercial
applications, Borland Turbo Prolog's successor
Mercury
Z. Somogyi
GNU
GNU
HAL
team
?
?
float?
1
Speed comparison
The following comparison tests the overheads incurred by unify_with_occurs_check/2.
Significant overheads are not inherent: The 496 logical inferences executed require a total of 465
unifications with occurs check. But 435 unify a variable with a constant, 30 unify a variable with a
ground list of the form [integer].
Mlips
Pentium III 1GHz
system
version default occurs check slowdown
SWI
5.4.0
SICStus
1.8
1.2 *
1.5
3.11.2 11.8
2.7
4.3
Yap
4.4.4
7.8
2.5
Ciao
1.10#5 6.6
2.0
3.3
GNU
1.2.16 10.9
5.8
1.9
B
6.6 #2 14.5
n.a
-
19.5
2
Deduktīvas datu bāzes sistēmas čaula
LDL++ sistēma
3
Systems implementing Datalog. Free software/Open
source
Written
Name
in
Java
C
Description
IRIS
IRIS extends Datalog with function symbols, built-in
predicates, locally stratified or un-stratified logic programs
(using the well-founded semantics), unsafe rules and XML
schema data types
Jena
a Semantic Web framework which includes a Datalog
implementation as part of its general purpose rule engine,
which provides OWL and RDFS support.
SociaLite
SociaLite is a datalog variant for large-scale graph analysis
developed in Stanford
Graal
Graal is a Java toolkit dedicated to querying knowledge bases
within the framework of existential rules, aka Datalog+/-.
XSB
A logic programming and deductive database system for Unix
and MS Windows with tabling giving Datalog-like termination
and efficiency, including incremental evaluation
Coral
A deductive database system written in C++ with semi-naïve
datalog evaluation. Developed 1988-1997.
Inter4QL
an open-source command-line interpreter of Datalog-like 4QL
query language implemented in C++ for Windows, Mac OS X
and Linux. Negation is allowed in heads and bodies of rules as
well as in recursion
RDFox
RDF triple store with Datalog reasoning. Implements the FBF
algorithm for incremental evaluation.
Souffle
an open-source Datalog-to-C++ compiler converting Datalog
into high-performance, parallel C++ code, specifically designed
for complex Datalog queries over large data sets as e.g.
encountered in the context of static program analysis
C++
Python
adds logic programming to python's toolbox. It can run logic
pyDatalog queries on databases or python objects, and use logic clauses to
define the behavior of python classes.
Ruby
bloom /
bud
A Ruby DSL for programming with data-centric constructs,
based on the Dedalus extension of Datalog which adds a
4
temporal dimension to the logic.
Lua
Datalog
a lightweight deductive database system.
Prolog
DES
an open-source implementation to be used for teaching Datalog
in courses
Cascalog
a Clojure library for querying data stored on Hadoop clusters
Clojure
Datalog
a contributed library implementing aspects of Datalog
Datascript
Immutable database and Datalog query engine that runs in the
browser
Clojure
Racket
Datalog
for Racket
Tcl
tclbdd
Implementation based on binary decision diagrams. Built to
support development of an optimizing compiler for Tcl.
Dyna
Dyna is a declarative programming language for statistical AI
programming. The language is based on Datalog, supports both
forward and backward chaining, and incremental evaluation.
Haskell
other or bddbddb
unknow
n
languag ConceptB
es
ase
an implementation of Datalog done at Stanford University. It is
mainly used to query Java bytecode including points-to analysis
on large Java programs
a deductive and object-oriented database system based on a
Datalog query evaluator. It is mainly used for conceptual
modeling and metamodeling
5
Non-free software
Datomic is a distributed database designed to enable scalable, flexible and intelligent
applications, running on new cloud architectures. It uses Datalog as the query
language.
DLV is a commercial Datalog extension that supports disjunctive head clauses.
FoundanDBtio provides a free-of-charge database binding for pyDatalog, with a
tutorial on its use.
Leapsight Semantic Dataspace (LSD) is a distributed deductive database that offers
high availability, fault tolerance, operational simplicity, and scalability. LSD uses
Leaplog (a Datalog implementation) for querying and reasoning and was create by
Leapsight.
LogicBlox, a commercial implementation of Datalog used for web-based retail
planning and insurance applications.
.QL, a commercial object-oriented variant of Datalog created by Semmle.
SecPAL a security policy language developed by Microsoft Research.
Stardog is a graph database, implemented in Java. It provides support for RDF and all
OWL 2 profiles providing extensive reasoning capabilities, including datalog
evaluation.
StrixDB: a commercial RDF graph store, SPARQL compliant with Lua API and
Datalog inference capabilities. Could be used as httpd (Apache HTTP Server) module
or standalone (although beta versions are under the Perl Artistic License 2.0).
6
Datalog Educational system8
8
http://des.sourceforge.net/
7
8
Realizāciju piemēri.
Sistēma maršrutu analīzei (track analysis)
Mazsalaca
18km
Rūjiena
Aloja
44km
Valmiera
Limbaži
28km
Stalbe
Saulkrasti
31km
Cēsis
9
Deduktīvās datu bāzes realizācija
Prologa sistēmas SQL interfeisa izmantošana
10
11
Deduktīvās datu bāzes realizācija (2. variants)
12
Deduktīvās DB darbības algoritms
13
Faktu tabula
Likumu tabula (rekursija)
14
Predikātu glabāšana
15
Deduktīvās datu bāzes interfeiss
16
Deduktīvās datu bāzes realizācija (3. variants)
17
1. Sākuma logs
2. Pieslēgšanās datu bāzei
18
3. Darba logs (var izpildīt arī vaicājumus datu bāzei)
19
4. Predikātu faktu logs
5. Predikātu likumu logs
20
6. Izveduma darbību secības apskate
7. Rezultāts
21
Deduktīvās datu bāzes realizācija (4. variants)
PHP programmēšanas valodas izmantošana
22
Pielikums
Deduktīvu datu bāzu sistēmas un prototipi9
Komerciālās sistēmas
DLV (Italy, University of Calabria) commercial
LogicBlox (USA) commercial
Intellidimensin (USA) commercial
Semmle (UK) commercial
9
http://users.informatik.uni-halle.de/~brass/lp14/software.html
23
Prolog/CLP sistēmas
SWI-Prolog
[http://www.swi-prolog.org/]
GNU Prolog
(GNU Prolog for Java is an implementation of ISO Prolog as a Java library
(gnu.prolog))
[http://gnu-prolog.inria.fr/]
The Ciao Prolog System
[http://clip.dia.fi.upm.es/~clip/Software/Ciao/]
ECLiPSe Constraint Logic Programming System
[http://eclipse.crosscoreop.com/eclipse/]
[http://www.clps.de/]
B-Prolog
[http://www.probp.com/]
SICStus Prolog
[http://www.sics.se/sicstus/] (Homepage)
[http://www.sics.se/sicstus/docs/3.7.1/html/sicstus_toc.html] (User Manual)
[http://www.sics.se/isl/sicstuswww/site/links.html] (Useful Links)
Visual Prolog
[http://www.visual-prolog.com/]
[http://www.pdc.dk/Default.htm] (PDC: Prolog Development Center)
The Prolog ISO Standard Documents
[http://pauillac.inria.fr/~deransar/prolog/docs.html]
InterProlog (Java front-end and enhancement for Prolog)10
XSB Prolog
YAP Prolog
10
http://www.declarativa.com/InterProlog/
24
Deduktīvās datu bāzes sistēmas
Coral11 Deductive Database (University of Wisconsin)
[http://www.cs.wisc.edu/coral/]
[http://se.aminet.net/pub/databases/deductive/coral/
[http://se.aminet.net/pub/databases/object-oriented/exodus/
The Aditi12 Deductive Database
[http://www.cs.mu.oz.au/research/aditi/]
The Deductive Database System LDL++13
[http://wis.cs.ucla.edu/ldl/]
[http://www.cs.ucla.edu/~zaniolo/papers/tplp02.pdf]
[http://www.cs.ucla.edu/ldl/] (LDL Java Interface)
[http://www.cs.uwyo.edu/~ruben/research/pdf/guide.pdf]
NAIL! (Stanford university)
The LOLA14 Project, Implementation of a Deductive Database System
[http://www.im.uni-passau.de/projekte/lola.html]
ROCK&ROLL: Deductive Object Oriented Database System
[http://www.cee.hw.ac.uk/Databases/rnr.html]
Datalog Educational System (DES)15 (Complutense university)
[http://www.softpedia.com/get/Others/Home-Education/Datalog-Educational-System.shtml]
[http://www.fdi.ucm.es/profesor/fernan/des/]
Lightwight Deductive Database System (MITRE Corporation)
[http://www.ccs.neu.edu/home/ramsdell/tools/datalog/]
bbdbddb - BDD-Based Deductive DataBase
[http://bddbddb.sourceforge.net/]
11
https://www.cse.iitb.ac.in/~sudarsha/Pubs-dir/coralimpl.sigmod93.pdf
http://research.cs.wisc.edu/coral/
12
13
14
15
VLDB Jouraal, 3, 245-288 (1994). Invited contribution. Hans-J. Schek, Editor.
http://web.cs.ucla.edu/~zaniolo/czdemo/tsur/Papers/ldlfinal.pdf
http://dbis-informatik.uibk.ac.at/files/ext/mitarbeiter/specht/lit/91-tec-ldl-lola-vgl-scan.pdf
https://www.fdi.ucm.es/profesor/fernan/FSP/SCG11aSlides.pdf
25
LogicBlox: Cloud-delivered platform for actionable Big Data enterprise
applications
[http://www.logicblox.com/] (Homepage)
[http://www.logicblox.com/presentations/arefdatalog20.pdf]
STARBURST
4QL (Warsaw University)
MegaLog
PRO_SQL – sistēma, kurā loģiskā programmēšanas valoda PROLOG sasaistīta
ar SQL/DS sistēmu (IBM Research Center at Yorktown Heights).
EDUCE - sistēma, kurā loģiskā programmēšanas valoda PROLOG sasaistīta ar
DBVS INGRES (European Computer Industry Research Center).
ESTEAM
- firmas Philips izstrāds interfeiss sistēmai ESTEAM un DBVS
INGRESS QUEL vaicājumu valodā.
BERMUDA
PRIMO – interfeiss starp Arity-Prolog sistēmu un DBVS Oracle, izstrāde veikta
Modenas universitātē Itālijā.
QUINTUS-PROLOG – firmas Quintus Computer System izstrādne, kurā
izveidots interfeiss ar DBVS Unify.
INDALOG a declarative deductive database language16
16
http://www.ual.es/~abecerra/archivos/prole01def.pdf
26
Loģiskās programmēšanas sistēmas
The Mercury Project
[http://www.cs.mu.oz.au/research/mercury/]
The Mozart Programming System
[http://www.mozart-oz.org/]
XSB (Stony Brook University, Uppsala Universitet)17
[http://xsb.sourceforge.net/]
Flora-2
[http://flora.sourceforge.net/]
FLORID/FloXML
[http://www.informatik.uni-freiburg.de/~dbis/florid/]
[http://www.semwebtech.org/domains/test/DLFlorid/] (Online Demo)
Xcerpt
[http://www.xcerpt.org/]
ConceptBase: A Deductive Object Manager for Meta Databases
(Passau, Aachen, Tilburg Universities)
[http://www-i5.informatik.rwth-aachen.de/CBdoc/]
The Goedel Programming Language
[http://www.cs.bris.ac.uk/~bowers/goedel.html]
A Java Deductive Reasoning Engine for the Web
[http://www.jdrew.org/jDREWebsite/jDREW.html]
IRIS - Integrated Rule Inference System
[http://iris-reasoner.org/]
17
http://xsb.sourceforge.net/
27
Answer Set Programming (ASP) Systems
smodels
[http://www.tcs.hut.fi/Software/smodels/]
Potassco (clasp, Gringo, ...)
[http://potassco.sourceforge.net/]
DLV
[http://www.dlvsystem.com/]
Datalog valoda
Datalog is a declarative logic programming language that syntactically is a subset of
Prolog.
It is often used as a query language for deductive databases. In recent years, Datalog
has found new application in:
1) data integration;
2) information extraction;
3) networking;
4) program analysis;
5) security;
6) cloud computing.
Its origins date back to the beginning of logic programming, but it became prominent
as a separate area around 1977 when Hervé Gallaire and Jack Minker organized a
workshop on logic and databases. David Maier is credited with coining the term
Datalog.
Unlike in Prolog, statements of a Datalog program can be stated in any order.
Furthermore, Datalog queries on finite sets are guaranteed to terminate, so Datalog
28
does not have Prolog's cut operator. This makes Datalog a truly declarative
language.
In contrast to Prolog, Datalog:
1) disallows complex terms as arguments of predicates, e.g., p (1, 2) is admissible
but not p (f (1);
2) imposes certain stratification restrictions on the use of negation and
recursion;
3) requires that every variable that appears in the head of a clause also appears in a
nonarithmetic positive (i.e. not negated) literal in the body of the clause;
4) requires that every variable appearing in a negative literal in the body of a clause
also appears in some positive literal in the body of the clause.
Query evaluation with Datalog is based on first order logic, and is thus sound and
complete. However, Datalog is not Turing complete, and is thus used as a domainspecific language that can take advantage of efficient algorithms developed for query
resolution. Indeed, various methods have been proposed to efficiently perform queries.
Several extensions have been made to Datalog, e.g., to support aggregate functions, to
allow object-oriented programming, or to allow disjunctions as heads of clauses.
29
Example Datalog program:
parent(bill, mary).
parent(mary, john).
These two lines define two facts, i.e. things that always hold. They can be intuitively
understood as: the parent of mary is bill and the parent of john is mary.
ancestor(X,Y) :- parent(X,Y).
ancestor(X,Y) :- parent(X,Z),ancestor(Z,Y).
These two lines describe the rules that define the ancestor relationship. A rule consists
of two main parts separated by the :- symbol. The part to the left of this symbol is the
head of the rule, the part to the right is the body. A rule is read (and can be intuitively
understood) as <head> if it is known that <body>. Uppercase letters stand for
variables. Hence in the example the first rule can be read as X is the ancestor of Y if it
is known that X is the parent of Y. And the second rule as X is the ancestor of Y if it is
known that X is the parent of some Z and Z is the ancestor of Y. The ordering of the
clauses is irrelevant in Datalog in contrast to Prolog which depends on the ordering of
clauses for computing the result of the query call.
Datalog distinguishes between Extensional predicate symbols (defined by facts) and
intensional predicate symbols (defined by rules). In the example above ancestor is an
intensional predicate symbol, and parent is extensional. Predicates may also be defined
by facts and rules and therefore neither be purely extensional nor intensional, but any
Datalog program can be rewritten into an equivalent program without such predicate
symbols with duplicate roles.
?- ancestor(bill,X).
The query above asks for all that bill is ancestor of, and would return mary and john
when posed against a Datalog system containing the facts and rules described above.