Markus Triska
62b61107e0
ENHANCED: Suspend propagation during filtering in scalar product constraints.
...
This allows subsequently invoked constraints to take the entire
filtering results into account, instead of being invoked when the
obtained information is not yet entirely used.
It speeds up programs such as the one in:
https://github.com/triska/clpz/issues/26
2023-12-30 10:30:25 +01:00
Markus Triska
10158f62e0
improve structure, naming and explanation of PKCS#8v2 encoding
2023-12-27 21:12:52 +01:00
Markus Triska
47ec5eb6c6
ENHANCED: Use crrl for Ed25519 signing and signature verification.
...
The main motivation for this change is the introduction of the newly
available predicate ed25519_seed_keypair/2, allowing to generate a key
pair from a given seed. In this way, a key pair can be dynamically
generated from (for example) a password, using crypto_password_hash/3
in combination with crypto_data_hkdf/4 to generate the seed. The
advantage of this method is that the private key need not be stored at
all anywhere.
It is not possible to add a corresponding feature to ring, since it is
closed as "not planned": https://github.com/briansmith/ring/issues/1003
I also used this opportunity to move more of the logic to Prolog. We
now have total control of the key pair representation, and I also
changed the representation to conform to the PKCS#8 v2 standard,
something that only later ring versions do, while still being
backwards compatible with tools that produce a wrong representation
including earlier ring versions.
Another great advantage we get from this change is that the Ed25519
predicates now also run on the 32-bit and WASM versions of Scryer.
2023-12-26 07:33:44 +01:00
Markus Triska
bcfdc812f9
explain starting Scryer Prolog
2023-12-22 08:36:29 +01:00
Markus Triska
eb575b9882
support (#=)/3 and (#<)/3 also in the monotonic execution mode
2023-12-02 22:33:56 +01:00
Markus Triska
8cb4dfef62
ADDED: term_si/1, true for terms
...
One use case is to ensure that once/1 is safe to use:
term_si(Goal),
once(Goal)
In such cases, Goal is ground and can yield at most one solution,
therefore once/1 does not remove any solutions.
2023-11-29 21:25:09 +01:00
Markus Triska
186bba9d75
ENHANCED: time/1 now shows the number of inferences
...
Example:
?- time(member(X, "abc")).
% CPU time: 0.000s, 1 inference
X = a
; % CPU time: 0.000s, 3 inferences
X = b
; % CPU time: 0.000s, 3 inferences
X = c.
This is an initial step towards addressing #1039 .
2023-11-21 20:36:44 +01:00
Markus Triska
a02bd46094
mention more passing tests
2023-11-14 04:09:03 +01:00
Markus Triska
721cf20cf7
shift morphing to the more general p/2 case
2023-10-12 23:32:04 +02:00
Markus Triska
6ed9a99832
ENHANCED: Omit unnecessary residual constraints in disentailed reified (//)/2
...
Example:
?- #\ 0#=(Y// -1)/0.
%@ clpz:(Y in inf..sup).
This addresses #2104 .
2023-10-12 23:32:04 +02:00
Markus Triska
8de3498e07
use round brackets around operators to form valid Prolog terms
2023-10-10 21:32:45 +02:00
Markus Triska
26fdf83a48
update comment to reflect the used propagators
2023-10-10 21:32:45 +02:00
Markus Triska
32af047925
remove definition and calls of do_queue/0, which has become a NOP
2023-10-10 21:32:45 +02:00
Markus Triska
282633c877
ENHANCED: Queue morphed propagators to give them a chance for propagation.
...
This addresses #2096 :
?- B in -2..0, 0#<==>0#=0/(B*B),labeling([],[B]).
B = 0.
?- A#<==>A#=A/A^2,A=0.
A = 0.
2023-10-10 21:32:45 +02:00
Markus Triska
7c1cd18a06
Z --> Y
2023-10-09 23:13:09 +02:00
Markus Triska
8329d222cb
ENHANCED: use (+)/2 to express unary minus
...
This makes answers a bit shorter and more readable.
Example:
?- X #= -Y.
clpz:(X+Y#=0).
This addresses #2058 .
2023-10-09 22:59:51 +02:00
Markus Triska
1c3df1cdd7
attach the propagator to Y
2023-10-09 21:55:39 +02:00
Markus Triska
99348ec309
ENHANCED: Omit projection of morphed (^)/2 in disentailed constraints.
...
Example:
?- B #<==> (0^Y/0) #= Z.
B = 0, clpz:(Y in 0..sup), clpz:(Z in inf..sup).
2023-10-09 21:33:04 +02:00
Markus Triska
cacc7f3193
FIXED: Queue triggered propagators to be processed after pexp/3 finishes
...
If reification constraints (such as reified equality) are triggered
here, then they may wish to disable this propagator and remove
attributes from auxiliary variables. If the pexp/3 propagation is
interrupted for that purpose, then the attributes will be
unintentionally reattached by the following fd_put/3 calls in this
propagator. We must ensure that this propagator completely finishes,
so we queue the triggered propagators for later processing.
geq/2 implements propagator activation outside the queue, and thus
should not be used in propagators in the way it was used here.
pexp/3 by itself may not seem particularly important. However, it can
arise by metamorphosis from Var*Var. Example:
?- A#<==> -1#=C*C, C in 0..1.
A = 0, clpz:(C in 0..1).
This addresses #2089 .
2023-10-09 20:42:28 +02:00
Markus Triska
743412de33
ENHANCED: Remove no longer needed morphed propagators.
...
This addresses all remaining cases from #2083 , excepting (//)/2:
?- #\ 1#=(X*X)/0.
clpz:(X in inf..sup).
?- #\ 1#=(X+X)/0.
clpz:(X in inf..sup).
Still remaining:
?- #\ 0#=(Y// -1)/0.
clpz:(-1*Y#=_A).
2023-10-08 20:15:56 +02:00
Markus Triska
f34703a279
remove no longer needed goal projection for pdiv
2023-10-08 12:07:17 +02:00
Markus Triska
5cce8ddd7d
ENHANCED: avoid pending residual constraints in disentailed reified (div)/2
...
This addresses #2083 :
?- #\0#=0//0 div 2.
true.
2023-10-08 11:53:06 +02:00
Markus Triska
ff63eacf2c
replace list//1 by seq//1 from library(dcgs)
2023-10-08 11:28:52 +02:00
Markus Triska
8121dce2a4
instead of prdiv, use ptimes directly
2023-10-08 09:46:41 +02:00
Markus Triska
4d910f6bfe
FIXED: variables in reified propagators must share the same queue
...
Otherwise, propagation steps may be inadvertently omitted, if
propagators are scheduled in a different queue.
This addresses #2084 .
2023-10-08 09:45:20 +02:00
Markus Triska
51c00fce57
adapt query to Scryer Prolog
2023-10-08 09:26:22 +02:00
Markus Triska
3fc969b38b
reorder and realign entries to form a contiguous group starting with d(D)
2023-10-06 22:58:56 +02:00
Markus Triska
7ed38d6c6c
FIXED: reification of (/)/2 for undefined subexpressions
...
This addresses #2078 and #2079 .
2023-10-06 22:55:46 +02:00
Markus Triska
7c10683e46
Revert "FIXED: corrections to expansion_simpler/2"
...
This reverts commit f3b848537a .
The root cause of this problem is a mistake in ground/1. See #2073 .
2023-10-03 19:16:04 +02:00
Markus Triska
f3b848537a
FIXED: corrections to expansion_simpler/2
...
Example:
?- X = 0, Y = 0, Z #= X-1 + Y-1.
X = 0, Y = 0, Z = -2.
This addresses #2064 .
See ca5a5b4392 for a previous issue in
this logic.
2023-10-02 23:17:06 +02:00
Markus Triska
5b1df8c4b3
use version from crates.io
2023-09-13 20:45:38 +02:00
Markus Triska
85cc4a80d0
remove code that is not needed in Scryer Prolog
2023-09-09 07:46:01 +02:00
Markus Triska
6fe85c5779
remove more attributes so that they do not appear in residual goals
2023-09-09 07:46:01 +02:00
Markus Triska
b38a56e7d3
move compatibility predicates and meta_predicate/1 declarations so that they are correctly taken into account
2023-09-09 07:46:01 +02:00
Markus Triska
ec67752db4
shorter partition/5, relying on first instantiated argument indexing
2023-09-09 07:32:06 +02:00
Markus Triska
ad4c17fbb6
add meta_predicate/1 declaration for include/3 and exclude/3
2023-09-09 07:32:06 +02:00
Markus Triska
672979c515
shorter include/3 and exclude/3, relying on improved indexing
2023-09-09 07:32:06 +02:00
Markus Triska
efcc2b81cd
add licensing information, addressing part of #1798
2023-09-09 07:32:06 +02:00
Markus Triska
640f29fe0f
update required Rust version
2023-09-09 07:30:23 +02:00
Markus Triska
b843b76b7a
this holds for all architectures (also 32-bit systems)
2023-09-08 23:22:36 +02:00
Markus Triska
182afe3b7d
update comment
2023-09-08 22:34:24 +02:00
Markus Triska
1967518fa2
FIXED: documentation of countall/2 ( #1976 )
2023-09-05 19:42:55 +02:00
Markus Triska
d54c3369b3
FIXED: countall/2 for zero solutions ( #1996 )
...
Example:
?- countall(false, 0).
true.
2023-09-05 19:39:05 +02:00
Markus Triska
aca0de06cd
FIXED: make occurs_check and answer_write_options flags discoverable
...
Quoting from 7.11 Flags:
NOTE - A built-in predicate current_prolog_flag(Flag, Value)
(8.17.2) enables a program to discover all the flags supported
by a processor and their current values.
2023-09-04 00:56:09 +02:00
Markus Triska
85f4bdbe0b
update answer
2023-09-03 22:01:38 +02:00
Markus Triska
1257ba165f
untabify
2023-09-03 21:57:51 +02:00
Markus Triska
1c33d2a2ed
remove clpb_max/1 attribute for residual goal projection
...
Example:
?- sat(A+B), weighted_maximum([1,1], [A,B], Max).
A = 1, B = 1, Max = 2.
2023-09-03 21:56:15 +02:00
Markus Triska
5ebd4bb2a4
mention precompiled binaries
2023-09-03 14:12:46 +02:00
Markus Triska
c934e06171
ADDED: New Prolog flag, answer_write_options.
...
This lets us specify additional write options used by the top level
for writing answers.
2023-09-03 10:49:07 +02:00
Markus Triska
75aec69de1
replace adjacent whitespace characters with a single SPACE character
2023-08-27 13:01:13 +02:00
Markus Triska
9b96735615
ENHANCED: rudimentary implementation of normalize_space
...
This removes leading and trailing whitespace from the text. Whitespace
within the string is not yet considered.
2023-08-27 09:56:30 +02:00
Markus Triska
98086de77e
attach more propagators before starting propagation
...
This prevents repeated triggering of already attached propagators
while new propagators are being attached to involved variables.
2023-08-22 21:52:55 +02:00
Markus Triska
24456e9703
remove optional (+)/1 prefix in get_atts/2 and put_atts/2 calls
...
The (+)/1 prefix in get_atts/2 at line 4219 by itself already causes a
greater than 15% slowdown for the benchmark shown in #1730 :
?- N #= 2^14,
time(((between(1, N, _),
X #\= Y,
false)
; true)).
The performance impact is not a good reason to remove the optional
(+)/1 prefix! Performance issues should be addressed at the root, in
this case get_atts/2 (#1962 ). We should never manually work around
performance issues in built-in predicates.
In contrast, readability is a good argument, and I find the calls
slightly easier to read without the optional (+)/1 prefix.
The prefix is now consistently omitted when possible.
2023-08-22 21:52:55 +02:00
Markus Triska
7f024f3b8d
use pneq/2
2023-08-22 21:52:55 +02:00
Markus Triska
67c1b171c7
enforce same queue in more constraints
2023-08-22 21:52:55 +02:00
Markus Triska
04fbb0c1ce
append the entire queues instead of inserting each element individually
2023-08-22 21:52:55 +02:00
Markus Triska
327423ab84
adapt query to Scryer Prolog
2023-08-21 21:19:29 +02:00
Markus Triska
20cfffdff5
update answers
2023-08-21 21:19:29 +02:00
Markus Triska
d8e126044f
use can_be/2
2023-08-21 21:19:29 +02:00
Markus Triska
013df58fea
ENHANCED: more extensive type checking in curve25519_scalar_mult/3
2023-08-20 14:43:14 +02:00
Markus Triska
745ddc2c87
switch to using crrl for scalar multiplication on Curve25519
...
This is to facilitate WASM compilation as currently worked on
by @rujialiu in #615 . Many thanks, and many thanks to @pornin
for crrl which makes this possible!
2023-08-20 14:43:14 +02:00
Markus Triska
92fdc7e380
use newly available double_quotes/1 write option in portray_clause_//1
2023-08-17 23:05:21 +02:00
Markus Triska
f02cd0ad3c
ENHANCED: domain error in zcompare/3 ( #1723 )
2023-08-14 17:54:18 +02:00
Markus Triska
4a6bf5fd5f
reorder tests, per https://github.com/mthom/scryer-prolog/pull/1961#pullrequestreview-1574380588
2023-08-11 23:41:54 +02:00
Markus Triska
26c0b4fc75
ADDED: succ/2, part of the Prologue for Prolog
...
Specification:
https://www.complang.tuwien.ac.at/ulrich/iso-prolog/prologue#succ
2023-08-11 22:46:46 +02:00
Markus Triska
924750f826
ENHANCED: more efficient chars_si/1, using specialized predicates of Scryer
...
Source:
https://github.com/mthom/scryer-prolog/issues/1947#issuecomment-1665113488
2023-08-04 21:18:37 +02:00
Markus Triska
8073a4ba87
add character_si/1 and use it to correct chars_si/1
...
This addresses #1947 .
2023-08-03 22:27:13 +02:00
Markus Triska
0ddda0a864
FIXED: do not attach constraint if the propagator is already entailed and killed
...
Example:
?- A#=A//A#==>B,A-B=1-1.
A = 1, B = 1.
This addresses #1941 .
2023-08-03 00:26:40 +02:00
Markus Triska
1c089a2bbb
better wording, applying the feedback from @dcnorris. Thank you a lot!
2023-07-31 22:07:13 +02:00
Markus Triska
54a887cdc3
ENHANCED: forget auxiliary constraints set up by the propagator for multiplication
...
This addresses the issue raised in https://github.com/mthom/scryer-prolog/discussions/1937 .
2023-07-31 21:57:25 +02:00
Markus Triska
03f7b01109
FIXED: correct handling of ascii_punctuation in char_type/2 ( #1926 )
2023-07-27 20:22:05 +02:00
Markus Triska
554e956ef5
remove another !/0 which is now no longer necessary due to improved indexing
2023-07-22 06:52:29 +02:00
Markus Triska
5d3295c40c
ENHANCED: use newly available read_term_from_chars/3 for better errors
...
Examples, previously:
$ scryer-prolog -g "member(X,Ls"
?-
$ scryer-prolog -g "member(X,Ls)"
member(_542,_543) causes: error(existence_error(procedure,member/2),member/2)
?-
Now:
$ scryer-prolog -g "member(X,Ls"
"member(X,Ls" cannot be read: error(syntax_error(incomplete_reduction),read_term_from_chars/3:0)
$ scryer-prolog -g "member(X,Ls)"
member(X,Ls) causes: error(existence_error(procedure,member/2),member/2)
?-
This also addresses #1185 .
2023-07-16 14:16:07 +02:00
Markus Triska
9590d5200c
ADDED: countall/2, for compatibility with GNU Prolog.
...
Example:
?- countall(member(X, "abc"), N).
N = 3.
2023-07-13 23:08:13 +02:00
Markus Triska
814ce2d672
ENHANCED: improved determinism of member/2
...
Example:
?- member(X, "abc").
%@ X = a
%@ ; X = b
%@ ; X = c.
This addresses #750 .
2023-07-12 14:39:08 -06:00
Markus Triska
918dfca409
DOC: new section on applications of Scryer Prolog
...
This addresses an important aspect of #1777 .
2023-07-09 10:29:53 -06:00
Markus Triska
d18f128a3c
correct \\ to \, addressing #1865
2023-07-09 10:29:53 -06:00
Markus Triska
6525c1f543
print version more readably, addressing #1868
2023-07-08 08:19:05 +02:00
Markus Triska
3b9b9e75c4
make double_quotes write option not dependent on double_quotes flag
...
This gives consistent results without depending on another flag.
2023-07-05 21:37:11 +02:00
Markus Triska
7f159a7ed2
advertise newly achieved strong syntactic conformance: all current tests pass
...
This addresses an important aspect of #1777 .
2023-07-03 22:04:26 +02:00
Markus Triska
31030738a4
remove now unneeded check
2023-06-30 22:14:00 +02:00
Markus Triska
42282c6e6e
remove unneeded case: only operator definitions should count, not quoting
2023-06-30 18:03:21 +02:00
Markus Triska
a3f8ddd24a
remove subsumed case: F == Value means Arity =:= 0, now considered above
2023-06-30 18:02:43 +02:00
Markus Triska
bfe808a779
shorten needs_bracketing/2
2023-06-30 18:01:54 +02:00
Markus Triska
28065b0565
constrain bracketing to operators with pertaining arity
...
Example:
?- X = -->(a,b,c).
X = -->(a,b,c).
2023-06-30 18:01:17 +02:00
Markus Triska
db972de40c
bracket all operators that are direct operands of (=)/2
...
This addresses #804 .
2023-06-30 08:03:38 +02:00
Markus Triska
c84a5c3282
remove unneeded single quotes
2023-06-29 19:25:23 +02:00
Markus Triska
ceb276b249
use copy_term_nat/2
2023-06-27 22:37:23 +02:00
Markus Triska
9bc3757a9e
another case of "read" --> "get", for an only internally used predicate
2023-06-24 11:48:28 +02:00
Markus Triska
18d0a74f23
MODIFIED: read_line_to_chars/3 is now called get_line_to_chars/3
...
This is for consistency with other I/O predicates, where "read" always
indicates Prolog terms. Please adjust your programs accordingly.
2023-06-24 11:47:32 +02:00
Markus Triska
2716381e7b
FIXED: correct dereferencing in atom_codes/2 and number_codes/2.
...
This addresses #1818 .
Test case:
run :-
length(Ls, L),
portray_clause(L),
maplist(=(X), Ls),
X = Y,
Y = 12,
atom_codes(_, Ls),
false.
2023-06-23 14:11:31 -06:00
Markus Triska
97bd778745
FIXED: correctly reset counter in reset_gensym/2 ( #1807 )
...
Many thanks to @infradig for detecting this issue and suggesting this
correction!
2023-06-23 14:11:31 -06:00
Markus Triska
43df2e2649
shorten gensym/2
2023-06-23 14:11:31 -06:00
Markus Triska
c2f2623471
extend logic to all control and whitespace characters
...
This addresses #1802 .
2023-06-23 14:11:31 -06:00
Markus Triska
86beb222ae
rely on first instantiated argument indexing in the definitions of foldl/N
...
This allows shorter and more natural definitions.
2023-06-23 14:11:31 -06:00
Markus Triska
5e124ccf44
ENHANCED: allow Roman numerals in strings
...
Example:
?- X = "ↁ".
X = "ↁ".
This addresses #1790 .
2023-06-23 14:11:31 -06:00
Markus Triska
47d4e6d2f9
FIXED: consistent read/write of further control characters, and non-breaking space
...
Example:
?- X = '\xa0\'.
X = '\xa0\'.
This addresses #1768 .
2023-06-23 14:11:31 -06:00
Markus Triska
5154314786
FIXED: correct dereferencing in atom_codes/2 and number_codes/2.
...
This addresses #1818 .
Test case:
run :-
length(Ls, L),
portray_clause(L),
maplist(=(X), Ls),
X = Y,
Y = 12,
atom_codes(_, Ls),
false.
2023-05-29 11:43:56 +02:00
Markus Triska
021c01dfd0
FIXED: correctly reset counter in reset_gensym/2 ( #1807 )
...
Many thanks to @infradig for detecting this issue and suggesting this
correction!
2023-05-16 22:42:57 +02:00
Markus Triska
30f222b837
shorten gensym/2
2023-05-16 22:41:20 +02:00