Opened 4 years ago

Doctests: Symbolic expression matching bug

Reported by: Owned by: rws major sage-8.4 symbolics Ralf Stephan N/A u/rws/25168-1 7f17534c420c0f3354fd97747c1a7d67971b2752 #25447, #24838

This is from GiNaC:

```sage: w0=SR.wild(0); w1=SR.wild(1); w2=SR.wild(2)
sage: (sqrt(c+x)*x).match(w0 * sqrt(w0+w1))
sage: (sqrt(c+x)*x).match(w1 * sqrt(w0+w1))
{\$0: c, \$1: x}
ssage: (sqrt(c*x)*x).match(w0 * sqrt(w0*w1))  # no output: fail
sage: (sqrt(c*x)*x).match(w1 * sqrt(w0*w1))
{\$0: c, \$1: x}
```

Matching practically works if wildcards are not repeated. This means it's unusable for serious work.

This branch adds extensive doctest cases in a file under `tests/`

comment:1 Changed 4 years ago by rws

It should be noted that GiNaC's match() also does not differentiate between regular and sequence variables, they behave as regular in nonassociative functions, but as sequence in sums and products. This means that `(a+b).match(a+b+w0)` will match with `w0:0`. This can no longer be changed as it's established by now. It however complicates real commutative matching (if done right) by a great deal.

In contrast Mathematica differentiates between `f[a + b + u_] := u` where `f` does not match `a+b`, and `f[a + b + u___] := u` with `f[a + b] = Sequence[]`.

comment:2 Changed 4 years ago by rws

• Branch set to u/rws/symbolic_expression_matching_bug

comment:3 Changed 4 years ago by git

• Commit set to 2a22ae8b65c543d233b6bf38aefde5050e6d5dff

Branch pushed to git repo; I updated commit sha1. New commits:

 ​20ea22a `25447: Support all GiNaC substitution flags` ​2a22ae8 `Merge branch 'u/rws/support_all_ginac_substitution_flags' of git://trac.sagemath.org/sage into t/25168/symbolic_expression_matching_bug`

comment:4 Changed 4 years ago by rws

• Authors set to Ralf Stephan
• Dependencies set to #25447, pynac-0.7.20
• Milestone changed from sage-8.2 to sage-8.3

comment:5 Changed 4 years ago by rws

• Branch changed from u/rws/symbolic_expression_matching_bug to u/rws/25168-1

comment:6 Changed 4 years ago by rws

• Commit changed from 2a22ae8b65c543d233b6bf38aefde5050e6d5dff to 7f17534c420c0f3354fd97747c1a7d67971b2752
• Dependencies changed from #25447, pynac-0.7.20 to #25447, #24868
• Status changed from new to needs_review

New commits:

 ​b33fff4 `Merge branch 'u/rws/symbolic_expression_matching_bug' of git://trac.sagemath.org/sage into HEAD` ​7f17534 `25168: remove bug comment`

comment:7 Changed 4 years ago by rws

• Dependencies changed from #25447, #24868 to #25447, #24838

comment:8 Changed 4 years ago by rws

• Description modified (diff)
• Summary changed from Symbolic expression matching bug to Doctests: Symbolic expression matching bug

comment:9 Changed 3 years ago by vdelecroix

• Milestone changed from sage-8.3 to sage-8.4

update milestone 8.3 -> 8.4

Note: See TracTickets for help on using tickets.