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 Vardefinition. - Check if
alphaVarin thewhereclause ofalphaEquivalentneeds 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
freeInand its test case. - If necessary, update
mguand its test case. - If necessary, update the
Unifiableinstance forTermand its test case. - If necessary, update
renameVarand 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
formatVariableand add a test.
In Bench in package hspl-bench:
- Add a case to
genPrologTermto translate the variable to an analagous Prolog variable.
In Control.Hspl.Internal.Ast:
- Add the constructor to the
data Goaldefinition. - Add a case to the
Eqinstance forGoaland update the associated unit tests.
In Control.Hspl.Internal.UI
- Add a case to
formatGoalwhich 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> = Falseclause toparensGoal. - In the
parensGoaltest 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
Unifiableinstance forGoaland update the associated test. - Add a case to
renameGoaland update the associated test.
In Control.Hspl.Internal.Solver:
- Add a case to
matchGoalin thewhereclause ofqueryTheoremand add tests. - Add a method to
class MonadSolvercalledtry<Constructor>. - Add a function called
prove<Constructor>which attempts to produce a proof of the newGoal, and definetry<Constructor> = prove<Constructor>in theMonadSolverinstance forSolverT. Add unit tests forprove<Constructor>. - Add a case to
Provewhich callsprove<Constructor>.
In Control.Hspl.Internal.Debugger:
- Define the new method in the
MonadSolverinstance 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
genPrologGoalto translate the goal into an analagous Prolog goal.