23

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.

Szabolcs
  • 234,956
  • 30
  • 623
  • 1,263
march
  • 23,399
  • 2
  • 44
  • 100
  • march, thanks for posting this question. I think it is written quite clearly. – Mr.Wizard Jul 26 '16 at 22:17
  • 16
    Reporting as a bug. – Daniel Lichtblau Jul 26 '16 at 23:25
  • 3
    @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. – Mr.Wizard Jul 27 '16 at 16:27
  • @Mr.Wizard I am not aware of any work around. I apologize for the inconvenience. – Daniel Lichtblau Jul 27 '16 at 17:46
  • @DanielLichtblau. Any progress on this? Has it been fixed in any of the versions since 11.0? – march Feb 19 '19 at 23:13
  • 1
    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). – Daniel Lichtblau Feb 19 '19 at 23:46
  • I cannot reproduce this in M11.0.1. Why does the header say persisting through 11.0? Was is present in 11.0.0 but fixed in 11.0.1? I will make a preliminary edit to the header. Please adjust as needed. – Szabolcs Apr 25 '19 at 16:14
  • @Szabolcs. I don't know why it said that it was persisting through 11.0 (but it turns that you made the original edit that said that! -- so maybe you had access to 11.0 at the time and it wasn't fixed?) – march Apr 25 '19 at 16:21
  • Ha! Indeed it was me. – Szabolcs Apr 25 '19 at 16:22

0 Answers0