/usr/share/axiom-20170501/src/algebra/OUTFORM.spad is in axiom-source 20170501-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 | )abbrev domain OUTFORM OutputForm
++ Author: SMW March/88
++ Description:
++ This domain is used to create and manipulate mathematical expressions
++ for output. It is intended to provide an insulating layer between
++ the expression rendering software (for example, FORTRAN or TeX) and
++ the output coercions in the various domains.
OutputForm() : SIG == CODE where
SIG ==> SetCategory with
print : $ -> Void
++ print(u) prints the form u.
message : String -> $
++ message(s) creates an form with no string quotes
++ from string s.
messagePrint : String -> Void
++ messagePrint(s) prints s without string quotes. Note:
++ \spad{messagePrint(s)} is equivalent to \spad{print message(s)}.
--% Creation of atomic forms
outputForm : Integer -> $
++ outputForm(n) creates an form for integer n.
outputForm : Symbol -> $
++ outputForm(s) creates an form for symbol s.
outputForm : String -> $
++ outputForm(s) creates an form for string s.
outputForm : DoubleFloat -> $
++ outputForm(sf) creates an form for small float sf.
empty : () -> $
++ empty() creates an empty form.
--% Sizings
width : $ -> Integer
++ width(f) returns the width of form f (an integer).
height : $ -> Integer
++ height(f) returns the height of form f (an integer).
width : -> Integer
++ width() returns the width of the display area (an integer).
height : -> Integer
++ height() returns the height of the display area (an integer).
subHeight : $ -> Integer
++ subHeight(f) returns the height of form f below the base line.
superHeight : $ -> Integer
++ superHeight(f) returns the height of form f above the base line.
--% Space manipulations
hspace : Integer -> $
++ hspace(n) creates white space of width n.
vspace : Integer -> $
++ vspace(n) creates white space of height n.
rspace : (Integer,Integer) -> $
++ rspace(n,m) creates rectangular white space, n wide by m high.
--% Area adjustments
left : ($,Integer) -> $
++ left(f,n) left-justifies form f within space of width n.
right : ($,Integer) -> $
++ right(f,n) right-justifies form f within space of width n.
center : ($,Integer) -> $
++ center(f,n) centers form f within space of width n.
left : $ -> $
++ left(f) left-justifies form f in total space.
right : $ -> $
++ right(f) right-justifies form f in total space.
center : $ -> $
++ center(f) centers form f in total space.
--% Area manipulations
hconcat : ($,$) -> $
++ hconcat(f,g) horizontally concatenate forms f and g.
vconcat : ($,$) -> $
++ vconcat(f,g) vertically concatenates forms f and g.
hconcat : List $ -> $
++ hconcat(u) horizontally concatenates all forms in list u.
vconcat : List $ -> $
++ vconcat(u) vertically concatenates all forms in list u.
--% Application formers
prefix : ($, List $) -> $
++ prefix(f,l) creates a form depicting the n-ary prefix
++ application of f to a tuple of arguments given by list l.
infix : ($, List $) -> $
++ infix(f,l) creates a form depicting the n-ary application
++ of infix operation f to a tuple of arguments l.
infix : ($, $, $) -> $
++ infix(op, a, b) creates a form which prints as: a op b.
postfix : ($, $) -> $
++ postfix(op, a) creates a form which prints as: a op.
infix? : $ -> Boolean
++ infix?(op) returns true if op is an infix operator,
++ and false otherwise.
elt : ($, List $) -> $
++ elt(op,l) creates a form for application of op
++ to list of arguments l.
--% Special forms
string : $ -> $
++ string(f) creates f with string quotes.
label : ($, $) -> $
++ label(n,f) gives form f an equation label n.
box : $ -> $
++ box(f) encloses f in a box.
matrix : List List $ -> $
++ matrix(llf) makes llf (a list of lists of forms) into
++ a form which displays as a matrix.
zag : ($, $) -> $
++ zag(f,g) creates a form for the continued fraction form for f over g.
root : $ -> $
++ root(f) creates a form for the square root of form f.
root : ($, $) -> $
++ root(f,n) creates a form for the nth root of form f.
over : ($, $) -> $
++ over(f,g) creates a form for the vertical fraction of f over g.
slash : ($, $) -> $
++ slash(f,g) creates a form for the horizontal fraction of f over g.
assign : ($, $) -> $
++ assign(f,g) creates a form for the assignment \spad{f := g}.
rarrow : ($, $) -> $
++ rarrow(f,g) creates a form for the mapping \spad{f -> g}.
differentiate : ($, NonNegativeInteger) -> $
++ differentiate(f,n) creates a form for the nth derivative of f,
++ for example, \spad{f'}, \spad{f''}, \spad{f'''},
++ "f super \spad{iv}".
binomial : ($, $) -> $
++ binomial(n,m) creates a form for the binomial coefficient of n and m.
--% Scripts
sub : ($, $) -> $
++ sub(f,n) creates a form for f subscripted by n.
super : ($, $) -> $
++ super(f,n) creates a form for f superscripted by n.
presub : ($, $) -> $
++ presub(f,n) creates a form for f presubscripted by n.
presuper : ($, $) -> $
++ presuper(f,n) creates a form for f presuperscripted by n.
scripts : ($, List $) -> $
++ \spad{scripts(f, [sub, super, presuper, presub])}
++ creates a form for f with scripts on all 4 corners.
supersub : ($, List $) -> $
++ supersub(a,[sub1,super1,sub2,super2,...])
++ creates a form with each subscript aligned
++ under each superscript.
--% Diacritical marks
quote : $ -> $
++ quote(f) creates the form f with a prefix quote.
dot : $ -> $
++ dot(f) creates the form with a one dot overhead.
dot : ($, NonNegativeInteger) -> $
++ dot(f,n) creates the form f with n dots overhead.
prime : $ -> $
++ prime(f) creates the form f followed by a suffix prime (single quote).
prime : ($, NonNegativeInteger) -> $
++ prime(f,n) creates the form f followed by n primes.
overbar : $ -> $
++ overbar(f) creates the form f with an overbar.
overlabel : ($, $) -> $
++ overlabel(x,f) creates the form f with "x overbar" over the top.
--% Plexes
sum : ($) -> $
++ sum(expr) creates the form prefixing expr by a capital sigma.
sum : ($, $) -> $
++ sum(expr,lowerlimit) creates the form prefixing expr by
++ a capital sigma with a lowerlimit.
sum : ($, $, $) -> $
++ sum(expr,lowerlimit,upperlimit) creates the form prefixing expr by
++ a capital sigma with both a lowerlimit and upperlimit.
prod : ($) -> $
++ prod(expr) creates the form prefixing expr by a capital pi.
prod : ($, $) -> $
++ prod(expr,lowerlimit) creates the form prefixing expr by
++ a capital pi with a lowerlimit.
prod : ($, $, $) -> $
++ prod(expr,lowerlimit,upperlimit) creates the form prefixing expr by
++ a capital pi with both a lowerlimit and upperlimit.
int : ($) -> $
++ int(expr) creates the form prefixing expr with an integral sign.
int : ($, $) -> $
++ int(expr,lowerlimit) creates the form prefixing expr by an
++ integral sign with a lowerlimit.
int : ($, $, $) -> $
++ int(expr,lowerlimit,upperlimit) creates the form prefixing expr by
++ an integral sign with both a lowerlimit and upperlimit.
--% Matchfix forms
brace : $ -> $
++ brace(f) creates the form enclosing f in braces (curly brackets).
brace : List $ -> $
++ brace(lf) creates the form separating the elements of lf
++ by commas and encloses the result in curly brackets.
bracket : $ -> $
++ bracket(f) creates the form enclosing f in square brackets.
bracket : List $ -> $
++ bracket(lf) creates the form separating the elements of lf
++ by commas and encloses the result in square brackets.
paren : $ -> $
++ paren(f) creates the form enclosing f in parentheses.
paren : List $ -> $
++ paren(lf) creates the form separating the elements of lf
++ by commas and encloses the result in parentheses.
--% Separators for aggregates
pile : List $ -> $
++ pile(l) creates the form consisting of the elements of l which
++ displays as a pile, the elements begin on a new line and
++ are indented right to the same margin.
commaSeparate : List $ -> $
++ commaSeparate(l) creates the form separating the elements of l
++ by commas.
semicolonSeparate : List $ -> $
++ semicolonSeparate(l) creates the form separating the elements of l
++ by semicolons.
blankSeparate : List $ -> $
++ blankSeparate(l) creates the form separating the elements of l
++ by blanks.
--% Specific applications
"=" : ($, $) -> $
++ f = g creates the equivalent infix form.
"^=" : ($, $) -> $
++ f ^= g creates the equivalent infix form.
"<" : ($, $) -> $
++ f < g creates the equivalent infix form.
">" : ($, $) -> $
++ f > g creates the equivalent infix form.
"<=" : ($, $) -> $
++ f <= g creates the equivalent infix form.
">=" : ($, $) -> $
++ f >= g creates the equivalent infix form.
"+" : ($, $) -> $
++ f + g creates the equivalent infix form.
"-" : ($, $) -> $
++ f - g creates the equivalent infix form.
"-" : ($) -> $
++ - f creates the equivalent prefix form.
"*" : ($, $) -> $
++ f * g creates the equivalent infix form.
"/" : ($, $) -> $
++ f / g creates the equivalent infix form.
"**" : ($, $) -> $
++ f ** g creates the equivalent infix form.
"div" : ($, $) -> $
++ f div g creates the equivalent infix form.
"rem" : ($, $) -> $
++ f rem g creates the equivalent infix form.
"quo" : ($, $) -> $
++ f quo g creates the equivalent infix form.
"exquo" : ($, $) -> $
++ exquo(f,g) creates the equivalent infix form.
"and" : ($, $) -> $
++ f and g creates the equivalent infix form.
"or" : ($, $) -> $
++ f or g creates the equivalent infix form.
"not" : ($) -> $
++ not f creates the equivalent prefix form.
SEGMENT : ($,$) -> $
++ SEGMENT(x,y) creates the infix form: \spad{x..y}.
SEGMENT : ($) -> $
++ SEGMENT(x) creates the prefix form: \spad{x..}.
CODE ==> add
import NumberFormats
-- Todo:
-- program forms, greek letters
-- infix, prefix, postfix, matchfix support in OUT BOOT
-- labove rabove, corresponding overs.
-- better super script, overmark, undermark
-- bug in product, paren blankSeparate []
-- uniformize integrals, products, etc as plexes.
cons ==> CONS$Lisp
car ==> CAR$Lisp
cdr ==> CDR$Lisp
Rep := List $
a, b: $
l: List $
s: String
e: Symbol
n: Integer
nn:NonNegativeInteger
sform: String -> $
eform: Symbol -> $
iform: Integer -> $
print x == mathprint(x)$Lisp
message s == (empty? s => empty(); s pretend $)
messagePrint s == print message s
(a:$ = b:$):Boolean == EQUAL(a, b)$Lisp
(a:$ = b:$):$ == [sform "=", a, b]
coerce(a):OutputForm == a pretend OutputForm
outputForm n == n pretend $
outputForm e == e pretend $
outputForm(f:DoubleFloat) == f pretend $
sform s == s pretend $
eform e == e pretend $
iform n == n pretend $
outputForm s ==
sform concat(quote()$Character, concat(s, quote()$Character))
width(a) == outformWidth(a)$Lisp
height(a) == height(a)$Lisp
subHeight(a) == subspan(a)$Lisp
superHeight(a) == superspan(a)$Lisp
height() == 20
width() == 66
center(a,w) == hconcat(hspace((w - width(a)) quo 2),a)
left(a,w) == hconcat(a,hspace((w - width(a))))
right(a,w) == hconcat(hspace(w - width(a)),a)
center(a) == center(a,width())
left(a) == left(a,width())
right(a) == right(a,width())
vspace(n) ==
n = 0 => empty()
vconcat(sform " ",vspace(n - 1))
hspace(n) ==
n = 0 => empty()
sform(fillerSpaces(n)$Lisp)
rspace(n, m) ==
n = 0 or m = 0 => empty()
vconcat(hspace n, rspace(n, m - 1))
matrix ll ==
lv:$ := [LIST2VEC$Lisp l for l in ll]
CONS(eform MATRIX, LIST2VEC$Lisp lv)$Lisp
pile l == cons(eform SC, l)
commaSeparate l == cons(eform AGGLST, l)
semicolonSeparate l == cons(eform AGGSET, l)
blankSeparate l ==
c:=eform CONCATB
l1:$:=[]
for u in reverse l repeat
if EQCAR(u,c)$Lisp
then l1:=[:cdr u,:l1]
else l1:=[u,:l1]
cons(c, l1)
brace a == [eform BRACE, a]
brace l == brace commaSeparate l
bracket a == [eform BRACKET, a]
bracket l == bracket commaSeparate l
paren a == [eform PAREN, a]
paren l == paren commaSeparate l
sub (a,b) == [eform SUB, a, b]
super (a, b) == [eform SUPERSUB,a,sform " ",b]
presub(a,b) == [eform SUPERSUB,a,sform " ",sform " ",sform " ",b]
presuper(a, b) == [eform SUPERSUB,a,sform " ",sform " ",b]
scripts (a, l) ==
null l => a
null rest l => sub(a, first l)
cons(eform SUPERSUB, cons(a, l))
supersub(a, l) ==
if odd?(#l) then l := append(l, [empty()])
cons(eform ALTSUPERSUB, cons(a, l))
hconcat(a,b) == [eform CONCAT, a, b]
hconcat l == cons(eform CONCAT, l)
vconcat(a,b) == [eform VCONCAT, a, b]
vconcat l == cons(eform VCONCAT, l)
a ^= b == [sform "^=", a, b]
a < b == [sform "<", a, b]
a > b == [sform ">", a, b]
a <= b == [sform "<=", a, b]
a >= b == [sform ">=", a, b]
a + b == [sform "+", a, b]
a - b == [sform "-", a, b]
- a == [sform "-", a]
a * b == [sform "*", a, b]
a / b == [sform "/", a, b]
a ** b == [sform "**", a, b]
a div b == [sform "div", a, b]
a rem b == [sform "rem", a, b]
a quo b == [sform "quo", a, b]
a exquo b == [sform "exquo", a, b]
a and b == [sform "and", a, b]
a or b == [sform "or", a, b]
not a == [sform "not", a]
SEGMENT(a,b)== [eform SEGMENT, a, b]
SEGMENT(a) == [eform SEGMENT, a]
binomial(a,b)==[eform BINOMIAL, a, b]
empty() == [eform NOTHING]
infix? a ==
e:$ :=
IDENTP$Lisp a => a
STRINGP$Lisp a => INTERN$Lisp a
return false
if GET(e,QUOTE(INFIXOP$Lisp)$Lisp)$Lisp then true else false
elt(a, l) ==
cons(a, l)
prefix(a,l) ==
not infix? a => cons(a, l)
hconcat(a, paren commaSeparate l)
infix(a, l) ==
null l => empty()
null rest l => first l
infix? a => cons(a, l)
hconcat [first l, a, infix(a, rest l)]
infix(a,b,c) ==
infix? a => [a, b, c]
hconcat [b, a, c]
postfix(a, b) ==
hconcat(b, a)
string a == [eform STRING, a]
quote a == [eform QUOTE, a]
overbar a == [eform OVERBAR, a]
dot a == super(a, sform ".")
prime a == super(a, sform ",")
dot(a,nn) == (s := new(nn, char "."); super(a, sform s))
prime(a,nn) == (s := new(nn, char ","); super(a, sform s))
overlabel(a,b) == [eform OVERLABEL, a, b]
box a == [eform BOX, a]
zag(a,b) == [eform ZAG, a, b]
root a == [eform ROOT, a]
root(a,b) == [eform ROOT, a, b]
over(a,b) == [eform OVER, a, b]
slash(a,b) == [eform SLASH, a, b]
assign(a,b)== [eform LET, a, b]
label(a,b) == [eform EQUATNUM, a, b]
rarrow(a,b)== [eform TAG, a, b]
differentiate(a, nn)==
zero? nn => a
nn < 4 => prime(a, nn)
r := FormatRoman(nn::PositiveInteger)
s := lowerCase(r::String)
super(a, paren sform s)
sum(a) == [eform SIGMA, empty(), a]
sum(a,b) == [eform SIGMA, b, a]
sum(a,b,c) == [eform SIGMA2, b, c, a]
prod(a) == [eform PI, empty(), a]
prod(a,b) == [eform PI, b, a]
prod(a,b,c)== [eform PI2, b, c, a]
int(a) == [eform INTSIGN,empty(), empty(), a]
int(a,b) == [eform INTSIGN,b, empty(), a]
int(a,b,c) == [eform INTSIGN,b, c, a]
|