login  home  contents  what's new  discussion  bug reports     help  links  subscribe  changes  refresh  edit

Test old defintion

axiom
position(exp(1)::Kernel EXPR INT)

\label{eq1}1536(1)
Type: PositiveInteger
axiom
position(pi()::EXPR INT::Kernel EXPR INT)

\label{eq2}1024(2)
Type: PositiveInteger
axiom
(%e<%pi)$EXPR INT
The function < is not implemented in Expression(Integer) .

All exp() are sorted before pi()

All Kernels compared numerically if possible

axiom
)clear completely
All user variables and function definitions have been cleared. All )browse facility databases have been cleared. Internally cached functions and constructors have been cleared. )clear completely is finished.

axiom
)abbrev domain KERNEL Kernel
++ Operators applied to elements of a set
++ Author: Manuel Bronstein
++ Date Created: 22 March 1988
++ Date Last Updated: 10 August 1994
++ Description:
++ A kernel over a set S is an operator applied to a given list
++ of arguments from S.
Kernel(S:OrderedSet): Exports == Implementation where
  O  ==> OutputForm
  N  ==> NonNegativeInteger
  OP ==> BasicOperator
  EF ==> Expression Float
SYMBOL ==> "%symbol" PMPRED ==> "%pmpredicate" PMOPT ==> "%pmoptional" PMMULT ==> "%pmmultiple" PMCONST ==> "%pmconstant" SPECIALDISP ==> "%specialDisp" SPECIALEQUAL ==> "%specialEqual" SPECIALINPUT ==> "%specialInput"
Exports ==> Join(CachableSet, Patternable S) with name : % -> Symbol ++ name(op(a1,...,an)) returns the name of op. operator: % -> OP ++ operator(op(a1,...,an)) returns the operator op. argument: % -> List S ++ argument(op(a1,...,an)) returns \spad{[a1,...,an]}. height : % -> N ++ height(k) returns the nesting level of k. kernel : (OP, List S, N) -> % ++ kernel(op, [a1,...,an], m) returns the kernel \spad{op(a1,...,an)} ++ of nesting level m. ++ Error: if op is k-ary for some k not equal to m. kernel : Symbol -> % ++ kernel(x) returns x viewed as a kernel. symbolIfCan: % -> Union(Symbol, "failed") ++ symbolIfCan(k) returns k viewed as a symbol if k is a symbol, and ++ "failed" otherwise. is? : (%, OP) -> Boolean ++ is?(op(a1,...,an), f) tests if op = f. is? : (%, Symbol) -> Boolean ++ is?(op(a1,...,an), s) tests if the name of op is s. if S has ConvertibleTo InputForm then ConvertibleTo InputForm
Implementation ==> add import SortedCache(%)
Rep := Record(op:OP, arg:List S, nest:N, posit:N)
clearCache()
B2Z : Boolean -> Integer triage: (%, %) -> Integer preds : OP -> List Any
is?(k:%, s:Symbol) == is?(operator k, s) is?(k:%, o:OP) == (operator k) = o name k == name operator k height k == k.nest operator k == k.op argument k == k.arg position k == k.posit setPosition(k, n) == k.posit := n B2Z flag == (flag => -1; 1) kernel s == kernel(assert(operator(s,0),SYMBOL), nil(), 1)
preds o == (u := property(o, PMPRED)) case "failed" => nil() (u::None) pretend List(Any)
symbolIfCan k == has?(operator k, SYMBOL) => name operator k "failed"
k1 = k2 == if k1.posit = 0 then enterInCache(k1, triage) if k2.posit = 0 then enterInCache(k2, triage) k1.posit = k2.posit
k1 < k2 == if k1.posit = 0 then enterInCache(k1, triage) if k2.posit = 0 then enterInCache(k2, triage) k1.posit < k2.posit
kernel(fn, x, n) == ((u := arity fn) case N) and (#x ^= u::N) => error "Wrong number of arguments" enterInCache([fn, x, n, 0]$Rep, triage)
-- SPECIALDISP contains a map List S -> OutputForm -- it is used when the converting the arguments first is not good, -- for instance with formal derivatives. coerce(k:%):OutputForm == (v := symbolIfCan k) case Symbol => v::Symbol::OutputForm (f := property(o := operator k, SPECIALDISP)) case None => ((f::None) pretend (List S -> OutputForm)) (argument k) l := [x::OutputForm for x in argument k]$List(OutputForm) (u := display o) case "failed" => prefix(name(o)::OutputForm, l) (u::(List OutputForm -> OutputForm)) l
triage(k1:%, k2:%) == n1:=numericIfCan(k1) n2:=numericIfCan(k2) n1 case Float and n2 case Float => B2Z(n1<n2) -- is?(k1,"pi"::Symbol) and is?(k2,"exp"::Symbol) => 1 -- is?(k2,"pi"::Symbol) and is?(k1,"exp"::Symbol) => -1 k1.nest ^= k2.nest => B2Z(k1.nest < k2.nest) k1.op ^= k2.op => B2Z(k1.op < k2.op) (n1 := #(argument k1)) ^= (n2 := #(argument k2)) => B2Z(n1 < n2) ((func := property(operator k1, SPECIALEQUAL)) case None) and (((func::None) pretend ((%, %) -> Boolean)) (k1, k2)) => 0 for x1 in argument(k1) for x2 in argument(k2) repeat x1 ^= x2 => return B2Z(x1 < x2) 0
if S has ConvertibleTo InputForm then convert(k:%):InputForm == (v := symbolIfCan k) case Symbol => convert(v::Symbol)@InputForm (f := property(o := operator k, SPECIALINPUT)) case None => ((f::None) pretend (List S -> InputForm)) (argument k) l := [convert x for x in argument k]$List(InputForm) (u := input operator k) case "failed" => convert concat(convert name operator k, l) (u::(List InputForm -> InputForm)) l
if S has ConvertibleTo Pattern Integer then convert(k:%):Pattern(Integer) == o := operator k (v := symbolIfCan k) case Symbol => s := patternVariable(v::Symbol, has?(o, PMCONST), has?(o, PMOPT), has?(o, PMMULT)) empty?(l := preds o) => s setPredicates(s, l) o [convert x for x in k.arg]$List(Pattern Integer) if S has ConvertibleTo Pattern Float then convert(k:%):Pattern(Float) == o := operator k (v := symbolIfCan k) case Symbol => s := patternVariable(v::Symbol, has?(o, PMCONST), has?(o, PMOPT), has?(o, PMMULT)) empty?(l := preds o) => s setPredicates(s, l) o [convert x for x in k.arg]$List(Pattern Float)
axiom
Compiling FriCAS source code from file 
      /var/zope2/var/LatexWiki/9104021763975394301-25px.008.spad using 
      old system compiler.
   KERNEL abbreviates domain Kernel 
   processing macro definition O ==> OutputForm 
   processing macro definition N ==> NonNegativeInteger 
   processing macro definition OP ==> BasicOperator 
   processing macro definition EF ==> Expression Float 
   processing macro definition SYMBOL ==> %symbol 
   processing macro definition PMPRED ==> %pmpredicate 
   processing macro definition PMOPT ==> %pmoptional 
   processing macro definition PMMULT ==> %pmmultiple 
   processing macro definition PMCONST ==> %pmconstant 
   processing macro definition SPECIALDISP ==> %specialDisp 
   processing macro definition SPECIALEQUAL ==> %specialEqual 
   processing macro definition SPECIALINPUT ==> %specialInput 
   processing macro definition Exports ==> -- the constructor category 
   processing macro definition Implementation ==> -- the constructor capsule 
------------------------------------------------------------------------
   initializing NRLIB KERNEL for Kernel 
   compiling into NRLIB KERNEL 
   importing SortedCache $
   compiling exported is? : ($,Symbol) -> Boolean
;;; *** |KERNEL;is?;$SB;1| REDEFINED Time: 0.03 SEC.
compiling exported is? : ($,BasicOperator) -> Boolean
;;; *** |KERNEL;is?;$BoB;2| REDEFINED Time: 0.01 SEC.
compiling exported name : $ -> Symbol
;;; *** |KERNEL;name;$S;3| REDEFINED Time: 0 SEC.
compiling exported height : $ -> NonNegativeInteger KERNEL;height;$Nni;4 is replaced by QVELTk2
;;; *** |KERNEL;height;$Nni;4| REDEFINED Time: 0 SEC.
compiling exported operator : $ -> BasicOperator KERNEL;operator;$Bo;5 is replaced by QVELTk0
;;; *** |KERNEL;operator;$Bo;5| REDEFINED Time: 0 SEC.
compiling exported argument : $ -> List S KERNEL;argument;$L;6 is replaced by QVELTk1
;;; *** |KERNEL;argument;$L;6| REDEFINED Time: 0 SEC.
compiling exported position : $ -> NonNegativeInteger KERNEL;position;$Nni;7 is replaced by QVELTk3
;;; *** |KERNEL;position;$Nni;7| REDEFINED Time: 0 SEC.
compiling exported setPosition : ($,NonNegativeInteger) -> Void KERNEL;setPosition;$NniV;8 is replaced by QSETVELTk3n
;;; *** |KERNEL;setPosition;$NniV;8| REDEFINED Time: 0 SEC.
compiling local B2Z : Boolean -> Integer
;;; *** |KERNEL;B2Z| REDEFINED Time: 0 SEC.
compiling exported kernel : Symbol -> $ ****** comp fails at level 3 with expression: ****** error in function kernel
(|kernel| (|assert| (|operator| |s| 0) | << %symbol >> |) (|nil|) 1) ****** level 3 ****** $x:= %symbol $m:= (Symbol) $f:= ((((|s| # #) (|preds| #) (|triage| #) (B2Z #) ...)))
>> Apparent user error: Cannot coerce %symbol of mode %symbol to mode (Union %symbol (Symbol))

Test new defintion

axiom
position(exp(1)::Kernel EXPR INT)

\label{eq7}1536(7)
Type: PositiveInteger
axiom
position(pi()::EXPR INT::Kernel EXPR INT)

\label{eq8}1024(8)
Type: PositiveInteger
axiom
(%e<%pi)$EXPR INT
The function < is not implemented in Expression(Integer) .

axiom
position(atan(%pi/4)::Kernel EXPR INT)

\label{eq9}5120(9)
Type: PositiveInteger
axiom
position(exp(2)::Kernel EXPR INT)

\label{eq10}1792(10)
Type: PositiveInteger
axiom
atan(%pi/4) < exp(2)
There are 4 exposed and 1 unexposed library operations named < having 2 argument(s) but none was determined to be applicable. Use HyperDoc Browse, or issue )display op < to learn more about the available operations. Perhaps package-calling the operation or using coercions on the arguments will allow you to apply the operation.
Cannot find a definition or applicable library operation named < with argument type(s) Expression(Integer) Expression(Integer)
Perhaps you should use "@" to indicate the required return type, or "$" to specify which version of the function you need. (atan(%pi/4)::Kernel EXPR INT) < (exp(2)::Kernel EXPR INT)

\label{eq11} \mbox{\rm false} (11)
Type: Boolean

Compare this with:

axiom
ke:=exp(2)::Kernel EXPR INT

\label{eq12}e^2(12)
Type: Kernel(Expression(Integer))
axiom
kat:=atan(%pi/4)::Kernel EXPR INT

\label{eq13}\arctan \left({\pi \over 4}\right)(13)
Type: Kernel(Expression(Integer))
axiom
ke1o:=operator(ke)

\label{eq14}exp(14)
Type: BasicOperator
axiom
ke1a:=argument(ke)

\label{eq15}\left[ 2 \right](15)
Type: List(Expression(Integer))
axiom
ke1:=(operator(ke) argument(ke))

\label{eq16}e^2(16)
Type: Expression(Integer)
axiom
kat1:=(operator(kat) argument(kat))

\label{eq17}\arctan \left({\pi \over 4}\right)(17)
Type: Expression(Integer)
axiom
ke1 < kat1
There are 4 exposed and 1 unexposed library operations named < having 2 argument(s) but none was determined to be applicable. Use HyperDoc Browse, or issue )display op < to learn more about the available operations. Perhaps package-calling the operation or using coercions on the arguments will allow you to apply the operation.
Cannot find a definition or applicable library operation named < with argument type(s) Expression(Integer) Expression(Integer)
Perhaps you should use "@" to indicate the required return type, or "$" to specify which version of the function you need. ke2:=numericIfCan(operator(ke) argument(ke))

\label{eq18}7.3890560989306502272(18)
Type: Union(Float,...)
axiom
kat2:= numericIfCan(operator(kat) argument(kat))

\label{eq19}0.66577375002835386359(19)
Type: Union(Float,...)
axiom
ke2 < kat2

\label{eq20} \mbox{\rm false} (20)
Type: Boolean

I don't know why the compiled code behave differently. Perhaps because argument returns a list?

No, it is still wrong --unknown, Thu, 21 Jul 2005 17:28:17 -0500 reply
Results for 15, 16, 23 are wrong. Result of 26 is right.

Does NOT compile --kratt6, Sat, 23 Jul 2005 02:07:46 -0500 reply
You did note that your code does not compile?

I tried an explanation in

http://lists.nongnu.org/archive/html/axiom-developer/2005-07/msg00222.html

Martin




  Subject:   Be Bold !!
  ( 7 subscribers )  
Please rate this page: