@@ -85,6 +85,9 @@ import Kore.Internal.Pattern
85
85
( Pattern
86
86
)
87
87
import qualified Kore.Internal.Pattern as Pattern
88
+ import Kore.Internal.Predicate
89
+ ( makeCeilPredicate_
90
+ )
88
91
import qualified Kore.Internal.SideCondition as SideCondition
89
92
import Kore.Internal.Symbol
90
93
( Symbol
@@ -199,6 +202,11 @@ class Goal goal where
199
202
-- checkImplication.
200
203
isTriviallyValid :: goal -> Bool
201
204
205
+ inferDefined
206
+ :: MonadSimplify m
207
+ => goal
208
+ -> Strategy. TransitionT (Rule goal ) m goal
209
+
202
210
checkImplication
203
211
:: MonadSimplify m
204
212
=> goal -> m (CheckImplicationResult goal )
@@ -277,8 +285,9 @@ simplifies the implementation. However, this assumption is not an essential
277
285
feature of the algorithm. You should not rely on this assumption elsewhere. This
278
286
decision is subject to change without notice.
279
287
280
- This instance contains the default implementation for a one-path strategy. You can apply it to the
281
- first two arguments and pass the resulting function to 'Kore.Strategies.Verification.verify'.
288
+ This instance contains the default implementation for a one-path strategy. You
289
+ can apply it to the first two arguments and pass the resulting function to
290
+ 'Kore.Strategies.Verification.verify'.
282
291
283
292
Things to note when implementing your own:
284
293
@@ -304,6 +313,8 @@ instance Goal OnePathRule where
304
313
305
314
isTriviallyValid = isTriviallyValid' _Unwrapped
306
315
316
+ inferDefined = inferDefined' _Unwrapped
317
+
307
318
deriveSeqOnePath
308
319
:: MonadSimplify simplifier
309
320
=> [Rule OnePathRule ]
@@ -331,6 +342,7 @@ instance Goal AllPathRule where
331
342
simplify = simplify' _Unwrapped
332
343
checkImplication = checkImplication' _Unwrapped
333
344
isTriviallyValid = isTriviallyValid' _Unwrapped
345
+ inferDefined = inferDefined' _Unwrapped
334
346
applyClaims claims = deriveSeqAllPath (map goalToRule claims)
335
347
336
348
applyAxioms axiomss = \ goal ->
@@ -406,6 +418,15 @@ instance Goal ReachabilityRule where
406
418
isTriviallyValid (AllPath goal) = isTriviallyValid goal
407
419
isTriviallyValid (OnePath goal) = isTriviallyValid goal
408
420
421
+ inferDefined (AllPath goal) =
422
+ inferDefined goal
423
+ & fmap AllPath
424
+ & allPathTransition
425
+ inferDefined (OnePath goal) =
426
+ inferDefined goal
427
+ & fmap OnePath
428
+ & onePathTransition
429
+
409
430
applyClaims claims (AllPath goal) =
410
431
applyClaims (mapMaybe maybeAllPath claims) goal
411
432
& fmap (fmap AllPath )
@@ -498,6 +519,13 @@ transitionRule claims axiomGroups = transitionRuleWorker
498
519
Profile. timeStrategy " Goal.SimplifyRemainder"
499
520
$ GoalRemainder <$> simplify goal
500
521
522
+ transitionRuleWorker InferDefined (GoalRemainder goal) =
523
+ Profile. timeStrategy " inferDefined" $ do
524
+ results <- tryTransitionT (inferDefined goal)
525
+ case results of
526
+ [] -> return Proven
527
+ _ -> GoalRemainder <$> Transition. scatter results
528
+
501
529
transitionRuleWorker CheckImplication (Goal goal) =
502
530
Profile. timeStrategy " Goal.CheckImplication" $ do
503
531
result <- checkImplication goal
@@ -559,6 +587,7 @@ reachabilityFirstStep =
559
587
, CheckGoalStuck
560
588
, CheckGoalRemainder
561
589
, Simplify
590
+ , InferDefined
562
591
, TriviallyValid
563
592
, CheckImplication
564
593
, ApplyAxioms
@@ -574,6 +603,7 @@ reachabilityNextStep =
574
603
, CheckGoalStuck
575
604
, CheckGoalRemainder
576
605
, Simplify
606
+ , InferDefined
577
607
, TriviallyValid
578
608
, CheckImplication
579
609
, ApplyClaims
@@ -623,7 +653,10 @@ checkImplication' lensRulePattern goal =
623
653
do
624
654
removal <- removalPatterns destination configuration existentials
625
655
when (isTop removal) (succeed . NotImplied $ rulePattern)
626
- let configAndRemoval = fmap (configuration <* ) removal
656
+ let definedConfig =
657
+ Pattern. andCondition configuration
658
+ $ from $ makeCeilPredicate_ (Conditional. term configuration)
659
+ let configAndRemoval = fmap (definedConfig <* ) removal
627
660
sideCondition =
628
661
Pattern. withoutTerm configuration
629
662
& SideCondition. fromCondition
@@ -669,6 +702,22 @@ simplify' lensRulePattern =
669
702
then pure Pattern. bottom
670
703
else Foldable. asum (pure <$> configs)
671
704
705
+ inferDefined'
706
+ :: MonadSimplify m
707
+ => Lens' goal (RulePattern VariableName )
708
+ -> goal
709
+ -> Strategy. TransitionT (Rule goal ) m goal
710
+ inferDefined' lensRulePattern =
711
+ Lens. traverseOf (lensRulePattern . RulePattern. leftPattern) $ \ config -> do
712
+ let definedConfig =
713
+ Pattern. andCondition config
714
+ $ from $ makeCeilPredicate_ (Conditional. term config)
715
+ configs <-
716
+ simplifyTopConfiguration definedConfig
717
+ >>= SMT.Evaluator. filterMultiOr
718
+ & lift
719
+ Foldable. asum (pure <$> configs)
720
+
672
721
isTriviallyValid' :: Lens' goal (RulePattern variable ) -> goal -> Bool
673
722
isTriviallyValid' lensRulePattern =
674
723
isBottom . RulePattern. left . Lens. view lensRulePattern
0 commit comments