I'm just trying to study z3 and its .NET interface. I'm using PowerShell for that, to make it a bit more interactive. And my first hello world
is below.
$ctx = [Microsoft.Z3.Context]::new()
$x = $ctx.MkConst("x", $ctx.MkIntSort())
$zero = $ctx.MkNumeral(0, $ctx.MkIntSort())
$one = $ctx.MkNumeral(1, $ctx.MkIntSort())
$s = $ctx.MkSolver()
$expr = $x * $x - $one # x*x- 1
$assert = $s.Assert($ctx.MkEq( $expr, $zero)) # x*x - 1 = 0
$s.Check()
$m = $s.Model
$m.Decls | % { "$($_.Name) -> $($m.ConstInterp($_))" }
this, however, returns
SATISFIABLE
x -> -1
This is a bit confusing to me, as I'd expect it to return two roots, 1 and -1
The more confusing it becomes when I try this in python (in google colab)
x = Int('x')
solve(x*x-1==0)
it says
What do I do wrong in both cases?