@@ -345,32 +345,31 @@ applyRule pat@Pattern{ceilConditions} rule =
345345 notAppliedIfBottom = RewriteRuleAppT $ pure NotApplied
346346 -- filter out any predicates known to be _syntactically_ present in the known prior
347347 let prior = pat. constraints
348- (knownTrue, toCheck) = partition (`Set.member` prior) ruleRequires
349- unless (null knownTrue) $
350- logMessage $
351- renderOneLineText $
352- " Known true side conditions (won't check):"
353- <+> (hsep . punctuate comma . map (pretty' @ mods ) $ knownTrue)
348+ toCheck <- lift $ filterOutKnownConstraints prior ruleRequires
354349
355350 unclearRequires <-
356351 catMaybes <$> mapM (checkConstraint id notAppliedIfBottom prior) toCheck
357352
353+ -- unclear conditions may have been simplified and
354+ -- could now be syntactically present in the path constraints, filter again
355+ stillUnclear <- lift $ filterOutKnownConstraints prior unclearRequires
356+
358357 -- check unclear requires-clauses in the context of known constraints (prior)
359358 mbSolver <- lift $ RewriteT $ (. smtSolver) <$> ask
360359
361360 let smtUnclear = do
362361 withContext CtxConstraint . withContext CtxAbort . logMessage $
363- WithJsonMessage (object [" conditions" .= (externaliseTerm . coerce <$> unclearRequires )]) $
362+ WithJsonMessage (object [" conditions" .= (externaliseTerm . coerce <$> stillUnclear )]) $
364363 renderOneLineText $
365364 " Uncertain about condition(s) in a rule:"
366- <+> (hsep . punctuate comma . map (pretty' @ mods ) $ unclearRequires )
365+ <+> (hsep . punctuate comma . map (pretty' @ mods ) $ stillUnclear )
367366 failRewrite $
368367 RuleConditionUnclear rule . coerce . foldl1 AndTerm $
369- map coerce unclearRequires
368+ map coerce stillUnclear
370369 case mbSolver of
371370 Just solver -> do
372371 checkAllRequires <-
373- SMT. checkPredicates solver prior mempty (Set. fromList unclearRequires )
372+ SMT. checkPredicates solver prior mempty (Set. fromList stillUnclear )
374373
375374 case checkAllRequires of
376375 Left SMT. SMTSolverUnknown {} ->
@@ -386,15 +385,15 @@ applyRule pat@Pattern{ceilConditions} rule =
386385 Right Nothing ->
387386 smtUnclear -- no implication could be determined
388387 Nothing ->
389- unless (null unclearRequires ) $ do
388+ unless (null stillUnclear ) $ do
390389 withContext CtxConstraint . withContext CtxAbort $
391390 logMessage $
392- WithJsonMessage (object [" conditions" .= (externaliseTerm . coerce <$> unclearRequires )]) $
391+ WithJsonMessage (object [" conditions" .= (externaliseTerm . coerce <$> stillUnclear )]) $
393392 renderOneLineText $
394393 " Uncertain about a condition(s) in rule, no SMT solver:"
395- <+> (hsep . punctuate comma . map (pretty' @ mods ) $ unclearRequires )
394+ <+> (hsep . punctuate comma . map (pretty' @ mods ) $ stillUnclear )
396395 failRewrite $
397- RuleConditionUnclear rule (head unclearRequires )
396+ RuleConditionUnclear rule (head stillUnclear )
398397
399398 -- check ensures constraints (new) from rhs: stop and return `Trivial` if
400399 -- any are false, remove all that are trivially true, return the rest
@@ -444,6 +443,18 @@ applyRule pat@Pattern{ceilConditions} rule =
444443 withPatternContext rewritten $
445444 return (rule, rewritten)
446445 where
446+ filterOutKnownConstraints :: Set. Set Predicate -> [Predicate ] -> RewriteT io [Predicate ]
447+ filterOutKnownConstraints priorKnowledge constraitns = do
448+ let (knownTrue, toCheck) = partition (`Set.member` priorKnowledge) constraitns
449+ unless (null knownTrue) $
450+ getPrettyModifiers >>= \ case
451+ ModifiersRep (_ :: FromModifiersT mods => Proxy mods ) ->
452+ logMessage $
453+ renderOneLineText $
454+ " Known true side conditions (won't check):"
455+ <+> hsep (intersperse " ," $ map (pretty' @ mods ) knownTrue)
456+ pure toCheck
457+
447458 failRewrite :: RewriteFailed " Rewrite" -> RewriteRuleAppT (RewriteT io ) a
448459 failRewrite = lift . (throw)
449460
0 commit comments