B
    >?[w                 @   sN   d dl mZmZmZmZmZmZmZmZm	Z	m
Z
mZmZ dddZdd ZdS )    )AllExpressionAndExpressionApplicationExpressionEqualityExpressionExistsExpressionIffExpressionImpExpressionNegatedExpressionOrExpressionVariableExpressionskolem_functionunique_variableNc             C   s  |dkrt  }|dkrt  }t| trdt| j|t | jgB |t | jgB }|| jtt|dS t| t	rt| j
||t| j||@ S t| trtt| j
||t| j||S t| trtt| j
 ||t| j||S t| tr(tt| j
 ||t| j||tt| j
||t| j ||@ S t| tr8| S t| tr| j}t|trt|j ||t |jgB }|r||jt|S tt|d}||j|S qt|t	rtt|j
 ||t|j ||S t|trt|j
 ||t|j ||@ S t|tr.t|j
||t|j ||@ S t|trztt|j
 ||t|j ||tt|j
||t|j||@ S t|tr| S t|trt|j||S t|trt|j |t |jgB |t |jgB }||jtt|dS t|tr | S td|  nxt| trjt| j||t | jgB }|rL|| jt|S tt|d}|| j|S nt| trz| S td|  dS )zO
    Skolemize the expression and convert to conjunctive normal form (CNF)
    N)ignorez'%s' cannot be skolemized)set
isinstancer   	skolemizetermZvariablereplacer   r   r   firstsecondr
   to_cnfr   r   r   r	   r   r   r   	Exception)Z
expressionZ
univ_scopeZused_variablesr   ZnegatedZskolem_constant r   1lib/python3.7/site-packages/nltk/sem/skolemize.pyr      s    



r   c             C   s`   t | tr*t| j|}t| j|}||@ S t |trTt| |j}t| |j}||@ S | |B S dS )zI
    Convert this split disjunction to conjunctive normal form (CNF)
    N)r   r   r   r   r   )r   r   Zr_firstZr_secondr   r   r   r      s    

r   )NN)Znltk.sem.logicr   r   r   r   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   <module>	   s   8
n