blob: 781b7c3a8f499654ae3d2ef4397ab84b40718a5f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
-- Programmed by Jedidiah Barber
-- Licensed under the Sunset License v1.0
-- See license.txt for further details
with
Ada.Text_IO,
Kompsos.Pretty_Print;
procedure FiveSix is
package TIO renames Ada.Text_IO;
package InKomp is new Kompsos (Integer);
use InKomp;
package InPrin is new InKomp.Pretty_Print (Integer'Image);
use InPrin;
function Fives
(This : in Goal)
return Goal
is
One, Two : Goal := This;
begin
One.Unify (One.Fresh, 5);
Two.Conjunct (Fives'Access);
return Disjunct (One, Two);
end Fives;
function Sixes
(This : in Goal)
return Goal
is
One, Two : Goal := This;
begin
One.Unify (One.Fresh, 6);
Two.Conjunct (Sixes'Access);
return Disjunct (One, Two);
end Sixes;
Relation : constant Goal := Disjunct (Fives (Empty_Goal), Sixes (Empty_Goal));
begin
TIO.Put_Line ("Test program for fives-and-sixes example from 2013 microKanren paper.");
TIO.Put_Line ("Since the result is infinite, only the first five states will be shown.");
TIO.New_Line;
-- Note how the States keep using new Variables instead of just reusing the same one.
-- This is an unavoidable side effect of setting up Variable Terms to be manually
-- created from a Goal by the programmer, instead of being supplied as needed in the
-- process of evaluation.
TIO.Put_Line (Image (Relation.Run (5)));
end FiveSix;
|