Reading a number of questions about infix operator notations I want to ask if somebody could reimplement the problem below in a simpler way, say modifying UnicodeCharacters.tr file?
In geometric (Clifford) algebra one uses three different product: inner (.), outer (^) and geometric (clifford) $\circ$. Lets assume that inner have highest precedence, then goes outer and geometric product precedence is lowest. Plus precedence is lower that any of products, and Times precedence is equal of geometric product itself.
My solution is as follows:
$GAPackageInputAliases = {};
$GAInstallProperties = {WedgeFont -> "ArialUnicodeMSFontForAllOS"};
If[(WedgeFont /. $GAInstallProperties) ===
"ArialUnicodeMSFontForAllOS", $GAPackageInputAliases =
Join[$GAPackageInputAliases, {"ip" ->
RowBox[{" ", "∙", " ", "\[SelectionPlaceholder]"}],
"il" -> RowBox[{" ",
StyleBox["⎦", FontFamily -> "Arial Unicode MS"], " ",
"\[SelectionPlaceholder]"}],
"ir" -> RowBox[{" ",
StyleBox["⎣", FontFamily -> "Arial Unicode MS"], " ",
"\[SelectionPlaceholder]"}],
"op" -> RowBox[{" ",
StyleBox["⋏", FontFamily -> "Arial Unicode MS"], " ",
"\[SelectionPlaceholder]"}],
"gp" -> RowBox[{" ", "\[EmptySmallCircle]", " ",
"\[SelectionPlaceholder]"}]}];,
If[$SystemID === "Windows", $GAPackageInputAliases =
Join[$GAPackageInputAliases, {"ip" ->
RowBox[{" ", "∙", " ", "\[SelectionPlaceholder]"}],
"il" -> RowBox[{" ",
StyleBox["⎦", FontFamily -> "Arial Unicode MS"], " ",
"\[SelectionPlaceholder]"}],
"ir" ->
RowBox[{" ", StyleBox["⎣", FontFamily -> "Arial Unicode MS"],
" ", "\[SelectionPlaceholder]"}],
"op" -> RowBox[{" ",
StyleBox["⋏", FontFamily -> "Arial Unicode MS"], " ",
"\[SelectionPlaceholder]"}],
"gp" -> RowBox[{" ", "\[EmptySmallCircle]", " ",
"\[SelectionPlaceholder]"}]}],
$GAPackageInputAliases =
Join[$GAPackageInputAliases, {"ip" ->
RowBox[{" ", "∙", " ", "\[SelectionPlaceholder]"}],
"il" -> RowBox[{" ", "⎦", " ", "\[SelectionPlaceholder]"}],
"ir" -> RowBox[{" ", "⎣", " ", "\[SelectionPlaceholder]"}],
"op" -> RowBox[{" ", "⋏", " ", "\[SelectionPlaceholder]"}],
"gp" -> RowBox[{" ", "\[EmptySmallCircle]", " ",
"\[SelectionPlaceholder]"}]}]]];
SetOptions[System`$FrontEndSession,
InputAliases ->
Join[CurrentValue[System`$FrontEndSession,
InputAliases], $GAPackageInputAliases]];
MakeExpression[y_String, StandardForm] :=
MakeExpression[
StringReplace[
y, {"∙" -> "\[CircleDot]", "⎦" -> "\[Vee]", "⎣" -> "\[Wedge]"}],
StandardForm] /; ! StringFreeQ[y, {"∙", "⎦", "⎣"}]
MakeExpression[RowBox[{x___, y_String, w___}], StandardForm] :=
MakeExpression[
RowBox[{x,
StringReplace[
y, {"∙" -> "\[CircleDot]", "⎦" -> "\[Vee]", "⎣" -> "\[Wedge]"}],
w}], StandardForm] /; !
StringFreeQ[StringJoin[{y}], {"∙", "⎦", "⎣"}]
MakeExpression[y_RowBox | _StyleBox, StandardForm] :=
MakeExpression[
ReplaceAll[
y, {StyleBox["⎦", FontFamily -> "Arial Unicode MS"] -> "\[Vee]",
StyleBox["⎣", FontFamily -> "Arial Unicode MS"] -> "\[Wedge]"}],
StandardForm] /; (!
FreeQ[y, StyleBox["⎦", FontFamily -> "Arial Unicode MS"],
Infinity]) || (!
FreeQ[y, StyleBox["⎣", FontFamily -> "Arial Unicode MS"],
Infinity])
MakeExpression[y_RowBox | _StyleBox, StandardForm] :=
MakeExpression[
ReplaceAll[
y, {StyleBox["⋏", FontFamily -> "Arial Unicode MS"] ->
"\[CircleTimes]"}], StandardForm] /; !
FreeQ[y, StyleBox["⋏", FontFamily -> "Arial Unicode MS"],
Infinity]
MakeExpression[y_String, StandardForm] :=
MakeExpression[StringReplace[y, {"⋏" -> "\[CircleTimes]"}],
StandardForm] /; ! StringFreeQ[y, "⋏"]
MakeExpression[RowBox[{x___, y_String, w___}], StandardForm] :=
MakeExpression[
RowBox[{x, StringReplace[y, {"⋏" -> "\[CircleTimes]"}], w}],
StandardForm] /; ! StringFreeQ[StringJoin[{y}], "⋏"]
MakeExpression[y_String, StandardForm] :=
MakeExpression[
StringReplace[y, {"\[EmptySmallCircle]" -> "\[CirclePlus]"}],
StandardForm] /; ! StringFreeQ[y, "\[EmptySmallCircle]"]
MakeExpression[RowBox[{x___, y_String, w___}], StandardForm] :=
MakeExpression[
RowBox[{x,
StringReplace[y, {"\[EmptySmallCircle]" -> "\[CirclePlus]"}],
w}], StandardForm] /; !
StringFreeQ[StringJoin[{y}], "\[EmptySmallCircle]"]
CirclePlus = GeometricProduct; GP = GeometricProduct;
CircleTimes = OuterProduct; OP = OuterProduct;
Vee = LeftContract; LC = LeftContract;
Wedge = RightContract; RC = RightContract;
CircleDot = InnerProduct; IP = InnerProduct;
Protect[CirclePlus, CircleTimes, Vee, Wedge, CircleDot];
MakeBoxes[InnerProduct[y_], StandardForm] :=
MakeBoxes[y] /; !
MemberQ[{RightContract, LeftContract, OuterProduct,
GeometricProduct, Plus}, Head[y]]
MakeBoxes[InnerProduct[y_], StandardForm] :=
RowBox[{"(", MakeBoxes[y], ")"}] /;
MemberQ[{RightContract, LeftContract, OuterProduct,
GeometricProduct, Plus}, Head[y]]
MakeBoxes[RightContract[y_], StandardForm] :=
MakeBoxes[y] /; !
MemberQ[{LeftContract, OuterProduct, GeometricProduct, Plus},
Head[y]]
MakeBoxes[RightContract[y_], StandardForm] :=
RowBox[{"(", MakeBoxes[y], ")"}] /;
MemberQ[{LeftContract, OuterProduct, GeometricProduct, Plus},
Head[y]]
MakeBoxes[LeftContract[y_], StandardForm] :=
MakeBoxes[y] /; !
MemberQ[{OuterProduct, GeometricProduct, Plus}, Head[y]]
MakeBoxes[LeftContract[y_], StandardForm] :=
RowBox[{"(", MakeBoxes[y], ")"}] /;
MemberQ[{OuterProduct, GeometricProduct, Plus}, Head[y]]
MakeBoxes[OuterProduct[y_], StandardForm] :=
MakeBoxes[y] /; ! MemberQ[{GeometricProduct, Plus}, Head[y]]
MakeBoxes[OuterProduct[y_], StandardForm] :=
RowBox[{"(", MakeBoxes[y], ")"}] /;
MemberQ[{GeometricProduct, Plus}, Head[y]]
MakeBoxes[GeometricProduct[y_], StandardForm] :=
MakeBoxes[y] /; Head[y] =!= Plus
MakeBoxes[GeometricProduct[y_], StandardForm] :=
RowBox[{"(", MakeBoxes[y], ")"}] /; Head[y] === Plus
MakeBoxes[InnerProduct[x_, y__], StandardForm] :=
RowBox[{RowBox[
Flatten[{MakeBoxes[x], "∙", MakeBoxes[InnerProduct[y]]}]]}] /; !
MemberQ[{RightContract, LeftContract, OuterProduct,
GeometricProduct, Plus}, Head[x]]
MakeBoxes[InnerProduct[x_, y__], StandardForm] :=
RowBox[Flatten[{"(", MakeBoxes[x], ")", "∙",
MakeBoxes[InnerProduct[y]]}]] /;
MemberQ[{RightContract, LeftContract, OuterProduct,
GeometricProduct, Plus}, Head[x]]
MakeBoxes[InnerProduct[y__, x_], StandardForm] :=
RowBox[{RowBox[
Flatten[{MakeBoxes[InnerProduct[y]], "∙", MakeBoxes[x]}]]}] /; !
MemberQ[{RightContract, LeftContract, OuterProduct,
GeometricProduct, Plus}, Head[x]]
MakeBoxes[InnerProduct[y__, x_], StandardForm] :=
RowBox[Flatten[{MakeBoxes[InnerProduct[y]], "∙", "(", MakeBoxes[x],
")"}]] /;
MemberQ[{RightContract, LeftContract, OuterProduct,
GeometricProduct, Plus}, Head[x]]
If[(WedgeFont /. $GAInstallProperties) ===
"UseArialUnicodeMSFontForAllOS" || $SystemID === "Windows",
MakeBoxes[RightContract[x_, y__], StandardForm] :=
RowBox[{RowBox[
Flatten[{MakeBoxes[x],
StyleBox["⎣", FontFamily -> "Arial Unicode MS"],
MakeBoxes[RightContract[y]]}]]}] /; !
MemberQ[{LeftContract, OuterProduct, GeometricProduct, Plus},
Head[x]];
MakeBoxes[RightContract[x_, y__], StandardForm] :=
RowBox[Flatten[{"(", MakeBoxes[x], ")",
StyleBox["⎣", FontFamily -> "Arial Unicode MS"],
MakeBoxes[RightContract[y]]}]] /;
MemberQ[{LeftContract, OuterProduct, GeometricProduct, Plus},
Head[x]];
MakeBoxes[RightContract[y__, x_], StandardForm] :=
RowBox[{RowBox[
Flatten[{MakeBoxes[RightContract[y]],
StyleBox["⎣", FontFamily -> "Arial Unicode MS"],
MakeBoxes[x]}]]}] /; !
MemberQ[{LeftContract, OuterProduct, GeometricProduct, Plus},
Head[x]];
MakeBoxes[RightContract[y__, x_], StandardForm] :=
RowBox[Flatten[{MakeBoxes[RightContract[y]],
StyleBox["⎣", FontFamily -> "Arial Unicode MS"], "(",
MakeBoxes[x], ")"}]] /;
MemberQ[{LeftContract, OuterProduct, GeometricProduct, Plus},
Head[x]];,
MakeBoxes[RightContract[x_, y__], StandardForm] :=
RowBox[{RowBox[
Flatten[{MakeBoxes[x], "⎣",
MakeBoxes[RightContract[y]]}]]}] /; !
MemberQ[{LeftContract, OuterProduct, GeometricProduct, Plus},
Head[x]];
MakeBoxes[RightContract[x_, y__], StandardForm] :=
RowBox[Flatten[{"(", MakeBoxes[x], ")", "⎣",
MakeBoxes[RightContract[y]]}]] /;
MemberQ[{LeftContract, OuterProduct, GeometricProduct, Plus},
Head[x]];
MakeBoxes[RightContract[y__, x_], StandardForm] :=
RowBox[{RowBox[
Flatten[{MakeBoxes[RightContract[y]], "⎣",
MakeBoxes[x]}]]}] /; !
MemberQ[{LeftContract, OuterProduct, GeometricProduct, Plus},
Head[x]];
MakeBoxes[RightContract[y__, x_], StandardForm] :=
RowBox[Flatten[{MakeBoxes[RightContract[y]], "⎣", "(", MakeBoxes[x],
")"}]] /;
MemberQ[{LeftContract, OuterProduct, GeometricProduct, Plus},
Head[x]];]
If[(WedgeFont /. $GAInstallProperties) ===
"UseArialUnicodeMSFontForAllOS" || $SystemID === "Windows",
MakeBoxes[LeftContract[x_, y__], StandardForm] :=
RowBox[{RowBox[
Flatten[{MakeBoxes[x],
StyleBox["⎦", FontFamily -> "Arial Unicode MS"],
MakeBoxes[LeftContract[y]]}]]}] /; !
MemberQ[{OuterProduct, GeometricProduct, Plus}, Head[x]];
MakeBoxes[LeftContract[x_, y__], StandardForm] :=
RowBox[Flatten[{"(", MakeBoxes[x], ")",
StyleBox["⎦", FontFamily -> "Arial Unicode MS"],
MakeBoxes[LeftContract[y]]}]] /;
MemberQ[{OuterProduct, GeometricProduct, Plus}, Head[x]];
MakeBoxes[LeftContract[y__, x_], StandardForm] :=
RowBox[{RowBox[
Flatten[{MakeBoxes[LeftContract[y]],
StyleBox["⎦", FontFamily -> "Arial Unicode MS"],
MakeBoxes[x]}]]}] /; !
MemberQ[{OuterProduct, GeometricProduct, Plus}, Head[x]];
MakeBoxes[LeftContract[y__, x_], StandardForm] :=
RowBox[Flatten[{MakeBoxes[LeftContract[y]],
StyleBox["⎦", FontFamily -> "Arial Unicode MS"], "(",
MakeBoxes[x], ")"}]] /;
MemberQ[{OuterProduct, GeometricProduct, Plus}, Head[x]];,
MakeBoxes[LeftContract[x_, y__], StandardForm] :=
RowBox[{RowBox[
Flatten[{MakeBoxes[x], "⎦",
MakeBoxes[LeftContract[y]]}]]}] /; !
MemberQ[{OuterProduct, GeometricProduct, Plus}, Head[x]];
MakeBoxes[LeftContract[x_, y__], StandardForm] :=
RowBox[Flatten[{"(", MakeBoxes[x], ")", "⎦",
MakeBoxes[LeftContract[y]]}]] /;
MemberQ[{OuterProduct, GeometricProduct, Plus}, Head[x]];
MakeBoxes[LeftContract[y__, x_], StandardForm] :=
RowBox[{RowBox[
Flatten[{MakeBoxes[LeftContract[y]], "⎦",
MakeBoxes[x]}]]}] /; !
MemberQ[{OuterProduct, GeometricProduct, Plus}, Head[x]];
MakeBoxes[LeftContract[y__, x_], StandardForm] :=
RowBox[Flatten[{MakeBoxes[LeftContract[y]], "⎦", "(", MakeBoxes[x],
")"}]] /;
MemberQ[{OuterProduct, GeometricProduct, Plus}, Head[x]];]
If[(WedgeFont /. $GAInstallProperties) ===
"UseArialUnicodeMSFontForAllOS" || $SystemID === "Windows",
MakeBoxes[OuterProduct[x_, y__], StandardForm] :=
RowBox[{RowBox[
Flatten[{MakeBoxes[x],
StyleBox["⋏", FontFamily -> "Arial Unicode MS"],
MakeBoxes[OuterProduct[y]]}]]}] /; !
MemberQ[{GeometricProduct, Plus}, Head[x]];
MakeBoxes[OuterProduct[x_, y__], StandardForm] :=
RowBox[Flatten[{"(", MakeBoxes[x], ")",
StyleBox["⋏", FontFamily -> "Arial Unicode MS"],
MakeBoxes[OuterProduct[y]]}]] /;
MemberQ[{GeometricProduct, Plus}, Head[x]];
MakeBoxes[OuterProduct[y__, x_], StandardForm] :=
RowBox[{RowBox[
Flatten[{MakeBoxes[OuterProduct[y]],
StyleBox["⋏", FontFamily -> "Arial Unicode MS"],
MakeBoxes[x]}]]}] /; !
MemberQ[{GeometricProduct, Plus}, Head[x]];
MakeBoxes[OuterProduct[y__, x_], StandardForm] :=
RowBox[Flatten[{MakeBoxes[OuterProduct[y]],
StyleBox["⋏", FontFamily -> "Arial Unicode MS"], "(",
MakeBoxes[x], ")"}]] /;
MemberQ[{GeometricProduct, Plus}, Head[x]];,
MakeBoxes[OuterProduct[x_, y__], StandardForm] :=
RowBox[{RowBox[
Flatten[{MakeBoxes[x], "⋏",
MakeBoxes[OuterProduct[y]]}]]}] /; !
MemberQ[{GeometricProduct, Plus}, Head[x]];
MakeBoxes[OuterProduct[x_, y__], StandardForm] :=
RowBox[Flatten[{"(", MakeBoxes[x], ")", "⋏",
MakeBoxes[OuterProduct[y]]}]] /;
MemberQ[{GeometricProduct, Plus}, Head[x]];
MakeBoxes[OuterProduct[y__, x_], StandardForm] :=
RowBox[{RowBox[
Flatten[{MakeBoxes[OuterProduct[y]], "⋏",
MakeBoxes[x]}]]}] /; !
MemberQ[{GeometricProduct, Plus}, Head[x]];
MakeBoxes[OuterProduct[y__, x_], StandardForm] :=
RowBox[Flatten[{MakeBoxes[OuterProduct[y]], "⋏", "(", MakeBoxes[x],
")"}]] /; MemberQ[{GeometricProduct, Plus}, Head[x]];]
MakeBoxes[GeometricProduct[x_, y__], StandardForm] :=
RowBox[{RowBox[
Flatten[{MakeBoxes[x], "\[EmptySmallCircle]",
MakeBoxes[GeometricProduct[y]]}]]}] /; Head[x] =!= Plus
MakeBoxes[GeometricProduct[x_, y__], StandardForm] :=
RowBox[Flatten[{"(", MakeBoxes[x], ")", "\[EmptySmallCircle]",
MakeBoxes[GeometricProduct[y]]}]] /; Head[x] === Plus
MakeBoxes[GeometricProduct[y__, x_], StandardForm] :=
RowBox[{RowBox[
Flatten[{MakeBoxes[GeometricProduct[y]], "\[EmptySmallCircle]",
MakeBoxes[x]}]]}] /; Head[x] =!= Plus
MakeBoxes[GeometricProduct[y__, x_], StandardForm] :=
RowBox[Flatten[{MakeBoxes[GeometricProduct[y]],
"\[EmptySmallCircle]", "(", MakeBoxes[x], ")"}]] /;
Head[x] === Plus
Code above is just proper opration notation with needed preferences. (no realization included). As a simple test can try this:
aa\[EmptySmallCircle] (f ⋏ D[a[x],
x]) ∙ b \[EmptySmallCircle] c \[EmptySmallCircle] g // FullForm
GeometricProduct[aa, InnerProduct[OuterProduct[f, Derivative[1][a][x]], b], c, g]
or
1/(f ⋏ a ∙ b \[EmptySmallCircle] c \[EmptySmallCircle] g) // FullForm
GeometricProduct[OuterProduct[f, InnerProduct[a, b]], c, g]^(-1)
UnicodeCharacters.tr. I'll try to find a solution but it may be that the values are simply not respected. – Mr.Wizard Aug 03 '15 at 01:28