@@ -9,6 +9,7 @@ module Kore.Strategies.Goal
9
9
, ClaimExtractor (.. )
10
10
, TransitionRuleTemplate (.. )
11
11
, WithConfiguration (.. )
12
+ , CheckImplicationResult (.. )
12
13
, extractClaims
13
14
, unprovenNodes
14
15
, proven
@@ -542,9 +543,8 @@ data TransitionRuleTemplate monad goal =
542
543
{ simplifyTemplate
543
544
:: goal -> Strategy.TransitionT (Rule goal) monad goal
544
545
, checkImplicationTemplate
545
- :: (forall x. x -> ProofState x)
546
- -> goal
547
- -> Strategy.TransitionT (Rule goal) monad (ProofState goal)
546
+ :: goal
547
+ -> Strategy.TransitionT (Rule goal) monad (CheckImplicationResult goal)
548
548
, isTriviallyValidTemplate :: goal -> Bool
549
549
, deriveParTemplate
550
550
:: [Rule goal ]
@@ -624,11 +624,19 @@ transitionRuleTemplate
624
624
$ GoalRemainder <$> simplifyTemplate goal
625
625
626
626
transitionRuleWorker CheckImplication (Goal goal) =
627
- Profile. timeStrategy " Goal.CheckImplication"
628
- $ checkImplicationTemplate Goal goal
627
+ Profile. timeStrategy " Goal.CheckImplication" $ do
628
+ result <- checkImplicationTemplate goal
629
+ case result of
630
+ NotImpliedStuck a -> pure (GoalStuck a)
631
+ Implied -> pure Proven
632
+ NotImplied a -> pure (Goal a)
629
633
transitionRuleWorker CheckImplication (GoalRemainder goal) =
630
- Profile. timeStrategy " Goal.CheckImplicationRemainder"
631
- $ checkImplicationTemplate GoalRemainder goal
634
+ Profile. timeStrategy " Goal.CheckImplicationRemainder" $ do
635
+ result <- checkImplicationTemplate goal
636
+ case result of
637
+ NotImpliedStuck a -> pure (GoalStuck a)
638
+ Implied -> pure Proven
639
+ NotImplied a -> pure (GoalRemainder a)
632
640
633
641
transitionRuleWorker TriviallyValid (Goal goal)
634
642
| isTriviallyValidTemplate goal =
@@ -756,28 +764,44 @@ allPathFollowupStep claims axiomGroups =
756
764
, TriviallyValid
757
765
]
758
766
767
+ {- | The result of checking the direct implication of a proof goal.
768
+
769
+ As an optimization, 'checkImplication' returns 'NotImpliedStuck' when the
770
+ implication between /terms/ is valid, but the implication between side
771
+ conditions does not hold.
772
+
773
+ -}
774
+ data CheckImplicationResult a
775
+ = Implied
776
+ -- ^ The implication is valid.
777
+ | NotImplied ! a
778
+ -- ^ The implication is not valid.
779
+ | NotImpliedStuck ! a
780
+ -- ^ The implication between /terms/ is valid, but the implication between
781
+ -- side-conditions is not valid.
782
+ deriving (Functor )
783
+
759
784
-- | Remove the destination of the goal.
760
785
checkImplication
761
786
:: forall goal m
762
787
. MonadSimplify m
763
788
=> MonadCatch m
764
789
=> Lens' goal (RulePattern VariableName )
765
- -> (forall x . x -> ProofState x )
766
790
-> goal
767
- -> Strategy. TransitionT (Rule goal ) m (ProofState goal )
768
- checkImplication lensRulePattern mkState goal =
791
+ -> Strategy. TransitionT (Rule goal ) m (CheckImplicationResult goal )
792
+ checkImplication lensRulePattern goal =
769
793
goal
770
794
& Lens. traverseOf lensRulePattern (Compose . checkImplicationWorker)
771
795
& getCompose
772
796
& lift
773
797
where
774
798
checkImplicationWorker
775
799
:: RulePattern VariableName
776
- -> m (ProofState (RulePattern VariableName ))
800
+ -> m (CheckImplicationResult (RulePattern VariableName ))
777
801
checkImplicationWorker (snd . Step. refreshRule mempty -> rulePattern) =
778
802
do
779
803
removal <- removalPatterns destination configuration existentials
780
- when (isTop removal) (succeed . mkState $ rulePattern)
804
+ when (isTop removal) (succeed . NotImplied $ rulePattern)
781
805
let configAndRemoval = fmap (configuration <* ) removal
782
806
sideCondition =
783
807
Pattern. withoutTerm configuration
@@ -786,11 +810,11 @@ checkImplication lensRulePattern mkState goal =
786
810
simplifyConditionsWithSmt
787
811
sideCondition
788
812
configAndRemoval
789
- when (isBottom simplifiedRemoval) (succeed Proven )
813
+ when (isBottom simplifiedRemoval) (succeed Implied )
790
814
let stuckConfiguration = OrPattern. toPattern simplifiedRemoval
791
815
rulePattern
792
816
& Lens. set RulePattern. leftPattern stuckConfiguration
793
- & GoalStuck
817
+ & NotImpliedStuck
794
818
& pure
795
819
& run
796
820
& withConfiguration configuration
0 commit comments