Creating Satisfaction Lists for a Constraint Set

Given a set of constraints, I would like to efficiently generate a set of values.

Suppose that I have several restrictions on my Tungus [1]:

goodThungus(X) :-
               X > 100,
               X < 1000.
               sin(X) = 0.

Now I can check the Tungus by asking:

goodThungus(500).

I would like to create all the good Thungi. I do not know how to do that; I am really not sure how to do this effectively.

Note: this, of course, must be a computable generation.

[1] An arbitrary object selected for this example.

+3
source share
3 answers

, , : , f (X) = 0, f - , , . , f (X) - " X?". .

:

  • , . , , ..

  • ,

UPDATE: , ( , ), :

  • , ... , . , sin (X) = 0 X = n * pi, n - .
  • , (), ( 100 < X < 1000)
  • , .
+1

, , , ...

, , PROLOG , , CLP (R) ( ) SWI-PROLOG; , , , , , , , PROLOG; , -, , X = sin(Y), .

SWI-PROLOG CLP (R) :

:- use_module(library(clpr)).

report_xsq_zeros :-
    findall(X, {0 = (X * X) - 10}, Results),
    write_ln(Results).

report_sin_zeros :-
    findall(X, {0 = sin(X)}, Results),
    write_ln(Results).

report_xsq_zeros :

 ?- report_xsq_zeros.
[3.16228, -3.16228]
true.

x^2 - 10, 3.16228 -3.16228, X . , report_sin_zeros, :

 ?- report_sin_zeros.
[0.0]
true.

, sin(X), X . , , , ( ...). , :

report_sin_zeros :-
    findall(X, {X > 100, X < 1000, 0 = sin(X)}, Results),
    write_ln(Results).

, sin(X), (.. X 0.0, ):

 ?- report_sin_zeros.
[]
true.

, SWI-PL CLP (R) ( ), () . CLP (R) - SWI-PROLOG CLP (R), , , SICSTUS CLP (R) ; .

+1

X [100..1000] sin (x) = 0. , / . ?

0
source

Source: https://habr.com/ru/post/1762490/


All Articles