eyeprolog 1.5.99 → 1.5.101
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1,506 @@
|
|
|
1
|
+
answer(25, [p(1, 1), p(2, 3), p(1, 5), p(3, 4), p(5, 5), p(4, 3), p(5, 1), p(3, 2), p(4, 4), p(2, 5), p(1, 3), p(2, 1), p(4, 2), p(5, 4), p(3, 5), p(1, 4), p(2, 2), p(4, 1), p(5, 3), p(4, 5), p(2, 4), p(1, 2), p(3, 3), p(5, 2), p(3, 1)]).
|
|
2
|
+
why(
|
|
3
|
+
answer(25, [p(1, 1), p(2, 3), p(1, 5), p(3, 4), p(5, 5), p(4, 3), p(5, 1), p(3, 2), p(4, 4), p(2, 5), p(1, 3), p(2, 1), p(4, 2), p(5, 4), p(3, 5), p(1, 4), p(2, 2), p(4, 1), p(5, 3), p(4, 5), p(2, 4), p(1, 2), p(3, 3), p(5, 2), p(3, 1)]),
|
|
4
|
+
proof(
|
|
5
|
+
goal(answer(25, [p(1, 1), p(2, 3), p(1, 5), p(3, 4), p(5, 5), p(4, 3), p(5, 1), p(3, 2), p(4, 4), p(2, 5), p(1, 3), p(2, 1), p(4, 2), p(5, 4), p(3, 5), p(1, 4), p(2, 2), p(4, 1), p(5, 3), p(4, 5), p(2, 4), p(1, 2), p(3, 3), p(5, 2), p(3, 1)])),
|
|
6
|
+
by(rule("knights-tour-warnsdorff.pl", clause(7))),
|
|
7
|
+
bindings([binding("SquareCount", 25), binding("Tour", [p(1, 1), p(2, 3), p(1, 5), p(3, 4), p(5, 5), p(4, 3), p(5, 1), p(3, 2), p(4, 4), p(2, 5), p(1, 3), p(2, 1), p(4, 2), p(5, 4), p(3, 5), p(1, 4), p(2, 2), p(4, 1), p(5, 3), p(4, 5), p(2, 4), p(1, 2), p(3, 3), p(5, 2), p(3, 1)])]),
|
|
8
|
+
uses([
|
|
9
|
+
proof(
|
|
10
|
+
goal(knights_tour(p(1, 1), [p(1, 1), p(2, 3), p(1, 5), p(3, 4), p(5, 5), p(4, 3), p(5, 1), p(3, 2), p(4, 4), p(2, 5), p(1, 3), p(2, 1), p(4, 2), p(5, 4), p(3, 5), p(1, 4), p(2, 2), p(4, 1), p(5, 3), p(4, 5), p(2, 4), p(1, 2), p(3, 3), p(5, 2), p(3, 1)])),
|
|
11
|
+
by(rule("knights-tour-warnsdorff.pl", clause(6))),
|
|
12
|
+
bindings([binding("Start", p(1, 1)), binding("Tour", [p(1, 1), p(2, 3), p(1, 5), p(3, 4), p(5, 5), p(4, 3), p(5, 1), p(3, 2), p(4, 4), p(2, 5), p(1, 3), p(2, 1), p(4, 2), p(5, 4), p(3, 5), p(1, 4), p(2, 2), p(4, 1), p(5, 3), p(4, 5), p(2, 4), p(1, 2), p(3, 3), p(5, 2), p(3, 1)]), binding("N", 5), binding("SquareCount", 25), binding("ReverseTour", [p(3, 1), p(5, 2), p(3, 3), p(1, 2), p(2, 4), p(4, 5), p(5, 3), p(4, 1), p(2, 2), p(1, 4), p(3, 5), p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)])]),
|
|
13
|
+
uses([
|
|
14
|
+
proof(
|
|
15
|
+
goal(board_size(5)),
|
|
16
|
+
by(fact("knights-tour-warnsdorff.pl", clause(1)))
|
|
17
|
+
),
|
|
18
|
+
proof(
|
|
19
|
+
goal(is(25, *(5, 5))),
|
|
20
|
+
by(builtin(is, 2))
|
|
21
|
+
),
|
|
22
|
+
proof(
|
|
23
|
+
goal(tour_(p(1, 1), [p(1, 1)], 25, [p(3, 1), p(5, 2), p(3, 3), p(1, 2), p(2, 4), p(4, 5), p(5, 3), p(4, 1), p(2, 2), p(1, 4), p(3, 5), p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)])),
|
|
24
|
+
by(rule("knights-tour-warnsdorff.pl", clause(5))),
|
|
25
|
+
bindings([binding("Current", p(1, 1)), binding("Visited", [p(1, 1)]), binding("SquareCount", 25), binding("Tour", [p(3, 1), p(5, 2), p(3, 3), p(1, 2), p(2, 4), p(4, 5), p(5, 3), p(4, 1), p(2, 2), p(1, 4), p(3, 5), p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)]), binding("Candidates", ['-'(5, p(2, 3)), '-'(5, p(3, 2))]), binding("__anon1", 5), binding("Best", p(2, 3)), binding("__anon2", ['-'(5, p(3, 2))])]),
|
|
26
|
+
uses([
|
|
27
|
+
proof(
|
|
28
|
+
goal(findall('-'(Degree, Next), (knight_move(p(1, 1), Next), '\\+'(member(Next, [p(1, 1)])), degree(Next, [p(1, 1)], Degree)), ['-'(5, p(2, 3)), '-'(5, p(3, 2))])),
|
|
29
|
+
by(builtin(findall, 3))
|
|
30
|
+
),
|
|
31
|
+
proof(
|
|
32
|
+
goal(\=(['-'(5, p(2, 3)), '-'(5, p(3, 2))], [])),
|
|
33
|
+
by(builtin(\=, 2))
|
|
34
|
+
),
|
|
35
|
+
proof(
|
|
36
|
+
goal(keysort(['-'(5, p(2, 3)), '-'(5, p(3, 2))], ['-'(5, p(2, 3)), '-'(5, p(3, 2))])),
|
|
37
|
+
by(builtin(keysort, 2))
|
|
38
|
+
),
|
|
39
|
+
proof(
|
|
40
|
+
goal(tour_(p(2, 3), [p(2, 3), p(1, 1)], 25, [p(3, 1), p(5, 2), p(3, 3), p(1, 2), p(2, 4), p(4, 5), p(5, 3), p(4, 1), p(2, 2), p(1, 4), p(3, 5), p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)])),
|
|
41
|
+
by(rule("knights-tour-warnsdorff.pl", clause(5))),
|
|
42
|
+
bindings([binding("Current", p(2, 3)), binding("Visited", [p(2, 3), p(1, 1)]), binding("SquareCount", 25), binding("Tour", [p(3, 1), p(5, 2), p(3, 3), p(1, 2), p(2, 4), p(4, 5), p(5, 3), p(4, 1), p(2, 2), p(1, 4), p(3, 5), p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)]), binding("Candidates", ['-'(3, p(3, 5)), '-'(3, p(4, 4)), '-'(1, p(1, 5)), '-'(3, p(3, 1)), '-'(3, p(4, 2))]), binding("__anon1", 1), binding("Best", p(1, 5)), binding("__anon2", ['-'(3, p(3, 5)), '-'(3, p(4, 4)), '-'(3, p(3, 1)), '-'(3, p(4, 2))])]),
|
|
43
|
+
uses([
|
|
44
|
+
proof(
|
|
45
|
+
goal(findall('-'(Degree, Next), (knight_move(p(2, 3), Next), '\\+'(member(Next, [p(2, 3), p(1, 1)])), degree(Next, [p(2, 3), p(1, 1)], Degree)), ['-'(3, p(3, 5)), '-'(3, p(4, 4)), '-'(1, p(1, 5)), '-'(3, p(3, 1)), '-'(3, p(4, 2))])),
|
|
46
|
+
by(builtin(findall, 3))
|
|
47
|
+
),
|
|
48
|
+
proof(
|
|
49
|
+
goal(\=(['-'(3, p(3, 5)), '-'(3, p(4, 4)), '-'(1, p(1, 5)), '-'(3, p(3, 1)), '-'(3, p(4, 2))], [])),
|
|
50
|
+
by(builtin(\=, 2))
|
|
51
|
+
),
|
|
52
|
+
proof(
|
|
53
|
+
goal(keysort(['-'(3, p(3, 5)), '-'(3, p(4, 4)), '-'(1, p(1, 5)), '-'(3, p(3, 1)), '-'(3, p(4, 2))], ['-'(1, p(1, 5)), '-'(3, p(3, 5)), '-'(3, p(4, 4)), '-'(3, p(3, 1)), '-'(3, p(4, 2))])),
|
|
54
|
+
by(builtin(keysort, 2))
|
|
55
|
+
),
|
|
56
|
+
proof(
|
|
57
|
+
goal(tour_(p(1, 5), [p(1, 5), p(2, 3), p(1, 1)], 25, [p(3, 1), p(5, 2), p(3, 3), p(1, 2), p(2, 4), p(4, 5), p(5, 3), p(4, 1), p(2, 2), p(1, 4), p(3, 5), p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)])),
|
|
58
|
+
by(rule("knights-tour-warnsdorff.pl", clause(5))),
|
|
59
|
+
bindings([binding("Current", p(1, 5)), binding("Visited", [p(1, 5), p(2, 3), p(1, 1)]), binding("SquareCount", 25), binding("Tour", [p(3, 1), p(5, 2), p(3, 3), p(1, 2), p(2, 4), p(4, 5), p(5, 3), p(4, 1), p(2, 2), p(1, 4), p(3, 5), p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)]), binding("Candidates", ['-'(5, p(3, 4))]), binding("__anon1", 5), binding("Best", p(3, 4)), binding("__anon2", [])]),
|
|
60
|
+
uses([
|
|
61
|
+
proof(
|
|
62
|
+
goal(findall('-'(Degree, Next), (knight_move(p(1, 5), Next), '\\+'(member(Next, [p(1, 5), p(2, 3), p(1, 1)])), degree(Next, [p(1, 5), p(2, 3), p(1, 1)], Degree)), ['-'(5, p(3, 4))])),
|
|
63
|
+
by(builtin(findall, 3))
|
|
64
|
+
),
|
|
65
|
+
proof(
|
|
66
|
+
goal(\=(['-'(5, p(3, 4))], [])),
|
|
67
|
+
by(builtin(\=, 2))
|
|
68
|
+
),
|
|
69
|
+
proof(
|
|
70
|
+
goal(keysort(['-'(5, p(3, 4))], ['-'(5, p(3, 4))])),
|
|
71
|
+
by(builtin(keysort, 2))
|
|
72
|
+
),
|
|
73
|
+
proof(
|
|
74
|
+
goal(tour_(p(3, 4), [p(3, 4), p(1, 5), p(2, 3), p(1, 1)], 25, [p(3, 1), p(5, 2), p(3, 3), p(1, 2), p(2, 4), p(4, 5), p(5, 3), p(4, 1), p(2, 2), p(1, 4), p(3, 5), p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)])),
|
|
75
|
+
by(rule("knights-tour-warnsdorff.pl", clause(5))),
|
|
76
|
+
bindings([binding("Current", p(3, 4)), binding("Visited", [p(3, 4), p(1, 5), p(2, 3), p(1, 1)]), binding("SquareCount", 25), binding("Tour", [p(3, 1), p(5, 2), p(3, 3), p(1, 2), p(2, 4), p(4, 5), p(5, 3), p(4, 1), p(2, 2), p(1, 4), p(3, 5), p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)]), binding("Candidates", ['-'(1, p(5, 5)), '-'(2, p(4, 2)), '-'(3, p(5, 3)), '-'(3, p(2, 2)), '-'(3, p(1, 3))]), binding("__anon1", 1), binding("Best", p(5, 5)), binding("__anon2", ['-'(2, p(4, 2)), '-'(3, p(5, 3)), '-'(3, p(2, 2)), '-'(3, p(1, 3))])]),
|
|
77
|
+
uses([
|
|
78
|
+
proof(
|
|
79
|
+
goal(findall('-'(Degree, Next), (knight_move(p(3, 4), Next), '\\+'(member(Next, [p(3, 4), p(1, 5), p(2, 3), p(1, 1)])), degree(Next, [p(3, 4), p(1, 5), p(2, 3), p(1, 1)], Degree)), ['-'(1, p(5, 5)), '-'(2, p(4, 2)), '-'(3, p(5, 3)), '-'(3, p(2, 2)), '-'(3, p(1, 3))])),
|
|
80
|
+
by(builtin(findall, 3))
|
|
81
|
+
),
|
|
82
|
+
proof(
|
|
83
|
+
goal(\=(['-'(1, p(5, 5)), '-'(2, p(4, 2)), '-'(3, p(5, 3)), '-'(3, p(2, 2)), '-'(3, p(1, 3))], [])),
|
|
84
|
+
by(builtin(\=, 2))
|
|
85
|
+
),
|
|
86
|
+
proof(
|
|
87
|
+
goal(keysort(['-'(1, p(5, 5)), '-'(2, p(4, 2)), '-'(3, p(5, 3)), '-'(3, p(2, 2)), '-'(3, p(1, 3))], ['-'(1, p(5, 5)), '-'(2, p(4, 2)), '-'(3, p(5, 3)), '-'(3, p(2, 2)), '-'(3, p(1, 3))])),
|
|
88
|
+
by(builtin(keysort, 2))
|
|
89
|
+
),
|
|
90
|
+
proof(
|
|
91
|
+
goal(tour_(p(5, 5), [p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)], 25, [p(3, 1), p(5, 2), p(3, 3), p(1, 2), p(2, 4), p(4, 5), p(5, 3), p(4, 1), p(2, 2), p(1, 4), p(3, 5), p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)])),
|
|
92
|
+
by(rule("knights-tour-warnsdorff.pl", clause(5))),
|
|
93
|
+
bindings([binding("Current", p(5, 5)), binding("Visited", [p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)]), binding("SquareCount", 25), binding("Tour", [p(3, 1), p(5, 2), p(3, 3), p(1, 2), p(2, 4), p(4, 5), p(5, 3), p(4, 1), p(2, 2), p(1, 4), p(3, 5), p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)]), binding("Candidates", ['-'(5, p(4, 3))]), binding("__anon1", 5), binding("Best", p(4, 3)), binding("__anon2", [])]),
|
|
94
|
+
uses([
|
|
95
|
+
proof(
|
|
96
|
+
goal(findall('-'(Degree, Next), (knight_move(p(5, 5), Next), '\\+'(member(Next, [p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)])), degree(Next, [p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)], Degree)), ['-'(5, p(4, 3))])),
|
|
97
|
+
by(builtin(findall, 3))
|
|
98
|
+
),
|
|
99
|
+
proof(
|
|
100
|
+
goal(\=(['-'(5, p(4, 3))], [])),
|
|
101
|
+
by(builtin(\=, 2))
|
|
102
|
+
),
|
|
103
|
+
proof(
|
|
104
|
+
goal(keysort(['-'(5, p(4, 3))], ['-'(5, p(4, 3))])),
|
|
105
|
+
by(builtin(keysort, 2))
|
|
106
|
+
),
|
|
107
|
+
proof(
|
|
108
|
+
goal(tour_(p(4, 3), [p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)], 25, [p(3, 1), p(5, 2), p(3, 3), p(1, 2), p(2, 4), p(4, 5), p(5, 3), p(4, 1), p(2, 2), p(1, 4), p(3, 5), p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)])),
|
|
109
|
+
by(rule("knights-tour-warnsdorff.pl", clause(5))),
|
|
110
|
+
bindings([binding("Current", p(4, 3)), binding("Visited", [p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)]), binding("SquareCount", 25), binding("Tour", [p(3, 1), p(5, 2), p(3, 3), p(1, 2), p(2, 4), p(4, 5), p(5, 3), p(4, 1), p(2, 2), p(1, 4), p(3, 5), p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)]), binding("Candidates", ['-'(2, p(3, 5)), '-'(3, p(2, 4)), '-'(1, p(5, 1)), '-'(2, p(3, 1)), '-'(2, p(2, 2))]), binding("__anon1", 1), binding("Best", p(5, 1)), binding("__anon2", ['-'(2, p(3, 5)), '-'(2, p(3, 1)), '-'(2, p(2, 2)), '-'(3, p(2, 4))])]),
|
|
111
|
+
uses([
|
|
112
|
+
proof(
|
|
113
|
+
goal(findall('-'(Degree, Next), (knight_move(p(4, 3), Next), '\\+'(member(Next, [p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)])), degree(Next, [p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)], Degree)), ['-'(2, p(3, 5)), '-'(3, p(2, 4)), '-'(1, p(5, 1)), '-'(2, p(3, 1)), '-'(2, p(2, 2))])),
|
|
114
|
+
by(builtin(findall, 3))
|
|
115
|
+
),
|
|
116
|
+
proof(
|
|
117
|
+
goal(\=(['-'(2, p(3, 5)), '-'(3, p(2, 4)), '-'(1, p(5, 1)), '-'(2, p(3, 1)), '-'(2, p(2, 2))], [])),
|
|
118
|
+
by(builtin(\=, 2))
|
|
119
|
+
),
|
|
120
|
+
proof(
|
|
121
|
+
goal(keysort(['-'(2, p(3, 5)), '-'(3, p(2, 4)), '-'(1, p(5, 1)), '-'(2, p(3, 1)), '-'(2, p(2, 2))], ['-'(1, p(5, 1)), '-'(2, p(3, 5)), '-'(2, p(3, 1)), '-'(2, p(2, 2)), '-'(3, p(2, 4))])),
|
|
122
|
+
by(builtin(keysort, 2))
|
|
123
|
+
),
|
|
124
|
+
proof(
|
|
125
|
+
goal(tour_(p(5, 1), [p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)], 25, [p(3, 1), p(5, 2), p(3, 3), p(1, 2), p(2, 4), p(4, 5), p(5, 3), p(4, 1), p(2, 2), p(1, 4), p(3, 5), p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)])),
|
|
126
|
+
by(rule("knights-tour-warnsdorff.pl", clause(5))),
|
|
127
|
+
bindings([binding("Current", p(5, 1)), binding("Visited", [p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)]), binding("SquareCount", 25), binding("Tour", [p(3, 1), p(5, 2), p(3, 3), p(1, 2), p(2, 4), p(4, 5), p(5, 3), p(4, 1), p(2, 2), p(1, 4), p(3, 5), p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)]), binding("Candidates", ['-'(4, p(3, 2))]), binding("__anon1", 4), binding("Best", p(3, 2)), binding("__anon2", [])]),
|
|
128
|
+
uses([
|
|
129
|
+
proof(
|
|
130
|
+
goal(findall('-'(Degree, Next), (knight_move(p(5, 1), Next), '\\+'(member(Next, [p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)])), degree(Next, [p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)], Degree)), ['-'(4, p(3, 2))])),
|
|
131
|
+
by(builtin(findall, 3))
|
|
132
|
+
),
|
|
133
|
+
proof(
|
|
134
|
+
goal(\=(['-'(4, p(3, 2))], [])),
|
|
135
|
+
by(builtin(\=, 2))
|
|
136
|
+
),
|
|
137
|
+
proof(
|
|
138
|
+
goal(keysort(['-'(4, p(3, 2))], ['-'(4, p(3, 2))])),
|
|
139
|
+
by(builtin(keysort, 2))
|
|
140
|
+
),
|
|
141
|
+
proof(
|
|
142
|
+
goal(tour_(p(3, 2), [p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)], 25, [p(3, 1), p(5, 2), p(3, 3), p(1, 2), p(2, 4), p(4, 5), p(5, 3), p(4, 1), p(2, 2), p(1, 4), p(3, 5), p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)])),
|
|
143
|
+
by(rule("knights-tour-warnsdorff.pl", clause(5))),
|
|
144
|
+
bindings([binding("Current", p(3, 2)), binding("Visited", [p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)]), binding("SquareCount", 25), binding("Tour", [p(3, 1), p(5, 2), p(3, 3), p(1, 2), p(2, 4), p(4, 5), p(5, 3), p(4, 1), p(2, 2), p(1, 4), p(3, 5), p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)]), binding("Candidates", ['-'(2, p(4, 4)), '-'(2, p(5, 3)), '-'(2, p(2, 4)), '-'(2, p(1, 3))]), binding("__anon1", 2), binding("Best", p(4, 4)), binding("__anon2", ['-'(2, p(5, 3)), '-'(2, p(2, 4)), '-'(2, p(1, 3))])]),
|
|
145
|
+
uses([
|
|
146
|
+
proof(
|
|
147
|
+
goal(findall('-'(Degree, Next), (knight_move(p(3, 2), Next), '\\+'(member(Next, [p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)])), degree(Next, [p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)], Degree)), ['-'(2, p(4, 4)), '-'(2, p(5, 3)), '-'(2, p(2, 4)), '-'(2, p(1, 3))])),
|
|
148
|
+
by(builtin(findall, 3))
|
|
149
|
+
),
|
|
150
|
+
proof(
|
|
151
|
+
goal(\=(['-'(2, p(4, 4)), '-'(2, p(5, 3)), '-'(2, p(2, 4)), '-'(2, p(1, 3))], [])),
|
|
152
|
+
by(builtin(\=, 2))
|
|
153
|
+
),
|
|
154
|
+
proof(
|
|
155
|
+
goal(keysort(['-'(2, p(4, 4)), '-'(2, p(5, 3)), '-'(2, p(2, 4)), '-'(2, p(1, 3))], ['-'(2, p(4, 4)), '-'(2, p(5, 3)), '-'(2, p(2, 4)), '-'(2, p(1, 3))])),
|
|
156
|
+
by(builtin(keysort, 2))
|
|
157
|
+
),
|
|
158
|
+
proof(
|
|
159
|
+
goal(tour_(p(4, 4), [p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)], 25, [p(3, 1), p(5, 2), p(3, 3), p(1, 2), p(2, 4), p(4, 5), p(5, 3), p(4, 1), p(2, 2), p(1, 4), p(3, 5), p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)])),
|
|
160
|
+
by(rule("knights-tour-warnsdorff.pl", clause(5))),
|
|
161
|
+
bindings([binding("Current", p(4, 4)), binding("Visited", [p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)]), binding("SquareCount", 25), binding("Tour", [p(3, 1), p(5, 2), p(3, 3), p(1, 2), p(2, 4), p(4, 5), p(5, 3), p(4, 1), p(2, 2), p(1, 4), p(3, 5), p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)]), binding("Candidates", ['-'(2, p(2, 5)), '-'(2, p(5, 2))]), binding("__anon1", 2), binding("Best", p(2, 5)), binding("__anon2", ['-'(2, p(5, 2))])]),
|
|
162
|
+
uses([
|
|
163
|
+
proof(
|
|
164
|
+
goal(findall('-'(Degree, Next), (knight_move(p(4, 4), Next), '\\+'(member(Next, [p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)])), degree(Next, [p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)], Degree)), ['-'(2, p(2, 5)), '-'(2, p(5, 2))])),
|
|
165
|
+
by(builtin(findall, 3))
|
|
166
|
+
),
|
|
167
|
+
proof(
|
|
168
|
+
goal(\=(['-'(2, p(2, 5)), '-'(2, p(5, 2))], [])),
|
|
169
|
+
by(builtin(\=, 2))
|
|
170
|
+
),
|
|
171
|
+
proof(
|
|
172
|
+
goal(keysort(['-'(2, p(2, 5)), '-'(2, p(5, 2))], ['-'(2, p(2, 5)), '-'(2, p(5, 2))])),
|
|
173
|
+
by(builtin(keysort, 2))
|
|
174
|
+
),
|
|
175
|
+
proof(
|
|
176
|
+
goal(tour_(p(2, 5), [p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)], 25, [p(3, 1), p(5, 2), p(3, 3), p(1, 2), p(2, 4), p(4, 5), p(5, 3), p(4, 1), p(2, 2), p(1, 4), p(3, 5), p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)])),
|
|
177
|
+
by(rule("knights-tour-warnsdorff.pl", clause(5))),
|
|
178
|
+
bindings([binding("Current", p(2, 5)), binding("Visited", [p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)]), binding("SquareCount", 25), binding("Tour", [p(3, 1), p(5, 2), p(3, 3), p(1, 2), p(2, 4), p(4, 5), p(5, 3), p(4, 1), p(2, 2), p(1, 4), p(3, 5), p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)]), binding("Candidates", ['-'(7, p(3, 3)), '-'(1, p(1, 3))]), binding("__anon1", 1), binding("Best", p(1, 3)), binding("__anon2", ['-'(7, p(3, 3))])]),
|
|
179
|
+
uses([
|
|
180
|
+
proof(
|
|
181
|
+
goal(findall('-'(Degree, Next), (knight_move(p(2, 5), Next), '\\+'(member(Next, [p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)])), degree(Next, [p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)], Degree)), ['-'(7, p(3, 3)), '-'(1, p(1, 3))])),
|
|
182
|
+
by(builtin(findall, 3))
|
|
183
|
+
),
|
|
184
|
+
proof(
|
|
185
|
+
goal(\=(['-'(7, p(3, 3)), '-'(1, p(1, 3))], [])),
|
|
186
|
+
by(builtin(\=, 2))
|
|
187
|
+
),
|
|
188
|
+
proof(
|
|
189
|
+
goal(keysort(['-'(7, p(3, 3)), '-'(1, p(1, 3))], ['-'(1, p(1, 3)), '-'(7, p(3, 3))])),
|
|
190
|
+
by(builtin(keysort, 2))
|
|
191
|
+
),
|
|
192
|
+
proof(
|
|
193
|
+
goal(tour_(p(1, 3), [p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)], 25, [p(3, 1), p(5, 2), p(3, 3), p(1, 2), p(2, 4), p(4, 5), p(5, 3), p(4, 1), p(2, 2), p(1, 4), p(3, 5), p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)])),
|
|
194
|
+
by(rule("knights-tour-warnsdorff.pl", clause(5))),
|
|
195
|
+
bindings([binding("Current", p(1, 3)), binding("Visited", [p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)]), binding("SquareCount", 25), binding("Tour", [p(3, 1), p(5, 2), p(3, 3), p(1, 2), p(2, 4), p(4, 5), p(5, 3), p(4, 1), p(2, 2), p(1, 4), p(3, 5), p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)]), binding("Candidates", ['-'(2, p(2, 1))]), binding("__anon1", 2), binding("Best", p(2, 1)), binding("__anon2", [])]),
|
|
196
|
+
uses([
|
|
197
|
+
proof(
|
|
198
|
+
goal(findall('-'(Degree, Next), (knight_move(p(1, 3), Next), '\\+'(member(Next, [p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)])), degree(Next, [p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)], Degree)), ['-'(2, p(2, 1))])),
|
|
199
|
+
by(builtin(findall, 3))
|
|
200
|
+
),
|
|
201
|
+
proof(
|
|
202
|
+
goal(\=(['-'(2, p(2, 1))], [])),
|
|
203
|
+
by(builtin(\=, 2))
|
|
204
|
+
),
|
|
205
|
+
proof(
|
|
206
|
+
goal(keysort(['-'(2, p(2, 1))], ['-'(2, p(2, 1))])),
|
|
207
|
+
by(builtin(keysort, 2))
|
|
208
|
+
),
|
|
209
|
+
proof(
|
|
210
|
+
goal(tour_(p(2, 1), [p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)], 25, [p(3, 1), p(5, 2), p(3, 3), p(1, 2), p(2, 4), p(4, 5), p(5, 3), p(4, 1), p(2, 2), p(1, 4), p(3, 5), p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)])),
|
|
211
|
+
by(rule("knights-tour-warnsdorff.pl", clause(5))),
|
|
212
|
+
bindings([binding("Current", p(2, 1)), binding("Visited", [p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)]), binding("SquareCount", 25), binding("Tour", [p(3, 1), p(5, 2), p(3, 3), p(1, 2), p(2, 4), p(4, 5), p(5, 3), p(4, 1), p(2, 2), p(1, 4), p(3, 5), p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)]), binding("Candidates", ['-'(6, p(3, 3)), '-'(1, p(4, 2))]), binding("__anon1", 1), binding("Best", p(4, 2)), binding("__anon2", ['-'(6, p(3, 3))])]),
|
|
213
|
+
uses([
|
|
214
|
+
proof(
|
|
215
|
+
goal(findall('-'(Degree, Next), (knight_move(p(2, 1), Next), '\\+'(member(Next, [p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)])), degree(Next, [p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)], Degree)), ['-'(6, p(3, 3)), '-'(1, p(4, 2))])),
|
|
216
|
+
by(builtin(findall, 3))
|
|
217
|
+
),
|
|
218
|
+
proof(
|
|
219
|
+
goal(\=(['-'(6, p(3, 3)), '-'(1, p(4, 2))], [])),
|
|
220
|
+
by(builtin(\=, 2))
|
|
221
|
+
),
|
|
222
|
+
proof(
|
|
223
|
+
goal(keysort(['-'(6, p(3, 3)), '-'(1, p(4, 2))], ['-'(1, p(4, 2)), '-'(6, p(3, 3))])),
|
|
224
|
+
by(builtin(keysort, 2))
|
|
225
|
+
),
|
|
226
|
+
proof(
|
|
227
|
+
goal(tour_(p(4, 2), [p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)], 25, [p(3, 1), p(5, 2), p(3, 3), p(1, 2), p(2, 4), p(4, 5), p(5, 3), p(4, 1), p(2, 2), p(1, 4), p(3, 5), p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)])),
|
|
228
|
+
by(rule("knights-tour-warnsdorff.pl", clause(5))),
|
|
229
|
+
bindings([binding("Current", p(4, 2)), binding("Visited", [p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)]), binding("SquareCount", 25), binding("Tour", [p(3, 1), p(5, 2), p(3, 3), p(1, 2), p(2, 4), p(4, 5), p(5, 3), p(4, 1), p(2, 2), p(1, 4), p(3, 5), p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)]), binding("Candidates", ['-'(2, p(5, 4))]), binding("__anon1", 2), binding("Best", p(5, 4)), binding("__anon2", [])]),
|
|
230
|
+
uses([
|
|
231
|
+
proof(
|
|
232
|
+
goal(findall('-'(Degree, Next), (knight_move(p(4, 2), Next), '\\+'(member(Next, [p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)])), degree(Next, [p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)], Degree)), ['-'(2, p(5, 4))])),
|
|
233
|
+
by(builtin(findall, 3))
|
|
234
|
+
),
|
|
235
|
+
proof(
|
|
236
|
+
goal(\=(['-'(2, p(5, 4))], [])),
|
|
237
|
+
by(builtin(\=, 2))
|
|
238
|
+
),
|
|
239
|
+
proof(
|
|
240
|
+
goal(keysort(['-'(2, p(5, 4))], ['-'(2, p(5, 4))])),
|
|
241
|
+
by(builtin(keysort, 2))
|
|
242
|
+
),
|
|
243
|
+
proof(
|
|
244
|
+
goal(tour_(p(5, 4), [p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)], 25, [p(3, 1), p(5, 2), p(3, 3), p(1, 2), p(2, 4), p(4, 5), p(5, 3), p(4, 1), p(2, 2), p(1, 4), p(3, 5), p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)])),
|
|
245
|
+
by(rule("knights-tour-warnsdorff.pl", clause(5))),
|
|
246
|
+
bindings([binding("Current", p(5, 4)), binding("Visited", [p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)]), binding("SquareCount", 25), binding("Tour", [p(3, 1), p(5, 2), p(3, 3), p(1, 2), p(2, 4), p(4, 5), p(5, 3), p(4, 1), p(2, 2), p(1, 4), p(3, 5), p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)]), binding("Candidates", ['-'(1, p(3, 5)), '-'(5, p(3, 3))]), binding("__anon1", 1), binding("Best", p(3, 5)), binding("__anon2", ['-'(5, p(3, 3))])]),
|
|
247
|
+
uses([
|
|
248
|
+
proof(
|
|
249
|
+
goal(findall('-'(Degree, Next), (knight_move(p(5, 4), Next), '\\+'(member(Next, [p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)])), degree(Next, [p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)], Degree)), ['-'(1, p(3, 5)), '-'(5, p(3, 3))])),
|
|
250
|
+
by(builtin(findall, 3))
|
|
251
|
+
),
|
|
252
|
+
proof(
|
|
253
|
+
goal(\=(['-'(1, p(3, 5)), '-'(5, p(3, 3))], [])),
|
|
254
|
+
by(builtin(\=, 2))
|
|
255
|
+
),
|
|
256
|
+
proof(
|
|
257
|
+
goal(keysort(['-'(1, p(3, 5)), '-'(5, p(3, 3))], ['-'(1, p(3, 5)), '-'(5, p(3, 3))])),
|
|
258
|
+
by(builtin(keysort, 2))
|
|
259
|
+
),
|
|
260
|
+
proof(
|
|
261
|
+
goal(tour_(p(3, 5), [p(3, 5), p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)], 25, [p(3, 1), p(5, 2), p(3, 3), p(1, 2), p(2, 4), p(4, 5), p(5, 3), p(4, 1), p(2, 2), p(1, 4), p(3, 5), p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)])),
|
|
262
|
+
by(rule("knights-tour-warnsdorff.pl", clause(5))),
|
|
263
|
+
bindings([binding("Current", p(3, 5)), binding("Visited", [p(3, 5), p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)]), binding("SquareCount", 25), binding("Tour", [p(3, 1), p(5, 2), p(3, 3), p(1, 2), p(2, 4), p(4, 5), p(5, 3), p(4, 1), p(2, 2), p(1, 4), p(3, 5), p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)]), binding("Candidates", ['-'(2, p(1, 4))]), binding("__anon1", 2), binding("Best", p(1, 4)), binding("__anon2", [])]),
|
|
264
|
+
uses([
|
|
265
|
+
proof(
|
|
266
|
+
goal(findall('-'(Degree, Next), (knight_move(p(3, 5), Next), '\\+'(member(Next, [p(3, 5), p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)])), degree(Next, [p(3, 5), p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)], Degree)), ['-'(2, p(1, 4))])),
|
|
267
|
+
by(builtin(findall, 3))
|
|
268
|
+
),
|
|
269
|
+
proof(
|
|
270
|
+
goal(\=(['-'(2, p(1, 4))], [])),
|
|
271
|
+
by(builtin(\=, 2))
|
|
272
|
+
),
|
|
273
|
+
proof(
|
|
274
|
+
goal(keysort(['-'(2, p(1, 4))], ['-'(2, p(1, 4))])),
|
|
275
|
+
by(builtin(keysort, 2))
|
|
276
|
+
),
|
|
277
|
+
proof(
|
|
278
|
+
goal(tour_(p(1, 4), [p(1, 4), p(3, 5), p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)], 25, [p(3, 1), p(5, 2), p(3, 3), p(1, 2), p(2, 4), p(4, 5), p(5, 3), p(4, 1), p(2, 2), p(1, 4), p(3, 5), p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)])),
|
|
279
|
+
by(rule("knights-tour-warnsdorff.pl", clause(5))),
|
|
280
|
+
bindings([binding("Current", p(1, 4)), binding("Visited", [p(1, 4), p(3, 5), p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)]), binding("SquareCount", 25), binding("Tour", [p(3, 1), p(5, 2), p(3, 3), p(1, 2), p(2, 4), p(4, 5), p(5, 3), p(4, 1), p(2, 2), p(1, 4), p(3, 5), p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)]), binding("Candidates", ['-'(1, p(2, 2)), '-'(4, p(3, 3))]), binding("__anon1", 1), binding("Best", p(2, 2)), binding("__anon2", ['-'(4, p(3, 3))])]),
|
|
281
|
+
uses([
|
|
282
|
+
proof(
|
|
283
|
+
goal(findall('-'(Degree, Next), (knight_move(p(1, 4), Next), '\\+'(member(Next, [p(1, 4), p(3, 5), p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)])), degree(Next, [p(1, 4), p(3, 5), p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)], Degree)), ['-'(1, p(2, 2)), '-'(4, p(3, 3))])),
|
|
284
|
+
by(builtin(findall, 3))
|
|
285
|
+
),
|
|
286
|
+
proof(
|
|
287
|
+
goal(\=(['-'(1, p(2, 2)), '-'(4, p(3, 3))], [])),
|
|
288
|
+
by(builtin(\=, 2))
|
|
289
|
+
),
|
|
290
|
+
proof(
|
|
291
|
+
goal(keysort(['-'(1, p(2, 2)), '-'(4, p(3, 3))], ['-'(1, p(2, 2)), '-'(4, p(3, 3))])),
|
|
292
|
+
by(builtin(keysort, 2))
|
|
293
|
+
),
|
|
294
|
+
proof(
|
|
295
|
+
goal(tour_(p(2, 2), [p(2, 2), p(1, 4), p(3, 5), p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)], 25, [p(3, 1), p(5, 2), p(3, 3), p(1, 2), p(2, 4), p(4, 5), p(5, 3), p(4, 1), p(2, 2), p(1, 4), p(3, 5), p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)])),
|
|
296
|
+
by(rule("knights-tour-warnsdorff.pl", clause(5))),
|
|
297
|
+
bindings([binding("Current", p(2, 2)), binding("Visited", [p(2, 2), p(1, 4), p(3, 5), p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)]), binding("SquareCount", 25), binding("Tour", [p(3, 1), p(5, 2), p(3, 3), p(1, 2), p(2, 4), p(4, 5), p(5, 3), p(4, 1), p(2, 2), p(1, 4), p(3, 5), p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)]), binding("Candidates", ['-'(2, p(4, 1))]), binding("__anon1", 2), binding("Best", p(4, 1)), binding("__anon2", [])]),
|
|
298
|
+
uses([
|
|
299
|
+
proof(
|
|
300
|
+
goal(findall('-'(Degree, Next), (knight_move(p(2, 2), Next), '\\+'(member(Next, [p(2, 2), p(1, 4), p(3, 5), p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)])), degree(Next, [p(2, 2), p(1, 4), p(3, 5), p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)], Degree)), ['-'(2, p(4, 1))])),
|
|
301
|
+
by(builtin(findall, 3))
|
|
302
|
+
),
|
|
303
|
+
proof(
|
|
304
|
+
goal(\=(['-'(2, p(4, 1))], [])),
|
|
305
|
+
by(builtin(\=, 2))
|
|
306
|
+
),
|
|
307
|
+
proof(
|
|
308
|
+
goal(keysort(['-'(2, p(4, 1))], ['-'(2, p(4, 1))])),
|
|
309
|
+
by(builtin(keysort, 2))
|
|
310
|
+
),
|
|
311
|
+
proof(
|
|
312
|
+
goal(tour_(p(4, 1), [p(4, 1), p(2, 2), p(1, 4), p(3, 5), p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)], 25, [p(3, 1), p(5, 2), p(3, 3), p(1, 2), p(2, 4), p(4, 5), p(5, 3), p(4, 1), p(2, 2), p(1, 4), p(3, 5), p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)])),
|
|
313
|
+
by(rule("knights-tour-warnsdorff.pl", clause(5))),
|
|
314
|
+
bindings([binding("Current", p(4, 1)), binding("Visited", [p(4, 1), p(2, 2), p(1, 4), p(3, 5), p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)]), binding("SquareCount", 25), binding("Tour", [p(3, 1), p(5, 2), p(3, 3), p(1, 2), p(2, 4), p(4, 5), p(5, 3), p(4, 1), p(2, 2), p(1, 4), p(3, 5), p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)]), binding("Candidates", ['-'(1, p(5, 3)), '-'(3, p(3, 3))]), binding("__anon1", 1), binding("Best", p(5, 3)), binding("__anon2", ['-'(3, p(3, 3))])]),
|
|
315
|
+
uses([
|
|
316
|
+
proof(
|
|
317
|
+
goal(findall('-'(Degree, Next), (knight_move(p(4, 1), Next), '\\+'(member(Next, [p(4, 1), p(2, 2), p(1, 4), p(3, 5), p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)])), degree(Next, [p(4, 1), p(2, 2), p(1, 4), p(3, 5), p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)], Degree)), ['-'(1, p(5, 3)), '-'(3, p(3, 3))])),
|
|
318
|
+
by(builtin(findall, 3))
|
|
319
|
+
),
|
|
320
|
+
proof(
|
|
321
|
+
goal(\=(['-'(1, p(5, 3)), '-'(3, p(3, 3))], [])),
|
|
322
|
+
by(builtin(\=, 2))
|
|
323
|
+
),
|
|
324
|
+
proof(
|
|
325
|
+
goal(keysort(['-'(1, p(5, 3)), '-'(3, p(3, 3))], ['-'(1, p(5, 3)), '-'(3, p(3, 3))])),
|
|
326
|
+
by(builtin(keysort, 2))
|
|
327
|
+
),
|
|
328
|
+
proof(
|
|
329
|
+
goal(tour_(p(5, 3), [p(5, 3), p(4, 1), p(2, 2), p(1, 4), p(3, 5), p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)], 25, [p(3, 1), p(5, 2), p(3, 3), p(1, 2), p(2, 4), p(4, 5), p(5, 3), p(4, 1), p(2, 2), p(1, 4), p(3, 5), p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)])),
|
|
330
|
+
by(rule("knights-tour-warnsdorff.pl", clause(5))),
|
|
331
|
+
bindings([binding("Current", p(5, 3)), binding("Visited", [p(5, 3), p(4, 1), p(2, 2), p(1, 4), p(3, 5), p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)]), binding("SquareCount", 25), binding("Tour", [p(3, 1), p(5, 2), p(3, 3), p(1, 2), p(2, 4), p(4, 5), p(5, 3), p(4, 1), p(2, 2), p(1, 4), p(3, 5), p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)]), binding("Candidates", ['-'(2, p(4, 5))]), binding("__anon1", 2), binding("Best", p(4, 5)), binding("__anon2", [])]),
|
|
332
|
+
uses([
|
|
333
|
+
proof(
|
|
334
|
+
goal(findall('-'(Degree, Next), (knight_move(p(5, 3), Next), '\\+'(member(Next, [p(5, 3), p(4, 1), p(2, 2), p(1, 4), p(3, 5), p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)])), degree(Next, [p(5, 3), p(4, 1), p(2, 2), p(1, 4), p(3, 5), p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)], Degree)), ['-'(2, p(4, 5))])),
|
|
335
|
+
by(builtin(findall, 3))
|
|
336
|
+
),
|
|
337
|
+
proof(
|
|
338
|
+
goal(\=(['-'(2, p(4, 5))], [])),
|
|
339
|
+
by(builtin(\=, 2))
|
|
340
|
+
),
|
|
341
|
+
proof(
|
|
342
|
+
goal(keysort(['-'(2, p(4, 5))], ['-'(2, p(4, 5))])),
|
|
343
|
+
by(builtin(keysort, 2))
|
|
344
|
+
),
|
|
345
|
+
proof(
|
|
346
|
+
goal(tour_(p(4, 5), [p(4, 5), p(5, 3), p(4, 1), p(2, 2), p(1, 4), p(3, 5), p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)], 25, [p(3, 1), p(5, 2), p(3, 3), p(1, 2), p(2, 4), p(4, 5), p(5, 3), p(4, 1), p(2, 2), p(1, 4), p(3, 5), p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)])),
|
|
347
|
+
by(rule("knights-tour-warnsdorff.pl", clause(5))),
|
|
348
|
+
bindings([binding("Current", p(4, 5)), binding("Visited", [p(4, 5), p(5, 3), p(4, 1), p(2, 2), p(1, 4), p(3, 5), p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)]), binding("SquareCount", 25), binding("Tour", [p(3, 1), p(5, 2), p(3, 3), p(1, 2), p(2, 4), p(4, 5), p(5, 3), p(4, 1), p(2, 2), p(1, 4), p(3, 5), p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)]), binding("Candidates", ['-'(2, p(3, 3)), '-'(1, p(2, 4))]), binding("__anon1", 1), binding("Best", p(2, 4)), binding("__anon2", ['-'(2, p(3, 3))])]),
|
|
349
|
+
uses([
|
|
350
|
+
proof(
|
|
351
|
+
goal(findall('-'(Degree, Next), (knight_move(p(4, 5), Next), '\\+'(member(Next, [p(4, 5), p(5, 3), p(4, 1), p(2, 2), p(1, 4), p(3, 5), p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)])), degree(Next, [p(4, 5), p(5, 3), p(4, 1), p(2, 2), p(1, 4), p(3, 5), p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)], Degree)), ['-'(2, p(3, 3)), '-'(1, p(2, 4))])),
|
|
352
|
+
by(builtin(findall, 3))
|
|
353
|
+
),
|
|
354
|
+
proof(
|
|
355
|
+
goal(\=(['-'(2, p(3, 3)), '-'(1, p(2, 4))], [])),
|
|
356
|
+
by(builtin(\=, 2))
|
|
357
|
+
),
|
|
358
|
+
proof(
|
|
359
|
+
goal(keysort(['-'(2, p(3, 3)), '-'(1, p(2, 4))], ['-'(1, p(2, 4)), '-'(2, p(3, 3))])),
|
|
360
|
+
by(builtin(keysort, 2))
|
|
361
|
+
),
|
|
362
|
+
proof(
|
|
363
|
+
goal(tour_(p(2, 4), [p(2, 4), p(4, 5), p(5, 3), p(4, 1), p(2, 2), p(1, 4), p(3, 5), p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)], 25, [p(3, 1), p(5, 2), p(3, 3), p(1, 2), p(2, 4), p(4, 5), p(5, 3), p(4, 1), p(2, 2), p(1, 4), p(3, 5), p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)])),
|
|
364
|
+
by(rule("knights-tour-warnsdorff.pl", clause(5))),
|
|
365
|
+
bindings([binding("Current", p(2, 4)), binding("Visited", [p(2, 4), p(4, 5), p(5, 3), p(4, 1), p(2, 2), p(1, 4), p(3, 5), p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)]), binding("SquareCount", 25), binding("Tour", [p(3, 1), p(5, 2), p(3, 3), p(1, 2), p(2, 4), p(4, 5), p(5, 3), p(4, 1), p(2, 2), p(1, 4), p(3, 5), p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)]), binding("Candidates", ['-'(2, p(1, 2))]), binding("__anon1", 2), binding("Best", p(1, 2)), binding("__anon2", [])]),
|
|
366
|
+
uses([
|
|
367
|
+
proof(
|
|
368
|
+
goal(findall('-'(Degree, Next), (knight_move(p(2, 4), Next), '\\+'(member(Next, [p(2, 4), p(4, 5), p(5, 3), p(4, 1), p(2, 2), p(1, 4), p(3, 5), p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)])), degree(Next, [p(2, 4), p(4, 5), p(5, 3), p(4, 1), p(2, 2), p(1, 4), p(3, 5), p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)], Degree)), ['-'(2, p(1, 2))])),
|
|
369
|
+
by(builtin(findall, 3))
|
|
370
|
+
),
|
|
371
|
+
proof(
|
|
372
|
+
goal(\=(['-'(2, p(1, 2))], [])),
|
|
373
|
+
by(builtin(\=, 2))
|
|
374
|
+
),
|
|
375
|
+
proof(
|
|
376
|
+
goal(keysort(['-'(2, p(1, 2))], ['-'(2, p(1, 2))])),
|
|
377
|
+
by(builtin(keysort, 2))
|
|
378
|
+
),
|
|
379
|
+
proof(
|
|
380
|
+
goal(tour_(p(1, 2), [p(1, 2), p(2, 4), p(4, 5), p(5, 3), p(4, 1), p(2, 2), p(1, 4), p(3, 5), p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)], 25, [p(3, 1), p(5, 2), p(3, 3), p(1, 2), p(2, 4), p(4, 5), p(5, 3), p(4, 1), p(2, 2), p(1, 4), p(3, 5), p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)])),
|
|
381
|
+
by(rule("knights-tour-warnsdorff.pl", clause(5))),
|
|
382
|
+
bindings([binding("Current", p(1, 2)), binding("Visited", [p(1, 2), p(2, 4), p(4, 5), p(5, 3), p(4, 1), p(2, 2), p(1, 4), p(3, 5), p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)]), binding("SquareCount", 25), binding("Tour", [p(3, 1), p(5, 2), p(3, 3), p(1, 2), p(2, 4), p(4, 5), p(5, 3), p(4, 1), p(2, 2), p(1, 4), p(3, 5), p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)]), binding("Candidates", ['-'(1, p(3, 3)), '-'(1, p(3, 1))]), binding("__anon1", 1), binding("Best", p(3, 3)), binding("__anon2", ['-'(1, p(3, 1))])]),
|
|
383
|
+
uses([
|
|
384
|
+
proof(
|
|
385
|
+
goal(findall('-'(Degree, Next), (knight_move(p(1, 2), Next), '\\+'(member(Next, [p(1, 2), p(2, 4), p(4, 5), p(5, 3), p(4, 1), p(2, 2), p(1, 4), p(3, 5), p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)])), degree(Next, [p(1, 2), p(2, 4), p(4, 5), p(5, 3), p(4, 1), p(2, 2), p(1, 4), p(3, 5), p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)], Degree)), ['-'(1, p(3, 3)), '-'(1, p(3, 1))])),
|
|
386
|
+
by(builtin(findall, 3))
|
|
387
|
+
),
|
|
388
|
+
proof(
|
|
389
|
+
goal(\=(['-'(1, p(3, 3)), '-'(1, p(3, 1))], [])),
|
|
390
|
+
by(builtin(\=, 2))
|
|
391
|
+
),
|
|
392
|
+
proof(
|
|
393
|
+
goal(keysort(['-'(1, p(3, 3)), '-'(1, p(3, 1))], ['-'(1, p(3, 3)), '-'(1, p(3, 1))])),
|
|
394
|
+
by(builtin(keysort, 2))
|
|
395
|
+
),
|
|
396
|
+
proof(
|
|
397
|
+
goal(tour_(p(3, 3), [p(3, 3), p(1, 2), p(2, 4), p(4, 5), p(5, 3), p(4, 1), p(2, 2), p(1, 4), p(3, 5), p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)], 25, [p(3, 1), p(5, 2), p(3, 3), p(1, 2), p(2, 4), p(4, 5), p(5, 3), p(4, 1), p(2, 2), p(1, 4), p(3, 5), p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)])),
|
|
398
|
+
by(rule("knights-tour-warnsdorff.pl", clause(5))),
|
|
399
|
+
bindings([binding("Current", p(3, 3)), binding("Visited", [p(3, 3), p(1, 2), p(2, 4), p(4, 5), p(5, 3), p(4, 1), p(2, 2), p(1, 4), p(3, 5), p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)]), binding("SquareCount", 25), binding("Tour", [p(3, 1), p(5, 2), p(3, 3), p(1, 2), p(2, 4), p(4, 5), p(5, 3), p(4, 1), p(2, 2), p(1, 4), p(3, 5), p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)]), binding("Candidates", ['-'(1, p(5, 2))]), binding("__anon1", 1), binding("Best", p(5, 2)), binding("__anon2", [])]),
|
|
400
|
+
uses([
|
|
401
|
+
proof(
|
|
402
|
+
goal(findall('-'(Degree, Next), (knight_move(p(3, 3), Next), '\\+'(member(Next, [p(3, 3), p(1, 2), p(2, 4), p(4, 5), p(5, 3), p(4, 1), p(2, 2), p(1, 4), p(3, 5), p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)])), degree(Next, [p(3, 3), p(1, 2), p(2, 4), p(4, 5), p(5, 3), p(4, 1), p(2, 2), p(1, 4), p(3, 5), p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)], Degree)), ['-'(1, p(5, 2))])),
|
|
403
|
+
by(builtin(findall, 3))
|
|
404
|
+
),
|
|
405
|
+
proof(
|
|
406
|
+
goal(\=(['-'(1, p(5, 2))], [])),
|
|
407
|
+
by(builtin(\=, 2))
|
|
408
|
+
),
|
|
409
|
+
proof(
|
|
410
|
+
goal(keysort(['-'(1, p(5, 2))], ['-'(1, p(5, 2))])),
|
|
411
|
+
by(builtin(keysort, 2))
|
|
412
|
+
),
|
|
413
|
+
proof(
|
|
414
|
+
goal(tour_(p(5, 2), [p(5, 2), p(3, 3), p(1, 2), p(2, 4), p(4, 5), p(5, 3), p(4, 1), p(2, 2), p(1, 4), p(3, 5), p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)], 25, [p(3, 1), p(5, 2), p(3, 3), p(1, 2), p(2, 4), p(4, 5), p(5, 3), p(4, 1), p(2, 2), p(1, 4), p(3, 5), p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)])),
|
|
415
|
+
by(rule("knights-tour-warnsdorff.pl", clause(5))),
|
|
416
|
+
bindings([binding("Current", p(5, 2)), binding("Visited", [p(5, 2), p(3, 3), p(1, 2), p(2, 4), p(4, 5), p(5, 3), p(4, 1), p(2, 2), p(1, 4), p(3, 5), p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)]), binding("SquareCount", 25), binding("Tour", [p(3, 1), p(5, 2), p(3, 3), p(1, 2), p(2, 4), p(4, 5), p(5, 3), p(4, 1), p(2, 2), p(1, 4), p(3, 5), p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)]), binding("Candidates", ['-'(0, p(3, 1))]), binding("__anon1", 0), binding("Best", p(3, 1)), binding("__anon2", [])]),
|
|
417
|
+
uses([
|
|
418
|
+
proof(
|
|
419
|
+
goal(findall('-'(Degree, Next), (knight_move(p(5, 2), Next), '\\+'(member(Next, [p(5, 2), p(3, 3), p(1, 2), p(2, 4), p(4, 5), p(5, 3), p(4, 1), p(2, 2), p(1, 4), p(3, 5), p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)])), degree(Next, [p(5, 2), p(3, 3), p(1, 2), p(2, 4), p(4, 5), p(5, 3), p(4, 1), p(2, 2), p(1, 4), p(3, 5), p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)], Degree)), ['-'(0, p(3, 1))])),
|
|
420
|
+
by(builtin(findall, 3))
|
|
421
|
+
),
|
|
422
|
+
proof(
|
|
423
|
+
goal(\=(['-'(0, p(3, 1))], [])),
|
|
424
|
+
by(builtin(\=, 2))
|
|
425
|
+
),
|
|
426
|
+
proof(
|
|
427
|
+
goal(keysort(['-'(0, p(3, 1))], ['-'(0, p(3, 1))])),
|
|
428
|
+
by(builtin(keysort, 2))
|
|
429
|
+
),
|
|
430
|
+
proof(
|
|
431
|
+
goal(tour_(p(3, 1), [p(3, 1), p(5, 2), p(3, 3), p(1, 2), p(2, 4), p(4, 5), p(5, 3), p(4, 1), p(2, 2), p(1, 4), p(3, 5), p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)], 25, [p(3, 1), p(5, 2), p(3, 3), p(1, 2), p(2, 4), p(4, 5), p(5, 3), p(4, 1), p(2, 2), p(1, 4), p(3, 5), p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)])),
|
|
432
|
+
by(rule("knights-tour-warnsdorff.pl", clause(4))),
|
|
433
|
+
bindings([binding("__anon0", p(3, 1)), binding("Visited", [p(3, 1), p(5, 2), p(3, 3), p(1, 2), p(2, 4), p(4, 5), p(5, 3), p(4, 1), p(2, 2), p(1, 4), p(3, 5), p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)]), binding("SquareCount", 25)]),
|
|
434
|
+
uses([
|
|
435
|
+
proof(
|
|
436
|
+
goal(length([p(3, 1), p(5, 2), p(3, 3), p(1, 2), p(2, 4), p(4, 5), p(5, 3), p(4, 1), p(2, 2), p(1, 4), p(3, 5), p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)], 25)),
|
|
437
|
+
by(library(length, 2))
|
|
438
|
+
),
|
|
439
|
+
proof(
|
|
440
|
+
goal(!),
|
|
441
|
+
by(builtin(goal, 0))
|
|
442
|
+
)
|
|
443
|
+
])
|
|
444
|
+
)
|
|
445
|
+
])
|
|
446
|
+
)
|
|
447
|
+
])
|
|
448
|
+
)
|
|
449
|
+
])
|
|
450
|
+
)
|
|
451
|
+
])
|
|
452
|
+
)
|
|
453
|
+
])
|
|
454
|
+
)
|
|
455
|
+
])
|
|
456
|
+
)
|
|
457
|
+
])
|
|
458
|
+
)
|
|
459
|
+
])
|
|
460
|
+
)
|
|
461
|
+
])
|
|
462
|
+
)
|
|
463
|
+
])
|
|
464
|
+
)
|
|
465
|
+
])
|
|
466
|
+
)
|
|
467
|
+
])
|
|
468
|
+
)
|
|
469
|
+
])
|
|
470
|
+
)
|
|
471
|
+
])
|
|
472
|
+
)
|
|
473
|
+
])
|
|
474
|
+
)
|
|
475
|
+
])
|
|
476
|
+
)
|
|
477
|
+
])
|
|
478
|
+
)
|
|
479
|
+
])
|
|
480
|
+
)
|
|
481
|
+
])
|
|
482
|
+
)
|
|
483
|
+
])
|
|
484
|
+
)
|
|
485
|
+
])
|
|
486
|
+
)
|
|
487
|
+
])
|
|
488
|
+
)
|
|
489
|
+
])
|
|
490
|
+
)
|
|
491
|
+
])
|
|
492
|
+
),
|
|
493
|
+
proof(
|
|
494
|
+
goal(reverse([p(3, 1), p(5, 2), p(3, 3), p(1, 2), p(2, 4), p(4, 5), p(5, 3), p(4, 1), p(2, 2), p(1, 4), p(3, 5), p(5, 4), p(4, 2), p(2, 1), p(1, 3), p(2, 5), p(4, 4), p(3, 2), p(5, 1), p(4, 3), p(5, 5), p(3, 4), p(1, 5), p(2, 3), p(1, 1)], [p(1, 1), p(2, 3), p(1, 5), p(3, 4), p(5, 5), p(4, 3), p(5, 1), p(3, 2), p(4, 4), p(2, 5), p(1, 3), p(2, 1), p(4, 2), p(5, 4), p(3, 5), p(1, 4), p(2, 2), p(4, 1), p(5, 3), p(4, 5), p(2, 4), p(1, 2), p(3, 3), p(5, 2), p(3, 1)])),
|
|
495
|
+
by(library(reverse, 2))
|
|
496
|
+
)
|
|
497
|
+
])
|
|
498
|
+
),
|
|
499
|
+
proof(
|
|
500
|
+
goal(length([p(1, 1), p(2, 3), p(1, 5), p(3, 4), p(5, 5), p(4, 3), p(5, 1), p(3, 2), p(4, 4), p(2, 5), p(1, 3), p(2, 1), p(4, 2), p(5, 4), p(3, 5), p(1, 4), p(2, 2), p(4, 1), p(5, 3), p(4, 5), p(2, 4), p(1, 2), p(3, 3), p(5, 2), p(3, 1)], 25)),
|
|
501
|
+
by(library(length, 2))
|
|
502
|
+
)
|
|
503
|
+
])
|
|
504
|
+
)
|
|
505
|
+
).
|
|
506
|
+
|
package/package.json
CHANGED
package/src/parser.js
CHANGED
|
@@ -927,7 +927,20 @@ class Parser {
|
|
|
927
927
|
// A negative number consists of a minus name token followed by a numeric
|
|
928
928
|
// token, with layout permitted between them. It is lexical number syntax,
|
|
929
929
|
// not an application of the current prefix `-` operator, and therefore
|
|
930
|
-
// remains valid even after op(0, fy, -)
|
|
930
|
+
// remains valid even after op(0, fy, -); this also applies when the minus
|
|
931
|
+
// is a quoted '-' rather than the bare graphic char, since quoting still
|
|
932
|
+
// denotes the same name token (WG17 #57/#58 require integer('-'1) and
|
|
933
|
+
// integer('-' 1) to succeed exactly like integer(-1)). An unquoted minus
|
|
934
|
+
// immediately touching a digit is instead merged into one NUMBER token by
|
|
935
|
+
// the scanner itself, before parsing ever reaches here, through the same
|
|
936
|
+
// integer/float construction every other numeric literal goes through --
|
|
937
|
+
// so -0 there already canonicalizes to plain 0. This branch used to paste
|
|
938
|
+
// the raw texts together instead ("-" + value), which kept a literal
|
|
939
|
+
// "-0"/"-0.0" spelling that compared and typed as zero but did not print
|
|
940
|
+
// as one: exactly the kind of divergent, duplicated number-building logic
|
|
941
|
+
// issue #114 flagged. Reusing parseNumberTokenText -- the single shared
|
|
942
|
+
// number-literal constructor -- keeps this merge canonicalizing the same
|
|
943
|
+
// way as every other numeric literal instead of re-deriving it here.
|
|
931
944
|
if (operatorName === '-' && this.token.type === TOK.ATOM) {
|
|
932
945
|
const state = {
|
|
933
946
|
pos: this.pos,
|
|
@@ -939,7 +952,7 @@ class Parser {
|
|
|
939
952
|
if (this.token.type === TOK.NUMBER && !this.token.text.startsWith('-')) {
|
|
940
953
|
const value = this.token.text;
|
|
941
954
|
this.advance();
|
|
942
|
-
return
|
|
955
|
+
return parseNumberTokenText(`-${value}`);
|
|
943
956
|
}
|
|
944
957
|
this.pos = state.pos;
|
|
945
958
|
this.line = state.line;
|
|
@@ -1415,6 +1428,28 @@ function parseClausesFastNoSource(source, emit = null, emitBinary = null, option
|
|
|
1415
1428
|
return value;
|
|
1416
1429
|
};
|
|
1417
1430
|
|
|
1431
|
+
// SIMPLE_NUMBER-matched text is already lexically valid Prolog number
|
|
1432
|
+
// syntax, and this fast path deliberately leaves a numeric literal's
|
|
1433
|
+
// spelling otherwise untouched (test/conformance/cases/arithmetic/
|
|
1434
|
+
// 024_numeric_literal_readback.pl: decimal and exponent literals retain
|
|
1435
|
+
// their lexical form here, so e.g. 6.02e23 must not become 6.02e+23).
|
|
1436
|
+
// Two things still cannot be left as raw matched text, though: an integer
|
|
1437
|
+
// is never left non-canonical anywhere else in the language (a leading
|
|
1438
|
+
// zero, or the "-0" from issue #114, must collapse the same way the
|
|
1439
|
+
// scanner's own adjacent-minus BigInt construction already does), and a
|
|
1440
|
+
// float whose value is exactly zero must never print with a stray minus --
|
|
1441
|
+
// this implementation deliberately never produces -0.0 (term.js
|
|
1442
|
+
// numberTextFromDouble) -- without reformatting any non-zero float.
|
|
1443
|
+
const canonicalFastNumberText = (text) => {
|
|
1444
|
+
if (text.includes('.') || text.includes('e') || text.includes('E')) {
|
|
1445
|
+
return (text.charCodeAt(0) === 45 && Number(text) === 0) ? text.slice(1) : text;
|
|
1446
|
+
}
|
|
1447
|
+
const first = text.charCodeAt(0);
|
|
1448
|
+
if (first !== 45 && (text.length === 1 || first !== 48)) return text;
|
|
1449
|
+
return BigInt(text).toString();
|
|
1450
|
+
};
|
|
1451
|
+
const fastNumberTerm = (text) => numberTerm(canonicalFastNumberText(text));
|
|
1452
|
+
|
|
1418
1453
|
const isFastScalarToken = (text) => SIMPLE_VARIABLE.test(text) || SIMPLE_ATOM.test(text) || GRAPHIC_ATOM.test(text) || SIMPLE_NUMBER.test(text);
|
|
1419
1454
|
const scalarOrVariableFast = (text) => {
|
|
1420
1455
|
if (!text || !isFastScalarToken(text)) throw new Error('bad simple term');
|
|
@@ -1427,7 +1462,7 @@ function parseClausesFastNoSource(source, emit = null, emitBinary = null, option
|
|
|
1427
1462
|
variableCache.set(text, value);
|
|
1428
1463
|
return value;
|
|
1429
1464
|
}
|
|
1430
|
-
if ((first === 45 || isDigitCode(first)) && SIMPLE_NUMBER.test(text)) return cached(numberCache, text,
|
|
1465
|
+
if ((first === 45 || isDigitCode(first)) && SIMPLE_NUMBER.test(text)) return cached(numberCache, text, fastNumberTerm);
|
|
1431
1466
|
return atom(text);
|
|
1432
1467
|
};
|
|
1433
1468
|
|
|
@@ -1493,7 +1528,10 @@ function parseClausesFastNoSource(source, emit = null, emitBinary = null, option
|
|
|
1493
1528
|
return term;
|
|
1494
1529
|
}
|
|
1495
1530
|
if (kind === 'atom') return atom(value);
|
|
1496
|
-
|
|
1531
|
+
// See canonicalFastNumberText above: "-0" and "007" must still come out
|
|
1532
|
+
// the same as everywhere else in the language (issue #114), without
|
|
1533
|
+
// reformatting a non-zero float's retained lexical spelling.
|
|
1534
|
+
if (simpleNumberInRange(text, start, end)) return cached(numberCache, value, fastNumberTerm);
|
|
1497
1535
|
return null;
|
|
1498
1536
|
};
|
|
1499
1537
|
|
|
@@ -1509,6 +1547,12 @@ function parseClausesFastNoSource(source, emit = null, emitBinary = null, option
|
|
|
1509
1547
|
if (type == null) return false;
|
|
1510
1548
|
let name = text.slice(start, end);
|
|
1511
1549
|
if (type === 'var' && name === '_') name = `__anon${anonymous++}`;
|
|
1550
|
+
// This range becomes a CompactBinaryClause argument, materialized lazily
|
|
1551
|
+
// as numberTerm(name) (program-indexing.js) and used as-is for indexing.
|
|
1552
|
+
// Canonicalize the stored text up front for the same reason as the two
|
|
1553
|
+
// callers above -- otherwise a fact such as bar(-0, 1) or bar(007, 1)
|
|
1554
|
+
// keeps its raw, non-canonical spelling forever (issue #114).
|
|
1555
|
+
if (type === 'number') name = canonicalFastNumberText(name);
|
|
1512
1556
|
if (slot === 0) {
|
|
1513
1557
|
out.arg0Type = type;
|
|
1514
1558
|
out.arg0Name = name;
|
|
@@ -5853,5 +5853,99 @@ answer(Result) :- countdown(2048, Result), Result = 2048.
|
|
|
5853
5853
|
assertIncludes(result.stderr, 'error(permission_error(modify, static_procedure), /(false, 0))', 'stderr');
|
|
5854
5854
|
},
|
|
5855
5855
|
},
|
|
5856
|
+
{
|
|
5857
|
+
name: 'a minus name token merged with a numeric token canonicalizes the same way everywhere, not just when adjacent and unquoted (issue #114)',
|
|
5858
|
+
run: () => {
|
|
5859
|
+
// An unquoted `-` immediately touching a digit is merged into a single
|
|
5860
|
+
// NUMBER token by the scanner itself (6.3.1.2), which already builds
|
|
5861
|
+
// its text through the same integer/float construction as every other
|
|
5862
|
+
// numeric literal -- so -0 there was always plain 0. Every other way
|
|
5863
|
+
// of writing the same negative-number production (layout between the
|
|
5864
|
+
// tokens, or a quoted '-') used to reach a second, separate code path
|
|
5865
|
+
// that pasted the texts together instead ("-" + "0"), keeping a
|
|
5866
|
+
// literal "-0"/"-0.0" spelling that compared and typed as zero but
|
|
5867
|
+
// did not print as one. Both forms must canonicalize identically.
|
|
5868
|
+
for (const spelling of ["'-'0", "'-' 0", '- 0']) {
|
|
5869
|
+
const result = run('', { goal: `N = ${spelling}, write_canonical(N), nl` });
|
|
5870
|
+
assertEqual(result.stats.completed_goal_lists, 1, `${spelling}: goal succeeds`);
|
|
5871
|
+
assertEqual(result.stdout, '0\n0 = 0, write_canonical(0), nl.\n', `${spelling}: N prints as plain 0, not -0`);
|
|
5872
|
+
}
|
|
5873
|
+
// The same merge applies to floats, where EyeProlog normalizes -0.0
|
|
5874
|
+
// to 0.0 everywhere (term.js numberTextFromDouble) -- so the quoted
|
|
5875
|
+
// and layout-separated spellings must collapse the sign exactly like
|
|
5876
|
+
// the plain adjacent `-0.0` already does, not retain it.
|
|
5877
|
+
for (const spelling of ["'-'0.0", "'-' 0.0", '- 0.0']) {
|
|
5878
|
+
assertEqual(
|
|
5879
|
+
run('', { goal: `N = ${spelling}, write_canonical(N), nl` }).stdout,
|
|
5880
|
+
'0.0\n0.0 = 0.0, write_canonical(0.0), nl.\n',
|
|
5881
|
+
`${spelling}: float negative zero collapses to 0.0`,
|
|
5882
|
+
);
|
|
5883
|
+
}
|
|
5884
|
+
// A genuine negative number must still merge and negate correctly
|
|
5885
|
+
// through every one of these spellings, quoted or not.
|
|
5886
|
+
for (const spelling of ["'-'1", "'-' 1", '- 1']) {
|
|
5887
|
+
assertEqual(
|
|
5888
|
+
run('', { goal: `N = ${spelling}, integer(N), N == -1` }).stats.completed_goal_lists,
|
|
5889
|
+
1,
|
|
5890
|
+
`${spelling}: still denotes the integer -1`,
|
|
5891
|
+
);
|
|
5892
|
+
}
|
|
5893
|
+
},
|
|
5894
|
+
},
|
|
5895
|
+
{
|
|
5896
|
+
// https://github.com/eyereasoner/eyeprolog/issues/114#issuecomment-5663598188
|
|
5897
|
+
name: 'the fast compact-clause loader canonicalizes numeric literals the same way the general parser does (issue #114 follow-up)',
|
|
5898
|
+
run: () => {
|
|
5899
|
+
// parseClausesFastNoSource (src/parser.js) has its own, separate
|
|
5900
|
+
// number-token handling for facts and rules that match its compact
|
|
5901
|
+
// two-argument shape -- exactly the kind of second code path that
|
|
5902
|
+
// reintroduces the #114 bug class. It used to build every numeric
|
|
5903
|
+
// argument straight from the raw regex-matched text, so a fact like
|
|
5904
|
+
// bar(-0, 1) or bar(007, 1) kept that raw spelling forever instead of
|
|
5905
|
+
// canonicalizing like every other numeric literal in the language.
|
|
5906
|
+
for (const [program, goal, expected] of [
|
|
5907
|
+
["bar(-0, 1).\n", 'bar(A, B), write_canonical(A), nl', '0'],
|
|
5908
|
+
["bar(-0.0, 1).\n", 'bar(A, B), write_canonical(A), nl', '0.0'],
|
|
5909
|
+
["bar(007, 1).\n", 'bar(A, B), write_canonical(A), nl', '7'],
|
|
5910
|
+
['point(1, -0).\n', 'point(A, B), write_canonical(B), nl', '0'],
|
|
5911
|
+
]) {
|
|
5912
|
+
const stdout = run(program, { goal }).stdout;
|
|
5913
|
+
assertEqual(stdout.split('\n')[0], expected, `${program.trim()}: ${goal}`);
|
|
5914
|
+
}
|
|
5915
|
+
// The fast loader also deliberately retains a numeric literal's exact
|
|
5916
|
+
// lexical spelling otherwise (test/conformance/cases/arithmetic/
|
|
5917
|
+
// 024_numeric_literal_readback.pl): the zero-canonicalization above
|
|
5918
|
+
// must not turn into a general reformatting pass that rewrites a
|
|
5919
|
+
// non-zero float's notation.
|
|
5920
|
+
assertEqual(
|
|
5921
|
+
run('raw(a, 6.02e23).\n', { goal: 'raw(_, B), write_canonical(B), nl' }).stdout.split('\n')[0],
|
|
5922
|
+
'6.02e23',
|
|
5923
|
+
'non-zero exponent notation is preserved, not reformatted to 6.02e+23',
|
|
5924
|
+
);
|
|
5925
|
+
assertEqual(
|
|
5926
|
+
run('raw(a, -1.0e-3).\n', { goal: 'raw(_, B), write_canonical(B), nl' }).stdout.split('\n')[0],
|
|
5927
|
+
'-1.0e-3',
|
|
5928
|
+
'non-zero negative exponent notation is preserved, not reformatted to -0.001',
|
|
5929
|
+
);
|
|
5930
|
+
},
|
|
5931
|
+
},
|
|
5932
|
+
{
|
|
5933
|
+
// https://github.com/eyereasoner/eyeprolog/issues/114#issuecomment-5663598188
|
|
5934
|
+
name: 'a genuine IEEE-754 negative zero produced by arithmetic (not just parsed from text) still prints as 0.0',
|
|
5935
|
+
run: () => {
|
|
5936
|
+
// Every fix above canonicalizes -0.0 where it is spelled out in
|
|
5937
|
+
// source text. EyeProlog's floats are ordinary JS doubles, though,
|
|
5938
|
+
// and JS arithmetic itself produces a real, distinct -0.0 bit
|
|
5939
|
+
// pattern for operations such as a negative number times zero --
|
|
5940
|
+
// this is genuine IEEE-754 negative zero, not a text-parsing
|
|
5941
|
+
// artifact, and 13211-1 has nothing to say about it either way. It
|
|
5942
|
+
// must still come out normalized to plain 0.0 on the way to a term,
|
|
5943
|
+
// the same as every syntactic spelling of negative zero does.
|
|
5944
|
+
for (const goal of ['X is -1.0 * 0.0', 'X is 0.0 * -1.0', 'X is -(1.0 - 1.0)']) {
|
|
5945
|
+
const stdout = run('', { goal: `${goal}, write_canonical(X), nl` }).stdout;
|
|
5946
|
+
assertEqual(stdout.split('\n')[0], '0.0', `${goal}: internal -0.0 normalizes to 0.0`);
|
|
5947
|
+
}
|
|
5948
|
+
},
|
|
5949
|
+
},
|
|
5856
5950
|
];
|
|
5857
5951
|
}
|
package/test/run-examples.mjs
CHANGED
|
@@ -100,6 +100,7 @@ export const proofExamples = [
|
|
|
100
100
|
'job-shop-scheduling.pl',
|
|
101
101
|
'dcg-command-parser.pl',
|
|
102
102
|
'knapsack-optimization.pl',
|
|
103
|
+
'knights-tour-warnsdorff.pl',
|
|
103
104
|
'declarative-fault-localization.pl',
|
|
104
105
|
'iso-integer-arithmetic.pl',
|
|
105
106
|
'workplace-compliance.pl',
|
package/the-art-of-eyeprolog.md
CHANGED
|
@@ -9936,7 +9936,7 @@ Review questions:
|
|
|
9936
9936
|
The [examples directory](https://github.com/eyereasoner/eyeprolog/tree/main/examples/) is the book's executable companion. The
|
|
9937
9937
|
top-level directory contains **235 self-contained runnable programs**. Every
|
|
9938
9938
|
source program has an exact answer file under
|
|
9939
|
-
[examples/output](https://github.com/eyereasoner/eyeprolog/tree/main/examples/output/), and **
|
|
9939
|
+
[examples/output](https://github.com/eyereasoner/eyeprolog/tree/main/examples/output/), and **103 selected programs** have a checked
|
|
9940
9940
|
explanation under [examples/proof](https://github.com/eyereasoner/eyeprolog/tree/main/examples/proof/). The thematic lists link every top-level program and open the program
|
|
9941
9941
|
itself rather than merely naming it.
|
|
9942
9942
|
|
|
@@ -10346,7 +10346,7 @@ hand.
|
|
|
10346
10346
|
|
|
10347
10347
|
#### Running and extending the corpus
|
|
10348
10348
|
|
|
10349
|
-
Run all 235 normal answer goldens and the
|
|
10349
|
+
Run all 235 normal answer goldens and the 103 selected proof goldens with:
|
|
10350
10350
|
|
|
10351
10351
|
```sh
|
|
10352
10352
|
node test/run-examples.mjs
|
|
@@ -10418,7 +10418,7 @@ accept texts outside the strict grammar, but it may not reinterpret an accepted
|
|
|
10418
10418
|
standard case.
|
|
10419
10419
|
|
|
10420
10420
|
The file-based conformance corpus contains 905 cases, including 479 focused ISO cases derived from the success, failure, mode, and error behavior in ISO/IEC 13211-1 clauses 7 and 8, Part 2 modules, and Part 3 grammar rules.
|
|
10421
|
-
Separate exact-output suites check 235 normal examples and
|
|
10421
|
+
Separate exact-output suites check 235 normal examples and 103 proof examples; all executable chapter programs are parsed and their declared goals are executed. The nine-case
|
|
10422
10422
|
playground contract suite imports the production worker, sends real reasoning
|
|
10423
10423
|
requests through its message protocol, and crawls the served module graph for
|
|
10424
10424
|
missing assets, bad MIME types, and static Node-only imports. `conformance-report.md` inventories the file-based conformance corpus and links to the live Neumerkel evidence, which includes the current WG17 syntax result.
|