1
1
module Main (main ) where
2
2
3
- import Control.Applicative
4
- ( Alternative (.. ), optional , (<$) )
5
- import qualified Control.Lens as Lens
6
- import Data.Function
7
- ( (&) )
8
- import Data.List
9
- ( intercalate )
10
- import qualified Data.Map as Map
11
- import Data.Maybe
12
- ( fromMaybe )
13
- import Data.Proxy
14
- ( Proxy (.. ) )
15
- import Data.Semigroup
16
- ( (<>) )
17
- import Data.Text
18
- ( Text )
19
- import Data.Text.Prettyprint.Doc.Render.Text
20
- ( hPutDoc , putDoc )
21
- import Options.Applicative
22
- ( InfoMod , Parser , argument , auto , fullDesc , header , help ,
23
- long , metavar , option , progDesc , readerError , str , strOption ,
24
- switch , value )
25
- import System.Exit
26
- ( ExitCode (.. ), exitWith )
27
- import System.IO
28
- ( IOMode (WriteMode ), withFile )
3
+ import Control.Applicative
4
+ ( Alternative (.. ), optional , (<$) )
5
+ import Data.List
6
+ ( intercalate )
7
+ import Data.Maybe
8
+ ( fromMaybe )
9
+ import Data.Semigroup
10
+ ( (<>) )
11
+ import Data.Text.Prettyprint.Doc.Render.Text
12
+ ( hPutDoc , putDoc )
13
+ import Options.Applicative
14
+ ( InfoMod , Parser , argument , auto , fullDesc , header , help , long ,
15
+ metavar , option , progDesc , readerError , str , strOption , value )
16
+ import System.Exit
17
+ ( ExitCode (.. ), exitWith )
18
+ import System.IO
19
+ ( IOMode (WriteMode ), withFile )
29
20
30
21
import Data.Limit
31
22
( Limit (.. ) )
@@ -35,24 +26,18 @@ import Kore.AST.Kore
35
26
import Kore.AST.Pure
36
27
import Kore.AST.Sentence
37
28
import Kore.AST.Valid
38
- import Kore.ASTVerifier.DefinitionVerifier
39
- ( AttributesVerification (DoNotVerifyAttributes ),
40
- defaultAttributesVerification ,
41
- verifyAndIndexDefinitionWithBase )
42
29
import qualified Kore.Attribute.Axiom as Attribute
43
- import qualified Kore.Builtin as Builtin
44
30
import Kore.Error
45
31
( printError )
46
32
import Kore.Exec
47
33
import Kore.IndexedModule.IndexedModule
48
- ( IndexedModule ( .. ), VerifiedModule )
34
+ ( VerifiedModule )
49
35
import Kore.Logger.Output
50
36
( KoreLogOptions (.. ), parseKoreLogOptions , withLogger )
51
37
import Kore.Parser.Parser
52
- ( parseKoreDefinition , parseKorePattern )
38
+ ( parseKorePattern )
53
39
import Kore.Predicate.Predicate
54
40
( makePredicate )
55
- import qualified Kore.Repl as Repl
56
41
import Kore.Step.Pattern
57
42
import Kore.Step.Representation.ExpandedPattern
58
43
( CommonExpandedPattern , Predicated (.. ) )
@@ -74,31 +59,6 @@ Main module to run kore-exec
74
59
TODO: add command line argument tab-completion
75
60
-}
76
61
77
- data KoreProveOptions =
78
- KoreProveOptions
79
- { specFileName :: ! FilePath
80
- -- ^ Name of file containing the spec to be proven
81
- , specMainModule :: ! ModuleName
82
- -- ^ The main module of the spec to be proven
83
- }
84
-
85
- parseKoreProveOptions :: Parser KoreProveOptions
86
- parseKoreProveOptions =
87
- KoreProveOptions
88
- <$> strOption
89
- ( metavar " SPEC_FILE"
90
- <> long " prove"
91
- <> help " Kore source file representing spec to be proven.\
92
- \Needs --spec-module."
93
- )
94
- <*> (ModuleName
95
- <$> strOption
96
- ( metavar " SPEC_MODULE"
97
- <> long " spec-module"
98
- <> help " The name of the main module in the spec to be proven."
99
- )
100
- )
101
-
102
62
103
63
data KoreSearchOptions =
104
64
KoreSearchOptions
@@ -198,7 +158,6 @@ data KoreExecOptions = KoreExecOptions
198
158
, koreLogOptions :: ! KoreLogOptions
199
159
, koreSearchOptions :: ! (Maybe KoreSearchOptions )
200
160
, koreProveOptions :: ! (Maybe KoreProveOptions )
201
- , koreRepl :: ! Bool
202
161
}
203
162
204
163
-- | Command Line Argument Parser
@@ -247,10 +206,6 @@ parseKoreExecOptions =
247
206
<*> parseKoreLogOptions
248
207
<*> pure Nothing
249
208
<*> optional parseKoreProveOptions
250
- <*> switch
251
- ( long " repl"
252
- <> help " Enable REPL mode for prove"
253
- )
254
209
SMT. Config { timeOut = defaultTimeOut } = SMT. defaultConfig
255
210
readSMTTimeOut = do
256
211
i <- auto
@@ -335,7 +290,6 @@ mainWithOptions
335
290
, koreLogOptions
336
291
, koreSearchOptions
337
292
, koreProveOptions
338
- , koreRepl
339
293
}
340
294
= do
341
295
let
@@ -345,10 +299,6 @@ mainWithOptions
345
299
{ SMT. timeOut = smtTimeOut
346
300
, SMT. preludeFile = smtPrelude
347
301
}
348
- repl =
349
- if koreRepl
350
- then Repl. proveClaim
351
- else const . pure $ ()
352
302
parsedDefinition <- parseDefinition definitionFileName
353
303
indexedDefinition@ (indexedModules, _) <-
354
304
verifyDefinitionWithBase
@@ -391,7 +341,7 @@ mainWithOptions
391
341
clockSomethingIO " Executing"
392
342
$ withLogger koreLogOptions (\ logger ->
393
343
SMT. runSMT smtConfig
394
- $ evalSimplifier logger repl
344
+ $ evalSimplifier logger
395
345
$ case proveParameters of
396
346
Nothing -> do
397
347
let purePattern =
@@ -428,30 +378,6 @@ mainWithOptions
428
378
withFile outputFile WriteMode (\ h -> hPutDoc h unparsed)
429
379
() <$ exitWith exitCode
430
380
431
- mainModule
432
- :: ModuleName
433
- -> Map. Map
434
- ModuleName
435
- (VerifiedModule StepperAttributes Attribute. Axiom )
436
- -> IO (VerifiedModule StepperAttributes Attribute. Axiom )
437
- mainModule name modules =
438
- case Map. lookup name modules of
439
- Nothing ->
440
- error
441
- ( " The main module, '"
442
- ++ getModuleNameForError name
443
- ++ " ', was not found. Check the --module flag."
444
- )
445
- Just m -> return m
446
-
447
- {- | Parse a Kore definition from a filename.
448
-
449
- Also prints timing information; see 'mainParse'.
450
-
451
- -}
452
- parseDefinition :: FilePath -> IO KoreDefinition
453
- parseDefinition = mainParse parseKoreDefinition
454
-
455
381
-- | IO action that parses a kore pattern from a filename and prints timing
456
382
-- information.
457
383
mainPatternParse :: String -> IO CommonKorePattern
@@ -484,100 +410,10 @@ mainParseSearchPattern indexedModule patternFileName = do
484
410
}
485
411
_ -> error " Unexpected non-conjunctive pattern"
486
412
487
- -- | IO action that parses a kore AST entity from a filename and prints timing
488
- -- information.
489
- mainParse
490
- :: (FilePath -> String -> Either String a )
491
- -> String
492
- -> IO a
493
- mainParse parser fileName = do
494
- contents <-
495
- clockSomethingIO " Reading the input file" (readFile fileName)
496
- parseResult <-
497
- clockSomething " Parsing the file" (parser fileName contents)
498
- case parseResult of
499
- Left err -> error err
500
- Right definition -> return definition
501
-
502
- {- | Verify the well-formedness of a Kore definition.
503
-
504
- Also prints timing information; see 'mainParse'.
505
-
506
- -}
507
- verifyDefinitionWithBase
508
- :: Maybe
509
- ( Map. Map
510
- ModuleName
511
- (VerifiedModule StepperAttributes Attribute. Axiom )
512
- , Map. Map Text AstLocation
513
- )
514
- -- ^ base definition to use for verification
515
- -> Bool -- ^ whether to check (True) or ignore attributes during verification
516
- -> KoreDefinition -- ^ Parsed definition to check well-formedness
517
- -> IO
518
- ( Map. Map
519
- ModuleName
520
- (VerifiedModule StepperAttributes Attribute. Axiom )
521
- , Map. Map Text AstLocation
522
- )
523
- verifyDefinitionWithBase maybeBaseModule willChkAttr definition =
524
- let attributesVerification =
525
- if willChkAttr
526
- then defaultAttributesVerification Proxy Proxy
527
- else DoNotVerifyAttributes
528
- in do
529
- verifyResult <-
530
- clockSomething " Verifying the definition"
531
- (verifyAndIndexDefinitionWithBase
532
- maybeBaseModule
533
- attributesVerification
534
- Builtin. koreVerifiers
535
- definition
536
- )
537
- case verifyResult of
538
- Left err1 -> error (printError err1)
539
- Right indexedDefinition -> return indexedDefinition
540
-
541
413
makePurePattern
542
414
:: VerifiedKorePattern
543
415
-> CommonStepPattern Object
544
416
makePurePattern pat =
545
417
case fromKorePattern Object pat of
546
418
Left err -> error (printError err)
547
419
Right objPat -> objPat
548
-
549
- -- TODO (traiansf): Get rid of this.
550
- -- The function below works around several limitations of
551
- -- the current tool by tricking the tool into believing that
552
- -- functions are constructors (so that function patterns can match)
553
- -- and that @kseq@ and @dotk@ are both functional and constructor.
554
- constructorFunctions
555
- :: VerifiedModule StepperAttributes Attribute. Axiom
556
- -> VerifiedModule StepperAttributes Attribute. Axiom
557
- constructorFunctions ixm =
558
- ixm
559
- { indexedModuleObjectSymbolSentences =
560
- Map. mapWithKey
561
- constructorFunctions1
562
- (indexedModuleObjectSymbolSentences ixm)
563
- , indexedModuleObjectAliasSentences =
564
- Map. mapWithKey
565
- constructorFunctions1
566
- (indexedModuleObjectAliasSentences ixm)
567
- , indexedModuleImports = recurseIntoImports <$> indexedModuleImports ixm
568
- }
569
- where
570
- constructorFunctions1 ident (atts, defn) =
571
- ( atts
572
- & lensConstructor Lens. <>~ Constructor isCons
573
- & lensFunctional Lens. <>~ Functional (isCons || isInj)
574
- & lensInjective Lens. <>~ Injective (isCons || isInj)
575
- & lensSortInjection Lens. <>~ SortInjection isInj
576
- , defn
577
- )
578
- where
579
- isInj = getId ident == " inj"
580
- isCons = elem (getId ident) [" kseq" , " dotk" ]
581
-
582
- recurseIntoImports (attrs, attributes, importedModule) =
583
- (attrs, attributes, constructorFunctions importedModule)
0 commit comments