Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
144 commits
Select commit Hold shift + click to select a range
16ef91d
Add module and datatype ClaimPattern
ana-pantilie Jul 24, 2020
19c1a8b
ClaimPattern: onePathRuleToTerm
ana-pantilie Jul 24, 2020
0d9cf80
ClaimPattern: allPathRuleToTerm
ana-pantilie Jul 24, 2020
6cf54fe
ClaimPattern: add missing instances
ana-pantilie Jul 24, 2020
6bfe65d
ClaimPattern: ReachabilityRule
ana-pantilie Jul 24, 2020
3fac67a
ClaimPattern: FreeVariables
ana-pantilie Jul 27, 2020
9be3816
Merge remote-tracking branch 'upstream/master' into change-representa…
ana-pantilie Jul 27, 2020
5faacd3
Rule.Expand: update to ClaimPattern
ana-pantilie Jul 27, 2020
256c30f
Rule.Simplify: add functionality for ClaimPattern
ana-pantilie Jul 27, 2020
058f1ab
Step.Rule: parse reachability claims to ClaimPattern
ana-pantilie Jul 27, 2020
12b61ca
Integrate old claim representation back
ana-pantilie Jul 27, 2020
6f9880d
Step.Rule.Expand: refactor instance for ClaimPattern
ana-pantilie Jul 28, 2020
52d5380
Step.Rule.Simplify: refactor instance for ClaimPattern
ana-pantilie Jul 28, 2020
be962b3
ClaimPattern: functions to construct ClaimPatterns
ana-pantilie Jul 28, 2020
cd886e3
Test.Step.Rule.Expand: add tests for ClaimPattern
ana-pantilie Jul 28, 2020
17c94ec
Test.Step.Rule: add Common.hs + add tests for ClaimPattern in Simplif…
ana-pantilie Jul 28, 2020
81cd449
Test.Step.Rule: fix sort issues
ana-pantilie Jul 28, 2020
f25410b
Test.Step.Rule: remove class specific to old OnePathRule
ana-pantilie Jul 28, 2020
4e27c08
Test.Step.Rule.Simplify: hlint workaround
ana-pantilie Jul 28, 2020
c263eee
Test.Step.Rule.Simplify: hlint workaround
ana-pantilie Jul 28, 2020
cdfd7ee
Test.Step.Rule.Simplify: fix unit test
ana-pantilie Jul 28, 2020
49d435c
HLint
ana-pantilie Jul 28, 2020
82c6c6c
Clean-up
ana-pantilie Jul 28, 2020
854f338
Merge branch 'master' into change-representation-of-claims
ana-pantilie Jul 29, 2020
89d4a32
Fix ClaimPattern right hand side free variables bug
ana-pantilie Jul 29, 2020
6eaf5c1
Fix ClaimPattern unparsing bug
ana-pantilie Jul 29, 2020
0342cc6
SentenceVerifier: case for ClaimPatterns
ana-pantilie Jul 29, 2020
deb9abd
Kore.Step.Rule.Expand: Remove redundant State field
ttuegel Jul 29, 2020
5f866d4
Test.Kore.Step.Rule.Expand: Separate old and new tests
ttuegel Jul 29, 2020
03f9f85
Address review comments
ana-pantilie Jul 30, 2020
5fc5741
Merge branch 'change-representation-of-claims' into change-representa…
ana-pantilie Jul 30, 2020
994e8e9
Global clean-up and WIP transition to ClaimPattern
ana-pantilie Jul 30, 2020
6f3631d
WIP fill in strategy steps + move RewritingVariable transformations
ana-pantilie Jul 31, 2020
d06b5a7
Kore.Repl: use ClaimPattern
ana-pantilie Aug 1, 2020
75140a2
ClaimPattern: refreshClaim
ana-pantilie Aug 3, 2020
978171a
UnifyingRule: variable type determined rule type
ana-pantilie Aug 4, 2020
726e294
Step.RewriteStep: implementation for ClaimPattern
ana-pantilie Aug 5, 2020
06a2d9d
Strategies.Goal: deriveSeqClaim + WIP deriveResultsClaim
ana-pantilie Aug 5, 2020
19ad066
Strategies.Goal: transitioning should save sum type of applied rule t…
ana-pantilie Aug 5, 2020
bc3eba1
Strategies.Goal: AppliedRule
ana-pantilie Aug 5, 2020
91e2898
Strategies.Goal: applyClaims
ana-pantilie Aug 5, 2020
c7a1237
Strategies.Goal: checkImplication implementation draft
ana-pantilie Aug 7, 2020
c61a755
Add missing implementations
ana-pantilie Aug 7, 2020
36cd8c9
ClaimPattern: fix unparsing bug
ana-pantilie Aug 10, 2020
3b6319a
Strategy fixes
ana-pantilie Aug 10, 2020
927a40f
Fix unparsing bug
ana-pantilie Aug 10, 2020
6f37c71
Test.Step.RewriteStep: revert changes
ana-pantilie Aug 11, 2020
b0fa63b
Repl.Interpreter: fix tests
ana-pantilie Aug 11, 2020
eb527b0
Repl: make goal when beginning to prove claim
ana-pantilie Aug 11, 2020
e148412
Kore.Exec: simplify claims only with ML rules
ana-pantilie Aug 11, 2020
6aae817
save-proofs: config variable wrapper
ana-pantilie Aug 11, 2020
a24817f
ClaimPattern: fix right hand side parsing bug
ana-pantilie Aug 11, 2020
14f0a9e
Fix bugs
ana-pantilie Aug 12, 2020
d9b12b6
Fix unparsing bugs
ana-pantilie Aug 13, 2020
18678d2
Fix unparsing bug
ana-pantilie Aug 13, 2020
abe74f1
Clean-up: RewritingVariable
ana-pantilie Aug 13, 2020
fcec97b
Remove trace
ana-pantilie Aug 13, 2020
b5b268f
Clean-up: lens ClaimPattern
ana-pantilie Aug 13, 2020
0f6e115
Clean-up: general
ana-pantilie Aug 13, 2020
55456ae
Revert golden change
ana-pantilie Aug 13, 2020
3dcbd15
Integration tests: questionable changes
ana-pantilie Aug 13, 2020
a6b54a7
Strategies.Goal: refactor checkImplication and clean-up
ana-pantilie Aug 13, 2020
7a96150
Strategies.Goal: checkImplication clarity + possible fix
ana-pantilie Aug 13, 2020
63c01fa
Step.RewriteStep: WIP reduce duplication
ana-pantilie Aug 13, 2020
42d8187
Step.RewriteStep: finish major refactoring
ana-pantilie Aug 14, 2020
c4430b4
Step.RewriteStep: clarity
ana-pantilie Aug 14, 2020
c91082d
Merge remote-tracking branch 'upstream/master' into change-representa…
ana-pantilie Aug 14, 2020
70d4edd
General clean-up
ana-pantilie Aug 14, 2020
29f310d
Clean-up
ana-pantilie Aug 14, 2020
9a0de4a
General clean-up
ana-pantilie Aug 14, 2020
840a504
Step.RulePattern: remove ToRulePattern and FromRulePattern
ana-pantilie Aug 14, 2020
33532a6
Unparsing change
ana-pantilie Aug 14, 2020
5f0b696
Revert integration test change: probably was from start-up claim simp…
ana-pantilie Aug 14, 2020
e9d36a9
Revert integration test change
ana-pantilie Aug 14, 2020
6fa510c
Add tests for refreshRule ClaimPattern
ana-pantilie Aug 14, 2020
8531b9b
Test.RewriteStep: duplicate renameRuleVariables
ana-pantilie Aug 17, 2020
f29c8c8
Test.RewriteStep: duplicate unifyRule
ana-pantilie Aug 17, 2020
63db91c
Test.RewriteStep: duplicate unifyRule
ana-pantilie Aug 17, 2020
7763685
Test.RewriteStep: WIP duplicate applyRewriteRule_
ana-pantilie Aug 17, 2020
36ab29b
Test.RewriteStep: duplicate applyRewriteRule_
ana-pantilie Aug 17, 2020
1829f3d
Test.RewriteStep: finish duplicating tests
ana-pantilie Aug 17, 2020
399b334
Test.Rule: add simple parsing test for claims + fix parsing bug
ana-pantilie Aug 17, 2020
fa6ab64
Test.Rule: add parsing test for claims with conditions + fix parsing bug
ana-pantilie Aug 17, 2020
101781f
Test.Rule: add parsing test for claims with conditions and existentials
ana-pantilie Aug 17, 2020
54051c3
Test.Rule: add parsing test for claims with conditions and existentia…
ana-pantilie Aug 17, 2020
e4d702b
Revert changes to integration tests
ana-pantilie Aug 17, 2020
9817a1e
Fix ClaimPattern RHS parsing bug
ana-pantilie Aug 17, 2020
b9c382c
General clean-up
ana-pantilie Aug 17, 2020
8f86040
Integration test failures?: add #Or in RHS of claims
ana-pantilie Aug 17, 2020
88f51b1
Remove redundant import
ana-pantilie Aug 17, 2020
227f918
Strategies.Goal: add suggested fixes + add exit case in checkImplication
ana-pantilie Aug 18, 2020
05bbd85
Revert changes to a couple of one/all-path tests
ana-pantilie Aug 18, 2020
d5197be
WIP: Add simplify-rhs integration test
ana-pantilie Aug 18, 2020
c36cc19
Add simplify-rhs integration test
ana-pantilie Aug 18, 2020
a71b3be
Update kore/test/Test/Kore/Strategies/AllPath/Verification.hs
ana-pantilie Aug 19, 2020
dc52f41
Update kore/src/Kore/Step/RewriteStep.hs
ana-pantilie Aug 19, 2020
a1d7242
Update kore/src/Kore/Step/ClaimPattern.hs
ana-pantilie Aug 19, 2020
2d7b560
Update kore/src/Kore/Internal/Pattern.hs
ana-pantilie Aug 19, 2020
e92a59a
Address review comments: parse claim RHS
ana-pantilie Aug 19, 2020
135a08d
Address review comments: separate predicate and substitution
ana-pantilie Aug 19, 2020
1fa7961
Merge branch 'change-representation-of-claims-part2' into simplify-rh…
ana-pantilie Aug 19, 2020
f9e62ff
RED: expect evaluated RHS
ana-pantilie Aug 19, 2020
48628e2
GRN: simplify RHS during Simplify strategy step
ana-pantilie Aug 19, 2020
ea5e101
Strategy.Goal: fix bugs in checkImplication
ana-pantilie Aug 19, 2020
3711f3e
MOVE THIS! Strategies.Goal: checkImplicationWorker to global scope fo…
ana-pantilie Aug 20, 2020
ede2f09
MOVE THIS! Test.Strategies.Goal: WIP add tests for checkImplicationWo…
ana-pantilie Aug 20, 2020
f0ac742
Remove test from simplify-rhs branch
ana-pantilie Aug 20, 2020
73a2d29
Remove simplify rhs
ana-pantilie Aug 20, 2020
10c2002
Test.Strategies.Goal: add RHS branching tests
ana-pantilie Aug 20, 2020
37f5f91
Refactor checkImplication. Tests still failing
ana-pantilie Aug 21, 2020
b773602
git add src/Kore/Step/Simplification/AndPredicates.hs! Step.Simplific…
ana-pantilie Aug 21, 2020
00235cf
Fix check implication
ana-pantilie Aug 21, 2020
cdbcddc
Update Exec.hs
ana-pantilie Aug 21, 2020
ae3fcc0
Extract assertFunctionLikeConfiguration
ttuegel Aug 21, 2020
d8aeabc
checkImplication: Allow branching
ttuegel Aug 21, 2020
03b989b
Merge branch 'master' into change-representation-of-claims-part2
ttuegel Aug 21, 2020
a7fd9db
Refactor checkImplicationWorker
ttuegel Aug 21, 2020
faed75d
stack.yaml: Update hashes
ttuegel Aug 21, 2020
bb590d9
test_checkImplication: does not unify, with left condition
ttuegel Aug 22, 2020
cf7d9e2
test_checkImplication: does not unify, with right condition
ttuegel Aug 22, 2020
5103706
Prelude.Kore: Export Data.Tuple
ttuegel Aug 22, 2020
983fd14
checkImplicationWorker: Report NotImplied if unification unsuccessful
ttuegel Aug 22, 2020
820a26e
test/all-path: Do not unify with initial configuration
ttuegel Aug 22, 2020
0fedd8b
hlint
ana-pantilie Aug 24, 2020
75d1655
checkImplicationWorker: Do not call topExistsToImplicitForall
ttuegel Aug 22, 2020
a3d3413
checkImplicationWorker: getNegatedConjuncts
ttuegel Aug 22, 2020
f8faedb
Remove topExistsToImplicitForall
ttuegel Aug 23, 2020
b06a6c0
checkImplicationWorker: Documentation
ttuegel Aug 23, 2020
9ea62dd
checkImplicationWorker: Use leftCondition as sideCondition
ttuegel Aug 23, 2020
dbeadd7
Kore.Internal.SideCondition.assertNormalized
ttuegel Aug 24, 2020
2a5e0ba
Revert "checkImplicationWorker: Use leftCondition as sideCondition"
ttuegel Aug 24, 2020
6bc7a11
TODO: checkImplicationWorker: SideCondition and subtitution
ttuegel Aug 24, 2020
2c8bb8c
finalizeAppliedClaim: Do not drop substitution from right-hand side
ttuegel Aug 24, 2020
7726522
finalizeAppliedRule: Do not drop substitution from right-hand side
ttuegel Aug 24, 2020
699a5fb
TODO: test: Check disjunction in ensures
ttuegel Aug 24, 2020
1aacaa1
constructConfiguration: Remove redundant ensures argument
ttuegel Aug 24, 2020
e6dec50
refreshRule: Use a State-based implementation
ttuegel Aug 24, 2020
6be2a1a
RulePattern.refreshRule: Use a State-based implementation
ttuegel Aug 24, 2020
e9e0af8
Address review comments
ana-pantilie Aug 24, 2020
94dded1
Kore.Step.AxiomPattern: add AxiomPattern
ana-pantilie Aug 24, 2020
e2c5762
Merge remote-tracking branch 'upstream/master' into change-representa…
ana-pantilie Aug 24, 2020
5d26ec4
AxiomPattern: remove From AllPathRule TermLike instances
ana-pantilie Aug 24, 2020
c1cbe38
Verification: unwrap variables in thrown config
ana-pantilie Aug 24, 2020
2a0f405
Remove redundant import
ana-pantilie Aug 24, 2020
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
10 changes: 5 additions & 5 deletions kore/app/exec/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,12 @@ import Kore.Parser
)
import Kore.Rewriting.RewritingVariable
import Kore.Step
import Kore.Step.RulePattern
import Kore.Step.ClaimPattern
( ReachabilityRule
, RewriteRule
, toSentence
)
import qualified Kore.Step.RulePattern as Rule
( toSentence
import Kore.Step.RulePattern
( RewriteRule
)
import Kore.Step.Search
( SearchType (..)
Expand Down Expand Up @@ -757,7 +757,7 @@ koreProve execOptions proveOptions = do
Module
{ moduleName = savedProofsModuleName
, moduleSentences =
specModuleDefinitions ++ map Rule.toSentence provenClaims
specModuleDefinitions <> fmap toSentence provenClaims
, moduleAttributes = def
}
provenDefinition = Definition
Expand Down
46 changes: 17 additions & 29 deletions kore/src/Kore/ASTVerifier/SentenceVerifier.hs
Original file line number Diff line number Diff line change
Expand Up @@ -75,26 +75,22 @@ import qualified Kore.Builtin as Builtin
import Kore.Error
import Kore.IndexedModule.IndexedModule
import Kore.IndexedModule.Resolvers as Resolvers
import Kore.Internal.Predicate
( unwrapPredicate
)
import qualified Kore.Internal.Symbol as Internal.Symbol
import Kore.Internal.TermLike.TermLike
( freeVariables
)
import Kore.Sort
import qualified Kore.Step.AntiLeft as AntiLeft
( toTermLike
import Kore.Step.ClaimPattern
( AllPathRule (..)
, ClaimPattern
, OnePathRule (..)
, freeVariablesLeft
, freeVariablesRight
)
import Kore.Step.Rule
( QualifiedAxiomPattern (..)
, fromSentenceAxiom
)
import Kore.Step.RulePattern
( AllPathRule (..)
, OnePathRule (..)
, RulePattern (..)
)
import Kore.Syntax.Definition
import Kore.Syntax.Variable
import qualified Kore.Verified as Verified
Expand Down Expand Up @@ -411,27 +407,19 @@ verifyClaimSentence sentence =
((attrs, verified) :)
rejectClaim attrs verified =
case fromSentenceAxiom (attrs, verified) of
Right (OnePathClaimPattern (OnePathRule rulePattern))
| rejectRulePattern rulePattern -> True
Right (AllPathClaimPattern (AllPathRule rulePattern))
| rejectRulePattern rulePattern -> True
Right (OnePathClaimPattern (OnePathRule claimPattern))
| rejectClaimPattern claimPattern -> True
Right (AllPathClaimPattern (AllPathRule claimPattern))
| rejectClaimPattern claimPattern -> True
_ -> False
rejectRulePattern :: RulePattern VariableName -> Bool
rejectRulePattern
RulePattern
{ left
, antiLeft
, requires
, rhs
}
=
not $ Set.isSubsetOf rightVars leftVars
rejectClaimPattern :: ClaimPattern -> Bool
rejectClaimPattern claimPattern =
not $ Set.isSubsetOf freeRightVars freeLeftVars
where
rightVars, leftVars :: Set (SomeVariable VariableName)
rightVars = freeVariables rhs & FreeVariables.toSet
lhs = Foldable.toList (AntiLeft.toTermLike <$> antiLeft)
<> [left, unwrapPredicate requires]
leftVars = foldMap freeVariables lhs & FreeVariables.toSet
freeRightVars =
freeVariablesRight claimPattern & FreeVariables.toSet
freeLeftVars =
freeVariablesLeft claimPattern & FreeVariables.toSet

verifySorts :: [ParsedSentence] -> SentenceVerifier ()
verifySorts = Foldable.traverse_ verifySortSentence . mapMaybe project
Expand Down
35 changes: 24 additions & 11 deletions kore/src/Kore/Exec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import Control.Error
( note
, runMaybeT
)
import qualified Control.Lens as Lens
import Control.Monad
( (>=>)
)
Expand Down Expand Up @@ -108,6 +109,10 @@ import qualified Kore.Repl as Repl
import qualified Kore.Repl.Data as Repl.Data
import Kore.Rewriting.RewritingVariable
import Kore.Step
import Kore.Step.ClaimPattern
( ReachabilityRule (..)
, lensClaimPattern
)
import Kore.Step.Rule
( extractImplicationClaims
, extractRewriteAxioms
Expand All @@ -124,11 +129,11 @@ import Kore.Step.Rule.Simplify
)
import Kore.Step.RulePattern
( ImplicationRule (..)
, ReachabilityRule (..)
, RewriteRule (RewriteRule)
, ToRulePattern (..)
, getRewriteRule
, lhsEqualsRhs
, mkRewritingRule
, unRewritingRule
)
import Kore.Step.RulePattern as RulePattern
( RulePattern (..)
Expand Down Expand Up @@ -233,10 +238,13 @@ exec breadthLimit verifiedModule strategy initialTerm =
Strategy.leavesM
updateQueue
(Strategy.unfoldTransition transit)
(strategy rewriteRules, (ExecDepth 0, initialConfig))
( strategy rewriteRules
, (ExecDepth 0, mkRewritingPattern initialConfig)
)
infoExecDepth execDepth
exitCode <- getExitCode verifiedModule finalConfig
let finalTerm = forceSort initialSort $ Pattern.toTermLike finalConfig
let finalConfig' = getRewritingPattern finalConfig
exitCode <- getExitCode verifiedModule finalConfig'
let finalTerm = forceSort initialSort $ Pattern.toTermLike finalConfig'
return (exitCode, finalTerm)
where
dropStrategy = snd
Expand All @@ -247,7 +255,7 @@ exec breadthLimit verifiedModule strategy initialTerm =
takeFirstResult act =
Logic.observeT (takeResult <$> lift act) & runMaybeT
orElseBottom =
pure . fromMaybe (ExecDepth 0, Pattern.bottomOf initialSort)
pure . fromMaybe (ExecDepth 0, mkRewritingPattern (Pattern.bottomOf initialSort))
verifiedModule' =
IndexedModule.mapPatterns
-- TODO (thomas.tuegel): Move this into Kore.Builtin
Expand Down Expand Up @@ -339,19 +347,23 @@ search breadthLimit verifiedModule strategy termLike searchPattern searchConfig
(config : _) -> config
runStrategy' =
runStrategy breadthLimit transitionRule (strategy rewriteRules)
executionGraph <- runStrategy' initialPattern
executionGraph <- runStrategy' (mkRewritingPattern initialPattern)
let
match target config = Search.matchWith target config
solutionsLists <-
searchGraph
searchConfig
(match SideCondition.topTODO searchPattern)
(match SideCondition.topTODO (mkRewritingPattern searchPattern))
executionGraph
let
solutions = concatMap MultiOr.extractPatterns solutionsLists
orPredicate =
makeMultipleOrPredicate (Condition.toPredicate <$> solutions)
return (forceSort patternSort $ unwrapPredicate orPredicate)
return
. forceSort patternSort
. getRewritingTerm
. unwrapPredicate
$ orPredicate
where
patternSort = termLikeSort termLike

Expand Down Expand Up @@ -643,8 +655,9 @@ simplifyReachabilityRule
=> ReachabilityRule
-> simplifier ReachabilityRule
simplifyReachabilityRule rule = do
rule' <- Rule.simplifyRewriteRule (RewriteRule . toRulePattern $ rule)
return (Goal.fromRulePattern rule . getRewriteRule $ rule')
let claim = Lens.view lensClaimPattern rule
claim' <- Rule.simplifyClaimPattern claim
return $ Lens.set lensClaimPattern claim' rule

-- | Collect various rules and simplifiers in preparation to execute.
initialize
Expand Down
2 changes: 0 additions & 2 deletions kore/src/Kore/IndexedModule/SortGraph.hs
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@ fromSubsorts relations =

nodeMap :: Map Sort Int
nodeMap = Map.fromList (map swap lnodes)
where
swap (x, y) = (y, x)

edges :: [Graph.LEdge ()]
edges =
Expand Down
16 changes: 16 additions & 0 deletions kore/src/Kore/Internal/Conditional.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ module Kore.Internal.Conditional
, isPredicate
, Kore.Internal.Conditional.mapVariables
, isNormalized
, assertNormalized
, markPredicateSimplified
, markPredicateSimplifiedConditional
, setPredicateSimplified
Expand Down Expand Up @@ -463,6 +464,21 @@ isNormalized Conditional { predicate, substitution } =
Substitution.isNormalized substitution
&& Predicate.isFreeOf predicate (Substitution.variables substitution)

{- | See also: 'isNormalized'
-}
assertNormalized
:: HasCallStack
=> Ord variable
=> Conditional variable term
-> a
-> a
assertNormalized Conditional { predicate, substitution } a =
a
& assert (Substitution.isNormalized substitution)
& assert (Predicate.isFreeOf predicate variables)
where
variables = Substitution.variables substitution

{-| Marks the condition's predicate as being simplified.

Since the substitution is usually simplified, this usually marks the entire
Expand Down
30 changes: 29 additions & 1 deletion kore/src/Kore/Internal/MultiAnd.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,13 @@ module Kore.Internal.MultiAnd
, make
, toPredicate
, singleton
, toPattern
, map
) where

import Prelude.Kore
import Prelude.Kore hiding
( map
)

import Control.DeepSeq
( NFData
Expand All @@ -30,11 +34,18 @@ import qualified GHC.Exts as GHC
import qualified GHC.Generics as GHC

import Debug
import Kore.Internal.Pattern
( Pattern
)
import qualified Kore.Internal.Pattern as Pattern
import Kore.Internal.Predicate
( Predicate
, makeAndPredicate
, makeTruePredicate_
)
import Kore.Internal.TermLike
( mkAnd
)
import Kore.Internal.Variable
import Kore.TopBottom
( TopBottom (..)
Expand Down Expand Up @@ -172,3 +183,20 @@ toPredicate (MultiAnd predicates) =
case predicates of
[] -> makeTruePredicate_
_ -> foldr1 makeAndPredicate predicates

toPattern
:: InternalVariable variable
=> MultiAnd (Pattern variable)
-> Pattern variable
toPattern (MultiAnd patterns) =
case patterns of
[] -> Pattern.top
_ -> foldr1 (\pat1 pat2 -> pure mkAnd <*> pat1 <*> pat2) patterns

map
:: Ord child2
=> TopBottom child2
=> (child1 -> child2)
-> MultiAnd child1
-> MultiAnd child2
map f = make . fmap f . extractPatterns
13 changes: 12 additions & 1 deletion kore/src/Kore/Internal/MultiOr.hs
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,14 @@ module Kore.Internal.MultiOr
, merge
, mergeAll
, singleton
, map
-- * Re-exports
, Alternative (..)
) where

import Prelude.Kore
import Prelude.Kore hiding
( map
)

import Control.DeepSeq
( NFData
Expand Down Expand Up @@ -355,3 +358,11 @@ gather act = make <$> Logic.gather act

observeAllT :: (Ord a, TopBottom a, Monad m) => LogicT m a -> m (MultiOr a)
observeAllT act = make <$> Logic.observeAllT act

map
:: Ord child2
=> TopBottom child2
=> (child1 -> child2)
-> MultiOr child1
-> MultiOr child2
map f = make . fmap f . extractPatterns
11 changes: 1 addition & 10 deletions kore/src/Kore/Internal/OrPattern.hs
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ module Kore.Internal.OrPattern
, toTermLike
, targetBinder
, substitute
, parseFromTermLike
, MultiOr.flatten
, MultiOr.filterOr
, MultiOr.gather
, MultiOr.observeAllT
, MultiOr.map
) where

import Prelude.Kore
Expand Down Expand Up @@ -57,7 +57,6 @@ import qualified Kore.Internal.SideCondition.SideCondition as SideCondition
)
import Kore.Internal.TermLike
( InternalVariable
, pattern Or_
, Sort
, TermLike
, mkBottom_
Expand Down Expand Up @@ -233,11 +232,3 @@ substitute
-> OrPattern variable
substitute subst =
fromPatterns . fmap (Pattern.substitute subst) . toPatterns

parseFromTermLike
:: InternalVariable variable
=> TermLike variable
-> OrPattern variable
parseFromTermLike (Or_ _ term1 term2) =
parseFromTermLike term1 <> parseFromTermLike term2
parseFromTermLike term = fromTermLike term
12 changes: 10 additions & 2 deletions kore/src/Kore/Internal/SideCondition.hs
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ andCondition
=> SideCondition variable
-> Condition variable
-> SideCondition variable
andCondition SideCondition {assumedTrue} newCondition =
assert (isNormalized result) result
andCondition SideCondition { assumedTrue } newCondition =
assertNormalized result result
where
result = SideCondition
{ representation = toRepresentationCondition merged
Expand Down Expand Up @@ -214,3 +214,11 @@ toRepresentationCondition =

isNormalized :: forall variable. Ord variable => SideCondition variable -> Bool
isNormalized = Conditional.isNormalized . from @_ @(Condition variable)

assertNormalized
:: forall variable a
. HasCallStack
=> Ord variable
=> SideCondition variable
-> a -> a
assertNormalized = Conditional.assertNormalized . from @_ @(Condition variable)
Loading