login  home  contents  what's new  discussion  bug reports     help  links  subscribe  changes  refresh  edit

Edit detail for DesignIssues revision 1 of 2

1 2
Editor: page
Time: 2007/11/12 22:46:32 GMT-8
Note: transferred from axiom-developer.org

changed:
-
This should become a page where we document design issues.

'variables\$UP'

  Currently, Axiom says
\begin{axiom}
variables((x^2+2*x)::UP(x, INT))
\end{axiom}

The reason for this is, that 'UP' is a 'UPOLYC', which in turn is a 

'PolynomialCategory(R:Ring, E:OrderedAbelianMonoidSup, VarSet:OrderedSet)' 

with 'VarSet' being 'SingletonAsOrderedSet'. Hence it is currently not possible to instantiate 'variables' in 'UP' with a modeline other than
'% -> List SingletonAsOrderedSet', and since the latter domain only contains '"?"', we are out of luck.

This issue might be related to the following:

<A name="variables">[Where do variables belong?]</A>

  Currently, Axiom allows
\begin{axiom}
(1/x)::UP(x, FRAC POLY INT)
\end{axiom}

and

\begin{axiom}
(1/x)::UP(x, EXPR INT)
\end{axiom}

Similarly also for 'MPOLY', 'UTS' and the like. The issue is that it currently not clear to which domain in the tower a variable belongs to. Mathematically related is the item "'UEXPR'":WishList#UEXPR on the WishList.

<A name="RINTERPdesign">Interface of 'RINTERP'</A>

  I'm quite unsure what the interface of 'RINTERP' should look like. Originally, I just wanted to mimick the interface of 'PINTERP'. However, I'm not sure whether this is ideal. I'd rather fix both at once.

More to come, if there is interest.

From unknown Tue Apr 26 21:39:15 -0500 2005
From: unknown
Date: Tue, 26 Apr 2005 21:39:15 -0500
Subject: Expression Integer type
Message-ID: <20050426213915-0500@page.axiom-developer.org>

I tried to put this on my wiki home page, but I have no idea if it was successful or not.

Why do the following have Expression Integer type when they aren't integers:

\begin{axiom}
sin(x)
\end{axiom}

\begin{axiom}
asin(1)
\end{axiom}

\begin{axiom}
sqrt(%pi)
\end{axiom}

From BillPage Sun Oct 2 21:36:42 -0500 2005
From: Bill Page
Date: Sun, 02 Oct 2005 21:36:42 -0500
Subject: Re: Expression Integer type
Message-ID: <20051002213642-0500@wiki.axiom-developer.org>

Type 'Expression Integer' refers to any expression involving
functions (or operators) and integers. If you don't tell Axiom otherwise, then Axiom
"thinks" of 'sin(x)' as 'sin(1*x)' i.e. an 'Expression' involving the function 'sin()', a polynomial function 'x' with coefficient '1'. For example, what would you expect the
result of the expression 'sin(1.0*x)' to be?
\begin{axiom}
sin(1.0*x)
\end{axiom}

The type of the result of some calculation in Axiom is often
expressed as an object of the same type as the operands that
created it. So in your example 'asin(1)' is an 'Expression Integer'
for the same reason as sin(x) is an 'Expression Integer' and the
result is still an 'Expression Integer' even though Axiom decides
to display the value of 'asin(1)' in a more convenient form.
Ditto 'sqrt(%pi)'.

In princple it should be possible to ask Axiom to represent the
result of a calculation in a different form. E.g.
\begin{axiom}
asin(1)::Expression Float
sqrt(%pi)::Expression Float
\end{axiom}

But in some cases the result is unexpected. For example:
\begin{axiom}
asin(1)::Pi
\end{axiom}
'Pi' is a type for certain constant-valued expressions in $\pi$.
However in this case it seems that the domain Expression Integer
is not sufficiently complete to perform this conversion, though
it works in the other direction
\begin{axiom}
%pi/2
%::Expression Integer
\end{axiom}

<hr>
Comments from wyscc: 

This is a quite common problem whenever a result can be expressed in a subdomain. In this case, the subdomain is 'Pi'. The correct way to perform conversion of types in this situation is to 'retract', not 'coerce' since 'coerce' is supposedly always possible, whereas 'retract' is not. The Interpreter will use 'retract' if it is available even when '::' is used. However, 'Expression Integer' does not have 'RetractableTo(Pi)' (we can add this if we like). An example where this works is:

\begin{axiom}
4/3 * 6/2
(4/3 * 6/2)::Integer
retract(4/3 * 6/2)@Integer
\end{axiom}

whereas this fails.

\begin{axiom}
coerce(4/3*6/2)@Integer
\end{axiom}



This should become a page where we document design issues.

variables$UP

Currently, Axiom says

fricas
variables((x^2+2*x)::UP(x, INT))

\label{eq1}\left[ \mbox{\tt "?"}\right](1)
Type: List(SingletonAsOrderedSet?)

The reason for this is, that UP is a UPOLYC, which in turn is a

PolynomialCategory(R:Ring, E:OrderedAbelianMonoidSup, VarSet:OrderedSet)

with VarSet being SingletonAsOrderedSet. Hence it is currently not possible to instantiate variables in UP with a modeline other than % -> List SingletonAsOrderedSet, and since the latter domain only contains "?", we are out of luck.

This issue might be related to the following:

[Where do variables belong?]?

Currently, Axiom allows

fricas
(1/x)::UP(x, FRAC POLY INT)

\label{eq2}1 \over x(2)
Type: UnivariatePolynomial?(x,Fraction(Polynomial(Integer)))

and

fricas
(1/x)::UP(x, EXPR INT)

\label{eq3}1 \over x(3)
Type: UnivariatePolynomial?(x,Expression(Integer))

Similarly also for MPOLY, UTS and the like. The issue is that it currently not clear to which domain in the tower a variable belongs to. Mathematically related is the item UEXPR on the WishList?.

Interface of RINTERP

I'm quite unsure what the interface of RINTERP should look like. Originally, I just wanted to mimick the interface of PINTERP. However, I'm not sure whether this is ideal. I'd rather fix both at once.

More to come, if there is interest.

Expression Integer type --unknown, Tue, 26 Apr 2005 21:39:15 -0500 reply
I tried to put this on my wiki home page, but I have no idea if it was successful or not.

Why do the following have Expression Integer type when they aren't integers:

fricas
sin(x)

\label{eq4}\sin \left({x}\right)(4)
Type: Expression(Integer)

fricas
asin(1)

\label{eq5}\pi \over 2(5)
Type: Expression(Integer)

fricas
sqrt(%pi)

\label{eq6}\sqrt{\pi}(6)
Type: Expression(Integer)

Re: Expression Integer type --Bill Page, Sun, 02 Oct 2005 21:36:42 -0500 reply
Type Expression Integer refers to any expression involving functions (or operators) and integers. If you don't tell Axiom otherwise, then Axiom "thinks" of sin(x) as sin(1*x) i.e. an Expression involving the function sin(), a polynomial function x with coefficient 1. For example, what would you expect the result of the expression sin(1.0*x) to be?
fricas
sin(1.0*x)

\label{eq7}\sin \left({x}\right)(7)
Type: Expression(Float)

The type of the result of some calculation in Axiom is often expressed as an object of the same type as the operands that created it. So in your example asin(1) is an Expression Integer for the same reason as sin(x) is an Expression Integer and the result is still an Expression Integer even though Axiom decides to display the value of asin(1) in a more convenient form. Ditto sqrt(%pi).

In princple it should be possible to ask Axiom to represent the result of a calculation in a different form. E.g.

fricas
asin(1)::Expression Float

\label{eq8}1.5707963267_948966192(8)
Type: Expression(Float)
fricas
sqrt(%pi)::Expression Float

\label{eq9}1.7724538509_055160273(9)
Type: Expression(Float)

But in some cases the result is unexpected. For example:

fricas
asin(1)::Pi
Cannot convert from type Expression(Integer) to Pi for value %pi --- 2

Pi is a type for certain constant-valued expressions in \pi. However in this case it seems that the domain Expression Integer is not sufficiently complete to perform this conversion, though it works in the other direction

fricas
%pi/2

\label{eq10}\pi \over 2(10)
Type: Pi
fricas
%::Expression Integer

\label{eq11}\pi \over 2(11)
Type: Expression(Integer)


Comments from wyscc:

This is a quite common problem whenever a result can be expressed in a subdomain. In this case, the subdomain is Pi. The correct way to perform conversion of types in this situation is to retract, not coerce since coerce is supposedly always possible, whereas retract is not. The Interpreter will use retract if it is available even when :: is used. However, Expression Integer does not have RetractableTo(Pi) (we can add this if we like). An example where this works is:

fricas
4/3 * 6/2

\label{eq12}4(12)
Type: Fraction(Integer)
fricas
(4/3 * 6/2)::Integer

\label{eq13}4(13)
Type: Integer
fricas
retract(4/3 * 6/2)@Integer

\label{eq14}4(14)
Type: Integer

whereas this fails.

fricas
coerce(4/3*6/2)@Integer
An expression involving @ Integer actually evaluated to one of type PartialFraction(Integer) . Perhaps you should use :: Integer .