Commit Graph

3664 Commits

Author SHA1 Message Date
notoria
1f3de74cbd Fix bound computation in (^)/2
?- A in 0..1, B in-1..0, A^2 #= B.
   false. % unexpected.
?- A^2 #= B, A in 0..1, B in-1..0.
   A = 0, B = 0.
2024-01-07 20:19:40 +01:00
notoria
770ead9c05 Remove min/2 and max/2 when possible
?- A #= min(A,B).
   clpz:(B#>=A), clpz:(A#=min(A,B)). % unexpected.
?- A #= min(A,0).
   clpz:(A in inf..0), clpz:(A#=min(A,0)). % unexpected.
2024-01-07 20:15:28 +01:00
notoria
fe371ff1d1 Fix min/2 and max/2
?- X in 0..1, Y in 2..4, Z #= max(X,Y).
   clpz:(X in 0..1), clpz:(Z#=max(X,Y)), clpz:(Z in 2..4), clpz:(Z#>=Y), clpz:(Y in 2..4). % unexpected.
?- X in 0..1, Y in 2..4, Z #= max(Y,X).
   Y = Z, clpz:(X in 0..1), clpz:(Y in 2..4).
2024-01-07 20:14:32 +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
Mark Thom
92b85d4ba6 Merge pull request #2264 from Skgland/fix-os-argv-1
Fix os:argv/1 in case the raw args contain multiple `--`
2024-01-06 15:52:53 -07: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
Mark Thom
ed92e1b4f4 Merge pull request #2275 from triska/master
Prevent assertion of clauses for (-->)/2 when DCGs are enabled.
2024-01-05 12:33:05 -07: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
Mark
d51defed06 fix cargo --fmt check error 2024-01-04 13:56:57 -07:00
Mark
851ea2c45b add missing permission error in compile_assert (#2271) 2024-01-04 13:53:46 -07:00
Mark
ec97ee5d41 fix acceptance of invalid syntax, update iso_conformity_tests.pl (#2270) 2024-01-04 13:14:58 -07:00
Skgland
78b83ca1e1 simplify os:argv/1 fix 2024-01-04 19:26:10 +01:00
Skgland
ea0130d114 use once to limit solutions instead of cut 2024-01-04 18:14:32 +01:00
Skgland
e66e7c5034 add another test case for os:argv/1 2024-01-04 18:12:38 +01:00
Mark Thom
ff010678c3 Merge pull request #2269 from aarroyoc/fix-2267
Use reqwest async and use futures::executor
2024-01-03 15:40:48 -07:00
Mark Thom
5abc72cc8b Merge pull request #2268 from aarroyoc/docs-toplevel
Small fixes in documentation and toplevel.pl
2024-01-03 14:52:34 -07:00
Adrián Arroyo Calle
fac8866fb4 Use reqwest async and use futures::executor 2024-01-03 22:43:22 +01:00
Adrián Arroyo Calle
d58e91303b Small fixes in documentation and toplevel.pl 2024-01-03 19:52:50 +01:00
Skgland
8bd0317e9c fix os:argv(V) not completing 2024-01-02 21:43:38 +01:00
Skgland
76b1167842 fix os:argv 2024-01-02 20:54:37 +01:00
Skgland
7537686d8f cover both args ending in -- and args not ending in -- for os:argv/1 test 2024-01-02 20:48:38 +01:00
Skgland
6fc340c4db remove unnecessary true 2024-01-02 20:27:14 +01:00
Skgland
38f25af47d cover trailing -- and os:argv([]) in os_argv test 2024-01-02 20:23:53 +01:00
Skgland
91df533834 fix os:argv/1 2024-01-02 19:55:27 +01:00
Skgland
9a05ca0667 add failing test for os:argv issue
See https://github.com/mthom/scryer-prolog/pull/2263#issuecomment-1874400820
2024-01-02 19:51:09 +01:00
Mark
ccf581d86f expand module names in transitive goals (#2255) 2024-01-02 11:34:38 -07:00
Mark
1dc546ac36 fix cargo fmt --check 2024-01-02 10:08:00 -07:00
Mark
372b4bca46 mark anonymous variables in compile_is_call (#2257) 2024-01-02 10:06:07 -07:00
Mark Thom
5c89029462 Merge pull request #2263 from aarroyoc/docs-toplevel
Move argv/1 to library(os)
2024-01-02 09:19:10 -07:00
Mark Thom
a475a8a899 Merge pull request #2262 from triska/faster_global_cardinality
ENHANCED: Suspend propagation during filtering in global_cardinality/2.
2024-01-02 09:18:42 -07:00
Adrián Arroyo Calle
47b5ae7984 Move argv/1 to library(os) 2024-01-02 13:16:11 +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
Mark Thom
1f90dbec20 Merge pull request #2259 from bakaq/comment_warnings
Emit warnings as Prolog comments
2024-01-01 00:33:58 -07:00
Mark Thom
d713456e29 Merge pull request #2258 from triska/faster_scalar_product
ENHANCED: Suspend propagation during filtering in scalar product constraints.
2024-01-01 00:33:36 -07:00
bakaq
d9d90d1ae8 Emit warnings as Prolog comments 2023-12-30 17:39:20 -03: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
Mark Thom
1e0fa56786 Merge pull request #2252 from aarroyoc/bump-versions
Update ring and bump versions in Cargo.lock
2023-12-29 13:10:19 -07:00
Mark Thom
97d5bf7e97 Merge pull request #2254 from bakaq/issue_1404
Parse as much of a list as possible as a partial string
2023-12-29 10:40:19 -07:00
Mark
75302ab716 check that Target is an atom in scoped_clause_to_evacuable (#2248) 2023-12-29 10:12:08 -07:00
Adrián Arroyo Calle
742de9e77c Update ring and bump versions in Cargo.lock 2023-12-28 20:23:01 +01:00
bakaq
921046e886 Parse as much of a list as possible as a partial string #1404 2023-12-28 15:12:32 -03:00
Mark Thom
781f4afe25 Merge pull request #2251 from triska/crrl_ed25519
improve structure, naming and explanation of PKCS#8v2 encoding
2023-12-27 17:37:42 -07:00
Markus Triska
10158f62e0 improve structure, naming and explanation of PKCS#8v2 encoding 2023-12-27 21:12:52 +01:00
Mark
42d6749501 throw errors from char_reader.rs and get_n_chars when reading bad UTF8 data (#2244) 2023-12-26 12:31:04 -07:00
Mark Thom
2fa46e6b6c Merge pull request #2245 from triska/crrl_ed25519
ENHANCED: Use crrl for Ed25519 signing and signature verification.
2023-12-26 10:09:08 -07: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
Mark Thom
799035c692 Merge pull request #2243 from bakaq/issue_2241
Fix anonymous attributed variables not showing in toplevel
2023-12-22 09:53:40 -07:00
Mark Thom
6c07256dc5 Merge pull request #2242 from triska/starting
explain starting Scryer Prolog
2023-12-22 09:52:56 -07:00
bakaq
20c6a327ea Fix anonymous attributed variables not showing in toplevel #2241 2023-12-22 13:07:09 -03:00
Markus Triska
bcfdc812f9 explain starting Scryer Prolog 2023-12-22 08:36:29 +01:00