Skip to content

Commit 8782a70

Browse files
committed
Revert "Validate function definitions (#2168)"
This reverts commit 39a42a5.
1 parent 412fa67 commit 8782a70

37 files changed

+1551
-2258
lines changed

Dockerfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ RUN curl -sSL https://github.com/github/hub/releases/download/v$HUB/hub-linux
2020
&& rm -fr hub-linux-amd64-$HUB
2121

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

2524
ARG USER_ID=1000
2625
ARG GROUP_ID=1000

kore/kore.cabal

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,6 @@ library
289289
Kore.Equation.Registry
290290
Kore.Equation.Sentence
291291
Kore.Equation.Simplification
292-
Kore.Equation.Validate
293292
Kore.Error
294293
Kore.Exec
295294
Kore.IndexedModule.Error

kore/src/Kore/ASTVerifier/SentenceVerifier.hs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ import Kore.ASTVerifier.PatternVerifier as PatternVerifier
4848
import Kore.ASTVerifier.SortVerifier
4949
import Kore.ASTVerifier.Verifier
5050
import qualified Kore.Attribute.Axiom as Attribute (
51-
Axiom (..),
51+
Axiom,
5252
parseAxiomAttributes,
5353
)
5454
import qualified Kore.Attribute.Hook as Attribute
@@ -68,11 +68,10 @@ import qualified Kore.Attribute.Sort.HasDomainValues as Attribute.HasDomainValue
6868
import qualified Kore.Attribute.Symbol as Attribute
6969
import qualified Kore.Attribute.Symbol as Attribute.Symbol
7070
import qualified Kore.Builtin as Builtin
71-
import Kore.Equation.Validate
7271
import Kore.Error
7372
import Kore.IndexedModule.IndexedModule
7473
import Kore.IndexedModule.Resolvers as Resolvers
75-
import qualified Kore.Internal.Symbol as Symbol
74+
import qualified Kore.Internal.Symbol as Internal.Symbol
7675
import Kore.Internal.TermLike.TermLike (
7776
freeVariables,
7877
)
@@ -357,7 +356,6 @@ verifyAxiomSentence sentence =
357356
verifiedModule'
358357
(freeVariables sentence)
359358
(sentenceAxiomAttributes sentence)
360-
validateAxiom attrs verified
361359
State.modify $ addAxiom verified attrs
362360
where
363361
addAxiom verified attrs =
@@ -485,7 +483,7 @@ parseAndVerifyAxiomAttributes ::
485483
IndexedModule Verified.Pattern Attribute.Symbol attrs ->
486484
FreeVariables VariableName ->
487485
Attributes ->
488-
error (Attribute.Axiom Symbol.Symbol VariableName)
486+
error (Attribute.Axiom Internal.Symbol.Symbol VariableName)
489487
parseAndVerifyAxiomAttributes indexModule freeVars attrs =
490488
parseAxiomAttributes' attrs >>= verifyAxiomAttributes indexModule
491489
where

kore/src/Kore/Equation/Registry.hs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import Kore.Attribute.Axiom (
2727
)
2828
import qualified Kore.Attribute.Axiom as Attribute
2929
import Kore.Attribute.Overload
30+
import qualified Kore.Attribute.Pattern as Pattern
3031
import Kore.Attribute.Symbol (
3132
StepperAttributes,
3233
)
@@ -49,6 +50,7 @@ import Kore.Syntax.Sentence (
4950
)
5051
import qualified Kore.Verified as Verified
5152
import Prelude.Kore
53+
import qualified Pretty
5254

5355
-- | Create a mapping from symbol identifiers to their defining axioms.
5456
extractEquations ::
@@ -110,10 +112,11 @@ partitionEquations equations =
110112
equations' =
111113
equations
112114
& filter (not . ignoreEquation)
113-
(simplificationRules, functionRules) =
115+
(simplificationRules, unProcessedFunctionRules) =
114116
partition Equation.isSimplificationRule
115117
. sortOn Equation.equationPriority
116118
$ equations'
119+
functionRules = filter (not . ignoreDefinition) unProcessedFunctionRules
117120

118121
{- | Should we ignore the 'EqualityRule' for evaluation or simplification?
119122
@@ -137,3 +140,17 @@ ignoreEquation Equation{attributes}
137140
Unit{isUnit} = Attribute.unit attributes
138141
Idem{isIdem} = Attribute.idem attributes
139142
Overload{getOverload} = Attribute.overload attributes
143+
144+
-- | Should we ignore the 'EqualityRule' for evaluating function definitions?
145+
ignoreDefinition :: Equation RewritingVariableName -> Bool
146+
ignoreDefinition Equation{attributes, left}
147+
| isLeftFunctionLike = False
148+
| otherwise =
149+
(error . show . Pretty.vsep)
150+
[ "left-hand side of equation was not function-like at:"
151+
, Pretty.indent 4 $ Pretty.pretty sourceLocation
152+
]
153+
where
154+
Attribute.Axiom{sourceLocation} = attributes
155+
isLeftFunctionLike =
156+
(Pattern.isFunction . Pattern.function) (extractAttributes left)

kore/src/Kore/Equation/Sentence.hs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,8 @@ import qualified Kore.Internal.TermLike as TermLike
3838
import Kore.Syntax.Sentence (
3939
SentenceAxiom (..),
4040
)
41-
import Kore.Unparser (
42-
unparse,
43-
)
4441
import qualified Kore.Verified as Verified
4542
import Prelude.Kore
46-
import Pretty
4743

4844
fromSentenceAxiom ::
4945
(Attribute.Axiom Symbol VariableName, Verified.SentenceAxiom) ->
@@ -64,16 +60,6 @@ data MatchEquationError variable
6460
deriving anyclass (SOP.Generic, SOP.HasDatatypeInfo)
6561
deriving anyclass (Debug)
6662

67-
instance InternalVariable variable => Pretty (MatchEquationError variable) where
68-
pretty (NotEquation term) = "The given term is not an equation:\n" <> unparse term
69-
pretty (RequiresError notPred) = "The equation's requires clause is not a predicate:\n" <> pretty notPred
70-
pretty (ArgumentError notPred) = "The equation's argument clause is not a predicate:\n" <> pretty notPred
71-
pretty (AntiLeftError notPred) = "The equation's anti-left clause is not a predicate:\n" <> pretty notPred
72-
pretty (EnsuresError notPred) = "The equation's ensures clause is not a predicate:\n" <> pretty notPred
73-
pretty FunctionalAxiom = "The term is a functional axiom"
74-
pretty ConstructorAxiom = "The term is a constructor axiom"
75-
pretty SubsortAxiom = "The term is a subsort axiom"
76-
7763
matchEquation ::
7864
forall variable.
7965
InternalVariable variable =>

kore/src/Kore/Equation/Validate.hs

Lines changed: 0 additions & 187 deletions
This file was deleted.

kore/src/Kore/Internal/Predicate.hs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1105,6 +1105,12 @@ hasFreeVariable ::
11051105
Bool
11061106
hasFreeVariable variableName = isFreeVariable variableName . freeVariables
11071107

1108+
{- | Traverse the predicate from the top down and apply substitutions.
1109+
1110+
The 'freeVariables' annotation is used to avoid traversing subterms that
1111+
contain none of the targeted variables.
1112+
-}
1113+
11081114
-- !! TODO The following is just a temporary solution and !!
11091115
-- !! the code using wrapPredicate should be refactored !!
11101116

@@ -1118,11 +1124,6 @@ wrapPredicate =
11181124
id
11191125
. makePredicate
11201126

1121-
{- | Traverse the predicate from the top down and apply substitutions.
1122-
1123-
The 'freeVariables' annotation is used to avoid traversing subterms that
1124-
contain none of the targeted variables.
1125-
-}
11261127
substitute ::
11271128
InternalVariable variable =>
11281129
Map (SomeVariableName variable) (TermLike variable) ->

kore/src/Kore/Internal/Symbol.hs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ module Kore.Internal.Symbol (
1414
isTotal,
1515
isInjective,
1616
isMemo,
17-
isAnywhere,
1817
noEvaluators,
1918
symbolHook,
2019
constructor,
@@ -171,9 +170,6 @@ isTotal = Attribute.isTotal . symbolAttributes
171170
isMemo :: Symbol -> Bool
172171
isMemo = Attribute.isMemo . Attribute.memo . symbolAttributes
173172

174-
isAnywhere :: Symbol -> Bool
175-
isAnywhere = Attribute.isAnywhere . Attribute.anywhere . symbolAttributes
176-
177173
noEvaluators :: Symbol -> Bool
178174
noEvaluators =
179175
Attribute.hasNoEvaluators . Attribute.noEvaluators . symbolAttributes

0 commit comments

Comments
 (0)