Some Context Probleme ?



Your program works in commercial macsyma on windows.


You could read about  declare(f,linear) to see if that
can help.
Also you can do this:
testfonc(x):=is (member(x,Fonc));

and  testsum(x):= is (atom(x) or (part(x,0)="+"))

   what did you want to do if the expression is 3*z ??
If you set
debugmode:true

and trace(is)

you might get more information.
RJF


Marc GILG wrote:
> Hello,,
> 
> I have create a file with some rules definitions, for exemple :
> LIN : f[x+y,z]->f[x,z]+f[y,z]
> A have also define a fonction in this file :
> e(x,y):=f[x,y];
> Now a load the file with BATCHLOAD("pb.mac");
> Now if I do APPLYB1(f[x,y],LIN); then OK
> If I do APPLYB1(e(x,y),LIN); then mistake !!!
> 
> What happed ?
> 
> Thank you for your help.
> 
> Marc GILG
> PS: I joint a copy of the file and the output from xmaxima. 
> 
> 
> 
> 
> ------------------------------------------------------------------------
> 
> 
> PARTSWITCH:TRUE$
> 
> PART2SUM(x):=BLOCK([rep:0,i],FOR i:2 STEP 1 UNLESS PART(x,i)=END DO
>                       rep:rep+PART(x,i),rep)$ 
> 
> /* Definition des noms de fonction */
> Fonc : [f,g]$
> /* Test si x est une fonction */
> TESTFONC(x):=IF MEMBER(x,Fonc) THEN TRUE ELSE FALSE$
> 
> /* Teste si x est une somme */
>  TESTSUM(x):=IF ATOM(x) THEN FALSE ELSE IF PART(x,0)="+" THEN TRUE ELSE FALSE$
> 
> 
> /* Declaration de modeles */ 
>  MATCHDECLARE(f,TESTFONC)$ 
>  MATCHDECLARE(A,TRUE)$
> 
> /* Declaration de la regle LIN */
>  MATCHDECLARE(B,TESTSUM)$
>  DEFRULE(LIN,f[A,B],f[A,PART(B,1)]+f[A,PART2SUM(B)])$ 
> 
> e(x,y):=f[x,y];
> 
> 
> ------------------------------------------------------------------------
> 
> (C1) 
> 
> batching #p/home/gilg/maxima/pb.mac
> (C2) 						 PARTSWITCH : TRUE
> (C3)  PART2SUM(x) := BLOCK([rep : 0, i], FOR i FROM 2 UNLESS PART(x, i) = END DO rep : PART(x, i) + rep, rep)
> (C4) 						   Fonc : [f, g]
> (C5) 			      TESTFONC(x) := IF MEMBER(x, Fonc) THEN TRUE ELSE FALSE
> (C6) 	        TESTSUM(x) := IF ATOM(x) THEN FALSE ELSE (IF PART(x, 0) = "+" THEN TRUE ELSE FALSE)
> (C7) 					     MATCHDECLARE(f, TESTFONC)
> (C8) 					       MATCHDECLARE(A, TRUE)
> (C9) 					     MATCHDECLARE(B, TESTSUM)
> (C10) 			       DEFRULE(LIN, f	 , f		   + f		   )
> 					     A, B   A, PART2SUM(B)    A, PART(B, 1)
> (C11) 						 e(x, y) := f
> 							     x, y
> (D11) 						 e(x, y) := f
> 							     x, y
> (C12) APPLYB1(f[x,y],LIN);
> (D12) 						       f
> 							x, y
> (C13) APPLYB1(e(x,y),LIN);
> 
> Error: Caught fatal error [memory may be damaged]
> Fast links are on: do (si::use-fast-links nil) for debugging
> Error signalled by COND.
> Broken at IS.  Type :H for Help.
> MAXIMA>>
>