|
|
last edited 16 years ago by Bill Page |
1 2 3 4 | ||
Editor: Bill Page
Time: 2008/04/08 17:33:55 GMT-7 |
||
Note: using = from Mapping |
changed: -MyReduce(S:Type): with MyReduce2(S:Type): with changed: -Notice that it fails in the same way as above, but it would work if we used the original trick of applying the function before comparing it. Notice that it fails in the same way as above: added: But it works if we used the original trick of applying the function to get rid of 'newGoGet' before comparing the functions. \begin{spad} )abbrev package MYRED3 MyReduce3 MyReduce3(S:Type): with myred3: ((S,S)->S,List S) -> S == add import NonNegativeInteger myred3(f:(S,S)->S, x:List S):S == if #x>1 then f(first x, myred3(f,rest x)) else if #x=1 then first x else if S has AbelianMonoid then -- Must force "newGoGet" by applying operations before comparison! f(0,0)=(0+0)$S and (f = _+$S)$Mapping(S,S,S) => return 0$S if S has Monoid then f(1,1)=(1*1)$S and (f = _*$S)$Mapping(S,S,S) => return 1$S error "reducing over an empty list needs the 3 argument form" \end{spad} \begin{axiom} myred3(+,[1,2,3,4]) myred3(+,[]$List Integer) myred3(*,[1,2,3,4]) myred3(*,[]$List Integer) \end{axiom}
\begin{axiom} )version \end{axiom} \begin{spad} )abbrev package MYRED MyReduce MyReduce(S:Type): with myred: ((S,S)->S,List S) -> S == add -- Waldek's local helper function ((f:(S,S)->S) = (g:(S,S)->S)):Boolean == print(coerceMap2E(f)$Lisp::OutputForm) print(coerceMap2E(g)$Lisp::OutputForm) EQ(f,g)$Lisp -- import NonNegativeInteger myred(f:(S,S)->S, x:List S):S == if #x>1 then f(first x, myred(f,rest x)) else if #x=1 then first x else if S has AbelianMonoid then -- Must force "newGoGet" by applying operations before comparison! -- f(0,0)=(0+0)$S and (f = _+$S) => return 0$S (f = _+$S) => return 0$S if S has Monoid then -- f(1,1)=(11)$S and (f = _$S) => return 1$S (f = _*$S) => return 1$S error "reducing over an empty list needs the 3 argument form" \end{spad}\begin{axiom} myred(+,[1,2,3,4]) myred(+,[]$List Integer) myred(*,[1,2,3,4]) myred(*,[]$List Integer)
\end{axiom}
Here is another version of the same thing using the
=
from theMapping
domain.\begin{spad} )abbrev package MYRED2 MyReduce2 MyReduce2(S:Type): with myred2: ((S,S)->S,List S) -> S == add import NonNegativeInteger myred2(f:(S,S)->S, x:List S):S == if #x>1 then f(first x, myred2(f,rest x)) else if #x=1 then first x else if S has AbelianMonoid then -- Must force "newGoGet" by applying operations before comparison! -- f(0,0)=(0+0)$S and (f = _+$S) => return 0$S (f = _+$S)$Mapping(S,S,S) => return 0$S if S has Monoid then -- f(1,1)=(11)$S and (f = _$S) => return 1$S (f = _*$S)$Mapping(S,S,S) => return 1$S error "reducing over an empty list needs the 3 argument form" \end{spad}
Notice that it fails in the same way as above: \begin{axiom} myred2(+,[1,2,3,4]) myred2(+,[]$List Integer) myred2(*,[1,2,3,4]) myred2(*,[]$List Integer) \end{axiom}
But it works if we used the original trick of applying the function to get rid of
newGoGet
before comparing the functions.\begin{spad} )abbrev package MYRED3 MyReduce3 MyReduce3(S:Type): with myred3: ((S,S)->S,List S) -> S == add import NonNegativeInteger myred3(f:(S,S)->S, x:List S):S == if #x>1 then f(first x, myred3(f,rest x)) else if #x=1 then first x else if S has AbelianMonoid then -- Must force "newGoGet" by applying operations before comparison! f(0,0)=(0+0)$S and (f = _+$S)$Mapping(S,S,S) => return 0$S if S has Monoid then f(1,1)=(11)$S and (f = _$S)$Mapping(S,S,S) => return 1$S error "reducing over an empty list needs the 3 argument form" \end{spad}
\begin{axiom} myred3(+,[1,2,3,4]) myred3(+,[]$List Integer) myred3(*,[1,2,3,4]) myred3(*,[]$List Integer) \end{axiom}
Some or all expressions may not have rendered properly, because Axiom returned the following error:Error: export FRICAS=/usr/local/lib/open-axiom/x86_64-unknown-linux/1.1.0-2008-01-28; export ALDORROOT=/usr/local/aldor/linux/1.1.0; export PATH=$ALDORROOT/bin:$PATH; export HOME=/var/zope2/var/LatexWiki; ulimit -t 600; export LD_LIBRARY_PATH=/usr/local/lib/open-axiom/x86_64-unknown-linux/1.1.0-2008-01-28/lib; LANG=en_US.UTF-8 $FRICAS/bin/FRICASsys < /var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/7234157229126066145-25px.axm /bin/sh: /usr/local/lib/open-axiom/x86_64-unknown-linux/1.1.0-2008-01-28/bin/FRICASsys: not found
This is pdfTeXk, Version 3.141592-1.40.3 (Web2C 7.5.6) \write18 enabled. %&-line parsing enabled. entering extended mode (./7990258885462259044-16.0px.tex LaTeX2e <2005/12/01> Babel <v3.8h> and hyphenation patterns for english, usenglishmax, dumylang, noh yphenation, arabic, farsi, croatian, ukrainian, russian, bulgarian, czech, slov ak, danish, dutch, finnish, basque, french, german, ngerman, ibycus, greek, mon ogreek, ancientgreek, hungarian, italian, latin, mongolian, norsk, icelandic, i nterlingua, turkish, coptic, romanian, welsh, serbian, slovenian, estonian, esp eranto, uppersorbian, indonesian, polish, portuguese, spanish, catalan, galicia n, swedish, ukenglish, pinyin, loaded. (/usr/share/texmf-texlive/tex/latex/base/article.cls Document Class: article 2005/09/16 v1.4f Standard LaTeX document class (/usr/share/texmf-texlive/tex/latex/base/size12.clo)) (/usr/share/texmf-texlive/tex/latex/ucs/ucs.sty (/usr/share/texmf-texlive/tex/latex/ucs/data/uni-global.def)) (/usr/share/texmf-texlive/tex/latex/base/inputenc.sty (/usr/share/texmf-texlive/tex/latex/ucs/utf8x.def)) (/usr/share/texmf-texlive/tex/latex/bbm/bbm.sty) (/usr/share/texmf-texlive/tex/latex/jknapltx/mathrsfs.sty) (/usr/share/texmf-texlive/tex/latex/base/fontenc.sty (/usr/share/texmf-texlive/tex/latex/base/t1enc.def)) (/usr/share/texmf-texlive/tex/latex/pstricks/pstricks.sty (/usr/share/texmf-texlive/tex/generic/pstricks/pstricks.tex `PSTricks' v1.15 <2006/12/22> (tvz) (/usr/share/texmf-texlive/tex/generic/pstricks/pstricks.con)) (/usr/share/texmf/tex/latex/xcolor/xcolor.sty (/etc/texmf/tex/latex/config/color.cfg) (/usr/share/texmf-texlive/tex/latex/graphics/dvips.def) (/usr/share/texmf-texlive/tex/latex/graphics/dvipsnam.def))) (/usr/share/texmf-texlive/tex/latex/graphics/epsfig.sty (/usr/share/texmf-texlive/tex/latex/graphics/graphicx.sty (/usr/share/texmf-texlive/tex/latex/graphics/keyval.sty) (/usr/share/texmf-texlive/tex/latex/graphics/graphics.sty (/usr/share/texmf-texlive/tex/latex/graphics/trig.sty) (/etc/texmf/tex/latex/config/graphics.cfg)))) (/usr/share/texmf-texlive/tex/latex/pst-grad/pst-grad.sty (/usr/share/texmf-texlive/tex/generic/pst-grad/pst-grad.tex (/usr/share/texmf-texlive/tex/latex/xkeyval/pst-xkey.tex (/usr/share/texmf-texlive/tex/latex/xkeyval/xkeyval.sty (/usr/share/texmf-texlive/tex/latex/xkeyval/xkeyval.tex))) `pst-plot' v1.05, 2006/11/04 (tvz,dg,hv))) (/usr/share/texmf-texlive/tex/latex/pstricks/pst-plot.sty (/usr/share/texmf-texlive/tex/generic/pstricks/pst-plot.tex v97 patch 2, 1999/12/12 (/usr/share/texmf-texlive/tex/generic/multido/multido.tex v1.41, 2004/05/18 <tvz>))) (/usr/share/texmf-texlive/tex/latex/geometry/geometry.sty (/usr/share/texmf-texlive/tex/xelatex/xetexconfig/geometry.cfg)Package geometry Warning: `lmargin' and `rmargin' result in NEGATIVE (-108.405p t). `width' should be shortened in length.
) (/usr/share/texmf-texlive/tex/latex/amsmath/amsmath.sty For additional information on amsmath, use the `?
option. (/usr/share/texmf-texlive/tex/latex/amsmath/amstext.sty (/usr/share/texmf-texlive/tex/latex/amsmath/amsgen.sty)) (/usr/share/texmf-texlive/tex/latex/amsmath/amsbsy.sty) (/usr/share/texmf-texlive/tex/latex/amsmath/amsopn.sty)) (/usr/share/texmf-texlive/tex/latex/amsfonts/amsfonts.sty) (/usr/share/texmf-texlive/tex/latex/amsfonts/amssymb.sty) (/usr/share/texmf-texlive/tex/latex/amscls/amsthm.sty) (/usr/share/texmf-texlive/tex/latex/setspace/setspace.sty Package: `setspace
6.7 <2000/12/01> ) (/usr/share/texmf-texlive/tex/generic/xypic/xy.sty (/usr/share/texmf-texlive/tex/generic/xypic/xy.tex Bootstrap'ing: catcodes, docmode, (/usr/share/texmf-texlive/tex/generic/xypic/xyrecat.tex) (/usr/share/texmf-texlive/tex/generic/xypic/xyidioms.tex)Xy-pic version 3.7 <1999/02/16> Copyright (c) 1991-1998 by Kristoffer H. Rose <krisrose@ens-lyon.fr> Xy-pic is free software: see the User's Guide for details.
Loading kernel: messages; fonts; allocations: state, direction, utility macros; pictures: \xy, positions, objects, decorations; kernel objects: directionals, circles, text; options; algorithms: directions, edges, connections; Xy-pic loaded)) (/usr/share/texmf-texlive/tex/generic/xypic/xyall.tex Xy-pic option: All features v.3.3 (/usr/share/texmf-texlive/tex/generic/xypic/xycurve.tex Xy-pic option: Curve and Spline extension v.3.7 curve, circles, loaded) (/usr/share/texmf-texlive/tex/generic/xypic/xyframe.tex Xy-pic option: Frame and Bracket extension v.3.7 loaded) (/usr/share/texmf-texlive/tex/generic/xypic/xycmtip.tex Xy-pic option: Computer Modern tip extension v.3.3 (/usr/share/texmf-texlive/tex/generic/xypic/xytips.tex Xy-pic option: More Tips extension v.3.3 loaded) loaded) (/usr/share/texmf-texlive/tex/generic/xypic/xyline.tex Xy-pic option: Line styles extension v.3.6 loaded) (/usr/share/texmf-texlive/tex/generic/xypic/xyrotate.tex Xy-pic option: Rotate and Scale extension v.3.3 loaded) (/usr/share/texmf-texlive/tex/generic/xypic/xycolor.tex Xy-pic option: Colour extension v.3.3 loaded) (/usr/share/texmf-texlive/tex/generic/xypic/xymatrix.tex Xy-pic option: Matrix feature v.3.4 loaded) (/usr/share/texmf-texlive/tex/generic/xypic/xyarrow.tex Xy-pic option: Arrow and Path feature v.3.5 path, \ar, loaded) (/usr/share/texmf-texlive/tex/generic/xypic/xygraph.tex Xy-pic option: Graph feature v.3.7 loaded) loaded) (/usr/share/texmf-texlive/tex/latex/tools/verbatim.sty) (/usr/share/texmf/tex/latex/graphviz/graphviz.sty (/usr/share/texmf-texlive/tex/latex/psfrag/psfrag.sty)) (/usr/share/texmf/tex/latex/sagetex.sty Writing sage input file 7990258885462259044-16.0px.sage (./7990258885462259044-16.0px.sout)) (/usr/share/texmf-texlive/tex/latex/gnuplottex/gnuplottex.sty (/usr/share/texmf-texlive/tex/latex/base/latexsym.sty) (/usr/share/texmf-texlive/tex/latex/moreverb/moreverb.sty) (/usr/share/texmf-texlive/tex/latex/base/ifthen.sty)) (./7990258885462259044-16.0px.aux) (/usr/share/texmf-texlive/tex/latex/ucs/ucsencs.def) (/usr/share/texmf-texlive/tex/latex/base/t1cmtt.fd)
LaTeX Warning: Characters dropped after `\end{axiom}' on input line 123.
(/usr/share/texmf-texlive/tex/latex/jknapltx/ursfs.fd) (/usr/share/texmf-texlive/tex/latex/amsfonts/umsa.fd) (/usr/share/texmf-texlive/tex/latex/amsfonts/umsb.fd) (/usr/share/texmf-texlive/tex/latex/base/ulasy.fd) You can't use `macro parameter character #' in math mode. l.137 if # x>1 then You can't use `macro parameter character #' in math mode. l.139 else if # x=1 then Missing $ inserted. <inserted text> $ l.144 -- f(0,0)=(0+0)$S and (f = _ +$S) => return 0$S Missing $ inserted. <inserted text> $ l.147 -- f(1,1)=(11)$S and (f = _ $S) => return 1$S Missing $ inserted. <inserted text> $ l.150 \end{spad} \newpage
Overfull \hbox (4.921pt too wide) in paragraph at lines 125--150 \T1/cmr/m/n/12 ((f:(S,S)->S) = (g:(S,S)->S)):Boolean == print(coerceMap2E(f)$\O ML/cmm/m/it/12 Lisp \OT1/cmr/m/n/12 :: \OML/cmm/m/it/12 OutputForm\OT1/cmr/m/n/ 12 )\OML/cmm/m/it/12 print\OT1/cmr/m/n/12 (\OML/cmm/m/it/12 coerceMap\OT1/cmr/m /n/12 2\OML/cmm/m/it/12 E\OT1/cmr/m/n/12 (\OML/cmm/m/it/12 g\OT1/cmr/m/n/12 )$\ T1/cmr/m/n/12 Lisp::OutputForm) EQ(f,g)$\OML/cmm/m/it/12 Lisp \OMS/cmsy/m/n/12 ^^@
Overfull \hbox (137.34442pt too wide) in paragraph at lines 125--150 \OMS/cmsy/m/n/12 ^^@\OML/cmm/m/it/12 importNonNegativeIntegermyred\OT1/cmr/m/n/ 12 (\OML/cmm/m/it/12 f \OT1/cmr/m/n/12 : (\OML/cmm/m/it/12 S; S\OT1/cmr/m/n/12 )\OMS/cmsy/m/n/12 ^^@ \OML/cmm/m/it/12 > S; x \OT1/cmr/m/n/12 : \OML/cmm/m/it/1 2 ListS\OT1/cmr/m/n/12 ) : \OML/cmm/m/it/12 S \OT1/cmr/m/n/12 == \OML/cmm/m/it/ 12 ifx > \OT1/cmr/m/n/12 1\OML/cmm/m/it/12 thenf\OT1/cmr/m/n/12 (\OML/cmm/m/it/ 12 firstx; myred\OT1/cmr/m/n/12 (\OML/cmm/m/it/12 f; restx\OT1/cmr/m/n/12 ))\OM L/cmm/m/it/12 elseifx \OT1/cmr/m/n/12 = 1\OML/cmm/m/it/12 thenfirstxelseifShasA belianMonoidthen \OMS/cmsy/m/n/12 ^^@
Overfull \hbox (43.71477pt too wide) in paragraph at lines 125--150 \T1/cmr/m/n/12 0$\OML/cmm/m/it/12 SifShasMonoidthen \OMS/cmsy/m/n/12 ^^@ ^^@\OM L/cmm/m/it/12 f\OT1/cmr/m/n/12 (1\OML/cmm/m/it/12 ; \OT1/cmr/m/n/12 1) = (1 \OM S/cmsy/m/n/12 ^^C \OT1/cmr/m/n/12 1)$\T1/cmr/m/n/12 S and (f = $[]$S) => re-tur n 1$\OML/cmm/m/it/12 S\OT1/cmr/m/n/12 (\OML/cmm/m/it/12 f \OT1/cmr/m/n/12 =[]$\ T1/cmr/m/n/12 S) => re-turn 1$\OML/cmm/m/it/12 Serror\OT1/cmr/m/n/12 "\OML/cmm/ m/it/12 reducingoveranemptylistneedsthe\OT1/cmr/m/n/12 3\OML/cmm/m/it/12 argume ntform\OT1/cmr/m/n/12 "$ [1]
LaTeX Warning: Characters dropped after `\end{axiom}' on input line 157.
You can't use `macro parameter character #' in horizontal mode. l.165 if # x>1 then You can't use `macro parameter character #' in horizontal mode. l.167 else if # x=1 then [2]
LaTeX Warning: Characters dropped after `\end{axiom}' on input line 184.
You can't use `macro parameter character #' in horizontal mode. l.192 if # x>1 then You can't use `macro parameter character #' in horizontal mode. l.194 else if # x=1 then [3]
LaTeX Warning: Characters dropped after `\end{axiom}' on input line 209.
[4] (./7990258885462259044-16.0px.aux) ) (see the transcript file for additional information) Output written on 7990258885462259044-16.0px.dvi (4 pages, 4444 bytes). Transcript written on 7990258885462259044-16.0px.log.