0

Is there some way to plain "uninterpreted functions" (UIF) inside Horn queries?

I think you're using UIFs to represent the "Horn variables", so perhaps I thought I could fake what I want with arrays. However, the following doesn't work:

(set-logic HORN)

(declare-fun k1 (Int) Bool)

(declare-const foo (Array Int Int))

(assert (forall ((v Int)) (=> (< 666 (select foo v)) (k1 v))))

(assert (forall ((v Int)) (=> (k1 v) (< 0 (select foo v)))))

(check-sat)

(get-model)

Is there some way to make the above work out? Thanks so much!

Ranjit Jhala
  • 1,242
  • 8
  • 18
  • I assume by "not work" you mean the query produces `unknown`? It's not quite clear what you're trying to achieve though; what exactly are you trying to "fake" in the first place? It'd be more illuminating if you posted what you want to do with HORN to start with, so we don't suffer from the XY problem: https://xyproblem.info – alias Mar 30 '23 at 19:37
  • It doesn't say unknown: z3 complains about the `declare-const foo` line for the reasons explained by @nikolaj-bjorner below... – Ranjit Jhala Mar 31 '23 at 20:19
  • With z3 compiled from master yesterday, it *does* say unknown. – alias Mar 31 '23 at 21:26
  • You are correct -- the exact message I get with version 4.12.1 is: `unknown (error "line 15 column 10: model is not available")` – Ranjit Jhala Apr 01 '23 at 23:40
  • Yeah, that's normal. When `unknown` is the answer, `(get-model)` returns nothing. Solvers used to return "alleged" models in certain cases in case of `unknown`, but it was mostly confusing. (Yices did that in particular.) I guess they no longer do it, and for good reason. – alias Apr 02 '23 at 01:52

1 Answers1

0

@nikolaj-bjorner answered the question by email, let me post the answer here for others:

The example is not in the “HORN” fragment that only allows uninterpreted predicates at top-level. Other symbols have to be universally quantified.

Arie (Gurfinkel) and collaborators work on extensions that handle uninterpreted functions at top level.

Logically, it is clearly well defined: just find a solution for predicates and functions that satisfy given set of formulas.

They published in FMCAD and other places on this.

We sometimes use formalizations of the form:

(set-logic HORN)

(declare-fun k1 ((Array Int Int) Int) Bool)

(assert (forall ((v Int) (foo (Array Int Int)))) (=> (< 666 (select foo v)) (k1 foo v))))

(assert (forall ((v Int) (foo (Array Int Int))))) (=> (k1 foo v) (< 0 (select foo v)))))
 
(check-sat)
 
(get-model)
Ranjit Jhala
  • 1,242
  • 8
  • 18
  • For me this version doesn't even go through since parens are not balanced. But once the parentheses are fixed, it does find a model indeed. – alias Apr 01 '23 at 01:05
  • 1
    oops sorry, yes I should have posted the paren-edited version! – Ranjit Jhala Apr 01 '23 at 23:42