Unexpected expansion of recursive functions leading to non-termination #7256
Unanswered
CyrilFMoser
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am trying to model a pattern match expression of Scala in Z3. With that model I then try to determine whether the pattern match is exhaustive or not.
As far as I have seen with my testing, if the pattern match is exhaustive, it is able to tell that is the case very quickly. But if it is not correct, it very often does not terminate. I would have thought that it would be way easier for it to figure out that a pattern match is not exhaustive?
This is an example of the latter case:
This is an inexhaustive pattern match with the case
CC_C()
missing. But even if I constrain the variable to beCC_C
Z3 is not able to prove that such a type exists and simply does not terminate. (Maybe I should have waited for longer, but I feel like it should almost instantly recognize that there is an issue here).In the statistics it says that it keeps expanding the recfun macros (ludicrous amounts). From the limited tests I can do to still get the same result, I feel like the issue is the function that determines whether an expression is matched and with it the subcase function.
I also feel like there is something weird happening with the solver strategy here, because it does not need to expand subcase more than once, as there is no subcase between
CC_A
/CC_B
andCC_C
as you can see below:Every
and
is simply another case for a combination oftyp1
andtyp2
to determine whethertyp1 <: typ2
. As you can see there is no case that allowsCC_C
to be a subtype of anything except forWildcards
CC_C
T_A
None of the 3 are present in the pattern match. So if
typ1
is constrained to beCC_C
it can't be matched. This is thematches_condition
:And these are the definitions for
pattern_0
andpattern_1
:Now I would simply blame it on Z3 being unlucky, but it doesn't make sense to me that it would expand a function if it didn't have to. So I believe something has to be wrong on my end.
If it helps, this would be the entirety of the program, but I believe the most important parts are above:
Beta Was this translation helpful? Give feedback.
All reactions