0

I'd like to define a function in SMT 2.0 that returns the minimal of 4 integer values.

Leonardo de Moura
  • 21,065
  • 2
  • 47
  • 53

1 Answers1

5

The min4 function (the minimal of 4 integer values) can be defined in the SMT 2.0 language as:

(define-fun min2 ((a Int) (b Int)) Int
    (ite (<= a b) a b))

(define-fun min3 ((a Int) (b Int) (c Int)) Int
    (min2 a (min2 b c)))

(define-fun min4 ((a Int) (b Int) (c Int) (d Int)) Int
    (min2 a (min3 b c d)))

The following link contains an example using this function: http://rise4fun.com/Z3/wuyU

In SMT 2.0, define-fun is essentially a macro definition. SMT 2.0 language does not support the definition of functions expecting arbitrary number of arguments. You may consider using programmatic APIs for SMT solvers such as Scala^Z3, SBV and Z3Py. They are much more convenient to use than SMT 2.0. Here is the same example in Z3Py: http://rise4fun.com/Z3Py/2vy

Leonardo de Moura
  • 21,065
  • 2
  • 47
  • 53
  • For reference purposes, here's how to do it using Haskell/SBV: http://gist.github.com/2353312 – alias Apr 10 '12 at 18:07