Internal vs language type names

Let me call them this way. I wonder whether there is a "conversion" table between these names. Examples:

objectid:=x->kernelopts(dagtag=disassemble(addressof(x))[1]):  

-1;objectid(%);
type(%%,negint);

                                  -1

                                INTNEG

                                 true

1;objectid(%);
type(%%,posint);

                                  1

                                INTPOS

                                 true

x>1;objectid(%);
type(%%,`<`);

                                1 < x

                               LESSTHAN

                                 true

2/5;objectid(%);
type(%%,fraction);

                                 2/5

                               RATIONAL

                                 true

These conversions are not available in (its natural place?) the Maple Advanced Programming Guide, A.2 Internal Representations of Data Types. And I do not find them trivial either.

Eg. the order of the components of the names is permuted here:

negint <-> INTNEG

posint <-> INTPOS

Any pointer to such a table?

dagtags

It isn't hard to figure out what the conversion is, though not all dagtags can be represented as a normal Maple object.  To print the dagtags, do

for i do try lprint(kernelopts(dagtag=i)); catch: break; end try; end do:

Note that the type that matches an expression doesn't necessarily match the dagtag. For example,

type(3*a, `+`);
                                 false
type(3*a, `*`);
                                 true
dismantle(3*a);
SUM(3)
   NAME(4): a
   INTPOS(2): 3

 

types, dagtags and headers

Yes, for column output it is fine. I have been using:

kernelopts(memusage)[1..,1];

and

seq( [i,kernelopts( dagtag = i )], i = 1..61 );

to see also their numbers.

Now, this appendix states:

All the internal data structures have the same general format: Header Data1 ... Datan ...

The header field, stored in one or more machine words, encodes the length of the structure and its type.

As written here, it sounds that there is a one-to-one correspondence: header-dagtag-type. Probably this paragraph should be improved.

And what about the correspondence of types with the output of 'ToInert'? Here:

ToInert(3*a);

_Inert_PROD(_Inert_NAME("a"),_Inert_INTPOS(3))

?ToInert states:

Inert forms closely mirror the Maple internal DAG data structure representation.

How close is "closely"?

Differences

Keep reading, same paragraph:

There are some differences between the internal representation and the inert representation, mostly in the cases of sums and products, as the internal representation is designed for fast polynomial arithmetic as opposed to convenient programmatic manipulation. For the exact internal representation, see dismantle.

 For a list of the various Maple DAGs, refer to "Appendix A: Internal
  Representation and Manipulation" in the Maple Advanced Programming Guide.

If you look at the programming manual, you'll see that a SUM dag is an n-ary linear combination without need for internal PRODs.  Dismantle shows the lack of PRODs in that case, while ToIntert shows PRODs:

> dismantle(1*x+3*y+3*z);  

SUM(7)
   NAME(4): x
   INTPOS(2): 1
   NAME(4): y
   INTPOS(2): 3
   NAME(4): z
   INTPOS(2): 3

> ToInert(1*x+3*y+3*z);  
_Inert_SUM(_Inert_NAME("x"), _Inert_PROD(_Inert_NAME("y"), _Inert_INTPOS(3)),
 _Inert_PROD(_Inert_NAME("z"), _Inert_INTPOS(3)))

Similarly, a PROD dag is an n-ary product of powers without need for internal POWER dags.

Also, that the ToInert return appears as the expression tree rather than the DAG structure. It doesn't seem to have a facility for reusing subexpressions which would be required for mirroring the DAG more directly.

some differences

OK, but this help page does not show a list of those differences. In particular, are these differences exactly the same as those between types and dagtags?

another paragraph

that seems to me confusing in the light of the current discussion.

?assemble:

The object identifier objectid represents the type of the object, and can be expressed as an integer, or as a symbolic name. The valid object identifier names are:

[list of object identifiers, aka dagtags]

dagtags

I'm not sure what confuses you.  It is saying that you can replace the first item in the sequence used to assemble an object with its symbolic dagtag.  For example:

tmp := disassemble(addressof(3*x));
                                    tmp := 16, 136157948, 7
pointto(assemble(SUM, tmp[2..]));
                                             3*x

If you know how dagtags work, you should be able to guess what the following returns

pointto(assemble(PROD, tmp[2..]));

 

What it says

is that: The object identifier objectid represents the type of the object. And clearly, from your example, these object identifiers and the types are not equivalent. So, the objectid cannot represent the type.

Yes

I see now.  Presumably the help page is using the more general sense of type rather than the Maple type.

In short

I think that it is fair to say that there are (at least) three inequivalent sets of identifiers for Maple objects: dagtags, types and inert headers. And that the differences between them are not fully documented.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
}