In other ML-variants (such as SML) it is possible to do something like this:
case l of
(true, _) => false
| (false,true) => false
| (false,false) => true
However, doing a similar thing using the Why3ML match declaration raises a syntax error:
match l with
| (true, _) -> false
| (false,true) -> false
| (false,false) -> true
end
How do I correctly do value-based pattern matching inside a tuple?
Yes, it's possible:
Why3's pattern language is quite basic compared to SML or OCaml. The only values permitted in patterns in Why3 are constructors (not even e.g. integer constants are allowed), and only tuples can be destructured. This is why
TrueandFalseare used in the patterns above; they are in fact the proper constructors forbool--trueandfalseexist for convenience, but they won't work in patterns. See figure 7.2 in the grammar reference and take a look at the definition ofpattern.