diff --git a/changelog b/changelog
index 84a01e3..e080aa2 100644
--- a/changelog
+++ b/changelog
@@ -1,3 +1,7 @@
+20071229 acr src/algebra/mathml.spad fix sum ambiguity bug in mathml (7057)
+20071229 tpd src/hyper/bookvol11 add testpage for summation mathml (7057)
+20071229 tpd src/input/Makefile add summation regression test (7057)
+20071229 tpd src/input/summation.input test mathml sum ambiguity (bug 7057)
20071229 jap src/hyper/bookvol11 remove /home/silver path (bug 7054)
20071228 tpd src/hyper/bookvol11 add standards compliance for gamma
20071228 tpd src/hyper/bitmaps/gammacomplexinverse.png added
diff --git a/src/algebra/mathml.spad.pamphlet b/src/algebra/mathml.spad.pamphlet
index 4b9869f..67a8157 100644
--- a/src/algebra/mathml.spad.pamphlet
+++ b/src/algebra/mathml.spad.pamphlet
@@ -1011,10 +1011,10 @@ have to be switched by swapping names.
formatSuperSub(expr : E, args : L E, opPrec : I) : S ==
-- this produces prime notation ordinary derivatives.
-- first have to divine the semantics, add cases as needed
- WriteLine$Lisp "SuperSub1 begin"
+-- WriteLine$Lisp "SuperSub1 begin"
atomE : L E := atomize(expr)
op : S := stringify first atomE
- WriteLine$Lisp "op: "op
+-- WriteLine$Lisp "op: "op
op ^= "SUPERSUB" => _
"Mistake in formatSuperSub: no SUPERSUB1"
#args ^= 1 => "Mistake in SuperSub1: #args <> 1"
@@ -1024,9 +1024,9 @@ have to be switched by swapping names.
-- {{{SUPERSUB}{y}{ }{,,}}{x}}, expr is the first {} and args is the
-- {x}
funcS : S := stringify first rest atomE
- WriteLine$Lisp "funcS: "funcS
+-- WriteLine$Lisp "funcS: "funcS
bvarS : S := stringify first args
- WriteLine$Lisp "bvarS: "bvarS
+-- WriteLine$Lisp "bvarS: "bvarS
-- count the number of commas
commaS : S := stringify first rest rest rest atomE
commaTest : S := ","
@@ -1035,7 +1035,7 @@ have to be switched by swapping names.
i := i+1
commaTest := commaTest","
s : S := ""funcS""
- WriteLine$Lisp "s: "s
+-- WriteLine$Lisp "s: "s
j : I := 0
while j < i repeat
s := s"′"
@@ -1046,7 +1046,7 @@ have to be switched by swapping names.
-- This one produces ordinary derivatives with differential notation,
-- it needs a little more work yet.
-- first have to divine the semantics, add cases as needed
- WriteLine$Lisp "SuperSub begin"
+-- WriteLine$Lisp "SuperSub begin"
atomE : L E := atomize(expr)
op : S := stringify first atomE
op ^= "SUPERSUB" => _
@@ -1069,6 +1069,7 @@ have to be switched by swapping names.
s : S := "ⅆ"string(ndiffs)""funcS"ⅆ"formatMml(first args,minPrec)""string(ndiffs)"("formatMml(first args,minPrec)")"
formatPlex(op : S, args : L E, prec : I) : S ==
+ checkarg:Boolean := false
hold : S
p : I := position(op,plexOps)
p < 1 => error "unknown plex op"
@@ -1077,13 +1078,21 @@ have to be switched by swapping names.
n : I := #args
(n ^= 2) and (n ^= 3) => error "wrong number of arguments for plex"
s : S :=
- op = "SIGMA" => "∑"
+ op = "SIGMA" =>
+ checkarg := true
+ "∑"
-- Sum
- op = "SIGMA2" => "∑"
+ op = "SIGMA2" =>
+ checkarg := true
+ "∑"
-- Sum
- op = "PI" => "∏"
+ op = "PI" =>
+ checkarg := true
+ "∏"
-- Product
- op = "PI2" => "∏"
+ op = "PI2" =>
+ checkarg := true
+ "∏"
-- Product
-- op = "INTSIGN" => "∫"
-- Integral, int
@@ -1104,7 +1113,15 @@ have to be switched by swapping names.
else
s := concat [s,group " ",""]
args := rest args
- s := concat [s,formatMml(first args,minPrec)]
+ -- if checkarg true need to test op arg for "+" at least
+ -- and wrap parentheses if so
+ if checkarg then
+ la : L E := (first args pretend L E)
+ opa : S := stringify first la
+ if opa = "+" then
+ s := concat [s,"(",formatMml(first args,minPrec),")"]
+ else s := concat [s,formatMml(first args,minPrec)]
+ else s := concat [s,formatMml(first args,minPrec)]
else
hold := group concat [hold,formatMml(first args,minPrec)]
s := concat [s,hold]
@@ -1178,7 +1195,17 @@ have to be switched by swapping names.
p : I := position(op,binaryOps)
p < 1 => error "unknown binary op"
opPrec := binaryPrecs.p
- s1 : S := formatMml(first args, opPrec)
+ -- if base op is product or sum need to add parentheses
+ if ATOM(first args)$Lisp@Boolean then
+ opa:S := stringify first args
+ else
+ la : L E := (first args pretend L E)
+ opa : S := stringify first la
+ if (opa = "SIGMA" or opa = "SIGMA2" or opa = "PI" or opa = "PI2") _
+ and op = "**" then
+ s1:S:=concat ["(",formatMml(first args, opPrec),")"]
+ else
+ s1 : S := formatMml(first args, opPrec)
s2 : S := formatMml(first rest args, opPrec)
op :=
op = "|" => s := concat ["",s1,"",op,"",s2,""]
@@ -1197,6 +1224,7 @@ have to be switched by swapping names.
group formatNaryNoGroup(op, args, prec)
formatNaryNoGroup(op : S, args : L E, prec : I) : S ==
+ checkargs:Boolean := false
null args => ""
p : I := position(op,naryOps)
p < 1 => error "unknown nary op"
@@ -1230,20 +1258,53 @@ have to be switched by swapping names.
position("ZAG",tmpS,1) > 0 => formatZag(args)
-- position("ZAG",tmpS,1) > 0 => formatZag1(args)
concat [formatMml(first args,minPrec) "+" formatZag(rest args)]
+ -- At least for the ops "*","+","-" we need to test to see if a sigma
+ -- or pi is one of their arguments because we might need parentheses
+ -- as indicated by the problem with
+ -- summation(operator(f)(i),i=1..n)+1 versus
+ -- summation(operator(f)(i)+1,i=1..n) having identical displays as
+ -- of 2007-21-21
op :=
op = "," => "," --originally , \:
op = ";" => ";" --originally ; \: should figure these out
- op = "*" => ""
+ op = "*" =>
+ checkargs := true
+ ""
-- InvisibleTimes
op = " " => ""
op = "ROW" => ""
- op = "+" => "+"
- op = "-" => "-"
+ op = "+" =>
+ checkargs := true
+ "+"
+ op = "-" =>
+ checkargs := true
+ "-"
op
l : L S := nil
opPrec := naryPrecs.p
+ -- if checkargs is true check each arg except last one to see if it's
+ -- a sigma or pi and if so add parentheses. Other op's may have to be
+ -- checked for in future
+ count:I := 1
for a in args repeat
- l := concat(op,concat(formatMml(a,opPrec),l)$L(S))$L(S)
+-- WriteLine$Lisp "checking args"
+ if checkargs then
+ if count < #args then
+ -- check here for sum or product
+ if ATOM(a)$Lisp@Boolean then
+ opa:S := stringify a
+ else
+ la : L E := (a pretend L E)
+ opa : S := stringify first la
+ if opa = "SIGMA" or opa = "SIGMA2" or _
+ opa = "PI" or opa = "PI2" then
+ l := concat(op,concat(_
+ concat ["(",formatMml(a,opPrec),_
+ ")"],l)$L(S))$L(S)
+ else l := concat(op,concat(formatMml(a,opPrec),l)$L(S))$L(S)
+ else l := concat(op,concat(formatMml(a,opPrec),l)$L(S))$L(S)
+ else l := concat(op,concat(formatMml(a,opPrec),l)$L(S))$L(S)
+ count := count + 1
s : S := concat reverse rest l
opPrec < prec => parenthesize s
s
diff --git a/src/hyper/bookvol11.pamphlet b/src/hyper/bookvol11.pamphlet
index 3a73f1c..293066e 100644
--- a/src/hyper/bookvol11.pamphlet
+++ b/src/hyper/bookvol11.pamphlet
@@ -1177,6 +1177,36 @@ is currently ignored.
value="(progn (setq |$options| '((|operations|))) (|show| '|Integer|))" />