Skip to content
Snippets Groups Projects
Commit 510168a8 authored by Philippe Suter's avatar Philippe Suter
Browse files

Solvers are LeonComponents.

parent 42c314f5
Branches
Tags
No related merge requests found
...@@ -22,8 +22,8 @@ class ParallelSolver(solvers : Solver*) extends Solver(solvers(0).context) with ...@@ -22,8 +22,8 @@ class ParallelSolver(solvers : Solver*) extends Solver(solvers(0).context) with
private val reporter = context.reporter private val reporter = context.reporter
val description = "Solver running subsolvers in parallel " + solvers.map(_.description).mkString("(", ", ", ")") val description = "Solver running subsolvers in parallel " + solvers.map(_.description).mkString("(", ", ", ")")
override val shortDescription = solvers.map(_.shortDescription).mkString("//") override val name = solvers.map(_.name).mkString("//")
override val superseeds : Seq[String] = solvers.map(_.shortDescription).toSeq override val superseeds : Seq[String] = solvers.map(_.name).toSeq
case class Solve(expr: Expr) case class Solve(expr: Expr)
case object Init case object Init
...@@ -39,10 +39,10 @@ class ParallelSolver(solvers : Solver*) extends Solver(solvers(0).context) with ...@@ -39,10 +39,10 @@ class ParallelSolver(solvers : Solver*) extends Solver(solvers(0).context) with
while(true) { while(true) {
receive { receive {
case Solve(expr) => { case Solve(expr) => {
reporter.info("Starting solver " + s.shortDescription) reporter.info("Starting solver " + s.name)
val res = s.solve(expr) val res = s.solve(expr)
that ! Result(res) that ! Result(res)
reporter.info("Ending solver " + s.shortDescription) reporter.info("Ending solver " + s.name)
} }
} }
} }
...@@ -54,15 +54,15 @@ class ParallelSolver(solvers : Solver*) extends Solver(solvers(0).context) with ...@@ -54,15 +54,15 @@ class ParallelSolver(solvers : Solver*) extends Solver(solvers(0).context) with
while(true) { while(true) {
receive { receive {
case Init => { case Init => {
reporter.info("Init solver " + s.shortDescription) reporter.info("Init solver " + s.name)
s.init s.init
coordinator ! Ready coordinator ! Ready
} }
case Solve(expr) => { case Solve(expr) => {
reporter.info("Starting solver " + s.shortDescription) reporter.info("Starting solver " + s.name)
val res = s.solve(expr) val res = s.solve(expr)
coordinator ! Result(res) coordinator ! Result(res)
reporter.info("Ending solver " + s.shortDescription) reporter.info("Ending solver " + s.name)
} }
} }
} }
...@@ -140,7 +140,7 @@ class ParallelSolver(solvers : Solver*) extends Solver(solvers(0).context) with ...@@ -140,7 +140,7 @@ class ParallelSolver(solvers : Solver*) extends Solver(solvers(0).context) with
class SolverRunner(s: Solver, expr: Expr) extends Actor { class SolverRunner(s: Solver, expr: Expr) extends Actor {
def act() { def act() {
reporter.info("Starting solver " + s.shortDescription) reporter.info("Starting solver " + s.name)
s.solve(expr) match { s.solve(expr) match {
case Some(b) => { case Some(b) => {
lock.acquire lock.acquire
...@@ -162,7 +162,7 @@ class ParallelSolver(solvers : Solver*) extends Solver(solvers(0).context) with ...@@ -162,7 +162,7 @@ class ParallelSolver(solvers : Solver*) extends Solver(solvers(0).context) with
if(nbResponses >= nbSolvers) if(nbResponses >= nbSolvers)
resultNotReady = false resultNotReady = false
lock.release lock.release
reporter.info("Ending solver " + s.shortDescription) reporter.info("Ending solver " + s.name)
} }
} }
*/ */
......
...@@ -17,8 +17,8 @@ class RandomSolver(context: LeonContext, val nbTrial: Option[Int] = None) extend ...@@ -17,8 +17,8 @@ class RandomSolver(context: LeonContext, val nbTrial: Option[Int] = None) extend
private val reporter = context.reporter private val reporter = context.reporter
val name = "QC"
val description = "Solver applying random testing (QuickCheck-like)" val description = "Solver applying random testing (QuickCheck-like)"
override val shortDescription = "QC"
private val random = new Random() private val random = new Random()
......
...@@ -6,11 +6,7 @@ import purescala.Definitions._ ...@@ -6,11 +6,7 @@ import purescala.Definitions._
import purescala.TreeOps._ import purescala.TreeOps._
import purescala.Trees._ import purescala.Trees._
abstract class Solver(val context : LeonContext) extends IncrementalSolverBuilder { abstract class Solver(val context : LeonContext) extends IncrementalSolverBuilder with LeonComponent {
// This used to be in Extension
val description : String
val shortDescription : String
// This can be used by solvers to "see" the programs from which the // This can be used by solvers to "see" the programs from which the
// formulas come. (e.g. to set up some datastructures for the defined // formulas come. (e.g. to set up some datastructures for the defined
// ADTs, etc.) // ADTs, etc.)
......
...@@ -7,8 +7,8 @@ import purescala.Trees._ ...@@ -7,8 +7,8 @@ import purescala.Trees._
import purescala.TypeTrees._ import purescala.TypeTrees._
class TrivialSolver(context: LeonContext) extends Solver(context) with NaiveIncrementalSolver { class TrivialSolver(context: LeonContext) extends Solver(context) with NaiveIncrementalSolver {
val name = "trivial"
val description = "Solver for syntactically trivial formulas" val description = "Solver for syntactically trivial formulas"
override val shortDescription = "trivial"
def solve(expression: Expr) : Option[Boolean] = expression match { def solve(expression: Expr) : Option[Boolean] = expression match {
case BooleanLiteral(v) => Some(v) case BooleanLiteral(v) => Some(v)
......
...@@ -15,23 +15,22 @@ import purescala.TypeTrees._ ...@@ -15,23 +15,22 @@ import purescala.TypeTrees._
import scala.collection.mutable.{Map => MutableMap} import scala.collection.mutable.{Map => MutableMap}
import scala.collection.mutable.{Set => MutableSet} import scala.collection.mutable.{Set => MutableSet}
class FairZ3Solver(context : LeonContext) extends Solver(context) with AbstractZ3Solver with Z3ModelReconstruction { class FairZ3Solver(context : LeonContext)
// have to comment this to use the solver for constraint solving... extends Solver(context)
// assert(Settings.useFairInstantiator) with AbstractZ3Solver
with Z3ModelReconstruction
private val UNKNOWNASSAT : Boolean = !Settings.noForallAxioms with LeonComponent {
val name = "Z3-f"
val description = "Fair Z3 Solver" val description = "Fair Z3 Solver"
override val shortDescription = "Z3-f"
// this is fixed // this is fixed
protected[leon] val z3cfg = new Z3Config( protected[leon] val z3cfg = new Z3Config(
"MODEL" -> true, "MODEL" -> true,
"MBQI" -> false, "MBQI" -> false,
// "SOFT_TIMEOUT" -> 100,
"TYPE_CHECK" -> true, "TYPE_CHECK" -> true,
"WELL_SORTED_CHECK" -> true "WELL_SORTED_CHECK" -> true
) )
toggleWarningMessages(true) toggleWarningMessages(true)
def isKnownDef(funDef: FunDef) : Boolean = functionMap.isDefinedAt(funDef) def isKnownDef(funDef: FunDef) : Boolean = functionMap.isDefinedAt(funDef)
......
...@@ -20,8 +20,8 @@ import purescala.TypeTrees._ ...@@ -20,8 +20,8 @@ import purescala.TypeTrees._
* Results should come back very quickly. * Results should come back very quickly.
*/ */
class UninterpretedZ3Solver(context : LeonContext) extends Solver(context) with AbstractZ3Solver with Z3ModelReconstruction { class UninterpretedZ3Solver(context : LeonContext) extends Solver(context) with AbstractZ3Solver with Z3ModelReconstruction {
val name = "Z3-u"
val description = "Uninterpreted Z3 Solver" val description = "Uninterpreted Z3 Solver"
override val shortDescription = "Z3-u"
// this is fixed // this is fixed
protected[leon] val z3cfg = new Z3Config( protected[leon] val z3cfg = new Z3Config(
......
...@@ -89,8 +89,8 @@ object AnalysisPhase extends LeonPhase[Program,VerificationReport] { ...@@ -89,8 +89,8 @@ object AnalysisPhase extends LeonPhase[Program,VerificationReport] {
// try all solvers until one returns a meaningful answer // try all solvers until one returns a meaningful answer
var superseeded : Set[String] = Set.empty[String] var superseeded : Set[String] = Set.empty[String]
solvers.find(se => { solvers.find(se => {
reporter.info("Trying with solver: " + se.shortDescription) reporter.info("Trying with solver: " + se.name)
if(superseeded(se.shortDescription) || superseeded(se.description)) { if(superseeded(se.name) || superseeded(se.description)) {
reporter.info("Solver was superseeded. Skipping.") reporter.info("Solver was superseeded. Skipping.")
false false
} else { } else {
......
...@@ -27,7 +27,7 @@ class VerificationCondition(val condition: Expr, val funDef: FunDef, val kind: V ...@@ -27,7 +27,7 @@ class VerificationCondition(val condition: Expr, val funDef: FunDef, val kind: V
} }
def solverStr = solvedWith match { def solverStr = solvedWith match {
case Some(s) => s.shortDescription case Some(s) => s.name
case None => "" case None => ""
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment