Skip to content

Commit 088ab0c

Browse files
committed
Factor out subfunction to find mutually recursive functions
1 parent cfe61d7 commit 088ab0c

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

core/src/main/scala/stainless/termination/MeasureInference.scala

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,18 @@ trait MeasureInference
5959
}
6060
}
6161

62+
def mutuallyRecursiveWithoutMeasure(id: Identifier): Option[Identifier] = {
63+
symbols.dependencies(id).find(id2 =>
64+
symbols.lookupFunction(id2).exists(fd2 =>
65+
symbols.dependencies(id2).contains(id) &&
66+
!fd2.measure(symbols).isEmpty
67+
)
68+
)
69+
}
70+
6271
def needsMeasure(fd: FunDef): Boolean = {
6372
if (symbols.isRecursive(fd.id) && fd.measure(symbols).isEmpty) {
64-
symbols.dependencies(fd.id).find(id =>
65-
symbols.lookupFunction(id).exists(fd2 =>
66-
symbols.dependencies(fd2.id).contains(fd.id) &&
67-
!fd2.measure(symbols).isEmpty
68-
)
69-
) match {
73+
mutuallyRecursiveWithoutMeasure(fd.id) match {
7074
case None =>
7175
true
7276
case Some(id) =>

0 commit comments

Comments
 (0)