
    Ed                         d Z ddlmZ ddlmZ ddlmZ ddlmZ ddl	m
Z
mZmZmZmZmZ ddlmZ ed             Zedd
            Zd Zed             Zd Zd Zd	S )z
Known facts in assumptions module.

This module defines the facts between unary predicates in ``get_known_facts()``,
and supports functions to generate the contents in
``sympy.assumptions.ask_generated`` file.
    )Q)AppliedPredicate)cacheit)Symbol)to_cnfAndNotImplies
Equivalent	Exclusive)satisfiablec                     t           j        t           j        t           j        z  t           j        z  t           j        t           j        t           j        z  t           j        t           j        t           j        z  t           j	        t           j        t           j        z  t           j
        t           j        t           j        z  t           j        t           j        t           j        z  t           j        z  t           j        z  t           j        z  t           j        t           j        t           j        z  t           j        t           j        t           j        z  t           j        t           j        t           j        z  t           j        z  t           j        z  t           j        t           j        t           j        z  t           j        z  t           j        t           j        t           j        z  t           j        z  t           j        t           j        t           j        z  iS N)r   realnegativezeropositiveintegerevenoddnonpositivenonzerononnegativeextended_realnegative_infinitepositive_infiniteextended_positiveextended_negativeextended_nonzeroextended_nonpositiveextended_nonnegativecomplex	algebraictranscendental     7lib/python3.11/site-packages/sympy/assumptions/facts.pyget_composite_predicatesr(      s   
 	
af$qz1		AFQUN	
QV+		AJ+	+	!-
:QVCajPSTSff	QZ!*==	QZ!*==	A/!*<qzIAL__	 3aj @16 I	 3a6I I		AK!"22 r&   Nc                 L   | t          d          } t          g t          t          j        |           t          j        |           t          j        |           t          j        |           t          j        |                     t          t          j	        |           t          j
        |                     t          t          j	        |           t          j
        |           z  t          j        |                     t          t          j        |           t          j        |                     t          t          j	        |           t          j        |           t          j        |           z            t          t          j        |           t          j        |                     t          t          j        |           t          j        |                     t          t          j        |           t          j        |                     t          t          j        |           t          j        |                     t          t          j        |           t          j        |                     t          t          j        |           t          j        |                     t          t          j        |           t          j        |           z  t          j        |           t          j        |           z            t          t          j        |           t          j        |           z  t          j        |            z  t          j        |                     t          t          j	        |           t          j        |                     t          t          j
        |           t          j        |                     t          t          j        |           t          j        |           t          j        |           z            t          t          j        |           t          j        |                     t          t          j        |           t          j        |                     t          t          j        |           t          j        |           z  t          j        |                     t          t          j        |           t          j        |           z  t          j        |                     t          t          j        |           t          j        |                     t          t          j        |           t          j        |                     t          t          j        |           t          j        |           z  t          j        |                     t          t          j        |           t          j         |                     t          t          j        |           t          j!        |                     t          t          j         |           t          j"        |                     t          t          j#        |           t          j         |                     t          t          j        |           t          j!        |                     t          t          j#        |           t          j$        |                     t          t          j#        |           t          j%        |                     t          t          j%        |           t          j&        |                     t          t          j$        |           t          j&        |                     t          t          j&        |           t          j$        |           t          j%        |           z            t          t          j$        |           t          j%        |           z  t          j#        |                     t          t          j#        |           t          j'        |                     t          t          j(        |           t          j&        |                     t          t          j!        |           t          j)        |                     t          t          j!        |           t          j"        |                     t          t          j'        |           t          j"        |                     t          t          j)        |           t          j"        |           z  t          j!        |                     t          t          j!        |           t          j*        |                      t          t          j+        |           t          j        |                     t          t          j        |           t          j,        |                     R  }|S )z
    Facts between unary predicates.

    Parameters
    ==========

    x : Symbol, optional
        Placeholder symbol for unary facts. Default is ``Symbol('x')``.

    Returns
    =======

    fact : Known facts in conjugated normal form.

    Nx)-r   r   r   r   r   r   r   r   r   r   	imaginaryr
   r"   r$   r#   r   rational
irrationalr   r   r   	compositeprime	hermitianantihermitianinfinitefinitecommutative
orthogonalpositive_definiteunitaryreal_elementsnormal
invertiblesquarediagonalupper_triangularlower_triangular
triangular	symmetricunit_triangularfullranksingularinteger_elementscomplex_elements)r*   facts     r'   get_known_factsrG   &   s   " 	 3KK <!%a((!*Q--JqMM1.q11	3 	3< 	!&))Q[^^,,< 	q		AKNN*AIaLL99< 	!"1%%q{1~~66< 	16!99ajmmal1oo=>>< 	!,q//1:a==11< 	
1q{1~~..<  	!&))QU1XX&&!<" 		!ajmm,,#<$ 	q		16!99%%%<& 	!+a..!'!**--'<( 	A+QYq\\AJqMM-IJJ)<* 	q		AJqMM)QWQZZK7QHH+<0 	q		1;q>>**1<2 	A 2 2333<4 	q		1;q>>AOA,>,>>??5<: 	!*Q--!--;<< 		!ahqkk**=<> 	#A&&)<Q)?)??AOO?<D 	ajmm+Q]1-=-=>>E<J 	Q!4Q!7!788K<L 	Q1..M<N 		!qq1111<??CCO<P 		!ahqkk**Q<R 		!al1oo..S<T 	QXa[[))U<V 	
1qx{{++W<X 	#A&&Q88Y<Z 	
1q1!4455[<\ 	
1q1!4455]<^ 	"1%%q|A77_<` 	"1%%q|A77a<b 	Q!3A!6!69KA9N9N!NOOc<d 	"1%%(:1(=(==qz!}}MMe<f 	
1q{1~~..g<h 	!!$$al1oo66i<j 	QA//k<l 	Q!--m<n 	A,,o<p 	
1+Q\!__==q<r 	1<??QZ]]N33s<t 	"1%%qq'9'9::u<v 	""A$6q$9$9::w< < <Dz Kr&   c                    t          |          }t          | |          }i }|                                D ]\  }}t                      }t                      }|D ]n}	t	          |	t
                    r|                    |	j                   2t	          |	t                    r'|	j	        d         }
|                    |
j                   o||f||j        <   |S )a  
    Computes and returns a dictionary which contains the relations between
    unary predicates.

    Each key is a predicate, and item is two groups of predicates.
    First group contains the predicates which are implied by the key, and
    second group contains the predicates which are rejected by the key.

    All predicates in *keys* and *fact* must be unary and have same placeholder
    symbol.

    Parameters
    ==========

    keys : list of AppliedPredicate instances.

    fact : Fact between predicates in conjugated normal form.

    Examples
    ========

    >>> from sympy import Q, And, Implies
    >>> from sympy.assumptions.facts import generate_known_facts_dict
    >>> from sympy.abc import x
    >>> keys = [Q.even(x), Q.odd(x), Q.zero(x)]
    >>> fact = And(Implies(Q.even(x), ~Q.odd(x)),
    ...     Implies(Q.zero(x), Q.even(x)))
    >>> generate_known_facts_dict(keys, fact)
    {Q.even: ({Q.even}, {Q.odd}),
     Q.odd: ({Q.odd}, {Q.even, Q.zero}),
     Q.zero: ({Q.even, Q.zero}, {Q.odd})}
    r   )
r   single_fact_lookupitemsset
isinstancer   addfunctionr	   args)keysrF   fact_cnfmappingretkeyvalueimpliedrejectedexprpreds              r'   generate_known_facts_dictrZ   z   s    B d||H x00G
Cmmoo 	0 	0
U%%55 	, 	,D$ 011 ,DM****D#&& ,y|T]+++$h/CLJr&   c                     t                      } t          j        t          j        t          j        t          j        t          j        t          j        fD ]}|                     |           g }t          j	        j
        D ]G}|                    d          rt          t          |          }|| v r2|                    |           H|S )z
    Return every unary predicates registered to ``Q``.

    This function is used to generate the keys for
    ``generate_known_facts_dict``.

    __)rK   r   eqnegtltgelerM   	__class____dict__
startswithgetattrappend)excluderY   resultattrs       r'   get_known_facts_keysrk      s     eeGqtQT14qt4  DF$  ??4   	q$7? 	dMr&   c                     i }| D ]m}|h||<   | D ]b}||k    rZt          |||          r||                             |           t          | ||          r||                             |            cn|S r   )ask_full_inferencerM   )known_facts_keysknown_facts_cnfrR   rT   	other_keys        r'   rI   rI      s    G 1 1u) 	1 	1IC 1%ioFF 0CL$$Y///%yj#GG 1CL$$iZ000	1 Nr&   c           	          t          t          |||                     sdS t          t          ||t          |                               sdS dS )z9
    Method for inferring properties about objects.

    FTN)r   r   r	   )propositionassumptionsro   s      r'   rm   rm      sS    
 s?KEEFF us?K[9I9IJJKK t4r&   r   )__doc__sympy.assumptions.askr   sympy.assumptions.assumer   sympy.core.cacher   sympy.core.symbolr   sympy.logic.boolalgr   r   r	   r
   r   r   sympy.logic.inferencer   r(   rG   rZ   rk   rI   rm   r%   r&   r'   <module>r{      sN    $ # # # # # 5 5 5 5 5 5 $ $ $ $ $ $ $ $ $ $ $ $                - - - - - - 	  	& 	P P P 	Pf/ / /d 	  	0  	 	 	 	 	r&   