DefineClasses:
PROC [] ~ {
local declarations (lots of 'em)
cmr10, cmti10, cmmi10, cmex10, cmsy10: Style;
integerClass, realClass, variableClass, plainSymClass, overlaySymClass, smallMathSymClass, bigMathSymClass, italSymClass, mathItalSymClass, lineClass, placeholderClass, spaceClass, greekVarClass, infinityClass: AtomClass;
sumClass, summationClass, fractionClass, integrationClass, indefIntClass, differenceClass, powClass, eqFormulaClass, approxEqFormulaClass, notEqFormulaClass, ltFormulaClass, leFormulaClass, geFormulaClass, gtFormulaClass, nRadicalClass, radicalClass, complexClass, productClass, orClass, notClass, negationClass, andClass, parenClass, subscriptClass, listClass, functionClass, altFunctionClass, limitClass, factorialClass, approachesClass: CompoundClass;
matrixClass, vectorClass: MatrixClass;
lbArg, ubArg, summandArg, llimArg, ulimArg, integrandArg, wrtArg, baseArg, exponentArg, numeratorArg, denominatorArg, nArg, radicandArg, realPartArg, imaginaryPartArg, aParenArg, subscriptArg, carArg, cdrArg, fArg, argsArg, ofArg, approachesArg, factorialArg: Argument;
plusSym, sigmaSym, integralSym, dxSym, lineSym, radRootSym, radLineSym, iSym, leftParenSym, rightParenSym, numerSpSym, denomSpSym, integralSpaceSym, commaSym, listSpSym, funSpaceSym, funLParenSym, funRParenSym, altFunLP, altFunRP, limSym, factorialSym, factorialSpSym, limSpaceSym, radSpaceSym: Symbol;
reset current DB state (i.e. clean slate)
MathDB.ResetAtomClasses[];
MathDB.ResetCompoundClasses[];
MathDB.ResetMatrixClasses[];
plain vanilla TeX fonts
cmr10 ← [font: "xerox/pressfonts/cmr60"]; -- standard times roman (1 unit high)
cmti10 ← [font: "xerox/pressfonts/cmti60"]; -- italic (1 unit high)
cmex10 ← [font: "xerox/pressfonts/cmex60"]; -- math extentsion font (1 unit high)
cmmi10 ← [font: "xerox/pressfonts/cmmi60"]; -- math italic font (1 unit high)
cmsy10 ← [font: "xerox/pressfonts/cmsy60"]; -- math symbols font (1 unit high)
define Atom Classes
integerClass ← MakeAtomClass[$integer, atom, argument, cmr10, RopeBox, PaintRope];
realClass ← MakeAtomClass[$real, atom, argument, cmr10, RopeBox, PaintRope];
variableClass ← MakeAtomClass[$variable, atom, argument, cmti10, RopeBox, PaintRope];
greekVarClass ← MakeAtomClass[$greekVar, atom, argument, cmmi10, CharBox, PaintChar, GreekVarToASRope];
plainSymClass ← MakeAtomClass[$plainSym, atom, symbol, cmr10, RopeBox, PaintRope];
overlaySymClass ← MakeAtomClass[$overlaySym, atom, symbol, cmr10, OverlayBox, PaintOverlay];
bigMathSymClass ← MakeAtomClass[$bigMathSym, atom, symbol, cmex10, CharBox, PaintChar];
smallMathSymClass ← MakeAtomClass[$smallMathSym, atom, symbol, cmsy10, CharBox, PaintChar];
mathItalSymClass ← MakeAtomClass[$mathItalicSym, atom, symbol, cmmi10, CharBox, PaintChar];
italSymClass ← MakeAtomClass[$italicSym, atom, symbol, cmti10, CharBox, PaintChar];
lineClass ← MakeAtomClass[$line, atom, symbol, cmr10, LineBox, PaintLine];
placeholderClass ← MakeAtomClass[$placeholder, atom, placeholder, cmmi10, RopeBox, PaintRope, PlaceHolderToASRope];
spaceClass ← MakeAtomClass[$space, atom, symbol, cmr10, SpaceBox, PaintSpace];
infinityClass ← MakeAtomClass[$infinity, atom, argument, cmsy10, CharBox, PaintChar, InfinityToASRope];
register atom classes
MathDB.InstallAtomClass[integerClass];
MathDB.InstallAtomClass[realClass];
MathDB.InstallAtomClass[variableClass];
MathDB.InstallAtomClass[greekVarClass];
MathDB.InstallAtomClass[plainSymClass];
MathDB.InstallAtomClass[overlaySymClass];
MathDB.InstallAtomClass[italSymClass];
MathDB.InstallAtomClass[smallMathSymClass];
MathDB.InstallAtomClass[bigMathSymClass];
MathDB.InstallAtomClass[mathItalSymClass];
MathDB.InstallAtomClass[lineClass];
MathDB.InstallAtomClass[placeholderClass];
MathDB.InstallAtomClass[spaceClass];
MathDB.InstallAtomClass[infinityClass];
define info for "complex a b" (a + bi)
realPartArg ← MakeArgument[$a, LIST[$aliasA, $aliasHot], normal];
imaginaryPartArg ← MakeArgument[$b, LIST[$aliasB], normal];
iSym ← MakeSymbol[$i, NIL, normal, MakeItalSym['i]];
plusSym ← MakeSymbol[$plus, LIST[$aliasBinOp], normal, MakePlainSym['+]];
define info for "summation lowerbound upperbound summand"
lbArg ← MakeArgument[$lowerbound, NIL, script];
ubArg ← MakeArgument[$upperbound, NIL, script];
summandArg ← MakeArgument[$summand, LIST[$aliasHot], normal];
sigmaSym ← MakeSymbol[$sigma, LIST[$aliasOp], normal, MakeBigMathSym['\130]];
define info for indefinite & definite integrals (normal & surface)
llimArg ← MakeArgument[$lowerlimit, NIL, script];
ulimArg ← MakeArgument[$upperlimit, NIL, script];
integrandArg ← MakeArgument[$integrand, LIST[$aliasHot], normal];
wrtArg ← MakeArgument[$wrt, NIL, normal];
integralSym ← MakeSymbol[$integral, LIST[$aliasOp], normal, MakeBigMathSym['\132]];
dxSym ← MakeSymbol[$dx, NIL, normal, MakeItalSym['d]];
integralSpaceSym ← MakeSymbol[$space, LIST[$aliasSpace], normal, MakeSpace[$thick]];
define info for "pow base exponent" & "subscript base subscript"
baseArg ← MakeArgument[$base, LIST[$aliasA, $aliasHot], normal];
exponentArg ← MakeArgument[$exponent, LIST[$aliasB], script];
subscriptArg ← MakeArgument[$subscript, LIST[$aliasB], script];
define info for "fraction numerator denominator"
numeratorArg ← MakeArgument[$numerator, LIST[$aliasA, $aliasHot], normal];
denominatorArg ← MakeArgument[$denominator, LIST[$aliasB], normal];
denomSpSym ← MakeSymbol[$bottomSpace, LIST[$aliasSpace], normal, MakeSpace[$thin]];
numerSpSym ← MakeSymbol[$topSpace, LIST[$aliasSpace], normal, MakeSpace[$thin]];
lineSym ← MakeSymbol[$fractionBar, LIST[$aliasLine], normal, MakeLine[]];
define info for "radical n radicand"
nArg ← MakeArgument[$n, LIST[$aliasB], script];
radicandArg ← MakeArgument[$radicand, LIST[$aliasA, $aliasHot], normal];
radRootSym ← MakeSymbol[$radRoot, NIL, normal, MakeBigMathSym['\162]];
radLineSym← MakeSymbol[$radLine, LIST[$aliasLine], normal, MakeLine[]];
radSpaceSym ← MakeSymbol[$space, LIST[$aliasSpace], normal, MakeSpace[$medium]];
define info for "( a )"
aParenArg ← MakeArgument[$a, LIST[$aliasA, $aliasHot], normal];
leftParenSym ← MakeSymbol[$leftParen, NIL, normal, MakeBigMathSym['\040]];
rightParenSym ← MakeSymbol[$rightParen, NIL, normal, MakeBigMathSym['\041]];
define info for "$list $car $cdr"
carArg ← MakeArgument[$car, LIST[$aliasA, $aliasHot], normal];
cdrArg ← MakeArgument[$cdr, LIST[$aliasB], normal];
commaSym ← MakeSymbol[$comma, NIL, normal, MakeItalSym[',]];
listSpSym ← MakeSymbol[$space, LIST[$aliasSpace], normal, MakeSpace[$thick]];
define info for functions
fArg ← MakeArgument[$f, LIST[$aliasA, $aliasHot], normal];
argsArg ← MakeArgument[$args, LIST[$aliasB], normal];
funSpaceSym ← MakeSymbol[$space, LIST[$aliasSpace], normal, MakeSpace[$medium]];
funLParenSym ← MakeSymbol[$leftParen, NIL, normal, MakePlainSym['\050]];
funRParenSym ← MakeSymbol[$rightParen, NIL, normal, MakePlainSym['\051]];
altFunLP ← MakeSymbol[$leftParen, NIL, normal, MakeSpace[$null]];
altFunRP ← MakeSymbol[$rightParen, NIL, normal, MakeSpace[$null]];
define info for limits
ofArg ← MakeArgument[$of, LIST[$aliasA, $aliasHot], normal];
approachesArg ← MakeArgument[$approaches, NIL, script];
limSpaceSym ← MakeSymbol[$space, LIST[$aliasSpace], normal, MakeSpace[$limit]];
limSym ← MakeSymbol[$lim, NIL, script, MakePlainRope["lim"]];
define into for factorial
factorialArg ← MakeArgument[$a, LIST[$aliasA, $aliasHot], normal];
factorialSym ← MakeSymbol[$bang, NIL, normal, MakePlainSym['!]];
factorialSpSym ← MakeSymbol[$space, LIST[$aliasSpace], normal, MakeSpace[$thin]];
define compound classes
binary operations
sumClass ← MakeBinOpClass[$sum, $plus, $addend, $augend, MakePlainSym['+], "a + b", "$addend + $augend"];
differenceClass ← MakeBinOpClass[$difference, $minus, $subtrahend, $minuend, MakePlainSym['\173], "a - b", "$subtrahend - $minuend"];
productClass ← MakeBinOpClass[$product, $times, $multiplier, $multiplicand, MakeSpace[$product], "a * b", "$multiplier * $multiplicand"];
andClass ← MakeBinOpClass[$and, $andOp, $a, $b, MakeSmallMathSym['\136], "a AND b", "$a & $b"];
orClass ← MakeBinOpClass[$or, $orOp, $a, $b, MakeSmallMathSym['\137], "a OR b", "$a | $b"];
unary operations
negationClass ← MakeUnaryOpClass[$negation, $minus, $a, MakePlainSym['-], "-a", "-$a"];
notClass ← MakeUnaryOpClass[$not, $notOp, $a, MakeSmallMathSym['\072], "~a", "~ $a"];
relations
eqFormulaClass ← MakeRelationClass[$eqFormula, $equals, $lhs, $rhs, MakePlainSym['=], "lhs = rhs", "$lhs = $rhs"];
notEqFormulaClass ← MakeRelationClass[$notEqFormula, $equals, $lhs, $rhs, MakeOverlaySym["=/"], "lhs # rhs", "$lhs # $rhs"];
ltFormulaClass ← MakeRelationClass[$ltFormula, $lt, $lhs, $rhs, MakeMathItalSym['<], "lhs < rhs", "$lhs < $rhs"];
gtFormulaClass ← MakeRelationClass[$gtFormula, $gt, $lhs, $rhs, MakeMathItalSym['>], "lhs > rhs", "$lhs > $rhs"];
leFormulaClass ← MakeRelationClass[$leFormula, $le, $lhs, $rhs, MakeSmallMathSym['\024], "lhs <= rhs", "$lhs <= $rhs"];
geFormulaClass ← MakeRelationClass[$geFormula, $ge, $lhs, $rhs, MakeSmallMathSym['\025], "lhs >= rhs", "$lhs >= $rhs"];
approxEqFormulaClass ← MakeRelationClass[$approxEqFormula, $equals, $lhs, $rhs, MakeSmallMathSym['\031], "lhs approx= rhs", "$lhs approx= $rhs"];
approachesClass ← MakeRelationClass[$approachesFormula, $approaches, $lhs, $rhs, MakeSmallMathSym['\041], "lhs -> rhs", "$lhs -> $rhs"];
others
listClass ← MakeCompoundClass[$list, other, "a, b", LIST[carArg, cdrArg], LIST[commaSym, listSpSym], FixedSizeBoxRule, ListCompRule, "($car $cdr)"];
functionClass ← MakeCompoundClass[$function, other, "function(args)", LIST[fArg, argsArg], LIST[funLParenSym, funRParenSym, funSpaceSym], FunctionBoxRule, FunctionCompRule, "(function $f $args)"];
altFunctionClass ← MakeCompoundClass[$altFunction, other, "function args", LIST[fArg, argsArg], LIST[altFunLP, altFunRP, funSpaceSym], FixedSizeBoxRule, FunctionCompRule, "(function $f $args)"];
complexClass ← MakeCompoundClass[$complex, other, "a + bi", LIST[realPartArg, imaginaryPartArg], LIST[iSym, plusSym], FixedSizeBoxRule, ComplexCompRule, "($a + $bi)"];
summationClass ← MakeCompoundClass[$summation, op, "summation", LIST[lbArg, ubArg, summandArg], LIST[sigmaSym], FixedSizeBoxRule, SummationCompRule, "(summation $lowerbound $upperbound $summand)"];
integrationClass ← MakeCompoundClass[$integration, op, "def integration", LIST[llimArg, ulimArg, integrandArg, wrtArg], LIST[integralSym, dxSym, integralSpaceSym], FixedSizeBoxRule, IntegrationCompRule, "(integral $lowerlimit $upperlimit $integrand $wrt)"];
indefIntClass ← MakeCompoundClass[$indefInt, op, "indef integration", LIST[integrandArg, wrtArg], LIST[integralSym, dxSym, integralSpaceSym], FixedSizeBoxRule, IndefiniteIntCompRule, "(indefIntegral $integrand $wrt)"];
powClass ← MakeCompoundClass[$pow, other, "a^b", LIST[baseArg, exponentArg], NIL, FixedSizeBoxRule, PowCompRule, "$base^$exponent"];
subscriptClass ← MakeCompoundClass[$subscript, other, "a sub b", LIST[baseArg, subscriptArg], NIL, FixedSizeBoxRule, SubscriptCompRule, "$baseSub$subscript"];
parenClass ← MakeCompoundClass[$paren, paren, "( a )", LIST[aParenArg], LIST[leftParenSym, rightParenSym], ParenBoxRule, ParenCompRule, "( $a )"];
fractionClass ← MakeCompoundClass[$fraction, over, "a / b", LIST[numeratorArg, denominatorArg], LIST[lineSym, numerSpSym, denomSpSym], FractionBoxRule, FractionCompRule, "$numerator / $denominator"];
nRadicalClass ← MakeCompoundClass[$nRadical, radical, "nth radical", LIST[nArg, radicandArg], LIST[radRootSym, radLineSym, radSpaceSym], NRadicalBoxRule, NRadicalCompRule, "(nthRoot $radicand $n)"];
radicalClass ← MakeCompoundClass[$radical, radical, "radical", LIST[radicandArg], LIST[radRootSym, radLineSym, radSpaceSym], RadicalBoxRule, RadicalCompRule, "(Root $radicand)"];
limitClass ← MakeCompoundClass[$limit, other, "limit", LIST[approachesArg, ofArg], LIST[limSpaceSym, limSym], FixedSizeBoxRule, LimitCompRule, "(limit $approaches $of)"];
factorialClass ← MakeCompoundClass[$factorial, other, "a!", LIST[factorialArg], LIST[factorialSym, factorialSpSym], FixedSizeBoxRule, FactorialCompRule, "$a!"];
register compound classes
binary ops
MathDB.InstallCompoundClass[sumClass];
MathDB.InstallCompoundClass[differenceClass];
MathDB.InstallCompoundClass[andClass];
MathDB.InstallCompoundClass[orClass];
unary ops
MathDB.InstallCompoundClass[notClass];
MathDB.InstallCompoundClass[negationClass];
others
MathDB.InstallCompoundClass[listClass];
MathDB.InstallCompoundClass[factorialClass];
MathDB.InstallCompoundClass[functionClass];
MathDB.InstallCompoundClass[altFunctionClass];
MathDB.InstallCompoundClass[powClass];
MathDB.InstallCompoundClass[subscriptClass];
MathDB.InstallCompoundClass[parenClass];
MathDB.InstallCompoundClass[complexClass];
MathDB.InstallCompoundClass[productClass];
MathDB.InstallCompoundClass[summationClass];
MathDB.InstallCompoundClass[limitClass];
MathDB.InstallCompoundClass[approachesClass];
MathDB.InstallCompoundClass[integrationClass];
MathDB.InstallCompoundClass[indefIntClass];
MathDB.InstallCompoundClass[fractionClass];
MathDB.InstallCompoundClass[radicalClass];
MathDB.InstallCompoundClass[nRadicalClass];
relations
MathDB.InstallCompoundClass[eqFormulaClass];
MathDB.InstallCompoundClass[notEqFormulaClass];
MathDB.InstallCompoundClass[ltFormulaClass];
MathDB.InstallCompoundClass[leFormulaClass];
MathDB.InstallCompoundClass[gtFormulaClass];
MathDB.InstallCompoundClass[geFormulaClass];
MathDB.InstallCompoundClass[approxEqFormulaClass];