Skip to content

Revert function validation #2582

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 6 commits into from
Apr 29, 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
1 change: 0 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ RUN curl -sSL https://github.com/github/hub/releases/download/v$HUB/hub-linux
&& rm -fr hub-linux-amd64-$HUB

ENV LC_ALL=C.UTF-8
ADD ./src/main/kore/prelude.kore /usr/include/kframework/kore/prelude.kore

ARG USER_ID=1000
ARG GROUP_ID=1000
Expand Down
1 change: 0 additions & 1 deletion kore/kore.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,6 @@ library
Kore.Equation.Registry
Kore.Equation.Sentence
Kore.Equation.Simplification
Kore.Equation.Validate
Kore.Error
Kore.Exec
Kore.IndexedModule.Error
Expand Down
6 changes: 2 additions & 4 deletions kore/src/Kore/ASTVerifier/SentenceVerifier.hs
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,10 @@ import qualified Kore.Attribute.Sort.HasDomainValues as Attribute.HasDomainValue
import qualified Kore.Attribute.Symbol as Attribute
import qualified Kore.Attribute.Symbol as Attribute.Symbol
import qualified Kore.Builtin as Builtin
import Kore.Equation.Validate
import Kore.Error
import Kore.IndexedModule.IndexedModule
import Kore.IndexedModule.Resolvers as Resolvers
import qualified Kore.Internal.Symbol as Symbol
import qualified Kore.Internal.Symbol as Internal.Symbol
import Kore.Internal.TermLike.TermLike (
freeVariables,
)
Expand Down Expand Up @@ -357,7 +356,6 @@ verifyAxiomSentence sentence =
verifiedModule'
(freeVariables sentence)
(sentenceAxiomAttributes sentence)
validateAxiom attrs verified
State.modify $ addAxiom verified attrs
where
addAxiom verified attrs =
Expand Down Expand Up @@ -485,7 +483,7 @@ parseAndVerifyAxiomAttributes ::
IndexedModule Verified.Pattern Attribute.Symbol attrs ->
FreeVariables VariableName ->
Attributes ->
error (Attribute.Axiom Symbol.Symbol VariableName)
error (Attribute.Axiom Internal.Symbol.Symbol VariableName)
parseAndVerifyAxiomAttributes indexModule freeVars attrs =
parseAxiomAttributes' attrs >>= verifyAxiomAttributes indexModule
where
Expand Down
19 changes: 18 additions & 1 deletion kore/src/Kore/Equation/Registry.hs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import Kore.Attribute.Axiom (
)
import qualified Kore.Attribute.Axiom as Attribute
import Kore.Attribute.Overload
import qualified Kore.Attribute.Pattern as Pattern
import Kore.Attribute.Symbol (
StepperAttributes,
)
Expand All @@ -49,6 +50,7 @@ import Kore.Syntax.Sentence (
)
import qualified Kore.Verified as Verified
import Prelude.Kore
import qualified Pretty

-- | Create a mapping from symbol identifiers to their defining axioms.
extractEquations ::
Expand Down Expand Up @@ -110,10 +112,11 @@ partitionEquations equations =
equations' =
equations
& filter (not . ignoreEquation)
(simplificationRules, functionRules) =
(simplificationRules, unProcessedFunctionRules) =
partition Equation.isSimplificationRule
. sortOn Equation.equationPriority
$ equations'
functionRules = filter (not . ignoreDefinition) unProcessedFunctionRules

{- | Should we ignore the 'EqualityRule' for evaluation or simplification?

Expand All @@ -137,3 +140,17 @@ ignoreEquation Equation{attributes}
Unit{isUnit} = Attribute.unit attributes
Idem{isIdem} = Attribute.idem attributes
Overload{getOverload} = Attribute.overload attributes

-- | Should we ignore the 'EqualityRule' for evaluating function definitions?
ignoreDefinition :: Equation RewritingVariableName -> Bool
ignoreDefinition Equation{attributes, left}
| isLeftFunctionLike = False
| otherwise =
(error . show . Pretty.vsep)
[ "left-hand side of equation was not function-like at:"
, Pretty.indent 4 $ Pretty.pretty sourceLocation
]
where
Attribute.Axiom{sourceLocation} = attributes
isLeftFunctionLike =
(Pattern.isFunction . Pattern.function) (extractAttributes left)
38 changes: 0 additions & 38 deletions kore/src/Kore/Equation/Sentence.hs
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,8 @@ import qualified Kore.Internal.TermLike as TermLike
import Kore.Syntax.Sentence (
SentenceAxiom (..),
)
import Kore.Unparser (
unparse,
)
import qualified Kore.Verified as Verified
import Prelude.Kore
import Pretty

fromSentenceAxiom ::
(Attribute.Axiom Symbol VariableName, Verified.SentenceAxiom) ->
Expand All @@ -64,40 +60,6 @@ data MatchEquationError variable
deriving anyclass (SOP.Generic, SOP.HasDatatypeInfo)
deriving anyclass (Debug)

instance InternalVariable variable => Pretty (MatchEquationError variable) where
pretty (NotEquation term) =
Pretty.vsep
[ "The given term is not an equation:"
, unparse term
]
pretty (RequiresError notPred) =
Pretty.vsep
[ "The equation's requires clause is not a predicate:"
, pretty notPred
, "This is a frontend bug. Please report this error at https://github.com/kframework/k/issues."
]
pretty (ArgumentError notPred) =
Pretty.vsep
[ "The equation's argument clause is not a predicate:"
, pretty notPred
, "This is a frontend bug. Please report this error at https://github.com/kframework/k/issues."
]
pretty (AntiLeftError notPred) =
Pretty.vsep
[ "The equation's anti-left clause is not a predicate:"
, pretty notPred
, "This is a frontend bug. Please report this error at https://github.com/kframework/k/issues."
]
pretty (EnsuresError notPred) =
Pretty.vsep
[ "The equation's ensures clause is not a predicate:"
, pretty notPred
, "This is a frontend bug. Please report this error at https://github.com/kframework/k/issues."
]
pretty FunctionalAxiom = "The term is a functional axiom."
pretty ConstructorAxiom = "The term is a constructor axiom."
pretty SubsortAxiom = "The term is a subsort axiom."

matchEquation ::
forall variable.
InternalVariable variable =>
Expand Down
188 changes: 0 additions & 188 deletions kore/src/Kore/Equation/Validate.hs

This file was deleted.

11 changes: 6 additions & 5 deletions kore/src/Kore/Internal/Predicate.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1105,6 +1105,12 @@ hasFreeVariable ::
Bool
hasFreeVariable variableName = isFreeVariable variableName . freeVariables

{- | Traverse the predicate from the top down and apply substitutions.

The 'freeVariables' annotation is used to avoid traversing subterms that
contain none of the targeted variables.
-}

-- !! TODO The following is just a temporary solution and !!
-- !! the code using wrapPredicate should be refactored !!

Expand All @@ -1118,11 +1124,6 @@ wrapPredicate =
id
. makePredicate

{- | Traverse the predicate from the top down and apply substitutions.

The 'freeVariables' annotation is used to avoid traversing subterms that
contain none of the targeted variables.
-}
substitute ::
InternalVariable variable =>
Map (SomeVariableName variable) (TermLike variable) ->
Expand Down
4 changes: 0 additions & 4 deletions kore/src/Kore/Internal/Symbol.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ module Kore.Internal.Symbol (
isTotal,
isInjective,
isMemo,
isAnywhere,
noEvaluators,
symbolHook,
constructor,
Expand Down Expand Up @@ -171,9 +170,6 @@ isTotal = Attribute.isTotal . symbolAttributes
isMemo :: Symbol -> Bool
isMemo = Attribute.isMemo . Attribute.memo . symbolAttributes

isAnywhere :: Symbol -> Bool
isAnywhere = Attribute.isAnywhere . Attribute.anywhere . symbolAttributes

noEvaluators :: Symbol -> Bool
noEvaluators =
Attribute.hasNoEvaluators . Attribute.noEvaluators . symbolAttributes
Expand Down
Loading