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

Function without args should not end up in a define-funs-rec

parent 5b35e1b6
No related branches found
No related tags found
No related merge requests found
...@@ -3,8 +3,9 @@ ...@@ -3,8 +3,9 @@
package leon package leon
package solvers.smtlib package solvers.smtlib
import leon.purescala.Common.FreshIdentifier
import leon.purescala.Expressions.Expr import leon.purescala.Expressions.Expr
import purescala.Definitions.TypedFunDef import leon.purescala.Definitions.{ValDef, TypedFunDef}
import purescala.DefOps.typedTransitiveCallees import purescala.DefOps.typedTransitiveCallees
import leon.purescala.ExprOps.{variablesOf, matchToIfThenElse} import leon.purescala.ExprOps.{variablesOf, matchToIfThenElse}
import smtlib.parser.Commands._ import smtlib.parser.Commands._
...@@ -23,11 +24,23 @@ trait SMTLIBUnrollingCVC4Target extends SMTLIBCVC4Target { ...@@ -23,11 +24,23 @@ trait SMTLIBUnrollingCVC4Target extends SMTLIBCVC4Target {
val (funs, exploredAll) = typedTransitiveCallees(Set(tfd), Some(typedFunDefExplorationLimit)) val (funs, exploredAll) = typedTransitiveCallees(Set(tfd), Some(typedFunDefExplorationLimit))
if (!exploredAll) { if (!exploredAll) {
reporter.warning( reporter.warning(
s"Did not manage to explore the space of typed functions called from ${tfd.id}. The solver may fail" s"Did not manage to explore the space of typed functions trasitively called from ${tfd.id}. The solver may fail"
) )
} }
val smtFunDecls = funs.toSeq.collect { val smtFunDecls = funs.toSeq.flatMap {
case tfd if tfd.params.isEmpty =>
// FIXME: Here we actually want to call super[SMTLIBCVC4Target].declareFunction(tfd),
// but we inline it to work around a freakish compiler bug
if (!functions.containsA(tfd)) {
val id = if (tfd.tps.isEmpty) {
tfd.id
} else {
FreshIdentifier(tfd.id.name)
}
sendCommand( DeclareFun(id2sym(id),Seq(),declareSort(tfd.returnType)) )
}
None
case tfd if !functions.containsA(tfd) && tfd.params.nonEmpty => case tfd if !functions.containsA(tfd) && tfd.params.nonEmpty =>
val id = if (tfd.tps.isEmpty) { val id = if (tfd.tps.isEmpty) {
tfd.id tfd.id
...@@ -36,11 +49,12 @@ trait SMTLIBUnrollingCVC4Target extends SMTLIBCVC4Target { ...@@ -36,11 +49,12 @@ trait SMTLIBUnrollingCVC4Target extends SMTLIBCVC4Target {
} }
val sym = id2sym(id) val sym = id2sym(id)
functions +=(tfd, sym) functions +=(tfd, sym)
FunDec( Some(FunDec(
sym, sym,
tfd.params map { p => SortedVar(id2sym(p.id), declareSort(p.getType)) }, tfd.params map { p => SortedVar(id2sym(p.id), declareSort(p.getType)) },
declareSort(tfd.returnType) declareSort(tfd.returnType)
) ))
case _ => None
} }
val smtBodies = smtFunDecls map { case FunDec(sym, _, _) => val smtBodies = smtFunDecls map { case FunDec(sym, _, _) =>
val tfd = functions.toA(sym) val tfd = functions.toA(sym)
......
...@@ -30,15 +30,15 @@ class NewSolversRegression extends VerificationRegression { ...@@ -30,15 +30,15 @@ class NewSolversRegression extends VerificationRegression {
false false
} }
( //(
if (isZ3Available) // if (isZ3Available)
List(List("--solvers=smt-z3-quantified", "--feelinglucky", "--timeout=3")) //List(List("--solvers=smt-z3-quantified", "--feelinglucky", "--timeout=3"))
else Nil //else Nil
) ++ ( //) ++ (
if (isCVC4Available) if (isCVC4Available)
List(List("--solvers=smt-2.5-cvc4", "--feelinglucky")) List(List("--solvers=smt-2.5-cvc4", "--feelinglucky"))
else Nil else Nil
) //)
} }
test() test()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment