Skip to content

Commit a43ce1e

Browse files
authored
Equality axiom sorts (#494)
* Kore.Step.AxiomPatterns: Fix generated axiom sorts * Rename Kore.Step.AxiomPatterns.mkFunctionAxiom to mkRewriteAxiom
1 parent 2478e62 commit a43ce1e

File tree

1 file changed

+23
-14
lines changed

1 file changed

+23
-14
lines changed

kore/src/Kore/Step/AxiomPatterns.hs

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ module Kore.Step.AxiomPatterns
2020
, extractRewriteAxioms
2121
, extractRewriteClaims
2222
, mkRewriteAxiom
23-
, mkFunctionAxiom
23+
, mkEqualityAxiom
2424
, refreshRulePattern
2525
, freeVariables
2626
, Kore.Step.AxiomPatterns.mapVariables
@@ -253,37 +253,46 @@ patternToAxiomPattern attributes pat =
253253
Forall_ _ _ child -> patternToAxiomPattern attributes child
254254
_ -> koreFail "Unsupported pattern type in axiom"
255255

256-
{- | Construct a 'VerifiedKoreSentence' corresponding to 'RewriteAxiomPattern'.
256+
{- | Construct a 'VerifiedKoreSentence' corresponding to 'RewriteRule'.
257+
258+
The requires clause must be a predicate, i.e. it can occur in any sort.
259+
257260
-}
258261
mkRewriteAxiom
259262
:: CommonStepPattern Object -- ^ left-hand side
260263
-> CommonStepPattern Object -- ^ right-hand side
261-
-> Maybe (CommonStepPattern Object) -- ^ requires clause
264+
-> Maybe (Sort Object -> CommonStepPattern Object) -- ^ requires clause
262265
-> VerifiedKoreSentence
263266
mkRewriteAxiom lhs rhs requires =
264267
(asKoreAxiomSentence . toKoreSentenceAxiom . mkAxiom_)
265268
(mkRewrites
266-
(mkAnd (fromMaybe mkTop_ requires) lhs)
267-
(mkAnd mkTop_ rhs)
269+
(mkAnd (fromMaybe mkTop requires $ patternSort) lhs)
270+
(mkAnd (mkTop patternSort) rhs)
268271
)
272+
where
273+
Valid { patternSort } = extract lhs
274+
275+
{- | Construct a 'VerifiedKoreSentence' corresponding to 'EqualityRule'.
276+
277+
The requires clause must be a predicate, i.e. it can occur in any sort.
269278
270-
{- | Construct a 'VerifiedKoreSentence' corresponding to 'FunctionAxiomPattern'.
271279
-}
272-
-- TODO(virgil): Rename the above since it applies to all sorts of axioms,
273-
-- not only to function-related ones.
274-
mkFunctionAxiom
280+
mkEqualityAxiom
275281
:: CommonStepPattern Object -- ^ left-hand side
276282
-> CommonStepPattern Object -- ^ right-hand side
277-
-> Maybe (CommonStepPattern Object) -- ^ requires clause
283+
-> Maybe (Sort Object -> CommonStepPattern Object) -- ^ requires clause
278284
-> VerifiedKoreSentence
279-
mkFunctionAxiom lhs rhs requires =
280-
(asKoreAxiomSentence . toKoreSentenceAxiom . mkAxiom_)
285+
mkEqualityAxiom lhs rhs requires =
286+
(asKoreAxiomSentence . toKoreSentenceAxiom . mkAxiom [sortVariableR])
281287
(case requires of
282-
Just requires' -> mkImplies requires' (mkAnd function mkTop_)
288+
Just requires' ->
289+
mkImplies (requires' sortR) (mkAnd function mkTop_)
283290
Nothing -> function
284291
)
285292
where
286-
function = mkEquals_ lhs rhs
293+
sortVariableR = SortVariable "R"
294+
sortR = SortVariableSort sortVariableR
295+
function = mkEquals sortR lhs rhs
287296

288297
{- | Refresh the variables of a 'RulePattern'.
289298

0 commit comments

Comments
 (0)