
    gT                    x   d Z ddlmZ dgZddlmZmZ ddlmZm	Z	m
Z
 ddlmZmZmZ ddlmZmZ ddlZddlZ G d	 d
          Z G d de          Z G d de          Z G d de          Ze G d de                      Z G d dee          Z G d dee          Z G d dee          Z G d dee          Z G d dee          Z  G d dee          Z! G d d ee          Z" G d! d"ee          Z# G d# d$ee          Z$ G d% d&ee          Z% G d' d(ee          Z& G d) d*ee          Z' G d+ d,ee          Z( G d- d.ee          Z) G d/ d0ee          Z* G d1 d2eee          Z+ G d3 d4eee          Z, G d5 d6eee          Z- G d7 d8eee          Z. G d9 d:eee          Z/ G d; d<eee          Z0 G d= d>ee          Z1 G d? d@eee          Z2 G dA dBee          Z3 G dC dDee          Z4dHdEZ5dF Z6dG Z7e8                                 dS )Iz>Options manager for :class:`~.Poly` and public API functions.     )annotationsOptions)Basicsympify)GeneratorsErrorOptionError	FlagError)numbered_symbolstopological_sortpublic)has_dupsis_sequenceNc                      e Zd ZU dZdZded<   dZg Zded<   g Zded<   g Z	ded	<   g Z
ded
<   ed             Zed             Zed             ZdS )Optionz%Base class for all kinds of options. Nz
str | NoneoptionF	list[str]requiresexcludesafterbeforec                    d S N clss    S/var/www/html/ai-engine/env/lib/python3.11/site-packages/sympy/polys/polyoptions.pydefaultzOption.default       t    c                    d S r   r   )r   r   s     r   
preprocesszOption.preprocess!   r   r   c                    d S r   r   r   optionss     r   postprocesszOption.postprocess%   s    r   )__name__
__module____qualname____doc__r   __annotations__is_Flagr   r   r   r   classmethodr   r!   r%   r   r   r   r   r      s         //FGHHEF  [   [   [  r   r   c                      e Zd ZdZdZdS )Flagz#Base class for all kinds of flags. TN)r&   r'   r(   r)   r+   r   r   r   r.   r.   *   s        --GGGr   r.   c                  (    e Zd ZdZed             ZdS )BooleanOptionzAAn option that must have a boolean value or equivalent assigned. c                \    |dv rt          |          S t          d| j        d|          )N)TF'z*' must have a boolean value assigned, got )boolr   r   )r   values     r   r!   zBooleanOption.preprocess3   s<    M!!;;+SVS]S]S]_d_defffr   N)r&   r'   r(   r)   r,   r!   r   r   r   r0   r0   0   s8        KKg g [g g gr   r0   c                      e Zd ZdZd ZdS )
OptionTypez7Base type for all options that does registers options. c                     t            fd            }t          t           j        |            t          j         j        <   d S )Nc                h    	 | j                  S # t          $ r                                 cY S w xY wr   )r   KeyErrorr   )selfr   s    r   getterz#OptionType.__init__.<locals>.getter?   sD    %CJ'' % % %{{}}$$$%s    11)propertysetattrr   r   __options__)r   argskwargsr;   s   `   r   __init__zOptionType.__init__>   sQ    		% 	% 	% 	% 
	% 	V,,,*-CJ'''r   N)r&   r'   r(   r)   rA   r   r   r   r6   r6   ;   s)        AA	. 	. 	. 	. 	.r   r6   c                       e Zd ZU dZdZi Zded<   ddZed             Z	i fdZ
 fd	Zed
             Zed             Zed             Z xZS )r   aB  
    Options manager for polynomial manipulation module.

    Examples
    ========

    >>> from sympy.polys.polyoptions import Options
    >>> from sympy.polys.polyoptions import build_options

    >>> from sympy.abc import x, y, z

    >>> Options((x, y, z), {'domain': 'ZZ'})
    {'auto': False, 'domain': ZZ, 'gens': (x, y, z)}

    >>> build_options((x, y, z), {'domain': 'ZZ'})
    {'auto': False, 'domain': ZZ, 'gens': (x, y, z)}

    **Options**

    * Expand --- boolean option
    * Gens --- option
    * Wrt --- option
    * Sort --- option
    * Order --- option
    * Field --- boolean option
    * Greedy --- boolean option
    * Domain --- option
    * Split --- boolean option
    * Gaussian --- boolean option
    * Extension --- option
    * Modulus --- option
    * Symmetric --- boolean option
    * Strict --- boolean option

    **Flags**

    * Auto --- boolean flag
    * Frac --- boolean flag
    * Formal --- boolean flag
    * Polys --- boolean flag
    * Include --- boolean flag
    * All --- boolean flag
    * Gen --- flag
    * Series --- boolean flag

    Nzdict[str, type[Option]]r>   Fc           	     (    t                                           |r%|                    dd          rt          d          |rt          |          }||d<   |                    di           } fd} ||           t          |          D ]<}| v r||= 
                                 D ]} j        |         }	||	j        v r||=  n= ||                                            D ]y} j        |         }	|	j        D ]-}
                     |
          t          d|d|
d          .|	j        D ]-}                     |          t          d|d|d          .z j	        D ]"} j        |         
                                #d S )	Ngensr   z1both '*gens' and keyword argument 'gens' supplieddefaultsc                ,   |                                  D ]}\  }}	 j        |         }n # t          $ r t          d|z            w xY wt	          |t
                    r|vrrt          d|z            ||                    |          |<   ~d S )N'%s' is not a valid option('%s' flag is not allowed in this context)itemsr>   r9   r   
issubclassr.   r!   )r?   r   r4   r   flagsr:   stricts       r   preprocess_optionsz,Options.__init__.<locals>.preprocess_options   s    !% 9 9M*62CC M M M%&BV&KLLLM c4(( c}e(;(;! c"-.X[a.a"b"bb$#&>>%#8#8DL9 9s	   *Ar2   z(' option is only allowed together with 'z'' option is not allowed together with ')dictrA   getr   popkeysr>   r   r   	__order__r%   )r:   rD   r?   rK   rL   rE   rM   keyr   r   require_optionexclude_options   `  ``       r   rA   zOptions.__init__~   s2   d 	 DHHVR(( 	 CE E E 	 ::DDL88J++	9 	9 	9 	9 	9 	9 	9 	4   >> 		 		Cd{{SMM"iikk  F*62Ccl**$SM + 	8$$$iikk 		r 		rF"6*C"%, s s88N++3%+Z`Z`Z`bpbpbp&qrrr 4 #&, r r88N++7%+Y_Y_Y_aoaoao&pqqq 8r n 	7 	7FV$006666	7 	7r   c                   | j         g t                      }}| j                                        D ]f\  }|                               |                    fd|j        D                        |                    fd|j        D                        g	 t          |t          |          f          | _         dS # t          $ r t          d          w xY wdS )z*Resolve the order of options' processing. Nc              3      K   | ]}|fV  	d S r   r   .0_namenames     r   	<genexpr>z3Options._init_dependencies_order.<locals>.<genexpr>   s'      EEueT]EEEEEEr   c              3      K   | ]}|fV  	d S r   r   rX   s     r   r\   z3Options._init_dependencies_order.<locals>.<genexpr>   s'      FFudE]FFFFFFr   z/cycle detected in sympy.polys options framework)rR   setr>   rI   appendupdater   r   r   list
ValueErrorRuntimeError)r   verticesedgesr   r[   s       @r   _init_dependencies_orderz Options._init_dependencies_order   s    =  #%%eH # 5 5 7 7 G Gf%%%EEEEEEEEEEFFFFFFFFFFFG 0(DKK1H I I G G G"EG G GG ! s   #B? ?Cc                    t                               | j                  }|                                 D ]
\  }}|||<   |                                D ]
\  }}|||<   |S )z-Clone ``self`` and update specified options. )rN   __new__	__class__rI   )r:   updatesobjr   r4   s        r   clonezOptions.clone   sf    ll4>**!ZZ\\ 	  	 MFECKK$]]__ 	  	 MFECKK
r   c                l    || j         v r|| |<   d S t                                          ||           d S r   )r>   super__setattr__)r:   attrr4   ri   s      r   ro   zOptions.__setattr__   s>    4###DJJJGGe,,,,,r   c                    i }|                                  D ]4\  }}|-|dk    r'| j        |         }t          |t                    s|||<   5|S )NrD   )rI   r>   rJ   r.   )r:   r?   r   r4   r   s        r   r?   zOptions.args   s`    !ZZ\\ 	) 	)MFE Vv%5%5&v.!#t,, )#(DLr   c                    i }| j                                         D ]-\  }}t          |t                    st	          | |          ||<   .|S r   r>   rI   rJ   r.   getattr)r:   r$   r   r   s       r   r$   zOptions.options   sT    +1133 	8 	8KFCc4(( 8")$"7"7r   c                    i }| j                                         D ]-\  }}t          |t                    rt	          | |          ||<   .|S r   rs   )r:   rK   r   r   s       r   rK   zOptions.flags   sT    +1133 	6 	6KFC#t$$ 6 'f 5 5fr   NF)r&   r'   r(   r)   rR   r>   r*   rA   r,   rf   rl   ro   r<   r?   r$   rK   __classcell__)ri   s   @r   r   r   J   s         - -^ I+-K----67 67 67 67p G G [G$  
 
 
 
- - - - - 
 
 X
   X   X    r   c                  J    e Zd ZU dZdZg Zded<   g Zded<   ed             Z	dS )Expandz8``expand`` option to polynomial manipulation functions. expandr   r   r   c                    dS NTr   r   s    r   r   zExpand.default  r   r   N)
r&   r'   r(   r)   r   r   r*   r   r,   r   r   r   r   ry   ry      s\         BBFHH  [  r   ry   )	metaclassc                  `    e Zd ZU dZdZg Zded<   g Zded<   ed             Z	ed             Z
dS )	Gensz6``gens`` option to polynomial manipulation functions. rD   r   r   r   c                    dS )Nr   r   r   s    r   r   zGens.default  s    rr   c                   t          |t                    r|f}n0t          |          dk    rt          |d                   r|d         }|dk    rd}nft	          |          rt          dt          |          z            t          d |D                       rt          dt          |          z            t          |          S )N   r   r   r   zduplicated generators: %sc              3  (   K   | ]}|j         d u V  dS )FN)is_commutativerY   gens     r   r\   z"Gens.preprocess.<locals>.<genexpr>!  s*      ==#u,======r   znon-commutative generators: %s)	
isinstancer   lenr   r   r   stranytuple)r   rD   s     r   r!   zGens.preprocess  s    dE"" 	7DDYY!^^DG 4 4^7D7??DDd^^ 	P!"=D		"IJJJ======= 	P!"BSYY"NOOOT{{r   Nr&   r'   r(   r)   r   r   r*   r   r,   r   r!   r   r   r   r   r   
  sw         @@FHH  [   [  r   r   c                  j    e Zd ZU dZdZg Zded<   g Zded<    ej	        d          Z
ed             ZdS )	Wrtz5``wrt`` option to polynomial manipulation functions. wrtr   r   r   z\s*,\s*|\s+c                   t          |t                    rt          |          gS t          |t                    rc|                                }|                    d          rt          d          |sg S t          | j                            |                    S t          |d          r"t          t          t          |                    S t          d          )N,zBad input: missing parameter.__getitem__z!invalid argument for 'wrt' option)r   r   r   stripendswithr   ra   	_re_splitsplithasattrmap)r   r   s     r   r!   zWrt.preprocess1  s    c5!! 	CHH:S!! 
	C))++C||C   C!"ABBB 	++C00111S-(( 	CC&&&ABBBr   N)r&   r'   r(   r)   r   r   r*   r   recompiler   r,   r!   r   r   r   r   r   '  sr         ??FHH
>**IC C [C C Cr   r   c                  `    e Zd ZU dZdZg Zded<   g Zded<   ed             Z	ed             Z
dS )	Sortz6``sort`` option to polynomial manipulation functions. sortr   r   r   c                    g S r   r   r   s    r   r   zSort.defaultJ  s    	r   c                    t          |t                    rd |                    d          D             S t          |d          r"t	          t          t          |                    S t          d          )Nc                6    g | ]}|                                 S r   )r   r   s     r   
<listcomp>z#Sort.preprocess.<locals>.<listcomp>Q  s     ===SSYY[[===r   >r   z"invalid argument for 'sort' option)r   r   r   r   ra   r   r   )r   r   s     r   r!   zSort.preprocessN  sk    dC   	D==DJJsOO====T=)) 	DC'''BCCCr   Nr   r   r   r   r   r   B  s|         @@FHH  [ D D [D D Dr   r   c                  `    e Zd ZU dZdZg Zded<   g Zded<   ed             Z	ed             Z
dS )	Orderz7``order`` option to polynomial manipulation functions. orderr   r   r   c                .    t           j        j        j        S r   )sympypolys	orderingslexr   s    r   r   zOrder.default`  s    {$((r   c                J    t           j        j                            |          S r   )r   r   r   monomial_key)r   r   s     r   r!   zOrder.preprocessd  s    {$11%888r   Nr   r   r   r   r   r   X  sw         AAFHH) ) [) 9 9 [9 9 9r   r   c                  .    e Zd ZU dZdZg Zded<   g dZdS )Fieldz7``field`` option to polynomial manipulation functions. fieldr   r   )domainr   gaussianNr&   r'   r(   r)   r   r   r*   r   r   r   r   r   r   i  s7         AAFH...HHHr   r   c                  .    e Zd ZU dZdZg Zded<   g dZdS )Greedyz8``greedy`` option to polynomial manipulation functions. greedyr   r   r   r   r   	extensionmodulus	symmetricNr   r   r   r   r   r   r  s7         BBFHSSSHHHr   r   c                  D    e Zd ZU dZdZed             Zg Zded<   g dZ	dS )	Compositez;``composite`` option to polynomial manipulation functions. 	compositec                    d S r   r   r   s    r   r   zComposite.default  r   r   r   r   r   N)
r&   r'   r(   r)   r   r,   r   r   r*   r   r   r   r   r   r   {  sR         EEF  [ HSSSHHHr   r   c                      e Zd ZU dZdZg Zded<   g dZdgZ e	j
        d          Z e	j
        d          Z e	j
        d	          Z e	j
        d
          Z e	j
        d          Z e	j
        d          Zed             Zed             ZdS )Domainz8``domain`` option to polynomial manipulation functions. r   r   r   )r   r   r   r   r   rD   z^(R|RR)(_(\d+))?$z^(C|CC)(_(\d+))?$z^(FF|GF)\((\d+)\)$z)^(Z|ZZ|Q|QQ|ZZ_I|QQ_I|R|RR|C|CC)\[(.+)\]$z^(Z|ZZ|Q|QQ)\((.+)\)$z^(Q|QQ)\<(.+)\>$c                j	   t          |t          j        j        j                  r|S t          |d          r|                                S t          |t                    rB|dv rt          j        j        j        S |dv rt          j        j        j	        S |dk    rt          j        j        j
        S |dk    rt          j        j        j        S |dk    rt          j        j        j        S | j                            |          }|a|                                \  }}}|t          j        j        j        S t          j        j                            t%          |                    S | j                            |          }|a|                                \  }}}|t          j        j        j        S t          j        j                            t%          |                    S | j                            |          }|It          j        j                            t%          |                                d                             S | j                            |          }||                                \  }}t3          t5          t6          |                    d                              }|dv rt          j        j        j        j        | S |dv rt          j        j        j	        j        | S |d	v rt          j        j        j        j        | S |dk    rt          j        j        j
        j        | S |dk    rt          j        j        j        j        | S t          j        j        j        j        | S | j                            |          }||                                \  }}t3          t5          t6          |                    d                              }|dv rt          j        j        j        j        | S t          j        j        j	        j        | S | j                             |          }|jt3          t5          t6          |                                d                             d                              }t          j        j        j	        j!        | S tE          d
|z            )N	to_domain)ZZZ)QQQZZ_IQQ_IEXr   r   )RRRz-expected a valid domain specification, got %s)#r   r   r   domainsr   r   r   r   r   r   r   r   r   _re_realfieldmatchgroupsr   	RealFieldint_re_complexfieldCCComplexField_re_finitefieldFF_re_polynomialra   r   r   r   	poly_ring_re_fraction
frac_field_re_algebraicalgebraic_fieldr   )r   r   r_precgroundrD   s          r   r!   zDomain.preprocess  s   fek1899 Q	EMV[)) O	E##%%%$$ M	E$${*--$${*--{*//{*//~~{*--!''//A}XXZZ
1d< ;.11 ;.88TCCC$**622A}XXZZ
1d< ;.11 ;.;;CIIFFF#))&11A}{*--c!((**Q-.@.@AAA"((00A} xxzzCC99::[(( ;.1;TBB{** ;.1;TBB{** ;.1;TBBv%% ;.3=tDDv%% ;.3=tDD ;.1;TBB &&v..A} xxzzCC99::[(( ;.1<dCC ;.1<dCC!''//A}CA)<)<S)A)ABBCC{*-=tDDIFRSSSr   c                4   d|v rPd|v rL|d         j         r?t          |d         j                  t          |d                   z  rt          d          d|vs|d         s5d|v r/|d         t          j        j        j        k    rt          d          d S d S d S )NrD   r   z/ground domain and generators interfere togetherz>you have to provide generators because EX domain was requested)is_Compositer^   symbolsr   r   r   r   r   r#   s     r   r%   zDomain.postprocess  s    WW!4!49J9W!4WX&.//#gfo2F2FF "5!AC C CG##76?#G##(9U[=P=S(S(S!"bccc $# $#(S(Sr   N)r&   r'   r(   r)   r   r   r*   r   r   r   r   r   r   r   r   r   r   r,   r!   r%   r   r   r   r   r     s         BBFHDDDHHEBJ344M!rz"677 bj!677ORZ LMMN2:677LBJ233MTT TT [TTl d d [d d dr   r   c                  D    e Zd ZU dZdZg Zded<   g dZed             Z	dS )Splitz7``split`` option to polynomial manipulation functions. r   r   r   )r   r   r   r   r   r   r   c                ,    d|v rt          d          d S )Nr   z%'split' option is not implemented yet)NotImplementedErrorr#   s     r   r%   zSplit.postprocess  s$    g%&MNNN r   N
r&   r'   r(   r)   r   r   r*   r   r,   r%   r   r   r   r   r     sc         AAFH     H O O [O O Or   r   c                  D    e Zd ZU dZdZg Zded<   g dZed             Z	dS )Gaussianz:``gaussian`` option to polynomial manipulation functions. r   r   r   )r   r   r   r   r   r   r   c                    d|v r?|d         du r7t           j        j        j        |d<   t                              |           d S d S d S )Nr   Tr   )r   r   r   r   	Extensionr%   r#   s     r   r%   zGaussian.postprocess  sV      WZ%8D%@%@ % 3 8GH!!'***** ! %@%@r   Nr   r   r   r   r   r   
  s^         DDFH     H + + [+ + +r   r   c                  Z    e Zd ZU dZdZg Zded<   g dZed             Z	ed             Z
dS )	r   z;``extension`` option to polynomial manipulation functions. r   r   r   )r   r   r   r   r   r   c                    |dk    rt          |          S |dk    rt          d          t          |d          s|h}n|sd }nt          |          }|S )Nr   r   z.'False' is an invalid argument for 'extension'__iter__)r3   r   r   r^   )r   r   s     r   r!   zExtension.preprocess#  sj    >>	??"!^^NOOO9j11 /&K		  / $II #IIr   c                v    d|v r2|d         dur*t          j        j        j        j        |d          |d<   d S d S d S )Nr   Tr   )r   r   r   r   r   r#   s     r   r%   zExtension.postprocess4  sR    '!!gk&:$&F&F % 3 6 F%!'GH "!&F&Fr   Nr&   r'   r(   r)   r   r   r*   r   r,   r!   r%   r   r   r   r   r     sy         EEFH  H   [  ' ' [' ' 'r   r   c                  Z    e Zd ZU dZdZg Zded<   g dZed             Z	ed             Z
dS )	Modulusz9``modulus`` option to polynomial manipulation functions. r   r   r   )r   r   r   r   r   c                |    t          |          }|j        r|dk    rt          |          S t          d|z            )Nr   z)'modulus' must a positive integer, got %s)r   
is_Integerr   r   )r   r   s     r   r!   zModulus.preprocessC  sL    '"" 	G'A++w<<;gEG G Gr   c                    d|v rH|d         }|                     dd          }t          j        j                            ||          |d<   d S d S )Nr   r   Tr   )rO   r   r   r   r   )r   r$   r   r   s       r   r%   zModulus.postprocessM  sW    i(GK66I % 3 6 6w	 J JGH  r   Nr   r   r   r   r   r   ;  sy         CCFHEEEHG G [G K K [K K Kr   r   c                  $    e Zd ZdZdZdgZg dZdS )	Symmetricz;``symmetric`` option to polynomial manipulation functions. r   r   )r   r   r   r   r   N)r&   r'   r(   r)   r   r   r   r   r   r   r   r   U  s+        EEF{HEEEHHHr   r   c                  ,    e Zd ZdZdZed             ZdS )Strictz8``strict`` option to polynomial manipulation functions. rL   c                    dS r|   r   r   s    r   r   zStrict.defaultc  r   r   Nr&   r'   r(   r)   r   r,   r   r   r   r   r   r   ^  s8        BBF  [  r   r   c                  J    e Zd ZdZdZg dZed             Zed             ZdS )Autoz4``auto`` flag to polynomial manipulation functions. auto)r   r   r   r   c                    dS r|   r   r   s    r   r   zAuto.defaulto  r   r   c                0    d|v sd|v rd|vrd|d<   d S d S d S )Nr   r   r   Fr   r#   s     r   r%   zAuto.postprocesss  s=    7g#5#56;P;P#GFOOO <Q;P#5#5r   N)	r&   r'   r(   r)   r   r   r,   r   r%   r   r   r   r   r   h  s^        >>F888E  [ $ $ [$ $ $r   r   c                  ,    e Zd ZdZdZed             ZdS )Fracz6``auto`` option to polynomial manipulation functions. fracc                    dS rv   r   r   s    r   r   zFrac.default~      ur   Nr   r   r   r   r  r  y  s8        @@F  [  r   r  c                  ,    e Zd ZdZdZed             ZdS )Formalz6``formal`` flag to polynomial manipulation functions. formalc                    dS rv   r   r   s    r   r   zFormal.default  r  r   Nr   r   r   r   r  r    8        @@F  [  r   r  c                      e Zd ZdZdZdS )Polysz5``polys`` flag to polynomial manipulation functions. r   N)r&   r'   r(   r)   r   r   r   r   r  r    s        ??FFFr   r  c                  ,    e Zd ZdZdZed             ZdS )Includez7``include`` flag to polynomial manipulation functions. includec                    dS rv   r   r   s    r   r   zInclude.default  r  r   Nr   r   r   r   r  r    s8        AAF  [  r   r  c                  ,    e Zd ZdZdZed             ZdS )Allz3``all`` flag to polynomial manipulation functions. allc                    dS rv   r   r   s    r   r   zAll.default  r  r   Nr   r   r   r   r  r    s8        ==F  [  r   r  c                  B    e Zd ZdZdZed             Zed             ZdS )Genz3``gen`` flag to polynomial manipulation functions. r   c                    dS )Nr   r   r   s    r   r   zGen.default  s    qr   c                \    t          |t          t          f          r|S t          d          )Nz!invalid argument for 'gen' option)r   r   r   r   )r   r   s     r   r!   zGen.preprocess  s-    cE3<(( 	CJABBBr   Nr&   r'   r(   r)   r   r,   r   r!   r   r   r   r  r    sX        ==F  [ C C [C C Cr   r  c                  ,    e Zd ZdZdZed             ZdS )Seriesz6``series`` flag to polynomial manipulation functions. seriesc                    dS rv   r   r   s    r   r   zSeries.default  r  r   Nr   r   r   r   r  r    r
  r   r  c                  B    e Zd ZdZdZed             Zed             ZdS )Symbolsz7``symbols`` flag to polynomial manipulation functions. r   c                $    t          dd          S )Nsr   )start)r
   r   s    r   r   zSymbols.default  s    1----r   c                d    t          |d          rt          |          S t          d|z            )Nr   z2expected an iterator or iterable container, got %s)r   iterr   )r   r   s     r   r!   zSymbols.preprocess  s6    7J'' 	^== RU\\]]]r   Nr  r   r   r   r  r    sX        AAF. . [. ^ ^ [^ ^ ^r   r  c                  ,    e Zd ZdZdZed             ZdS )Methodz6``method`` flag to polynomial manipulation functions. methodc                x    t          |t                    r|                                S t          d|z            )Nzexpected a string, got %s)r   r   lowerr   )r   r'  s     r   r!   zMethod.preprocess  s7    fc"" 	D<<>>!9FBCCCr   N)r&   r'   r(   r)   r   r,   r!   r   r   r   r&  r&    s=        @@FD D [D D Dr   r&  c                p    |d| }} t          |          dk    sd|vs| rt          | |          S |d         S )z9Construct options from keyword arguments or ... options. Nr   r   opt)r   r   )rD   r?   s     r   build_optionsr,    sH    |d
4yyA~~d**d*tT"""E{r   c                    t          |          }|                                 D ]P}	 t          j        |         j        r||vrt          d|z            1# t          $ r t          d|z            w xY wdS )a  
    Allow specified flags to be used in the given context.

    Examples
    ========

    >>> from sympy.polys.polyoptions import allowed_flags
    >>> from sympy.polys.domains import ZZ

    >>> allowed_flags({'domain': ZZ}, [])

    >>> allowed_flags({'domain': ZZ, 'frac': True}, [])
    Traceback (most recent call last):
    ...
    FlagError: 'frac' flag is not allowed in this context

    >>> allowed_flags({'domain': ZZ, 'frac': True}, ['frac'])

    rH   rG   N)r^   rQ   r   r>   r+   r	   r9   r   )r?   rK   args      r   allowed_flagsr/    s    ( JJEyy{{ B B	B"3'/ FCu4D4D>DF F F 	B 	B 	B:S@AAA	BB Bs   -AA2c                6    d| vrt          |           } || d<   | S )z$Update options with default values. rE   )rN   )r$   rE   s     r   set_defaultsr1  
  s'      w--&
Nr   r   )9r)   
__future__r   __all__
sympy.corer   r   sympy.polys.polyerrorsr   r   r	   sympy.utilitiesr
   r   r   sympy.utilities.iterablesr   r   sympy.polysr   r   r   r.   r0   typer6   rN   r   ry   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r  r  r  r  r  r&  r,  r/  r1  rf   r   r   r   <module>r:     s&   D D " " " " " "+ % % % % % % % % J J J J J J J J J J F F F F F F F F F F ; ; ; ; ; ; ; ;     				       4    6   g g g g gF g g g. . . . . . . . o o o o od o o od
 
 
 
 
]j 
 
 
 
    6Z    :C C C C C&J C C C C6D D D D D6Z D D D D,9 9 9 9 9Fj 9 9 9 9"/ / / / /MZ / / / /T T T T T]j T T T T
T 
T 
T 
T 
T 
T 
T 
T 
Tpd pd pd pd pdVz pd pd pd pdfO O O O OMZ O O O O+ + + + +}
 + + + + ' ' ' ' '* ' ' ' 'BK K K K Kf
 K K K K4F F F F F F F F F    ]j    $ $ $ $ $=$* $ $ $ $"    =$*        ]DJ        M4:        mTZ        -    C C C C C$* C C C C"    ]DJ    ^ ^ ^ ^ ^dj ^ ^ ^ ^"
D 
D 
D 
D 
DTZ 
D 
D 
D 
D   B B B>        " " " " "r   