-
Notifications
You must be signed in to change notification settings - Fork 15
CILC 2022 – Tech Contest
2P-Kt is a Kotlin-based and multi-platform reboot of tuProlog. It consists of an open ecosystem for symbolic artificial intelligence (AI), and, in particular, logic-based technologies.
In this page, we briefly summarise the purpose, the functionalities, the intended userbase, and the potential of 2P-Kt.
2P-Kt consists of a pool of interrelated libraries for logic programming (LP). It aims at helping mainstream developers to exploit LP in their software, as well as logic programmers to develop new logic-based technologies without having to rely on Prolog, or rewriting everything from scratch. It also aims at providing portable and easy-to-use user interfaces for logic solvers: in this sense, 2P-Kt may also act as an ordinary Prolog interpreter.
Finally, 2P-Kt aims at widening its support to cover increasingly many aspects of LP. It does so by enforcing modularity and by easing reusability and extensibility. In this way, developers may support novel LP facilities by building upon the previous ones constructed so far.
2P-Kt is deeply rooted in LP, a programming paradigm based on Computational Logic. In LP, programs are typically theories (a.k.a. knowledge bases, KB), i.e. collections of sentences in logical form, expressing facts and rules about some domain, typically in the form of Horn clauses, i.e.:
H :- B_1, ..., B_n
where both H
and B_i
are atomic formulæ, and the whole sentence is read declaratively as logical implication (right-to-left).
If n = 0
, the clause is called a fact, a rule otherwise.
An atomic formula is an expression of the form P(t_1, ..., t_m)
where P
is a m
-ary predicate (m >= 0
), and t_j
are terms.
Terms are the most general sort of data structure in LP languages.
They can be constant (either numbers or atoms/strings), variables, or recursive elements named structures. Structures are used to represent clauses, lists, sets, or other sorts of expressions.
Logic solvers exploit KB to answer users' queries via some inference procedure and resolution strategy. For instance, Prolog interpreters exploit a deductive procedure rooted into the SLD resolution principle with negation as failure, and a depth-first strategy. Yet, other options exist like, e.g., abductive, inductive, probabilistic inference. Each of them represents a particular reification of a logic solver.
A common mechanism in LP is the Martelli and Montanari's unification algorithm for constructing a most general unifier (MGU) among any two terms. Provided that a MGU exists, its subsequent application to the terms, makes them syntactically equal. This is a basic brick in virtually all LP algorithms, regardless of the particular inference rule.
Summarising, LP leverages several mechanisms – terms and clauses representation, knowledge base storage, unification, resolution, etc. –, which constitute the basis of any logic solver. Subsets of these mechanisms may be useful per se. 2P-Kt makes LP mechanisms individually available, while easing the construction of novel mechanisms on top of the existing ones.
2P-Kt currently supports basic knowledge-representation (via logic terms and Horn clauses) and -manipulation (via substitutions, unification, indexing, etc.), as well as inference (e.g. deductive, concurrent, or probabilistic).
As shown in the project map, 2P-Kt currently focuses on supporting knowledge representation and automatic reasoning through logic programming, by featuring:
-
a module for logic terms and clauses representation, namely
core
, -
a module for logic unification representation, namely
unify
, -
a module for in-memory indexing and storing logic theories, as well as other sorts of collections of logic clauses, namely
theory
, -
a module providing generic API for resolution of logic queries, namely
solve
, coming with several implementations (e.g.solve-classic
andsolve-streams
, targetting Prolog ISO Standard compliant resolution), -
a module providing generic API for the probabilistic resolution of logic queries via probabilistic logic programming (PLP), namely
solve-plp
, coming with an implementation targetting ProbLog (solve-problog
)- leveraging on module
:bdd
, which provides a multi-platform implementation of binary decision diagrams (BDD) - further details are provided in this paper
- leveraging on module
-
a module providing OR-concurrent resolution facilities, namely
solve-concurrent
, -
a number of modules (i.e., the many
dsl-*
modules) supporting a Prolog-like, Domain Specific Language (DSL) aimed at bridging the logic programming with the Kotlin object-oriented & functional environment,- further details are provided in this paper
-
two parsing modules: one aimed at parsing terms, namely
parser-core
, and the other aimed at parsing theories, namelyparser-theory
, -
two serialisation-related modules: one aimed at (de)serialising terms and clauses, namely
serialize-core
, and the other aimed at (de)serialising terms theories, namelyserialize-theory
, -
a module for using Prolog via a command-line interface, namely
repl
, -
a module for using Prolog via a graphical user interface (GUI), namely
ide
, -
a module for using PLP (and, in particular, ProbLob) via a GUI, namely
ide-plp
.
The modular, unopinionated architecture of 2P-Kt is deliberately aimed at supporting and encouraging extensions towards other sorts of logic-based technologies (than Prolog)---such as ASP, tabled-inference, etc.
As a pool of libraries, 2P-Kt is meant to be used by developers. However, command-line and graphical user interfaces are available as well, to support the execution of ordinary logic interpreters, such as the Prolog one.
Which kinds of developers/users really depends on which particular functionality of 2P-Kt one is taking into consideration. Developers may be either willing to exploit logic representation, unification, or inference in their software, or they may be willing to construct novel logic-based technologies by altering/extending the way logic representation, unification, or inference work by default. Users may consist of logic programmers willing to exploit the supported means for logic representation, unification, or inference---either as libraries or as graphical/command-line applications.
To maximise the potential audience of 2P-Kt, we currently support both the JVM, and JS platforms -- which implies, the Windows, Mac Os, Linux, and Android operative systems --, whereas Python support is under development (cf. 2ppy).
The 2P-Kt technology may impact on many research areas.
As far as LP is concerned, 2P-Kt provides a well-grounded technological basis for implementing/experimenting/extending the many solutions proposed in the literature -- e.g., abductive inference, rule induction, probabilistic reasoning, labelled LP -- to make them reusable as individual mechanisms.
However, 2P-Kt is also being considered as the technological basis of many contributions involving
- multi-agent systems (as it enables the implementation of custom BDI agents)
- coordination (as it enables the implementation of custom tuple spaces/centres)
- planning (as it enables the implementation of custom planners)
- inductive logic programming (as it enables the implementation of custom inducers)
- and so on and so forth.
Finally, 2P-Kt is being exploited as a didactic tool within the scope of the Intelligent System Engineering course, where it allows teachers to let students practice (via coding) with low-level aspects of LP (cf. the slides of the course).