Skip to content

Fix uninterpreted functions in keys of Maps and Sets #2323

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

Merged
merged 19 commits into from
Feb 3, 2021
Merged
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
4 changes: 3 additions & 1 deletion kore/kore.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ cabal-version: 2.2
--
-- see: https://github.com/sol/hpack
--
-- hash: 3a3209955e7db4f112e2b2c2ab073b1d479448d68f21f84c4a14ce8f5f2293d9
-- hash: 1eb807e1a58c0a657f51fd08934c8a7e171988a07bcd9e0e4c098055595b6ac4

name: kore
version: 0.38.0.0
Expand Down Expand Up @@ -183,6 +183,7 @@ library
Kore.Internal.InternalMap
Kore.Internal.InternalSet
Kore.Internal.InternalString
Kore.Internal.Key
Kore.Internal.MultiAnd
Kore.Internal.MultiOr
Kore.Internal.NormalizedAc
Expand Down Expand Up @@ -962,6 +963,7 @@ test-suite kore-test
Test.Kore.IndexedModule.SortGraph
Test.Kore.Internal.ApplicationSorts
Test.Kore.Internal.Condition
Test.Kore.Internal.Key
Test.Kore.Internal.MultiAnd
Test.Kore.Internal.OrCondition
Test.Kore.Internal.OrPattern
Expand Down
3 changes: 0 additions & 3 deletions kore/src/Data/Sup.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ module Data.Sup

import Prelude.Kore

import Control.DeepSeq
( NFData
)
import Data.Data
( Data
)
Expand Down
14 changes: 14 additions & 0 deletions kore/src/From.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,13 @@ License : NCSA

module From
( From (..)
, into
) where

import Data.Sequence
( Seq
)
import qualified Data.Sequence as Seq
import Data.Void

{- | Convert type @from@ into @to@.
Expand Down Expand Up @@ -43,8 +48,17 @@ let b = let a :: A = _ in from @_ @B a
class From from to where
from :: from -> to

{- | @into@ is 'from' with the type parameters in reverse order.
-}
into :: forall to from. From from to => from -> to
into = from @from @to

{- | This instance implements the principle /ex falso quodlibet/.
-}
instance From Void any where
from = absurd
{-# INLINE from #-}

instance From [a] (Seq a) where
from = Seq.fromList
{-# INLINE from #-}
3 changes: 0 additions & 3 deletions kore/src/Kore/Attribute/Attributes.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ module Kore.Attribute.Attributes

import Prelude.Kore

import Control.DeepSeq
( NFData
)
import Data.Default
( Default (..)
)
Expand Down
3 changes: 0 additions & 3 deletions kore/src/Kore/Attribute/Axiom.hs
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ module Kore.Attribute.Axiom

import Prelude.Kore

import Control.DeepSeq
( NFData
)
import qualified Control.Lens as Lens
import qualified Control.Monad as Monad
import Data.Default
Expand Down
3 changes: 0 additions & 3 deletions kore/src/Kore/Attribute/Null.hs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ module Kore.Attribute.Null

import Prelude.Kore

import Control.DeepSeq
( NFData
)
import Data.Default
import qualified Generics.SOP as SOP
import qualified GHC.Generics as GHC
Expand Down
3 changes: 0 additions & 3 deletions kore/src/Kore/Attribute/Parser.hs
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,6 @@ module Kore.Attribute.Parser

import Prelude.Kore

import Control.DeepSeq
( NFData
)
import Control.Lens
( Getter
, Iso'
Expand Down
3 changes: 0 additions & 3 deletions kore/src/Kore/Attribute/Pattern.hs
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ module Kore.Attribute.Pattern

import Prelude.Kore

import Control.DeepSeq
( NFData
)
import qualified Control.Lens as Lens
import Data.Generics.Product
import qualified Generics.SOP as SOP
Expand Down
1 change: 0 additions & 1 deletion kore/src/Kore/Attribute/Pattern/ConstructorLike.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ module Kore.Attribute.Pattern.ConstructorLike

import Prelude.Kore

import Control.DeepSeq
import qualified Generics.SOP as SOP
import qualified GHC.Generics as GHC

Expand Down
1 change: 0 additions & 1 deletion kore/src/Kore/Attribute/Pattern/Created.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ module Kore.Attribute.Pattern.Created

import Prelude.Kore

import Control.DeepSeq
import qualified Generics.SOP as SOP
import qualified GHC.Generics as GHC
import GHC.Stack
Expand Down
1 change: 0 additions & 1 deletion kore/src/Kore/Attribute/Pattern/Defined.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ module Kore.Attribute.Pattern.Defined

import Prelude.Kore

import Control.DeepSeq
import Data.Functor.Const
import Data.Monoid
import qualified Generics.SOP as SOP
Expand Down
1 change: 0 additions & 1 deletion kore/src/Kore/Attribute/Pattern/FreeVariables.hs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import Prelude.Kore hiding
( toList
)

import Control.DeepSeq
import Data.Functor.Const
import Data.Map.Strict
( Map
Expand Down
1 change: 0 additions & 1 deletion kore/src/Kore/Attribute/Pattern/Function.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ module Kore.Attribute.Pattern.Function

import Prelude.Kore

import Control.DeepSeq
import Data.Functor.Const
import Data.Monoid
import qualified Generics.SOP as SOP
Expand Down
1 change: 0 additions & 1 deletion kore/src/Kore/Attribute/Pattern/Functional.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ module Kore.Attribute.Pattern.Functional

import Prelude.Kore

import Control.DeepSeq
import Data.Functor.Const
import Data.Monoid
import qualified Generics.SOP as SOP
Expand Down
1 change: 0 additions & 1 deletion kore/src/Kore/Attribute/Pattern/Simplified.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ module Kore.Attribute.Pattern.Simplified

import Prelude.Kore

import Control.DeepSeq
import Data.Text
( Text
)
Expand Down
3 changes: 0 additions & 3 deletions kore/src/Kore/Attribute/PredicatePattern.hs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ module Kore.Attribute.PredicatePattern

import Prelude.Kore

import Control.DeepSeq
( NFData
)
import qualified Control.Lens as Lens
import Data.Generics.Product
import qualified Generics.SOP as SOP
Expand Down
3 changes: 0 additions & 3 deletions kore/src/Kore/Attribute/RuleIndex.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ module Kore.Attribute.RuleIndex

import Prelude.Kore

import Control.DeepSeq
( NFData
)
import Data.Default
import qualified Generics.SOP as SOP
import qualified GHC.Generics as GHC
Expand Down
3 changes: 0 additions & 3 deletions kore/src/Kore/Attribute/Smtlib/Smtlib.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ module Kore.Attribute.Smtlib.Smtlib

import Prelude.Kore

import Control.DeepSeq
( NFData
)
import Data.Default
( Default (..)
)
Expand Down
3 changes: 0 additions & 3 deletions kore/src/Kore/Attribute/SourceLocation.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ module Kore.Attribute.SourceLocation

import Prelude.Kore

import Control.DeepSeq
( NFData
)
import Control.Monad
( (>=>)
)
Expand Down
3 changes: 0 additions & 3 deletions kore/src/Kore/Attribute/Symbol.hs
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,6 @@ module Kore.Attribute.Symbol

import Prelude.Kore

import Control.DeepSeq
( NFData
)
import qualified Control.Lens as Lens
import Control.Monad
( (>=>)
Expand Down
20 changes: 10 additions & 10 deletions kore/src/Kore/Builtin/AssocComm/CeilSimplifier.hs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import Kore.Attribute.Pattern.FreeVariables
( FreeVariables
)
import qualified Kore.Attribute.Pattern.FreeVariables as FreeVariables
import qualified Kore.Builtin.Builtin as Builtin
import Kore.Internal.InternalMap
import Kore.Internal.InternalSet
import Kore.Internal.MultiAnd
Expand All @@ -54,12 +53,13 @@ import Kore.Internal.SideCondition
)
import Kore.Internal.TermLike
( Ceil (..)
, Concrete
, ElementVariable
, InternalVariable
, Key
, TermLike
, fromVariableName
, generatedId
, retractKey
, termLikeSort
)
import qualified Kore.Internal.TermLike as TermLike
Expand All @@ -76,7 +76,7 @@ import Kore.Variables.Fresh
)

type BuiltinAssocComm normalized variable =
InternalAc (TermLike Concrete) normalized (TermLike variable)
InternalAc Key normalized (TermLike variable)

type MkBuiltinAssocComm normalized variable =
BuiltinAssocComm normalized variable -> TermLike variable
Expand Down Expand Up @@ -188,7 +188,8 @@ newBuiltinAssocCommCeilSimplifier mkBuiltin mkNotMember =
CeilSimplifier $ \Ceil { ceilChild } -> do
let internalAc@InternalAc { builtinAcChild } = ceilChild
sideCondition <- Reader.ask
let normalizedAc = unwrapAc builtinAcChild
let normalizedAc :: NormalizedAc normalized Key (TermLike variable)
normalizedAc = unwrapAc builtinAcChild
NormalizedAc
{ elementsWithVariables = abstractElements
, concreteElements
Expand Down Expand Up @@ -234,7 +235,7 @@ newBuiltinAssocCommCeilSimplifier mkBuiltin mkNotMember =
:: [Value normalized (TermLike variable)]
(abstractKeys, abstractValues) =
unzip (unwrapElement <$> abstractElements)
concreteKeys = TermLike.fromConcrete <$> Map.keys concreteElements
concreteKeys = from @Key <$> Map.keys concreteElements
concreteValues = Map.elems concreteElements
allValues = concreteValues <> abstractValues

Expand Down Expand Up @@ -310,7 +311,7 @@ newBuiltinAssocCommCeilSimplifier mkBuiltin mkNotMember =
& MultiAnd.singleton

notMembers
:: NormalizedAc normalized (TermLike Concrete) (TermLike variable)
:: NormalizedAc normalized Key (TermLike variable)
-> TermLike variable
-> MultiAnd (OrCondition variable)
notMembers normalizedAc termLike =
Expand All @@ -320,7 +321,7 @@ foldElements
:: AcWrapper collection
=> InternalVariable variable
=> Lens.Fold
(NormalizedAc collection (TermLike Concrete) (TermLike variable))
(NormalizedAc collection Key (TermLike variable))
(Element collection (TermLike variable))
foldElements =
Lens.folding $ \normalizedAc ->
Expand All @@ -335,11 +336,10 @@ foldElements =

fromElement
:: AcWrapper normalized
=> InternalVariable variable
=> Element normalized (TermLike variable)
-> NormalizedAc normalized (TermLike Concrete) (TermLike variable)
-> NormalizedAc normalized Key (TermLike variable)
fromElement element
| Just concreteKey <- Builtin.toKey symbolicKey
| Just concreteKey <- retractKey symbolicKey
= emptyNormalizedAc { concreteElements = Map.singleton concreteKey value }
| otherwise
= emptyNormalizedAc { elementsWithVariables = [element] }
Expand Down
Loading