@@ -37,7 +37,7 @@ import Data.List (intersperse, partition)
37
37
import Data.List.NonEmpty (NonEmpty (.. ), toList )
38
38
import Data.List.NonEmpty qualified as NE
39
39
import Data.Map qualified as Map
40
- import Data.Maybe (catMaybes , fromMaybe , mapMaybe )
40
+ import Data.Maybe (catMaybes , fromMaybe )
41
41
import Data.Sequence (Seq , (|>) )
42
42
import Data.Set qualified as Set
43
43
import Data.Text as Text (Text , pack )
@@ -50,11 +50,9 @@ import Booster.LLVM as LLVM (API)
50
50
import Booster.Log
51
51
import Booster.Pattern.ApplyEquations (
52
52
CacheTag (Equations ),
53
- Direction (.. ),
54
53
EquationFailure (.. ),
55
54
SimplifierCache (.. ),
56
55
evaluatePattern ,
57
- evaluateTerm ,
58
56
simplifyConstraint ,
59
57
)
60
58
import Booster.Pattern.Base
@@ -371,7 +369,6 @@ applyRule pat@Pattern{ceilConditions} rule =
371
369
normalisedPatternSubst <-
372
370
lift $
373
371
normaliseSubstitution
374
- pat. constraints
375
372
pat. substitution
376
373
newSubsitution
377
374
-- NOTE it is necessary to first apply the rule substitution and then the pattern/ensures substitution, but it is suboptimal to traverse the term twice.
@@ -395,31 +392,12 @@ applyRule pat@Pattern{ceilConditions} rule =
395
392
where
396
393
-- Given known predicates, a known substitution and a newly acquired substitution (from the ensures clause):
397
394
-- - apply the new substitution to the old substitution
398
- -- - simplify the substituted old substitution, assuming known truth
399
- -- - TODO check for loops?
400
- -- - TODO filter out possible trivial items?
401
- -- - finally, merge with the new substitution items and return
395
+ -- - merge with the new substitution items and return
402
396
normaliseSubstitution ::
403
- Set. Set Predicate -> Substitution -> Substitution -> RewriteT io Substitution
404
- normaliseSubstitution knownTruth oldSubst newSubst = do
405
- RewriteConfig {definition, llvmApi, smtSolver} <- RewriteT ask
397
+ Substitution -> Substitution -> RewriteT io Substitution
398
+ normaliseSubstitution oldSubst newSubst = do
406
399
let substitutedOldSubst = Map. map (substituteInTerm newSubst) oldSubst
407
- simplifiedSubstitution <-
408
- processResults
409
- <$> traverse
410
- (fmap fst . evaluateTerm BottomUp definition llvmApi smtSolver knownTruth)
411
- substitutedOldSubst
412
- pure (newSubst `Map.union` simplifiedSubstitution) -- new bindings take priority
413
- where
414
- processResults =
415
- Map. fromList
416
- . mapMaybe
417
- ( \ case
418
- (var, Left _err) -> (var,) <$> Map. lookup var oldSubst
419
- (var, Right simplified) -> Just (var, simplified)
420
- )
421
- . Map. assocs
422
-
400
+ pure (newSubst `Map.union` substitutedOldSubst) -- new bindings take priority
423
401
filterOutKnownConstraints :: Set. Set Predicate -> [Predicate ] -> RewriteT io [Predicate ]
424
402
filterOutKnownConstraints priorKnowledge constraitns = do
425
403
let (knownTrue, toCheck) = partition (`Set.member` priorKnowledge) constraitns
0 commit comments