Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
65cb367
inferDefined': mark configuration defined
ttuegel Jul 15, 2020
999362d
transitionRule: Apply InferDefined to all rewritable goals
ttuegel Jul 16, 2020
5bb65b6
AndTerms: Add unifyDefined
ttuegel Jul 16, 2020
9e17258
Kore.Internal.TermLike.unDefined
ttuegel Jul 20, 2020
b3ef4bb
equalAndEquals: Ignore Defined terms
ttuegel Jul 20, 2020
dd67400
unifyDefined
ttuegel Jul 20, 2020
435decf
matchDefined
ttuegel Jul 20, 2020
f8a1536
equalsAndEquals: Prefer the term which is defined
ttuegel Jul 21, 2020
1d1eb6f
functionAnd: Fix predicate sort
ttuegel Jul 25, 2020
f37f619
updateConcreteElements: Use separate assertions for clearer errors
ttuegel Jul 26, 2020
e6d03d8
test_Defined
ttuegel Jul 26, 2020
ddd5ef0
RED test_Defined Sets
ttuegel Jul 27, 2020
827c527
GRN test_Defined Sets
ttuegel Jul 27, 2020
77888fc
RED test_Defined Maps
ttuegel Jul 27, 2020
274472f
GRN test_Defined Maps
ttuegel Jul 27, 2020
3675ff5
Move InferDefined step into Simplify
ttuegel Jul 27, 2020
aab9652
Remove InferDefined step
ttuegel Jul 27, 2020
32b3d09
Goal: Remove method inferDefined
ttuegel Jul 27, 2020
7c38484
Remove -fno-prof-auto everywhere
ttuegel Jul 30, 2020
aba09d7
test_Defined: Test equal patterns both ways
ttuegel Aug 4, 2020
21ee72b
equalAndEquals: Always return first pattern
ttuegel Aug 4, 2020
83be041
RED test_goTranslatePredicate: Test defined /Int patterns
ttuegel Aug 4, 2020
fdc14ed
GRN translatePredicateWith: Remove Defined wrapper from Int and Bool
ttuegel Aug 4, 2020
b3e15b2
test_goTranslatePredicate -> test_translatePredicateWith
ttuegel Aug 4, 2020
288cfff
test/imp: make golden
ttuegel Aug 4, 2020
74de3f7
test/map/map-definedness: make golden
ttuegel Aug 4, 2020
175c0ad
Merge branch 'master' into feature--infer-defined-config
ttuegel Aug 4, 2020
d936801
test_Defined: equalAndEquals returns the first argument
ttuegel Aug 6, 2020
c9c3213
Kore.Internal.TermLike.unDefined: Documentation
ttuegel Aug 6, 2020
329d946
Merge branch 'master' into feature--infer-defined-config
ttuegel Aug 6, 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
9 changes: 4 additions & 5 deletions kore/src/Kore/Builtin/AssociativeCommutative.hs
Original file line number Diff line number Diff line change
Expand Up @@ -426,10 +426,9 @@ updateConcreteElements
-> [(TermLike Concrete, value)]
-> Maybe (Map (TermLike Concrete) value)
updateConcreteElements elems newElems =
TermLike.assertConstructorLikeKeys allKeys
$ Foldable.foldrM (uncurry insertMissing) elems newElems
where
allKeys = Map.keys elems <> fmap fst newElems
Foldable.foldrM (uncurry insertMissing) elems newElems
& TermLike.assertConstructorLikeKeys (Map.keys elems)
& TermLike.assertConstructorLikeKeys (fst <$> newElems)

{- | Sort the abstract elements.

Expand Down Expand Up @@ -767,7 +766,7 @@ unifyEqualsNormalized
(unzip . Map.toList)
(Domain.concreteElements unwrapped)

return (unifierTerm `withCondition` unifierCondition)
return (unifierTerm `Pattern.withCondition` unifierCondition)
where
sort1 = termLikeSort first

Expand Down
1 change: 0 additions & 1 deletion kore/src/Kore/Debug.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{-# OPTIONS_GHC -Wno-unused-top-binds #-}
{-# OPTIONS_GHC -fno-prof-auto #-}

{- |
Copyright : (c) Runtime Verification, 2018
Expand Down
2 changes: 0 additions & 2 deletions kore/src/Kore/Internal/Conditional.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ Representation of conditional terms.

-}

{-# OPTIONS_GHC -fno-prof-auto #-}

module Kore.Internal.Conditional
( Conditional (..)
, withoutTerm
Expand Down
11 changes: 11 additions & 0 deletions kore/src/Kore/Internal/TermLike.hs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ module Kore.Internal.TermLike
, mkEndianness
, mkSignedness
, mkDefined
, unDefined
-- * Predicate constructors
, mkBottom_
, mkCeil_
Expand Down Expand Up @@ -1557,6 +1558,16 @@ mkDefined = updateCallStack . worker
mkDefinedAtTop :: Ord variable => TermLike variable -> TermLike variable
mkDefinedAtTop = synthesize . DefinedF . Defined

{- | Remove (recursively) the 'Defined' wrappers throughout a 'TermLike'.
-}
unDefined :: TermLike variable -> TermLike variable
unDefined =
Recursive.unfold $ \termLike ->
let attrs :< termLikeF = Recursive.project termLike in
case termLikeF of
DefinedF defined -> Recursive.project (getDefined defined)
_ -> attrs :< termLikeF

{- | Construct an 'Endianness' pattern.
-}
mkEndianness
Expand Down
1 change: 0 additions & 1 deletion kore/src/Kore/Log/InfoReachability.hs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ instance Entry InfoReachability where
primDoc :: Prim -> Maybe (Doc ann)
primDoc Simplify = Just "simplifying the claim"
primDoc CheckImplication = Just "checking the implication"
primDoc InferDefined = Just "inferring that the configuration is defined"
primDoc ApplyClaims = Just "applying claims"
primDoc ApplyAxioms = Just "applying axioms"
primDoc _ = Nothing
Expand Down
10 changes: 10 additions & 0 deletions kore/src/Kore/Step/Axiom/Matcher.hs
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ matchOne pair =
<|> matchBuiltinSet pair
<|> matchInj pair
<|> matchOverload pair
<|> matchDefined pair
)
& Error.maybeT (defer pair) return

Expand Down Expand Up @@ -408,6 +409,15 @@ matchOverload
-> MaybeT (MatcherT variable simplifier) ()
matchOverload termPair = Error.hushT (matchOverloading termPair) >>= push

matchDefined
:: (MatchingVariable variable, MonadSimplify simplifier)
=> Pair (TermLike variable)
-> MaybeT (MatcherT variable simplifier) ()
matchDefined (Pair term1 term2)
| Defined_ def1 <- term1 = push (Pair def1 term2)
| Defined_ def2 <- term2 = push (Pair term1 def2)
| otherwise = empty

-- * Implementation

type MatchingVariable variable = InternalVariable variable
Expand Down
2 changes: 2 additions & 0 deletions kore/src/Kore/Step/SMT/Translate.hs
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ translatePredicateWith translateTerm predicate =
(<|>)
(translateApplication app)
(translateUninterpreted SMT.tInt pat)
DefinedF (Defined child) -> translateInt child
_ -> empty

-- | Translate a functional pattern in the builtin Bool sort for SMT.
Expand All @@ -230,6 +231,7 @@ translatePredicateWith translateTerm predicate =
(<|>)
(translateApplication app)
(translateUninterpreted SMT.tBool pat)
DefinedF (Defined child) -> translateBool child
_ -> empty

translateApplication :: Application Symbol p -> Translator m variable SExpr
Expand Down
76 changes: 63 additions & 13 deletions kore/src/Kore/Step/Simplification/AndTerms.hs
Original file line number Diff line number Diff line change
Expand Up @@ -239,13 +239,14 @@ andEqualsFunctions notSimplifier =
, (AndT, \_ _ s -> Builtin.KEqual.unifyIfThenElse s)
, (BothT, \_ _ _ -> Builtin.Endianness.unifyEquals)
, (BothT, \_ _ _ -> Builtin.Signedness.unifyEquals)
, (BothT, \_ _ s -> Builtin.Map.unifyEquals s)
, (BothT, \_ _ s -> unifyDefinedModifier (Builtin.Map.unifyEquals s))
, (EqualsT, \_ _ s -> Builtin.Map.unifyNotInKeys s notSimplifier)
, (BothT, \_ _ s -> Builtin.Set.unifyEquals s)
, (BothT, \_ _ s -> unifyDefinedModifier (Builtin.Set.unifyEquals s))
, (BothT, \_ t s -> Builtin.List.unifyEquals t s)
, (BothT, \_ _ _ -> domainValueAndConstructorErrors)
, (BothT, \_ _ _ -> domainValueAndEqualsAssumesDifferent)
, (BothT, \_ _ _ -> stringLiteralAndEqualsAssumesDifferent)
, (BothT, \_ _ s -> unifyDefined s)
, (AndT, \_ _ _ t1 t2 -> Error.hoistMaybe $ functionAnd t1 t2)
]

Expand Down Expand Up @@ -330,7 +331,8 @@ equalAndEquals
-> TermLike variable
-> MaybeT unifier (Pattern variable)
equalAndEquals first second
| first == second =
| unDefined first == unDefined second =
-- TODO (thomas.tuegel): Preserve defined and simplified flags.
return (Pattern.fromTermLike first)
equalAndEquals _ _ = empty

Expand Down Expand Up @@ -699,16 +701,14 @@ functionAnd
-> Maybe (Pattern variable)
functionAnd first second
| isFunctionPattern first, isFunctionPattern second =
return Conditional
{ term = first -- different for Equals
-- Ceil predicate not needed since first being
-- bottom will make the entire term bottom. However,
-- one must be careful to not just drop the term.
, predicate =
Predicate.markSimplified
$ makeEqualsPredicate_ first second
, substitution = mempty
}
makeEqualsPredicate_ first second
& Predicate.markSimplified
-- Ceil predicate not needed since first being
-- bottom will make the entire term bottom. However,
-- one must be careful to not just drop the term.
& Condition.fromPredicate
& Pattern.withCondition first -- different for Equals
& pure
| otherwise = empty

bytesDifferent
Expand All @@ -723,3 +723,53 @@ bytesDifferent
| bytesFirst /= bytesSecond
= return Pattern.bottom
bytesDifferent _ _ = empty

{- | Unwrap a 'Defined' term if it is not handled elsewhere.
-}
unifyDefined
:: MonadUnify unifier
=> TermSimplifier variable unifier
-> TermLike variable
-> TermLike variable
-> MaybeT unifier (Pattern variable)
unifyDefined unifyChildren term1 term2
| Defined_ child1 <- term1 = lift $ unifyChildren child1 term2
| Defined_ child2 <- term2 = lift $ unifyChildren term1 child2
| otherwise = empty

unifyDefinedModifier
:: InternalVariable variable
=> Monad monad
=> (TermLike variable -> TermLike variable -> monad (Pattern variable))
-> TermLike variable
-> TermLike variable
-> monad (Pattern variable)
unifyDefinedModifier unify (Defined_ def1) (Defined_ def2) = do
unified <- unify def1 def2
let Conditional { term } = unified
term'
| term == def1 || term == def2
= mkDefined term
| otherwise = term
unified' = term' <$ unified
pure unified'
unifyDefinedModifier unify (Defined_ def1) term2 = do
unified <- unify def1 term2
let Conditional { term } = unified
term'
| unDefined term == unDefined def1
= mkDefined term
| otherwise = term
unified' = term' <$ unified
pure unified'
unifyDefinedModifier unify term1 (Defined_ def2) = do
unified <- unify term1 def2
let Conditional { term } = unified
term'
| unDefined term == unDefined def2
= mkDefined term
| otherwise = term
unified' = term' <$ unified
pure unified'
unifyDefinedModifier unify term1 term2 =
unify term1 term2
1 change: 0 additions & 1 deletion kore/src/Kore/Step/Simplification/Data.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ Portability : portable
-}

{-# LANGUAGE UndecidableInstances #-}
{-# OPTIONS_GHC -fno-prof-auto #-}

module Kore.Step.Simplification.Data
( Simplifier
Expand Down
2 changes: 0 additions & 2 deletions kore/src/Kore/Step/Transition.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ License : NCSA

{-# LANGUAGE UndecidableInstances #-}

{-# OPTIONS_GHC -fno-prof-auto #-}

module Kore.Step.Transition
( TransitionT (..)
, Transition
Expand Down
42 changes: 2 additions & 40 deletions kore/src/Kore/Strategies/Goal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ import Kore.Internal.Symbol
)
import Kore.Internal.TermLike
( isFunctionPattern
, mkDefined
, mkIn
, termLikeSort
)
Expand Down Expand Up @@ -202,11 +203,6 @@ class Goal goal where
-- checkImplication.
isTriviallyValid :: goal -> Bool

inferDefined
:: MonadSimplify m
=> goal
-> Strategy.TransitionT (Rule goal) m goal

checkImplication
:: MonadSimplify m
=> goal -> m (CheckImplicationResult goal)
Expand Down Expand Up @@ -313,8 +309,6 @@ instance Goal OnePathRule where

isTriviallyValid = isTriviallyValid' _Unwrapped

inferDefined = inferDefined' _Unwrapped

deriveSeqOnePath
:: MonadSimplify simplifier
=> [Rule OnePathRule]
Expand Down Expand Up @@ -342,7 +336,6 @@ instance Goal AllPathRule where
simplify = simplify' _Unwrapped
checkImplication = checkImplication' _Unwrapped
isTriviallyValid = isTriviallyValid' _Unwrapped
inferDefined = inferDefined' _Unwrapped
applyClaims claims = deriveSeqAllPath (map goalToRule claims)

applyAxioms axiomss = \goal ->
Expand Down Expand Up @@ -418,15 +411,6 @@ instance Goal ReachabilityRule where
isTriviallyValid (AllPath goal) = isTriviallyValid goal
isTriviallyValid (OnePath goal) = isTriviallyValid goal

inferDefined (AllPath goal) =
inferDefined goal
& fmap AllPath
& allPathTransition
inferDefined (OnePath goal) =
inferDefined goal
& fmap OnePath
& onePathTransition

applyClaims claims (AllPath goal) =
applyClaims (mapMaybe maybeAllPath claims) goal
& fmap (fmap AllPath)
Expand Down Expand Up @@ -515,12 +499,6 @@ transitionRule claims axiomGroups = transitionRuleWorker
transitionRuleWorker Simplify (GoalRemainder goal) =
GoalRemainder <$> simplify goal

transitionRuleWorker InferDefined (GoalRemainder goal) = do
results <- tryTransitionT (inferDefined goal)
case results of
[] -> return Proven
_ -> GoalRemainder <$> Transition.scatter results

transitionRuleWorker CheckImplication (Goal goal) = do
result <- checkImplication goal
case result of
Expand Down Expand Up @@ -582,7 +560,6 @@ reachabilityFirstStep =
, CheckGoalStuck
, CheckGoalRemainder
, Simplify
, InferDefined
, TriviallyValid
, CheckImplication
, ApplyAxioms
Expand All @@ -598,7 +575,6 @@ reachabilityNextStep =
, CheckGoalStuck
, CheckGoalRemainder
, Simplify
, InferDefined
, TriviallyValid
, CheckImplication
, ApplyClaims
Expand Down Expand Up @@ -689,23 +665,9 @@ simplify'
-> goal
-> Strategy.TransitionT (Rule goal) m goal
simplify' lensRulePattern =
Lens.traverseOf (lensRulePattern . RulePattern.leftPattern) $ \config -> do
configs <-
simplifyTopConfiguration config >>= SMT.Evaluator.filterMultiOr
& lift
if isBottom configs
then pure Pattern.bottom
else Foldable.asum (pure <$> configs)

inferDefined'
:: MonadSimplify m
=> Lens' goal (RulePattern VariableName)
-> goal
-> Strategy.TransitionT (Rule goal) m goal
inferDefined' lensRulePattern =
Lens.traverseOf (lensRulePattern . RulePattern.leftPattern) $ \config -> do
let definedConfig =
Pattern.andCondition config
Pattern.andCondition (mkDefined <$> config)
$ from $ makeCeilPredicate_ (Conditional.term config)
configs <-
simplifyTopConfiguration definedConfig
Expand Down
6 changes: 1 addition & 5 deletions kore/src/Kore/Strategies/ProofState.hs
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ data Prim
| Simplify
| CheckImplication
-- ^ Check if the claim's implication is valid.
| InferDefined
-- ^ Infer that the left-hand side of the claim is defined. This is related
-- to 'CheckImplication', but separated as an optimization.
| TriviallyValid
| ApplyClaims
| ApplyAxioms
Expand All @@ -52,9 +49,8 @@ instance Pretty Prim where
pretty CheckGoalRemainder = "Transition CheckGoalRemainder."
pretty CheckGoalStuck = "Transition CheckGoalStuck."
pretty ResetGoal = "Transition ResetGoal."
pretty Simplify = "Transition Simplify."
pretty Simplify = "simplify the claim"
pretty CheckImplication = "Transition CheckImplication."
pretty InferDefined = "infer left-hand side is defined"
pretty TriviallyValid = "Transition TriviallyValid."
pretty ApplyClaims = "apply claims"
pretty ApplyAxioms = "apply axioms"
Expand Down
2 changes: 0 additions & 2 deletions kore/src/Kore/Unification/UnifierT.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ License : NCSA

-}

{-# OPTIONS_GHC -fno-prof-auto #-}

module Kore.Unification.UnifierT
( UnifierT (..)
, runUnifierT
Expand Down
2 changes: 0 additions & 2 deletions kore/src/Prof.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ License : NCSA

-}

{-# OPTIONS_GHC -fno-prof-auto #-}

module Prof
( MonadProf (..)
, defaultTraceProf
Expand Down
2 changes: 0 additions & 2 deletions kore/src/SMT.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ License : NCSA
Maintainer : thomas.tuegel@runtimeverification.com
-}

{-# OPTIONS_GHC -fno-prof-auto #-}

module SMT
( SMT, getSMT
, Solver
Expand Down
Loading