Prolog CSPs: Less than constraint with instantiated counters

user3161227

Using Eclipse prolog and assuming I have a variable X and X must be less than a known number N. For this i can write:

X #< N

So, whenever X gets instantiated to a number larger than N the suspended predicate above fails.

But that if i have a counter C that starts from 0, increases during search and fails if it surpasses N?

For example what if I want to track the number of times a value is selected from a domain and the constraint is to never exceed N times. I can't do the above because Counter C gets instantiated to 0 and uses other variables for the incrementation (C1 is C+1).

do I have to do it with pure prolog? Something like this:

pred(X, N):- X1 is X+1, X1<N, pred(X1, N)
user3161227

OP here. I found what I was looking for. It's a cardinality constraint and is implemented in the ic global library of eclipse prolog.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Prolog: foreach or forall for constraint solving?

Prolog - arguments are not instantiated

Prolog: Multiplying 2 lists with 1 of them not instantiated?

Prolog: Arguments are not sufficiently instantiated

How to check if variable is instantiated in Prolog?

Prolog ERROR: is/2: Arguments are not sufficiently instantiated

Prolog: ERROR: >/2: Arguments are not sufficiently instantiated

Prolog - Arguments are not sufficiently instantiated. Recursion depth

Arguments are not sufficiently instantiated prolog

Prolog (arguments not instantiated)

Prolog - Keep track of multiple sum counters

could be instantiated with a different subtype of constraint '{}' typescript error

Grouping in my SQL for a constraint less than 10

Function could be instantiated with a different subtype of constraint

Mysql: possible to add constraint that prevents a one to many relation from having less than certain number of relations?

Prolog error arguments are not instantiated

R linear programming set up in linprog package ignores constraint (less than or equal to) using solveLP

Simple Prolog program: "Arguments are not sufficiently instantiated" error

Prolog -- Arguments are not sufficiently instantiated

Prolog only check variable is instantiated

How to solved error: Inconsistent accessibility: constraint type 'IEntity' is less accessible than 'GenericRepository<T>'

Beginner with Prolog - Arguments Insufficiently Instantiated

prolog - ERROR: Arguments are not sufficiently instantiated

Typescript error - could be instantiated with a different subtype of constraint

The type could be instantiated with a different subtype of constraint error

Why did the removal of a UNIQUE constraint reduce the size of my database to less than half?

How can I get a list of the powers of X less-than or equal to N in Prolog?

How to convey "less than" constraint using type classes?

'T' could be instantiated with a different subtype of constraint 'Component'