Skip to content

SMT-LIB should consider disallowing shadowed variables in define-fun(-rec) #36

Description

@ajreynol

Currently, SMT-LIB gives an unintuitive definition of how define-fun with shadowed variables should be handled, where technically this should be treated as a partial definition based on the standard.

In detail, the SMT-LIB standard page 63 states:

(define-fun f ((x1 U1) ... (xn Un)) U t)

is equivalent to

(declare-fun f (U1 ... Un) U)
(assert (forall ((x1 U1) ... (xn Un)) (= (f x1 ... xn) t)))

Now consider what happens when we have shadowed variables. Take this benchmark:

(set-logic ALL)
(define-fun P ((x Int) (x Int)) Bool (= x 0))
(assert (P 0 1))
(check-sat)

cvc5 1.1.0 and z3 4.8.10 say "unsat" for this. The command

(define-fun P ((x Int) (x Int)) Bool (= x 0))

partially defines P over the domain where its arguments are equal, as

(forall ((x Int) (x Int)) (= (P x x) (= x 0)))

is equivalent to

(forall ((x Int)) (= (P x x) (= x 0)))

meaning (P 0 1) is unconstrained.

It is recommended the standard is updated to explicitly allow variable shadowing in arguments to define-fun(-rec).

See cvc5/cvc5#11507.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions