@@ -56,6 +56,7 @@ import Options.Applicative
5656 , value
5757 )
5858import qualified Options.Applicative as Options
59+ import qualified Options.Applicative.Help.Pretty as OptPretty
5960import System.Clock
6061 ( Clock (Monotonic )
6162 , TimeSpec
@@ -82,7 +83,6 @@ import System.IO
8283 , withFile
8384 )
8485
85- import qualified Data.Limit as Limit
8686import Kore.Attribute.Symbol as Attribute
8787import Kore.BugReport
8888import Kore.Exec
@@ -148,9 +148,6 @@ import Kore.Reachability
148148import qualified Kore.Reachability.Claim as Claim
149149import Kore.Rewriting.RewritingVariable
150150import Kore.Step
151- import Kore.Step.RulePattern
152- ( RewriteRule
153- )
154151import Kore.Step.Search
155152 ( SearchType (.. )
156153 )
@@ -268,9 +265,6 @@ applyKoreSearchOptions Nothing koreExecOpts = koreExecOpts
268265applyKoreSearchOptions koreSearchOptions@ (Just koreSearchOpts) koreExecOpts =
269266 koreExecOpts
270267 { koreSearchOptions
271- , strategy =
272- -- Search relies on exploring the entire space of states.
273- (" all" , priorityAllStrategy)
274268 , depthLimit = min depthLimit searchTypeDepthLimit
275269 }
276270 where
@@ -293,7 +287,7 @@ data KoreExecOptions = KoreExecOptions
293287 -- ^ The name of the main module in the definition
294288 , breadthLimit :: ! (Limit Natural )
295289 , depthLimit :: ! (Limit Natural )
296- , strategy :: ! ( String , [ RewriteRule RewritingVariableName ] -> Strategy ( Prim ( RewriteRule RewritingVariableName )))
290+ , strategy :: ! ExecutionMode
297291 , koreSolverOptions :: ! KoreSolverOptions
298292 , koreLogOptions :: ! KoreLogOptions
299293 , koreSearchOptions :: ! (Maybe KoreSearchOptions )
@@ -346,17 +340,12 @@ parseKoreExecOptions startTime =
346340 parseBreadthLimit = Limit <$> breadth <|> pure Unlimited
347341 parseDepthLimit = Limit <$> depth <|> pure Unlimited
348342 parseStrategy =
349- option (readSum " strategy " strategies)
343+ option parseExecutionMode
350344 ( metavar " STRATEGY"
351345 <> long " strategy"
352- <> value ( " all " , priorityAllStrategy)
346+ <> value All
353347 <> help " Select rewrites using STRATEGY."
354348 )
355- where
356- strategies =
357- [ (" any" , priorityAnyStrategy)
358- , (" all" , priorityAllStrategy)
359- ]
360349
361350 breadth =
362351 option auto
@@ -384,6 +373,20 @@ parseKoreExecOptions startTime =
384373 , long " rts-statistics"
385374 , help " Write runtime statistics to FILENAME in JSON format."
386375 ]
376+ parseExecutionMode = do
377+ val <- str
378+ case val :: String of
379+ " all" -> return All
380+ " any" -> return Any
381+ _ ->
382+ readerError
383+ $ show
384+ $ OptPretty. hsep
385+ [ " Unknown option"
386+ , OptPretty. squotes (OptPretty. text val)
387+ <> OptPretty. dot
388+ , " Known options are 'all' and 'any'."
389+ ]
387390
388391-- | modifiers for the Command line parser description
389392parserInfoModifiers :: InfoMod options
@@ -462,7 +465,7 @@ koreExecSh
462465 <$> maybeLimit Nothing Just breadthLimit
463466 , (\ limit -> unwords [" --depth" , show limit])
464467 <$> maybeLimit Nothing Just depthLimit
465- , pure $ unwords [" --strategy" , fst strategy]
468+ , pure $ unwords [" --strategy" , unparseExecutionMode strategy]
466469 , rtsStatistics $>
467470 unwords [" --rts-statistics" , defaultRtsStatisticsFilePath]
468471 ]
@@ -472,6 +475,8 @@ koreExecSh
472475 , maybe mempty unparseKoreProveOptions koreProveOptions
473476 , maybe mempty unparseKoreMergeOptions koreMergeOptions
474477 ]
478+ unparseExecutionMode All = " all"
479+ unparseExecutionMode Any = " any"
475480
476481defaultDefinitionFilePath :: KoreExecOptions -> FilePath
477482defaultDefinitionFilePath KoreExecOptions { koreProveOptions }
@@ -615,14 +620,13 @@ koreSearch execOptions searchOptions = do
615620 initial <- loadPattern mainModule patternFileName
616621 final <-
617622 execute execOptions mainModule
618- $ search breadthLimit mainModule strategy' initial target config
623+ $ search depthLimit breadthLimit mainModule initial target config
619624 lift $ renderResult execOptions (unparse final)
620625 return ExitSuccess
621626 where
622627 KoreSearchOptions { bound, searchType } = searchOptions
623628 config = Search. Config { bound, searchType }
624- KoreExecOptions { breadthLimit, depthLimit, strategy } = execOptions
625- strategy' = Limit. replicate depthLimit . snd strategy
629+ KoreExecOptions { breadthLimit, depthLimit } = execOptions
626630
627631koreRun :: KoreExecOptions -> Main ExitCode
628632koreRun execOptions = do
@@ -634,12 +638,11 @@ koreRun execOptions = do
634638 initial <- loadPattern mainModule patternFileName
635639 (exitCode, final) <-
636640 execute execOptions mainModule
637- $ exec breadthLimit mainModule strategy' initial
641+ $ exec depthLimit breadthLimit mainModule strategy initial
638642 lift $ renderResult execOptions (unparse final)
639643 return exitCode
640644 where
641645 KoreExecOptions { breadthLimit, depthLimit, strategy } = execOptions
642- strategy' = Limit. replicate depthLimit . snd strategy
643646
644647koreProve :: KoreExecOptions -> KoreProveOptions -> Main ExitCode
645648koreProve execOptions proveOptions = do
0 commit comments