How to constrain indefinite number variables and constraints?

Recently, I encountered a problem. Because the result of the required variable must be an integer, and some results may not be unique, I associate it with matrix and CLP (FD).
I have read the tutorial CLP(FD) Constraint Logic Programming over Finite Domains written by anniepoo and saw the example of cryptoarithmetic. Using this method, people can edit each equation manually and finally get the result.

But what if the length of the input element content is not fixed? The first parameter can be expressed as a coefficient matrix, and the second parameter can be expressed as the sum of each row. For example, the first argument is [[1, -2, 1], [0, 2, -8], [5, 0, -5]] and the second argument is [0, 8, 10]; The first argument is [[1, 6, 2, -5, -2], [0, 0, 2, -8, -1], [0, 0, 0, 1]], and the second argument is [-4, 3, 7].
I thought of using the maplist predicate. The results of each row are processed row by row, and the list composed of the results of each row is naturally the second parameter given. However, an error message is displayed: “arguments are not sufficiently instantiated”. Then put the label predicate in front. Although the results of each variable can be obtained, the speed is very slow, which is equivalent to constraining the minimum and maximum values of all variables, and then exhaustive. And in the tutorial, variables are instantiated after each constraint condition, which is very fast.

Excuse me. How to constrain indefinite number variables and constraints?

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:

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

There’s solutions etc. in topic: Advent of Code 2025