File: bookvol3.pamphlet

package info (click to toggle)
axiom 20170501-6
  • links: PTS
  • area: main
  • in suites: bullseye
  • size: 1,050,164 kB
  • sloc: javascript: 8,042; lisp: 3,600; makefile: 505; cpp: 223; ansic: 181; sh: 96
file content (176 lines) | stat: -rw-r--r-- 6,220 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
\documentclass[dvipdfmx]{book}
\newcommand{\VolumeName}{Volume 3: Axiom Programmers Guide}
\input{bookheader.tex}
\mainmatter
\setcounter{chapter}{0} % Chapter 1
\chapter{Details for Programmers}
Axiom maintains internal representations for domains.
There are functions for examining the internals of objects of
a particular domain. 
\section{Examining Internals}
One useful function is {\bf devaluate} which takes an object
and returns a Lisp pair. The CAR of the pair is the Axiom type.
The CDR of the pair is the object representation.
For instances, consider the session where we create a list of 
objects using the domain {\bf List(Any)}.
\begin{verbatim}
(1) -> w:=[1,7.2,"luanne",3*x^2+5,_
           (3*x^2+5)::FRAC(POLY(INT)),_
           (3*x^2+5)::POLY(FRAC(INT)),_
           (3*x^2+5)::EXPR(INT)]$LIST(ANY)

                          2       2       2       2
   (1)  [1,7.2,"luanne",3x  + 5,3x  + 5,3x  + 5,3x  + 5]
                                                              Type: List(Any)

\end{verbatim}
The first object, {\bf 1} is a primitive object that has the domain
{\bf PI} and uses the underlying Lisp representation for the number.
\begin{verbatim}
(2) -> devaluate(1)$Lisp

   (2)  1
                                                            Type: SExpression
\end{verbatim}
The second object, {\bf 7.2} is a primitive object that has the domain
{\bf FLOAT} and uses the underlying Lisp representation for the number,
in this case, itself a pair whose CAR is the floating point base and whose
CDR is the mantissa,
\begin{verbatim}
(3) -> devaluate(7.2)$Lisp

   (3)  (265633114661417543270 . - 65)
                                                            Type: SExpression
\end{verbatim}
The third object, {\tt {\bf "luanne"}} is from the domain {\bf STRING}
and uses the Lisp string representation.
\begin{verbatim}
(4) -> devaluate("luanne")$Lisp

   (4)  luanne
                                                            Type: SExpression
\end{verbatim}

Now we get more complicated. We illustrate various ways to store the
formula $3x^2+5$ in different domains. Each domain has a chosen 
representation. 

\begin{verbatim}
(5) -> devaluate(3*x^2+5)$Lisp

   (5)  (1 x (2 0 . 3) (0 0 . 5))
                                                            Type: SExpression
\end{verbatim}
The fourth object, $3x^2+5$ is from the domain {\bf POLY(INT)}. It is stored
as the list
\begin{verbatim}
   (1 x (2 0 . 3) (0 0 . 5))
\end{verbatim}
From the domain {\bf POLY} (Vol 10.3, POLY) we see that
\begin{verbatim}
   Polynomial(R:Ring): ...
      == SparseMultivariatePolynomial(R, Symbol) add ...
\end{verbatim}
So objects from this domain are represented as {\bf SMP(INT,SYMBOL)}. 
From this domain we ss that 
\begin{verbatim}
   SparseMultivariatePolynomial(R: Ring,VarSet: OrderedSet): ...
     == add
       --representations
       D := SparseUnivariatePolynomial(%)
\end{verbatim}
So objects from this domain are represented as a {\bf SUP(INT)}
\begin{verbatim}
   SparseUnivariatePolynomial(R:Ring): ...
     == PolynomialRing(R,NonNegativeInteger) add
\end{verbatim}
So objects from this domain are represented as {\bf PR(INT,NNI)}
\begin{verbatim}
   PolynomialRing(R:Ring,E:OrderedAbelianMonoid): ...
     FreeModule(R,E) add
       --representations
       Term:=  Record(k:E,c:R)
       Rep:=  List Term
\end{verbatim}
So objects from this domain are represented as {\bf FM(INT,NNI)}
\begin{verbatim}
   FreeModule(R:Ring,S:OrderedSet):
      == IndexedDirectProductAbelianGroup(R,S) add
        --representations
        Term:=  Record(k:S,c:R)
        Rep:=  List Term
\end{verbatim}
So objects from this domain are represented as {\bf IDPAG(INT,NNI)}
\begin{verbatim}
   IndexedDirectProductAbelianGroup(A:AbelianGroup,S:OrderedSet):
     ==  IndexedDirectProductAbelianMonoid(A,S) add
\end{verbatim}
So objects from this domain are represented as {\bf IDPAM(INT,NNI)}
\begin{verbatim}
   IndexedDirectProductAbelianMonoid(A:AbelianMonoid,S:OrderedSet):
     ==  IndexedDirectProductObject(A,S) add
       --representations
       Term:=  Record(k:S,c:A)
       Rep:=  List Term
\end{verbatim}
So objects from this domain are represented as {\bf IDPO(INT,NNI)}
\begin{verbatim}
IndexedDirectProductObject(A:SetCategory,S:OrderedSet):
 == add
       -- representations
       Term:=  Record(k:S,c:A)
       Rep:=  List Term
\end{verbatim}

\begin{verbatim}
(6) -> devaluate((3*x^2+5)::FRAC(POLY(INT)))$Lisp

   (6)  ((1 x (2 0 . 3) (0 0 . 5)) 0 . 1)
                                                            Type: SExpression
\end{verbatim}
\begin{verbatim}
(7) -> devaluate((3*x^2+5)::POLY(FRAC(INT)))$Lisp

   (7)  (1 x (2 0 3 . 1) (0 0 5 . 1))
                                                            Type: SExpression
\end{verbatim}
\begin{verbatim}
(8) -> devaluate((3*x^2+5)::EXPR(INT))$Lisp

   (8)  ((1 [[x,0,%symbol()()()],NIL,1,1024] (2 0 . 3) (0 0 . 5)) 0 . 1)
                                                            Type: SExpression
\end{verbatim}
\begin{verbatim}
(9) -> devaluate(w)$Lisp

   (9)
   (((PositiveInteger) . 1)  ((Float) 265633114661417543270 . - 65)
    ((String) . luanne)  ((Polynomial (Integer)) 1 x (2 0 . 3) (0 0 . 5))
    ((Fraction (Polynomial (Integer))) (1 x (2 0 . 3) (0 0 . 5)) 0 . 1)
    ((Polynomial (Fraction (Integer))) 1 x (2 0 3 . 1) (0 0 5 . 1))

     ((Expression (Integer))
      (1 [[x,0,%symbol()()()],NIL,1,1024] (2 0 . 3) (0 0 . 5))  0  .  1)
     )
                                                            Type: SExpression
\end{verbatim}


\section{Makefile}
This book is actually a literate program\cite{Knut92} and can contain 
executable source code. In particular, the Makefile for this book
is part of the source of the book and is included below. 
\eject
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\cleardoublepage
\phantomsection
\addcontentsline{toc}{chapter}{Bibliography}
\bibliographystyle{axiom}
\bibliography{axiom}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\cleardoublepage
\phantomsection
\addcontentsline{toc}{chapter}{Index}
\printindex
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\end{document}