-2

Is it possible to minimize the image of a function with an Optimizer? If not, how else would I go about achieving it?

The function is defined as (declare-fun vmorph (V) V)

where V is

(declare-datatypes () ((V V1 V2 V3 V4 V5 V6))).

There's other stipulations that make vmorph neither surjective nor injective. Instead of just ruling out those two I'd like to minimize the image of vmorph in the first place, ideally mapping all Elements to the same element. If it were python it would be something like:

a = len({vmorph(v) for v in V})
minimize(a)

Where minimize is the z3 functionality I'm looking for.

  • 1
    I'm afraid your question doesn't make much sense without any context. What aspect of which type of function do you want to optimize? Is this in any way related to Z3, or is this a general logic question? – Christoph Wintersteiger Feb 19 '18 at 17:33

1 Answers1

0

Perhaps you can assign a "cost" function for each V and ask that to be minimized. Something like this:

(declare-datatypes () ((V (V1) (V2) (V3) (V4) (V5) (V6))))

(declare-fun vmorph (V) V)

(define-fun cost ((x V)) Int (ite (= x V1) 1
                             (ite (= x V2) 2
                             (ite (= x V3) 3
                             (ite (= x V4) 4
                             (ite (= x V5) 5 6))))))

(minimize (+ (cost (vmorph V1))
             (cost (vmorph V2))
             (cost (vmorph V3))
             (cost (vmorph V4))
             (cost (vmorph V5))
             (cost (vmorph V6))))

(check-sat)
(get-model)

This will "favor" V1 over V2 over V3, etc. Of course, this isn't guaranteed to get you a global minimum; since preferring V6 for all might work out better. But depending on the properties of vmorph you might be able to come up with a good cost function that achieves the effect you want.

alias
  • 28,120
  • 2
  • 23
  • 40