I suggest that we apply this patch to FriCAS as well (personally, I would have
preferred the other way round, but I prefer to stay close to OpenAxiom)
Martin
Gabriel Dos Reis <[EMAIL PROTECTED]> writes:
> The patch below does two things:
>
> (1) Make ^ an alias for **
> (2) Fix bug AW/431
>
> The decision for (1) is based on the following facts:
>
> (a) We don't have that many in-depth coverage of Axiom materials
> out there, and it is essential that the only one we have (the
> Axiom Book) not be made outdated for no solid, good reasons.
>
> (b) The Axiom Book does document ** as the exponentiation operator.
> It does not mention ^ at all. In fact ^ is a relatively new
> addition (presumably to lure Maple users).
>
> (c) When ^ was introduced, apparently the understanding was that
> it should serve the same purpose as **. There are codes in
> the interpreter from all AXIOM-based systems to attempt that
> identification.
>
> (d) The identification mentioned in (c) is not enforced
> systematically, leading to some surprises or requiring library
> writers to offer duplicate definitions.
>
> (e) Data from both Bill Page and me posted earlier suggested that
> ** are used much more often than ^, at least with the algebra
> itself.
>
> Considering a-e, it does not strike me as a particular clever move for
> OpenAxiom to remove ** entirely so that it does not mean exponentiation
> anymore. This is a design decision, and I'll not be totally surprised
> if other AXIOM-based systems make different choices.
>
>
> >From user point of view, the bottom line is that you can freely use
> ^ for exponentiation even if the library source code mentions **.
>
> Applied to trunk.
> A different version of the fix for AW/431 will be applied to the 1.2-branch.
>
>
> -- Gaby
>
> 2008-09-01 Martin Rubey <[EMAIL PROTECTED]>
> Gabriel Dos Reis <[EMAIL PROTECTED]>
>
> Fix AW/431
> * algebra/ore.spad.pamphlet (SpareUnivariateSkewPolynomial):
> Implement **.
>
> 2008-09-01 Gabriel Dos Reis <[EMAIL PROTECTED]>
>
> Make ^ an alias for **.
> * interp/postpar.boot (postAtom): Replace "^" with "**".
> * interp/format.boot (reportOpSymbol): Announce that "^" is an
> alias for "**".
> * interp/nrungo.boot (compiledLookup): Be sure to look for "**"
> when operation is "^".
> * interp/define.boot (noteCapsuleFunctionDefinition): New.
> (clearCapsuleFunctionTable): Likewise.
> (noteExport): Likewise.
> (clearExportsTable): Likewise.
> (compDefineCapsuleFunction): Rename "^" to "**". Take a note
> of the capsule function being compiled.
> (compCapsule): Clear previous capsule functions table.
> (doItIf): Keep track of predicate validity.
> (compCategory): Clear previous exports table.
> (compCategoryItem): Take notes of declared attributes and signatures.
> * algebra/catdef.spad.pamphlet (DivisionRing): Remove duplicate
> definition for "^".
> (Group): Likewise.
> (Monoid): Likewise.
> (SemiGroup): Likewise.
> * algebra/poly.spad.pamphlet (PolynomialRing): Remove duplicate
> definitins of "^".
> (SparseUnivariatePolynomial): Likewise.
> * algebra/multpoly.spad.pamphlet (SparseMultivariatePolynomial):
> Remove duplicate definitions for "^".
> * algebra/interval.spad.pamphlet (Interval): Remove duplicate
> definition for "^".
> * algebra/curve.spad.pamphlet (FunctionFieldCategory): Remove
> duplicate declaration for represents.
> * algebra/strap/: Update cached Lisp translations.
> * share/algebra: Update databases.
>
> *** interp/define.boot (revision 832)
> --- interp/define.boot (local)
> *************** $suffix := nil
> *** 53,58 ****
> --- 53,103 ----
> -- ??? turns off buggy code
> $NRTopt := false
>
> + ++ List of operations defined in a given capsule
> + ++ Each item on this list is of the form
> + ++ (op sig pred)
> + ++ where
> + ++ op: name of the operation
> + ++ sig: signature of the operation
> + ++ pred: scope predicate of the operation.
> + $capsuleFunctions := nil
> +
> + ++ record that the operation `op' with signature `sig' and predicate
> + ++ `pred' is defined in the current capsule of the current domain
> + ++ being compiled.
> + noteCapsuleFunctionDefinition(op,sig,pred) ==
> + member([op,sig,pred],$capsuleFunctions) =>
> + stackAndThrow('"redefinition of %1b: %2 %3",
> + [op,formatUnabbreviated ["Mapping",:sig],formatIf pred])
> + $capsuleFunctions := [[op,sig,pred],:$capsuleFunctions]
> +
> + ++ Clear the list of functions defined in the last domain capsule.
> + clearCapsuleFunctionTable() ==
> + $capsuleFunctions := nil
> +
> +
> + ++ List of exports (paireed with scope predicate) declared in
> + ++ the category of the currend domain or package.
> + ++ Note: for category packages, this list is nil.
> + $exports := nil
> +
> + noteExport(form,pred) ==
> + -- don't recheck category package exports; we just check
> + -- them when defining the category. Plus, we might actually
> + -- get indirect duplicates, which is OK.
> + $insideCategoryPackageIfTrue => nil
> + member([form,pred],$exports) =>
> + stackAndThrow('"redeclaration of %1 %2",
> + [form,formatIf pred])
> + $exports := [[form,pred],:$exports]
> +
> + clearExportsTable() ==
> + $exports := nil
> +
> + makePredicate l ==
> + null l => true
> + MKPF(l,"and")
> +
> --% FUNCTIONS WHICH MUNCH ON == STATEMENTS
>
> compDefine: (%Form,%Mode,%Env) -> %Maybe %Triple
> *************** compDefineCapsuleFunction(df is ['DEF,fo
> *** 842,847 ****
> --- 887,897 ----
> $CapsuleDomainsInScope: local:= get("$DomainsInScope","special",e)
> $insideExpressionIfTrue: local:= true
> $returnMode:= m
> + -- Change "^" to "**" in definitions. All other places have
> + -- been changed before we get here.
> + if first form = "^" then
> + sayBrightly ['"Replacing", :bright '"^", '"with",:bright '"**"]
> + rplac(first form,"**")
> [$op,:argl]:= form
> $form:= [$op,:argl]
> argl:= stripOffArgumentConditions argl
> *************** compDefineCapsuleFunction(df is ['DEF,fo
> *** 894,899 ****
> --- 944,950 ----
> sayBrightly ['" compiling ",localOrExported,
> :bright $op,'": ",:formattedSig]
>
> + noteCapsuleFunctionDefinition($op,signature', makePredicate $predl)
> T := CATCH('compCapsuleBody, compOrCroak(body,rettype,e))
> or [" ",rettype,e]
> NRTassignCapsuleFunctionSlot($op,signature')
> *************** compCapsule(['CAPSULE,:itemList],m,e) ==
> *** 1272,1277 ****
> --- 1323,1329 ----
> [bootStrapError($functorForm, _/EDITFILE),m,e]
> $insideExpressionIfTrue: local:= false
> $useRepresentationHack := true
> + clearCapsuleFunctionTable()
> compCapsuleInner(maybeInsertViewMorphisms itemList,m,addDomain('_$,e))
>
> compSubDomain: (%Form,%Mode,%Env) -> %Maybe %Triple
> *************** compCapsuleItems(itemlist,$predl,$e) ==
> *** 1324,1330 ****
> $myFunctorBody :local := nil ---needed for translator
> $signatureOfForm: local := nil
> $suffix: local:= 0
> ! for item in itemlist repeat $e:= compSingleCapsuleItem(item,$predl,$e)
> $e
>
> compSingleCapsuleItem(item,$predl,$e) ==
> --- 1376,1383 ----
> $myFunctorBody :local := nil ---needed for translator
> $signatureOfForm: local := nil
> $suffix: local:= 0
> ! for item in itemlist repeat
> ! $e:= compSingleCapsuleItem(item,$predl,$e)
> $e
>
> compSingleCapsuleItem(item,$predl,$e) ==
> *************** doItIf(item is [.,p,x,y],$predl,$e) ==
> *** 1412,1422 ****
> [p',.,$e]:= compCompilerPredicate(p,$e) or userError ['"not a Boolean:",p]
> oldFLP:=$functorLocalParameters
> if x^="%noBranch" then
> ! compSingleCapsuleItem(x,$predl,getSuccessEnvironment(p,$e))
> x':=localExtras(oldFLP)
> oldFLP:=$functorLocalParameters
> if y^="%noBranch" then
> ! compSingleCapsuleItem(y,$predl,getInverseEnvironment(p,olde))
> y':=localExtras(oldFLP)
> RPLACA(item,"COND")
> RPLACD(item,[[p',x,:x'],['(QUOTE T),y,:y']])
> --- 1465,1475 ----
> [p',.,$e]:= compCompilerPredicate(p,$e) or userError ['"not a Boolean:",p]
> oldFLP:=$functorLocalParameters
> if x^="%noBranch" then
> ! compSingleCapsuleItem(x,[p,:$predl],getSuccessEnvironment(p,$e))
> x':=localExtras(oldFLP)
> oldFLP:=$functorLocalParameters
> if y^="%noBranch" then
> !
> compSingleCapsuleItem(y,[["not",p],:$predl],getInverseEnvironment(p,olde))
> y':=localExtras(oldFLP)
> RPLACA(item,"COND")
> RPLACD(item,[[p',x,:x'],['(QUOTE T),y,:y']])
> *************** makeCategoryForm(c,e) ==
> *** 1503,1508 ****
> --- 1556,1562 ----
> compCategory: (%Form,%Mode,%Env) -> %Maybe %Triple
> compCategory(x,m,e) ==
> $TOP__LEVEL: local:= true
> + clearExportsTable()
> (m:= resolve(m,$Category))=$Category and x is ['CATEGORY,
> domainOrPackage,:l] =>
> $sigList: local := nil
> *************** compCategoryItem(x,predl,env) ==
> *** 1572,1595 ****
> --1. if x is a conditional expression, recurse; otherwise, form the
> predicate
> x is ["COND",[p,e]] =>
> predl':= [p,:predl]
> ! e is ["PROGN",:l] => for y in l repeat compCategoryItem(y,predl',env)
> compCategoryItem(e,predl',env)
> x is ["IF",a,b,c] =>
> predl':= [a,:predl]
> if b^="%noBranch" then
> ! b is ["PROGN",:l] => for y in l repeat compCategoryItem(y,predl',env)
> compCategoryItem(b,predl',env)
> c="%noBranch" => nil
> predl':= [["not",a],:predl]
> ! c is ["PROGN",:l] => for y in l repeat compCategoryItem(y,predl',env)
> compCategoryItem(c,predl',env)
> ! pred:= (predl => MKPF(predl,"AND"); true)
>
> --2. if attribute, push it and return
> ! x is ["ATTRIBUTE",y] => PUSH(MKQ [y,pred],$atList)
>
> --3. it may be a list, with PROGN as the CAR, and some information as the
> CDR
> ! x is ["PROGN",:l] => for u in l repeat compCategoryItem(u,predl,env)
>
> -- 4. otherwise, x gives a signature for a
> -- single operator name or a list of names; if a list of names,
> --- 1626,1655 ----
> --1. if x is a conditional expression, recurse; otherwise, form the
> predicate
> x is ["COND",[p,e]] =>
> predl':= [p,:predl]
> ! e is ["PROGN",:l] =>
> ! for y in l repeat compCategoryItem(y,predl',env)
> compCategoryItem(e,predl',env)
> x is ["IF",a,b,c] =>
> predl':= [a,:predl]
> if b^="%noBranch" then
> ! b is ["PROGN",:l] =>
> ! for y in l repeat compCategoryItem(y,predl',env)
> compCategoryItem(b,predl',env)
> c="%noBranch" => nil
> predl':= [["not",a],:predl]
> ! c is ["PROGN",:l] =>
> ! for y in l repeat compCategoryItem(y,predl',env)
> compCategoryItem(c,predl',env)
> ! pred := (predl => MKPF(predl,"AND"); true)
>
> --2. if attribute, push it and return
> ! x is ["ATTRIBUTE",y] =>
> ! noteExport(y,pred)
> ! PUSH(MKQ [y,pred],$atList)
>
> --3. it may be a list, with PROGN as the CAR, and some information as the
> CDR
> ! x is ["PROGN",:l] =>
> ! for u in l repeat compCategoryItem(u,predl,env)
>
> -- 4. otherwise, x gives a signature for a
> -- single operator name or a list of names; if a list of names,
> *************** compCategoryItem(x,predl,env) ==
> *** 1604,1607 ****
> --- 1664,1668 ----
> --4. branch on a single type or a signature %with source and target
> for t in first sig repeat
> diagnoseUknownType(t,env)
> + noteExport(rest x,pred)
> PUSH(MKQ [rest x,pred],$sigList)
> *** interp/format.boot (revision 832)
> --- interp/format.boot (local)
> *************** substInOrder(alist,x) ==
> *** 171,176 ****
> --- 171,180 ----
> x
>
> reportOpSymbol op1 ==
> + -- Don't forget that "^" is another name for "**"
> + if op1 = "^" then
> + sayMessage ['" ",op1, '" is another name for", :bright '"**"]
> + op1 := "**"
> op := (STRINGP op1 => INTERN op1; op1)
> modemaps := getAllModemapsFromDatabase(op,nil)
> null modemaps =>
> *** interp/nrungo.boot (revision 832)
> --- interp/nrungo.boot (local)
> *************** compiledLookup(op,sig,dollar) ==
> *** 65,70 ****
> --- 65,75 ----
> --called by coerceByFunction, evalForm, findEqualFun, findUniqueOpInDomain,
> -- getFunctionFromDomain, optDeltaEntry, retractByFunction
> if not VECP dollar then dollar := NRTevalDomain dollar
> + -- "^" is an alternate name for "**" in OpenAxiom libraries.
> + -- ??? When, we get to support Aldor libraries and the equivalence
> + -- ??? does not hold, we may want to do the reverse lookup too.
> + -- ??? See compiledLookupCheck below.
> + if op = "^" then op := "**"
> basicLookup(op,sig,dollar,dollar)
>
> --------------------> NEW DEFINITION (see interop.boot.pamphlet)
> *************** compiledLookupCheck(op,sig,dollar) ==
> *** 80,91 ****
> fn := compiledLookup(op,sig,dollar)
>
> -- NEW COMPILER COMPATIBILITY ON
> !
> ! if (fn = nil) and (op = "^") then
> ! fn := compiledLookup("**",sig,dollar)
> ! else if (fn = nil) and (op = "**") then
> fn := compiledLookup("^",sig,dollar)
> -
> -- NEW COMPILER COMPATIBILITY OFF
>
> fn = nil =>
> --- 85,92 ----
> fn := compiledLookup(op,sig,dollar)
>
> -- NEW COMPILER COMPATIBILITY ON
> ! if (fn = nil) and (op = "**") then
> fn := compiledLookup("^",sig,dollar)
> -- NEW COMPILER COMPATIBILITY OFF
>
> fn = nil =>
> *** interp/postpar.boot (revision 832)
> --- interp/postpar.boot (local)
> *************** postAtom x ==
> *** 177,182 ****
> --- 177,183 ----
> EQ(x,'T) => "T$" -- rename T in spad code to T$
> IDENTP x and niladicConstructorFromDB x => [x]
> x="," => "%Comma"
> + x = "^" => "**" -- always use `**' internally for exponentiation
> x
>
> postBlock: %ParseTree -> %ParseForm
> *** algebra/catdef.spad.pamphlet (revision 832)
> --- algebra/catdef.spad.pamphlet (local)
> *************** DivisionRing(): Category ==
> *** 408,415 ****
> Join(EntireRing, Algebra Fraction Integer) with
> "**": (%,Integer) -> %
> ++ x**n returns x raised to the integer power n.
> - "^" : (%,Integer) -> %
> - ++ x^n returns x raised to the integer power n.
> inv : % -> %
> ++ inv x returns the multiplicative inverse of x.
> ++ Error: if x is 0.
> --- 408,413 ----
> *************** DivisionRing(): Category ==
> *** 419,425 ****
> add
> n: Integer
> x: %
> - _^(x:%, n:Integer):% == x ** n
> import RepeatedSquaring(%)
> x ** n: Integer ==
> zero? n => 1
> --- 417,422 ----
> *************** Group(): Category == Monoid with
> *** 824,830 ****
> inv: % -> % ++ inv(x) returns the inverse of x.
> "/": (%,%) -> % ++ x/y is the same as x times the inverse
> of y.
> "**": (%,Integer) -> % ++ x**n returns x raised to the integer
> power n.
> - "^": (%,Integer) -> % ++ x^n returns x raised to the integer
> power n.
> unitsKnown ++ unitsKnown asserts that recip only
> returns
> ++ "failed" for non-units.
> conjugate: (%,%) -> %
> --- 821,826 ----
> *************** Group(): Category == Monoid with
> *** 836,842 ****
> import RepeatedSquaring(%)
> x:% / y:% == x*inv(y)
> recip(x:%) == inv(x)
> - _^(x:%, n:Integer):% == x ** n
> x:% ** n:Integer ==
> zero? n => 1
> n<0 => expt(inv(x),(-n) pretend PositiveInteger)
> --- 832,837 ----
> *************** Monoid(): Category == SemiGroup with
> *** 1014,1027 ****
> one?: % -> Boolean ++ one?(x) tests if x is equal to
> 1.
> "**": (%,NonNegativeInteger) -> % ++ x**n returns the repeated
> product
> ++ of x n times, i.e.
> exponentiation.
> - "^" : (%,NonNegativeInteger) -> % ++ x^n returns the repeated
> product
> - ++ of x n times, i.e.
> exponentiation.
> recip: % -> Union(%,"failed")
> ++ recip(x) tries to compute the multiplicative inverse for x
> ++ or "failed" if it cannot find the inverse (see unitsKnown).
> add
> import RepeatedSquaring(%)
> - _^(x:%, n:NonNegativeInteger):% == x ** n
> one? x == x = 1
> sample() == 1
> recip x ==
> --- 1009,1019 ----
> *************** SemiGroup(): Category == SetCategory wit
> *** 1614,1625 ****
> "*": (%,%) -> % ++ x*y returns the product of x and
> y.
> "**": (%,PositiveInteger) -> % ++ x**n returns the repeated product
> ++ of x n times, i.e. exponentiation.
> - "^": (%,PositiveInteger) -> % ++ x^n returns the repeated product
> - ++ of x n times, i.e. exponentiation.
> add
> import RepeatedSquaring(%)
> x:% ** n:PositiveInteger == expt(x,n)
> - _^(x:%, n:PositiveInteger):% == x ** n
>
> @
> \section{category SETCAT SetCategory}
> --- 1606,1614 ----
> *** algebra/curve.spad.pamphlet (revision 832)
> --- algebra/curve.spad.pamphlet (local)
> *************** FunctionFieldCategory(F, UP, UPUP): Cate
> *** 124,132 ****
> differentiate : ($, UP -> UP) -> $
> ++ differentiate(x, d) extends the derivation d from UP to $ and
> ++ applies it to x.
> - represents : (Vector UP, UP) -> $
> - ++ represents([A0,...,A(n-1)],D) returns
> - ++ \spad{(A0 + A1 y +...+ A(n-1)*y**(n-1))/D}.
> primitivePart : $ -> $
> ++ primitivePart(f) removes the content of the denominator and
> ++ the common content of the numerator of f.
> --- 124,129 ----
> *** algebra/interval.spad.pamphlet (revision 832)
> --- algebra/interval.spad.pamphlet (local)
> *************** Interval(R:Join(FloatingPointSystem,Tran
> *** 176,186 ****
> interval(inf(a)**n,sup(a)**n)
>
>
> - _^ (a:%,n:PositiveInteger):% ==
> - contains?(a,0) and zero?((n pretend Integer) rem 2) =>
> - interval(0,max(inf(a)**n,sup(a)**n))
> - interval(inf(a)**n,sup(a)**n)
> -
> _- (a:%):% == exactInterval(-sup(a),-inf(a))
>
> _= (a:%,b:%):Boolean == (inf(a)=inf(b)) and (sup(a)=sup(b))
> --- 176,181 ----
> *** algebra/multpoly.spad.pamphlet (revision 832)
> --- algebra/multpoly.spad.pamphlet (local)
> *************** SparseMultivariatePolynomial(R: Ring,Var
> *** 348,356 ****
> up:=p1*p2.ts
> if ground? up then leadingCoefficient(up) else [mvar,up]$VPoly
>
> - p ^ kp == p ** (kp pretend NonNegativeInteger)
> p ** kp == p ** (kp pretend NonNegativeInteger )
> - p ^ k == p ** k
> p ** k ==
> p case R => p::R ** k
> -- univariate special case
> --- 348,354 ----
> *** algebra/ore.spad.pamphlet (revision 832)
> --- algebra/ore.spad.pamphlet (local)
> *************** UnivariateSkewPolynomialCategoryOps(R, C
> *** 464,470 ****
> )abbrev domain ORESUP SparseUnivariateSkewPolynomial
> ++ Author: Manuel Bronstein
> ++ Date Created: 19 October 1993
> ! ++ Date Last Updated: 1 February 1994
> ++ Description:
> ++ This is the domain of sparse univariate skew polynomials over an Ore
> ++ coefficient field.
> --- 464,470 ----
> )abbrev domain ORESUP SparseUnivariateSkewPolynomial
> ++ Author: Manuel Bronstein
> ++ Date Created: 19 October 1993
> ! ++ Date Last Updated: September, 2008
> ++ Description:
> ++ This is the domain of sparse univariate skew polynomials over an Ore
> ++ coefficient field.
> *************** SparseUnivariateSkewPolynomial(R:Ring, s
> *** 479,484 ****
> --- 479,488 ----
>
> x:% * y:% == times(x, y, sigma, delta)
> apply(p, c, r) == apply(p, c, r, sigma, delta)
> + x:% ** n:PositiveInteger == expt(x,n)$RepeatedSquaring(%)
> + x:% ** n:NonNegativeInteger ==
> + zero? n => 1
> + expt(x,n::PositiveInteger)$RepeatedSquaring(%)
>
> if R has IntegralDomain then
> monicLeftDivide(a, b) == monicLeftDivide(a, b, sigma)
> *** algebra/poly.spad.pamphlet (revision 832)
> --- algebra/poly.spad.pamphlet (local)
> *************** PolynomialRing(R:Ring,E:OrderedAbelianMo
> *** 294,302 ****
> -- -- reduces both time and space
> [Abbott/Bradford/Davenport]
> if R has CommutativeRing then
> p ** np == p ** (np pretend NonNegativeInteger)
> - p ^ np == p ** (np pretend NonNegativeInteger)
> - p ^ nn == p ** nn
> -
>
> p ** nn ==
> null p => 0
> --- 294,299 ----
> *************** SparseUnivariatePolynomial(R:Ring): Univ
> *** 434,441 ****
>
> if R has FieldOfPrimeCharacteristic then
> p ** np == p ** (np pretend NonNegativeInteger)
> - p ^ np == p ** (np pretend NonNegativeInteger)
> - p ^ n == p ** n
> p ** n ==
> null p => 0
> zero? n => 1
> --- 431,436 ----
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
> Build the coolest Linux based applications with Moblin SDK & win great prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> open-axiom-patches mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/open-axiom-patches
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"FriCAS - computer algebra system" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/fricas-devel?hl=en
-~----------~----~----~----~------~----~------~--~---