mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-24 13:53:54 +00:00
Estimated hours taken: 1
tests/Mmakefile:
Add the new tabling directory to the list of directories.
tests/tabling/Mmakefile:
tests/tabling/runtests:
The intrastructure of the new tests directory.
tests/tabling/fib.{m,exp}:
A test of the memoing of a det procedure.
tests/tabling/tc_loop.{m,exp}:
A test of loop checking for a nondet procedure.
tests/tabling/tc_minimal.{m,exp}:
A test of minimal model tabling for a nondet procedure.
(Doesn't work yet).
tests/tabling/boyer.{m,exp}:
A benchmark program, translated to Mercury by Bart Demoen
from an original in Prolog.
(Doesn't work yet).
38 lines
575 B
Mathematica
38 lines
575 B
Mathematica
:- module tc_loop.
|
|
|
|
:- interface.
|
|
|
|
:- import_module io.
|
|
|
|
:- pred main(io__state::di, io__state::uo) is det.
|
|
|
|
:- implementation.
|
|
|
|
:- import_module std_util, list.
|
|
|
|
main -->
|
|
{ solutions(tc(1), Solns) },
|
|
( { Solns = [] } ->
|
|
io__write_string("loopcheck failed, tc has no solutions\n")
|
|
;
|
|
io__write_string("loopcheck failed, tc has solutions\n")
|
|
).
|
|
|
|
:- pred tc(int::in, int::out) is nondet.
|
|
:- pragma loop_check(tc/2).
|
|
|
|
tc(A, B) :-
|
|
(
|
|
edge(A, B)
|
|
;
|
|
edge(A, C),
|
|
tc(C, B)
|
|
).
|
|
|
|
:- pred edge(int::in, int::out) is nondet.
|
|
|
|
edge(1, 2).
|
|
edge(1, 3).
|
|
edge(2, 1).
|
|
edge(3, 4).
|