Skip to content
Advertisement

finding max of the numbers in z3 using SMTLIB2

I have 7 cups which contains some water. I need to program these cups to have different amounts of water. Once this is done I need to measure the cup which has the highest amount of water and then remove some quantity (say 2 units of water).

c implementations:

JavaScript

This will give an answer as c7 = 3.8

I was trying to implement this in z3 and I assigned the values to c1….c7

JavaScript

and when I get the model values it should give c7_1 as 3.8

Is it possible to define this in z3? When I am using the and’s of different conditions in if condition (in ite) its giving me an error. Can it not be defined like this? Is there someway around this?

Thanks in advance

[problem description][1]

I am experimenting with the Z3 tool, It was easy to get he first part However for the second part is being a bit difficult.

Advertisement

Answer

Sure. Here it is in SMTLib:

JavaScript

z3 says:

JavaScript

So, looks like it put 2 units in c1, less than 2 on all the others, so you ended up with a final value of 0 left.

Your question is rather vague in what other constraints might be at play here, but hopefully this will get you started.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement