Ask Your Question

Revision history [back]

This is not really a problem with type checking. The substitution code of symbolic expression assumes that you want to create a symbolic expression. It does "evaluate" the expression as you would like.

sage: x,y = SR.var('x, y')
sage: expr_symb = x + y
sage: expr_synb.subs(x=1, y=3).parent()
Symbolic Ring

Note that the same behavior can be observed for multivariate polynomials

sage: R = ZZ['x,y']
sage: x,y = R.gens()
sage: expr_poly = x + y
sage: expr_poly..subs(x=1, y=3)parent()
Multivariate Polynomial Ring in x, y over Integer Ring

What you want is a form of "function call". It sort of works for polynomials

sage: expr_poly(1, 3).parent()
Integer Ring
sage: expr_poly(x=1, y=3).parent()   # hum... inconsistency?
Multivariate Polynomial Ring in x, y over Integer Ring

But the symbolic ring never spits out an integer

sage: expr_symb(1, 3).parent()
Symbolic Ring
sage: expr_symb(x=1, y=3).parent()
Symbolic Ring

(My) conclusion: this is a desirable feature that is not available. The current behavior is a bit consistent. But we still want to distinguish an "internal substitution" and an "external substitution".