
    MZd                         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y	)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     9/usr/lib/python3/dist-packages/sympy/assumptions/facts.pyget_composite_predicatesr(      sz   
 	
aff$qzz1			AFFQUUN	

QVV+			AJJ+	+	!--

:QVVCajjPSTSfSff	QZZ!*=*==	QZZ!*=*==	A//!**<qzzIAL_L__	 3 3ajj @166 I	 3a6I6I I			AKK!"2"22 r&   Nc                    | 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        j0                  |             t        t        j                  |       t        j.                  |       t        j0                  |       z        t        t        j2                  |       t        j4                  |             t        t        j                  |       t        j4                  |             t        t        j                  |       t        j                  |       z  t        j2                  |             t        t        j4                  |       t        j2                  |       z  t        j6                  |             t        t        j8                  |       t        j:                  |             t        t        j8                  |       t        j<                  |             t        t        j<                  |       t        j>                  |       z  t        j8                  |             t        t        j<                  |       t        j@                  |             t        t        j<                  |       t        jB                  |             t        t        j@                  |       t        jD                  |             t        t        jF                  |       t        j@                  |             t        t        j:                  |       t        jB                  |             t        t        jF                  |       t        jH                  |             t        t        jF                  |       t        jJ                  |             t        t        jJ                  |       t        jL                  |             t        t        jH                  |       t        jL                  |             t        t        jL                  |       t        jH                  |       t        jJ                  |       z        t        t        jH                  |       t        jJ                  |       z  t        jF                  |             t        t        jF                  |       t        jN                  |             t        t        jP                  |       t        jL                  |             t        t        jB                  |       t        jR                  |             t        t        jB                  |       t        jD                  |             t        t        jN                  |       t        jD                  |             t        t        jR                  |       t        jD                  |       z  t        jB                  |             t        t        jB                  |       t        jT                  |              t        t        jV                  |       t        j>                  |             t        t        j>                  |       t        jX                  |              }|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.

    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   " 	y3K <!%%a(!**Q-JJqM1..q1	3< 	!&&)Q[[^,< 	q	AKKN*AIIaL9< 	!""1%q{{1~6< 	166!9ajjmall1o=>< 	!,,q/1::a=1< 	

1q{{1~.<  	!&&)QUU1X&!<" 			!ajjm,#<$ 	q	166!9%%<& 	!++a.!''!*-'<( 	A+QYYq\AJJqM-IJ)<* 	q	AJJqM)QWWQZK7QH+<0 	q	1;;q>*1<2 	A 233<4 	q	1;;q>AOOA,>>?5<: 	!**Q-!-;<< 			!ahhqk*=<> 	##A&)<)<Q)??AO?<D 	ajjm+Q]]1-=>E<J 	Q!4!4Q!78K<L 	Q1.M<N 			!qq111<<?CO<P 			!ahhqk*Q<R 			!all1o.S<T 	QXXa[)U<V 	

1qxx{+W<X 	##A&Q8Y<Z 	

1q11!45[<\ 	

1q11!45]<^ 	""1%q||A7_<` 	""1%q||A7a<b 	Q!3!3A!69K9KA9N!NOc<d 	""1%(:(:1(==qzz!}Me<f 	

1q{{1~.g<h 	!!!$all1o6i<j 	QA/k<l 	Q!-m<n 	A,o<p 	

1+Q\\!_=q<r 	1<<?QZZ]N3s<t 	""1%qq'9:u<v 	"A$6$6q$9:w<Dz Kr&   c                    t        |      }t        | |      }i }|j                         D ]  \  }}t               }t               }|D ]i  }	t	        |	t
              r|j                  |	j                         /t	        |	t              s@|	j                  d   }
|j                  |
j                         k ||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0G
Cmmo 	0
U%5 	,D$ 01DMM*D#&yy|T]]+	, %h/CLL	0 Jr&   c                     t               } t        j                  t        j                  t        j                  t        j
                  t        j                  t        j                  fD ]  }| j                  |        g }t        j                  j                  D ]:  }|j                  d      rt        t        |      }|| v r*|j                  |       < |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     eGqttQTT144qtt4 D F$$ ??4 q$7?d Mr&   c                     i }| D ]Z  }|h||<   | D ]M  }||k7  s	t        |||      r||   j                  |       t        | ||      s9||   j                  |        O \ |S r   )ask_full_inferencerM   )known_facts_keysknown_facts_cnfrR   rT   	other_keys        r'   rI   rI      s    G 1u) 	1IC%ioFCL$$Y/%yj#GCL$$iZ0	11 Nr&   c           	      r    t        t        |||             syt        t        ||t        |                   syy)z9
    Method for inferring properties about objects.

    FTN)r   r   r	   )propositionassumptionsro   s      r'   rm   rm      s4    
 s?KEFs?K[9IJKr&   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{      st    $ 5 $ $  - 	 	& 	P 	Pf/d 	 	0	r&   