LogicProgrammingScopeWithResolution
Adds resolution-driving sugar to LogicProgrammingScopeWithUnificator: implements MutableSolver itself (forwarding to defaultSolver, e.g. via MutableSolver by defaultSolver as LogicProgrammingScopeImpl does), so solve/solveOnce/solveList and every knowledge-base-mutating operation (MutableSolver.assertZ, MutableSolver.retract, ...) are callable directly on the scope — plus staticKb/dynamicKb shorthands for loading a whole knowledge base at once, and solverOf for building additional, independent solvers sharing this scope's solverFactory/unificator.
This is what turns the DSL from a pure term/theory builder into something that can actually run queries:
prolog {
staticKb(
fact { "parent"("abraham", "isaac") },
rule { "ancestor"("X", "Y") `if` "parent"("X", "Y") },
)
for (solution in solve("ancestor"("abraham", "X"))) {
if (solution is it.unibo.tuprolog.solve.Solution.Yes) {
println(solution.substitution["X"])
}
}
}solve (and the rest of the MutableSolver/it.unibo.tuprolog.solve.Solver surface) is inherited, undocumented here, from it.unibo.tuprolog.solve.Solver and MutableSolver themselves.
Type Parameters
the concrete, self-referential scope type (see it.unibo.tuprolog.dsl.BaseLogicProgrammingScope).
Inheritors
Properties
The MutableSolver this scope forwards MutableSolver/it.unibo.tuprolog.solve.Solver operations (solve, staticKb, dynamicKb, assertZ, ...) to. Built once when the scope is created (see LogicProgrammingScopeImpl's secondary constructor) via SolverFactory.mutableSolverOf.
The SolverFactory this scope's defaultSolver was created from, and that solverOf builds further solvers from by default.
Functions
Replaces defaultSolver's dynamic knowledge base with theory; see MutableSolver.loadDynamicKb.
Replaces defaultSolver's dynamic knowledge base with a Theory indexing clauses; see MutableSolver.loadDynamicClauses.
Builds a brand-new MutableSolver from solverFactory (defaulting every argument to solverFactory's default* values, except unificator which defaults to this scope's own), including solverFactory's standard-library builtins — see SolverFactory.mutableSolverWithDefaultBuiltins. Unlike defaultSolver, this returns an independent solver each time it's called, not the one backing this scope's solve/staticKb calls.
Replaces defaultSolver's static knowledge base with theory; see MutableSolver.loadStaticKb.
Replaces defaultSolver's static knowledge base with a Theory indexing clauses; see MutableSolver.loadStaticClauses.