Opened 3 years ago

Last modified 3 years ago

#25168 needs_review defect

Doctests: Symbolic expression matching bug

Reported by: rws Owned by:
Priority: major Milestone: sage-8.4
Component: symbolics Keywords:
Cc: Merged in:
Authors: Ralf Stephan Reviewers:
Report Upstream: N/A Work issues:
Branch: u/rws/25168-1 (Commits, GitHub, GitLab) Commit: 7f17534c420c0f3354fd97747c1a7d67971b2752
Dependencies: #25447, #24838 Stopgaps:

Status badges

Description (last modified by rws)

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/

Change History (9)

comment:1 Changed 3 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 3 years ago by rws

  • Branch set to u/rws/symbolic_expression_matching_bug

comment:3 Changed 3 years ago by git

  • Commit set to 2a22ae8b65c543d233b6bf38aefde5050e6d5dff

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

20ea22a25447: Support all GiNaC substitution flags
2a22ae8Merge branch 'u/rws/support_all_ginac_substitution_flags' of git:// into t/25168/symbolic_expression_matching_bug

comment:4 Changed 3 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 3 years ago by rws

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

comment:6 Changed 3 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:

b33fff4Merge branch 'u/rws/symbolic_expression_matching_bug' of git:// into HEAD
7f1753425168: remove bug comment

comment:7 Changed 3 years ago by rws

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

comment:8 Changed 3 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.