Skip to content
Snippets Groups Projects
Commit 8d1a95b3 authored by Manos Koukoutos's avatar Manos Koukoutos
Browse files

Fix problems with options

Move optEval to MainComponent
Add helpful comments
Beautify how debugSections are printed
Termination and analysis should happen iff --verify and --termination
parent 5a074d0d
No related branches found
No related tags found
No related merge requests found
...@@ -31,20 +31,25 @@ object Main { ...@@ -31,20 +31,25 @@ object Main {
solvers.z3.FairZ3Component, MainComponent, SharedOptions, solvers.smtlib.SMTLIBCVC4Component solvers.z3.FairZ3Component, MainComponent, SharedOptions, solvers.smtlib.SMTLIBCVC4Component
) )
/*
* This object holds the options that determine the selected pipeline of Leon.
* Please put any further such options here to have them print nicely in --help message.
*/
object MainComponent extends LeonComponent { object MainComponent extends LeonComponent {
val name = "main" val name = "main"
val description = "Options that determine the feature of Leon to be used (mutually exclusive). Default: verify" val description = "Options that determine the feature of Leon to be used (mutually exclusive). Default: verify"
val optTermination = LeonFlagOptionDef("termination", "Check program termination", false) val optEval = LeonStringOptionDef("eval", "Evaluate ground functions with selected evaluator", "default", "[code|default]")
val optRepair = LeonFlagOptionDef("repair", "Repair selected functions", false) val optXLang = LeonFlagOptionDef("xlang", "Verification with support for extra program constructs (imperative,...)", false)
val optSynthesis = LeonFlagOptionDef("synthesis", "Partial synthesis of choose() constructs", false) val optTermination = LeonFlagOptionDef("termination", "Check program termination", false)
val optXLang = LeonFlagOptionDef("xlang", "Support for extra program constructs (imperative,...)", false) val optRepair = LeonFlagOptionDef("repair", "Repair selected functions", false)
val optNoop = LeonFlagOptionDef("noop", "No operation performed, just output program", false) val optSynthesis = LeonFlagOptionDef("synthesis", "Partial synthesis of choose() constructs", false)
val optVerify = LeonFlagOptionDef("verify", "Verify function contracts", true ) val optNoop = LeonFlagOptionDef("noop", "No operation performed, just output program", false)
val optHelp = LeonFlagOptionDef("help", "Show help message", false) val optVerify = LeonFlagOptionDef("verify", "Verify function contracts", true )
val optHelp = LeonFlagOptionDef("help", "Show help message", false)
override val definedOptions: Set[LeonOptionDef[Any]] = override val definedOptions: Set[LeonOptionDef[Any]] =
Set(optTermination, optRepair, optSynthesis, optXLang, optNoop, optHelp, optVerify) Set(optTermination, optRepair, optSynthesis, optXLang, optNoop, optHelp, optEval, optVerify)
} }
...@@ -149,10 +154,10 @@ object Main { ...@@ -149,10 +154,10 @@ object Main {
val synthesisF = ctx.findOptionOrDefault(optSynthesis) val synthesisF = ctx.findOptionOrDefault(optSynthesis)
val xlangF = ctx.findOptionOrDefault(optXLang) val xlangF = ctx.findOptionOrDefault(optXLang)
val repairF = ctx.findOptionOrDefault(optRepair) val repairF = ctx.findOptionOrDefault(optRepair)
val analysisF = ctx.findOption(optVerify).isDefined && ctx.findOption(optTermination).isDefined
val terminationF = ctx.findOptionOrDefault(optTermination) val terminationF = ctx.findOptionOrDefault(optTermination)
val verifyF = ctx.findOptionOrDefault(optVerify) val verifyF = ctx.findOptionOrDefault(optVerify)
val evalF = ctx.findOption(SharedOptions.optEval) val evalF = ctx.findOption(optEval)
val analysisF = verifyF && terminationF
def debugTrees(title: String): LeonPhase[Program, Program] = { def debugTrees(title: String): LeonPhase[Program, Program] = {
if (ctx.reporter.isDebugEnabled(DebugSectionTrees)) { if (ctx.reporter.isDebugEnabled(DebugSectionTrees)) {
......
...@@ -5,6 +5,12 @@ package leon ...@@ -5,6 +5,12 @@ package leon
import leon.utils.{DebugSections, DebugSection} import leon.utils.{DebugSections, DebugSection}
import OptionParsers._ import OptionParsers._
/*
* This object contains options that are shared among different modules of Leon.
*
* Options that determine the pipeline of Leon are not stored here,
* but in MainComponent in Main.scala.
*/
object SharedOptions extends LeonComponent { object SharedOptions extends LeonComponent {
val name = "sharedOptions" val name = "sharedOptions"
...@@ -22,8 +28,6 @@ object SharedOptions extends LeonComponent { ...@@ -22,8 +28,6 @@ object SharedOptions extends LeonComponent {
val usageRhs = "f1,f2,..." val usageRhs = "f1,f2,..."
} }
val optEval = LeonStringOptionDef("eval", "Evaluate ground functions", "default", "[code|default]")
val optSelectedSolvers = new LeonOptionDef[Set[String]] { val optSelectedSolvers = new LeonOptionDef[Set[String]] {
val name = "solvers" val name = "solvers"
val description = "Use solvers s1, s2,...\n" + solvers.SolverFactory.availableSolversPretty val description = "Use solvers s1, s2,...\n" + solvers.SolverFactory.availableSolversPretty
...@@ -35,10 +39,13 @@ object SharedOptions extends LeonComponent { ...@@ -35,10 +39,13 @@ object SharedOptions extends LeonComponent {
val optDebug = new LeonOptionDef[Set[DebugSection]] { val optDebug = new LeonOptionDef[Set[DebugSection]] {
import OptionParsers._ import OptionParsers._
val name = "debug" val name = "debug"
val description = ( val description = {
"Enable detailed messages per component.\nAvailable:" +: val sects = DebugSections.all.toSeq.map(_.name).sorted
DebugSections.all.toSeq.map(_.name).sorted val (first, second) = sects.splitAt(sects.length/2)
).mkString("\n ") "Enable detailed messages per component.\nAvailable:\n" +
" " + first.mkString(", ") + ",\n" +
" " + second.mkString(", ")
}
val default = Set[DebugSection]() val default = Set[DebugSection]()
val usageRhs = "d1,d2,..." val usageRhs = "d1,d2,..."
val debugParser: OptionParser[Set[DebugSection]] = s => { val debugParser: OptionParser[Set[DebugSection]] = s => {
...@@ -66,7 +73,6 @@ object SharedOptions extends LeonComponent { ...@@ -66,7 +73,6 @@ object SharedOptions extends LeonComponent {
optSelectedSolvers, optSelectedSolvers,
optDebug, optDebug,
optWatch, optWatch,
optEval,
optTimeout optTimeout
) )
} }
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
package leon package leon
package evaluators package evaluators
import leon.Main.MainComponent
import purescala.Definitions._ import purescala.Definitions._
import purescala.DefOps._ import purescala.DefOps._
import purescala.Expressions._ import purescala.Expressions._
...@@ -16,7 +17,7 @@ object EvaluationPhase extends LeonPhase[Program, Unit] { ...@@ -16,7 +17,7 @@ object EvaluationPhase extends LeonPhase[Program, Unit] {
def run(ctx: LeonContext)(program: Program): Unit = { def run(ctx: LeonContext)(program: Program): Unit = {
val evalFuns: Option[Seq[String]] = ctx.findOption(SharedOptions.optFunctions) val evalFuns: Option[Seq[String]] = ctx.findOption(SharedOptions.optFunctions)
val evaluator = ctx.findOptionOrDefault(SharedOptions.optEval) val evaluator = ctx.findOptionOrDefault(MainComponent.optEval)
val reporter = ctx.reporter val reporter = ctx.reporter
......
...@@ -15,7 +15,7 @@ object SynthesisPhase extends LeonPhase[Program, Program] { ...@@ -15,7 +15,7 @@ object SynthesisPhase extends LeonPhase[Program, Program] {
val name = "Synthesis" val name = "Synthesis"
val description = "Partial synthesis of \"choose\" constructs. Also used by repair during the synthesis stage." val description = "Partial synthesis of \"choose\" constructs. Also used by repair during the synthesis stage."
val optManual = LeonStringOptionDef("manual", "Manual search", default = "", "cmd") val optManual = LeonStringOptionDef("manual", "Manual search", default = "", "[cmd]")
val optCostModel = LeonStringOptionDef("costmodel", "Use a specific cost model for this search", "FIXME", "cm") val optCostModel = LeonStringOptionDef("costmodel", "Use a specific cost model for this search", "FIXME", "cm")
val optDerivTrees = LeonFlagOptionDef( "derivtrees", "Generate derivation trees", false) val optDerivTrees = LeonFlagOptionDef( "derivtrees", "Generate derivation trees", false)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment