Skip to content

Commit

Permalink
Add "condition_kind" node to simplify locating additional conditions …
Browse files Browse the repository at this point in the history
…in JSON
  • Loading branch information
danmatichuk committed Nov 26, 2024
1 parent c377010 commit a7b2bee
Showing 1 changed file with 21 additions and 17 deletions.
38 changes: 21 additions & 17 deletions src/Pate/Verification/StrongestPosts.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1275,6 +1275,11 @@ updateAbsBlockState node d = do
_ -> return ()
-}

instance IsTraceNode '(sym,arch) "condition_kind" where
type TraceNodeType '(sym,arch) "condition_kind" = ConditionKind
prettyNode () condk = PP.pretty $ conditionPrefix condk
nodeTags = mkTags @'(sym, arch) @"condition_kind" [Simplified, Summary]

withSatConditionAssumed ::
PS.SimScope sym arch v ->
PS.SimBundle sym arch v ->
Expand All @@ -1291,8 +1296,7 @@ withSatConditionAssumed scope bundle dom nd condK gr0 f = withSym $ \sym -> do
case W4.asConstantPred eqCond_pred of
Just True -> f
_ -> do
let msg = conditionPrefix condK
(mtraceT, mtraceF) <- withTracing @"message" msg $ getTracesForPred scope bundle dom eqCond_pred
(mtraceT, mtraceF) <- withTracing @"condition_kind" condK $ getTracesForPred scope bundle dom eqCond_pred
case (mtraceT, mtraceF) of
-- condition is not necessarily true or false
(Just{}, Just{}) -> do
Expand All @@ -1319,21 +1323,21 @@ getTracesForPred ::
EquivM sym arch (Maybe (CE.TraceEvents sym arch), Maybe (CE.TraceEvents sym arch))
getTracesForPred scope bundle dom p = withSym $ \sym -> do
not_p <- liftIO $ W4.notPred sym p
withTracing @"expr" (Some p) $ do
withTracing @"message" "Simplified Condition" $ withForkedSolver_ $ do
p_pretty <- withTracing @"debug" "simplifier" $ PSi.applySimpStrategy PSi.prettySimplifier p
emitTrace @"expr" (Some p_pretty)
mtraceT <- withTracing @"message" "With condition assumed" $
withSatAssumption (PAS.fromPred p) $ do
traceT <- getSomeGroundTrace scope bundle dom Nothing
emitTrace @"trace_events" traceT
return traceT
mtraceF <- withTracing @"message" "With negation assumed" $
withSatAssumption (PAS.fromPred not_p) $ do
traceF <- getSomeGroundTrace scope bundle dom Nothing
emitTrace @"trace_events" traceF
return traceF
return (mtraceT, mtraceF)
emitTraceLabel @"expr" "Predicate" (Some p)
withTracing @"message" "Simplified Predicate" $ withForkedSolver_ $ do
p_pretty <- withTracing @"debug" "simplifier" $ PSi.applySimpStrategy PSi.prettySimplifier p
emitTrace @"expr" (Some p_pretty)
mtraceT <- withTracing @"message" "With condition assumed" $
withSatAssumption (PAS.fromPred p) $ do
traceT <- getSomeGroundTrace scope bundle dom Nothing
emitTrace @"trace_events" traceT
return traceT
mtraceF <- withTracing @"message" "With negation assumed" $
withSatAssumption (PAS.fromPred not_p) $ do
traceF <- getSomeGroundTrace scope bundle dom Nothing
emitTrace @"trace_events" traceF
return traceF
return (mtraceT, mtraceF)

withConditionsAssumed ::
PS.SimScope sym arch v ->
Expand Down

0 comments on commit a7b2bee

Please sign in to comment.