Defining a Theory of Sets with Z3/SMT-LIB2

后端 未结 1 1840
余生分开走
余生分开走 2021-01-04 06:55

I\'m trying to define a theory of sets (union, intersection etc.) for Z3 using the SMTLIB interface. Unfortunately, my current definition hangs z3 for a trivial query, so

相关标签:
1条回答
  • 2021-01-04 07:51

    Your formula is satisfiable, and Z3 is not capable to produce a model for this kind of formula. Note that, it will have to generate an interpretation for the uninterpreted sort Set. There are a couple of alternatives you may consider.

    1- Disable the model-based quantifier instantiation (MBQI) module. BTW, all Boogie-based tools (VCC, Dafny, Coral, etc) do that. To disable the MBQI module, we have to use

    (set-option :auto-config false)
    (set-option :mbqi false)
    

    Remark: in the work-in-progress branch, the option :mbqi has been renamed to :smt.mbqi.

    Cons: when the MBQI module is disable, Z3 will usually return unknown for satisfiable formulas that contain quantifier.

    2- Encode sets of T as Arrays from T to Boolean. Z3 supports extended array theory. The extended theory has two new operators: ((_ const T) a) constant arrays, ((_ map f) a b) map operator. This paper describes the extended array theory, and how to encode set operations such as union and intersection using it. The rise4fun website has examples. This is a good alternative if these are the only quantifiers in your problem because the problem is now in a decidable fragment. On the other hand, if you have additional quantified formulas that contain sets, then this will probably perform poorly. The problem is that the model built by the array theory is unaware of the existence of the additional quantifiers.

    For example of how to encode the above operators using const and map see: http://rise4fun.com/Z3/DWYC

    3- Represent sets of T as functions from T to Bool. This approach usually works well if we don't have sets of sets, or uninterpreted functions that take sets as arguments. the Z3 online tutorial has an example (Quantifiers section).

    0 讨论(0)
提交回复
热议问题