<> <> <> <> DIRECTORY MathExpr, MathRules, MathDB, MathTypes, MathBox, Imager, Rope, Vector, MathConstructors; MathExprClassesAnalysis: CEDAR PROGRAM IMPORTS MathBox, MathRules, MathExpr, MathDB, MathConstructors ~ BEGIN <> EXPR: TYPE ~ MathExpr.EXPR; BOX: TYPE ~ MathBox.BOX; ROPE: TYPE ~ Rope.ROPE; VEC: TYPE ~ Vector.VEC; CompoundBoxProc: TYPE ~ MathRules.CompoundBoxProc; CompositionProc: TYPE ~ MathRules.CompositionProc; Alignment2D: TYPE ~ MathRules.Alignment2D; Offset: TYPE ~ MathRules.Offset; Size: TYPE ~ MathRules.Size; Argument: TYPE ~ MathExpr.Argument; Symbol: TYPE ~ MathExpr.Symbol; CompoundClass: TYPE ~ MathExpr.CompoundClass; FormatClass: TYPE ~ MathTypes.FormatClass; Style: TYPE ~ MathTypes.Style; <> MakeArgument: PROC[name: ATOM, aliases: LIST OF ATOM, size: Size] RETURNS[Argument] ~ MathExpr.MakeArgument; MakeSymbol: PROC[name: ATOM, aliases: LIST OF ATOM, size: Size, value: EXPR] RETURNS[Symbol] ~ MathExpr.MakeSymbol; MakeCompoundClass: PROC[name: ATOM, formatClass: FormatClass, description: ROPE, args: LIST OF Argument, syms: LIST OF Symbol, boxRule: CompoundBoxProc, compBox: CompositionProc, cvtAS, cvtReduce, cvtSMP, cvtOther: ROPE _ NIL] RETURNS[CompoundClass] ~ MathExpr.MakeCompoundClass; <> smallGap: REAL = 0.05; medGap: REAL = 0.10; bigGap: REAL = 0.25; <> FixedSizeBoxRule: CompoundBoxProc ~ { <> RETURN[boxes]; }; FractionBoxRule: CompoundBoxProc ~ { <> <> fbarBox: BOX _ MathBox.GetBox[$fractionBar, boxes]; numBox: BOX _ MathBox.GetBox[$numerator, boxes]; denomBox: BOX _ MathBox.GetBox[$denominator, boxes]; topSpaceBox: BOX _ MathBox.GetBox[$topSpace, boxes]; bottomSpaceBox: BOX _ MathBox.GetBox[$bottomSpace, boxes]; <> scaleX: REAL _ 1.1 * MAX[numBox.Width[], denomBox.Width[] ] / fbarBox.Width[]; <> fbarBox _ MathBox.Scale[fbarBox, [scaleX, 1.0]]; RETURN[LIST[fbarBox, numBox, denomBox, topSpaceBox, bottomSpaceBox]]; }; dDxBoxRule: CompoundBoxProc ~ { <> <> fbarBox: BOX _ MathBox.GetBox[$fractionBar, boxes]; dOfBox: BOX _ MathBox.GetBox[$dOf, boxes]; dxBox: BOX _ MathBox.GetBox[$dx, boxes]; differandBox: BOX _ MathBox.GetBox[$differand, boxes]; wrtBox: BOX _ MathBox.GetBox[$wrt, boxes]; topSpaceBox: BOX _ MathBox.GetBox[$topSpace, boxes]; bottomSpaceBox: BOX _ MathBox.GetBox[$bottomSpace, boxes]; <> scaleX: REAL _ 1.1 * MAX[dOfBox.Width[]+differandBox.Width[], dxBox.Width[]+wrtBox.Width[] ] / fbarBox.Width[]; <> fbarBox _ MathBox.Scale[fbarBox, [scaleX, 1.0]]; RETURN[LIST[fbarBox, dOfBox, dxBox, differandBox, wrtBox, topSpaceBox, bottomSpaceBox]]; }; PartialDerivBoxRule: CompoundBoxProc ~ { <> fbarBox: BOX _ MathBox.GetBox[$fractionBar, boxes]; partialOfBox: BOX _ MathBox.GetBox[$partialOf, boxes]; partialWrtBox: BOX _ MathBox.GetBox[$partialWrt, boxes]; differandBox: BOX _ MathBox.GetBox[$differand, boxes]; wrtBox: BOX _ MathBox.GetBox[$wrt, boxes]; topSpaceBox: BOX _ MathBox.GetBox[$topSpace, boxes]; bottomSpaceBox: BOX _ MathBox.GetBox[$bottomSpace, boxes]; <> scaleX: REAL _ 1.1 * MAX[partialOfBox.Width[]+differandBox.Width[], partialWrtBox.Width[]+wrtBox.Width[] ] / fbarBox.Width[]; <> fbarBox _ MathBox.Scale[fbarBox, [scaleX, 1.0]]; topSpaceBox _ MathBox.Scale[topSpaceBox, [scaleX, 1.0]]; bottomSpaceBox _ MathBox.Scale[bottomSpaceBox, [scaleX, 1.0]]; RETURN[LIST[fbarBox, partialOfBox, partialWrtBox, differandBox, wrtBox, topSpaceBox, bottomSpaceBox]]; }; NRadicalBoxRule: CompoundBoxProc ~ { <> <> radRootBox: BOX _ MathBox.GetBox[$radRoot, boxes]; radLineBox: BOX _ MathBox.GetBox[$radLine, boxes]; nBox: BOX _ MathBox.GetBox[$n, boxes]; spaceBox: BOX _ MathBox.GetBox[$space, boxes]; radicandBox: BOX _ MathBox.GetBox[$radicand, boxes]; <> <> rootScale: REAL _ ((2 * spaceBox.Height[]) + radicandBox.Height[]) / radRootBox.Height[]; lineScale: VEC _ [radicandBox.Width[]/radLineBox.Width[], 1.0]; <> radRootBox _ MathBox.Scale[radRootBox, [rootScale, rootScale]]; radLineBox _ MathBox.Scale[radLineBox, lineScale]; RETURN[LIST[radRootBox, radLineBox, nBox, radicandBox, spaceBox]]; }; SummationBoxRule: CompoundBoxProc ~ { <> <> <> sigmaBox: BOX _ MathBox.GetBox[$sigma, boxes]; lowerboundBox: BOX _ MathBox.GetBox[$lowerbound, boxes]; upperboundBox: BOX _ MathBox.GetBox[$upperbound, boxes]; summandBox: BOX _ MathBox.GetBox[$summand, boxes]; <> <> scaleFac: REAL _ MAX[summandBox.Height[]/sigmaBox.Height[], 1.0]; <> sigmaBox _ MathBox.Scale[sigmaBox, [scaleFac, scaleFac] ]; RETURN[LIST[sigmaBox, lowerboundBox, upperboundBox, summandBox]]; }; IndefiniteIntBoxRule: CompoundBoxProc ~ { <> <> <> integralBox: BOX _ MathBox.GetBox[$integral, boxes]; integrandBox: BOX _ MathBox.GetBox[$integrand, boxes]; spaceBox: BOX _ MathBox.GetBox[$space, boxes]; dxBox: BOX _ MathBox.GetBox[$dx, boxes]; wrtBox: BOX _ MathBox.GetBox[$wrt, boxes]; <> scaleFac: REAL _ MAX[integrandBox.Height[]/integralBox.Height[], 1.0]; <> integralBox _ MathBox.Scale[integralBox, [scaleFac, scaleFac] ]; RETURN[LIST[integralBox, integrandBox, dxBox, wrtBox, spaceBox]]; }; DefiniteIntBoxRule: CompoundBoxProc ~ { <> <> <> integralBox: BOX _ MathBox.GetBox[$integral, boxes]; lowerlimitBox: BOX _ MathBox.GetBox[$lowerlimit, boxes]; upperlimitBox: BOX _ MathBox.GetBox[$upperlimit, boxes]; integrandBox: BOX _ MathBox.GetBox[$integrand, boxes]; spaceBox: BOX _ MathBox.GetBox[$space, boxes]; dxBox: BOX _ MathBox.GetBox[$dx, boxes]; wrtBox: BOX _ MathBox.GetBox[$wrt, boxes]; <> scaleFac: REAL _ MAX[integrandBox.Height[]/integralBox.Height[], 1.0]; <> integralBox _ MathBox.Scale[integralBox, [scaleFac, scaleFac] ]; RETURN[LIST[integralBox, lowerlimitBox, upperlimitBox, integrandBox, dxBox, wrtBox, spaceBox]]; }; RadicalBoxRule: CompoundBoxProc ~ { <> <> radRootBox: BOX _ MathBox.GetBox[$radRoot, boxes]; radLineBox: BOX _ MathBox.GetBox[$radLine, boxes]; spaceBox: BOX _ MathBox.GetBox[$space, boxes]; radicandBox: BOX _ MathBox.GetBox[$radicand, boxes]; <> <> rootScale: REAL _ ((2 * spaceBox.Height[]) + radicandBox.Height[]) / radRootBox.Height[]; lineScale: VEC _ [radicandBox.Width[]/radLineBox.Width[], 1.0]; <> radRootBox _ MathBox.Scale[radRootBox, [rootScale, rootScale]]; radLineBox _ MathBox.Scale[radLineBox, lineScale]; RETURN[LIST[radRootBox, radLineBox, radicandBox, spaceBox]]; }; <> FractionCompRule: CompositionProc ~ { <> tempBox: BOX; tempBoxes: LIST OF BOX; alignments: LIST OF Alignment2D _ LIST[ [$topSpace, [$fractionBar, [center], [center]], [$fractionBar, [bottom], [top]]], [$bottomSpace, [$fractionBar, [center], [center]], [$fractionBar, [top], [bottom]]], [$numerator, [$fractionBar, [center], [center]], [$topSpace, [bottom], [top]]], [$denominator, [$fractionBar, [center], [center]], [$bottomSpace, [top], [bottom]]]]; [tempBox, tempBoxes] _ MathRules.Compose[boxes, alignments, [$fractionBar, [origin]], [$fractionBar, [origin]]]; RETURN[tempBox, tempBoxes]; }; dDxCompRule: CompositionProc ~ { <> tempBox: BOX; tempBoxes: LIST OF BOX; alignments: LIST OF Alignment2D _ LIST[ [$topSpace, [$fractionBar, [center], [center]], [$fractionBar, [bottom], [top]]], [$bottomSpace, [$fractionBar, [center], [center]], [$fractionBar, [top], [bottom]]], [$dOf, [$fractionBar, [left], [left, 0.05]], [$topSpace, [bottom], [top]]], [$differand, [$dOf, [left], [right]], [$dOf, [bottom], [bottom]]], [$dx, [$fractionBar, [left], [left, 0.05]], [$bottomSpace, [top], [bottom]]], [$wrt, [$dx, [left], [right]], [$dx, [origin], [origin]]] ]; [tempBox, tempBoxes] _ MathRules.Compose[boxes, alignments, [$fractionBar, [origin]], [$fractionBar, [origin]]]; RETURN[tempBox, tempBoxes]; }; <> <> <> <> <<[$topSpace,>> <<[$fractionBar, [center], [center]],>> <<[$fractionBar, [bottom], [top]]],>> <<[$bottomSpace,>> <<[$fractionBar, [center], [center]],>> <<[$fractionBar, [top], [bottom]]],>> <<[$partialOf,>> <<[$fractionBar, [left], [left, 0.05]],>> <<[$topSpace, [bottom], [top]]],>> <<[$differand,>> <<[$partialOf, [left], [right]],>> <<[$partialOf, [origin], [origin]]],>> <<[$partialWrt,>> <<[$fractionBar, [right], [center]],>> <<[$bottomSpace, [top], [bottom]]],>> <<[$wrt,>> <<[$partialWrt, [left], [right]],>> <<[$partialWrt, [origin], [origin]]]>> <<];>> <<>> <<[tempBox, tempBoxes] _ MathRules.Compose[boxes, alignments, [$fractionBar, [origin]], [$fractionBar, [origin]]];>> <<>> <> <<};>> PartialDerivCompRule: CompositionProc ~ { tempBox: BOX; tempBoxes: LIST OF BOX; alignments: LIST OF Alignment2D _ LIST[ [$topSpace, [$fractionBar, [center], [center]], [$fractionBar, [bottom], [top]]], [$bottomSpace, [$fractionBar, [center], [center]], [$fractionBar, [top], [bottom]]], [$differand, [$fractionBar, [right], [right, -0.05]], [$topSpace, [bottom], [top]]], [$partialOf, [$differand, [right], [left]], [$differand, [origin], [origin]]], [$partialWrt, [$fractionBar, [right], [center]], [$bottomSpace, [top], [bottom]]], [$wrt, [$partialWrt, [left], [right]], [$partialWrt, [origin], [origin]]] ]; [tempBox, tempBoxes] _ MathRules.Compose[boxes, alignments, [$fractionBar, [origin]], [$fractionBar, [origin]]]; RETURN[tempBox, tempBoxes]; }; LimitCompRule: CompositionProc ~ { <> tempBox: BOX; tempBoxes: LIST OF BOX; limBox: BOX _ MathBox.GetBox[$lim, boxes]; approachesBox: BOX _ MathBox.GetBox[$approaches, boxes]; alignments: LIST OF Alignment2D; IF approachesBox.Width[] > limBox.Width[] THEN { alignments _ LIST[ [$space, [$of, [right], [left]], [$of, [center], [center]]], [$approaches, [$space, [right], [left]], [$space, [top], [bottom]]], [$lim, [$approaches, [center], [center]], [$space, [bottom], [top]]]]; } ELSE { alignments _ LIST[ [$space, [$of, [right], [left]], [$of, [center], [center]]], [$lim, [$space, [right], [left]], [$space, [bottom], [top]]], [$approaches, [$lim, [center], [center]], [$space, [top], [bottom]]]]; }; [tempBox, tempBoxes] _ MathRules.Compose[boxes, alignments, [$approaches, [origin]], [$of, [origin]]]; RETURN[tempBox, tempBoxes]; }; SummationCompRule: CompositionProc ~ { <> << $summand)>> tempBox: BOX; tempBoxes: LIST OF BOX; alignments: LIST OF Alignment2D _ NIL; vertSigmaOffset, vertSummandOffset: Offset; SELECT MathBox.GetBox[$summand, boxes].FormatClass[] FROM over, radical, matrix => { vertSigmaOffset _ [center]; vertSummandOffset _ [center]; }; ENDCASE => { vertSummandOffset _ [origin]; vertSigmaOffset _ [center, -0.2]; }; alignments _ LIST[ [$lowerbound, [$sigma, [center], [center]], [$sigma, [top], [bottom, -smallGap]]], [$upperbound, [$sigma, [center], [center]], [$sigma, [bottom], [top, +smallGap]]], [$summand, [$sigma, [left], [right, medGap]], [$sigma, vertSummandOffset, vertSigmaOffset]]]; [tempBox, tempBoxes] _ MathRules.Compose[boxes, alignments, [$sigma, [origin]], [$sigma, [center, -0.2]]]; RETURN[tempBox, tempBoxes]; }; NRadicalCompRule: CompositionProc ~ { <> tempBox: BOX; tempBoxes: LIST OF BOX; alignments: LIST OF Alignment2D _ LIST[ [$radRoot, [$radicand, [right], [left]], [$radicand, [center], [center]]], [$space, [$radicand, [center], [center]], [$radicand, [bottom], [top]]], [$radLine, [$radRoot, [left], [right]], [$radRoot, [top], [top]]], [$n, [$radRoot, [right], [left, bigGap]], [$radRoot, [bottom], [center, +smallGap]]]]; [tempBox, tempBoxes] _ MathRules.Compose[boxes, alignments, [$n, [origin]], [$radicand, [center, -0.4]]]; RETURN[tempBox, tempBoxes]; }; RadicalCompRule: CompositionProc ~ { <> tempBox: BOX; tempBoxes: LIST OF BOX; alignments: LIST OF Alignment2D _ LIST[ [$radRoot, [$radicand, [right], [left]], [$radicand, [center], [center]]], [$space, [$radicand, [center], [center]], [$radicand, [bottom], [top]]], [$radLine, [$radRoot, [left], [right]], [$radRoot, [top], [top]]]]; [tempBox, tempBoxes] _ MathRules.Compose[boxes, alignments, [$radicand, [origin]], [$radicand, [origin]]]; RETURN[tempBox, tempBoxes]; }; IntegrationCompRule: CompositionProc ~ { <> << $upperlimit $integrand $dx $wrt)>> tempBox: BOX; tempBoxes: LIST OF BOX; alignments: LIST OF Alignment2D _ NIL; vertIntegralOffset, vertIntegrandOffset: Offset; SELECT MathBox.GetBox[$integrand, boxes].FormatClass[] FROM over, radical, matrix => { vertIntegralOffset _ [center]; vertIntegrandOffset _ [center]; }; ENDCASE => { vertIntegralOffset _ [center, -0.2]; vertIntegrandOffset _ [origin]; }; alignments _ LIST[ [$lowerlimit, [$integral, [right], [left, +bigGap]], [$integral, [top], [bottom, -smallGap]]], [$upperlimit, [$integral, [right], [right]], [$integral, [bottom], [top, +smallGap]]], [$integrand, [$integral, [left], [right]], [$integral, vertIntegrandOffset, vertIntegralOffset]], [$space, [$integrand, [left], [right]], [$integrand, [origin], [origin]]], [$dx, [$space, [left], [right]], <<[$space, [origin], [origin]]], -- Carl's original y-alignment>> [$integral, vertIntegrandOffset, vertIntegralOffset ]], -- dsa 4/15/87 [$wrt, [$dx, [left], [right]], [$dx, [origin], [origin]]]]; [tempBox, tempBoxes] _ MathRules.Compose[boxes, alignments, [$lowerlimit, [origin]], [$integral, [center, -0.2]]]; RETURN[tempBox, tempBoxes]; }; IndefiniteIntCompRule: CompositionProc ~ { <> tempBox: BOX; tempBoxes: LIST OF BOX; vertIntegralOffset, vertIntegrandOffset: Offset; alignments: LIST OF Alignment2D _ NIL; SELECT MathBox.GetBox[$integrand, boxes].FormatClass[] FROM over, radical, matrix => { vertIntegralOffset _ [center]; vertIntegrandOffset _ [center]; }; ENDCASE => { vertIntegralOffset _ [center, -0.2]; vertIntegrandOffset _ [origin]; }; alignments _ LIST[ [$integrand, [$integral, [left], [right]], [$integral, vertIntegrandOffset, vertIntegralOffset ]], [$space, [$integrand, [left], [right]], [$integrand, [origin], [origin]]], [$dx, [$space, [left], [right,]], <<[$space, [origin], [origin]]], -- Carl's original y-alignment>> [$integral, vertIntegrandOffset, vertIntegralOffset ]], -- dsa 4/15/87 [$wrt, [$dx, [left], [right]], [$dx, [origin], [origin]]]]; [tempBox, tempBoxes] _ MathRules.Compose[boxes, alignments, [$integral, [origin]], [$integral, [center, -0.2]]]; RETURN[tempBox, tempBoxes]; }; UnaryOpCompRule: CompositionProc ~ { <> tempBox: BOX; tempBoxes: LIST OF BOX; alignments: LIST OF Alignment2D _ LIST[ [$aliasSpace, [$aliasUnaryOp, [left], [right]], [$aliasUnaryOp, [origin], [origin]]], [$aliasA, [$aliasSpace, [left], [right]], [$aliasSpace, [origin], [origin]]]]; [tempBox, tempBoxes] _ MathRules.Compose[boxes, alignments, [$aliasUnaryOp, [origin]], [$aliasUnaryOp, [origin]]]; RETURN[tempBox, tempBoxes]; }; BinaryOpCompRule: CompositionProc ~ { <> << symbols $aliasLeftSpace & $aliasRightSpace.>> <<>> tempBox: BOX; tempBoxes: LIST OF BOX; leftVertOffsetA, leftVertOffsetOp, rightVertOffsetB, rightVertOffsetOp: Offset; alignments: LIST OF Alignment2D; <> SELECT MathBox.GetBox[$aliasA, boxes].FormatClass[] FROM over => { leftVertOffsetA _ [origin]; leftVertOffsetOp _ [center]; }; matrix => { leftVertOffsetA _ [center]; leftVertOffsetOp _ [center]; }; ENDCASE => { leftVertOffsetA _ [origin]; leftVertOffsetOp _ [origin]; }; SELECT MathBox.GetBox[$aliasB, boxes].FormatClass[] FROM over => { rightVertOffsetB _ [origin]; rightVertOffsetOp _ [center]; }; matrix => { rightVertOffsetB _ [center]; rightVertOffsetOp _ [center]; }; ENDCASE => { rightVertOffsetB _ [origin]; rightVertOffsetOp _ [origin]; }; alignments _ LIST[ [$aliasLeftSpace, [$aliasBinOp, [right], [left]], [$aliasBinOp, [origin], [origin]]], [$aliasA, [$aliasLeftSpace, [right], [left]], [$aliasBinOp, leftVertOffsetA, leftVertOffsetOp]], [$aliasRightSpace, [$aliasBinOp, [left], [right]], [$aliasBinOp, [origin], [origin]]], [$aliasB, [$aliasRightSpace, [left], [right]], [$aliasBinOp, rightVertOffsetB, rightVertOffsetOp]]]; [tempBox, tempBoxes] _ MathRules.Compose[boxes, alignments, [$aliasA, [origin]], [$aliasBinOp, [origin]]]; RETURN[tempBox, tempBoxes]; }; RelationCompRule: CompositionProc ~ { <> << symbols $aliasLeftSpace & $aliasRightSpace.>> <<>> tempBox: BOX; tempBoxes: LIST OF BOX; leftVertOffsetLHS, leftVertOffsetRel, rightVertOffsetRHS, rightVertOffsetRel: Offset; alignments: LIST OF Alignment2D; <> SELECT MathBox.GetBox[$aliasLHS, boxes].FormatClass[] FROM over => { leftVertOffsetLHS _ [origin]; leftVertOffsetRel _ [center]; }; matrix => { leftVertOffsetLHS _ [center]; leftVertOffsetRel _ [center]; }; ENDCASE => { leftVertOffsetLHS _ [origin]; leftVertOffsetRel _ [origin]; }; SELECT MathBox.GetBox[$aliasRHS, boxes].FormatClass[] FROM over => { rightVertOffsetRHS _ [origin]; rightVertOffsetRel _ [center]; }; matrix => { rightVertOffsetRHS _ [center]; rightVertOffsetRel _ [center]; }; ENDCASE => { rightVertOffsetRHS _ [origin]; rightVertOffsetRel _ [origin]; }; alignments _ LIST[ [$aliasLeftSpace, [$aliasRelation, [right], [left]], [$aliasRelation, [origin], [origin]]], [$aliasLHS, [$aliasLeftSpace, [right], [left]], [$aliasRelation, leftVertOffsetLHS, leftVertOffsetRel]], [$aliasRightSpace, [$aliasRelation, [left], [right]], [$aliasRelation, [origin], [origin]]], [$aliasRHS, [$aliasRightSpace, [left], [right]], [$aliasRelation, rightVertOffsetRHS, rightVertOffsetRel]]]; [tempBox, tempBoxes] _ MathRules.Compose[boxes, alignments, [$aliasLHS, [origin]], [$aliasRelation, [origin]]]; RETURN[tempBox, tempBoxes]; }; <> MakeUnaryOpClass: PUBLIC PROC[class, op, arg: ATOM, operation: EXPR, description: ROPE, cvtAS, cvtReduce, cvtSMP, cvtOther: ROPE _ NIL] RETURNS[CompoundClass] ~ { <> << The alignment is "operation arg"; alignment is thru baselines. >> << Both op, arg are of fixed size "normal".>> <<>> argArg: Argument _ MakeArgument[arg, LIST[$aliasA, $aliasHot], normal]; spaceSym: Symbol _ MakeSymbol[$Space, LIST[$aliasSpace], normal, MathConstructors.MakeSpace[$medium]]; unaryOpSym: Symbol _ MakeSymbol[op, LIST[$aliasUnaryOp], normal, operation]; RETURN[MakeCompoundClass[class, unaryOp, description, LIST[argArg], LIST[unaryOpSym, spaceSym], FixedSizeBoxRule, UnaryOpCompRule, cvtAS]]; }; MakeBinOpClass: PUBLIC PROC[class, op, a, b: ATOM, operation: EXPR, description: ROPE, cvtAS, cvtReduce, cvtSMP, cvtOther: ROPE _ NIL] RETURNS[CompoundClass] ~ { <> << The alignment is "a operation b"; alignment is thru baselines. >> << All of a, b, op are of fixed size "normal".>> aArg: Argument _ MakeArgument[a, LIST[$aliasA, $aliasHot], normal]; bArg: Argument _ MakeArgument[b, LIST[$aliasB], normal]; opSym: Symbol _ MakeSymbol[op, LIST[$aliasBinOp], normal, operation]; leftSpace: Symbol _ MakeSymbol[$leftThinSpace, LIST[$aliasLeftSpace], normal, MathConstructors.MakeSpace[$thin]]; rightSpace: Symbol _ MakeSymbol[$rightThinSpace, LIST[$aliasRightSpace], normal, MathConstructors.MakeSpace[$thin]]; RETURN[MakeCompoundClass[class, binaryOp, description, LIST[aArg, bArg], LIST[opSym, leftSpace, rightSpace], FixedSizeBoxRule, BinaryOpCompRule, cvtAS]]; }; MakeRelationClass: PUBLIC PROC[class, rel, lhs, rhs: ATOM, relation: EXPR, description: ROPE, cvtAS, cvtReduce, cvtSMP, cvtOther: ROPE _ NIL] RETURNS[CompoundClass] ~ { <> << The alignment is "lhs relation rhs"; alignment is thru baselines. >> << All of lhs, rhs, rel are of fixed size "normal".>> lhsArg: Argument _ MakeArgument[lhs, LIST[$aliasLHS, $aliasHot], normal]; rhsArg: Argument _ MakeArgument[rhs, LIST[$aliasRHS], normal]; relSym: Symbol _ MakeSymbol[rel, LIST[$aliasRelation], normal, relation]; leftSpace: Symbol _ MakeSymbol[$leftSpace, LIST[$aliasLeftSpace], normal, MathConstructors.MakeSpace[$thick]]; rightSpace: Symbol _ MakeSymbol[$rightSpace, LIST[$aliasRightSpace], normal, MathConstructors.MakeSpace[$thick]]; RETURN[MakeCompoundClass[class, relation, description, LIST[lhsArg, rhsArg], LIST[relSym, leftSpace, rightSpace], FixedSizeBoxRule, RelationCompRule, cvtAS]]; }; <> wrongBoxType: PUBLIC ERROR = CODE; <> InstallAnalysisClassesAA: PROC [] ~ { <> summationClass, integrationClass, indefIntClass, nRadicalClass, radicalClass, limitClass, dDxClass, partialDerivClass: CompoundClass; lbArg, ubArg, summandArg, llimArg, ulimArg, integrandArg, wrtArg, nArg, radicandArg, ofArg, approachesArg, differandArg: Argument; sigmaSym, integralSym, dxSym, lineSym, radRootSym, radLineSym, integralSpaceSym, limSym, limSpaceSym, radSpaceSym, dOfSym, partialOfSym, partialWrtSym: Symbol; numerSpSym, denomSpSym: Symbol; <> lbArg _ MakeArgument[$lowerbound, NIL, script]; ubArg _ MakeArgument[$upperbound, NIL, script]; summandArg _ MakeArgument[$summand, LIST[$aliasHot], normal]; sigmaSym _ MakeSymbol[$sigma, LIST[$aliasOp], normal, MathConstructors.MakeBigMathSym['\172]]; <> 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, MathConstructors.MakeBigMathSym['\165]]; dxSym _ MakeSymbol[$dx, NIL, normal, MathConstructors.MakeItalSym['d]]; integralSpaceSym _ MakeSymbol[$space, LIST[$aliasSpace], normal, MathConstructors.MakeSpace[$thick]]; <> denomSpSym _ MakeSymbol[$bottomSpace, LIST[$aliasSpace], normal, MathConstructors.MakeSpace[$medium]]; numerSpSym _ MakeSymbol[$topSpace, LIST[$aliasSpace], normal, MathConstructors.MakeSpace[$medium]]; lineSym _ MakeSymbol[$fractionBar, LIST[$aliasLine], normal, MathConstructors.MakeLine[]]; differandArg _ MakeArgument[$differand, LIST[$aliasHot], normal]; dOfSym _ MakeSymbol[$dOf, NIL, normal, MathConstructors.MakeItalSym['d]]; <> partialOfSym _ MakeSymbol[$partialOf, NIL, normal, MathConstructors.MakeBigMathSym['\272]]; partialWrtSym _ MakeSymbol[$partialWrt, NIL, normal, MathConstructors.MakeBigMathSym['\272]]; <> nArg _ MakeArgument[$n, LIST[$aliasB], script]; radicandArg _ MakeArgument[$radicand, LIST[$aliasA, $aliasHot], normal]; radRootSym _ MakeSymbol[$radRoot, NIL, normal, MathConstructors.MakeBigMathSym['\174]]; radLineSym_ MakeSymbol[$radLine, LIST[$aliasLine], normal, MathConstructors.MakeLine[]]; radSpaceSym _ MakeSymbol[$space, LIST[$aliasSpace], normal, MathConstructors.MakeSpace[$medium]]; <> ofArg _ MakeArgument[$of, LIST[$aliasA, $aliasHot], normal]; approachesArg _ MakeArgument[$approaches, NIL, script]; limSpaceSym _ MakeSymbol[$space, LIST[$aliasSpace], normal, MathConstructors.MakeSpace[$limit]]; limSym _ MakeSymbol[$lim, NIL, script, MathConstructors.MakePlainRope["lim"]]; summationClass _ MakeCompoundClass[$summation, op, "summation", LIST[lbArg, ubArg, summandArg], LIST[sigmaSym], SummationBoxRule, SummationCompRule, "(summation $lowerbound $upperbound $summand)"]; integrationClass _ MakeCompoundClass[$integration, op, "def integration", LIST[llimArg, ulimArg, integrandArg, wrtArg], LIST[integralSym, dxSym, integralSpaceSym], DefiniteIntBoxRule, IntegrationCompRule, "(integral $lowerlimit $upperlimit $integrand $wrt)", "Int[$integrand, $wrt, $lowerlimit, $upperlimit]"]; indefIntClass _ MakeCompoundClass[$indefInt, op, "indef integration", LIST[integrandArg, wrtArg], LIST[integralSym, dxSym, integralSpaceSym], IndefiniteIntBoxRule, IndefiniteIntCompRule, "(indefIntegral $integrand $wrt)", "int($integrand, $wrt)", "Int[$integrand, $wrt]"]; dDxClass _ MakeCompoundClass[$dDx, over, "dF / dx", LIST[differandArg, wrtArg], LIST[lineSym, dOfSym, dxSym, numerSpSym, denomSpSym], dDxBoxRule, dDxCompRule, "d $differand / d $wrt", "df($differand, $wrt)", "Diff[$differand, $wrt]"]; partialDerivClass _ MakeCompoundClass[$partialDeriv, over, "partial Derivative", LIST[differandArg, wrtArg], LIST[lineSym, partialOfSym, partialWrtSym, numerSpSym, denomSpSym], PartialDerivBoxRule, PartialDerivCompRule, "partial $differand / partial $wrt", "df($differand, $wrt)", "Diff[$differand, $wrt]"]; 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)"]; <> <<>> MathDB.InstallCompoundClass[summationClass]; MathDB.AddOperator[summationClass, $Analysis]; MathDB.InstallCompoundClass[limitClass]; MathDB.AddOperator[limitClass, $Analysis]; MathDB.InstallCompoundClass[integrationClass]; MathDB.AddOperator[integrationClass, $Analysis]; MathDB.InstallCompoundClass[indefIntClass]; MathDB.AddOperator[indefIntClass, $Analysis]; MathDB.InstallCompoundClass[dDxClass]; MathDB.AddOperator[dDxClass, $Analysis]; MathDB.InstallCompoundClass[partialDerivClass]; MathDB.AddOperator[partialDerivClass, $Analysis]; MathDB.InstallCompoundClass[radicalClass]; MathDB.AddOperator[radicalClass, $Analysis]; MathDB.InstallCompoundClass[nRadicalClass]; MathDB.AddOperator[nRadicalClass, $Analysis]; }; InstallAnalysisClassesB: PROC [] ~ { <> approxEqFormulaClass, approachesClass: CompoundClass; <> approxEqFormulaClass _ MakeRelationClass[$approxEqFormula, $equals, $lhs, $rhs, MathConstructors.MakeBigMathSym['\167], "a approx= b", "$lhs approx= $rhs"]; approachesClass _ MakeRelationClass[$approachesFormula, $approaches, $lhs, $rhs, MathConstructors.MakePlainSym['\256], "a -> b", "$lhs -> $rhs"]; <<>> MathDB.InstallCompoundClass[approachesClass]; MathDB.AddOperator[approachesClass, $Analysis]; MathDB.InstallCompoundClass[approxEqFormulaClass]; MathDB.AddOperator[approxEqFormulaClass, $Analysis]; }; <> InstallAnalysisClassesAA[]; InstallAnalysisClassesB[]; END.