
    \h                     2    S SK Jr  SSKJr   " S S\5      rg)   )
CartanType    )Atomc                   H    \ rS rSrSrS rS rS rS rS r	S r
S	 rS
 rSrg)
RootSystem   a  Represent the root system of a simple Lie algebra

Every simple Lie algebra has a unique root system.  To find the root
system, we first consider the Cartan subalgebra of g, which is the maximal
abelian subalgebra, and consider the adjoint action of g on this
subalgebra.  There is a root system associated with this action. Now, a
root system over a vector space V is a set of finite vectors Phi (called
roots), which satisfy:

1.  The roots span V
2.  The only scalar multiples of x in Phi are x and -x
3.  For every x in Phi, the set Phi is closed under reflection
    through the hyperplane perpendicular to x.
4.  If x and y are roots in Phi, then the projection of y onto
    the line through x is a half-integral multiple of x.

Now, there is a subset of Phi, which we will call Delta, such that:
1.  Delta is a basis of V
2.  Each root x in Phi can be written x = sum k_y y for y in Delta

The elements of Delta are called the simple roots.
Therefore, we see that the simple roots span the root space of a given
simple Lie algebra.

References
==========

.. [1] https://en.wikipedia.org/wiki/Root_system
.. [2] Lie Algebras and Representation Theory - Humphreys

c                 R    [         R                  " U 5      n[        U5      Ul        U$ )ae  Create a new RootSystem object

This method assigns an attribute called cartan_type to each instance of
a RootSystem object.  When an instance of RootSystem is called, it
needs an argument, which should be an instance of a simple Lie algebra.
We then take the CartanType of this argument and set it as the
cartan_type attribute of the RootSystem instance.

)r   __new__r   cartan_type)cls
cartantypeobjs      U/var/www/auris/envauris/lib/python3.13/site-packages/sympy/liealgebras/root_system.pyr
   RootSystem.__new__%   s#     ll3$Z0
    c                     U R                   R                  5       n[        SUS-   5       Vs0 s H  o"U R                   R                  U5      _M      nnU$ s  snf )a  Generate the simple roots of the Lie algebra

The rank of the Lie algebra determines the number of simple roots that
it has.  This method obtains the rank of the Lie algebra, and then uses
the simple_root method from the Lie algebra classes to generate all the
simple roots.

Examples
========

>>> from sympy.liealgebras.root_system import RootSystem
>>> c = RootSystem("A3")
>>> roots = c.simple_roots()
>>> roots
{1: [1, -1, 0, 0], 2: [0, 1, -1, 0], 3: [0, 0, 1, -1]}

r   )r   rankrangesimple_root)selfnirootss       r   simple_rootsRootSystem.simple_roots3   sU    $ !!#=B1ac]K]D$$0033]K Ls   %Ac                     U R                   R                  5       n[        UR                  5       5      n[	        U5      nU H"  nUS-  nX   nU Vs/ s H  of* PM     nnXqU'   M$     U$ s  snf )aW  Generate all the roots of a given root system

The result is a dictionary where the keys are integer numbers.  It
generates the roots by getting the dictionary of all positive roots
from the bases classes, and then taking each root, and multiplying it
by -1 and adding it to the dictionary.  In this way all the negative
roots are generated.

r   )r   positive_rootslistkeysmax)r   alphar   kvalrootxnewroots           r   	all_rootsRootSystem.all_rootsJ   sr       //1EJJL!ICFA:D#'(4ar4G(!H	 
  )s   A)c                     U R                   R                  5       nSR                  S [        SUS-   5       5       5      nU$ )a  Return the span of the simple roots

The root space is the vector space spanned by the simple roots, i.e. it
is a vector space with a distinguished basis, the simple roots.  This
method returns a string that represents the root space as the span of
the simple roots, alpha[1],...., alpha[n].

Examples
========

>>> from sympy.liealgebras.root_system import RootSystem
>>> c = RootSystem("A3")
>>> c.root_space()
'alpha[1] + alpha[2] + alpha[3]'

z + c              3   D   #    U  H  nS [        U5      -   S-   v   M     g7f)zalpha[]N)str).0r   s     r   	<genexpr>(RootSystem.root_space.<locals>.<genexpr>p   s     DmQ,ms    r   )r   r   joinr   )r   r   rss      r   
root_spaceRootSystem.root_space^   s;    " !!#ZZDeAqsmDD	r   c                     U R                  5       nU[        U5      :  d  U[        U5      :  a  [        S5      eX1   nX2   n[        XE5       VVs/ s H	  u  pgXg-   PM     nnnU$ s  snnf )a  Add two simple roots together

The function takes as input two integers, root1 and root2.  It then
uses these integers as keys in the dictionary of simple roots, and gets
the corresponding simple roots, and then adds them together.

Examples
========

>>> from sympy.liealgebras.root_system import RootSystem
>>> c = RootSystem("A3")
>>> newroot = c.add_simple_roots(1, 2)
>>> newroot
[1, 0, -1, 0]

z&You've used a root that doesn't exist!)r   len
ValueErrorzip)	r   root1root2r!   a1a2_a1_a2r&   s	            r   add_simple_rootsRootSystem.add_simple_rootss   si    $ !!#3u:U!3EFF\\-0[9[39[9 :s   A%c                     U R                  5       n[        X5       VVs/ s H	  u  pEXE-   PM     nnnXcR                  5       ;   a  U$ gs  snnf )a+  Add two roots together if and only if their sum is also a root

It takes as input two vectors which should be roots.  It then computes
their sum and checks if it is in the list of all possible roots.  If it
is, it returns the sum.  Otherwise it returns a string saying that the
sum is not a root.

Examples
========

>>> from sympy.liealgebras.root_system import RootSystem
>>> c = RootSystem("A3")
>>> c.add_as_roots([1, 0, -1, 0], [0, 0, 1, -1])
[1, 0, 0, -1]
>>> c.add_as_roots([1, -1, 0, 0], [0, 0, -1, 1])
'The sum of these two roots is not a root'

z(The sum of these two roots is not a root)r'   r7   values)r   r8   r9   r!   r1r2r&   s          r   add_as_rootsRootSystem.add_as_roots   sH    &  ),U):;):vr27):;lln$N=	 <s   Ac                 6    U R                   R                  5       $ )zCartan matrix of Lie algebra associated with this root system

Examples
========

>>> from sympy.liealgebras.root_system import RootSystem
>>> c = RootSystem("A3")
>>> c.cartan_matrix()
Matrix([
    [ 2, -1,  0],
    [-1,  2, -1],
    [ 0, -1,  2]])
)r   cartan_matrixr   s    r   rG   RootSystem.cartan_matrix   s     --//r   c                 6    U R                   R                  5       $ )zDynkin diagram of the Lie algebra associated with this root system

Examples
========

>>> from sympy.liealgebras.root_system import RootSystem
>>> c = RootSystem("A3")
>>> print(c.dynkin_diagram())
0---0---0
1   2   3
)r   dynkin_diagramrH   s    r   rK   RootSystem.dynkin_diagram   s     ..00r    N)__name__
__module____qualname____firstlineno____doc__r
   r   r'   r2   r>   rD   rG   rK   __static_attributes__rM   r   r   r   r      s0    @.(*4>60 1r   r   N)r   r   sympy.core.basicr   r   rM   r   r   <module>rU      s    # !@1 @1r   