0

I have an issue with my SMT code. I'm using SMT-LIB 2.7 syntax, and executing it with a 2.6 solver (CVC4). Here is my code:

(set-option :print-success false)
(set-logic ALL)

(define-sort |Z| () Int)
(declare-sort P 1)
(define-sort |POW Z| () (P |Z|))

(declare-const vmax |Z|)
(declare-const vset |POW Z|)
(declare-const |set.empty Z| |POW Z|)

(assert (!
  (forall ((e |Z|))
    (not (|set.in |Z|| e |set.empty |Z||)))
  :named |ax.set.in.empty Z|))

(declare-fun |set.in Z| (|Z| |POW Z|) Bool)
(declare-fun max (|POW Z|) |Z|)

(assert (!
  (forall ((s |POW Z|))
    (=> (not (= s |set.empty |Z||))
        (|set.in |Z|| (max s) s)))
  :named |ax.max.is.member|))

(assert (!
  (forall ((s |POW Z|) (e |Z|))
    (=> (|set.in |Z|| e s)
        (<= e (max s))))
  :named |ax.max.is.ge|))

(assert (!
  (not (= vmax (max vset)))
  :named |Goal|))

(check-sat)
(exit)

When I run this with CVC4, I get the following error:

(error "Parse Error: output.smt:11.36: Symbol Z is not declared.
(forall ((e |Z|)) (not (|set.in |Z|| e |set.empty |Z||)))
                                     ^")

I don’t understand why it says "Z is not declared", while I clearly declared it with:

(define-sort |Z| () Int)

I am new to SMT and there are not many resources available online, so I would appreciate your help.

Also, could this be caused by a version mismatch? I'm writing in SMT-LIB 2.7 but running it with a 2.6 solver. Unfortunately, I couldn’t find a download link for a 2.7-compliant solver.

Thanks in advance, and have a great day!

1 Answer 1

0

This line is problematic:

    (not (|set.in |Z|| e |set.empty |Z||)))

Note that you haven't defined set.in yet; it comes a few lines later:

(declare-fun |set.in Z| (|Z| |POW Z|) Bool)

But even with that confusion, when you write a string inside two bar's, (like |...|) then those bars are dropped and whatever inside is considered a single atom. (This allows you to put in spaces or special characters.) Looking at what you wrote:

|set.in |Z||

the way this parses is as a sequence of three tokens:

  1. set.in (there's an extra space at the end!)
  2. Z
  3. <> (empty!)

And it's precisely this Z that CVC5 is complaining about that you haven't defined.

Finally, I'll point out that CVC5 already supports sets: https://cvc5.github.io/docs/cvc5-1.0.7/examples/sets.html

You can of course define your own notion of a set, but it might be best to just stick to what they have internal support for. (And note that membership there is defined set.member, not set.in.)

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you I understand the problem and fix it ! I have another question if you can help me. I am using -> but I got an error that is not defined : ``` (define-sort |? Z| () (-> |Z| Bool)) (declare-const |set.intent Z| (-> |? Z| |POW Z|)) (assert (! (forall ((p |? Z|)) (forall ((x |Z|)) (= (|set.in Z| x (|set.intent Z| p)) (p x) ) ) ) :named |set.in.intent Z|) ) ``` I got (error "Parse Error: output.smt:37.36: Symbol '->' not declared as a type") Thank you for help
Comments are not intended for new questions. Please start a new one. See: stackoverflow.com/help/how-to-ask

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.