# How to constrain indefinite number variables and constraints?

**URL:** <https://swi-prolog.discourse.group/t/how-to-constrain-indefinite-number-variables-and-constraints/9466>\
**Category:** Help!\
**Tags:** discussion, how-to\
**Created:** [December 30, 2025, 2:46pm UTC](https://swi-prolog.discourse.group/t/how-to-constrain-indefinite-number-variables-and-constraints/9466 "2025-12-30T14:46:39Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![brebs](https://avatars.discourse-cdn.com/v4/letter/b/e9c0ed/32.png) [@brebs](https://swi-prolog.discourse.group/u/brebs)\
**Post date:** [December 30, 2025, 3:53pm UTC](https://swi-prolog.discourse.group/t/how-to-constrain-indefinite-number-variables-and-constraints/9466/2 "2025-12-30T15:53:55Z")

</div>

There has to be boundaries, otherwise the labeling/2 search could never end.

i.e. for a list of integers, the list length must be known, with an upper and lower boundary for each number.

To fully utilise clpfd:

- Replace member/2 with element/3
- Replace `->` with e.g. `#==>` as in [SWI-Prolog manual](https://www.swi-prolog.org/man/clpfd.html)

An example is [https://stackoverflow.com/questions/79583486/sliding-15-puzzle-using-clpfd](https://stackoverflow.com/questions/79583486/sliding-15-puzzle-using-clpfd)

There’s solutions etc. in topic: [Advent of Code 2025](https://swi-prolog.discourse.group/t/advent-of-code-2025/9406)

---

_[View the full topic](https://swi-prolog.discourse.group/t/how-to-constrain-indefinite-number-variables-and-constraints/9466)._
