Constrained random question

What is the best way to constrain the conditions below.

Arrays x and y are sized dynamically and each value is rangebound. The sum of products of array x and y should be less than a certain value. X[i]Y[i] + X[i+1]Y[i+1] + … < Val

I know I can create another array Z which can hold the product such as Z[i]=X[i]Y[i} etc and then apply Z.sum to < Val.

However, is there a more efficient single line solution to SoP?

In reply to kernalmode1:

The with clause can contain any expression-- it does not even have to reference the array sum is called on.

constraint sum_xy { x.sum(Xi) with (Xi*y[Xi.index]) < Val;}

In reply to dave_59:

Oh I see. Yeah, without exposure to the wide range of usage, it is really difficult to realize the full potential of such expressions. I dont think any book explains this.
Thanks Dave.

In reply to dave_59:

I think we need still little modification in the code.

constraint sum_xy { x.sum(Xi) with (int’(Xi*y[Xi.index])) < Val;}

One thing I don’t get it why do we need to cast it to “int”?

In reply to PratikShah:

There is no point in suggesting a solution when one does not understand what the implication of that is.
Casting int’() takes care of overflow cases in situations where variables of x, y are declared to be of insufficient width, as ‘sum’ can cause the result to be.