Opened 11 months ago

Last modified 6 weeks ago

#32008 new enhancement

CallableSymbolicExpressionRing over subrings of SR

Reported by: mkoeppe Owned by:
Priority: major Milestone: sage-9.7
Component: symbolics Keywords:
Cc: rburing, slelievre, egourgoulhon, tscrim, dkrenn Merged in:
Authors: Reviewers:
Report Upstream: N/A Work issues:
Branch: u/mkoeppe/callablesymbolicexpressionring_over_subrings_of_sr (Commits, GitHub, GitLab) Commit: f71de5b9a42aecde807e42aaecc9a2329a2bbef3
Dependencies: Stopgaps:

Status badges

Description (last modified by mkoeppe)

  1. Currently, CallableSymbolicExpressionRing allows meaningless operations such as the following.
    sage: f(t) = t
    sage: f
    t |--> t
    sage: f * t
    t |--> t^2
    
    This should be changed so it gives:
    _dummy |--> _dummy * t
    
    f currently is an element of a CallableSymbolicExpressionRing, a ring over the base SR (the only allowed base for this class).
  1. The design of CallableSymbolicExpressionRing has another critical flaw pointed out in #28434 (Syntax for callable symbolic expressions causes too much confusion) as "7. Addition confusion":
    sage: f(x) = x^2
    sage: g(x) = x^2
    sage: var('t')
    sage: h(t) = t^2
    sage: f+g
    x |--> 2*x^2
    sage: f+h
    (t, x) |--> t^2 + x^2
    

In this ticket:

  • We remove the distinction between the CallableSymbolicExpressionRing instances based on the names of the argument variable names. Instead, they will be unique by number of arguments, and the set of non-argument symbols that appear in the definition.
  • The element constructor substitutes the arguments in the expression by dummy variables, i.e., unique internal symbols that are only used for this purpose. The argument names are substituted back only in _repr_ and when converted into SR by SymbolicRing._element_constructor_
  • We extend the class to support base rings that are subrings of SR. Then we change the default base ring of a callable expression to be the subring of SR that rejects all dummy variables.

Related:

  • #18259 (comparison of symbolic functions)
  • #19949 (composition of symbolic subring functors)

Change History (12)

comment:1 Changed 11 months ago by mkoeppe

  • Description modified (diff)

comment:2 Changed 11 months ago by mkoeppe

  • Branch set to u/mkoeppe/callablesymbolicexpressionring_over_subrings_of_sr

comment:3 Changed 11 months ago by git

  • Commit set to f71de5b9a42aecde807e42aaecc9a2329a2bbef3

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

b5a0bbeExpression.function: Pass parent to CallableSymbolicExpressionRing as base ring
f71de5bWIP coercion

comment:4 Changed 11 months ago by mkoeppe

With this version, we get:

sage: var('a b c')
(a, b, c)
sage: (a*b*c).function(a, b)
(a, b) |--> a*b*c
sage: _.parent()
Callable function ring with arguments (a, b) over Symbolic Subring rejecting the variables a, b
sage: (a*b*c).function(a, b) * b
TypeError: unsupported operand parent(s) for *: 'Callable function ring with arguments (a, b) over Symbolic Subring rejecting the variables a, b' and 'Symbolic Ring'
sage: (a*b*c).function(a, b) * SR.subring([x])(x)
(a, b) |--> a*b*c*x

comment:5 Changed 10 months ago by mkoeppe

  • Cc rburing slelievre egourgoulhon tscrim added
  • Description modified (diff)

comment:6 Changed 10 months ago by mkoeppe

  • Cc dkrenn added
  • Description modified (diff)

comment:7 Changed 10 months ago by mkoeppe

  • Description modified (diff)

comment:8 Changed 10 months ago by mkoeppe

  • Description modified (diff)

comment:9 Changed 10 months ago by mkoeppe

  • Description modified (diff)

comment:10 Changed 10 months ago by mkoeppe

  • Milestone changed from sage-9.4 to sage-9.5

comment:11 Changed 5 months ago by mkoeppe

  • Milestone changed from sage-9.5 to sage-9.6

comment:12 Changed 6 weeks ago by mkoeppe

  • Milestone changed from sage-9.6 to sage-9.7
Note: See TracTickets for help on using tickets.