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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
-- 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 Complete is
package TIO renames Ada.Text_IO;
package InKomp is new Kompsos (Integer);
use InKomp;
package Printer is new InKomp.Pretty_Print (Integer'Image);
function Fives
(This : in Goal;
Item : in Term'Class)
return Goal
is
One, Two : Goal := This;
begin
One.Unify (Item, 5);
Two.Conjunct (Fives'Access, Item);
return Disjunct (One, Two);
end Fives;
function Simple
(This : in Goal;
Item : in Term'Class)
return Goal is
begin
return This.Unify (Item, 1);
end Simple;
begin
TIO.Put_Line ("This program will loop forever unless the implementation is using");
TIO.Put_Line ("a complete search strategy. It is suggested to terminate it manually");
TIO.Put_Line ("if it doesn't complete quickly.");
TIO.New_Line;
declare
Relation : Goal := Empty_Goal;
Value : constant Term := Relation.Fresh;
Ignore : constant Term := Relation.Fresh;
begin
Relation := Disjunct (Relation.Unify (Ignore, 6), Relation.Unify (Value, 7));
Relation := Fives (Relation, Ignore);
TIO.Put_Line ("Value is " & Printer.Image (Value.Resolve (Relation.Run)) & " on right.");
end;
declare
Relation : Goal := Empty_Goal;
Value : constant Term := Relation.Fresh;
Ignore : constant Term := Relation.Fresh;
begin
Relation := Disjunct (Relation.Unify (Value, 7), Relation.Unify (Ignore, 6));
Relation := Fives (Relation, Ignore);
TIO.Put_Line ("Value is " & Printer.Image (Value.Resolve (Relation.Run)) & " on left.");
end;
TIO.New_Line;
declare
Relation : Goal := Empty_Goal;
Value : constant Term := Relation.Fresh;
begin
Relation.Unify (Value, 9);
Relation := Fives (Relation, Value);
Relation.Disjunct (Empty_Goal.Conjunct (Simple'Access, Value));
TIO.Put_Line ("Value is " & Printer.Image (Value.Resolve (Relation.Run)) &
" after escaping Conjunct trap.");
end;
TIO.New_Line;
TIO.Put_Line ("Test complete.");
end Complete;
|