I'm reading the Rosette Essentials.
The guide explains the use of define-symbolic
:
The
define-symbolic
form binds the variable to the same (unique) [symbolic] constant every time it is evaluated.
(define (static)
(define-symbolic x boolean?) ; Creates the same constant when evaluated.
x)
(define (dynamic)
(define-symbolic* y integer?) ; Creates a fresh constant when evaluated.
y)
> (eq? (static) (static))
#t
> (eq? (dynamic) (dynamic))
(= y$1 y$2)
Printed constant names, such as
x
orb
, are just comments. Two [symbolic] constants created by evaluating two distinctdefine-symbolic
(or,define-symbolic*
) forms are distinct, even if they have the same printed name. They may still represent the same concrete value, but that is determined by the solver:
(define (yet-another-x)
(define-symbolic x boolean?)
x)
> (eq? (static) (yet-another-x))
(<=> x x)
I don't really understand the explanation of define-symbolic
:
Why (eq? (static) (static))
returns #t, but (eq? (static) (yet-another-x))
returns (<=> x x)
?
Since the define-symbolic
binds the variable to the same (unique) constant every time it is evaluated, why (eq? (static) (yet-another-x))
does not return #t
? , just like (eq? (static) (static))
?
Does it mean that two symbolic variables occur in the different scope with the same name are still different, even if we use define-symbolic
?
What's the difference between <=>
and =
? e.g. (<=> x x)
vs (= y$1 y$2)
.
Thanks.