Problem with Times. Bug ????

*To*: mathgroup at yoda.physics.unc.edu*Subject*: Problem with Times. Bug ????*From*: barenco at eldp.epfl.ch (ADRI)*Date*: Thu, 3 Jun 1993 17:10:53 +0200

Hello, I am trying to implement a fast non-commutative operation under Mma to work with non-commutative algebras (see a previous post). Among the things I tried, one was to redefine the Times operation in order to make it non- commutative on a certain class of objects, and to reimplement the commutativity for all other standard objects for which Times is usually commutative. I know that this is _highly_ discouraged by the authors of Mma. I tried various implementations, and got contradictory or inconsistent results, I tracked down the problem and found this : In[1]:= b a Out[1]= a b ! this is the standard order, Times is ! commutative In[2]:= Unprotect[Times]; In[3]:= ClearAttributes[Times,Orderless] ! This removes the commutativity of Times In[4]:= b a Out[4]= b a ! OK, it doesn't commute anymore In[5]:= a_*(b_+c_):=a*b + a*c; ! This introduces the left ditributivity ! of Times on Plus In[6]:= 2 (1 + b a) Out[6]= 2 + b a ! the result is as expected. In[7]:= 2 (1 - b a) Out[7]= 2 - 2 a b ! ???? the expression In[7] matches the pattern ! on the left handside of In[5], but in the ! replacement process Mma seems to have forgotten ! that Times is not commutative anymore !!! Is this a bug ? Is it due to a specific implementation of Times in the Kernel of Mma, so that Times does not tolerate modifications of its attributes ? Thanks for your answers, Adriano Barenco ============================================== Adriano Barenco Inst. for Micro- and Optoelectronics Dept. of Physics Swiss Fed. Inst. of Technology (EPFL) PHB-Ecublens CH-1015 Lausanne (Switzerland) email: barenco at eldpa.epfl.ch ==============================================