eyeprolog 1.6.34 → 1.6.35

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.
Files changed (118) hide show
  1. package/examples/book/README.md +59 -75
  2. package/examples/book/chapter-02/02-measurement.pl +0 -2
  3. package/examples/book/chapter-03/01-eligible.pl +0 -2
  4. package/examples/book/chapter-03/04-ancestor.pl +2 -0
  5. package/examples/book/chapter-03/{07-different.pl → 05-different.pl} +1 -1
  6. package/examples/book/chapter-03/{08-has_parent.pl → 06-has_parent.pl} +1 -1
  7. package/examples/book/chapter-03/07-program.pl +2 -0
  8. package/examples/book/chapter-04/02-path.pl +1 -3
  9. package/examples/book/chapter-06/01-next.pl +0 -2
  10. package/examples/book/chapter-06/03-square.pl +0 -2
  11. package/examples/book/chapter-07/03-move.pl +4 -0
  12. package/examples/book/chapter-08/01-outgoing_costs.pl +0 -2
  13. package/examples/book/chapter-08/02-best_route.pl +0 -2
  14. package/examples/book/chapter-09/01-normalized.pl +0 -2
  15. package/examples/book/chapter-09/02-message.pl +0 -2
  16. package/examples/book/chapter-12/01-invalid_probability.pl +5 -0
  17. package/examples/book/chapter-13/01-reach.pl +3 -0
  18. package/examples/book/chapter-17/01-path.pl +0 -2
  19. package/examples/book/chapter-17/02-adult.pl +1 -3
  20. package/examples/book/chapter-17/03-bad_member.pl +0 -2
  21. package/examples/book/chapter-18/01-routeable.pl +1 -3
  22. package/examples/book/chapter-18/02-routeable-2.pl +0 -2
  23. package/examples/book/chapter-18/03-prefix.pl +1 -1
  24. package/examples/book/chapter-18/04-candidate_pair.pl +1 -3
  25. package/examples/book/chapter-19/01-factorial.pl +1 -1
  26. package/examples/book/chapter-19/02-invalid_limits.pl +1 -1
  27. package/examples/book/chapter-20/01-connected.pl +1 -1
  28. package/examples/book/chapter-20/02-within_thermal_limits.pl +1 -1
  29. package/examples/book/chapter-20/03-search.pl +1 -1
  30. package/examples/book/chapter-21/02-grandparent.pl +1 -1
  31. package/examples/book/chapter-21/03-loop_edge.pl +0 -2
  32. package/examples/book/chapter-21/04-eligible.pl +0 -2
  33. package/examples/book/chapter-21/05-grows.pl +1 -1
  34. package/examples/book/chapter-22/02-tree_member.pl +0 -2
  35. package/examples/book/chapter-22/03-mirror.pl +1 -1
  36. package/examples/book/chapter-22/04-sentence.pl +1 -1
  37. package/examples/book/chapter-22/05-evaluate.pl +1 -1
  38. package/examples/book/chapter-22/06-lookup.pl +0 -2
  39. package/examples/book/chapter-22/07-simplify.pl +1 -1
  40. package/examples/book/chapter-23/01-adult.pl +0 -2
  41. package/examples/book/chapter-23/02-adult-2.pl +0 -2
  42. package/examples/book/chapter-23/03-can_board.pl +0 -2
  43. package/examples/book/chapter-23/04-traveler_in_good_standing.pl +0 -2
  44. package/examples/book/chapter-23/{06-rail_connection.pl → 05-rail_connection.pl} +1 -1
  45. package/examples/book/chapter-23/{07-sum_numbers.pl → 06-sum_numbers.pl} +1 -1
  46. package/examples/book/chapter-24/01-worker.pl +1 -1
  47. package/examples/book/chapter-24/03-best_plan.pl +0 -1
  48. package/examples/book/chapter-25/01-person.pl +1 -3
  49. package/examples/book/chapter-25/02-active_badge.pl +0 -2
  50. package/examples/book/chapter-25/03-in_good_standing.pl +1 -1
  51. package/examples/book/chapter-25/04-permit.pl +1 -3
  52. package/examples/book/chapter-26/01-triple.pl +8 -0
  53. package/examples/book/chapter-26/02-edge.pl +6 -0
  54. package/examples/book/chapter-27/02-list_length.pl +1 -3
  55. package/examples/book/chapter-27/03-reverse_acc.pl +1 -1
  56. package/examples/book/chapter-28/01-triangle.pl +1 -3
  57. package/examples/book/chapter-28/{03-integer_rectangle.pl → 02-integer_rectangle.pl} +2 -3
  58. package/examples/book/chapter-28/03-preserves_combine.pl +7 -0
  59. package/examples/book/chapter-29/01-counterexample_to_odd_square.pl +3 -6
  60. package/examples/book/chapter-31/01-edge.pl +3 -2
  61. package/examples/book/chapter-31/{03-double.pl → 02-double_is_even.pl} +5 -9
  62. package/examples/book/chapter-32/01-age.pl +6 -0
  63. package/examples/book/chapter-32/{04-reference_square.pl → 02-reference_square.pl} +1 -2
  64. package/examples/book/chapter-33/{02-source_role.pl → 01-source_role.pl} +1 -2
  65. package/examples/book/chapter-33/{03-chosen_pair.pl → 02-chosen_pair.pl} +1 -2
  66. package/examples/book/chapter-33/03-unregistered.pl +4 -0
  67. package/examples/book/chapter-33/04-step.pl +2 -0
  68. package/examples/book/chapter-33/{07-depends.pl → 05-depends.pl} +3 -1
  69. package/examples/book/chapter-33/{08-within_limit.pl → 06-within_limit.pl} +1 -1
  70. package/examples/book/chapter-33/{09-invalid_badge_assignment.pl → 07-invalid_badge_assignment.pl} +1 -3
  71. package/examples/book/chapter-33/{10-theory_version.pl → 08-theory_version.pl} +1 -1
  72. package/examples/book/chapter-34/02-require_route.pl +1 -1
  73. package/examples/book/chapter-34/03-regional_total.pl +1 -3
  74. package/examples/book/chapter-36/03-program-3.pl +1 -1
  75. package/examples/book/chapter-38/01-city.pl +1 -3
  76. package/examples/book/chapter-39/03-answer.pl +0 -2
  77. package/examples/book/chapter-39/05-answer-3.pl +0 -2
  78. package/examples/book/chapter-39/06-cost.pl +0 -1
  79. package/examples/book/chapter-39/07-message.pl +0 -2
  80. package/package.json +1 -1
  81. package/test/regression/cases-documentation-sync.mjs +1 -1
  82. package/test/regression/support.mjs +1 -1
  83. package/the-art-of-eyeprolog.md +3320 -6192
  84. package/book-assets/proof-as-computation.svg +0 -30
  85. package/book-assets/reference-navigation.svg +0 -68
  86. package/book-assets/review-lenses.svg +0 -49
  87. package/examples/book/chapter-02/03-label.pl +0 -3
  88. package/examples/book/chapter-03/02-adult.pl +0 -6
  89. package/examples/book/chapter-03/05-parent.pl +0 -2
  90. package/examples/book/chapter-03/06-ancestor.pl +0 -2
  91. package/examples/book/chapter-03/09-program.pl +0 -2
  92. package/examples/book/chapter-07/02-move.pl +0 -4
  93. package/examples/book/chapter-11/01-type.pl +0 -8
  94. package/examples/book/chapter-12/02-invalid_assignment.pl +0 -5
  95. package/examples/book/chapter-18/05-compatible_pair.pl +0 -6
  96. package/examples/book/chapter-23/05-connection.pl +0 -2
  97. package/examples/book/chapter-26/01-mortal.pl +0 -2
  98. package/examples/book/chapter-26/02-triple.pl +0 -12
  99. package/examples/book/chapter-26/03-triple-2.pl +0 -4
  100. package/examples/book/chapter-26/04-edge.pl +0 -8
  101. package/examples/book/chapter-28/02-rectangle.pl +0 -4
  102. package/examples/book/chapter-28/04-preserves_combine.pl +0 -10
  103. package/examples/book/chapter-29/02-noncommuting_pair.pl +0 -7
  104. package/examples/book/chapter-31/02-program.pl +0 -6
  105. package/examples/book/chapter-32/01-eligible.pl +0 -6
  106. package/examples/book/chapter-32/02-eligible-2.pl +0 -6
  107. package/examples/book/chapter-32/03-candidate_debug.pl +0 -9
  108. package/examples/book/chapter-33/01-assigned_badge.pl +0 -4
  109. package/examples/book/chapter-33/04-path.pl +0 -7
  110. package/examples/book/chapter-33/05-unregistered.pl +0 -4
  111. package/examples/book/chapter-33/06-step.pl +0 -2
  112. package/examples/book/chapter-39/09-program.pl +0 -4
  113. /package/examples/book/chapter-03/{03-can_enter.pl → 02-can_enter.pl} +0 -0
  114. /package/examples/book/chapter-03/{04-high_score.pl → 03-high_score.pl} +0 -0
  115. /package/examples/book/chapter-03/{10-closed.pl → 08-closed.pl} +0 -0
  116. /package/examples/book/chapter-03/{11-p.pl → 09-p.pl} +0 -0
  117. /package/examples/book/chapter-07/{03-all_tests_pass.pl → 02-all_tests_pass.pl} +0 -0
  118. /package/examples/book/chapter-23/{08-sum_numbers_acc.pl → 07-sum_numbers_acc.pl} +0 -0
@@ -22,26 +22,23 @@ node tools/extract-book-examples.mjs
22
22
 
23
23
  - [01-same_shape.pl](chapter-02/01-same_shape.pl) — Unification
24
24
  - [02-measurement.pl](chapter-02/02-measurement.pl)
25
- - [03-label.pl](chapter-02/03-label.pl)
26
25
 
27
26
  ## Chapter 3: Rules and their two readings
28
27
 
29
28
  - [01-eligible.pl](chapter-03/01-eligible.pl)
30
- - [02-adult.pl](chapter-03/02-adult.pl)
31
- - [03-can_enter.pl](chapter-03/03-can_enter.pl)
32
- - [04-high_score.pl](chapter-03/04-high_score.pl)
33
- - [05-parent.pl](chapter-03/05-parent.pl) — The Herbrand world
34
- - [06-ancestor.pl](chapter-03/06-ancestor.pl)
35
- - [07-different.pl](chapter-03/07-different.pl) — Why terms denote themselves
36
- - [08-has_parent.pl](chapter-03/08-has_parent.pl) — Quantification and visible witnesses
37
- - [09-program.pl](chapter-03/09-program.pl) — Equality, unification, and the occurs check
38
- - [10-closed.pl](chapter-03/10-closed.pl) — Meaning is not the search strategy
39
- - [11-p.pl](chapter-03/11-p.pl)
29
+ - [02-can_enter.pl](chapter-03/02-can_enter.pl)
30
+ - [03-high_score.pl](chapter-03/03-high_score.pl)
31
+ - [04-ancestor.pl](chapter-03/04-ancestor.pl) — Deeper foundations: the Herbrand world
32
+ - [05-different.pl](chapter-03/05-different.pl) — Terms denote themselves
33
+ - [06-has_parent.pl](chapter-03/06-has_parent.pl) — Witnesses instead of hidden objects
34
+ - [07-program.pl](chapter-03/07-program.pl) — The occurs check
35
+ - [08-closed.pl](chapter-03/08-closed.pl) — Meaning is not the search strategy
36
+ - [09-p.pl](chapter-03/09-p.pl)
40
37
 
41
38
  ## Chapter 4: Recursion: describing reachability
42
39
 
43
40
  - [01-ancestor.pl](chapter-04/01-ancestor.pl)
44
- - [02-path.pl](chapter-04/02-path.pl) — Constructing the recursive argument
41
+ - [02-path.pl](chapter-04/02-path.pl) — Cycles and tabling
45
42
 
46
43
  ## Chapter 5: Lists as relations
47
44
 
@@ -58,8 +55,8 @@ node tools/extract-book-examples.mjs
58
55
  ## Chapter 7: Failure, negation, and quantification
59
56
 
60
57
  - [01-allowed.pl](chapter-07/01-allowed.pl)
61
- - [02-move.pl](chapter-07/02-move.pl)
62
- - [03-all_tests_pass.pl](chapter-07/03-all_tests_pass.pl)
58
+ - [02-all_tests_pass.pl](chapter-07/02-all_tests_pass.pl)
59
+ - [03-move.pl](chapter-07/03-move.pl) — Negation through recursion
63
60
 
64
61
  ## Chapter 8: Collecting and choosing answers
65
62
 
@@ -76,14 +73,13 @@ node tools/extract-book-examples.mjs
76
73
  - [01-color.pl](chapter-10/01-color.pl)
77
74
  - [02-plan.pl](chapter-10/02-plan.pl)
78
75
 
79
- ## Chapter 11: Queries, answers, and proofs
80
-
81
- - [01-type.pl](chapter-11/01-type.pl)
82
-
83
76
  ## Chapter 12: Integrity checks as ordinary predicates
84
77
 
85
78
  - [01-invalid_probability.pl](chapter-12/01-invalid_probability.pl)
86
- - [02-invalid_assignment.pl](chapter-12/02-invalid_assignment.pl)
79
+
80
+ ## Chapter 13: Termination, tabling, and performance
81
+
82
+ - [01-reach.pl](chapter-13/01-reach.pl)
87
83
 
88
84
  ## Chapter 14: Knowledge engineering
89
85
 
@@ -92,46 +88,45 @@ node tools/extract-book-examples.mjs
92
88
  ## Chapter 17: Logic and control
93
89
 
94
90
  - [01-path.pl](chapter-17/01-path.pl)
95
- - [02-adult.pl](chapter-17/02-adult.pl) — The same relation, a different computation
91
+ - [02-adult.pl](chapter-17/02-adult.pl) — Same meaning, different computation
96
92
  - [03-bad_member.pl](chapter-17/03-bad_member.pl)
97
93
  - [04-item.pl](chapter-17/04-item.pl)
98
94
 
99
95
  ## Chapter 18: Constructing a program
100
96
 
101
- - [01-routeable.pl](chapter-18/01-routeable.pl) — Begin with ground sentences
97
+ - [01-routeable.pl](chapter-18/01-routeable.pl) — Begin with a ground sentence
102
98
  - [02-routeable-2.pl](chapter-18/02-routeable-2.pl)
103
- - [03-prefix.pl](chapter-18/03-prefix.pl) — Invent examples before recursion
104
- - [04-candidate_pair.pl](chapter-18/04-candidate_pair.pl) — Separate generate, test, and describe
105
- - [05-compatible_pair.pl](chapter-18/05-compatible_pair.pl)
99
+ - [03-prefix.pl](chapter-18/03-prefix.pl) — Examples before recursion
100
+ - [04-candidate_pair.pl](chapter-18/04-candidate_pair.pl) — Generate, then test
106
101
 
107
102
  ## Chapter 19: Correctness and termination
108
103
 
109
- - [01-factorial.pl](chapter-19/01-factorial.pl) — Termination needs its own argument
110
- - [02-invalid_limits.pl](chapter-19/02-invalid_limits.pl) — Integrity is not merely failure
104
+ - [01-factorial.pl](chapter-19/01-factorial.pl) — Termination needs its own measure
105
+ - [02-invalid_limits.pl](chapter-19/02-invalid_limits.pl) — Integrity is not failure
111
106
 
112
107
  ## Chapter 20: Improving a program
113
108
 
114
- - [01-connected.pl](chapter-20/01-connected.pl) — Strengthen calls before adding machinery
115
- - [02-within_thermal_limits.pl](chapter-20/02-within_thermal_limits.pl) — Introduce helpers that express invariants
116
- - [03-search.pl](chapter-20/03-search.pl) — Move invariant work outward
109
+ - [01-connected.pl](chapter-20/01-connected.pl) — Ask a better question first
110
+ - [02-within_thermal_limits.pl](chapter-20/02-within_thermal_limits.pl) — Name invariants with helpers
111
+ - [03-search.pl](chapter-20/03-search.pl) — Hoist invariant work
117
112
 
118
113
  ## Chapter 21: Reading the computation
119
114
 
120
115
  - [01-parent.pl](chapter-21/01-parent.pl)
121
- - [02-grandparent.pl](chapter-21/02-grandparent.pl) — Substitutions accumulate
116
+ - [02-grandparent.pl](chapter-21/02-grandparent.pl) — Bindings flow forward
122
117
  - [03-loop_edge.pl](chapter-21/03-loop_edge.pl)
123
118
  - [04-eligible.pl](chapter-21/04-eligible.pl) — Failure rewinds choices, not facts
124
- - [05-grows.pl](chapter-21/05-grows.pl) — Variants, cycles, and tables
119
+ - [05-grows.pl](chapter-21/05-grows.pl) — Variants and tables
125
120
 
126
121
  ## Chapter 22: Trees, languages, and symbolic evaluation
127
122
 
128
123
  - [01-tree.pl](chapter-22/01-tree.pl)
129
124
  - [02-tree_member.pl](chapter-22/02-tree_member.pl)
130
- - [03-mirror.pl](chapter-22/03-mirror.pl) — Transforming a tree
131
- - [04-sentence.pl](chapter-22/04-sentence.pl) — A standard definite clause grammar
132
- - [05-evaluate.pl](chapter-22/05-evaluate.pl) — Interpreting an expression
125
+ - [03-mirror.pl](chapter-22/03-mirror.pl) — Relating two trees
126
+ - [04-sentence.pl](chapter-22/04-sentence.pl) — A definite clause grammar
127
+ - [05-evaluate.pl](chapter-22/05-evaluate.pl) — An evaluator
133
128
  - [06-lookup.pl](chapter-22/06-lookup.pl)
134
- - [07-simplify.pl](chapter-22/07-simplify.pl) — Rewriting symbolic expressions
129
+ - [07-simplify.pl](chapter-22/07-simplify.pl) — Rewriting
135
130
 
136
131
  ## Chapter 23: Transforming programs
137
132
 
@@ -139,81 +134,71 @@ node tools/extract-book-examples.mjs
139
134
  - [02-adult-2.pl](chapter-23/02-adult-2.pl)
140
135
  - [03-can_board.pl](chapter-23/03-can_board.pl)
141
136
  - [04-traveler_in_good_standing.pl](chapter-23/04-traveler_in_good_standing.pl)
142
- - [05-connection.pl](chapter-23/05-connection.pl) — Specializing a relation
143
- - [06-rail_connection.pl](chapter-23/06-rail_connection.pl)
144
- - [07-sum_numbers.pl](chapter-23/07-sum_numbers.pl) — Accumulators and modes
145
- - [08-sum_numbers_acc.pl](chapter-23/08-sum_numbers_acc.pl)
137
+ - [05-rail_connection.pl](chapter-23/05-rail_connection.pl) — Specialization
138
+ - [06-sum_numbers.pl](chapter-23/06-sum_numbers.pl) — Accumulators change modes
139
+ - [07-sum_numbers_acc.pl](chapter-23/07-sum_numbers_acc.pl)
146
140
 
147
141
  ## Chapter 24: Designing finite search
148
142
 
149
- - [01-worker.pl](chapter-24/01-worker.pl) — Generate, constrain, describe
143
+ - [01-worker.pl](chapter-24/01-worker.pl) — Generate and constrain
150
144
  - [02-simple_path.pl](chapter-24/02-simple_path.pl) — Search over states
151
145
  - [03-best_plan.pl](chapter-24/03-best_plan.pl) — Optimization is search plus an order
152
146
 
153
147
  ## Chapter 25: Case study: an auditable decision service
154
148
 
155
- - [01-person.pl](chapter-25/01-person.pl) — Source and concept layers
149
+ - [01-person.pl](chapter-25/01-person.pl) — Sources and concepts
156
150
  - [02-active_badge.pl](chapter-25/02-active_badge.pl)
157
- - [03-in_good_standing.pl](chapter-25/03-in_good_standing.pl) — Closed-world choice
158
- - [04-permit.pl](chapter-25/04-permit.pl) — Decision, reasons, and proof
151
+ - [03-in_good_standing.pl](chapter-25/03-in_good_standing.pl) — The closed-world choice
152
+ - [04-permit.pl](chapter-25/04-permit.pl) — Decision and reason
159
153
  - [05-incompatible_status.pl](chapter-25/05-incompatible_status.pl) — Integrity before decisions
160
154
 
161
155
  ## Chapter 26: A proof can be a computation
162
156
 
163
- - [01-mortal.pl](chapter-26/01-mortal.pl)
164
- - [02-triple.pl](chapter-26/02-triple.pl) — Answers are existential witnesses
165
- - [03-triple-2.pl](chapter-26/03-triple-2.pl) — Proof objects and proof checking
166
- - [04-edge.pl](chapter-26/04-edge.pl) — The least model as mathematical closure
157
+ - [01-triple.pl](chapter-26/01-triple.pl)
158
+ - [02-edge.pl](chapter-26/02-edge.pl) — The least model as closure
167
159
 
168
160
  ## Chapter 27: Recursion is induction in motion
169
161
 
170
162
  - [01-natural.pl](chapter-27/01-natural.pl)
171
- - [02-list_length.pl](chapter-27/02-list_length.pl) — Structural induction and data design
172
- - [03-reverse_acc.pl](chapter-27/03-reverse_acc.pl) — Accumulators and strengthened invariants
163
+ - [02-list_length.pl](chapter-27/02-list_length.pl) — Data shapes give you the induction
164
+ - [03-reverse_acc.pl](chapter-27/03-reverse_acc.pl) — Accumulators need stronger invariants
173
165
 
174
166
  ## Chapter 28: Algebra, symmetry, and representation
175
167
 
176
168
  - [01-triangle.pl](chapter-28/01-triangle.pl) — Symmetry reduces search
177
- - [02-rectangle.pl](chapter-28/02-rectangle.pl) — Relations reveal inverse problems
178
- - [03-integer_rectangle.pl](chapter-28/03-integer_rectangle.pl)
179
- - [04-preserves_combine.pl](chapter-28/04-preserves_combine.pl) — Composition, homomorphism, and reusable laws
169
+ - [02-integer_rectangle.pl](chapter-28/02-integer_rectangle.pl) — Relations expose inverse problems
170
+ - [03-preserves_combine.pl](chapter-28/03-preserves_combine.pl) — Laws as testable relations
180
171
 
181
172
  ## Chapter 29: Search as experimental mathematics
182
173
 
183
- - [01-counterexample_to_odd_square.pl](chapter-29/01-counterexample_to_odd_square.pl) — Examples suggest; proofs compel
184
- - [02-noncommuting_pair.pl](chapter-29/02-noncommuting_pair.pl) — One counterexample has asymmetric power
174
+ - [01-counterexample_to_odd_square.pl](chapter-29/01-counterexample_to_odd_square.pl)
185
175
 
186
176
  ## Chapter 31: Testing a theory
187
177
 
188
178
  - [01-edge.pl](chapter-31/01-edge.pl) — Positive and negative observers
189
- - [02-program.pl](chapter-31/02-program.pl)
190
- - [03-double.pl](chapter-31/03-double.pl) — Properties over finite domains
179
+ - [02-double_is_even.pl](chapter-31/02-double_is_even.pl) — Properties over finite domains
191
180
 
192
181
  ## Chapter 32: Debugging by meaning, search, and proof
193
182
 
194
- - [01-eligible.pl](chapter-32/01-eligible.pl) — Follow bindings from left to right
195
- - [02-eligible-2.pl](chapter-32/02-eligible-2.pl)
196
- - [03-candidate_debug.pl](chapter-32/03-candidate_debug.pl) — Create diagnostic relations
197
- - [04-reference_square.pl](chapter-32/04-reference_square.pl) — Compare specification and implementation
183
+ - [01-age.pl](chapter-32/01-age.pl) — Follow bindings left to right
184
+ - [02-reference_square.pl](chapter-32/02-reference_square.pl) — Compare with a reference
198
185
 
199
186
  ## Chapter 33: A pattern catalog for reasoning
200
187
 
201
- - [01-assigned_badge.pl](chapter-33/01-assigned_badge.pl) — Pattern 1: Ground sentence first
202
- - [02-source_role.pl](chapter-33/02-source_role.pl) — Pattern 2: Normalize at the boundary
203
- - [03-chosen_pair.pl](chapter-33/03-chosen_pair.pl) — Pattern 3: Generate, constrain, describe
204
- - [04-path.pl](chapter-33/04-path.pl) — Pattern 4: Carry the witness
205
- - [05-unregistered.pl](chapter-33/05-unregistered.pl) — Pattern 5: Bound absence
206
- - [06-step.pl](chapter-33/06-step.pl) — Pattern 6: Explicit state transition
207
- - [07-depends.pl](chapter-33/07-depends.pl) — Pattern 7: Fixed-point closure
208
- - [08-within_limit.pl](chapter-33/08-within_limit.pl) — Pattern 8: Proof façade
209
- - [09-invalid_badge_assignment.pl](chapter-33/09-invalid_badge_assignment.pl) — Pattern 9: Integrity before inference
210
- - [10-theory_version.pl](chapter-33/10-theory_version.pl) — Pattern 10: Version the evidence boundary
188
+ - [01-source_role.pl](chapter-33/01-source_role.pl)
189
+ - [02-chosen_pair.pl](chapter-33/02-chosen_pair.pl)
190
+ - [03-unregistered.pl](chapter-33/03-unregistered.pl)
191
+ - [04-step.pl](chapter-33/04-step.pl)
192
+ - [05-depends.pl](chapter-33/05-depends.pl)
193
+ - [06-within_limit.pl](chapter-33/06-within_limit.pl)
194
+ - [07-invalid_badge_assignment.pl](chapter-33/07-invalid_badge_assignment.pl)
195
+ - [08-theory_version.pl](chapter-33/08-theory_version.pl)
211
196
 
212
197
  ## Chapter 34: Control, exceptions, and grouped solutions
213
198
 
214
199
  - [01-travel_status.pl](chapter-34/01-travel_status.pl)
215
- - [02-require_route.pl](chapter-34/02-require_route.pl)
216
- - [03-regional_total.pl](chapter-34/03-regional_total.pl)
200
+ - [02-require_route.pl](chapter-34/02-require_route.pl) — Exceptions
201
+ - [03-regional_total.pl](chapter-34/03-regional_total.pl) — Grouped solutions
217
202
 
218
203
  ## Chapter 35: Reflective terms and atomic conversion
219
204
 
@@ -223,7 +208,7 @@ node tools/extract-book-examples.mjs
223
208
 
224
209
  - [01-program.pl](chapter-36/01-program.pl)
225
210
  - [02-program-2.pl](chapter-36/02-program-2.pl)
226
- - [03-program-3.pl](chapter-36/03-program-3.pl)
211
+ - [03-program-3.pl](chapter-36/03-program-3.pl) — Operators
227
212
 
228
213
  ## Chapter 37: Streams and term I/O
229
214
 
@@ -231,7 +216,7 @@ node tools/extract-book-examples.mjs
231
216
 
232
217
  ## Chapter 38: Language and ISO profile
233
218
 
234
- - [01-city.pl](chapter-38/01-city.pl)
219
+ - [01-city.pl](chapter-38/01-city.pl) — Source text
235
220
  - [02-look_ahead.pl](chapter-38/02-look_ahead.pl) — Part 3-oriented definite clause grammars
236
221
 
237
222
  ## Chapter 39: Predicate reference
@@ -244,7 +229,6 @@ node tools/extract-book-examples.mjs
244
229
  - [06-cost.pl](chapter-39/06-cost.pl)
245
230
  - [07-message.pl](chapter-39/07-message.pl)
246
231
  - [08-task.pl](chapter-39/08-task.pl)
247
- - [09-program.pl](chapter-39/09-program.pl) — Specialized library implementation notes
248
232
 
249
233
  ## Chapter 40: Running EyeProlog: command line and corpus
250
234
 
@@ -1,5 +1,3 @@
1
1
  % From The Art of EyeProlog, Chapter 2.
2
- :- use_module(library(lists)).
3
-
4
2
  measurement(battery_1, sample(17, volts(28.4), amps(12.1))).
5
3
  route(a, d, path([a, b, d], cost(9))).
@@ -1,6 +1,4 @@
1
1
  % From The Art of EyeProlog, Chapter 3.
2
- :- use_module(library(lists)).
3
-
4
2
  eligible(Person) :-
5
3
  age(Person, Years),
6
4
  (Years >= 18),
@@ -0,0 +1,2 @@
1
+ % From The Art of EyeProlog, Chapter 3 — Deeper foundations: the Herbrand world.
2
+ ancestor(X, Z) :- parent(X, Y), ancestor(Y, Z).
@@ -1,4 +1,4 @@
1
- % From The Art of EyeProlog, Chapter 3 — Why terms denote themselves.
1
+ % From The Art of EyeProlog, Chapter 3 — Terms denote themselves.
2
2
  different(alice, bob) :- (alice \= bob).
3
3
  different(ticket(alice), ticket(bob)) :-
4
4
  (ticket(alice) \= ticket(bob)).
@@ -1,4 +1,4 @@
1
- % From The Art of EyeProlog, Chapter 3 — Quantification and visible witnesses.
1
+ % From The Art of EyeProlog, Chapter 3 — Witnesses instead of hidden objects.
2
2
  has_parent(Child, parent_of(Child)) :-
3
3
  person(Child).
4
4
 
@@ -0,0 +1,2 @@
1
+ % From The Art of EyeProlog, Chapter 3 — The occurs check.
2
+ cyclic_unification :- X = wrapper(X).
@@ -1,6 +1,4 @@
1
- % From The Art of EyeProlog, Chapter 4 — Constructing the recursive argument.
2
- :- use_module(library(lists)).
3
-
1
+ % From The Art of EyeProlog, Chapter 4 — Cycles and tabling.
4
2
  path(X, Y, [X, Y]) :- edge(X, Y).
5
3
  path(X, Z, [X | Rest]) :-
6
4
  edge(X, Y),
@@ -1,6 +1,4 @@
1
1
  % From The Art of EyeProlog, Chapter 6.
2
- :- use_module(library(lists)).
3
-
4
2
  next(X, Y) :- (Y is X + 1).
5
3
  area_rectangle(W, H, Area) :- (Area is W * H).
6
4
 
@@ -1,6 +1,4 @@
1
1
  % From The Art of EyeProlog, Chapter 6.
2
- :- use_module(library(lists)).
3
-
4
2
  square(N, Square) :-
5
3
  between(1, 10, N),
6
4
  (Square is N * N).
@@ -0,0 +1,4 @@
1
+ % From The Art of EyeProlog, Chapter 7 — Negation through recursion.
2
+ move(a, b).
3
+ move(b, a).
4
+ win(X) :- move(X, Y), tnot(win(Y)).
@@ -1,7 +1,5 @@
1
1
  % From The Art of EyeProlog, Chapter 8.
2
2
  :- use_module(library(aggregate)).
3
- :- use_module(library(lists)).
4
-
5
3
  outgoing_costs(Node, Costs) :-
6
4
  findall(Cost, edge(Node, _, Cost), Costs).
7
5
 
@@ -1,7 +1,5 @@
1
1
  % From The Art of EyeProlog, Chapter 8.
2
2
  :- use_module(library(aggregate)).
3
- :- use_module(library(lists)).
4
-
5
3
  best_route(From, To, Route, Cost) :-
6
4
  aggregate_min(
7
5
  [CandidateCost, CandidateRoute],
@@ -1,7 +1,5 @@
1
1
  % From The Art of EyeProlog, Chapter 9.
2
2
  :- use_module(library(strings)).
3
- :- use_module(library(lists)).
4
-
5
3
  normalized(Input, Words) :-
6
4
  trim(Input, Trimmed),
7
5
  lowercase(Trimmed, Lower),
@@ -1,6 +1,4 @@
1
1
  % From The Art of EyeProlog, Chapter 9.
2
- :- use_module(library(lists)).
3
-
4
2
  message(event_17, (severity(high), source(sensor_3), reading(temp, 91))).
5
3
 
6
4
  context_member((Left, _right), Member) :- context_member(Left, Member).
@@ -2,3 +2,8 @@
2
2
  invalid_probability(Disease, Probability) :-
3
3
  probability(Disease, Probability),
4
4
  (Probability > 1).
5
+
6
+ invalid_assignment(Person, Role, Other) :-
7
+ assigned(Person, Role),
8
+ incompatible_roles(Role, Other),
9
+ assigned(Person, Other).
@@ -0,0 +1,3 @@
1
+ % From The Art of EyeProlog, Chapter 13.
2
+ reach(X, Y) :- edge(X, Y).
3
+ reach(X, Z) :- edge(X, Y), reach(Y, Z).
@@ -1,5 +1,3 @@
1
1
  % From The Art of EyeProlog, Chapter 17.
2
- :- use_module(library(lists)).
3
-
4
2
  path(X, Y) :- edge(X, Y).
5
3
  path(X, Z) :- edge(X, Y), path(Y, Z).
@@ -1,6 +1,4 @@
1
- % From The Art of EyeProlog, Chapter 17 — The same relation, a different computation.
2
- :- use_module(library(lists)).
3
-
1
+ % From The Art of EyeProlog, Chapter 17 — Same meaning, different computation.
4
2
  adult(Person) :- person(Person), age(Person, Age), (Age >= 18).
5
3
 
6
4
  adult(Person) :- (Age >= 18), age(Person, Age), person(Person).
@@ -1,5 +1,3 @@
1
1
  % From The Art of EyeProlog, Chapter 17.
2
- :- use_module(library(lists)).
3
-
4
2
  % Poor control: recursion starts before one list cell is exposed.
5
3
  bad_member(X, List) :- bad_member(X, Rest), (List = [_ | Rest]).
@@ -1,4 +1,2 @@
1
- % From The Art of EyeProlog, Chapter 18 — Begin with ground sentences.
2
- :- use_module(library(lists)).
3
-
1
+ % From The Art of EyeProlog, Chapter 18 — Begin with a ground sentence.
4
2
  routeable(parcel_7, hub_north).
@@ -1,6 +1,4 @@
1
1
  % From The Art of EyeProlog, Chapter 18.
2
- :- use_module(library(lists)).
3
-
4
2
  routeable(Parcel, Hub) :-
5
3
  destination_zone(Parcel, Zone),
6
4
  serves(Hub, Zone),
@@ -1,3 +1,3 @@
1
- % From The Art of EyeProlog, Chapter 18 — Invent examples before recursion.
1
+ % From The Art of EyeProlog, Chapter 18 — Examples before recursion.
2
2
  prefix([], _).
3
3
  prefix([X | Xs], [X | Ys]) :- prefix(Xs, Ys).
@@ -1,4 +1,4 @@
1
- % From The Art of EyeProlog, Chapter 18 — Separate generate, test, and describe.
1
+ % From The Art of EyeProlog, Chapter 18 — Generate, then test.
2
2
  candidate_pair(A, B) :-
3
3
  person(A),
4
4
  person(B).
@@ -7,5 +7,3 @@ compatible_pair(A, B) :-
7
7
  candidate_pair(A, B),
8
8
  (A \= B),
9
9
  \+ conflict(A, B).
10
-
11
- answer(pair(A, B)) :- compatible_pair(A, B).
@@ -1,4 +1,4 @@
1
- % From The Art of EyeProlog, Chapter 19 — Termination needs its own argument.
1
+ % From The Art of EyeProlog, Chapter 19 — Termination needs its own measure.
2
2
  factorial(0, 1).
3
3
  factorial(N, F) :-
4
4
  (N > 0),
@@ -1,4 +1,4 @@
1
- % From The Art of EyeProlog, Chapter 19 — Integrity is not merely failure.
1
+ % From The Art of EyeProlog, Chapter 19 — Integrity is not failure.
2
2
  invalid_limits(Name, Low, High) :-
3
3
  lower_limit(Name, Low),
4
4
  upper_limit(Name, High),
@@ -1,2 +1,2 @@
1
- % From The Art of EyeProlog, Chapter 20 — Strengthen calls before adding machinery.
1
+ % From The Art of EyeProlog, Chapter 20 — Ask a better question first.
2
2
  connected(X, Y) :- path_with_nodes(X, Y, _).
@@ -1,4 +1,4 @@
1
- % From The Art of EyeProlog, Chapter 20 — Introduce helpers that express invariants.
1
+ % From The Art of EyeProlog, Chapter 20 — Name invariants with helpers.
2
2
  within_thermal_limits(Battery) :-
3
3
  temperature(Battery, T),
4
4
  temperature_limit(Max),
@@ -1,4 +1,4 @@
1
- % From The Art of EyeProlog, Chapter 20 — Move invariant work outward.
1
+ % From The Art of EyeProlog, Chapter 20 — Hoist invariant work.
2
2
  search(Request, Answer) :-
3
3
  normalized_request(Request, Normalized),
4
4
  search_normalized(Normalized, initial_state, Answer).
@@ -1,4 +1,4 @@
1
- % From The Art of EyeProlog, Chapter 21 — Substitutions accumulate.
1
+ % From The Art of EyeProlog, Chapter 21 — Bindings flow forward.
2
2
  grandparent(X, Z) :-
3
3
  parent(X, Y),
4
4
  parent(Y, Z).
@@ -1,4 +1,2 @@
1
1
  % From The Art of EyeProlog, Chapter 21.
2
- :- use_module(library(lists)).
3
-
4
2
  loop_edge(Node) :- edge(Node, Node).
@@ -1,6 +1,4 @@
1
1
  % From The Art of EyeProlog, Chapter 21 — Failure rewinds choices, not facts.
2
- :- use_module(library(lists)).
3
-
4
2
  eligible(Person) :-
5
3
  applicant(Person),
6
4
  age(Person, Age),
@@ -1,2 +1,2 @@
1
- % From The Art of EyeProlog, Chapter 21 — Variants, cycles, and tables.
1
+ % From The Art of EyeProlog, Chapter 21 — Variants and tables.
2
2
  grows(X) :- grows(wrapper(X)).
@@ -1,6 +1,4 @@
1
1
  % From The Art of EyeProlog, Chapter 22.
2
- :- use_module(library(lists)).
3
-
4
2
  tree_member(X, tree(X, _, _)).
5
3
  tree_member(X, tree(_, Left, _)) :- tree_member(X, Left).
6
4
  tree_member(X, tree(_, _, Right)) :- tree_member(X, Right).
@@ -1,4 +1,4 @@
1
- % From The Art of EyeProlog, Chapter 22 — Transforming a tree.
1
+ % From The Art of EyeProlog, Chapter 22 — Relating two trees.
2
2
  mirror(empty, empty).
3
3
  mirror(
4
4
  tree(Value, Left, Right),
@@ -1,4 +1,4 @@
1
- % From The Art of EyeProlog, Chapter 22 — A standard definite clause grammar.
1
+ % From The Art of EyeProlog, Chapter 22 — A definite clause grammar.
2
2
  sentence --> noun_phrase, verb_phrase.
3
3
 
4
4
  noun_phrase --> [the], noun.
@@ -1,4 +1,4 @@
1
- % From The Art of EyeProlog, Chapter 22 — Interpreting an expression.
1
+ % From The Art of EyeProlog, Chapter 22 — An evaluator.
2
2
  evaluate(number(N), N).
3
3
 
4
4
  evaluate(add(Left, Right), Value) :-
@@ -1,6 +1,4 @@
1
1
  % From The Art of EyeProlog, Chapter 22.
2
- :- use_module(library(lists)).
3
-
4
2
  lookup(Name, [binding(Name, Value) | _], Value).
5
3
  lookup(Name, [_ | Rest], Value) :- lookup(Name, Rest, Value).
6
4
 
@@ -1,4 +1,4 @@
1
- % From The Art of EyeProlog, Chapter 22 — Rewriting symbolic expressions.
1
+ % From The Art of EyeProlog, Chapter 22 — Rewriting.
2
2
  simplify(add(number(0), X), X).
3
3
  simplify(add(X, number(0)), X).
4
4
  simplify(multiply(number(1), X), X).
@@ -1,6 +1,4 @@
1
1
  % From The Art of EyeProlog, Chapter 23 — Unfolding and folding.
2
- :- use_module(library(lists)).
3
-
4
2
  adult(Person) :-
5
3
  recorded_age(Person, Age),
6
4
  adult_age(Age).
@@ -1,6 +1,4 @@
1
1
  % From The Art of EyeProlog, Chapter 23.
2
- :- use_module(library(lists)).
3
-
4
2
  adult(Person) :-
5
3
  recorded_age(Person, Age),
6
4
  (Age >= 18).
@@ -1,6 +1,4 @@
1
1
  % From The Art of EyeProlog, Chapter 23.
2
- :- use_module(library(lists)).
3
-
4
2
  can_board(Person) :-
5
3
  registered(Person),
6
4
  identity_checked(Person),
@@ -1,6 +1,4 @@
1
1
  % From The Art of EyeProlog, Chapter 23.
2
- :- use_module(library(lists)).
3
-
4
2
  traveler_in_good_standing(Person) :-
5
3
  registered(Person),
6
4
  identity_checked(Person),
@@ -1,3 +1,3 @@
1
- % From The Art of EyeProlog, Chapter 23.
1
+ % From The Art of EyeProlog, Chapter 23 — Specialization.
2
2
  rail_connection(From, To, Cost) :-
3
3
  connection(rail, From, To, Cost).
@@ -1,4 +1,4 @@
1
- % From The Art of EyeProlog, Chapter 23 — Accumulators and modes.
1
+ % From The Art of EyeProlog, Chapter 23 — Accumulators change modes.
2
2
  sum_numbers([], 0).
3
3
  sum_numbers([X | Xs], Sum) :-
4
4
  sum_numbers(Xs, Rest),
@@ -1,4 +1,4 @@
1
- % From The Art of EyeProlog, Chapter 24 — Generate, constrain, describe.
1
+ % From The Art of EyeProlog, Chapter 24 — Generate and constrain.
2
2
  worker(ada).
3
3
  worker(byron).
4
4
  worker(clara).
@@ -1,6 +1,5 @@
1
1
  % From The Art of EyeProlog, Chapter 24 — Optimization is search plus an order.
2
2
  :- use_module(library(aggregate)).
3
- :- use_module(library(lists)).
4
3
 
5
4
  best_plan(Request, Plan, Cost) :-
6
5
  aggregate_min(
@@ -1,6 +1,4 @@
1
- % From The Art of EyeProlog, Chapter 25 — Source and concept layers.
2
- :- use_module(library(lists)).
3
-
1
+ % From The Art of EyeProlog, Chapter 25 — Sources and concepts.
4
2
  person(ada).
5
3
  badge(b17, ada).
6
4
  badge_status(b17, active).
@@ -1,6 +1,4 @@
1
1
  % From The Art of EyeProlog, Chapter 25.
2
- :- use_module(library(lists)).
3
-
4
2
  active_badge(Person, Badge) :-
5
3
  badge(Badge, Person),
6
4
  badge_status(Badge, active).
@@ -1,4 +1,4 @@
1
- % From The Art of EyeProlog, Chapter 25 — Closed-world choice.
1
+ % From The Art of EyeProlog, Chapter 25 — The closed-world choice.
2
2
  in_good_standing(Person) :-
3
3
  person(Person),
4
4
  \+ suspended(Person).