1313
1414import re
1515from typing import Dict , List , Tuple , Optional , Set
16- from z3 import Solver , Real , And , sat
16+ from z3 import Solver , Real , And , Not , sat , unsat
1717
1818
1919class SpatialMapZ3Solver :
@@ -259,9 +259,8 @@ def count_objects_in_direction(
259259 # Check if this entity MUST be in that direction
260260 # (i.e. the negation is unsatisfiable)
261261 self .solver .push ()
262- from z3 import Not
263262 self .solver .add (Not (constraint ))
264- must_be = self .solver .check () != sat
263+ must_be = self .solver .check () == unsat
265264 self .solver .pop ()
266265
267266 if must_be :
@@ -487,7 +486,7 @@ def verify_spatialmap_step(
487486 Returns:
488487 (is_valid, errors)
489488 """
490- from z3 import Not as Z3Not , sat as z3sat
489+ from z3 import Not as Z3Not , unsat as z3unsat
491490
492491 errors = []
493492
@@ -508,7 +507,7 @@ def verify_spatialmap_step(
508507 if compiled is not None :
509508 z3_solver .solver .push ()
510509 z3_solver .solver .add (Z3Not (compiled ))
511- is_entailed = z3_solver .solver .check () != z3sat
510+ is_entailed = z3_solver .solver .check () == z3unsat
512511 z3_solver .solver .pop ()
513512 if is_entailed :
514513 z3_solver .apply_ir (claim )
@@ -725,7 +724,7 @@ def get_possible_count_range(
725724
726725 Returns ``None`` if the reference entity cannot be found.
727726 """
728- from z3 import And as Z3And , Not as Z3Not , sat as z3sat
727+ from z3 import And as Z3And , Not as Z3Not , sat as z3sat , unsat as z3unsat
729728
730729 direction = direction .lower ().strip ()
731730 if direction in ('north' , 'south' , 'east' , 'west' ):
@@ -782,7 +781,7 @@ def _find(name):
782781 # Must it be?
783782 solver .solver .push ()
784783 solver .solver .add (Z3Not (c ))
785- must_be = solver .solver .check () != z3sat
784+ must_be = solver .solver .check () == z3unsat
786785 solver .solver .pop ()
787786
788787 if must_be :
0 commit comments