CHARYBDIS(ID:382/cha010)
Graphic extensions to Mathlab
- Country: us
- Began: 1967
- Published: 1969
- Type:Algebraic
for CHARacter-composed sYmBolic DISplay
Millen, The Mitre Corporation, 1967
LISP program to display math expressions, pretty much an improved MATHLAB with plotting 2d output/input
from the documentation: "Charybdis is a LISP program that accepts, as input, mathematical expressions written in LISP prefix notation, and displays them in familiar two-dimensional form on devices with a small fixed character set. It is a simply organized, modular program whose structure is based on the recursive structure of mathematical expressions. Changes and additions to the repertory of Charybdis can be made easily and independently of one another by LISP programmers familiar win little more than its conceptual basis."
Related languages
References:
Millen, J.K. "Charybdis: a LISP program to display mathematical expressions on typewriter-like devices" Mitre Corp Technical Report August 1 1967 view details
Extract: Introduction CHARYBDIS: A LISP PROGRAM TO DISPLAY MATHEMATICAL EXPRESSIONS ON TYPEWRITER-LIKE DEVICES J. K. Millen AUGUST 1967
THE: MITRE CORPORATION BOX 208 BEDFORD, MASSACHUSETTS
This document has been released for public dissemination.
Project 9515
ACKNOWLEDGMENTS This project was sponsored by The MITRE Corporation's Dependent Research Program.
It was also supported, in part, through access to its computer facilities, by Project MAC, an M. I. T. Research Program sponsored by the Advanced Research Projects Agency, Department of Defense, under Office of Naval Research Contract No. NONR-4102(01). The author wishes to thank C. Engelman for his many helpful comments and suggestions.
ABSTRACT
Charybdis is a LISP program that accepts, as input, mathematical expressions written in LISP prefix notation, and displays them in familiar two-dimensional form on devices with a small fixed character set. It is a simply organized, modular program whose structure is based on the recursive structure of mathematical expressions. Changes and additions to the repertory of Charybdis can be made easily and independently of one another by LISP programmers familiar win little more than its conceptual basis.
TABLE OF CONTENTS Page
LIST OF ILLUSTRATIONS ..... viii SECTION I INTRODUCTION ..... 1 SECTION II DESCRIPTION OF THE DISPLAYS ..... 3
THE CHARACTER SET AND ITS LIMITATIONS ..... 3 LINE OVERFLOW ..... 8 SPECIAL SYMBOLISM ..... 10 OTHER DISPLAYS .....10
SECTION III PROGRAM STRUCTURE .....14
INTRODUCTION .....14 CHARYBDIS .....14 PROGRAM STRUCTURE ..... 15 CONCEPTUAL BASIS .....16 THE EXAMPLE .....19
SECTION IV SUMMARY .....22 REFERENCES .....23
LIST OF ILLUSTRATIONS
Figure No. Page 1 Some Displays (a) Continued Fraction ..... 3 (b) MATHLAB: Differentiation Result ..... 4 (c) MATHLAB: Integration Result ..... 5
2 Parentheses (a) Single Line ..... 7 (b) Stacked ..... 7
3 Splitting Across Lines (a) A Differential Equation ..... 9 (b) Its Solution ..... 9
4 Extended Summation ..... 11
5 Other Displays (a) Matrix ..... 12 (b) Binary Trees ..... 13
6 Block Diagram of Charybdis ..... 15
7 Illustration of Terms ..... 18
SECTION I - INTRODUCTION
Charybdis (from CHARacter-composed sYmBolic DISplay) is a LISP program to display mathematical expressions on typewriter-like devices (line printers, teletypes, and scopes which display lines of characters, as well as typewriters). It was written as part of the output interface for MATHLAB ] , which uses LISP for two reasons which apply to Charybdis. First is the fact that the data expressions in LISP are lists, i. e., tree structures, composed ultimately of atomic symbols, which include variables, numbers, and, in particular, characters. Second, but at least as important, is the power of recursion.
The kind of expression accepted as an input by Charybdis is a list structure in a prefix notation which serves as the common internal form for expressions in MATHLAB. The output of Charybdis, that is, the display of a mathematical expression, is described in Section II of this paper. Section m discusses the structure of the program, emphasizing the way it can be expanded to include more mathematical displays, or even arbitrary displays which are either not too large or are amenable to recursive techniques. A knowledge of LISP is desirable for reading Section m, although it is not necessary for an understanding of the conceptual basis of Charybdis.
The need for such a program arose from the following considerations: Experienced programmers grow accustomed to a variety of notations whose purpose is to represent arithmetic and algebraic expressions one-dimensionally. FORTRANners have no difficulty reading the polynomial
color=#009999>15*X**3+31*Y**3-4* X**2*Y**2
and those who know LISP are used to expressions like color=#009999>(QUOTIENT (PLUS(TIMES 13 (EXPT X 2)) (QUOTIENT A 2)) (DIFFERENCE(TIMES 5 (INEPT X 3))197))
To most scientists who deal with applied mathematics, these notations are not nearly so legible and easy to deal with as the universal two-dimensional form. Compare the above examples with: color=#009999>15x3 + 31y3 - 4X2y2 and color=#009999>(13x2 + a/2) / (5x5 - 197)
Hence it is to the advantage of a symbolic manipulation program to display its output two-dimensionally. W.A. Martin's system [ 2 ] , for example, makes elegant use of the extensive facilities of the PDP-6 display console (DEC 340) with its wide vocabulary of characters and ability to create new symbols, and also use the equally general capabilities of a plotter for hard copy. Although these devices make it possible to create beautiful and accurately symbolized displays of mathematical expressions, they have certain disadvantges. Scopes with vector capabilities are expensive; plotters are slow; both are difficult to program. Practically any computer, however, has a typewriter-like device for its normal output. Furthermore, in any LISP system, printing atomic symbols on such a device is a simple matter.
SECTION II DESCRIPTION OF THE DISPLAYS
THE CHARACTER SET AND ITS LIMITATIONSCharybdis assumes a character set containing the upper case alphabet, the decimal digits, and these additional symbols: + - = / .,: ( ) * . One notices immediately that the capital sigma representing summation, and other common mathematical operators, are missing; but even more basic problems exist. What about the horizontal bar in a quotient? Where are exponents and subscripts, and where are tall parentheses (to match the size of the parenthesized expression)? Charybdis& quot;solutions to some of these problems are illustrated in Figures l(a) - l(c). With a little reflection, it becomes evident that there is really only one possible way to handle most of these initial problems. The resulting displays are somewhat alien at first glance, but are readable and easy to get used to.
Figure l(a). Some Displays- Continued Fraction [omitted] Figure l(b) Some Displays-MATHLAB Differentiation Result [omitted] Figure l(c). Some Displays- MATHLAB: Integration Result [omitted]
Figures l(b) and l(c) are in the context of MATHLAB, which reads expressions in a FORTRAN-like form but prints them out using Charybdis. A complete explanation of the meaning of the commands and replies shown would be too lengthy to include here, but the conversation is not hard to follow, even without the explanation.
Notice in the figures that variables in a product are separated from neighboring variables by asterisks. Although multiplication is usually signified by adjacency, that could lead to ambiguity. The ambiguous situations are those in which a single variable is represented by a string of more than one character. With a character set not containing Greek letters, for example, one often writes PI for p, THETA for ?, etc. Now, if adjacency signifies multiplication, PI could be either a variable or a product. Context might resolve the difficulty, or it might not. An equally acceptable solution would be the interposition of a blank instead of a star; familiarity with FORTRAN prompted the choice that was made.
Tall parentheses can be simulated as in Figure 2(b). The same expressions can also be displayed as in Figure 2(a), in which parentheses are always single. The Charybdis user has his choice, made known to the program by setting a switch (the global variable TALLPAR).
Parentheses which match the height of the parenthesized expression are easier to pair, but tend to clutter the display. Single-line parentheses are harder to pair, but are never actually ambiguous. (This remark is not quite as obvious as it appears; recall that tall parentheses also indicate the top and bottom of an expression)
Because of the bias of the author, the switch is set initially for single-line parentheses.
Figure 2. Parentheses (a) Single Line (b) Stacked [omitted]
Expressions too long for a single line are a problem for any display program using a device with a fixed line length -- even textbooks. Charybdis splits such expressions over several lines in an unconventional way, as illustrated in Figure 3(b). The expression shown is the solution, as computed by MATH LAB [ 3 ] , of the differential equation in Figure 3(a) The algorithm for splitting the expression is as follows: if the expression is a quotient, exponential, or equation, the two subexpressions are displayed, indented three spaces, above and below the main connective (/, **, or =, respectively). If the expression is a sum or product, it is split into as many parts as necessary, and the parts displayed one after another indented three spaces, separated by the main connective + or * on intervening lines.
In all other cases, the keyword is displayed, and then the individual arguments, indented three spaces, with commas on intervening lines.
If any of the parts which are to be displayed is still too long, the process is applied recursively to split the part.
Future development of the program should include more sophisticated splitting of some expressions currently in the'in all other cases'category.
The net effect is that the expression is spread out into a tree-like structure, with its root at the left. Looking again at Figure 3(b), and reading from the'/'at the left, one sees that the expression is a quotient whose denominator is (a+b+c) &sqrt{4ca-b2};, and whose numerator is the sum of two products, etc.
A drawback of this method of presentation is that it assumes a bottomless display surface. Appropriate though this may be for line printers and teletypes, a scope screen might not be able to show the entire display of an extremely complicated expression. Charybdis would have to be modified to handle such situations. Martin's system takes care of this by naming sufficiently many subexpressions, and substituting their names for the subexpressions themselves in the whole expression, so that the result will fit on the screen. The named expressions can then be displayed later at will. Such a solution must clearly be undertaken hand in hand with the background mathematical manipulation program.
face='MS PGothic'> Figure3(a). Splitting Across Lines-A Differential Equation [omitted]
Figure 3(b). Splitting Across Lines - Its Solution [omitted]
SPECIAL SYMBOLISM
Let us return to the less immediate but more vexing difficulty of displaying expressions requiring special characters, such as the sigma of extended summation. A natural approach is to draw the symbol with characters like periods or asterisks. Figure 4 is an example of this. Heated arguments occur over just how the symbols ought to be drawn. Even in the case of the sigma, which is pretty straightforward, it has been suggested that another parameter be included in order to adjust its height. Here we are venturing into regions where the original author of the display program is not the proper arbiter. Provisions must, and do, exist for the'system programmer', i. e., the LISP-acquainted person whose concern is the maintenance and expansion of the symbolic manipulation program, to make and incorporate his own decisions as to the appearance of displays for new kinds of symbolic expressions, as they are added to the vocabulary of his system.
Figure 4. Extended Summation [omitted] Figure 5(a). Other Displays-Matrix [omitted] Figure 5(b). Other Displays-Binary Tree [omitted]
OTHER DISPLAYSface='MS Gothic'>
The class of displays which Charybdis is capable of handling is broader than the term'mathematical expressions'and the preceding examples might lead one to believe. By way of illustration, we include Figures 5(a) and 5(b), which are displays of a more general nature produced by Charybdis.
SECTION III PROGRAM STRUCTURE
INTRODUCTIONface='MS Gothic'>
Section III is divided into four subsections: 1) a discussion of the usage and purpose of the main function, CHARYBDIS; 2) an explanation of the global structure of the program; 3) a summary of the conceptual basis of the display, containing the definition of the origin of a display; and 4) an example of the addition of a kind of display to Charybdis. Woven through their midst is the story of how additions (or changes) are made, culminating in the example in the last section.
CHARYBDIS
CHARYBDIS is a function of three arguments: charybdis [ expression; start; line length ] . The first argument is the expression to be displayed, encoded in the proper input format, which we shall specify in a moment.'Start'is the desired leftmost column of the display; i. e., if start is fifteen, the whole display will be indented fourteen spaces. The last argument is the number of columns available; it is this number which is compared with the width of the expression to see if the latter must be split over more than one line. Each expression to be displayed is expected to be in the following form: (keyword arg1 arg2 . . . ), or else just an atom. The keyword, generally atomic, is a prefix signifying the kind of expression, while the erg's are the variable subexpressions of which it is composed. The order of the arguments is, of course, significant. Some of the previous figures show the input expressions corresponding to the displays.
There are two steps to the display of an expression. First, a list of atoms, together with the Cartesian coordinates of their initial characters, is built up.
Then, this list, the display list, is handed line by line to SCYLLA, a function which writes it out onto the device referenced by the system function PRINT.
If the expression is wider than the line length permits, then not one, but a succession of display lists is created and written.
CHARYBDIS itself contains the algorithm for splitting expressions over several lines and the loop which sends the lines of a display list to SCYLLA. CHARYBDIS enters the function APP to obtain the display list.
Figure 6. Block Diagram of Charybdis [omitted]
PROGRAM STRUCTUREface='MS Gothic'>
APP is the doorway to the rest of the program, which has no other responsibility than the creation of a display list. In Figure 6, the block diagram of the whole program, APP appears as one of the four functions in the'executive module'. The operation of APP, as well as the other three functions in that module, must be explained in terms of concepts developed in the next section. Meanwhile, however, we can still say a great deal about the overall structure of the program.
Every module is a set of four functions, just like the executive module. Each'individual module'handles one kind of expression: product, quotient, etc. In fact, the executive module is nothing more than a multi-position switch, which handles an arbitrary expression by determining its type (from the keyword) and calling upon the appropriate individual module -- except for the trivial case of atomic symbols, which it takes care of itself.
If no other individual module applies, an'otherwise'module is used; it puts the expression in conventional functional form, the keyword being the function name. SIN, LOG, SQRT (square root) and other familiar functions are treated this way, as well as those which are truly unexpected. It is worth noting that the display program needs no other individual module than this one to work -- in fact, LISP programmers will recognize the stripped-down program as a'pretty print'function for list structures!
CONCEPTUAL BASISface='MS Gothic'>
In order to add a new kind of display to Charybdis, one must first understand the notion of the origin of the display of an expression. The reason is that the purposes of three out of the four LISP functions which must be defined to accomplish the addition are stated in terms of the origin. The origin is a distinguished location within a display, whose coordinates are determined as follows:
1) The abscissa of the origin is that of the leftmost character in the display. 2) If the expression, call it a, were written as the argument of an arbitrary function F. as F(a), the ordinate of the origin would be that of the'F'. Property 2) is meant to be a precise way of describing the'middle line'of an expression -- not the measured middle line, but the natural one. In this sense, the middle line of a quotient, for instance, is the one in which the horizontal bar lies -- regardless of how tall the numerator and how short the denominator, or vice versa. Thus the origin of a quotient is the location of the leftmost dash in the bar. The origin of (the display of) an atom is easily seen to be the location of its initial character.
Property 2), as it is stated, applies to mathematical expressions in only the narrowest sense of the word Recall that the capital sigma, for example, does not occur alone as the argument of any function. If one wishes to deal with an arbitrary display, the looser definition of the origin -- as on the'natural middle line'-- is more appropriate; for, the less mathematical the display, the more free the choice of an origin can afford to be. In fact, if the display will not occur as a subexpression of any expression, the ordinate of the origin may be chosen arbitrarily.
After defining three more terms, we shall be in a position to describe the entire process of adding displays, and give an example.
The width of a display is the number of columns from the extreme left of the display to the extreme right.
The superspan of a display is the number of lines it extends above the origin. An atom has a superspan of zero.
The subspan of a display is the number of lines it extends below the origin. An atom has subspan zero. These attributes are illustrated in Figure 7. A corollary of the definitions above is that the height of a display can be expressed by this formula: superspan + 1 + subspan.
The four functions which constitute an individual module for handling expressions of a particular type are: 1) a function whose four arguments are: an expression, the two coordinates x, y of the desired origin, and a partial display list; and whose value is the new display list obtained from the one given by appending to it the description of the display of the input expression; (this function does the work for APP, which derives its name from the fact that it appends to the display list. ); 2) a function of one argument whose value is its width; 3) a function of one argument whose value is its superspan; 4) a function of one argument whose value is its subspan. Figure 7. Illustration of Terms [omitted] These functions are made known to the executive module by placing their names on the property list of the keyword under the indicators APP, WIDTH, SUPERSPAN, and SUBSPAN, respectively.
Now for an example.
THE EXAMPLELet us suppose that we wish to specify the display of a sum of two terms. The first step, of course, is to specify the input expression: (SUM term1 terms2) The only restrictions on our choice are that it must have the proper keyword-argument form, and it must agree with the form used in the underlying mathematical manipulation program. The sum is made up out of two variable subexpressions -- the terms -- and a plus sign. The plus sign is a character, a fortiori an atom, and may be viewed as just another subexpression. Our job is to specify the positions of these three subexpressions relative to one another, and place the whole at some given location. Restated in the framework of the subsection, 'CONCEPTUAL BASIS', the task is as follows: given the coordinates (x, y) of the origin of the whole expression, specify the coordinates of the origins of the subexpressions.
Let us place the origin of a) the first term at (x, y), b) the plus sign at (x + w, y) (where wis the width of the first term), c) the second term at (x + w + 1, y)
These statements completely describe the display of the sum. It is clear that the origin of the new display satisfies the defining properties 1) and 2). But we are not done yet; how do we know that this display is satisfactory, i. e., looks like a sum should? Because of property 1), concerning the abscissas of the origins of the subexpressions, and the use of the width of the first term, the display will have the plus sign between the two terms, as desired Furthermore, since the origin of each term is on the line on which an applied function would be placed (property 2)), and since the exterior plus sign belongs on that same line, the vertical placement of the terms is correct.
In other words, it is on this particular definition of an origin, together with the availability of functions to compute the width and (for other displays) the superspan and subspan, that our confidence in the ability of Charybdis to handle the new display properly rests.
Note that any other choice for the abscissa of the origin, except for the right-hand end of the display, would result in more arithmetic for computing the width, The advantage of the left side over the right is that it indulges our predilection for constructing expressions as we would write them, from left to right.
As for the ordinate of the origin, the value chosen is necessary information in the example, as in most displays. Another choice of origin would necessitate extra computation to find that value.
Having abstractly specified the display, we can now write the four LISP functions to handle the jobs of APP, WIDTH, SUPERSPAN, and SUBSPAN. Note the parallel between the definition of the APP and the description of the display given above.
face='MS Mincho' color=#008080>appsum [ u; x; y; d ] = prog [ [ newd; w ] ; newd := d; w: = width [ cadr [ u ] ; newd: = app [ cadr [ u ] ; x; y; newd ] ; newd: = app [ pluss; x+w; y; newd ] ; newd: = app [ caddr [ u ] ; x +w + 1; y; newd ] ; return [ newd ] ]
widthsum [ u ] = width [ cadr [ u ] ] +1+width [ caddr [ u ] ] superspansum [ u ] = max [ superspan [ cadr [ u ] ] ; superspan [ caddr [ u ] ] ] subspansum [ u ] = max L subspan [ cadr [ u ] ; subspan L caddr [ u ] ] ] face='MS Mincho'>< P > In this example, the number of subexpressions was known in advance. When this is not the case, as in the actual version of this kind of expression (with keyword PLUS) in Charybdis, the functions in the individual module contain loops or are more highly recursive and fragmented. In any case, the complexity of the functions only reflects the complexity of the display itself.
SECTION IV SUMMARYface='MS Gothic'>
Charybdis is a simply organized, modular program whose structure is based on the recursive structure of mathematical expressions. The program is made possible by the ability to define functions recursively, and by the recognition of the origin of the display of a mathematical expression as the mechanism with which to implement the recursion. Changes and additions to the repertory of the program can be made easily and independently of one another by LISP programmers familiar with the conceptual basis of the program and only a bare minimum of details.
REFERENCESface='MS Gothic'>
1. C. Engelman, MATHLAB: A Program for On-Line Assistance in Symbolic Computations, The MITRE Corporation, MTP-18, October 1965; see also Proc. Fall Joint Comp. Conf., Vol. I, Washington, D. C., Spartan Books, 1965; also Vol. II, Thompson Book Co., Washington, D. C. and Academic Press, Inc., London, 1967. (These three are similar publications; however, the first is the best.) 2. W.A. Martin, Symbolic Mathematical Laboratory, Ph. D. Thesis, E. E. Dept., M. I. T., January, 1967. 3. M. Manove, S. Bloom, C. Engelman, Rational Functions in Mathlab, (Forthcoming) Proc. of IFIP Working Conference on Symbol Manipulating,: Languages, Pisa, 1966; see also MTP-35, The MITRE Corporation, August, 1966.
Millen, J. K. "CHARYBDIS: a LISP program to display mathematical expressions on typewriter-like devices" In Interactive Systems
for Experimental Applied Mathematics, M Klerer and J. Reinfelds (Eds), Academic Press, New York, 1968 pp. 155-163
view details
Sammet, Jean E. "Computer Languages - Principles and History"
Englewood Cliffs, N.J. Prentice-Hall 1969. p.522. view details
Smith, Lyle B. "A Survey of Interactive Graphical Systems for Mathematics" view details
in [ACM] ACM Computing Surveys 2(4) Dec1970 view details
Engelman, C. "Algebraic Manipulation Languages" view details
Extract: FORMAC The best known, purely symbolic systems are, of course, Formac and its current version PL/IFORMAC (Petrick, 1971; pp. 105-114). Formac was the first widely available general-purpose algebraic manipulation system and served for a period to define the field. Certainly, there was a time when one could have safely made the statement that the majority of all mechanical symbolic mathematical computations had been done within Formac. The practical success of these systems, in spite of their rigidity with respect to user modifications and their lack of any seminumerical facilities for rational function computations, is probably due to the overall intelligence of the facilities that were provided. Above all, they were certainly sufficient to support the dominant application area of truncated power series expansion. Current support is minimal.
Extract: CHARYBDIS and MATHLAB MATHLAB. This system is distributed currently for on-line operation on the DEC system-10 (PDP-10) computer, although subsystems have been converted to run on IBM and CDC machines. This was the first heavyweight hybrid system passing data freely between a general-purpose simplification package and a powerful rational function package. Marred by the lack of a number of practical necessities, this system is probably most important for its computational innovations. These include the first complete program for the factorization of multivariate polynomials over the integers, and consequently for the partial fraction expansion of rational functions; for the integration of rational functions; for the inverse Laplace transform of rational functions; for the solution of linear differential equations with constant coefficients; and for the solution of equations via polynomial factorization. In addition it contains CHARYBDIS, the first program for the two-dimensional display of mathematical expressions on typewriter-like devices (Teletypes, alphanumeric displays, line printer, etc.). Its dedication to an on-line environment led to an interesting command structure and a number of convenient core-oriented and disk oriented bookkeeping facilities.
Extract: Symbolic systems SYMBOLIC SYSTEMS. We should mention first a sequence of three early programs for the simplification of general symbolic mathematical expressions represented as prefix-notation tree structures. The first, at M.I.T., was due to Hart, and the other two were due to Wooldridge and Korsvold at Stanford. The latter has survived in current usage as a result of its incorporation, subject to modification, into the MATHLAB, MACSYMA, and SCRATCHPAD systems.
In the mid-1960s there appeared two systems, Formula Algol and FAMOUS, which, while dedicated to the symbolic manipulation of mathematical expressions, presented the user with almost no built-in automatic simplification facilities. This was due, at least in the case of FAMOUS, to a conscious decision that, since the "simplicity" of an expression is surely context- dependent, it should be reasonable to present the user with complete control over the simplification process. That is, the user'should be compelled to define all transformations, rather than, as with most systems, be permitted simply to switch on and off the transformations supplied by the system architects. No system of this species has ever solved the inherent efficiency problems to the extent that it could serve more than didactic purposes. Probably neither Formula Algol nor FAMOUS could be revived today.
Another lost symbolic system of importance is the Symbolic Mathematical Laboratory of W. A. Martin. This system provided high-quality 2-D graphics on a DEC-340 display and was also the first to employ a light pen for subexpression selection. In some ways, it represented a degree of interaction that has not been duplicated by any subsequent system. Nor were its innovative internal programming techniques restricted to its graphics facilities. Of particular interest is the use of hash coding for subexpression matching (Petrick, 1971; pp. 305-310).
in Encyclopedia of Computer Science, Ralston, Anthony, and Meek, Chester L. (eds) New York, NY Petrocelli/Charter 1976 view details
|