HSPL (Haskell Predicate Logic) is an embedded domain specific language that brings logic programming to Haskell. HSPL uses resolution-based automated theorem proving to make logical deductions, and will provide functionality similar to that of logic programming languages like Prolog.
- Install Stack.
- Pull the code:
git clone https://github.com/jbearer/hspl.git
cd hspl
- Build the library:
stack build hspl
Or, to build all packages (including benchmarks):
stack build
HSPL maintains a thorough suite of unit tests covering the library. To run,
stack test hspl
There are several benchmarks which can be used to assess the performance of HSPL by comparing the
running time of some example programs with that of comparable programs written in Prolog. To
simplify dependency management, each benchmark program lives in its own package. Common benchmarking
utilitiese are defined in the package hspl-bench
. To build the utilities:
stack build hspl-bench
To run all benchmarks:
stack bench -j1 --dump-logs
Or, to run a specific benchmark:
stack bench <benchmark>
In Control.Hspl.Internal.Ast
:
- Add the constructor to the
data Var
definition. - Check if
alphaVar
in thewhere
clause ofalphaEquivalent
needs to be updated. This will depend on the desired semantics of the new constructor. If necessary, update and add tests.
In Control.Hspl.Internal.Unification
:
- If necessary (depending on the desired semantics) update
freeIn
and its test case. - If necessary, update
mgu
and its test case. - If necessary, update the
Unifiable
instance forTerm
and its test case. - If necessary, update
renameVar
and its test case.
In Control.Hspl
:
- If the new variable type is user-facing (as opposed to, say,
Fresh
, which is purely internal), add syntax for creating variables of this type, and add tests.
In Control.Hspl.Internal.UI
:
- Add a case in
formatVariable
and add a test.
In Bench
in package hspl-bench
:
- Add a case to
genPrologTerm
to translate the variable to an analagous Prolog variable.
In Control.Hspl.Internal.Ast
:
- Add the constructor to the
data Goal
definition. - Add a case to the
Eq
instance forGoal
and update the associated unit tests.
In Control.Hspl.Internal.UI
- Add a case to
formatGoal
which converts the new goal into a string consistent with the new syntax, and add a test case. - If the new syntax consists of a single token, add a
needsParens <NewGoal> = False
clause toparensGoal
. - In the
parensGoal
test case, add an example of the new goal to either the list of goals which need parentheses, or the list of those which don't, as appropriate.
In Control.Hspl.Internal.Unification
:
- Add a case to the
Unifiable
instance forGoal
and update the associated test. - Add a case to
renameGoal
and update the associated test.
In Control.Hspl.Internal.Solver
:
- Add a case to
matchGoal
in thewhere
clause ofqueryTheorem
and add tests. - Add a method to
class MonadSolver
calledtry<Constructor>
. - Add a function called
prove<Constructor>
which attempts to produce a proof of the newGoal
, and definetry<Constructor> = prove<Constructor>
in theMonadSolver
instance forSolverT
. Add unit tests forprove<Constructor>
. - Add a case to
Prove
which callsprove<Constructor>
.
In Control.Hspl.Internal.Debugger
:
- Define the new method in the
MonadSolver
instance ofDebugSolverT
, and add example goals and traces to the test suite.
In Control.Hspl
:
- Define a predicate or a new syntactic primitive which users can use to create goals of the new type. Add tests that either check that the correct goal is created, or run a program that uses the new predicate and check the results, as appropriate.
In Bench
in package hspl-bench
:
- Add a case in
genPrologGoal
to translate the goal into an analagous Prolog goal.