eyeprolog 1.4.10 → 1.5.1

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 (73) hide show
  1. package/README.md +7 -0
  2. package/conformance-report.md +1 -1
  3. package/examples/bayes-diagnosis.pl +5 -5
  4. package/examples/bayes-therapy.pl +15 -7
  5. package/examples/binomial-vandermonde.pl +3 -1
  6. package/examples/book/chapter-04/01-ancestor.pl +2 -0
  7. package/examples/catalan-convolution.pl +3 -1
  8. package/examples/chart-parser.pl +3 -1
  9. package/examples/collatz-1000.pl +3 -1
  10. package/examples/continued-fraction-sqrt2.pl +3 -1
  11. package/examples/critical-path-schedule.pl +3 -0
  12. package/examples/cyclic-path.pl +2 -0
  13. package/examples/dijkstra-findall-sort.pl +1 -0
  14. package/examples/enigma1225.pl +4 -2
  15. package/examples/equality-saturation.pl +3 -0
  16. package/examples/fibonacci.pl +2 -0
  17. package/examples/fundamental-theorem-arithmetic.pl +6 -5
  18. package/examples/illegitimate-reasoning.pl +6 -6
  19. package/examples/integer-partitions.pl +2 -0
  20. package/examples/knowledge-engineering-alignment-flow.pl +7 -3
  21. package/examples/language.pl +3 -1
  22. package/examples/matrix-chain-order.pl +3 -1
  23. package/examples/modular-exponentiation.pl +2 -0
  24. package/examples/output/bayes-diagnosis.pl +4 -0
  25. package/examples/output/bayes-therapy.pl +5 -5
  26. package/examples/output/fundamental-theorem-arithmetic.pl +1 -1
  27. package/examples/output/illegitimate-reasoning.pl +4 -0
  28. package/examples/output/knowledge-engineering-alignment-flow.pl +4 -0
  29. package/examples/output/peano-arithmetic.pl +0 -2
  30. package/examples/peano-arithmetic.pl +2 -2
  31. package/examples/pell-equation.pl +3 -1
  32. package/examples/proof/bayes-diagnosis.pl +64 -0
  33. package/examples/proof/chart-parser.pl +73 -73
  34. package/examples/proof/weighted-interval-scheduling.pl +1011 -1011
  35. package/examples/service-impact.pl +3 -0
  36. package/examples/takeuchi.pl +2 -0
  37. package/examples/totient-summatory.pl +3 -1
  38. package/examples/weighted-interval-scheduling.pl +3 -1
  39. package/index.d.ts +19 -1
  40. package/package.json +1 -1
  41. package/src/cli.js +29 -7
  42. package/src/execute.js +326 -1
  43. package/src/index.js +23 -8
  44. package/src/iso.js +3 -11
  45. package/src/lib/tabling.pl +3 -3
  46. package/src/parser.js +10 -0
  47. package/src/program.js +183 -18
  48. package/src/solver.js +19 -33
  49. package/test/conformance/ISO-COMPLIANCE.md +3 -3
  50. package/test/conformance/ISO-IMPLEMENTATION-DEFINED.md +1 -1
  51. package/test/conformance/ISO-PROLOG-TEXT-EXECUTION-MATRIX.md +1 -1
  52. package/test/conformance/README.md +1 -1
  53. package/test/conformance/cases/{automatic-tabling/038_automatic_tabling.pl → explicit-tabling/038_explicit_tabling.pl} +2 -1
  54. package/test/conformance/cases/{automatic-tabling → explicit-tabling}/102_recursive_inference.pl +3 -1
  55. package/test/conformance/cases/{automatic-tabling/automatic_left_recursion_path.pl → explicit-tabling/explicit_left_recursion_path.pl} +2 -0
  56. package/test/conformance/cases/{automatic-tabling/automatic_tabling_preserves_answers.pl → explicit-tabling/explicit_tabling_preserves_answers.pl} +3 -1
  57. package/test/conformance/cases/{automatic-tabling/extra_automatic_bound_cycle.pl → explicit-tabling/extra_explicit_bound_cycle.pl} +2 -0
  58. package/test/conformance/cases/{automatic-tabling/extra_automatic_open_call_fallback.pl → explicit-tabling/extra_explicit_open_call.pl} +2 -0
  59. package/test/conformance/expected-proofs/proofs/{automatic_recursive.pl → explicit_recursive.pl} +8 -8
  60. package/test/conformance/proofs/proofs/explicit_recursive.pl +8 -0
  61. package/test/run-iso-strict.mjs +1 -1
  62. package/test/run-regression.mjs +65 -39
  63. package/the-art-of-eyeprolog.md +75 -43
  64. package/why-eyeprolog.md +12 -4
  65. package/test/conformance/proofs/proofs/automatic_recursive.pl +0 -7
  66. /package/test/conformance/expected/{automatic-tabling/038_automatic_tabling.pl → explicit-tabling/038_explicit_tabling.pl} +0 -0
  67. /package/test/conformance/expected/{automatic-tabling → explicit-tabling}/102_recursive_inference.pl +0 -0
  68. /package/test/conformance/expected/{automatic-tabling/automatic_left_recursion_path.pl → explicit-tabling/explicit_left_recursion_path.pl} +0 -0
  69. /package/test/conformance/expected/{automatic-tabling/automatic_tabling_preserves_answers.pl → explicit-tabling/explicit_tabling_preserves_answers.pl} +0 -0
  70. /package/test/conformance/expected/{automatic-tabling/extra_automatic_bound_cycle.pl → explicit-tabling/extra_explicit_bound_cycle.pl} +0 -0
  71. /package/test/conformance/expected/{automatic-tabling/extra_automatic_open_call_fallback.pl → explicit-tabling/extra_explicit_open_call.pl} +0 -0
  72. /package/test/conformance/expected-proofs/proofs/{extra_automatic_path_bound.pl → extra_explicit_path_bound.pl} +0 -0
  73. /package/test/conformance/proofs/proofs/{extra_automatic_path_bound.pl → extra_explicit_path_bound.pl} +0 -0
package/README.md CHANGED
@@ -58,6 +58,13 @@ printf 'human(socrates).\nmortal(X) :- human(X).\n' |
58
58
  npx --yes eyeprolog --proof --goal 'mortal(socrates)' -
59
59
  ```
60
60
 
61
+ ## Native forward rules (`:+`)
62
+
63
+ Normal mode executes top-level `Conclusion :+ Premise` rules natively when no explicit
64
+ `-g/--goal` is supplied. `true :+ Goal` prints answers and `false :+ Goal` emits a
65
+ `fuse/1`; JavaScript `run()` follows the same rule. Strict ISO mode disables this
66
+ extension. See [*The Art of EyeProlog*](the-art-of-eyeprolog.md) for the full semantics.
67
+
61
68
  ## Links
62
69
 
63
70
  - [The Art of EyeProlog](https://eyereasoner.github.io/eyeprolog/the-art-of-eyeprolog) — complete reference
@@ -21,10 +21,10 @@ spelling therefore changes this report even when no corpus file is added or remo
21
21
  | aggregation | 17 | 0 | 0 | 0 | 17 |
22
22
  | arithmetic | 38 | 0 | 0 | 0 | 38 |
23
23
  | atoms | 23 | 8 | 0 | 0 | 31 |
24
- | automatic-tabling | 6 | 0 | 0 | 0 | 6 |
25
24
  | builtins | 11 | 0 | 0 | 0 | 11 |
26
25
  | context | 11 | 0 | 0 | 0 | 11 |
27
26
  | control | 15 | 0 | 0 | 0 | 15 |
27
+ | explicit-tabling | 6 | 0 | 0 | 0 | 6 |
28
28
  | iso | 169 | 217 | 0 | 0 | 386 |
29
29
  | lists | 52 | 3 | 0 | 0 | 55 |
30
30
  | modules | 2 | 0 | 0 | 0 | 2 |
@@ -96,10 +96,10 @@ score_decimal(bacterialPneumonia, 0.000047879999999999996).
96
96
 
97
97
  total_score_decimal(0.0016436300000000003).
98
98
 
99
- posterior(covid19, 0.9412093962753174).
100
- posterior(influenza, 0.029203652890249024).
101
- posterior(allergicRhinitis, 0.00045630707641014084).
102
- posterior(bacterialPneumonia, 0.029130643758023392).
99
+ posterior_decimal(covid19, 0.9412093962753174).
100
+ posterior_decimal(influenza, 0.029203652890249024).
101
+ posterior_decimal(allergicRhinitis, 0.00045630707641014084).
102
+ posterior_decimal(bacterialPneumonia, 0.029130643758023392).
103
103
 
104
104
  scores(case, [
105
105
  0.0015470000000000002,
@@ -111,4 +111,4 @@ evidenceTotal(case, Total) :- total_score_decimal(Total).
111
111
  result(case, result(Disease)) :- disease(Disease).
112
112
  disease(result(Disease), Disease) :- disease(Disease).
113
113
  unnormalized(result(Disease), Score) :- score_decimal(Disease, Score).
114
- posterior(result(Disease), Posterior) :- posterior(Disease, Posterior).
114
+ posterior(result(Disease), Posterior) :- posterior_decimal(Disease, Posterior).
@@ -1,3 +1,11 @@
1
+ :- table likelihood/3.
2
+ :- table scores_for/2.
3
+ :- table score_sum/2.
4
+ :- table normalize_scores/3.
5
+ :- table disease_posterior/4.
6
+ :- table dot_product/3.
7
+ :- table best_therapy/2.
8
+
1
9
  % Memoize shared inference layers: the score vector, disease likelihood tails,
2
10
  % and expected therapy success are reused by several report relations.
3
11
  % Output declarations: host-supplied goals select the relations written to this example's golden output.
@@ -145,8 +153,8 @@ expected_success(Therapy, Expectedsuccess) :-
145
153
  success_by_disease(Therapy, Successbydisease),
146
154
  dot_product(Posteriors, Successbydisease, Expectedsuccess).
147
155
 
148
- % utility/2 turns expected success and adverse effects into a ranking score.
149
- utility(Therapy, Utility) :-
156
+ % therapy_utility/2 turns expected success and adverse effects into a ranking score.
157
+ therapy_utility(Therapy, Utility) :-
150
158
  expected_success(Therapy, Expectedsuccess),
151
159
  adverse(Therapy, Adverse),
152
160
  benefit_weight(Benefitweight),
@@ -156,12 +164,12 @@ utility(Therapy, Utility) :-
156
164
  (Utility is Benefit - Harmcost).
157
165
 
158
166
  better_of(Therapy1, Therapy2, Therapy1) :-
159
- utility(Therapy1, Utility1),
160
- utility(Therapy2, Utility2),
167
+ therapy_utility(Therapy1, Utility1),
168
+ therapy_utility(Therapy2, Utility2),
161
169
  (Utility1 >= Utility2).
162
170
  better_of(Therapy1, Therapy2, Therapy2) :-
163
- utility(Therapy1, Utility1),
164
- utility(Therapy2, Utility2),
171
+ therapy_utility(Therapy1, Utility1),
172
+ therapy_utility(Therapy2, Utility2),
165
173
  (Utility1 < Utility2).
166
174
 
167
175
  best_therapy([Therapy], Therapy).
@@ -191,7 +199,7 @@ expectedAdverse(Therapy, Adverse) :-
191
199
  adverse(Therapy, Adverse).
192
200
  utility(Therapy, Utility) :-
193
201
  therapy(Therapy),
194
- utility(Therapy, Utility).
202
+ therapy_utility(Therapy, Utility).
195
203
  recommendedTherapy(case, Best) :-
196
204
  therapies(case, Therapies),
197
205
  best_therapy(Therapies, Best).
@@ -1,6 +1,8 @@
1
1
  :- use_module(library(aggregate)).
2
2
  :- use_module(library(between), [between/3]).
3
3
 
4
+ :- table choose_step/5.
5
+
4
6
  % Binomial coefficients and Vandermonde's identity.
5
7
  %
6
8
  % choose(N,K,C) is computed by a multiplicative recurrence, then vandermonde/5 checks
@@ -8,7 +10,7 @@
8
10
  % the binomial-row prefixes shared across both sides of the identity.
9
11
  % choose_step/5 uses the multiplicative recurrence
10
12
  % C(N, I+1) = C(N, I) * (N-I) / (I+1)
11
- % and is cached automatically because row sums and identities reuse prefixes.
13
+ % and is explicitly tabled because row sums and identities reuse prefixes.
12
14
  %% goal: binomial_answer(X0, X1)
13
15
 
14
16
 
@@ -1,3 +1,5 @@
1
1
  % From The Art of EyeProlog, Chapter 4.
2
+ :- table ancestor/2.
3
+
2
4
  ancestor(X, Y) :- parent(X, Y).
3
5
  ancestor(X, Z) :- parent(X, Y), ancestor(Y, Z).
@@ -1,7 +1,9 @@
1
1
  :- use_module(library(aggregate)).
2
2
  :- use_module(library(between), [between/3]).
3
3
 
4
- % Catalan numbers by automatically tabled convolution.
4
+ :- table catalan/2.
5
+
6
+ % Catalan numbers by explicitly tabled convolution.
5
7
  %
6
8
  % catalan(N,C) sums all splits of N-1 into left and right substructures. The same
7
9
  % Catalan values appear in binary tree shapes, parenthesizations, and polygon
@@ -1,7 +1,9 @@
1
1
  :- use_module(library(lists)).
2
2
  :- use_module(library(iso_ext)).
3
3
 
4
- % A tiny automatically tabled chart parser for a context-free grammar.
4
+ :- table span/4.
5
+
6
+ % A tiny explicitly tabled chart parser for a context-free grammar.
5
7
  %
6
8
  % span(Sentence, Category, Start, End) is the dynamic-programming chart item:
7
9
  % Category covers a half-open token interval. Memoizing span/4 turns recursive
@@ -1,5 +1,7 @@
1
1
  :- use_module(library(between), [between/3]).
2
2
 
3
+ :- table collatz/2.
4
+
3
5
  % Collatz conjecture suite translated from Eyeling's examples/collatz-1000.n3.
4
6
  % It enumerates starts N = 1000, 999, ..., 1 by deriving N = 1000 - N0
5
7
  % from a repeat relation, then querys each full trajectory.
@@ -8,7 +10,7 @@
8
10
  % https://raw.githubusercontent.com/eyereasoner/eyeling/refs/heads/main/examples/collatz-1000.n3
9
11
 
10
12
  % Output declarations: host-supplied goals select the relations written to this example's golden output.
11
- % Automatic tabling caches shared suffix trajectories so the 1000 starts do not recompute
13
+ % Explicit tabling caches shared suffix trajectories so the 1000 starts do not recompute
12
14
  % the same Collatz tails hundreds of times.
13
15
  %% goal: collatzTrajectory(X0, X1)
14
16
 
@@ -1,7 +1,9 @@
1
1
  :- use_module(library(aggregate)).
2
2
  :- use_module(library(between), [between/3]).
3
3
 
4
- % Convergents of sqrt(2) by automatically tabled recurrence.
4
+ :- table conv/3.
5
+
6
+ % Convergents of sqrt(2) by explicitly tabled recurrence.
5
7
  %
6
8
  % conv(N, P, Q) gives the Nth numerator/denominator pair for [1; 2, 2, ...].
7
9
  % Because each convergent depends on the previous two, memoization avoids the
@@ -1,5 +1,8 @@
1
1
  :- use_module(library(aggregate)).
2
2
 
3
+ :- table earliest_start/2.
4
+ :- table finish_time/2.
5
+
3
6
  % Critical-path scheduling for a small project network.
4
7
  %
5
8
  % earliest_start/2 is the maximum finish time over all predecessors; finish_time/2
@@ -1,3 +1,5 @@
1
+ :- table path/2.
2
+
1
3
  % Cyclic transitive closure.
2
4
  %
3
5
  % The graph deliberately contains the directed cycle a -> b -> c -> d -> a. The
@@ -1,4 +1,5 @@
1
1
  :- use_module(library(lists)).
2
+ :- table edge/3.
2
3
 
3
4
  % Eyelet-inspired Dijkstra example using findall/3 and sort/2.
4
5
  % The priority queue is represented as sorted list entries [Cost, Node | Path].
@@ -1,13 +1,15 @@
1
1
  :- use_module(library(aggregate)).
2
2
  :- use_module(library(lists)).
3
3
 
4
+ :- table generator/2.
5
+
4
6
  % New Scientist puzzle Enigma 1225
5
7
  % Original code from https://www.sciencedirect.com/science/article/pii/S0898122106002057
6
8
  %
7
9
  % The maximum is retained in one pass with aggregate_max/5. The recursive
8
10
  % helpers below are deterministic in the modes used by square/5; their cuts
9
- % make that operational contract explicit and keep automatic tabling for the
10
- % genuinely generative partition relation only.
11
+ % make that operational contract explicit; the genuinely generative partition
12
+ % relation opts into tabling with an explicit table declaration.
11
13
 
12
14
  enigma1225(Size, [Permutation, Board, Max]) :-
13
15
  aggregate_max(Total, board(M, Perm),
@@ -2,6 +2,9 @@
2
2
  :- use_module(library(between), [between/3]).
3
3
  :- use_module(library(lists)).
4
4
  :- use_module(library(iso_ext)).
5
+ :- table rewrite_anywhere/2.
6
+ :- table equivalent_at_depth/3.
7
+ :- table expr_cost/2.
5
8
 
6
9
  % Bounded equality saturation over tiny arithmetic expression terms.
7
10
  %
@@ -1,3 +1,5 @@
1
+ :- table fib_pair/3.
2
+
1
3
  % Fibonacci numbers by fast doubling.
2
4
  %
3
5
  % The public fibonacci/2 relation is bounded by fib_case/1 facts, while fib_pair/3
@@ -1,5 +1,6 @@
1
1
  :- use_module(library(primes)).
2
2
  :- use_module(library(lists)).
3
+ :- table factor_smallest/2.
3
4
 
4
5
  % Adapted from Eyeling's fundamental-theorem-arithmetic.n3.
5
6
  % Compute a prime factorization by repeated smallest-divisor decomposition,
@@ -72,9 +73,9 @@ factor_largest(N, Factors) :-
72
73
  factor_smallest(N, Smallest),
73
74
  reverse(Smallest, Factors).
74
75
 
75
- product([], 1).
76
- product([X|Rest], P) :-
77
- product(Rest, P0),
76
+ factor_product([], 1).
77
+ factor_product([X|Rest], P) :-
78
+ factor_product(Rest, P0),
78
79
  (P is X * P0).
79
80
 
80
81
  all_expected_primes(true) :-
@@ -97,7 +98,7 @@ factorsLargest(case, Factors) :-
97
98
  product(case, Product) :-
98
99
  case(fta, N),
99
100
  factor_smallest(N, Factors),
100
- product(Factors, Product).
101
+ factor_product(Factors, Product).
101
102
 
102
103
  expectedFactorsMatched(case, true) :-
103
104
  case(fta, N),
@@ -107,7 +108,7 @@ expectedFactorsMatched(case, true) :-
107
108
  productReconstructsInput(case, true) :-
108
109
  case(fta, N),
109
110
  factor_smallest(N, Factors),
110
- product(Factors, N).
111
+ factor_product(Factors, N).
111
112
 
112
113
  distinctPrimeCount(case, 4) :-
113
114
  all_expected_primes(true).
@@ -27,7 +27,7 @@
27
27
  :- discontiguous(implication/3).
28
28
  :- discontiguous(observed/2).
29
29
  :- discontiguous(concludes/2).
30
- :- discontiguous(reason/2).
30
+ :- discontiguous(reason_fact/2).
31
31
 
32
32
  % Program structure: facts set up the scenario, and rules derive the queried conclusions.
33
33
  argument(arg_affirming_consequent).
@@ -88,14 +88,14 @@ fallacy(A, false_dilemma) :-
88
88
  omitted_alternative(A, _),
89
89
  concludes(A, _).
90
90
 
91
- reason(arg_affirming_consequent, "observing the consequent does not prove the antecedent").
92
- reason(arg_denying_antecedent, "denying the antecedent does not disprove the consequent").
93
- reason(arg_hasty_generalization, "sample size is below the threshold for a universal conclusion").
94
- reason(arg_false_dilemma, "a relevant alternative is omitted").
91
+ reason_fact(arg_affirming_consequent, "observing the consequent does not prove the antecedent").
92
+ reason_fact(arg_denying_antecedent, "denying the antecedent does not disprove the consequent").
93
+ reason_fact(arg_hasty_generalization, "sample size is below the threshold for a universal conclusion").
94
+ reason_fact(arg_false_dilemma, "a relevant alternative is omitted").
95
95
 
96
96
  type(A, illegitimate_reasoning) :- fallacy(A, _).
97
97
  conclusion(A, C) :- fallacy(A, _), concludes(A, C).
98
- reason(A, R) :- fallacy(A, _), reason(A, R).
98
+ reason(A, R) :- fallacy(A, _), reason_fact(A, R).
99
99
  sampleSize(A, N) :- fallacy(A, hasty_generalization), sample_size(A, N).
100
100
  requiredSampleSize(A, Min) :- fallacy(A, hasty_generalization), required_sample_size(A, Min).
101
101
  omittedAlternative(A, Alt) :- fallacy(A, false_dilemma), omitted_alternative(A, Alt).
@@ -1,6 +1,8 @@
1
1
  :- use_module(library(aggregate)).
2
2
  :- use_module(library(between), [between/3]).
3
3
 
4
+ :- table partitions/3.
5
+
4
6
  % Integer partition counts by tabled dynamic programming.
5
7
  %
6
8
  % partitions(N, K, Count) counts unordered sums of N using parts no larger than K.
@@ -29,8 +29,8 @@ sub_property(temperature_celsius, sosa_hasSimpleResult).
29
29
  sub_property(in_flow, fpv_hasFlowStep).
30
30
  equivalent_property(observed_feature, sosa_hasFeatureOfInterest).
31
31
 
32
- type(msg1, local_observation).
33
- type(probe7, temperature_probe).
32
+ base_type(msg1, local_observation).
33
+ base_type(probe7, temperature_probe).
34
34
  triple(msg1, observed_by, probe7).
35
35
  triple(msg1, observed_at, "2026-06-17T12:34:56Z").
36
36
  triple(msg1, temperature_celsius, 18.6).
@@ -38,7 +38,11 @@ triple(msg1, observed_feature, platform_b).
38
38
  triple(msg1, in_flow, ingest_step).
39
39
 
40
40
  % Generic alignment rules.
41
- type(Thing, Super) :- type(Thing, Class), sub_class(Class, Super).
41
+ type(Thing, Class) :- base_type(Thing, Class).
42
+ type(Thing, Super) :- base_type(Thing, Class), sub_class_of(Class, Super).
43
+
44
+ sub_class_of(Class, Super) :- sub_class(Class, Super).
45
+ sub_class_of(Class, Super) :- sub_class(Class, Middle), sub_class_of(Middle, Super).
42
46
  target_fact(Subject, Superpredicate, Object) :- triple(Subject, Predicate, Object), sub_property(Predicate, Superpredicate).
43
47
  target_fact(Subject, Targetpredicate, Object) :- triple(Subject, Predicate, Object), equivalent_property(Predicate, Targetpredicate).
44
48
  target_fact(Subject, Sourcepredicate, Object) :- triple(Subject, Predicate, Object), equivalent_property(Sourcepredicate, Predicate).
@@ -1,9 +1,11 @@
1
+ :- table path/2.
2
+
1
3
  % EyeProlog language-identity example.
2
4
  %
3
5
  % This file intentionally uses the modern EyeProlog surface syntax:
4
6
  % - `.pl` source files instead of Prolog `.pl` files
5
7
  % - ISO Prolog-style uppercase variables
6
- % - automatic tabling for recursive predicates
8
+ % - explicit `table/1` declarations for tabled predicates
7
9
  % - quoted angle-bracket atoms for web-shaped identifiers
8
10
 
9
11
  %% goal: path(X0, X1)
@@ -3,7 +3,9 @@
3
3
  :- use_module(library(lists)).
4
4
  :- use_module(library(iso_ext)).
5
5
 
6
- % Matrix-chain multiplication order by automatically tabled interval dynamic programming.
6
+ :- table cost/3.
7
+
8
+ % Matrix-chain multiplication order by explicitly tabled interval dynamic programming.
7
9
  %
8
10
  % cost(I, J, Cost) is the minimum scalar multiplication cost for matrices I..J.
9
11
  % best_split/3 records which split obtains that cost, and parenthesization/3
@@ -1,3 +1,5 @@
1
+ :- table pow_mod/4.
2
+
1
3
  % Modular exponentiation by repeated squaring.
2
4
  %
3
5
  % pow_mod(Base, Exp, Modulus, Result) uses the even/odd exponent split, giving
@@ -11,3 +11,7 @@ unnormalized(result(covid19), 0.0015470000000000002).
11
11
  unnormalized(result(influenza), 0.000048000000000000015).
12
12
  unnormalized(result(allergicRhinitis), 7.499999999999999e-7).
13
13
  unnormalized(result(bacterialPneumonia), 0.000047879999999999996).
14
+ posterior(result(covid19), 0.9412093962753174).
15
+ posterior(result(influenza), 0.029203652890249024).
16
+ posterior(result(allergicRhinitis), 0.00045630707641014084).
17
+ posterior(result(bacterialPneumonia), 0.029130643758023392).
@@ -1,8 +1,3 @@
1
- utility(paxlovid, 3.5851740117076503).
2
- utility(oseltamivir, 2.6114101258814744).
3
- utility(antihistamine, 0.91268919364852963).
4
- utility(antibiotic, 0.89952579796093612).
5
- utility(supportiveCare, 2.8851195397013814).
6
1
  scores(case, [0.0092820000000000021, 0.008208, 0.00012824999999999997, 0.00156408]).
7
2
  evidenceTotal(case, 0.019182330000000004).
8
3
  posteriors(case, [0.48388282341092037, 0.42789379600913957, 0.0066858405626428041, 0.081537540017297155]).
@@ -20,4 +15,9 @@ expectedAdverse(oseltamivir, 0.08).
20
15
  expectedAdverse(antihistamine, 0.03).
21
16
  expectedAdverse(antibiotic, 0.07).
22
17
  expectedAdverse(supportiveCare, 0.01).
18
+ utility(paxlovid, 3.5851740117076503).
19
+ utility(oseltamivir, 2.6114101258814744).
20
+ utility(antihistamine, 0.91268919364852963).
21
+ utility(antibiotic, 0.89952579796093612).
22
+ utility(supportiveCare, 2.8851195397013814).
23
23
  recommendedTherapy(case, paxlovid).
@@ -1,7 +1,7 @@
1
- product(case, 202692987).
2
1
  n(case, 202692987).
3
2
  factorsSmallest(case, [3, 3, 7, 829, 3881]).
4
3
  factorsLargest(case, [3881, 829, 7, 3, 3]).
4
+ product(case, 202692987).
5
5
  expectedFactorsMatched(case, true).
6
6
  productReconstructsInput(case, true).
7
7
  distinctPrimeCount(case, 4).
@@ -10,6 +10,10 @@ conclusion(arg_affirming_consequent, rain).
10
10
  conclusion(arg_denying_antecedent, neg(door_opens)).
11
11
  conclusion(arg_hasty_generalization, all(crows, black)).
12
12
  conclusion(arg_false_dilemma, approve_now).
13
+ reason(arg_affirming_consequent, "observing the consequent does not prove the antecedent").
14
+ reason(arg_denying_antecedent, "denying the antecedent does not disprove the consequent").
15
+ reason(arg_hasty_generalization, "sample size is below the threshold for a universal conclusion").
16
+ reason(arg_false_dilemma, "a relevant alternative is omitted").
13
17
  sampleSize(arg_hasty_generalization, 3).
14
18
  requiredSampleSize(arg_hasty_generalization, 30).
15
19
  omittedAlternative(arg_false_dilemma, revise_proposal).
@@ -1,3 +1,7 @@
1
+ type(msg1, local_observation).
2
+ type(probe7, temperature_probe).
3
+ type(msg1, sosa_observation).
4
+ type(probe7, sosa_sensor).
1
5
  target_fact(msg1, sosa_madeBySensor, probe7).
2
6
  target_fact(msg1, sosa_resultTime, "2026-06-17T12:34:56Z").
3
7
  target_fact(msg1, sosa_hasSimpleResult, 18.6).
@@ -1,3 +1 @@
1
- factorial(0, s(0)).
2
- factorial(s(0), s(0)).
3
1
  factorial(s(s(s(s(s(0))))), s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(0))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))).
@@ -20,7 +20,7 @@ peano_multiply(A, s(B), C) :-
20
20
  peano_multiply(A, B, D),
21
21
  peano_add(A, D, C).
22
22
 
23
- factorial(A, B) :-
23
+ factorial_value(A, B) :-
24
24
  fac(A, s(0), B).
25
25
 
26
26
  fac(0, A, A).
@@ -31,4 +31,4 @@ fac(s(A), B, C) :-
31
31
  factorial(B, C) :-
32
32
  peano_multiply(s(0), s(s(0)), A),
33
33
  peano_add(A, s(s(s(0))), B),
34
- factorial(B, C).
34
+ factorial_value(B, C).
@@ -1,7 +1,9 @@
1
1
  :- use_module(library(aggregate)).
2
2
  :- use_module(library(between), [between/3]).
3
3
 
4
- % Pell equation x^2 - 2y^2 = 1 by automatically tabled recurrence.
4
+ :- table pell/3.
5
+
6
+ % Pell equation x^2 - 2y^2 = 1 by explicitly tabled recurrence.
5
7
  %
6
8
  % The fundamental solution (3,2) induces a linear recurrence for all positive
7
9
  % solutions of x^2 - 2y^2 = 1. The example querys later solutions and also
@@ -206,3 +206,67 @@ why(
206
206
  )
207
207
  ).
208
208
 
209
+ posterior(result(covid19), 0.9412093962753174).
210
+ why(
211
+ posterior(result(covid19), 0.9412093962753174),
212
+ proof(
213
+ goal(posterior(result(covid19), 0.9412093962753174)),
214
+ by(rule("bayes-diagnosis.pl", clause(50))),
215
+ bindings([binding("Disease", covid19), binding("Posterior", 0.9412093962753174)]),
216
+ uses([
217
+ proof(
218
+ goal(posterior_decimal(covid19, 0.9412093962753174)),
219
+ by(fact("bayes-diagnosis.pl", clause(41)))
220
+ )
221
+ ])
222
+ )
223
+ ).
224
+
225
+ posterior(result(influenza), 0.029203652890249024).
226
+ why(
227
+ posterior(result(influenza), 0.029203652890249024),
228
+ proof(
229
+ goal(posterior(result(influenza), 0.029203652890249024)),
230
+ by(rule("bayes-diagnosis.pl", clause(50))),
231
+ bindings([binding("Disease", influenza), binding("Posterior", 0.029203652890249024)]),
232
+ uses([
233
+ proof(
234
+ goal(posterior_decimal(influenza, 0.029203652890249024)),
235
+ by(fact("bayes-diagnosis.pl", clause(42)))
236
+ )
237
+ ])
238
+ )
239
+ ).
240
+
241
+ posterior(result(allergicRhinitis), 0.00045630707641014084).
242
+ why(
243
+ posterior(result(allergicRhinitis), 0.00045630707641014084),
244
+ proof(
245
+ goal(posterior(result(allergicRhinitis), 0.00045630707641014084)),
246
+ by(rule("bayes-diagnosis.pl", clause(50))),
247
+ bindings([binding("Disease", allergicRhinitis), binding("Posterior", 0.00045630707641014084)]),
248
+ uses([
249
+ proof(
250
+ goal(posterior_decimal(allergicRhinitis, 0.00045630707641014084)),
251
+ by(fact("bayes-diagnosis.pl", clause(43)))
252
+ )
253
+ ])
254
+ )
255
+ ).
256
+
257
+ posterior(result(bacterialPneumonia), 0.029130643758023392).
258
+ why(
259
+ posterior(result(bacterialPneumonia), 0.029130643758023392),
260
+ proof(
261
+ goal(posterior(result(bacterialPneumonia), 0.029130643758023392)),
262
+ by(rule("bayes-diagnosis.pl", clause(50))),
263
+ bindings([binding("Disease", bacterialPneumonia), binding("Posterior", 0.029130643758023392)]),
264
+ uses([
265
+ proof(
266
+ goal(posterior_decimal(bacterialPneumonia, 0.029130643758023392)),
267
+ by(fact("bayes-diagnosis.pl", clause(44)))
268
+ )
269
+ ])
270
+ )
271
+ ).
272
+