Commit Graph

122 Commits

Author SHA1 Message Date
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
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
ceb276b249 use copy_term_nat/2 2023-06-27 22:37:23 +02:00
notoria
495df8846a Compute correctly the domain of the remainder 2023-05-27 13:47:14 +02:00
notoria
05d48cdcc3 Don't add variable
?- Z #= 0, Z #= X mod Y.
   Z = 0, clpz:(_A*Y#=X), clpz:(Y in inf.. -1\/1..sup) % Unexpected.

The expected result:
   Z = 0, clpz:(X mod Y#=0), clpz:(Y in inf.. -1\/1..sup).
2023-05-27 13:41:04 +02:00
notoria
dc02be4944 Remove and move comments 2023-05-27 13:08:25 +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
01285f12c3 remove no longer needed queue attributes after propagation 2023-03-15 21:17:06 +01:00
Markus Triska
cd586aab8c show remaining queue/2 attributes as residual goals
This lets us verify that all attributes are correctly removed earlier.
2023-03-15 19:56:02 +01:00
Markus Triska
997161c740 rely on first instantiated argument indexing
This great improvement to indexing allows much more natural
definitions of virtually all meta-predicates. Many thanks to @notoria!
2023-02-25 10:17:55 +01:00
Markus Triska
2a04d5e799 in projection of residual goals, mark considered propagators as processed
This is to avoid duplicated goals with the new projection mechanism.
2023-02-23 00:05:27 +01:00
Markus Triska
196e9c1e47 DOC: teletype font for reification 2023-02-03 20:47:08 +01:00
Markus Triska
da4c0a359b correct DocLog ~/.scryerrc rendering 2023-02-01 23:26:52 +01:00
Markus Triska
95278c221b DOC: use valid Prolog terms as predicate indicators 2023-01-29 21:48:22 +01:00
Markus Triska
814b631543 use DocLog syntax for section anchors and links within the document 2023-01-28 17:37:43 +01:00
Markus Triska
0d8c7f8785 small documentation adjustments 2023-01-28 17:37:43 +01:00
Markus Triska
5bae8fcaf8 FIXED: use lsb/2 and msb/2 from library(arithmetic)
This addresses #1720.
2023-01-28 17:37:43 +01:00
Mark Thom
df266378c4 Merge pull request #1689 from triska/clpb_doc
DOC: preliminary CLP(B) documentation in DocLog format
2023-01-24 22:51:35 +01:00
Markus Triska
1c08b56e05 strengthen reified division for divisor == 1 2023-01-24 22:15:05 +01:00
Markus Triska
909f2e1058 DOC: improve CLP(ℤ) DocLog documentation 2023-01-24 20:39:47 +01:00
Markus Triska
f213956ceb use (#)/1 2023-01-11 17:23:53 +01:00
Markus Triska
c5caa9d311 ADDED: sign/1 is now reifiable.
This addresses #1500.
2023-01-11 17:22:38 +01:00
Markus Triska
542b9e1976 rely on newly available operator notation for (#)/1 2023-01-10 22:59:11 +01:00
Markus Triska
73a1ee59fa replace several more instances of ?/1 by (#)/1 2023-01-10 22:57:14 +01:00
Markus Triska
2771109427 use (#)/1 already internally for describing constraint projections 2023-01-10 22:50:38 +01:00
Markus Triska
cc420bd31a FIXED: reification of (xor)/2.
Example:

    ?- A #= 1 xor 0 #<==> R.
    %@    clpz:(A#=1#<==>R), clpz:(R in 0..1).
2023-01-10 22:09:41 +01:00
Markus Triska
2fe1d2ef53 FIXED: correctly reify (/)/2.
Example:

    ?- 0 #==> X #= 1/2.
    %@    clpz:(X in inf..sup)
    %@ ;  false.

This addresses #1501.
2023-01-10 17:35:43 +01:00
Markus Triska
d91ee5b77c FIXED: CLP(ℤ): Correctly remove all attributes during propagation of all_distinct/1 and other global constraints.
The constraints from library(clpz) were already correctly removed, but
others such as pending freeze/2 goals were not, potentially leading to
an accumulation of redundant constraints during propagation.

Test case:

   ?- freeze(A,(X=1;X=2)), all_distinct([A]), A = 1.
      A = 1, X = 1
   ;  A = 1, X = 2.

The combination of freeze/2 and CLP(ℤ) is useful for example when
creating animations of search processes.

This addresses #1624.
2022-10-26 23:36:07 -06:00
Markus Triska
7c96b91663 remove nth1/3, which is now provided by library(lists) 2022-10-26 23:36:07 -06:00
Markus Triska
c7caf6b7a9 ENHANCED: CLP(ℤ): Reduce redundant propagator invocations during all_distinct/1 filtering
First, the current propagator is now logged and not re-triggered
during filtering. Second, and more significantly, all neq_num/2
constraints are scheduled and processed before more global constraints
are invoked. In this way, all the distilled information can be taken
into account by subsequently invoked global constraints.

These changes yield a 3-fold improvement in several Sudoku instances,
and a significant runtime reduction in social golfer instance 8-4-9.
2022-10-26 23:36:07 -06:00
Markus Triska
4422ffe39f add meta_predicate/1 declarations 2022-10-26 23:36:07 -06:00
Mark Thom
1ff52f70aa resolve phrase modules internally (#1541) 2022-10-26 23:36:07 -06:00
Mark Thom
1ffbf63d20 inline metacalls 2022-10-26 23:36:07 -06:00
Markus Triska
d58dd7cc91 ADDED: sign/1 2022-05-05 22:51:49 +02:00
Markus Triska
7e06abebd5 remove comment that seems no longer valid 2022-05-05 22:51:49 +02:00
Mark Thom
2d19243b3b Merge branch 'rebis-dev' into 0.9.0 release
Some checks failed
Test / build (macos-10.15, beta) (push) Has been cancelled
Test / build (macos-10.15, stable) (push) Has been cancelled
Test / build (ubuntu-20.04, beta) (push) Has been cancelled
Test / build (ubuntu-20.04, stable) (push) Has been cancelled
2022-03-06 09:45:05 -07:00
Mark Thom
8df346f377 expand phrase/{2,3} using dcg_body whenever possible 2022-01-21 08:10:55 -07:00
Jos De Roo
1a4f8f992b Update clpz.pl
While running with scryer-prolog the resource control file should be ~/.scryerrc
2022-01-17 22:35:31 +01:00
Markus Triska
3e7cd24814 address #995: wrong results for popcount/1
Many thanks to @notoria and @flexoron for very useful test cases!
2021-06-21 21:19:37 +02:00
Markus Triska
ee393c66dd ADDED: popcount(+Integer)
Example:

    ?- X #= popcount(3+5).
       X = 1.

This builds on #986 provided by @Regan-Koopmans. Many thanks!
2021-06-17 20:18:36 +02:00
Markus Triska
066f740819 check for correct domain of integers in reifiable expressions also in the expanded code
This is to preserve domain errors instead of failing silently. Example:

   ?- 5 #> 3 #<==> 2.
   %@ caught: error(domain_error(clpz_reifiable_expression,2),unknown(2)-1)
2021-06-03 22:57:58 +02:00
Markus Triska
fc8d33a98a ENHANCED: Goal expansion for reified constraints.
Used in package precautionary by @dcnorris.
2021-06-03 20:26:44 +02:00
Markus Triska
581e055359 FIXED: correct propagation of tuples_in/2 (#929)
Many thanks to @notoria for producing a very short test case.
2021-05-13 21:48:43 +02:00
Markus Triska
38db8d4e1a FIXED: module qualification for between/3 in goal expansion (#941)
Many thanks to @dcnorris for reporting this issue!
2021-05-09 23:54:37 +02:00
Markus Triska
f56e2fc48e remove rectractall/1 (built-in since 8188e3d0cf).
This resolves #899.
2021-04-14 20:18:50 +02:00