With the following example I am trying to set a constraint on the length of all possible lists in a quantified way. This will lead to a "unsat" result which I am sure is correct.
Can somebody go into detail why this is unsatisfiable and if there is a way around that limitation without putting the length limitation on a specific variable/constant?
I found this interesting thread but my question was not really answered there. In addition, the answers are old and refer to SMT-LIB version 2.0 (and one to a not quantified version). Maybe Z3 is capable to do so nowadays in a way unknown to me.
(set-logic ALL)
(set-option :produce-unsat-cores true)
(declare-datatypes ((List 1)) ((par (T) ((cons (head T) (tail (List T))) (nil)))))
(define-sort IntList() (List Int))
(define-fun-rec IntList.length((l IntList)) Int
(ite
(= l (as nil IntList))
0
(+ (IntList.length (tail l)) 1)
)
)
(assert (! (forall ((this IntList)) (<= 2 (IntList.length this))) :named a10))
(check-sat)
(get-unsat-core)
I use commit 8abb644378ebaf1a9699e1b2fdd32075bcfcea4e of Z3 master as of 2021-01-12, 64-bit on Win10.