Skip to content

Commit 53309ed

Browse files
ana-pantiliegithub-actions
andauthored
Extract axioms from spec module and add to definition (#2938)
* Extract axioms from spec module and add to definition * Move implementation at the very top level * Format with fourmolu * Implement for kore-repl as well * Format with fourmolu * Add documentation * Format with fourmolu * Retrigger build * Materialize Nix expressions * Review: add suggestion Co-authored-by: github-actions <[email protected]>
1 parent dd3d4d9 commit 53309ed

File tree

5 files changed

+35
-7
lines changed

5 files changed

+35
-7
lines changed

kore/app/exec/Main.hs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -688,18 +688,19 @@ koreProve execOptions proveOptions = do
688688
mainModule <- loadModule mainModuleName definition
689689
let KoreProveOptions{specMainModule} = proveOptions
690690
specModule <- loadModule specMainModule definition
691+
let mainModule' = addExtraAxioms mainModule specModule
691692
let KoreProveOptions{saveProofs} = proveOptions
692693
maybeAlreadyProvenModule <- loadProven definitionFileName saveProofs
693694
let KoreExecOptions{maxCounterexamples} = execOptions
694-
proveResult <- execute execOptions mainModule $ do
695+
proveResult <- execute execOptions mainModule' $ do
695696
let KoreExecOptions{breadthLimit, depthLimit} = execOptions
696697
KoreProveOptions{graphSearch} = proveOptions
697698
prove
698699
graphSearch
699700
breadthLimit
700701
depthLimit
701702
maxCounterexamples
702-
mainModule
703+
mainModule'
703704
specModule
704705
maybeAlreadyProvenModule
705706

kore/app/repl/Main.hs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,9 @@ mainWithOptions
220220
indexedModule <- loadModule mainModuleName definition
221221
specDefIndexedModule <- loadModule specModule definition
222222

223-
let smtConfig =
223+
let validatedDefinition =
224+
addExtraAxioms indexedModule specDefIndexedModule
225+
smtConfig =
224226
SMT.defaultConfig
225227
{ SMT.timeOut = smtTimeOut
226228
, SMT.rLimit = smtRLimit
@@ -253,11 +255,11 @@ mainWithOptions
253255
SMT.runSMT
254256
smtConfig
255257
( give
256-
(MetadataTools.build indexedModule)
257-
(declareSMTLemmas indexedModule)
258+
(MetadataTools.build validatedDefinition)
259+
(declareSMTLemmas validatedDefinition)
258260
)
259261
$ proveWithRepl
260-
indexedModule
262+
validatedDefinition
261263
specDefIndexedModule
262264
Nothing
263265
mvarLogAction

kore/app/share/GlobalMain.hs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,21 @@ module GlobalMain (
2424
loadModule,
2525
mainParseSearchPattern,
2626
mainPatternParseAndVerify,
27+
addExtraAxioms,
2728
) where
2829

2930
import Control.Exception (
3031
evaluate,
3132
)
3233
import Control.Lens (
3334
(%~),
35+
(<>~),
3436
)
3537
import qualified Control.Lens as Lens
3638
import qualified Control.Monad as Monad
39+
import Data.Generics.Product (
40+
field,
41+
)
3742
import Data.List (
3843
intercalate,
3944
nub,
@@ -68,6 +73,7 @@ import qualified Kore.Attribute.Symbol as Attribute (
6873
)
6974
import qualified Kore.Builtin as Builtin
7075
import Kore.IndexedModule.IndexedModule (
76+
IndexedModule (indexedModuleAxioms),
7177
VerifiedModule,
7278
)
7379
import Kore.Internal.Conditional (Conditional (..))
@@ -560,3 +566,16 @@ mainPatternParseAndVerify indexedModule patternFileName =
560566
-}
561567
mainPatternParse :: String -> Main ParsedPattern
562568
mainPatternParse = mainParse parseKorePattern
569+
570+
{- | Extract axioms from a module and add them to the main definition module.
571+
This should be safe, as long as the axioms only depend on sorts/symbols
572+
defined in the main module.
573+
-}
574+
addExtraAxioms ::
575+
VerifiedModule StepperAttributes ->
576+
VerifiedModule StepperAttributes ->
577+
VerifiedModule StepperAttributes
578+
addExtraAxioms definitionModule moduleWithExtraAxioms =
579+
definitionModule
580+
& field @"indexedModuleAxioms"
581+
<>~ indexedModuleAxioms moduleWithExtraAxioms

kore/kore.cabal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ common global-main
104104
build-depends: clock >=0.8
105105
build-depends: containers >=0.5
106106
build-depends: filepath >=1.4
107+
build-depends: generic-lens >=1.1
107108
build-depends: lens >=4.17
108109
build-depends: megaparsec >=7.0
109110
build-depends: optparse-applicative >=0.14

nix/kore.nix.d/kore.nix

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,7 @@
473473
(hsPkgs."clock" or (errorHandler.buildDepError "clock"))
474474
(hsPkgs."containers" or (errorHandler.buildDepError "containers"))
475475
(hsPkgs."filepath" or (errorHandler.buildDepError "filepath"))
476+
(hsPkgs."generic-lens" or (errorHandler.buildDepError "generic-lens"))
476477
(hsPkgs."lens" or (errorHandler.buildDepError "lens"))
477478
(hsPkgs."megaparsec" or (errorHandler.buildDepError "megaparsec"))
478479
(hsPkgs."optparse-applicative" or (errorHandler.buildDepError "optparse-applicative"))
@@ -481,7 +482,6 @@
481482
(hsPkgs."directory" or (errorHandler.buildDepError "directory"))
482483
(hsPkgs."exceptions" or (errorHandler.buildDepError "exceptions"))
483484
(hsPkgs."extra" or (errorHandler.buildDepError "extra"))
484-
(hsPkgs."generic-lens" or (errorHandler.buildDepError "generic-lens"))
485485
(hsPkgs."reflection" or (errorHandler.buildDepError "reflection"))
486486
];
487487
buildable = true;
@@ -500,6 +500,7 @@
500500
(hsPkgs."clock" or (errorHandler.buildDepError "clock"))
501501
(hsPkgs."containers" or (errorHandler.buildDepError "containers"))
502502
(hsPkgs."filepath" or (errorHandler.buildDepError "filepath"))
503+
(hsPkgs."generic-lens" or (errorHandler.buildDepError "generic-lens"))
503504
(hsPkgs."lens" or (errorHandler.buildDepError "lens"))
504505
(hsPkgs."megaparsec" or (errorHandler.buildDepError "megaparsec"))
505506
(hsPkgs."optparse-applicative" or (errorHandler.buildDepError "optparse-applicative"))
@@ -521,6 +522,7 @@
521522
(hsPkgs."clock" or (errorHandler.buildDepError "clock"))
522523
(hsPkgs."containers" or (errorHandler.buildDepError "containers"))
523524
(hsPkgs."filepath" or (errorHandler.buildDepError "filepath"))
525+
(hsPkgs."generic-lens" or (errorHandler.buildDepError "generic-lens"))
524526
(hsPkgs."lens" or (errorHandler.buildDepError "lens"))
525527
(hsPkgs."megaparsec" or (errorHandler.buildDepError "megaparsec"))
526528
(hsPkgs."optparse-applicative" or (errorHandler.buildDepError "optparse-applicative"))
@@ -557,6 +559,7 @@
557559
(hsPkgs."clock" or (errorHandler.buildDepError "clock"))
558560
(hsPkgs."containers" or (errorHandler.buildDepError "containers"))
559561
(hsPkgs."filepath" or (errorHandler.buildDepError "filepath"))
562+
(hsPkgs."generic-lens" or (errorHandler.buildDepError "generic-lens"))
560563
(hsPkgs."lens" or (errorHandler.buildDepError "lens"))
561564
(hsPkgs."megaparsec" or (errorHandler.buildDepError "megaparsec"))
562565
(hsPkgs."optparse-applicative" or (errorHandler.buildDepError "optparse-applicative"))
@@ -580,6 +583,7 @@
580583
(hsPkgs."clock" or (errorHandler.buildDepError "clock"))
581584
(hsPkgs."containers" or (errorHandler.buildDepError "containers"))
582585
(hsPkgs."filepath" or (errorHandler.buildDepError "filepath"))
586+
(hsPkgs."generic-lens" or (errorHandler.buildDepError "generic-lens"))
583587
(hsPkgs."lens" or (errorHandler.buildDepError "lens"))
584588
(hsPkgs."megaparsec" or (errorHandler.buildDepError "megaparsec"))
585589
(hsPkgs."optparse-applicative" or (errorHandler.buildDepError "optparse-applicative"))
@@ -602,6 +606,7 @@
602606
(hsPkgs."clock" or (errorHandler.buildDepError "clock"))
603607
(hsPkgs."containers" or (errorHandler.buildDepError "containers"))
604608
(hsPkgs."filepath" or (errorHandler.buildDepError "filepath"))
609+
(hsPkgs."generic-lens" or (errorHandler.buildDepError "generic-lens"))
605610
(hsPkgs."lens" or (errorHandler.buildDepError "lens"))
606611
(hsPkgs."megaparsec" or (errorHandler.buildDepError "megaparsec"))
607612
(hsPkgs."optparse-applicative" or (errorHandler.buildDepError "optparse-applicative"))

0 commit comments

Comments
 (0)