@@ -345,32 +345,31 @@ applyRule pat@Pattern{ceilConditions} rule =
345
345
notAppliedIfBottom = RewriteRuleAppT $ pure NotApplied
346
346
-- filter out any predicates known to be _syntactically_ present in the known prior
347
347
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
354
349
355
350
unclearRequires <-
356
351
catMaybes <$> mapM (checkConstraint id notAppliedIfBottom prior) toCheck
357
352
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
+
358
357
-- check unclear requires-clauses in the context of known constraints (prior)
359
358
mbSolver <- lift $ RewriteT $ (. smtSolver) <$> ask
360
359
361
360
let smtUnclear = do
362
361
withContext CtxConstraint . withContext CtxAbort . logMessage $
363
- WithJsonMessage (object [" conditions" .= (externaliseTerm . coerce <$> unclearRequires )]) $
362
+ WithJsonMessage (object [" conditions" .= (externaliseTerm . coerce <$> stillUnclear )]) $
364
363
renderOneLineText $
365
364
" Uncertain about condition(s) in a rule:"
366
- <+> (hsep . punctuate comma . map (pretty' @ mods ) $ unclearRequires )
365
+ <+> (hsep . punctuate comma . map (pretty' @ mods ) $ stillUnclear )
367
366
failRewrite $
368
367
RuleConditionUnclear rule . coerce . foldl1 AndTerm $
369
- map coerce unclearRequires
368
+ map coerce stillUnclear
370
369
case mbSolver of
371
370
Just solver -> do
372
371
checkAllRequires <-
373
- SMT. checkPredicates solver prior mempty (Set. fromList unclearRequires )
372
+ SMT. checkPredicates solver prior mempty (Set. fromList stillUnclear )
374
373
375
374
case checkAllRequires of
376
375
Left SMT. SMTSolverUnknown {} ->
@@ -386,15 +385,15 @@ applyRule pat@Pattern{ceilConditions} rule =
386
385
Right Nothing ->
387
386
smtUnclear -- no implication could be determined
388
387
Nothing ->
389
- unless (null unclearRequires ) $ do
388
+ unless (null stillUnclear ) $ do
390
389
withContext CtxConstraint . withContext CtxAbort $
391
390
logMessage $
392
- WithJsonMessage (object [" conditions" .= (externaliseTerm . coerce <$> unclearRequires )]) $
391
+ WithJsonMessage (object [" conditions" .= (externaliseTerm . coerce <$> stillUnclear )]) $
393
392
renderOneLineText $
394
393
" 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 )
396
395
failRewrite $
397
- RuleConditionUnclear rule (head unclearRequires )
396
+ RuleConditionUnclear rule (head stillUnclear )
398
397
399
398
-- check ensures constraints (new) from rhs: stop and return `Trivial` if
400
399
-- any are false, remove all that are trivially true, return the rest
@@ -444,6 +443,18 @@ applyRule pat@Pattern{ceilConditions} rule =
444
443
withPatternContext rewritten $
445
444
return (rule, rewritten)
446
445
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
+
447
458
failRewrite :: RewriteFailed " Rewrite" -> RewriteRuleAppT (RewriteT io ) a
448
459
failRewrite = lift . (throw)
449
460
0 commit comments