Discussion:
[fricas-devel] inconsistency
Ralf Hemmecke
2018-10-18 12:08:49 UTC
Permalink
Hi,

while testing my code I've made a very strange observation.

In fact, it appeared with the argument n*s^0, but when trying to write a
little package to demonstrate the problem, it became even more weird.

Look at attached packages. Foo just adds another argument to the
function (which it does not actually use), but suddenly the interpreter
thinks that it has to do "convenient"-coercion differently.

I can understand that (8) and (9) yield something unexpected, since the
interpreter has two choices of how to convert n (of type Qn) into
something of type Qns. Keeping the variable and extending the
coefficient domain, looks like the most natural thing (even though it is
wrong here).

I do, however, not understand that there is a difference between (12)
and (13) or (16) and (17). Clearly there is a function

*: (Qn, Qns) -> Qns.

Why does the interpreter prefer to first coerce n to Qns and only then
apply

*: (Qns, Qns) -> Qns

? I think that "intelligence" of the interpreter should be unlearned. In
other words, the interpreter should clearly prefer function applications
that do not involve a convenience coercion.

Why does the second parameter influence of what the interpreter does
with the arguments?

Any ideas?

Ralf
========================================================================


(1) -> Z ==> Integer; Q ==> Fraction Z; Qn ==> SparseUnivariatePolynomial Q
Type:
Void
(2) -> Qns ==> SparseUnivariatePolynomial Qn
Type:
Void
(3) -> n: Qn := monomial(1, 1)$Qn

(3) ?
Type:
SparseUnivariatePolynomial(Fraction(Integer))
(4) -> nn: Qns := monomial(n, 0)

(4) ?
Type:
SparseUnivariatePolynomial(SparseUnivariatePolynomial(Fraction(Integer)))
(5) -> s: Qns := monomial(1, 1)$Qns

(5) ?
Type:
SparseUnivariatePolynomial(SparseUnivariatePolynomial(Fraction(Integer)))
(6) -> f ==> foo $ Foo(Q)
Type:
Void
(7) -> b ==> bar $ Bar(Q)
Type:
Void
(8) -> f(n, n) = 0
?
1

(8) 1 = 0
Type:
Equation(Integer)
(9) -> b(n) = 0
?
1

(9) 1 = 0
Type:
Equation(Integer)
(10) -> f(s, n) = 1
?
1

(10) 1 = 1
Type:
Equation(Integer)
(11) -> b(s) = 1
?
1

(11) 1 = 1
Type:
Equation(Integer)
(12) -> f(n*s^1, n) = 1
2
?
1

(12) 2 = 1
Type:
Equation(Integer)
(13) -> b(n*s^1) = 1
? ?
?

(13) 1 = 1
Type:
Equation(Integer)
(14) -> f(nn*s^1, n) = 1
? ?
?

(14) 1 = 1
Type:
Equation(Integer)
(15) -> b(nn*s^1) = 1
? ?
?

(15) 1 = 1
Type:
Equation(Integer)
(16) -> f(n*s^0, n) = 0
?
1

(16) 1 = 0
Type:
Equation(Integer)
(17) -> b(n*s^0) = 0
?
?

(17) 0 = 0
Type:
Equation(Integer)
(18) -> f(nn*s^0, n) = 0
?
?

(18) 0 = 0
Type:
Equation(Integer)
(19) -> b(nn*s^0) = 0
?
?

(19) 0 = 0
Type:
Equation(Integer)
--
You received this message because you are subscribed to the Google Groups "FriCAS - computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fricas-devel+***@googlegroups.com.
To post to this group, send email to fricas-***@googlegroups.com.
Visit this group at https://groups.google.com/group/fricas-devel.
For more options, visit https://groups.google.com/d/optout.
Loading...