Markus Triska
6b8a679a51
explain potential side-channel attacks due to compact string representation
...
This legitimate concern was already raised by @infogulch in:
https://github.com/mthom/scryer-prolog/issues/1309#issuecomment-1080028854
Thank you a lot!
2024-03-01 22:03:57 +01:00
Markus Triska
ec251b254c
ENHANCED: Safe HMAC verification, using constant time string comparison.
...
Without this provision, the expected HMAC can be gathered from timing
differences depending on the position where the strings first diverge,
and hence an attacker can forge an authenticated message by supplying
the gathered HMAC.
Test case, using exp(E) to succeed exactly 2^E times:
exp(E) :-
N is 2^E,
between(1, N, _).
yielding:
?- Options = [algorithm(sha512),hmac([1,2,3])],
Ds = "test",
crypto_data_hash(Ds, H, Options),
phrase((seq(As),seq(Bs)), H),
same_length(Bs, Cs),
maplist(=(a), Cs),
append(As, Cs, H1),
time((exp(10),crypto_data_hash(Ds, H1, Options),false)).
%@ % CPU time: 0.710s, 7_942_187 inferences
%@ % CPU time: 0.713s, 7_942_187 inferences
%@ % CPU time: 0.712s, 7_942_187 inferences
%@ % CPU time: 0.711s, 7_942_187 inferences
%@ % CPU time: 0.710s, 7_942_187 inferences
%@ % CPU time: 0.711s, 7_942_187 inferences
%@ % CPU time: 0.710s, 7_942_187 inferences
?- length(_, L), time((exp(10),crypto_data_hash("test", "3caebd1a0a2647930319a660b7d3642eb380fbd43202f9f6d08aabaa9ba50c39522a12ead10f0423f0af613cbc6fea74ad682ee11f563cc2e735722004fda2ba", [algorithm(sha512),hmac([0,L])]),false)).
%@ % CPU time: 0.733s, 7_878_699 inferences
%@ % CPU time: 0.734s, 7_878_699 inferences
%@ % CPU time: 0.732s, 7_878_699 inferences
%@ % CPU time: 0.733s, 7_878_699 inferences
%@ % CPU time: 0.733s, 7_878_699 inferences
%@ % CPU time: 0.733s, 7_878_699 inferences
%@ % CPU time: 0.733s, 7_878_699 inferences
%@ % CPU time: 0.733s, 7_878_699 inferences
%@ % CPU time: 0.733s, 7_878_699 inferences
%@ % CPU time: 0.733s, 7_878_699 inferences
%@ % CPU time: 0.733s, 7_878_699 inferences
%@ % CPU time: 0.515s, 5_525_404 inferences
%@ error('$interrupt_thrown',repl/0).
2024-03-01 18:59:48 +01:00
Markus Triska
1dd0c599c6
DOC: Add DocLog comments for reasoning about elliptic curves.
2024-02-24 20:43:57 +01:00
Markus Triska
27852eafd7
ADDED: Hash-based message authentication code (HMAC), using hmac(Key).
2024-02-22 20:53:27 +01:00
Markus Triska
74a525a672
link to newly available paper on analysis of dose-escalation protocols
...
Many thanks to @dcnorris for this great application and cooperation!
2024-02-18 09:25:29 +01:00
Markus Triska
8f2e9c6b94
FIXED: char_type/2 for unbound first argument.
...
Surrogate pairs form a gap in valid character codes, see:
https://github.com/mthom/scryer-prolog/issues/2326#issuecomment-1937864665
Many thanks to @Skgland for the pointer, and to @librarianmage for the
question that spawned this!
This addresses #2326 .
2024-02-11 22:19:19 +01:00
Markus Triska
53b7d9eec9
ENHANCED: Bidirectional char_type/2, addressing #2321 .
...
Suggested by @librarianmage, many thanks!
2024-02-07 20:57:28 +01:00
Markus Triska
aa98a7e7d6
ADDED: clpz_t/2, generalizing support for use with library(reif)
...
This was suggested and contributed by @librarianmage in:
https://github.com/mthom/scryer-prolog/issues/2225#issuecomment-1890801923
Many thanks!
If anyone can find a better predicate name, please let us know any time!
2024-02-06 19:05:29 +01:00
Markus Triska
3505cc3ba0
update answers using latest toplevel output
2024-01-25 21:33:27 +01:00
Markus Triska
05ba5f4358
rely on recently improved argument indexing for determinism
...
This is possible as of 4fd37335f5 .
2024-01-25 21:31:08 +01:00
Markus Triska
a6ccf95076
improve error context
...
Source: https://github.com/mthom/scryer-prolog/issues/2304#issuecomment-1906434756
2024-01-23 21:43:34 +01:00
Markus Triska
665f319a0e
no longer use (->)//2, since it is implementation defined
...
This addresses #2304 .
2024-01-23 21:42:36 +01:00
Markus Triska
81dba11ab1
use newly available false//0
2024-01-21 22:53:22 +01:00
Markus Triska
388fa5baa9
no longer use (->)//2, since it is implementation dependent
2024-01-21 22:50:36 +01:00
Markus Triska
fe3241c07c
remove checks that are now no longer needed due to representation errors
2024-01-21 10:28:19 +01:00
Markus Triska
0559ddca2a
ENHANCED: Throw representation errors for DCG bodies that use unsupported constructs.
...
This addresses #2285 .
2024-01-21 10:28:19 +01:00
Markus Triska
98a046500f
MODIFIED: (->)/2 in DCGs is now only supported in the context of if-then-else.
...
That is, ( If -> Then ; Else ) is still supported, but ( If -> Then ) not.
2024-01-21 10:28:19 +01:00
Markus Triska
2f783f0aef
Correct arithmetic inequalities accidentally broken in f5d9a67f36.
...
Example:
?- X #>= Y.
%@ clpz:(X#>=Y).
2024-01-07 09:33:54 +01:00
Markus Triska
e702fe5c68
ADDED: Support for higher-order non-terminals phrase//[2,3]
...
These non-terminals take a grammar rule body and additional arguments
as arguments. These arguments are appended to the first argument.
A key motivation for the introduction of these non-terminals is found
in the discussion and sample code provided by @bakaq in:
https://github.com/mthom/scryer-prolog/discussions/2260
In this way, portable higher-order DCG programming is possible while
keeping the logical grammar rule expansion implementation dependent.
Example:
?- phrase(phrase('.', a, []), Cs).
Cs = "a".
2024-01-06 14:02:13 +01:00
Markus Triska
f2b63d1689
Prevent assertion of clauses for (-->)/2 when DCGs are enabled.
...
This addresses #1508 .
2024-01-05 19:04:53 +01:00
Markus Triska
f5d9a67f36
ENHANCED: Suspend propagation during filtering in global_cardinality/2.
...
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.
The SICStus-style attributed variables mechanism of Scryer Prolog
automatically prevents very subtle interaction problems that can arise
in systems that do not give all variables that are involved in a
unification an opportunity to schedule their propagators.
An example of such a subtle interaction is:
?- tuples_in([[A,C,B]], [[3,1,3],[4,2,4]]),
global_cardinality([A,B,D], [3-1,4-2]),
A = 4.
A = 4 causes pgcc_check/1 and pgcc/2 to be queued in the fast and slow
queue, respectively. In the fast queue, there is also rel_tuple/2,
which is worked off after gcc_check/1 and simultaneously instantiates
both C and B (to 2 and 4, respectively). Instantiation of C schedules
do_queue//0 from verify_attributes/3. Note that C does not participate
in the global_cardinality/2 constraint.
Critically, B also gets an opportunity to schedule its propagators in
this case, so another gcc_check/1 is run before gcc_global/2!
2024-01-01 10:50:06 +01:00
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