21
$\begingroup$

Bug introduced in 10.1 and fixed in 11.0(.1)


In making an attempt to answer this question, we ran into a version-dependent pattern-matching issue. An extended discussion in the comments transpired, and some inconsistencies arose. Consider the following expressions:

MatchQ[f[a + 3, b + 3, c + 3], f[pat : (_ + n_) ..]]
MatchQ[f[a + 3, b + 3, c + 3], f[Verbatim[Plus][___, n_, ___] ..]]

On all of the machines and version I have access to, these expressions evaluate to True, including

  1. V10.0.1 under Mac OS 10.10.5

  2. V 8.0 under Windows

  3. 7.0.1 under Windows

So far, in the following version-OS combinations, the expressions evaluate to False:

  1. 10.4.0 / Win7-64

  2. 10.1.0 under Windows 7 x64

It seems as if something has changed between V10.0 and V10.1, and we'd like to pinpoint what it is.

It was noted that if the pattern is changed to

f[pat : (n_Integer + _) ..]

then the expression evaluates to True.

This might be related to a similar issue outlined in Pattern does not match with Orderless head and answered by Mr. Wizard there, where it seems like the pattern-matching algorithm does not attempt to match every permutation of an expression inside a function (like Plus) that has the Orderless attribute, and that might be an issue here.

So what is going on, and what has changed?

Note 1

Since I cannot test to see which Patterns fail, anyone who can find a simpler example of the pattern that matches in earlier versions but doesn't in later versions should edit this post with those simpler patterns.

$\endgroup$
  • $\begingroup$ march, thanks for posting this question. I think it is written quite clearly. $\endgroup$ – Mr.Wizard Jul 26 '16 at 22:17
  • 16
    $\begingroup$ Reporting as a bug. $\endgroup$ – Daniel Lichtblau Jul 26 '16 at 23:25
  • 3
    $\begingroup$ @Daniel If a work-around is found, e.g. a System Option that can be reverted to an earlier value, please let us know. I may not be able to upgrade from 10.1.0 for some time and it is disturbing to know that something as fundamental as the pattern matching engine in my copy is not behaving as it should. $\endgroup$ – Mr.Wizard Jul 27 '16 at 16:27
  • $\begingroup$ @Mr.Wizard I am not aware of any work around. I apologize for the inconvenience. $\endgroup$ – Daniel Lichtblau Jul 27 '16 at 17:46
  • 1
    $\begingroup$ They both give True in the current version. Which probably could be tested by logging into the Wolfram Cloud (there is a free way to do this). $\endgroup$ – Daniel Lichtblau Feb 19 at 23:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.