eyelang 1.5.2 → 1.5.4
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.
- package/README.md +2 -0
- package/examples/access-control-policy.pl +3 -0
- package/examples/ackermann.pl +3 -0
- package/examples/age.pl +3 -0
- package/examples/aliases-and-namespaces.pl +7 -0
- package/examples/alignment-demo.pl +3 -0
- package/examples/allen-interval-calculus.pl +3 -0
- package/examples/ancestor.pl +7 -0
- package/examples/animal.pl +3 -0
- package/examples/annotation.pl +3 -0
- package/examples/auroracare.pl +309 -0
- package/examples/backward.pl +3 -0
- package/examples/basic-monadic.pl +3 -1
- package/examples/bayes-diagnosis.pl +3 -0
- package/examples/bayes-therapy.pl +3 -0
- package/examples/beam-deflection.pl +3 -0
- package/examples/blocks-world-planning.pl +3 -0
- package/examples/bmi.pl +3 -0
- package/examples/braking-safety-worlds.pl +3 -0
- package/examples/buck-converter-design.pl +3 -0
- package/examples/cache-performance.pl +3 -0
- package/examples/canary-release.pl +3 -0
- package/examples/cat-koko.pl +3 -0
- package/examples/clinical-trial-screening.pl +3 -0
- package/examples/collatz-1000.pl +3 -0
- package/examples/combinatorics-findall-sort.pl +6 -0
- package/examples/competitive-enzyme-kinetics.pl +3 -0
- package/examples/complex-matrix-stability.pl +3 -0
- package/examples/complex.pl +3 -0
- package/examples/composition-of-injective-functions-is-injective.pl +3 -0
- package/examples/context-association.pl +3 -0
- package/examples/control-system.pl +3 -0
- package/examples/cryptarithmetic-send-more-money.pl +3 -0
- package/examples/cyclic-path.pl +3 -1
- package/examples/d3-group.pl +8 -0
- package/examples/dairy-energy-balance.pl +3 -0
- package/examples/data-negotiation.pl +6 -0
- package/examples/deep-taxonomy-10.pl +3 -0
- package/examples/deep-taxonomy-100.pl +3 -0
- package/examples/deep-taxonomy-1000.pl +3 -0
- package/examples/deep-taxonomy-10000.pl +3 -0
- package/examples/deep-taxonomy-100000.pl +3 -0
- package/examples/delfour.pl +18 -1
- package/examples/dense-hamiltonian-cycle.pl +3 -0
- package/examples/deontic-logic.pl +6 -0
- package/examples/derived-backward-rule.pl +3 -0
- package/examples/derived-rule.pl +3 -0
- package/examples/diamond-property.pl +3 -0
- package/examples/dijkstra-findall-sort.pl +6 -0
- package/examples/dijkstra-risk-path.pl +3 -0
- package/examples/dijkstra.pl +3 -0
- package/examples/dining-philosophers.pl +3 -0
- package/examples/dog.pl +5 -0
- package/examples/drone-corridor-planner.pl +3 -0
- package/examples/easter-computus.pl +6 -0
- package/examples/electrical-rc-filter.pl +3 -0
- package/examples/epidemic-policy.pl +6 -0
- package/examples/equivalence-classes-overlap-implies-same-class.pl +3 -0
- package/examples/eulerian-path.pl +6 -0
- package/examples/ev-range-worlds.pl +3 -0
- package/examples/exact-cover-sudoku.pl +3 -0
- package/examples/existential-rule.pl +3 -0
- package/examples/exoplanet-validation-worlds.pl +3 -0
- package/examples/expression-eval.pl +5 -0
- package/examples/family-cousins.pl +3 -0
- package/examples/fastpow.pl +5 -0
- package/examples/fft8-numeric.pl +6 -0
- package/examples/fibonacci.pl +3 -0
- package/examples/field-nitrogen-balance.pl +3 -0
- package/examples/flandor.pl +296 -0
- package/examples/floating-point.pl +5 -0
- package/examples/four-color-map.pl +3 -0
- package/examples/fundamental-theorem-arithmetic.pl +3 -0
- package/examples/gcd-bezout-identity.pl +3 -0
- package/examples/gd-step-certified.pl +3 -0
- package/examples/gdpr-compliance.pl +6 -0
- package/examples/goldbach-1000.pl +3 -0
- package/examples/good-cobbler.pl +3 -0
- package/examples/gps.pl +3 -0
- package/examples/graph-reachability.pl +3 -0
- package/examples/gray-code-counter.pl +6 -0
- package/examples/greatest-lower-bound-uniqueness.pl +3 -0
- package/examples/group-inverse-uniqueness.pl +3 -0
- package/examples/hamiltonian-cycle.pl +3 -0
- package/examples/hamiltonian-path.pl +3 -0
- package/examples/hamming-code.pl +3 -0
- package/examples/hanoi.pl +3 -0
- package/examples/heat-loss.pl +3 -0
- package/examples/heron-theorem.pl +5 -0
- package/examples/ideal-gas-law.pl +3 -0
- package/examples/illegitimate-reasoning.pl +3 -0
- package/examples/kaprekar.pl +3 -0
- package/examples/law-of-cosines.pl +5 -0
- package/examples/least-squares-regression.pl +3 -0
- package/examples/list-collection.pl +5 -0
- package/examples/lldm.pl +3 -0
- package/examples/manufacturing-quality-control.pl +3 -0
- package/examples/matrix.pl +3 -0
- package/examples/microgrid-dispatch.pl +3 -0
- package/examples/monkey-bananas.pl +3 -0
- package/examples/n-queens.pl +3 -0
- package/examples/network-sla.pl +3 -0
- package/examples/newton-raphson.pl +3 -0
- package/examples/nixon-diamond.pl +3 -0
- package/examples/odrl-dpv-healthcare-risk-ranked.pl +3 -0
- package/examples/odrl-dpv-risk-ranked.pl +3 -0
- package/examples/orbital-transfer-design.pl +3 -0
- package/examples/output/auroracare.pl +117 -0
- package/examples/output/delfour.pl +7 -1
- package/examples/output/flandor.pl +43 -0
- package/examples/path-discovery.pl +3 -0
- package/examples/peano-arithmetic.pl +3 -0
- package/examples/peasant.pl +5 -0
- package/examples/pendulum-period.pl +3 -0
- package/examples/polynomial.pl +3 -0
- package/examples/project-portfolio-optimization.pl +3 -0
- package/examples/proof-contrapositive.pl +3 -0
- package/examples/quadratic-formula.pl +3 -0
- package/examples/quine-mccluskey.pl +3 -0
- package/examples/radioactive-decay.pl +3 -0
- package/examples/sat-dpll.pl +3 -0
- package/examples/security-incident-correlation.pl +3 -0
- package/examples/service-impact.pl +3 -0
- package/examples/sieve.pl +3 -0
- package/examples/skolem-functions.pl +3 -0
- package/examples/socket-age.pl +3 -0
- package/examples/socket-family.pl +3 -0
- package/examples/socrates.pl +3 -0
- package/examples/statistics-summary.pl +3 -0
- package/examples/sudoku.pl +3 -0
- package/examples/superdense-coding.pl +3 -0
- package/examples/traveling-salesman.pl +6 -0
- package/examples/turing.pl +3 -0
- package/examples/vector-similarity.pl +6 -0
- package/examples/witch.pl +3 -0
- package/examples/wolf-goat-cabbage.pl +3 -0
- package/examples/zebra.pl +3 -0
- package/package.json +1 -1
- package/playground.html +2 -0
|
@@ -3,17 +3,20 @@
|
|
|
3
3
|
% For small oscillations, T = 2*pi*sqrt(length / gravity). Gravity is chosen
|
|
4
4
|
% as pi^2 m/s^2 so a one-meter pendulum has a period of two seconds.
|
|
5
5
|
|
|
6
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
6
7
|
materialize(period_s, 2).
|
|
7
8
|
materialize(periodError_s, 2).
|
|
8
9
|
materialize(status, 2).
|
|
9
10
|
materialize(reason, 2).
|
|
10
11
|
|
|
12
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
11
13
|
constant(pi, 3.141592653589793).
|
|
12
14
|
experiment(pendulum1, length_m, 1.0).
|
|
13
15
|
experiment(pendulum1, gravity_m_s2, 9.869604401089358).
|
|
14
16
|
limit(pendulum1, target_period_s, 2.0).
|
|
15
17
|
limit(pendulum1, tolerance_s, 0.01).
|
|
16
18
|
|
|
19
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
17
20
|
period(Experiment, Period) :-
|
|
18
21
|
experiment(Experiment, length_m, Length),
|
|
19
22
|
experiment(Experiment, gravity_m_s2, Gravity),
|
package/examples/polynomial.pl
CHANGED
|
@@ -6,12 +6,14 @@
|
|
|
6
6
|
% searching a finite complex-integer candidate grid. The two cases below are
|
|
7
7
|
% the same quartic polynomials used by the Eyelet source.
|
|
8
8
|
|
|
9
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
9
10
|
materialize(polynomial, 2).
|
|
10
11
|
materialize(root, 2).
|
|
11
12
|
materialize(reconstructedPolynomial, 2).
|
|
12
13
|
materialize(reconstructionMatches, 2).
|
|
13
14
|
materialize(allRootsVerified, 2).
|
|
14
15
|
|
|
16
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
15
17
|
case(real_quartic).
|
|
16
18
|
case(complex_quartic).
|
|
17
19
|
|
|
@@ -32,6 +34,7 @@ known_roots(complex_quartic, [[0, 1], [1, 1], [3, 2], [5, 1]]).
|
|
|
32
34
|
|
|
33
35
|
c_zero([0, 0]).
|
|
34
36
|
|
|
37
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
35
38
|
c_add([A, B], [C, D], [E, F]) :-
|
|
36
39
|
add(A, C, E),
|
|
37
40
|
add(B, D, F).
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
% accumulate, then use aggregate builtins to select useful optima without
|
|
6
6
|
% building and sorting a large bag of candidate portfolios.
|
|
7
7
|
|
|
8
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
8
9
|
materialize(bestPortfolio, 2).
|
|
9
10
|
materialize(lowRiskTarget, 2).
|
|
10
11
|
materialize(feasibleCount, 2).
|
|
@@ -12,6 +13,7 @@ materialize(projectCount, 2).
|
|
|
12
13
|
materialize(totalAvailableValue, 2).
|
|
13
14
|
materialize(note, 2).
|
|
14
15
|
|
|
16
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
15
17
|
budget(portfolio2026, 75).
|
|
16
18
|
riskCap(portfolio2026, 28).
|
|
17
19
|
targetValue(portfolio2026, 125).
|
|
@@ -31,6 +33,7 @@ allProjectData([
|
|
|
31
33
|
p(security, 25, 16, 7)
|
|
32
34
|
]).
|
|
33
35
|
|
|
36
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
34
37
|
project(Name, Value, Cost, Risk) :-
|
|
35
38
|
allProjectData(Projects),
|
|
36
39
|
member(p(Name, Value, Cost, Risk), Projects).
|
|
@@ -3,13 +3,16 @@
|
|
|
3
3
|
% The implication itself is represented as data with implies/2. The proof
|
|
4
4
|
% rule remains ordinary eyelang: if A implies B and B is false, then A is false.
|
|
5
5
|
|
|
6
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
6
7
|
materialize(refutes, 2).
|
|
7
8
|
materialize(method, 2).
|
|
8
9
|
materialize(reason, 2).
|
|
9
10
|
|
|
11
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
10
12
|
implies(raining, wet_ground).
|
|
11
13
|
false(wet_ground).
|
|
12
14
|
|
|
15
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
13
16
|
false(A) :-
|
|
14
17
|
implies(A, B),
|
|
15
18
|
false(B).
|
|
@@ -3,12 +3,15 @@
|
|
|
3
3
|
% Each equation is represented as a*x^2 + b*x + c = 0. The example uses
|
|
4
4
|
% eyelang arithmetic predicates to derive the discriminant and the two roots.
|
|
5
5
|
|
|
6
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
6
7
|
materialize(discriminant, 2).
|
|
7
8
|
materialize(root, 2).
|
|
8
9
|
|
|
10
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
9
11
|
equation(eq1, 1.0, -5.0, 6.0).
|
|
10
12
|
equation(eq2, 2.0, -4.0, -6.0).
|
|
11
13
|
|
|
14
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
12
15
|
discriminant(Case, D) :-
|
|
13
16
|
equation(Case, A, B, C),
|
|
14
17
|
pow(B, 2.0, B2),
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
% Eyelet-inspired Quine-McCluskey minimization using findall/3 and sort/2.
|
|
2
2
|
% Problem: f(A,B,C,D) = Sigma m(1,3,7,11,15) + d(0,2,5).
|
|
3
3
|
|
|
4
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
4
5
|
materialize(primeImplicants, 2).
|
|
5
6
|
materialize(minimalCover, 2).
|
|
6
7
|
materialize(equation, 2).
|
|
7
8
|
materialize(reason, 2).
|
|
8
9
|
|
|
10
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
9
11
|
minterm(1).
|
|
10
12
|
minterm(3).
|
|
11
13
|
minterm(7).
|
|
@@ -33,6 +35,7 @@ bits(13, [1, 1, 0, 1]).
|
|
|
33
35
|
bits(14, [1, 1, 1, 0]).
|
|
34
36
|
bits(15, [1, 1, 1, 1]).
|
|
35
37
|
|
|
38
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
36
39
|
initial_pattern(P) :- minterm(M), bits(M, P).
|
|
37
40
|
initial_pattern(P) :- dont_care(D), bits(D, P).
|
|
38
41
|
|
|
@@ -2,17 +2,20 @@
|
|
|
2
2
|
%
|
|
3
3
|
% Activity remaining after elapsed time is initial_activity * 0.5^(t/half_life).
|
|
4
4
|
|
|
5
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
5
6
|
materialize(halfLivesElapsed, 2).
|
|
6
7
|
materialize(remainingActivity_Bq, 2).
|
|
7
8
|
materialize(decayedActivity_Bq, 2).
|
|
8
9
|
materialize(status, 2).
|
|
9
10
|
materialize(reason, 2).
|
|
10
11
|
|
|
12
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
11
13
|
sample(iodine_sample, initial_activity_bq, 80.0).
|
|
12
14
|
sample(iodine_sample, half_life_h, 8.0).
|
|
13
15
|
sample(iodine_sample, elapsed_h, 16.0).
|
|
14
16
|
threshold(iodine_sample, low_activity_bq, 25.0).
|
|
15
17
|
|
|
18
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
16
19
|
half_lives(Sample, Count) :-
|
|
17
20
|
sample(Sample, elapsed_h, Elapsed),
|
|
18
21
|
sample(Sample, half_life_h, HalfLife),
|
package/examples/sat-dpll.pl
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
% larger instance has eight variables and twelve clauses, so it is still small
|
|
6
6
|
% enough for full model collection but no longer a toy four-variable search.
|
|
7
7
|
|
|
8
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
8
9
|
materialize(status, 2).
|
|
9
10
|
materialize(witness, 2).
|
|
10
11
|
materialize(modelCount, 2).
|
|
@@ -12,6 +13,7 @@ materialize(variableCount, 2).
|
|
|
12
13
|
materialize(clauseCount, 2).
|
|
13
14
|
materialize(reason, 2).
|
|
14
15
|
|
|
16
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
15
17
|
problem(sat_instance,
|
|
16
18
|
[a, b, c, d, e, f, g, h],
|
|
17
19
|
[
|
|
@@ -33,6 +35,7 @@ truth(false).
|
|
|
33
35
|
truth(true).
|
|
34
36
|
|
|
35
37
|
assignment([], []).
|
|
38
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
36
39
|
assignment([Var|Vars], [value(Var, Truth)|Rest]) :-
|
|
37
40
|
truth(Truth),
|
|
38
41
|
assignment(Vars, Rest).
|
|
@@ -3,10 +3,12 @@
|
|
|
3
3
|
% The rules correlate endpoint, identity, vulnerability, and threat-intelligence
|
|
4
4
|
% signals into an escalation decision with concise reason relations.
|
|
5
5
|
|
|
6
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
6
7
|
materialize(type, 2).
|
|
7
8
|
materialize(status, 2).
|
|
8
9
|
materialize(reason, 2).
|
|
9
10
|
|
|
11
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
10
12
|
incident(inc42).
|
|
11
13
|
incident(inc43).
|
|
12
14
|
|
|
@@ -30,6 +32,7 @@ alert(inc43, outbound_ip, ip_198_51_100_42).
|
|
|
30
32
|
vulnerability(endpoint23, cve_critical_rce).
|
|
31
33
|
threat_intel(ip_203_0_113_17, command_and_control).
|
|
32
34
|
|
|
35
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
33
36
|
critical_asset(Endpoint) :-
|
|
34
37
|
asset(Endpoint, criticality, high).
|
|
35
38
|
|
|
@@ -3,10 +3,12 @@
|
|
|
3
3
|
% fraud_service, fraud_service calls risk_rules, and risk_rules calls payment_service
|
|
4
4
|
% for authorization data. A payment outage should still produce a finite impact set.
|
|
5
5
|
|
|
6
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
6
7
|
materialize(impactedByFailureOf, 2).
|
|
7
8
|
materialize(status, 2).
|
|
8
9
|
materialize(businessFunctionAtRisk, 2).
|
|
9
10
|
|
|
11
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
10
12
|
depends_on(web_store, checkout_api).
|
|
11
13
|
depends_on(mobile_app, checkout_api).
|
|
12
14
|
depends_on(checkout_api, payment_service).
|
|
@@ -25,6 +27,7 @@ business_function(show_stock, inventory_service).
|
|
|
25
27
|
|
|
26
28
|
failed(payment_service).
|
|
27
29
|
|
|
30
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
28
31
|
impacted(Service, Failed) :- depends_on(Service, Failed).
|
|
29
32
|
impacted(Service, Failed) :- depends_on(Service, Dependency), impacted(Dependency, Failed).
|
|
30
33
|
|
package/examples/sieve.pl
CHANGED
|
@@ -4,10 +4,13 @@
|
|
|
4
4
|
% eyelang uses the built-in smallest_divisor_from/3 relation to keep the
|
|
5
5
|
% example fast while preserving the same generated prime list.
|
|
6
6
|
|
|
7
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
7
8
|
materialize(primes, 2).
|
|
8
9
|
|
|
10
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
9
11
|
want_primes(1000).
|
|
10
12
|
|
|
13
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
11
14
|
prime_under(Limit, P) :-
|
|
12
15
|
between(2, Limit, P),
|
|
13
16
|
smallest_divisor_from(P, 2, P).
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
% function symbol whose arguments contain the values that make the resource
|
|
5
5
|
% unique, such as skolem_observation(Patient, Test).
|
|
6
6
|
|
|
7
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
7
8
|
materialize(type, 2).
|
|
8
9
|
materialize(patient, 2).
|
|
9
10
|
materialize(test, 2).
|
|
@@ -12,10 +13,12 @@ materialize(about, 2).
|
|
|
12
13
|
materialize(sameInputsSameId, 2).
|
|
13
14
|
materialize(noObservationClash, 2).
|
|
14
15
|
|
|
16
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
15
17
|
test_result(alice, glucose, 6.8).
|
|
16
18
|
test_result(alice, cholesterol, 4.2).
|
|
17
19
|
test_result(bob, glucose, 5.1).
|
|
18
20
|
|
|
21
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
19
22
|
high_glucose(Patient) :-
|
|
20
23
|
test_result(Patient, glucose, Value),
|
|
21
24
|
gt(Value, 6.0).
|
package/examples/socket-age.pl
CHANGED
|
@@ -14,8 +14,10 @@
|
|
|
14
14
|
% Run:
|
|
15
15
|
% eyelang socket-age.pl
|
|
16
16
|
|
|
17
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
17
18
|
materialize(ageAbove, 2).
|
|
18
19
|
|
|
20
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
19
21
|
socket(patient_registry, provides(birthDay_2)).
|
|
20
22
|
socket(policy_source, provides(duration_2)).
|
|
21
23
|
socket(clock_source, provides(today_1)).
|
|
@@ -28,6 +30,7 @@ birthDay(patH, "1944-08-21").
|
|
|
28
30
|
duration(check, "P80Y").
|
|
29
31
|
today("2026-05-30").
|
|
30
32
|
|
|
33
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
31
34
|
ageAbove(S, A) :-
|
|
32
35
|
birthDay(S, B),
|
|
33
36
|
duration(check, A),
|
|
@@ -9,14 +9,17 @@
|
|
|
9
9
|
% Run:
|
|
10
10
|
% eyelang socket-family.pl
|
|
11
11
|
|
|
12
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
12
13
|
materialize(ancestor, 2).
|
|
13
14
|
|
|
15
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
14
16
|
socket(family_source, provides(parent_2)).
|
|
15
17
|
plug(family_file, family_source).
|
|
16
18
|
|
|
17
19
|
parent(pat, jan).
|
|
18
20
|
parent(jan, emma).
|
|
19
21
|
|
|
22
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
20
23
|
ancestor(X, Y) :-
|
|
21
24
|
parent(X, Y).
|
|
22
25
|
|
package/examples/socrates.pl
CHANGED
|
@@ -3,11 +3,14 @@
|
|
|
3
3
|
% Eyelet uses type('Socrates', 'Man') and a single rule deriving Mortal.
|
|
4
4
|
% eyelang keeps the same reasoning shape and emits relation facts.
|
|
5
5
|
|
|
6
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
6
7
|
materialize(type, 2).
|
|
7
8
|
materialize(is, 2).
|
|
8
9
|
|
|
10
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
9
11
|
type(socrates, man).
|
|
10
12
|
|
|
13
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
11
14
|
type(X, mortal) :-
|
|
12
15
|
type(X, man).
|
|
13
16
|
|
|
@@ -3,14 +3,17 @@
|
|
|
3
3
|
% The sample is the textbook data set [2,4,4,4,5,5,7,9], whose population
|
|
4
4
|
% mean is 5, variance is 4, and standard deviation is 2.
|
|
5
5
|
|
|
6
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
6
7
|
materialize(count, 2).
|
|
7
8
|
materialize(mean, 2).
|
|
8
9
|
materialize(populationVariance, 2).
|
|
9
10
|
materialize(populationStddev, 2).
|
|
10
11
|
|
|
12
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
11
13
|
sample(scores, [2.0, 4.0, 4.0, 4.0, 5.0, 5.0, 7.0, 9.0]).
|
|
12
14
|
|
|
13
15
|
sum([], 0.0).
|
|
16
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
14
17
|
sum([X|Xs], Total) :-
|
|
15
18
|
sum(Xs, Rest),
|
|
16
19
|
add(X, Rest, Total).
|
package/examples/sudoku.pl
CHANGED
|
@@ -4,14 +4,17 @@
|
|
|
4
4
|
% 0, dot, or underscore marks a blank. The builtin also accepts a 9x9 list
|
|
5
5
|
% of integers in the same representation.
|
|
6
6
|
|
|
7
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
7
8
|
materialize(solution, 2).
|
|
8
9
|
|
|
10
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
9
11
|
puzzle(classic,
|
|
10
12
|
"100007090030129008009600500005300900010080002600794000350408219240005867897201304").
|
|
11
13
|
|
|
12
14
|
puzzle(third,
|
|
13
15
|
"078200000005000400100400092000035070007000500050810000720004008009000300000006910").
|
|
14
16
|
|
|
17
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
15
18
|
solution(Name, Rows) :-
|
|
16
19
|
puzzle(Name, Grid),
|
|
17
20
|
sudoku(Grid, Rows).
|
|
@@ -7,10 +7,12 @@
|
|
|
7
7
|
% with a single support path after the interference choices are expanded.
|
|
8
8
|
|
|
9
9
|
% |R) = |0, 0) + |1, 1)
|
|
10
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
10
11
|
materialize(decodesAs, 2).
|
|
11
12
|
materialize(preservesMessage, 2).
|
|
12
13
|
materialize(cancelsCrossTalk, 2).
|
|
13
14
|
|
|
15
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
14
16
|
r(false, false).
|
|
15
17
|
r(true, true).
|
|
16
18
|
|
|
@@ -28,6 +30,7 @@ k(true, false).
|
|
|
28
30
|
k(true, true).
|
|
29
31
|
|
|
30
32
|
% KG and GK compositions.
|
|
33
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
31
34
|
kg(X, Y) :-
|
|
32
35
|
g(X, Z),
|
|
33
36
|
k(Z, Y).
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
% Traveling salesman problem, adapted from Eyelet input/traveling-salesman.pl.
|
|
2
2
|
% The optimal tour matches Eyelet output-swipl/traveling-salesman.pl.
|
|
3
3
|
|
|
4
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
4
5
|
materialize(optimalTour, 2).
|
|
5
6
|
|
|
7
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
8
|
+
% The target list fixes the city set; weighted_hamiltonian_path/4 searches tours.
|
|
6
9
|
target_cities([aaa, bbb, ccc, ddd, eee, fff, ggg]).
|
|
7
10
|
|
|
8
11
|
distance(aaa, bbb, 10).
|
|
@@ -22,6 +25,8 @@ distance(ddd, fff, 35).
|
|
|
22
25
|
distance(ddd, ggg, 5).
|
|
23
26
|
distance(eee, fff, 20).
|
|
24
27
|
|
|
28
|
+
% Distances are stored once; distance2/3 makes the graph undirected.
|
|
29
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
25
30
|
distance2(A, B, D) :-
|
|
26
31
|
distance(A, B, D).
|
|
27
32
|
distance2(A, B, D) :-
|
|
@@ -41,6 +46,7 @@ total_distance([X, Y|Tail], D) :-
|
|
|
41
46
|
tsp(Cities, Tour, Distance) :-
|
|
42
47
|
weighted_hamiltonian_path(distance, Cities, Tour, Distance).
|
|
43
48
|
|
|
49
|
+
% Materialized output keeps only the minimum-distance candidate.
|
|
44
50
|
optimalTour(Cities, Optimal) :-
|
|
45
51
|
target_cities(Cities),
|
|
46
52
|
findall([T, D], tsp(Cities, T, D), Solutions),
|
package/examples/turing.pl
CHANGED
|
@@ -3,10 +3,13 @@
|
|
|
3
3
|
% The machine below adds 1 to a binary number represented as a list of bits.
|
|
4
4
|
% The blank tape symbol is #.
|
|
5
5
|
|
|
6
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
6
7
|
materialize(input, 2).
|
|
7
8
|
materialize(output, 2).
|
|
8
9
|
materialize(addsOne, 2).
|
|
9
10
|
|
|
11
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
12
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
10
13
|
compute([], OutTape) :-
|
|
11
14
|
start(_Machine, I),
|
|
12
15
|
find(I, [], #, [], OutTape).
|
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
% Vector dot product, Euclidean norm, and cosine similarity.
|
|
2
2
|
|
|
3
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
3
4
|
materialize(dotProduct, 2).
|
|
4
5
|
materialize(normA, 2).
|
|
5
6
|
materialize(normB, 2).
|
|
6
7
|
materialize(cosineSimilarity, 2).
|
|
7
8
|
|
|
9
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
10
|
+
% Two named vectors form the single cosine-similarity case.
|
|
8
11
|
vector(pair1, a, [1.0, 2.0, 3.0]).
|
|
9
12
|
vector(pair1, b, [4.0, -5.0, 6.0]).
|
|
10
13
|
|
|
14
|
+
% Recursive list folds compute dot products and sums of squares.
|
|
11
15
|
dot([], [], 0.0).
|
|
16
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
12
17
|
dot([A|As], [B|Bs], Dot) :-
|
|
13
18
|
mul(A, B, Product),
|
|
14
19
|
dot(As, Bs, Rest),
|
|
@@ -24,6 +29,7 @@ norm(Vector, Norm) :-
|
|
|
24
29
|
sum_squares(Vector, SumSquares),
|
|
25
30
|
pow(SumSquares, 0.5, Norm).
|
|
26
31
|
|
|
32
|
+
% cosine = dot(A,B) / (norm(A) * norm(B)).
|
|
27
33
|
cosine_similarity(Case, Similarity) :-
|
|
28
34
|
vector(Case, a, A),
|
|
29
35
|
vector(Case, b, B),
|
package/examples/witch.pl
CHANGED
|
@@ -5,12 +5,15 @@
|
|
|
5
5
|
% things that float are made of wood; things made of wood burn; and a woman
|
|
6
6
|
% who burns is a witch.
|
|
7
7
|
|
|
8
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
8
9
|
materialize(floats, 1).
|
|
9
10
|
materialize(madeOfWood, 1).
|
|
10
11
|
materialize(burns, 1).
|
|
11
12
|
materialize(witch, 1).
|
|
12
13
|
materialize(is, 2).
|
|
13
14
|
|
|
15
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
16
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
14
17
|
witch(X) :-
|
|
15
18
|
burns(X),
|
|
16
19
|
woman(X).
|
|
@@ -5,11 +5,14 @@
|
|
|
5
5
|
% bank w or east bank e. The recursive search keeps a visited list so eyelang
|
|
6
6
|
% explores the finite state space without looping.
|
|
7
7
|
|
|
8
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
8
9
|
materialize(solution, 2).
|
|
9
10
|
materialize(solved, 2).
|
|
10
11
|
|
|
12
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
11
13
|
memoize(solve, 4).
|
|
12
14
|
|
|
15
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
13
16
|
solution(Moves) :-
|
|
14
17
|
solve([w, w, w, w], [e, e, e, e], [[w, w, w, w]], Moves),
|
|
15
18
|
length(Moves, 7).
|
package/examples/zebra.pl
CHANGED
|
@@ -4,10 +4,13 @@
|
|
|
4
4
|
% Cigarette). The answer is the classic one: the Norwegian drinks water and the
|
|
5
5
|
% Japanese owns the zebra.
|
|
6
6
|
|
|
7
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
7
8
|
materialize(waterDrinker, 2).
|
|
8
9
|
materialize(zebraOwner, 2).
|
|
9
10
|
materialize(solved, 2).
|
|
10
11
|
|
|
12
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
13
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
11
14
|
zebra(WaterDrinker, ZebraOwner) :-
|
|
12
15
|
eq(Houses, [_, _, _, _, _]),
|
|
13
16
|
first(Houses, house(_, norwegian, _, _, _)),
|
package/package.json
CHANGED
package/playground.html
CHANGED
|
@@ -432,6 +432,7 @@
|
|
|
432
432
|
"ancestor",
|
|
433
433
|
"animal",
|
|
434
434
|
"annotation",
|
|
435
|
+
"auroracare",
|
|
435
436
|
"backward",
|
|
436
437
|
"basic-monadic",
|
|
437
438
|
"bayes-diagnosis",
|
|
@@ -491,6 +492,7 @@
|
|
|
491
492
|
"fibonacci",
|
|
492
493
|
"field-nitrogen-balance",
|
|
493
494
|
"floating-point",
|
|
495
|
+
"flandor",
|
|
494
496
|
"four-color-map",
|
|
495
497
|
"fundamental-theorem-arithmetic",
|
|
496
498
|
"gcd-bezout-identity",
|