eyeprolog 0.5.9 → 0.5.11

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 CHANGED
@@ -7,8 +7,7 @@
7
7
  [![npm version](https://img.shields.io/npm/v/eyeprolog.svg)](https://www.npmjs.com/package/eyeprolog)
8
8
  [![DOI](https://img.shields.io/badge/DOI-10.5281%2Fzenodo.21446308-blue.svg)](https://doi.org/10.5281/zenodo.21446308)
9
9
 
10
- EyeProlog combines ISO Prolog and W3C RDF 1.2 to produce answers with
11
- inspectable proofs.
10
+ EyeProlog combines ISO Prolog and W3C RDF 1.2 to turn portable rules and linked data into answers and inspectable proofs.
12
11
 
13
12
  **[Book — *The Art of EyeProlog*](https://eyereasoner.github.io/eyeprolog/the-art-of-eyeprolog)** ·
14
13
  **[Why EyeProlog?](https://eyereasoner.github.io/eyeprolog/why-eyeprolog)** ·
@@ -37,19 +37,9 @@ divides(A, B) :-
37
37
  (B > 0),
38
38
  (0 is B mod A).
39
39
 
40
- smallest_divisor_from(N, D, D) :-
41
- divides(D, N).
42
-
43
- smallest_divisor_from(N, D, N) :-
44
- (D2 is D * D),
45
- (D2 > N).
46
-
47
- smallest_divisor_from(N, D, S) :-
48
- \+ divides(D, N),
49
- (D2 is D * D),
50
- (D2 =< N),
51
- (D1 is D + 1),
52
- smallest_divisor_from(N, D1, S).
40
+ % smallest_divisor_from/3 is supplied by eyeprolog-library.pl. Its
41
+ % implementation is plain Prolog and avoids repeating a long trial scan for
42
+ % values that are prime.
53
43
 
54
44
  trial_prime(2).
55
45
  trial_prime(3).
package/examples/sieve.pl CHANGED
@@ -1,8 +1,8 @@
1
1
  % Prime enumeration inspired by Eyelet input/sieve.pl.
2
2
  % The 1000-limit answer matches Eyelet output-swipl/sieve.pl.
3
3
  %
4
- % The portable Prolog smallest_divisor_from/3 relation preserves the same
5
- % generated prime list without requiring a host accelerator.
4
+ % A plain-Prolog 6k-1/6k+1 candidate wheel preserves the same generated prime
5
+ % list without requiring a host accelerator.
6
6
 
7
7
  % Output declarations: host-supplied goals select the relations written to this example's golden output.
8
8
  %% goal: primes(X0, X1)
@@ -12,9 +12,38 @@
12
12
  want_primes(1000).
13
13
 
14
14
  % Derivation rules: each rule below contributes one logical step toward the displayed results.
15
+ prime_under(Limit, 2) :-
16
+ (Limit >= 2).
17
+
18
+ prime_under(Limit, 3) :-
19
+ (Limit >= 3).
20
+
21
+ % Starting at 5, alternating steps of 2 and 4 generates exactly the 6k-1 and
22
+ % 6k+1 candidates, excluding every larger multiple of 2 or 3.
23
+ prime_candidate(Current, High, _, Current) :-
24
+ (Current =< High).
25
+
26
+ prime_candidate(Current, High, Step, Value) :-
27
+ (Current < High),
28
+ (Next is Current + Step),
29
+ (NextStep is 6 - Step),
30
+ !,
31
+ prime_candidate(Next, High, NextStep, Value).
32
+
33
+ prime_from(N, Divisor, _) :-
34
+ (Divisor * Divisor > N).
35
+
36
+ prime_from(N, Divisor, Step) :-
37
+ (Divisor * Divisor =< N),
38
+ (N mod Divisor =\= 0),
39
+ (Next is Divisor + Step),
40
+ (NextStep is 6 - Step),
41
+ !,
42
+ prime_from(N, Next, NextStep).
43
+
15
44
  prime_under(Limit, P) :-
16
- between(2, Limit, P),
17
- smallest_divisor_from(P, 2, P).
45
+ prime_candidate(5, Limit, 2, P),
46
+ prime_from(P, 5, 2).
18
47
 
19
48
  primes(Limit, Ps) :-
20
49
  want_primes(Limit),
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "0.5.9",
6
+ "version": "0.5.11",
7
7
  "description": "EyeProlog turns facts and rules into answers and proofs.",
8
8
  "type": "module",
9
9
  "main": "./index.js",