Commit Graph
100 Commits
Author SHA1 Message Date
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
Markus Triska 49addc7b04 extend logic to all control and whitespace characters
This addresses #1802.
2023-05-14 09:25:08 +02:00
Markus Triska 4e60cc46a2 rely on first instantiated argument indexing in the definitions of foldl/N
This allows shorter and more natural definitions.
2023-05-04 00:50:27 +02:00
Markus Triska d8edf7bfff FIXED: consistent read/write of further control characters, and non-breaking space
Example:

    ?- X = '\xa0\'.
       X = '\xa0\'.

This addresses #1768.
2023-05-03 23:29:22 +02:00
Markus Triska e951db662d ENHANCED: allow Roman numerals in strings
Example:

    ?- X = "ↁ".
       X = "ↁ".

This addresses #1790.
2023-05-03 22:02:47 +02:00
Markus Triska 2a1b8f37ec remove residual goal for ground BDD
Example:

    ?- sat(X).
       X = 1.
2023-04-23 09:23:00 +02:00
Markus Triska 8b7281fad0 ADDED: dif_si/2
Source: https://stackoverflow.com/questions/20223390/prolog-a-person-is-a-sibling-of-himself

In Scryer Prolog, this is actually not needed, since Scryer Prolog provides
dif/2 in library(dif). However, it is still useful to provide dif_si/2 for two reasons:

  1) to more easily port code from systems where only dif_si/2 is available
  2) to provide correct disequality in other systems that adopt this library
2023-04-23 00:37:14 +02:00
Markus Triska 5763a4b9df FIXED: propagation for ground tuples
Example:

    ?- tuples_in([[A,A]],[[0,1],[2,0]]).
       false.

See https://github.com/triska/clpz/issues/22.
2023-04-13 23:39:45 +02:00
Markus Triska 5dce7d9075 FIXED: enforce equality also for ground elements in tuples
Example:

    ?- tuples_in([[A,B]], [[1,2],[3,4]]),
       tuples_in([[A,B]], [[3,2]]).
       false.

See https://github.com/SWI-Prolog/swipl-devel/issues/1160.
2023-04-11 22:33:19 +02:00
Markus Triska f08f539768 do not create attributed variables for ground tuples 2023-04-11 21:26:18 +02:00
Markus Triska be45672e22 actually disable and reenable the queue 2023-04-11 21:26:18 +02:00
Markus Triska 94efb9ffe3 remove no longer needed clpz_relation attributes 2023-04-11 21:26:18 +02:00
Markus Triska fd1e902492 do not leave an attribute when (re-)enabling a queue 2023-04-11 21:14:18 +02:00
Markus Triska fe27605497 FIXED: number_chars(N, "0' "), addressing #1580.
There may be a more elegant way to solve this.
2023-04-02 10:04:52 +02:00
Markus Triska b87fe1e21f DOC: link to "Indexing dif/2" 2023-04-01 11:04:37 +02:00
Markus Triska d6ac125425 DOC: explain location of scryer-prolog after compilation
This question was recently raised on the #scryer IRC channel.
2023-04-01 11:04:37 +02:00
Markus Triska b79d8732ea use the release flag so that the instructions can be used verbatim
Also, the location of the executable depends on this flag.
2023-04-01 11:04:33 +02:00
Markus Triska 3df0806017 change "run" to "build", since "run" leads to a Scryer prompt which can be unexpected 2023-04-01 11:03:31 +02:00