Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: allow certain recursive axioms #3507

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions kore/src/Kore/Equation/Application.hs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import Control.Error (
import Control.Monad (
(>=>),
)
import Data.List (delete)
import Data.Map.Strict (
Map,
)
Expand Down Expand Up @@ -89,6 +90,7 @@ import Kore.Log.DecidePredicateUnknown (
OnDecidePredicateUnknown (..),
srcLoc,
)
import Kore.Rewrite.Axiom.Identifier (matchAxiomIdentifier)
import Kore.Rewrite.Axiom.Matcher (
MatchResult,
patternMatch,
Expand Down Expand Up @@ -142,7 +144,7 @@ attemptEquation sideCondition termLike equation = do
onDecidePredicateUnknown = case simplification of
Attribute.NotSimplification -> ErrorDecidePredicateUnknown $srcLoc eqSrc
Attribute.IsSimplification _ -> WarnDecidePredicateUnknown $srcLoc eqSrc
checkRequires onDecidePredicateUnknown sideCondition predicate requires
checkRequires equation onDecidePredicateUnknown sideCondition predicate requires
& whileCheckRequires
return $ Pattern.withCondition right $ from @(Predicate _) ensures

Expand Down Expand Up @@ -344,26 +346,25 @@ Throws 'RequiresNotMet' if the 'Predicate's do not hold under the
'SideCondition'.
-}
checkRequires ::
-- | Original equation
Equation RewritingVariableName ->
OnDecidePredicateUnknown ->
SideCondition RewritingVariableName ->
-- | requires from matching
Predicate RewritingVariableName ->
-- | requires from 'Equation'
Predicate RewritingVariableName ->
ExceptT (CheckRequiresError RewritingVariableName) Simplifier ()
checkRequires onUnknown sideCondition predicate requires =
checkRequires equation onUnknown sideCondition predicate requires =
do
let requires' = makeAndPredicate predicate requires
-- The condition to refute:
condition :: Condition RewritingVariableName
condition = from @(Predicate _) (makeNotPredicate requires')
return condition
-- First try to refute 'condition' without user-defined axioms:
>>= withoutAxioms . simplifyCondition
-- Next try to refute 'condition' including user-defined axioms:
>>= withAxioms . simplifyCondition
-- Finally, try to refute the simplified 'condition' using the
-- external solver:
>>= Simplifier.localAxiomEquations (removeAxiom equation) . simplifyCondition
>>= filterBranch
>>= simplifyCondition . Condition.forgetSimplified
>>= filterBranch

-- Collect the simplified results. If they are \bottom, then \and(predicate,
Expand Down Expand Up @@ -397,10 +398,9 @@ checkRequires onUnknown sideCondition predicate requires =
, negatedImplication
}

withoutAxioms =
fmap Condition.forgetSimplified
. Simplifier.localAxiomEquations (const mempty)
withAxioms = id
removeAxiom a m =
let iden = matchAxiomIdentifier . left $ a
in Map.adjust (delete a) iden m

refreshVariables ::
SideCondition RewritingVariableName ->
Expand Down
3 changes: 3 additions & 0 deletions kore/src/Kore/Rewrite/SMT/Evaluator.hs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ evalPredicate onUnknown predicate sideConditionM = case predicate of
condition using an external SMT solver.
-}
evalConditional ::
HasCallStack =>
InternalVariable variable =>
OnDecidePredicateUnknown ->
Conditional variable term ->
Expand All @@ -132,6 +133,7 @@ filterMultiOr ::
( Ord term
, TopBottom term
, InternalVariable variable
, HasCallStack
) =>
Loc ->
MultiOr (Conditional variable term) ->
Expand All @@ -141,6 +143,7 @@ filterMultiOr hsLoc multiOr = do
return (MultiOr.make (catMaybes elements))
where
refute ::
HasCallStack =>
Conditional variable term ->
Simplifier (Maybe (Conditional variable term))
refute p =
Expand Down