InstallArithmeticClassesA:
PROC [] ~ {
local declarations
sumClass, fractionClass, differenceClass, powClass, productClass, negationClass, inverseClass: CompoundClass;
baseArg, exponentArg, numeratorArg, denominatorArg: Argument;
lineSym, numerSpSym, denomSpSym: Symbol;
define info for "pow base exponent" & "subscript base subscript" & "hat base hat"
baseArg ← MakeArgument[$base, LIST[$aliasA, $aliasHot], normal];
exponentArg ← MakeArgument[$exponent, 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, MathConstructors.MakeSpace[$thin]];
numerSpSym ← MakeSymbol[$topSpace, LIST[$aliasSpace], normal, MathConstructors.MakeSpace[$thin]];
lineSym ← MakeSymbol[$fractionBar, LIST[$aliasLine], normal, MathConstructors.MakeLine[]];
define compound classes
inverseClass ← MakeUnaryOpClass[$invert, $inv, $a, MathConstructors.MakePlainRope["inv"], "inv a", "recip($a)", "$a ** (-1)"];
negationClass ← MakeUnaryOpClass[$negation, $minus, $a, MathConstructors.MakePlainSym['-], "-a", "-$a", "minus($a)", "Minus[$a]"];
sumClass ← MakeBinOpClass[$sum, $plus, $addend, $augend, MathConstructors.MakePlainSym['+], "a + b", "$addend + $augend", "plus($addend, $augend)", "Plus[$addend, $augend]"];
differenceClass ← MakeBinOpClass[$difference, $minus, $subtrahend, $minuend, MathConstructors.MakePlainSym['-], "a - b", "$subtrahend - $minuend", "difference($subtrahend, $minuend)", "Minus[$subtrahend, $minuend]"];
productClass ← MakeBinOpClass[$product, $times, $multiplier, $multiplicand, MathConstructors.MakeSpace[$product], "a * b", "$multiplier * $multiplicand", "times($multiplier, $multiplicand)", "Mult[$multiplier, $multiplicand]"];
powClass ← MakeCompoundClass[$pow, other, "a^b", LIST[baseArg, exponentArg], NIL, FixedSizeBoxRule, PowCompRule, "$base ** $exponent", "expt($base, $exponent)", "Pow[$base, $exponent]"];
fractionClass ← MakeCompoundClass[$fraction, over, "a / b", LIST[numeratorArg, denominatorArg], LIST[lineSym, numerSpSym, denomSpSym], FractionBoxRule, FractionCompRule, "$numerator / $denominator", "quotient($numerator, $denominator)", "Div[$numerator, $denominator]"];
Register compound classes in user-friendly order
MathDB.InstallCompoundClass[sumClass];
MathDB.AddOperator[sumClass, $Arithmetic];
MathDB.InstallCompoundClass[negationClass];
MathDB.AddOperator[negationClass, $Arithmetic];
MathDB.InstallCompoundClass[differenceClass];
MathDB.AddOperator[differenceClass, $Arithmetic];
MathDB.InstallCompoundClass[productClass];
MathDB.AddOperator[productClass, $Arithmetic];
MathDB.InstallCompoundClass[gcdClass];
MathDB.AddOperator[gcdClass, $Arithmetic];
MathDB.InstallCompoundClass[powClass];
MathDB.AddOperator[powClass, $Arithmetic];
MathDB.InstallCompoundClass[fractionClass];
MathDB.AddOperator[fractionClass, $Arithmetic];
MathDB.InstallCompoundClass[inverseClass];
MathDB.AddOperator[inverseClass, $Arithmetic];
};
InstallArithmeticClassesAA:
PROC [] ~ {
local declarations
absClass, factorialClass: CompoundClass;
aAbsArg, factorialArg: Argument;
leftAbsSym, rightAbsSym, factorialSym, factorialSpSym: Symbol;
define info for "| a |"
aAbsArg ← MakeArgument[$a, LIST[$aliasA, $aliasHot], normal];
leftAbsSym ← MakeSymbol[$leftAbs, NIL, normal, MathConstructors.MakePlainSym['\174]];
rightAbsSym ← MakeSymbol[$rightAbs, NIL, normal, MathConstructors.MakePlainSym['\174]];
define into for factorial
factorialArg ← MakeArgument[$a, LIST[$aliasA, $aliasHot], normal];
factorialSym ← MakeSymbol[$bang, NIL, normal, MathConstructors.MakePlainSym['!]];
factorialSpSym ← MakeSymbol[$space, LIST[$aliasSpace], normal, MathConstructors.MakeSpace[$thin]];
absClass ← MakeCompoundClass[$abs, paren, "| a |", LIST[aAbsArg], LIST[leftAbsSym, rightAbsSym], AbsBoxRule, AbsCompRule, "| $a |"];
factorialClass ← MakeCompoundClass[$factorial, other, "a!", LIST[factorialArg], LIST[factorialSym, factorialSpSym], FixedSizeBoxRule, FactorialCompRule, "$a!"];
MathDB.InstallCompoundClass[absClass];
MathDB.AddOperator[absClass, $Arithmetic];
MathDB.InstallCompoundClass[factorialClass];
MathDB.AddOperator[factorialClass, $Arithmetic];
};