eyeprolog 1.6.12 → 1.6.13

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 (129) hide show
  1. package/examples/proof/abstract-interpretation.pl +146 -0
  2. package/examples/proof/ackermann.pl +296 -0
  3. package/examples/proof/alignment-demo.pl +196 -0
  4. package/examples/proof/allen-interval-calculus.pl +1271 -0
  5. package/examples/proof/auroracare.pl +954 -0
  6. package/examples/proof/basic-monadic.pl +37176 -0
  7. package/examples/proof/bayes-therapy.pl +1349 -0
  8. package/examples/proof/bench.pl +2802 -0
  9. package/examples/proof/binomial-vandermonde.pl +983 -0
  10. package/examples/proof/blocks-world-planning.pl +471 -0
  11. package/examples/proof/bmi.pl +386 -0
  12. package/examples/proof/braking-safety-worlds.pl +508 -0
  13. package/examples/proof/buck-converter-design.pl +179 -0
  14. package/examples/proof/bulk-stream-write.pl +3 -0
  15. package/examples/proof/collatz-1000.pl +43784 -0
  16. package/examples/proof/competitive-enzyme-kinetics.pl +167 -0
  17. package/examples/proof/complex.pl +514 -0
  18. package/examples/proof/context-schema-audit.pl +374 -0
  19. package/examples/proof/continued-fraction-sqrt2.pl +476 -0
  20. package/examples/proof/control-system.pl +137 -0
  21. package/examples/proof/critical-path-schedule.pl +491 -0
  22. package/examples/proof/cross-organization-data-sharing.pl +732 -0
  23. package/examples/proof/cyclic-path.pl +44 -0
  24. package/examples/proof/dairy-energy-balance.pl +290 -0
  25. package/examples/proof/dcg-expression-language.pl +157 -0
  26. package/examples/proof/deep-taxonomy-10.pl +185 -0
  27. package/examples/proof/deep-taxonomy-100.pl +365 -0
  28. package/examples/proof/deep-taxonomy-1000.pl +163 -0
  29. package/examples/proof/deep-taxonomy-10000.pl +163 -0
  30. package/examples/proof/deep-taxonomy-100000.pl +163 -0
  31. package/examples/proof/delfour.pl +1615 -0
  32. package/examples/proof/dijkstra-findall-sort.pl +354 -0
  33. package/examples/proof/dijkstra-risk-path.pl +820 -0
  34. package/examples/proof/dijkstra.pl +753 -0
  35. package/examples/proof/dining-philosophers.pl +2663 -0
  36. package/examples/proof/donald-gerald-robert.pl +311 -0
  37. package/examples/proof/dpv-odrl-purpose-mapping.pl +1189 -0
  38. package/examples/proof/drone-corridor-planner.pl +2365 -0
  39. package/examples/proof/easter-computus.pl +1406 -0
  40. package/examples/proof/eulerian-path.pl +457 -0
  41. package/examples/proof/ev-range-worlds.pl +508 -0
  42. package/examples/proof/exoplanet-validation-worlds.pl +397 -0
  43. package/examples/proof/explainable-ev-depot-configuration.pl +313 -0
  44. package/examples/proof/family-cousins.pl +920 -0
  45. package/examples/proof/fast-fourier-transform.pl +5045 -0
  46. package/examples/proof/fastpow.pl +769 -0
  47. package/examples/proof/fft8-numeric.pl +685 -0
  48. package/examples/proof/fibonacci.pl +1425 -0
  49. package/examples/proof/field-nitrogen-balance.pl +320 -0
  50. package/examples/proof/flandor.pl +533 -0
  51. package/examples/proof/fundamental-theorem-arithmetic.pl +245 -0
  52. package/examples/proof/gd-step-certified.pl +1717 -0
  53. package/examples/proof/goldbach.pl +1135 -0
  54. package/examples/proof/gps.pl +627 -0
  55. package/examples/proof/graph.pl +105 -0
  56. package/examples/proof/gray-code-counter.pl +355 -0
  57. package/examples/proof/hamiltonian-path.pl +3373 -0
  58. package/examples/proof/hamming-code.pl +232 -0
  59. package/examples/proof/heron-theorem.pl +79 -0
  60. package/examples/proof/http-client.pl +0 -0
  61. package/examples/proof/illegitimate-reasoning.pl +220 -0
  62. package/examples/proof/integer-partitions.pl +1642 -0
  63. package/examples/proof/iso-atomic-conversion.pl +73 -0
  64. package/examples/proof/knowledge-engineering-alignment-flow.pl +200 -0
  65. package/examples/proof/knuth-bendix-completion.pl +290 -0
  66. package/examples/proof/law-of-cosines.pl +71 -0
  67. package/examples/proof/least-squares-regression.pl +342 -0
  68. package/examples/proof/lee.pl +637 -0
  69. package/examples/proof/lldm.pl +581 -0
  70. package/examples/proof/manufacturing-quality-control.pl +181 -0
  71. package/examples/proof/map-four-color-search.pl +796 -0
  72. package/examples/proof/markov-logic-network.pl +405 -0
  73. package/examples/proof/matrix-chain-order.pl +164 -0
  74. package/examples/proof/matrix-noncommutativity.pl +183 -0
  75. package/examples/proof/microgrid-dispatch.pl +164 -0
  76. package/examples/proof/missionaries-cannibals.pl +428 -0
  77. package/examples/proof/modular-exponentiation.pl +838 -0
  78. package/examples/proof/monkey-bananas.pl +278 -0
  79. package/examples/proof/network-sla.pl +100 -0
  80. package/examples/proof/newton-raphson.pl +520 -0
  81. package/examples/proof/observability-log-correlation.pl +1061 -0
  82. package/examples/proof/odrl-dpv-fpv-trust-flow.pl +1366 -0
  83. package/examples/proof/odrl-dpv-healthcare-risk-ranked.pl +488 -0
  84. package/examples/proof/odrl-dpv-risk-ranked.pl +637 -0
  85. package/examples/proof/odrl-policy-advanced.pl +705 -0
  86. package/examples/proof/odrl-policy-reasoning.pl +1423 -0
  87. package/examples/proof/odrl-policy.pl +103 -0
  88. package/examples/proof/operational-incident-response.pl +435 -0
  89. package/examples/proof/orbital-transfer-design.pl +288 -0
  90. package/examples/proof/path-discovery.pl +502 -0
  91. package/examples/proof/peano-arithmetic.pl +910 -0
  92. package/examples/proof/peano-calculus.pl +294 -0
  93. package/examples/proof/pell-equation.pl +295 -0
  94. package/examples/proof/pendulum-period.pl +97 -0
  95. package/examples/proof/pi.pl +3 -0
  96. package/examples/proof/pointer-analysis.pl +94 -0
  97. package/examples/proof/polynomial.pl +2487 -0
  98. package/examples/proof/portable-library-overlap.pl +6 -0
  99. package/examples/proof/quadratic-formula.pl +159 -0
  100. package/examples/proof/quine-mccluskey.pl +914 -0
  101. package/examples/proof/radioactive-decay.pl +104 -0
  102. package/examples/proof/rdf12-annotated-claims.pl +263 -0
  103. package/examples/proof/register-allocation.pl +120 -0
  104. package/examples/proof/relational-cube-lookup.pl +15867 -0
  105. package/examples/proof/riemann-hypothesis.pl +148 -0
  106. package/examples/proof/sat-solver-dpll.pl +226 -0
  107. package/examples/proof/scientific-evidence-graph.pl +681 -0
  108. package/examples/proof/send-more-money.pl +252 -0
  109. package/examples/proof/service-impact.pl +151 -0
  110. package/examples/proof/shoelace-polygon-area.pl +161 -0
  111. package/examples/proof/skolem-functions.pl +128 -0
  112. package/examples/proof/statistics-summary.pl +250 -0
  113. package/examples/proof/stirling-bell-numbers.pl +125 -0
  114. package/examples/proof/superdense-coding.pl +118 -0
  115. package/examples/proof/symbiotic-knowledge-graph.pl +1569 -0
  116. package/examples/proof/truth-maintenance-system.pl +466 -0
  117. package/examples/proof/turing.pl +1183 -0
  118. package/examples/proof/type-inference.pl +267 -0
  119. package/examples/proof/vector-similarity.pl +163 -0
  120. package/examples/proof/vulnerability-impact.pl +180 -0
  121. package/examples/proof/wolf-goat-cabbage.pl +339 -0
  122. package/examples/proof/zebra.pl +176 -0
  123. package/package.json +1 -1
  124. package/src/check-proof.js +159 -11
  125. package/test/conformance/NEUMERKEL-LATEST.md +3 -3
  126. package/test/regression/cases-white-box.mjs +38 -0
  127. package/test/run-examples.mjs +7 -111
  128. package/test/run-proof-checking.mjs +28 -5
  129. package/the-art-of-eyeprolog.md +4 -2
@@ -0,0 +1,128 @@
1
+ type(skolem_observation(alice, glucose), observation).
2
+ type(skolem_observation(alice, cholesterol), observation).
3
+ type(skolem_observation(bob, glucose), observation).
4
+ type(skolem_alert(alice, glucose), highGlucoseAlert).
5
+ patient(skolem_observation(alice, glucose), alice).
6
+ patient(skolem_observation(alice, cholesterol), alice).
7
+ patient(skolem_observation(bob, glucose), bob).
8
+ test(skolem_observation(alice, glucose), glucose).
9
+ test(skolem_observation(alice, cholesterol), cholesterol).
10
+ test(skolem_observation(bob, glucose), glucose).
11
+ value(skolem_observation(alice, glucose), 6.8).
12
+ value(skolem_observation(alice, cholesterol), 4.2).
13
+ value(skolem_observation(bob, glucose), 5.1).
14
+ about(skolem_alert(alice, glucose), skolem_observation(alice, glucose)).
15
+ sameInputsSameId(skolemDemo, true).
16
+ noObservationClash(skolemDemo, true).
17
+
18
+ clause(1, test_result(alice, glucose, 6.8), true).
19
+ clause(2, test_result(alice, cholesterol, 4.2), true).
20
+ clause(3, test_result(bob, glucose, 5.1), true).
21
+ clause(4,
22
+ high_glucose(var('Patient')),
23
+ (test_result(var('Patient'), glucose, var('Value')), var('Value') > 6.0)).
24
+ clause(6,
25
+ type(skolem_observation(var('Patient'), var('Test')), observation),
26
+ test_result(var('Patient'), var('Test'), anonymous(1))).
27
+ clause(7,
28
+ patient(skolem_observation(var('Patient'), var('Test')), var('Patient')),
29
+ test_result(var('Patient'), var('Test'), anonymous(1))).
30
+ clause(8,
31
+ test(skolem_observation(var('Patient'), var('Test')), var('Test')),
32
+ test_result(var('Patient'), var('Test'), anonymous(1))).
33
+ clause(9,
34
+ value(skolem_observation(var('Patient'), var('Test')), var('Value')),
35
+ test_result(var('Patient'), var('Test'), var('Value'))).
36
+ clause(10,
37
+ type(skolem_alert(var('Patient'), glucose), highGlucoseAlert),
38
+ high_glucose(var('Patient'))).
39
+ clause(11,
40
+ about(skolem_alert(var('Patient'), glucose), skolem_observation(var('Patient'), glucose)),
41
+ high_glucose(var('Patient'))).
42
+ clause(12,
43
+ sameInputsSameId(skolemDemo, true),
44
+ skolem_observation(alice, glucose) = skolem_observation(alice, glucose)).
45
+ clause(13,
46
+ noObservationClash(skolemDemo, true),
47
+ (skolem_observation(alice, glucose) \= skolem_observation(alice, cholesterol),
48
+ skolem_observation(alice, glucose) \= skolem_observation(bob, glucose))).
49
+
50
+ step(type(skolem_observation(alice, glucose), observation),
51
+ rule(6),
52
+ ['Patient' = alice, 'Test' = glucose],
53
+ [test_result(alice, glucose, 6.8)]).
54
+ step(test_result(alice, glucose, 6.8), fact(1), [], []).
55
+ step(type(skolem_observation(alice, cholesterol), observation),
56
+ rule(6),
57
+ ['Patient' = alice, 'Test' = cholesterol],
58
+ [test_result(alice, cholesterol, 4.2)]).
59
+ step(test_result(alice, cholesterol, 4.2), fact(2), [], []).
60
+ step(type(skolem_observation(bob, glucose), observation),
61
+ rule(6),
62
+ ['Patient' = bob, 'Test' = glucose],
63
+ [test_result(bob, glucose, 5.1)]).
64
+ step(test_result(bob, glucose, 5.1), fact(3), [], []).
65
+ step(type(skolem_alert(alice, glucose), highGlucoseAlert),
66
+ rule(10),
67
+ ['Patient' = alice],
68
+ [high_glucose(alice)]).
69
+ step(high_glucose(alice),
70
+ rule(4),
71
+ ['Patient' = alice, 'Value' = 6.8],
72
+ [test_result(alice, glucose, 6.8), 6.8 > 6.0]).
73
+ step(6.8 > 6.0, builtin, [], []).
74
+ step(patient(skolem_observation(alice, glucose), alice),
75
+ rule(7),
76
+ ['Patient' = alice, 'Test' = glucose],
77
+ [test_result(alice, glucose, 6.8)]).
78
+ step(patient(skolem_observation(alice, cholesterol), alice),
79
+ rule(7),
80
+ ['Patient' = alice, 'Test' = cholesterol],
81
+ [test_result(alice, cholesterol, 4.2)]).
82
+ step(patient(skolem_observation(bob, glucose), bob),
83
+ rule(7),
84
+ ['Patient' = bob, 'Test' = glucose],
85
+ [test_result(bob, glucose, 5.1)]).
86
+ step(test(skolem_observation(alice, glucose), glucose),
87
+ rule(8),
88
+ ['Patient' = alice, 'Test' = glucose],
89
+ [test_result(alice, glucose, 6.8)]).
90
+ step(test(skolem_observation(alice, cholesterol), cholesterol),
91
+ rule(8),
92
+ ['Patient' = alice, 'Test' = cholesterol],
93
+ [test_result(alice, cholesterol, 4.2)]).
94
+ step(test(skolem_observation(bob, glucose), glucose),
95
+ rule(8),
96
+ ['Patient' = bob, 'Test' = glucose],
97
+ [test_result(bob, glucose, 5.1)]).
98
+ step(value(skolem_observation(alice, glucose), 6.8),
99
+ rule(9),
100
+ ['Patient' = alice, 'Test' = glucose, 'Value' = 6.8],
101
+ [test_result(alice, glucose, 6.8)]).
102
+ step(value(skolem_observation(alice, cholesterol), 4.2),
103
+ rule(9),
104
+ ['Patient' = alice, 'Test' = cholesterol, 'Value' = 4.2],
105
+ [test_result(alice, cholesterol, 4.2)]).
106
+ step(value(skolem_observation(bob, glucose), 5.1),
107
+ rule(9),
108
+ ['Patient' = bob, 'Test' = glucose, 'Value' = 5.1],
109
+ [test_result(bob, glucose, 5.1)]).
110
+ step(about(skolem_alert(alice, glucose), skolem_observation(alice, glucose)),
111
+ rule(11),
112
+ ['Patient' = alice],
113
+ [high_glucose(alice)]).
114
+ step(sameInputsSameId(skolemDemo, true),
115
+ rule(12),
116
+ [],
117
+ [skolem_observation(alice, glucose) = skolem_observation(alice, glucose)]).
118
+ step(skolem_observation(alice, glucose) = skolem_observation(alice, glucose), builtin, [], []).
119
+ step(noObservationClash(skolemDemo, true),
120
+ rule(13),
121
+ [],
122
+ [skolem_observation(alice, glucose) \= skolem_observation(alice, cholesterol),
123
+ skolem_observation(alice, glucose) \= skolem_observation(bob, glucose)]).
124
+ step(skolem_observation(alice, glucose) \= skolem_observation(alice, cholesterol),
125
+ builtin,
126
+ [],
127
+ []).
128
+ step(skolem_observation(alice, glucose) \= skolem_observation(bob, glucose), builtin, [], []).
@@ -0,0 +1,250 @@
1
+ mean(scores, 5.0).
2
+ count(scores, 8).
3
+ populationVariance(scores, 4.0).
4
+ populationStddev(scores, 2.0).
5
+
6
+ clause(1, sample(scores, [2.0, 4.0, 4.0, 4.0, 5.0, 5.0, 7.0, 9.0]), true).
7
+ clause(2, sum([], 0.0), true).
8
+ clause(3,
9
+ sum([var('X') | var('Xs')], var('Total')),
10
+ (sum(var('Xs'), var('Rest')), var('Total') is var('X') + var('Rest'))).
11
+ clause(4,
12
+ mean(var('Name'), var('Mean')),
13
+ (sample(var('Name'), var('Values')),
14
+ sum(var('Values'), var('Total')),
15
+ length(var('Values'), var('Count')),
16
+ var('Mean') is var('Total') / var('Count'))).
17
+ clause(5, squared_error_sum([], anonymous(1), 0.0), true).
18
+ clause(6,
19
+ squared_error_sum([var('X') | var('Xs')], var('Mean'), var('Total')),
20
+ (var('Delta') is var('X') - var('Mean'),
21
+ var('Squared') is var('Delta') ** 2.0,
22
+ squared_error_sum(var('Xs'), var('Mean'), var('Rest')),
23
+ var('Total') is var('Squared') + var('Rest'))).
24
+ clause(7,
25
+ population_variance(var('Name'), var('Variance')),
26
+ (sample(var('Name'), var('Values')),
27
+ mean(var('Name'), var('Mean')),
28
+ squared_error_sum(var('Values'), var('Mean'), var('Sumsquarederrors')),
29
+ length(var('Values'), var('Count')),
30
+ var('Variance') is var('Sumsquarederrors') / var('Count'))).
31
+ clause(8,
32
+ population_stddev(var('Name'), var('Stddev')),
33
+ (population_variance(var('Name'), var('Variance')),
34
+ var('Stddev') is var('Variance') ** 0.5)).
35
+ clause(9,
36
+ count(var('Name'), var('Count')),
37
+ (sample(var('Name'), var('Values')), length(var('Values'), var('Count')))).
38
+ clause(10,
39
+ populationVariance(var('Name'), var('Variance')),
40
+ population_variance(var('Name'), var('Variance'))).
41
+ clause(11,
42
+ populationStddev(var('Name'), var('Stddev')),
43
+ population_stddev(var('Name'), var('Stddev'))).
44
+
45
+ step(mean(scores, 5.0),
46
+ rule(4),
47
+ ['Name' = scores,
48
+ 'Mean' = 5.0,
49
+ 'Values' = [2.0, 4.0, 4.0, 4.0, 5.0, 5.0, 7.0, 9.0],
50
+ 'Total' = 40.0,
51
+ 'Count' = 8],
52
+ [sample(scores, [2.0, 4.0, 4.0, 4.0, 5.0, 5.0, 7.0, 9.0]),
53
+ sum([2.0, 4.0, 4.0, 4.0, 5.0, 5.0, 7.0, 9.0], 40.0),
54
+ length([2.0, 4.0, 4.0, 4.0, 5.0, 5.0, 7.0, 9.0], 8),
55
+ 5.0 is 40.0 / 8]).
56
+ step(sample(scores, [2.0, 4.0, 4.0, 4.0, 5.0, 5.0, 7.0, 9.0]), fact(1), [], []).
57
+ step(sum([2.0, 4.0, 4.0, 4.0, 5.0, 5.0, 7.0, 9.0], 40.0),
58
+ rule(3),
59
+ ['X' = 2.0, 'Xs' = [4.0, 4.0, 4.0, 5.0, 5.0, 7.0, 9.0], 'Total' = 40.0, 'Rest' = 38.0],
60
+ [sum([4.0, 4.0, 4.0, 5.0, 5.0, 7.0, 9.0], 38.0), 40.0 is 2.0 + 38.0]).
61
+ step(sum([4.0, 4.0, 4.0, 5.0, 5.0, 7.0, 9.0], 38.0),
62
+ rule(3),
63
+ ['X' = 4.0, 'Xs' = [4.0, 4.0, 5.0, 5.0, 7.0, 9.0], 'Total' = 38.0, 'Rest' = 34.0],
64
+ [sum([4.0, 4.0, 5.0, 5.0, 7.0, 9.0], 34.0), 38.0 is 4.0 + 34.0]).
65
+ step(sum([4.0, 4.0, 5.0, 5.0, 7.0, 9.0], 34.0),
66
+ rule(3),
67
+ ['X' = 4.0, 'Xs' = [4.0, 5.0, 5.0, 7.0, 9.0], 'Total' = 34.0, 'Rest' = 30.0],
68
+ [sum([4.0, 5.0, 5.0, 7.0, 9.0], 30.0), 34.0 is 4.0 + 30.0]).
69
+ step(sum([4.0, 5.0, 5.0, 7.0, 9.0], 30.0),
70
+ rule(3),
71
+ ['X' = 4.0, 'Xs' = [5.0, 5.0, 7.0, 9.0], 'Total' = 30.0, 'Rest' = 26.0],
72
+ [sum([5.0, 5.0, 7.0, 9.0], 26.0), 30.0 is 4.0 + 26.0]).
73
+ step(sum([5.0, 5.0, 7.0, 9.0], 26.0),
74
+ rule(3),
75
+ ['X' = 5.0, 'Xs' = [5.0, 7.0, 9.0], 'Total' = 26.0, 'Rest' = 21.0],
76
+ [sum([5.0, 7.0, 9.0], 21.0), 26.0 is 5.0 + 21.0]).
77
+ step(sum([5.0, 7.0, 9.0], 21.0),
78
+ rule(3),
79
+ ['X' = 5.0, 'Xs' = [7.0, 9.0], 'Total' = 21.0, 'Rest' = 16.0],
80
+ [sum([7.0, 9.0], 16.0), 21.0 is 5.0 + 16.0]).
81
+ step(sum([7.0, 9.0], 16.0),
82
+ rule(3),
83
+ ['X' = 7.0, 'Xs' = [9.0], 'Total' = 16.0, 'Rest' = 9.0],
84
+ [sum([9.0], 9.0), 16.0 is 7.0 + 9.0]).
85
+ step(sum([9.0], 9.0),
86
+ rule(3),
87
+ ['X' = 9.0, 'Xs' = [], 'Total' = 9.0, 'Rest' = 0.0],
88
+ [sum([], 0.0), 9.0 is 9.0 + 0.0]).
89
+ step(sum([], 0.0), fact(2), [], []).
90
+ step(9.0 is 9.0 + 0.0, builtin, [], []).
91
+ step(16.0 is 7.0 + 9.0, builtin, [], []).
92
+ step(21.0 is 5.0 + 16.0, builtin, [], []).
93
+ step(26.0 is 5.0 + 21.0, builtin, [], []).
94
+ step(30.0 is 4.0 + 26.0, builtin, [], []).
95
+ step(34.0 is 4.0 + 30.0, builtin, [], []).
96
+ step(38.0 is 4.0 + 34.0, builtin, [], []).
97
+ step(40.0 is 2.0 + 38.0, builtin, [], []).
98
+ step(length([2.0, 4.0, 4.0, 4.0, 5.0, 5.0, 7.0, 9.0], 8), builtin, [], []).
99
+ step(5.0 is 40.0 / 8, builtin, [], []).
100
+ step(count(scores, 8),
101
+ rule(9),
102
+ ['Name' = scores, 'Count' = 8, 'Values' = [2.0, 4.0, 4.0, 4.0, 5.0, 5.0, 7.0, 9.0]],
103
+ [sample(scores, [2.0, 4.0, 4.0, 4.0, 5.0, 5.0, 7.0, 9.0]),
104
+ length([2.0, 4.0, 4.0, 4.0, 5.0, 5.0, 7.0, 9.0], 8)]).
105
+ step(populationVariance(scores, 4.0),
106
+ rule(10),
107
+ ['Name' = scores, 'Variance' = 4.0],
108
+ [population_variance(scores, 4.0)]).
109
+ step(population_variance(scores, 4.0),
110
+ rule(7),
111
+ ['Name' = scores,
112
+ 'Variance' = 4.0,
113
+ 'Values' = [2.0, 4.0, 4.0, 4.0, 5.0, 5.0, 7.0, 9.0],
114
+ 'Mean' = 5.0,
115
+ 'Sumsquarederrors' = 32.0,
116
+ 'Count' = 8],
117
+ [sample(scores, [2.0, 4.0, 4.0, 4.0, 5.0, 5.0, 7.0, 9.0]),
118
+ mean(scores, 5.0),
119
+ squared_error_sum([2.0, 4.0, 4.0, 4.0, 5.0, 5.0, 7.0, 9.0], 5.0, 32.0),
120
+ length([2.0, 4.0, 4.0, 4.0, 5.0, 5.0, 7.0, 9.0], 8),
121
+ 4.0 is 32.0 / 8]).
122
+ step(squared_error_sum([2.0, 4.0, 4.0, 4.0, 5.0, 5.0, 7.0, 9.0], 5.0, 32.0),
123
+ rule(6),
124
+ ['X' = 2.0,
125
+ 'Xs' = [4.0, 4.0, 4.0, 5.0, 5.0, 7.0, 9.0],
126
+ 'Mean' = 5.0,
127
+ 'Total' = 32.0,
128
+ 'Delta' = -3.0,
129
+ 'Squared' = 9.0,
130
+ 'Rest' = 23.0],
131
+ [-3.0 is 2.0 - 5.0,
132
+ 9.0 is -3.0 ** 2.0,
133
+ squared_error_sum([4.0, 4.0, 4.0, 5.0, 5.0, 7.0, 9.0], 5.0, 23.0),
134
+ 32.0 is 9.0 + 23.0]).
135
+ step(-3.0 is 2.0 - 5.0, builtin, [], []).
136
+ step(9.0 is -3.0 ** 2.0, builtin, [], []).
137
+ step(squared_error_sum([4.0, 4.0, 4.0, 5.0, 5.0, 7.0, 9.0], 5.0, 23.0),
138
+ rule(6),
139
+ ['X' = 4.0,
140
+ 'Xs' = [4.0, 4.0, 5.0, 5.0, 7.0, 9.0],
141
+ 'Mean' = 5.0,
142
+ 'Total' = 23.0,
143
+ 'Delta' = -1.0,
144
+ 'Squared' = 1.0,
145
+ 'Rest' = 22.0],
146
+ [-1.0 is 4.0 - 5.0,
147
+ 1.0 is -1.0 ** 2.0,
148
+ squared_error_sum([4.0, 4.0, 5.0, 5.0, 7.0, 9.0], 5.0, 22.0),
149
+ 23.0 is 1.0 + 22.0]).
150
+ step(-1.0 is 4.0 - 5.0, builtin, [], []).
151
+ step(1.0 is -1.0 ** 2.0, builtin, [], []).
152
+ step(squared_error_sum([4.0, 4.0, 5.0, 5.0, 7.0, 9.0], 5.0, 22.0),
153
+ rule(6),
154
+ ['X' = 4.0,
155
+ 'Xs' = [4.0, 5.0, 5.0, 7.0, 9.0],
156
+ 'Mean' = 5.0,
157
+ 'Total' = 22.0,
158
+ 'Delta' = -1.0,
159
+ 'Squared' = 1.0,
160
+ 'Rest' = 21.0],
161
+ [-1.0 is 4.0 - 5.0,
162
+ 1.0 is -1.0 ** 2.0,
163
+ squared_error_sum([4.0, 5.0, 5.0, 7.0, 9.0], 5.0, 21.0),
164
+ 22.0 is 1.0 + 21.0]).
165
+ step(squared_error_sum([4.0, 5.0, 5.0, 7.0, 9.0], 5.0, 21.0),
166
+ rule(6),
167
+ ['X' = 4.0,
168
+ 'Xs' = [5.0, 5.0, 7.0, 9.0],
169
+ 'Mean' = 5.0,
170
+ 'Total' = 21.0,
171
+ 'Delta' = -1.0,
172
+ 'Squared' = 1.0,
173
+ 'Rest' = 20.0],
174
+ [-1.0 is 4.0 - 5.0,
175
+ 1.0 is -1.0 ** 2.0,
176
+ squared_error_sum([5.0, 5.0, 7.0, 9.0], 5.0, 20.0),
177
+ 21.0 is 1.0 + 20.0]).
178
+ step(squared_error_sum([5.0, 5.0, 7.0, 9.0], 5.0, 20.0),
179
+ rule(6),
180
+ ['X' = 5.0,
181
+ 'Xs' = [5.0, 7.0, 9.0],
182
+ 'Mean' = 5.0,
183
+ 'Total' = 20.0,
184
+ 'Delta' = 0.0,
185
+ 'Squared' = 0.0,
186
+ 'Rest' = 20.0],
187
+ [0.0 is 5.0 - 5.0,
188
+ 0.0 is 0.0 ** 2.0,
189
+ squared_error_sum([5.0, 7.0, 9.0], 5.0, 20.0),
190
+ 20.0 is 0.0 + 20.0]).
191
+ step(0.0 is 5.0 - 5.0, builtin, [], []).
192
+ step(0.0 is 0.0 ** 2.0, builtin, [], []).
193
+ step(squared_error_sum([5.0, 7.0, 9.0], 5.0, 20.0),
194
+ rule(6),
195
+ ['X' = 5.0,
196
+ 'Xs' = [7.0, 9.0],
197
+ 'Mean' = 5.0,
198
+ 'Total' = 20.0,
199
+ 'Delta' = 0.0,
200
+ 'Squared' = 0.0,
201
+ 'Rest' = 20.0],
202
+ [0.0 is 5.0 - 5.0,
203
+ 0.0 is 0.0 ** 2.0,
204
+ squared_error_sum([7.0, 9.0], 5.0, 20.0),
205
+ 20.0 is 0.0 + 20.0]).
206
+ step(squared_error_sum([7.0, 9.0], 5.0, 20.0),
207
+ rule(6),
208
+ ['X' = 7.0,
209
+ 'Xs' = [9.0],
210
+ 'Mean' = 5.0,
211
+ 'Total' = 20.0,
212
+ 'Delta' = 2.0,
213
+ 'Squared' = 4.0,
214
+ 'Rest' = 16.0],
215
+ [2.0 is 7.0 - 5.0,
216
+ 4.0 is 2.0 ** 2.0,
217
+ squared_error_sum([9.0], 5.0, 16.0),
218
+ 20.0 is 4.0 + 16.0]).
219
+ step(2.0 is 7.0 - 5.0, builtin, [], []).
220
+ step(4.0 is 2.0 ** 2.0, builtin, [], []).
221
+ step(squared_error_sum([9.0], 5.0, 16.0),
222
+ rule(6),
223
+ ['X' = 9.0,
224
+ 'Xs' = [],
225
+ 'Mean' = 5.0,
226
+ 'Total' = 16.0,
227
+ 'Delta' = 4.0,
228
+ 'Squared' = 16.0,
229
+ 'Rest' = 0.0],
230
+ [4.0 is 9.0 - 5.0, 16.0 is 4.0 ** 2.0, squared_error_sum([], 5.0, 0.0), 16.0 is 16.0 + 0.0]).
231
+ step(4.0 is 9.0 - 5.0, builtin, [], []).
232
+ step(16.0 is 4.0 ** 2.0, builtin, [], []).
233
+ step(squared_error_sum([], 5.0, 0.0), fact(5), [], []).
234
+ step(16.0 is 16.0 + 0.0, builtin, [], []).
235
+ step(20.0 is 4.0 + 16.0, builtin, [], []).
236
+ step(20.0 is 0.0 + 20.0, builtin, [], []).
237
+ step(21.0 is 1.0 + 20.0, builtin, [], []).
238
+ step(22.0 is 1.0 + 21.0, builtin, [], []).
239
+ step(23.0 is 1.0 + 22.0, builtin, [], []).
240
+ step(32.0 is 9.0 + 23.0, builtin, [], []).
241
+ step(4.0 is 32.0 / 8, builtin, [], []).
242
+ step(populationStddev(scores, 2.0),
243
+ rule(11),
244
+ ['Name' = scores, 'Stddev' = 2.0],
245
+ [population_stddev(scores, 2.0)]).
246
+ step(population_stddev(scores, 2.0),
247
+ rule(8),
248
+ ['Name' = scores, 'Stddev' = 2.0, 'Variance' = 4.0],
249
+ [population_variance(scores, 4.0), 2.0 is 4.0 ** 0.5]).
250
+ step(2.0 is 4.0 ** 0.5, builtin, [], []).
@@ -0,0 +1,125 @@
1
+ stirling_bell_answer(stirling_10_4, 34105.0).
2
+ stirling_bell_answer(stirling_12_5, 1379400.0).
3
+ stirling_bell_answer(bell_10, 115975).
4
+ stirling_bell_answer(bell_12, 4213597).
5
+
6
+ clause(1, factorial(0, 1), true).
7
+ clause(2,
8
+ factorial(var('N'), var('Value')),
9
+ (var('N') > 0,
10
+ var('N1') is var('N') - 1,
11
+ factorial(var('N1'), var('Previous')),
12
+ var('Value') is var('N') * var('Previous'))).
13
+ clause(12,
14
+ stirling2(var('N'), var('K'), var('Count')),
15
+ (var('N') > 0,
16
+ var('K') > 0,
17
+ sumall(var('Term'), (between(0, var('K'), var('I')), signed_term(var('N'), var('K'), var('I'), var('Term'))), var('Sum')),
18
+ factorial(var('K'), var('Factorial')),
19
+ var('Count') is var('Sum') / var('Factorial'))).
20
+ clause(14,
21
+ bell(var('N'), var('Count')),
22
+ (var('N') > 0,
23
+ var('N1') is var('N') - 1,
24
+ sumall(var('Term'), (between(0, var('N1'), var('K')), binomial(var('N1'), var('K'), var('Choose')), bell(var('K'), var('Bell')), var('Term') is var('Choose') * var('Bell')), var('Count')))).
25
+ clause(15, stirling_bell_answer(stirling_10_4, var('Count')), stirling2(10, 4, var('Count'))).
26
+ clause(16, stirling_bell_answer(stirling_12_5, var('Count')), stirling2(12, 5, var('Count'))).
27
+ clause(17, stirling_bell_answer(bell_10, var('Count')), bell(10, var('Count'))).
28
+ clause(18, stirling_bell_answer(bell_12, var('Count')), bell(12, var('Count'))).
29
+
30
+ step(stirling_bell_answer(stirling_10_4, 34105.0),
31
+ rule(15),
32
+ ['Count' = 34105.0],
33
+ [stirling2(10, 4, 34105.0)]).
34
+ step(stirling2(10, 4, 34105.0),
35
+ rule(12),
36
+ ['N' = 10, 'K' = 4, 'Count' = 34105.0, 'Sum' = 818520.0, 'Factorial' = 24],
37
+ [10 > 0,
38
+ 4 > 0,
39
+ sumall(Expression, (between(0, 4, I), signed_term(10, 4, I, Expression)), 818520.0),
40
+ factorial(4, 24),
41
+ 34105.0 is 818520.0 / 24]).
42
+ step(10 > 0, builtin, [], []).
43
+ step(4 > 0, builtin, [], []).
44
+ step(sumall(Expression, (between(0, 4, I), signed_term(10, 4, I, Expression)), 818520.0),
45
+ builtin,
46
+ [],
47
+ []).
48
+ step(factorial(4, 24),
49
+ rule(2),
50
+ ['N' = 4, 'Value' = 24, 'N1' = 3, 'Previous' = 6],
51
+ [4 > 0, 3 is 4 - 1, factorial(3, 6), 24 is 4 * 6]).
52
+ step(3 is 4 - 1, builtin, [], []).
53
+ step(factorial(3, 6),
54
+ rule(2),
55
+ ['N' = 3, 'Value' = 6, 'N1' = 2, 'Previous' = 2],
56
+ [3 > 0, 2 is 3 - 1, factorial(2, 2), 6 is 3 * 2]).
57
+ step(3 > 0, builtin, [], []).
58
+ step(2 is 3 - 1, builtin, [], []).
59
+ step(factorial(2, 2),
60
+ rule(2),
61
+ ['N' = 2, 'Value' = 2, 'N1' = 1, 'Previous' = 1],
62
+ [2 > 0, 1 is 2 - 1, factorial(1, 1), 2 is 2 * 1]).
63
+ step(2 > 0, builtin, [], []).
64
+ step(1 is 2 - 1, builtin, [], []).
65
+ step(factorial(1, 1),
66
+ rule(2),
67
+ ['N' = 1, 'Value' = 1, 'N1' = 0, 'Previous' = 1],
68
+ [1 > 0, 0 is 1 - 1, factorial(0, 1), 1 is 1 * 1]).
69
+ step(1 > 0, builtin, [], []).
70
+ step(0 is 1 - 1, builtin, [], []).
71
+ step(factorial(0, 1), fact(1), [], []).
72
+ step(1 is 1 * 1, builtin, [], []).
73
+ step(2 is 2 * 1, builtin, [], []).
74
+ step(6 is 3 * 2, builtin, [], []).
75
+ step(24 is 4 * 6, builtin, [], []).
76
+ step(34105.0 is 818520.0 / 24, builtin, [], []).
77
+ step(stirling_bell_answer(stirling_12_5, 1379400.0),
78
+ rule(16),
79
+ ['Count' = 1379400.0],
80
+ [stirling2(12, 5, 1379400.0)]).
81
+ step(stirling2(12, 5, 1379400.0),
82
+ rule(12),
83
+ ['N' = 12, 'K' = 5, 'Count' = 1379400.0, 'Sum' = 165528000.0, 'Factorial' = 120],
84
+ [12 > 0,
85
+ 5 > 0,
86
+ sumall(Expression, (between(0, 5, I), signed_term(12, 5, I, Expression)), 165528000.0),
87
+ factorial(5, 120),
88
+ 1379400.0 is 165528000.0 / 120]).
89
+ step(12 > 0, builtin, [], []).
90
+ step(5 > 0, builtin, [], []).
91
+ step(sumall(Expression, (between(0, 5, I), signed_term(12, 5, I, Expression)), 165528000.0),
92
+ builtin,
93
+ [],
94
+ []).
95
+ step(factorial(5, 120),
96
+ rule(2),
97
+ ['N' = 5, 'Value' = 120, 'N1' = 4, 'Previous' = 24],
98
+ [5 > 0, 4 is 5 - 1, factorial(4, 24), 120 is 5 * 24]).
99
+ step(4 is 5 - 1, builtin, [], []).
100
+ step(120 is 5 * 24, builtin, [], []).
101
+ step(1379400.0 is 165528000.0 / 120, builtin, [], []).
102
+ step(stirling_bell_answer(bell_10, 115975), rule(17), ['Count' = 115975], [bell(10, 115975)]).
103
+ step(bell(10, 115975),
104
+ rule(14),
105
+ ['N' = 10, 'Count' = 115975, 'N1' = 9],
106
+ [10 > 0,
107
+ 9 is 10 - 1,
108
+ sumall(Expression, (between(0, 9, K), binomial(9, K, Choose), bell(K, Bell), Expression is Choose * Bell), 115975)]).
109
+ step(9 is 10 - 1, builtin, [], []).
110
+ step(sumall(Expression, (between(0, 9, K), binomial(9, K, Choose), bell(K, Bell), Expression is Choose * Bell), 115975),
111
+ builtin,
112
+ [],
113
+ []).
114
+ step(stirling_bell_answer(bell_12, 4213597), rule(18), ['Count' = 4213597], [bell(12, 4213597)]).
115
+ step(bell(12, 4213597),
116
+ rule(14),
117
+ ['N' = 12, 'Count' = 4213597, 'N1' = 11],
118
+ [12 > 0,
119
+ 11 is 12 - 1,
120
+ sumall(Expression, (between(0, 11, K), binomial(11, K, Choose), bell(K, Bell), Expression is Choose * Bell), 4213597)]).
121
+ step(11 is 12 - 1, builtin, [], []).
122
+ step(sumall(Expression, (between(0, 11, K), binomial(11, K, Choose), bell(K, Bell), Expression is Choose * Bell), 4213597),
123
+ builtin,
124
+ [],
125
+ []).
@@ -0,0 +1,118 @@
1
+ decodesAs(message(1), 1).
2
+ decodesAs(message(3), 3).
3
+ decodesAs(message(0), 0).
4
+ decodesAs(message(2), 2).
5
+ preservesMessage(protocol, true).
6
+ cancelsCrossTalk(protocol, true).
7
+
8
+ clause(1, r(false, false), true).
9
+ clause(2, r(true, true), true).
10
+ clause(3, identity(false, false), true).
11
+ clause(4, identity(true, true), true).
12
+ clause(5, g(false, true), true).
13
+ clause(8, k(true, false), true).
14
+ clause(10, kg(var('X'), var('Y')), (g(var('X'), var('Z')), k(var('Z'), var('Y')))).
15
+ clause(11, gk(var('X'), var('Y')), (k(var('X'), var('Z')), g(var('Z'), var('Y')))).
16
+ clause(12, alice(0, var('X'), var('Y')), identity(var('X'), var('Y'))).
17
+ clause(13, alice(1, var('X'), var('Y')), g(var('X'), var('Y'))).
18
+ clause(14, alice(2, var('X'), var('Y')), k(var('X'), var('Y'))).
19
+ clause(15, alice(3, var('X'), var('Y')), kg(var('X'), var('Y'))).
20
+ clause(16, bob(var('X'), var('Y'), 0), gk(var('X'), var('Y'))).
21
+ clause(17, bob(var('X'), var('Y'), 1), k(var('X'), var('Y'))).
22
+ clause(18, bob(var('X'), var('Y'), 2), g(var('X'), var('Y'))).
23
+ clause(19, bob(var('X'), var('Y'), 3), identity(var('X'), var('Y'))).
24
+ clause(20,
25
+ sdc_path(var('N'), var('M'), path(var('X'), var('Y'), var('B'))),
26
+ (r(var('X'), var('Y')),
27
+ alice(var('N'), var('X'), var('B')),
28
+ bob(var('B'), var('Y'), var('M')))).
29
+ clause(22,
30
+ sdcoding(var('N'), var('M')),
31
+ (sdc_path(var('N'), var('M'), var('Proof')),
32
+ \+ duplicate_sdc_path(var('N'), var('M'), var('Proof')))).
33
+ clause(23, decodesAs(message(var('N')), var('M')), sdcoding(var('N'), var('M'))).
34
+ clause(24,
35
+ preservesMessage(protocol, true),
36
+ (sdcoding(0, 0), sdcoding(1, 1), sdcoding(2, 2), sdcoding(3, 3))).
37
+ clause(25,
38
+ cancelsCrossTalk(protocol, true),
39
+ (\+ sdcoding(0, 1), \+ sdcoding(1, 0), \+ sdcoding(2, 3), \+ sdcoding(3, 2))).
40
+
41
+ step(decodesAs(message(1), 1), rule(23), ['N' = 1, 'M' = 1], [sdcoding(1, 1)]).
42
+ step(sdcoding(1, 1),
43
+ rule(22),
44
+ ['N' = 1, 'M' = 1, 'Proof' = path(false, false, true)],
45
+ [sdc_path(1, 1, path(false, false, true)),
46
+ \+ duplicate_sdc_path(1, 1, path(false, false, true))]).
47
+ step(sdc_path(1, 1, path(false, false, true)),
48
+ rule(20),
49
+ ['N' = 1, 'M' = 1, 'X' = false, 'Y' = false, 'B' = true],
50
+ [r(false, false), alice(1, false, true), bob(true, false, 1)]).
51
+ step(r(false, false), fact(1), [], []).
52
+ step(alice(1, false, true), rule(13), ['X' = false, 'Y' = true], [g(false, true)]).
53
+ step(g(false, true), fact(5), [], []).
54
+ step(bob(true, false, 1), rule(17), ['X' = true, 'Y' = false], [k(true, false)]).
55
+ step(k(true, false), fact(8), [], []).
56
+ step(\+ duplicate_sdc_path(1, 1, path(false, false, true)), absent, [], []).
57
+ step(decodesAs(message(3), 3), rule(23), ['N' = 3, 'M' = 3], [sdcoding(3, 3)]).
58
+ step(sdcoding(3, 3),
59
+ rule(22),
60
+ ['N' = 3, 'M' = 3, 'Proof' = path(false, false, false)],
61
+ [sdc_path(3, 3, path(false, false, false)),
62
+ \+ duplicate_sdc_path(3, 3, path(false, false, false))]).
63
+ step(sdc_path(3, 3, path(false, false, false)),
64
+ rule(20),
65
+ ['N' = 3, 'M' = 3, 'X' = false, 'Y' = false, 'B' = false],
66
+ [r(false, false), alice(3, false, false), bob(false, false, 3)]).
67
+ step(alice(3, false, false), rule(15), ['X' = false, 'Y' = false], [kg(false, false)]).
68
+ step(kg(false, false),
69
+ rule(10),
70
+ ['X' = false, 'Y' = false, 'Z' = true],
71
+ [g(false, true), k(true, false)]).
72
+ step(bob(false, false, 3), rule(19), ['X' = false, 'Y' = false], [identity(false, false)]).
73
+ step(identity(false, false), fact(3), [], []).
74
+ step(\+ duplicate_sdc_path(3, 3, path(false, false, false)), absent, [], []).
75
+ step(decodesAs(message(0), 0), rule(23), ['N' = 0, 'M' = 0], [sdcoding(0, 0)]).
76
+ step(sdcoding(0, 0),
77
+ rule(22),
78
+ ['N' = 0, 'M' = 0, 'Proof' = path(true, true, true)],
79
+ [sdc_path(0, 0, path(true, true, true)),
80
+ \+ duplicate_sdc_path(0, 0, path(true, true, true))]).
81
+ step(sdc_path(0, 0, path(true, true, true)),
82
+ rule(20),
83
+ ['N' = 0, 'M' = 0, 'X' = true, 'Y' = true, 'B' = true],
84
+ [r(true, true), alice(0, true, true), bob(true, true, 0)]).
85
+ step(r(true, true), fact(2), [], []).
86
+ step(alice(0, true, true), rule(12), ['X' = true, 'Y' = true], [identity(true, true)]).
87
+ step(identity(true, true), fact(4), [], []).
88
+ step(bob(true, true, 0), rule(16), ['X' = true, 'Y' = true], [gk(true, true)]).
89
+ step(gk(true, true),
90
+ rule(11),
91
+ ['X' = true, 'Y' = true, 'Z' = false],
92
+ [k(true, false), g(false, true)]).
93
+ step(\+ duplicate_sdc_path(0, 0, path(true, true, true)), absent, [], []).
94
+ step(decodesAs(message(2), 2), rule(23), ['N' = 2, 'M' = 2], [sdcoding(2, 2)]).
95
+ step(sdcoding(2, 2),
96
+ rule(22),
97
+ ['N' = 2, 'M' = 2, 'Proof' = path(true, true, false)],
98
+ [sdc_path(2, 2, path(true, true, false)),
99
+ \+ duplicate_sdc_path(2, 2, path(true, true, false))]).
100
+ step(sdc_path(2, 2, path(true, true, false)),
101
+ rule(20),
102
+ ['N' = 2, 'M' = 2, 'X' = true, 'Y' = true, 'B' = false],
103
+ [r(true, true), alice(2, true, false), bob(false, true, 2)]).
104
+ step(alice(2, true, false), rule(14), ['X' = true, 'Y' = false], [k(true, false)]).
105
+ step(bob(false, true, 2), rule(18), ['X' = false, 'Y' = true], [g(false, true)]).
106
+ step(\+ duplicate_sdc_path(2, 2, path(true, true, false)), absent, [], []).
107
+ step(preservesMessage(protocol, true),
108
+ rule(24),
109
+ [],
110
+ [sdcoding(0, 0), sdcoding(1, 1), sdcoding(2, 2), sdcoding(3, 3)]).
111
+ step(cancelsCrossTalk(protocol, true),
112
+ rule(25),
113
+ [],
114
+ [\+ sdcoding(0, 1), \+ sdcoding(1, 0), \+ sdcoding(2, 3), \+ sdcoding(3, 2)]).
115
+ step(\+ sdcoding(0, 1), absent, [], []).
116
+ step(\+ sdcoding(1, 0), absent, [], []).
117
+ step(\+ sdcoding(2, 3), absent, [], []).
118
+ step(\+ sdcoding(3, 2), absent, [], []).