Skip to content

Mysterious bug on lists and pairs #36

@shiatsumat

Description

@shiatsumat

The following SMT2 code is not accepted by HoIce, probably by a bug.

I tried the following code on HoIce. (Sorry for this noisy and messy bug report!)

(set-logic HORN)

(declare-datatypes ((Mut 1)) ((par (T) ((mut (cur T) (ret T))))))
(declare-datatypes ((List 1)) ((par (T) (nil (insert (head T) (tail (List T)))))))

(declare-fun inck (Int (Mut (List Int))) Bool)
(assert (forall ((k Int))
  (=> true
    (inck k (mut nil nil)))
))
(assert (forall ((k Int) (x Int) (xs (List Int)) (xs! (List Int)))
  (=> (inck k (mut xs xs!))
    (inck k (mut (insert x xs) (insert (+ x k) xs!))))
))

(declare-fun length ((List Int) Int) Bool)
(assert (forall ((dummy Int))
  (=> true (length nil 0))
))
(assert (forall ((n Int) (x Int) (xs (List Int)))
  (=> (length xs n) (length (insert x xs) (+ 1 n)))
))

(declare-fun sum ((List Int) Int) Bool)
(assert (forall ((dummy Int))
  (=> true (sum nil 0))
))
(assert (forall ((n Int) (x Int) (xs (List Int)))
  (=> (sum xs n) (sum (insert x xs) (+ x n)))
))

(assert (forall ((n Int) (l Int) (r Int) (k Int) (xs (List Int)) (xs! (List Int)))
  (=> (and (sum xs n) (length xs l) (inck k (mut xs xs!)) (sum xs! r))
    (= r (+ n (* k l))))
))

(check-sat)
(get-model)

Passing the code above to HoIce under z3 4.7.1, I will unexpectedly get the following error.

(error "
  solver error: "line 30 column 54: unknown function/constant mut"
")

Interestingly, when I just swap the two arguments of inck, I will get unsat.

unsat
(error "
  no model available
")

However, the expected answer is sat.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions