0

I'm trying to use pattern matching in z3 to work with algebraic datatypes. I'm exactly following the syntax given in the SMTLib standard on page 27, but z3 is giving me a syntax error. For example in the following program:

(declare-datatype Dyn ((a) (b)))
(define-fun foo ((x Dyn)) Int (
  match x (
    (a 1)
    (b 2)
  )
))
(assert (= (foo a) (1)))
(check-sat)

it gives me the error "line 4 column 7: variable symbol expected". As far as I can tell I'm following the specified syntax exactly. How do I fix this?

vijrox
  • 1,063
  • 1
  • 13
  • 33
  • As of Feb 3rd 2018, building z3 from github sources, this program is accepted just fine. Looks like they fixed the bug! – alias Feb 04 '19 at 01:49
  • Great! I opened an issue about this on their github and they closed it, so it's good that it is indeed fixed! – vijrox Feb 04 '19 at 06:06

1 Answers1

1

I don't think you're doing anything wrong! Looks like this is a z3 bug that you should report at https://github.com/Z3Prover/z3/issues/

There's one little problem with your assert statement right before (check-sat). It should read:

(assert (= (foo a) 1))

i.e., without any parenthesis around 1. But your use of the match command is syntactically correct and should be reported as a z3 bug.

alias
  • 28,120
  • 2
  • 23
  • 40