Skip to content

Commit daf60d6

Browse files
committed
Update benchmarks
1 parent 641ae08 commit daf60d6

File tree

10 files changed

+43
-73
lines changed

10 files changed

+43
-73
lines changed

core/src/main/scala/stainless/extraction/trace/Trace.scala

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -96,17 +96,21 @@ trait Trace extends CachingPhase with IdentityFunctions with IdentitySorts { sel
9696
var funInv: Option[s.FunctionInvocation] = None
9797
fd.flags.filter(elem => elem.name == "traceInduct").head match {
9898
case s.Annotation("traceInduct", fun) => {
99-
s.exprOps.preTraversal {
100-
case _ if funInv.isDefined => // do nothing
101-
case fi @ s.FunctionInvocation(tfd, _, args) if symbols.isRecursive(tfd) && (fun.contains(StringLiteral(tfd.name)) || fun.contains(StringLiteral("")))
102-
=> {
103-
val paramVars = fd.params.map(_.toVariable)
104-
val argCheck = args.forall(paramVars.contains) && args.toSet.size == args.size
105-
if (argCheck)
106-
funInv = Some(fi)
107-
}
99+
BodyWithSpecs(fd.fullBody).getSpec(PostconditionKind) match {
100+
case Some(Postcondition(post)) =>
101+
s.exprOps.preTraversal {
102+
case _ if funInv.isDefined => // do nothing
103+
case fi @ s.FunctionInvocation(tfd, _, args) if symbols.isRecursive(tfd) && (fun.contains(StringLiteral(tfd.name)) || fun.contains(StringLiteral("")))
104+
=> {
105+
val paramVars = fd.params.map(_.toVariable)
106+
val argCheck = args.forall(paramVars.contains) && args.toSet.size == args.size
107+
if (argCheck)
108+
funInv = Some(fi)
109+
}
110+
case _ =>
111+
}(post)
108112
case _ =>
109-
}(fd.fullBody)
113+
}
110114
}
111115
}
112116

@@ -161,17 +165,11 @@ trait Trace extends CachingPhase with IdentityFunctions with IdentitySorts { sel
161165
val returnType = model.returnType
162166
val flags = Seq(s.Derived(lemma.id), s.Derived(model.id))
163167

164-
val fi = FunctionInvocation(model.id, newParamTps, newParamVars)
165-
166-
/*val body = FunctionInvocation(
167-
ast.SymbolIdentifier("stainless.lang.specialize"),
168-
fi.tps,
169-
Seq(fi)
170-
)*/
171-
172168
val body = FunctionInvocation(model.id, newParamTps, newParamVars)
173169
val indPattern = new s.FunDef(id, newParamTypes, newParams, returnType, body, flags)
174170

171+
val fi = FunctionInvocation(model.id, newParamTps, newParamVars)
172+
175173
class Specializer(
176174
origFd: FunDef,
177175
newId: Identifier,

core/src/main/scala/stainless/frontend/BatchedCallBack.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@ class BatchedCallBack(components: Seq[Component])(implicit val context: inox.Con
109109
}
110110
report = Report(reports)
111111
rerunPipeline = Trace.nextIteration(report)
112-
if (rerunPipeline) report.emit(context)
113-
else Trace.printEverything
112+
if (!rerunPipeline) Trace.printEverything
113+
//else report.emit(context)
114114
}
115115
}
116116

frontends/benchmarks/verification/valid/Count.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ object Count {
1717
}//ensuring(res => res == count1(p, l))
1818

1919
@traceInduct("")
20-
def count_check(p: BigInt => Boolean, l: List[BigInt]): Boolean = {
21-
count1(p, l) == count2(p, l)
22-
}.holds
23-
}
20+
def count_check(p: BigInt => Boolean, l: List[BigInt]): Unit = {
21+
()
22+
} ensuring (res => count1(p, l) == count2(p, l))
23+
}

frontends/benchmarks/verification/valid/Filter.scala

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ object Filter {
77

88
def filter1(p: BigInt => Boolean, l: List[BigInt], n: BigInt): List[BigInt] = {
99
require(l.size <= n)
10-
if(l.isEmpty) Nil()
10+
if (l.isEmpty) List()
1111
else if(p(l.head)) l.head::filter1(p, l.tail, n)
1212
else filter1(p, l.tail, n)
1313
}
@@ -18,8 +18,9 @@ object Filter {
1818
}
1919

2020
@traceInduct("")
21-
def filter_check(p: BigInt => Boolean, l: List[BigInt], n: BigInt): Boolean = {
21+
def filter_check(p: BigInt => Boolean, l: List[BigInt], n: BigInt): Unit = {
2222
require(l.size <= n)
23-
filter1(p, l, n) == filter2(p, l, n)
24-
}.holds
25-
}
23+
()
24+
} ensuring(filter1(p, l, n) == filter2(p, l, n))
25+
26+
}

frontends/benchmarks/verification/valid/Insert.scala

Lines changed: 0 additions & 29 deletions
This file was deleted.

frontends/benchmarks/verification/valid/Monotonicity.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ object Monotonicity {
1313
}
1414

1515
@traceInduct("")
16-
def monotonicity(l: List[BigInt], set1: Set[BigInt], set2: Set[BigInt]): Boolean = {
17-
(contains(l, set1, set2) && set1.subsetOf(set2)) ==> contains(l, set2, set1)
18-
}.holds
16+
def monotonicity(l: List[BigInt], set1: Set[BigInt], set2: Set[BigInt]): Unit = {
17+
()
18+
} ensuring((contains(l, set1, set2) && set1.subsetOf(set2)) ==> contains(l, set2, set1))
1919
}
2020

frontends/benchmarks/verification/valid/Reverse.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ object Reverse {
2020
}
2121

2222
@traceInduct("reverse0")
23-
def revPreservesContent(l1: IList, l2: IList): Boolean = {
24-
content(l1) ++ content(l2) == content(reverse0(l1, l2))
25-
}.holds
23+
def revPreservesContent(l1: IList, l2: IList): Unit = {
24+
()
25+
} ensuring (content(l1) ++ content(l2) == content(reverse0(l1, l2)))
2626
}
2727

frontends/benchmarks/verification/valid/Size.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ object Size {
1313
}) //ensuring(res => res >= 0)
1414

1515
@traceInduct("")
16-
def nonNegSize(l: IList): Boolean = {
17-
size(l) >= 0
18-
}.holds
16+
def nonNegSize(l: IList): Unit = {
17+
()
18+
} ensuring (size(l) >= 0)
1919
}
2020

frontends/benchmarks/verification/valid/Sorted.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ object Sorted {
2222
}//ensuring(res => res == sorted1(l))
2323

2424
@traceInduct("")
25-
def sorted_check(l: List[BigInt]): Boolean = {
26-
sorted1(l) == sorted2(l)
27-
}.holds
25+
def sorted_check(l: List[BigInt]): Unit = {
26+
()
27+
} ensuring (sorted1(l) == sorted2(l))
2828

2929
}

frontends/benchmarks/verification/valid/Zero.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ object Zero {
1414
}//ensuring(res => res == zero1(arg))
1515

1616
@traceInduct("")
17-
def zero_check(arg: BigInt): Boolean = {
18-
zero1(arg) == zero2(arg)
19-
}.holds
17+
def zero_check(arg: BigInt): Unit = {
18+
()
19+
} ensuring (zero1(arg) == zero2(arg))
2020

2121
}

0 commit comments

Comments
 (0)