Does z3 provide a cross product function for two lists? If not is it possible to define one without using higher order functions or using the provided list functions? I have been having trouble trying to define one. I know how to define one using map but I don’t think that is supported in z3.
Share
You can declare the cross product function in SMT 2.0.
However, any non-trivial property will require a proof by induction. Z3 currently does not support proofs by induction. Thus, it will only be able to prove very simple facts.
BTW, by cross-product of lists, I’m assuming you want a function that given the lists
[a, b]and[c, d]returns the list or pairs[(a, c), (a, d), (b, c), (b, d)].Here is a script that defines the
productfunction.The script also demonstrates some limitations of the SMT 2.0 language. For example, SMT 2.0 does not support the definition of parametric axioms or functions. So, I used uninterpreted sorts to “simulate” that. I also had to define the auxiliary functions
appendandproduct-aux. You can try this example online at: http://rise4fun.com/Z3/QahiPThe example also proves the following trivial fact that if
l = product([a], [b]), thenfirst(head(l))must bea.If you are insterested in proving non-trivial properties. I see two options. We can try to prove the base case and inductive cases using Z3. The main disadvantage in this approach is that we have to manually create these cases, and mistakes can be made. Another option is to use an interactive theorem prover such as Isabelle. BTW, Isabelle has a much richer input language, and provides tactics for invoking Z3.
For more information about algebraic datatypes in Z3, go to the online tutorial http://rise4fun.com/Z3/tutorial/guide (Section Datatypes).