Skip to content

Remove SymbolOrAliasSorts #392

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
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
98a7dd5
SmartConstructors: Make predicateSort unrepresentable in Kore
ttuegel Dec 11, 2018
7bcaaf6
Kore.AST.Pure: Add eraseAnnotations
ttuegel Dec 11, 2018
49a2f45
Kore.AST.Pure: Generalize type of asConcretePurePattern
ttuegel Dec 11, 2018
e7d30bc
Sentence: Add instances Functor, Foldable, and Traversable
ttuegel Dec 12, 2018
3c884eb
Sentence: Add VerifiedKoreModule and VerifiedKoreDefinition
ttuegel Dec 12, 2018
8218da5
Sentence: Add eraseSentenceAnnotations
ttuegel Dec 12, 2018
69244cc
AxiomPatterns: Remove syntactically-invalid test
ttuegel Dec 12, 2018
a0bad3f
Kore.Unparser: Export helpers
ttuegel Dec 19, 2018
3bc798f
Kore.Sort: Add substituteSortVariables
ttuegel Dec 13, 2018
18fb43e
Add module Kore.AST.Valid
ttuegel Dec 12, 2018
7c3a98c
OrOfExpandedPattern: Rename extract to getMultiOr
ttuegel Dec 13, 2018
c38d29b
Kore.AST.Pure: Re-export Control.Comonad
ttuegel Dec 13, 2018
3f8c557
Kore.AST.Sentence: Add VerifiedPureSentence
ttuegel Dec 13, 2018
f6748f5
Test.Kore.Comparators: Add instances for Valid
ttuegel Dec 13, 2018
58bc4ad
testSymbolWithSolver: Add constraint HasCallStack
ttuegel Dec 14, 2018
8d4b0ee
Remove SymbolOrAliasSorts
ttuegel Dec 13, 2018
cc7a830
translatePredicate: Always attempt to translate builtin equality
ttuegel Dec 17, 2018
80a751d
Kore.Predicate.Predicate: Add instance Unparse GenericPredicate
ttuegel Dec 17, 2018
293668b
MockMetadataTools: Add HasCallStack constraints
ttuegel Dec 18, 2018
1736dc8
Fully specify instances Recursive, Corecursive
ttuegel Dec 18, 2018
22ac134
Kore.Step.ExpandedPattern: Add bottomOf and topOf
ttuegel Dec 21, 2018
d5949b1
Kore.AST.Valid: Add mkSortVariable
ttuegel Dec 21, 2018
2de5854
kore-exec: Output a properly-sorted pattern
ttuegel Dec 21, 2018
4700c69
TODO: Preserve pattern sorts in the simplifier
ttuegel Dec 20, 2018
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
30 changes: 9 additions & 21 deletions src/main/haskell/kore/app/exec/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ import Data.Maybe
( fromMaybe )
import Data.Proxy
( Proxy (..) )
import Data.Reflection
( give )
import Data.Semigroup
( (<>) )
import qualified Data.Set as Set
Expand All @@ -35,13 +33,12 @@ import System.IO
import Data.Limit
( Limit (..) )
import Kore.AST.Kore
( CommonKorePattern )
( CommonKorePattern, VerifiedKorePattern )
import Kore.AST.Pure
import Kore.AST.PureToKore
( patternKoreToPure )
import Kore.AST.Sentence
import qualified Kore.ASTUtils.SmartConstructors as Pattern
import Kore.ASTUtils.SmartPatterns
import Kore.AST.Valid
import Kore.ASTVerifier.DefinitionVerifier
( AttributesVerification (DoNotVerifyAttributes),
defaultAttributesVerification,
Expand All @@ -52,8 +49,6 @@ import Kore.Error
import Kore.Exec
import Kore.IndexedModule.IndexedModule
( IndexedModule (..), VerifiedModule )
import Kore.IndexedModule.MetadataTools
( MetadataTools (..), extractMetadataTools )
import Kore.Parser.Parser
( fromKore, fromKorePattern )
import Kore.Predicate.Predicate
Expand Down Expand Up @@ -341,7 +336,7 @@ externalizeFreshVars pat = Recursive.fold renameFreshLocal pat
-> CommonStepPattern level
renameFreshLocal (_ :< VariablePattern v@(Variable {variableName}))
| name `Set.member` freshVarsIds =
Var_ v {
mkVar v {
variableName = variableName
{ getId =
freshPrefix <> Text.filter (/= '_') name
Expand Down Expand Up @@ -451,7 +446,7 @@ mainWithOptions
Just specIndexedModule ->
either
(\pat -> (ExitFailure 1, pat))
(\_ -> (ExitSuccess, Pattern.mkTop))
(\_ -> (ExitSuccess, mkTop $ mkSortVariable "R" ))
<$> prove
stepLimit
indexedModule
Expand Down Expand Up @@ -502,30 +497,23 @@ mainPatternParseAndVerify
:: VerifiedModule StepperAttributes
-> String
-> IO (CommonStepPattern Object)
mainPatternParseAndVerify indexedModule patternFileName
= do
mainPatternParseAndVerify indexedModule patternFileName = do
parsedPattern <- mainPatternParse patternFileName
mainPatternVerify indexedModule parsedPattern
return (makePurePattern parsedPattern)
makePurePattern <$> mainPatternVerify indexedModule parsedPattern

mainParseSearchPattern
:: VerifiedModule StepperAttributes
-> String
-> IO (CommonExpandedPattern Object)
mainParseSearchPattern indexedModule patternFileName
= do
let
metadataTools :: MetadataTools Object StepperAttributes
metadataTools = extractMetadataTools indexedModule
MetadataTools { symbolOrAliasSorts } = metadataTools
mainParseSearchPattern indexedModule patternFileName = do
purePattern <- mainPatternParseAndVerify indexedModule patternFileName
case purePattern of
And_ _ term predicateTerm -> return
Predicated
{ term
, predicate =
either (error . printError) id
(give symbolOrAliasSorts makePredicate predicateTerm)
(makePredicate predicateTerm)
, substitution = mempty
}
_ -> error "Unexpected non-conjunctive pattern"
Expand Down Expand Up @@ -581,7 +569,7 @@ verifyDefinitionWithBase maybeBaseModule willChkAttr definition =
Right indexedDefinition -> return indexedDefinition

makePurePattern
:: CommonKorePattern
:: VerifiedKorePattern
-> CommonStepPattern Object
makePurePattern pat =
case patternKoreToPure Object pat of
Expand Down
3 changes: 2 additions & 1 deletion src/main/haskell/kore/app/parser/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ main = do
when willVerify $ do
indexedModule <-
mainModule (ModuleName mainModuleName) indexedModules
mainPatternVerify indexedModule parsedPattern
_ <- mainPatternVerify indexedModule parsedPattern
return ()
when willPrintPattern $
putStrLn (prettyPrintToString parsedPattern)

Expand Down
11 changes: 4 additions & 7 deletions src/main/haskell/kore/app/share/GlobalMain.hs
Original file line number Diff line number Diff line change
Expand Up @@ -178,15 +178,12 @@ mainPatternVerify
:: VerifiedModule attrs
-- ^ Module containing definitions visible in the pattern
-> CommonKorePattern -- ^ Parsed pattern to check well-formedness
-> IO ()
mainPatternVerify verifiedModule patt =
do
verifyResult <-
-> IO VerifiedKorePattern
mainPatternVerify verifiedModule patt = do
verifyResult <-
clockSomething "Verifying the pattern"
(runPatternVerifier context $ verifyStandalonePattern Nothing patt)
case verifyResult of
Left err1 -> error (printError err1)
Right _ -> return ()
either (error . printError) return verifyResult
where
Builtin.Verifiers { patternVerifier } = Builtin.koreVerifiers
indexedModule =
Expand Down
28 changes: 26 additions & 2 deletions src/main/haskell/kore/bench/exec/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import Data.Function
import Data.Limit
( Limit (Unlimited) )
import qualified Data.Map as Map
import qualified Data.Set as Set

import qualified Kore.AST.Kore as Kore
import Kore.AST.Pure
import Kore.AST.PureToKore
( patternKoreToPure )
Expand All @@ -17,12 +19,15 @@ import Kore.AST.Sentence
import Kore.ASTVerifier.DefinitionVerifier
( AttributesVerification (DoNotVerifyAttributes),
verifyAndIndexDefinition )
import qualified Kore.ASTVerifier.PatternVerifier as PatternVerifier
import qualified Kore.Attribute.Null as Attribute
import qualified Kore.Builtin as Builtin
import Kore.Error
( printError )
import Kore.Exec
import Kore.IndexedModule.IndexedModule
( IndexedModule (..), VerifiedModule )
( IndexedModule (..), VerifiedModule,
mapIndexedModulePatterns )
import Kore.Parser.Parser
( fromKore, fromKorePattern )
import Kore.Step.Pattern
Expand Down Expand Up @@ -125,6 +130,7 @@ execBenchmark root kFile definitionFile mainModuleName test =
envWithCleanup setUp cleanUp $ bench name . nfIO . execution
where
name = takeFileName test
setUp :: IO (VerifiedModule StepperAttributes, CommonStepPattern Object)
setUp = do
kompile
definition <- readFile $ root </> definitionFile
Expand All @@ -139,12 +145,30 @@ execBenchmark root kFile definitionFile mainModuleName test =
Just verifiedModule =
fmap constructorFunctions
$ Map.lookup mainModuleName verifiedModules
indexedModule =
mapIndexedModulePatterns
Kore.eraseAnnotations
verifiedModule
pat <- parseProgram
let
parsedPattern = either error id $ fromKorePattern "" pat
verifiedPattern =
either (error . printError) id
$ PatternVerifier.runPatternVerifier context
$ PatternVerifier.verifyStandalonePattern Nothing parsedPattern
where
context =
PatternVerifier.Context
{ builtinPatternVerifier =
Builtin.patternVerifier Builtin.koreVerifiers
, indexedModule = Attribute.Null <$ indexedModule
, declaredSortVariables = Set.empty
, declaredVariables =
PatternVerifier.emptyDeclaredVariables
}
purePattern =
either (error . printError) id
$ patternKoreToPure Object parsedPattern
$ patternKoreToPure Object verifiedPattern
return (verifiedModule, purePattern)
execution
:: (VerifiedModule StepperAttributes, CommonStepPattern Object)
Expand Down
43 changes: 19 additions & 24 deletions src/main/haskell/kore/src/Kore/AST/Builders.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ module Kore.AST.Builders
, bottom_ -- TODO: not used yet
, ceilS_ -- TODO: not used yet
, ceil_ -- TODO: not used yet
, parameterizedDomainValue_
, equalsAxiom_
, equalsS_
, equals_
Expand Down Expand Up @@ -45,6 +44,7 @@ module Kore.AST.Builders

import Control.Comonad.Trans.Cofree
( CofreeF (..) )
import Data.Functor.Classes
import Data.Proxy
( Proxy (..) )
import Data.Text
Expand All @@ -56,7 +56,6 @@ import Kore.AST.BuildersImpl
import Kore.AST.Pure
import Kore.AST.Sentence
import Kore.ASTHelpers
import qualified Kore.Domain.Builtin as Domain
import Kore.Error

{-|'sortParameter' defines a sort parameter that can be used in declarations.
Expand All @@ -78,6 +77,7 @@ applyPS
:: ( Functor domain
, SentenceSymbolOrAlias s
, Show level
, Show1 domain
, Show (Pattern level domain Variable child)
, child ~ CommonPurePattern level domain
)
Expand Down Expand Up @@ -113,6 +113,7 @@ applyS
:: ( Functor domain
, SentenceSymbolOrAlias s
, Show level
, Show1 domain
, Show (Pattern level domain Variable child)
, child ~ CommonPurePattern level domain
)
Expand Down Expand Up @@ -202,7 +203,7 @@ alias_
-> Sort level
-> [Variable level]
-- ^ The left-hand side of the alias: the alias applied to these variables
-> CommonPurePattern level domain
-> PurePattern level domain Variable (Annotation.Null level)
-- ^ The right-hand side of the alias
-> PureSentenceAlias level domain
alias_ name location = parameterizedAlias_ name location []
Expand All @@ -217,7 +218,7 @@ parameterizedAlias_
-> Sort level
-> [Variable level]
-- ^ The left-hand side of the alias: the alias applied to these variables
-> CommonPurePattern level domain
-> PurePattern level domain Variable (Annotation.Null level)
-- ^ The right-hand side of the alias
-> PureSentenceAlias level domain
parameterizedAlias_
Expand Down Expand Up @@ -270,6 +271,7 @@ equalsS_
:: ( Functor domain
, MetaOrObject level
, Show (CommonPurePattern level domain)
, Show1 domain
)
=> Sort level
-> CommonPurePatternStub level domain
Expand All @@ -283,6 +285,7 @@ equals_
:: ( Functor domain
, MetaOrObject level
, Show (CommonPurePattern level domain)
, Show1 domain
)
=> CommonPurePatternStub level domain
-> CommonPurePatternStub level domain
Expand All @@ -295,6 +298,7 @@ inS_
:: ( Functor domain
, MetaOrObject level
, Show (CommonPurePattern level domain)
, Show1 domain
)
=> Sort level
-> CommonPurePatternStub level domain
Expand All @@ -308,6 +312,7 @@ in_
:: ( Functor domain
, MetaOrObject level
, Show (CommonPurePattern level domain)
, Show1 domain
)
=> CommonPurePatternStub level domain
-> CommonPurePatternStub level domain
Expand All @@ -322,6 +327,7 @@ ceilS_
, child ~ CommonPurePattern level domain
, Show child
, Show (Pattern level domain Variable child)
, Show1 domain
)
=> Sort level
-> CommonPurePatternStub level domain
Expand All @@ -336,6 +342,7 @@ ceil_
, child ~ CommonPurePattern level domain
, Show child
, Show (Pattern level domain Variable child)
, Show1 domain
)
=> CommonPurePatternStub level domain
-> CommonPurePatternStub level domain
Expand All @@ -349,6 +356,7 @@ floorS_
, child ~ CommonPurePattern level domain
, Show child
, Show (Pattern level domain Variable child)
, Show1 domain
)
=> Sort level
-> CommonPurePatternStub level domain
Expand All @@ -363,6 +371,7 @@ floor_
, child ~ CommonPurePattern level domain
, Show child
, Show (Pattern level domain Variable child)
, Show1 domain
)
=> CommonPurePatternStub level domain
-> CommonPurePatternStub level domain
Expand Down Expand Up @@ -500,25 +509,6 @@ next_ =
}
)

-- |Builds a 'PatternStub' representing 'DomainValue' given a 'Sort' and
-- a'String' for its operand.
parameterizedDomainValue_
:: Sort Object
-> String
-> CommonPurePatternStub Object Domain.Builtin
parameterizedDomainValue_ sort str =
SortedPatternStub
SortedPattern
{ sortedPatternSort = sort
, sortedPatternPattern =
DomainValuePattern DomainValue
{ domainValueSort = sort
, domainValueChild =
(Domain.BuiltinPattern . asPurePattern . (mempty :<))
(StringLiteralPattern $ StringLiteral str)
}
}

-- |Builds a 'PatternStub' representing 'Rewrites' given 'PatternStub's for its
-- operands.
rewrites_
Expand Down Expand Up @@ -546,6 +536,7 @@ parameterizedAxiom_
, child ~ CommonPurePattern level domain
, Show child
, Show (Pattern level domain Variable child)
, Show1 domain
)
=> [SortVariable level]
-> CommonPurePatternStub level domain
Expand All @@ -564,9 +555,10 @@ parameterizedAxiom_
SentenceAxiom
{ sentenceAxiomParameters = parameters
, sentenceAxiomPattern =
quantifyFreeVariables s (asPurePattern $ Annotation.Null :< p)
quantifyFreeVariables s (asPurePattern $ mempty :< p)
, sentenceAxiomAttributes = Attributes []
}

{-|Creates an axiom with no sort parameters from a pattern.
-}
axiom_
Expand All @@ -575,6 +567,7 @@ axiom_
, MetaOrObject level
, child ~ CommonPurePattern level domain
, Show child
, Show1 domain
, Show (Pattern level domain Variable child)
)
=> CommonPurePatternStub level domain
Expand All @@ -594,6 +587,7 @@ parameterizedEqualsAxiom_
, MetaOrObject level
, child ~ CommonPurePattern level domain
, Show child
, Show1 domain
, Show (Pattern level domain Variable child)
)
=> [SortVariable level]
Expand All @@ -618,6 +612,7 @@ equalsAxiom_
, MetaOrObject level
, child ~ CommonPurePattern level domain
, Show child
, Show1 domain
, Show (Pattern level domain Variable child)
)
=> SortVariable level
Expand Down
Loading