Closed adsharma closed 3 years ago
This code is working better for me:
# unsigned
for w in (64, 32, 16, 8):
T = getattr(self, f"u{w}")
t = self.new_z3_const("t")
a = ForAll(t, And(self.subtype(t, T), t < (1 << w), t >= 0))
axioms.append(a)
But one problem remains: only Constants from ArithSort
seem to be comparable to integer constants. For example:
t = Int('t')
axioms.append(t >=0)
works. But if t is from z3_types.type_sort
, comparison to constants isn't possible. Looking for ways to make z3_types.u8
behave the same way as z3.Int
.
I made some more progress in:
https://github.com/adsharma/Typpete/commit/618d449a654df379d5c49775c046c6859a7a051e
But now I see a different problem in _infer_annotated_assign()
.
https://paste.ubuntu.com/p/ShWffRkfjY/
Any hints on how to convince z3 that Int
is compatible with i8
as long as it's within the bounds?
Also discussed here: https://github.com/Z3Prover/z3/discussions/5428
The discussion moved to https://github.com/dafny-lang/dafny/issues/1323. I'm able to get things working with dafny. Now trying to generate similar results using typpete.
I'm trying to implement the following:
using
https://github.com/adsharma/Typpete/commit/53feec072a60675436748d024a988902ae489f33
But I'm running into an error on this line:
https://github.com/adsharma/Typpete/blob/53feec072a60675436748d024a988902ae489f33/typpete/src/z3_types.py#L566
If
t
was anInt
it would have been a valid expression. But it seems to be aDatatypeRef
. Any suggestions on how to specify this constraint? Looks like I have to ast-fy the limit to be able to build an expression. Pointers to existing code would be great. I looked at z3_axioms.py but couldn't find one.