Summarize array values in a constraint

In reply to AL_verif:

It might be easier to have indexes be an array of single bits the same size as you your vals array.

conatraint c_list {
     indexes.sum() with (int'(item)) == 3; // your example showed only 3 indexes "active"
     vals.sum() with {indexes[item.index] ? int'item) : 0 ) == sum_vals;
{