Skip to content

Commit 405bf59

Browse files
author
Brian Huffman
committed
Make goal_eval preserve pi-bound variables in goals.
Fixes #985.
1 parent 6789b1a commit 405bf59

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/SAWScript/Builtins.hs

+12-2
Original file line numberDiff line numberDiff line change
@@ -535,13 +535,23 @@ goal_eval unints =
535535
withFirstGoal $ \goal ->
536536
do sc <- getSharedContext
537537
unintSet <- resolveNames unints
538-
t0 <- liftIO $ propToPredicate sc (goalProp goal)
538+
-- replace all pi-bound quantified variables with new free variables
539+
let (args, body) = asPiList (unProp (goalProp goal))
540+
body' <-
541+
case asEqTrue body of
542+
Just t -> pure t
543+
Nothing -> fail "goal_eval: expected EqTrue"
544+
ecs <- liftIO $ traverse (uncurry (scFreshEC sc)) args
545+
vars <- liftIO $ traverse (scExtCns sc) ecs
546+
t0 <- liftIO $ instantiateVarList sc 0 (reverse vars) body'
539547
let gen = globalNonceGenerator
540548
sym <- liftIO $ Crucible.newSAWCoreBackend FloatRealRepr sc gen
541549
(_names, (_mlabels, p)) <- liftIO $ W4Sim.w4Eval sym sc Map.empty unintSet t0
542550
t1 <- liftIO $ Crucible.toSC sym p
543551
t2 <- liftIO $ scEqTrue sc t1
544-
return ((), mempty, Just (goal { goalProp = Prop t2 }))
552+
-- turn the free variables we generated back into pi-bound variables
553+
t3 <- liftIO $ scGeneralizeExts sc ecs t2
554+
return ((), mempty, Just (goal { goalProp = Prop t3 }))
545555

546556
beta_reduce_goal :: ProofScript ()
547557
beta_reduce_goal =

0 commit comments

Comments
 (0)