Skip to content

Reference

Information-oriented technical description of 2P-Kt's modules and APIs.

The full generated API documentation (Dokka, covering every module) is available at /api/.

At a glance: the Term hierarchy

Every piece of logic data in 2P-Kt — atoms, numbers, variables, structures, clauses — is a Term. Terms are immutable, tree-like data structures:

package it.unibo.tuprolog.core

import it.unibo.tuprolog.utils.Castable
import it.unibo.tuprolog.utils.Taggable
import kotlin.js.JsName

/**
 * Base type for all logic terms: [Var]iables, [Constant]s ([Atom]s and [Numeric]s), and [Struct]ures
 * (including [Clause]s, [List]s, [Tuple]s, and [Block]s, which are all just structures with a conventional
 * functor). Every piece of data 2P-Kt's logic engine manipulates is, ultimately, a [Term].
 *
 * [Term]s are immutable tree-like data structures: there is no public API mutating a [Term] in place, only
 * ones (like [freshCopy] and [Applicable.apply]) that return a new [Term]. This is what lets terms be shared
 * freely between larger terms, knowledge bases, and concurrent computations without any risk of aliasing.
 *
 * [Term] also defines three, deliberately distinct, notions of equality  [equals] (identity-like, comparing

Term interface

See Module map for how the ~30 modules relate to each other.

Suggested reading order

Reference pages are self-contained lookup material, but they build on each other roughly in this order — from the big picture down to specific APIs, ending with a couple of project-meta pages:

  1. Module map — what the ~30 modules are and how they depend on each other.
  2. Term hierarchy — the core logic-data model everything else is built on.
  3. Unification API — unifying and substituting Terms.
  4. Solver API — the platform-agnostic goal-resolution API.
  5. Primitives and functions — the building blocks a Solver executes.
  6. Default predicates — the standard predicates built from those primitives.
  7. Libraries — bundling predicates/functions into a pluggable unit.
  8. I/O library — the :io-lib predicate catalogue and platform caveats, a concrete Library example.
  9. Prolog DSL — the Kotlin DSL for building terms/theories/queries.
  10. Errors and exceptions — the exception hierarchy raised during resolution.
  11. CI/CD pipeline — project-meta: how 2P-Kt itself is built, tested, and released.