
    /hfc                        S r SSKrSSKrSSKrSSKrSSKJr  SSKJr  SSK	J
r
JrJrJrJrJrJrJrJrJrJrJrJrJrJrJr   " S S\5      r " S S	\5      rS
 rS rS rS r  " S S\!5      r"\RF                  " S5      r$\RF                  " S5      r%\RF                  " S\RL                  5      r'S r(S"S jr) " S S\!5      r* " S S5      r+Sr,S"S jr-S#S jr.S"S jr/S"S jr0S$S jr1\2S:X  a  \1" S SS!9  gg)%zK
This module provides data structures for representing first-order
models.
    Npformat)	decorator)AbstractVariableExpressionAllExpressionAndExpressionApplicationExpressionEqualityExpressionExistsExpression
ExpressionIffExpressionImpExpressionIndividualVariableExpressionIotaExpressionLambdaExpressionNegatedExpressionOrExpressionVariable	is_indvarc                       \ rS rSrSrg)Error,    N__name__
__module____qualname____firstlineno____static_attributes__r       I/var/www/auris/envauris/lib/python3.13/site-packages/nltk/sem/evaluate.pyr   r   ,       r    r   c                       \ rS rSrSrg)	Undefined0   r   Nr   r   r    r!   r$   r$   0   r"   r    r$   c                     [         R                  " U 5      n[        [        US   U5      5      nUR	                  SS 5      (       a/  [        5         UR                  5        H  n[        SU-  5        M     U " U0 UD6$ )Nr   tracez%s => %s)inspectgetfullargspecdictzippopprintitems)fargskwargspecditems         r!   r'   r'   4   sh    $$Q'GST"#AuuWdGGID*t#$ d>b>r    c                     [        U 5      S:X  a  g[        S U  5       5      (       a+  [        [        U 5      5      [        [        U 5      5      :X  a  g[	        SU -  5      e)z
Check whether a set represents a relation (of any arity).

:param s: a set containing tuples of str elements
:type s: set
:rtype: bool
r   Tc              3   B   #    U  H  n[        U[        5      v   M     g 7fN)
isinstancetuple).0els     r!   	<genexpr>is_rel.<locals>.<genexpr>J   s     /QrZE""Qs   z.Set %r contains sequences of different lengths)lenallmaxmin
ValueError)ss    r!   is_relrD   >   sN     1v{	/Q/	/	/CAK3s1v;4NIAMNNr    c                    [        5       nU  Hn  n[        U[        5      (       a  UR                  U45        M,  [        U[        5      (       a  UR                  [        U5      5        M]  UR                  U5        Mp     U$ )a.  
Convert a set containing individuals (strings or numbers) into a set of
unary tuples. Any tuples of strings already in the set are passed through
unchanged.

For example:
  - set(['a', 'b']) => set([('a',), ('b',)])
  - set([3, 27]) => set([('3',), ('27',)])

:type s: set
:rtype: set of tuple of str
)setr8   straddint)rC   newelems      r!   set2relrL   P   s_     %CdC  GGTGc""GGCIGGDM  Jr    c                 P    [        U 5      S:X  a  g[        [        U 5      S   5      $ )zU
Check the arity of a relation.
:type rel: set of tuples
:rtype: int of tuple of str
r   )r>   list)rels    r!   arityrP   h   s%     3x1}tCy|r    c                   h   ^  \ rS rSrSrU 4S jrS rS r\S 5       r	\S 5       r
\S 5       rS	rU =r$ )
	Valuations   a  
A dictionary which represents a model-theoretic Valuation of non-logical constants.
Keys are strings representing the constants to be interpreted, and values correspond
to individuals (represented as strings) and n-ary relations (represented as sets of tuples
of strings).

An instance of ``Valuation`` will raise a KeyError exception (i.e.,
just behave like a standard  dictionary) if indexed with an expression that
is not in its list of symbols.
c                 ,  > [         TU ]  5         U H  u  p#[        U[        5      (       d  [        U[        5      (       a  X0U'   M5  [        U[
        5      (       a  [        U5      X'   MY  [        R                  " SU< SU< 3SS9n[        U5      e   g)z-
:param xs: a list of (symbol, value) pairs.
z@Error in initializing Valuation. Unrecognized value for symbol 'z':
B   )widthN)
super__init__r8   rG   boolrF   rL   textwrapfillrB   )selfxssymvalmsg	__class__s        r!   rX   Valuation.__init__   s|     	HC#s##z#t'<'<S	C%%#CL	mmADcK !o% r    c                 R    X;   a  [         R                  X5      $ [        SU-  5      e)NzUnknown expression: '%s'r*   __getitem__r$   r\   keys     r!   re   Valuation.__getitem__   s)    ;##D..6<==r    c                     [        U 5      $ r7   r   r\   s    r!   __str__Valuation.__str__   s    t}r    c           	      6   / nU R                  5        Hs  n[        U[        5      (       a  UR                  U5        M+  [        U[        5      (       a  MB  UR                  U VVs/ s H  o3  H	  oDc  M  UPM     M     snn5        Mu     [        U5      $ s  snnf )z7Set-theoretic domain of the value-space of a Valuation.)valuesr8   rG   appendrY   extendrF   )r\   domr_   tuple_rK   s        r!   domainValuation.domain   su     ;;=C#s##

3T**

(+SfTTS	 ! 3x Ts   %B4
Bc                 4    [        U R                  5       5      $ )z9The non-logical constants which the Valuation recognizes.)sortedkeysrj   s    r!   symbolsValuation.symbols   s     diik""r    c                     [        U5      $ r7   )read_valuation)clsrC   s     r!   
fromstringValuation.fromstring   s    a  r    r   )r   r   r   r   __doc__rX   re   rk   propertyrs   rx   classmethodr}   r   __classcell__ra   s   @r!   rR   rR   s   sS    	&&> 
 
 # # ! !r    rR   z	\s*=+>\s*z\s*,\s*zg\s*
                                (\([^)]+\))  # tuple-expression
                                \s*c                 t   [         R                  U 5      nUS   nUS   nUR                  S5      (       a  USS n[        R	                  U5      nU(       a@  / nU H7  nUSS n[        [        R                  U5      5      nUR                  U5        M9     O[        R                  U5      n[        U5      nX#4$ )z
Read a line in a valuation file.

Lines are expected to be of the form::

  noosa => n
  girl => {g1, g2}
  chase => {(b1, g1), (b2, g1), (g1, d1), (g2, d2)}

:param s: input line
:type s: str
:return: a pair (symbol, value)
:rtype: tuple
r      {)	_VAL_SPLIT_REsplit
startswith
_TUPLES_REfindallr9   _ELEMENT_SPLIT_REro   rF   )rC   piecessymbolvaluetuple_stringsset_elementstselements           r!   _read_valuation_liner      s       #FAYF1IEa"**51L#"X 1 7 7 ;<##G, $
 -2259LL!=r    c                 b   Ub  U R                  U5      n / n[        U R                  5       5       HN  u  p4UR                  5       nUR	                  S5      (       d  US:X  a  M3   UR                  [        U5      5        MP     [        U5      $ ! [         a  n[        SU SU 35      UeSnAff = f)z
Convert a valuation string into a valuation.

:param s: a valuation string
:type s: str
:param encoding: the encoding of the input string, if it is binary
:type encoding: str
:return: a ``nltk.sem`` valuation
:rtype: Valuation
N# zUnable to parse line z: )	decode	enumerate
splitlinesstripr   ro   r   rB   rR   )rC   encoding
statementslinenumlinees         r!   r{   r{      s     HHXJ"1<<>2zz|??342:	O2489 3 Z    	O4WIRvFGQN	Os   $B
B.B))B.c                   X   ^  \ rS rSrSrSU 4S jjrS rS rSS jrS r	S r
S	 rS
rU =r$ )
Assignment   a  
A dictionary which represents an assignment of values to variables.

An assignment can only assign values from its domain.

If an unknown expression *a* is passed to a model *M*\ 's
interpretation function *i*, *i* will first check whether *M*\ 's
valuation assigns an interpretation to *a* as a constant, and if
this fails, *i* will delegate the interpretation of *a* to
*g*. *g* only assigns values to individual variables (i.e.,
members of the class ``IndividualVariableExpression`` in the ``logic``
module. If a variable is not assigned a value by *g*, it will raise
an ``Undefined`` exception.

A variable *Assignment* is a mapping from individual variables to
entities in the domain. Individual variables are usually indicated
with the letters ``'x'``, ``'y'``, ``'w'`` and ``'z'``, optionally
followed by an integer (e.g., ``'x0'``, ``'y332'``).  Assignments are
created using the ``Assignment`` constructor, which also takes the
domain as a parameter.

    >>> from nltk.sem.evaluate import Assignment
    >>> dom = set(['u1', 'u2', 'u3', 'u4'])
    >>> g3 = Assignment(dom, [('x', 'u1'), ('y', 'u2')])
    >>> g3 == {'x': 'u1', 'y': 'u2'}
    True

There is also a ``print`` format for assignments which uses a notation
closer to that in logic textbooks:

    >>> print(g3)
    g[u1/x][u2/y]

It is also possible to update an assignment using the ``add`` method:

    >>> dom = set(['u1', 'u2', 'u3', 'u4'])
    >>> g4 = Assignment(dom)
    >>> g4.add('x', 'u1')
    {'x': 'u1'}

With no arguments, ``purge()`` is equivalent to ``clear()`` on a dictionary:

    >>> g4.purge()
    >>> g4
    {}

:param domain: the domain of discourse
:type domain: set
:param assign: a list of (varname, value) associations
:type assign: list
c                   > [         TU ]  5         Xl        U(       aY  U HS  u  p4X@R                  ;   d!   SR                  UU R                  5      5       e[	        U5      (       d
   SU-  5       eX@U'   MU     S U l        U R                  5         g )Nz'{}' is not in the domain: {}-Wrong format for an Individual Variable: '%s')rW   rX   rs   formatr   variant_addvariant)r\   rs   assignvarr_   ra   s        r!   rX   Assignment.__init__0  s    "kk) +J+Q+QKK, ) !~~ CcI~  S	 # r    c                 R    X;   a  [         R                  X5      $ [        SU-  5      e)Nz"Not recognized as a variable: '%s'rd   rf   s     r!   re   Assignment.__getitem__@  s)    ;##D..@3FGGr    c                 R    [        U R                  5      nUR                  U 5        U$ r7   )r   rs   update)r\   rJ   s     r!   copyAssignment.copyF  s!    %

4
r    c                 X    U(       a  X	 OU R                  5         U R                  5         g)z
Remove one or all keys (i.e. logic variables) from an
assignment, and update ``self.variant``.

:param var: a Variable acting as a key for the assignment.
N)clearr   )r\   r   s     r!   purgeAssignment.purgeK  s$     	JJLr    c                 b    Sn[        U R                  5      nU H  u  p4USU SU S3-  nM     U$ )zA
Pretty printing for assignments. {'x', 'u'} appears as 'g[u/x]'
g[/])rv   r   )r\   gstringr   r_   r   s        r!   rk   Assignment.__str__Y  sA     &HC3%qQ''G  r    c                 x    / nU R                  5        H  nUS   US   4nUR                  U5        M      Xl        g)z;
Create a more pretty-printable version of the assignment.
r   r   N)r.   ro   r   )r\   list_r4   pairs       r!   r   Assignment._addvariantd  sA     JJLDGT!W%DLL ! r    c                     X R                   ;   d   U SU R                    35       e[        U5      (       d
   SU-  5       eX U'   U R                  5         U $ )zP
Add a new variable-value pair to the assignment, and update
``self.variant``.

z is not in the domain r   )rs   r   r   )r\   r   r_   s      r!   rH   Assignment.addo  s[     kk!NcU*@#NN!~~TNQTTT~S	r    )rs   r   r7   )r   r   r   r   r   rX   re   r   r   rk   r   rH   r   r   r   s   @r!   r   r      s2    2h H
		
 
r    r   c                   R    \ rS rSrSrS rS rS rSS jrSS jr	SS	 jr
SS
 jrSrg)Modeli|  a/  
A first order model is a domain *D* of discourse and a valuation *V*.

A domain *D* is a set, and a valuation *V* is a map that associates
expressions with values in the model.
The domain of *V* should be a subset of *D*.

Construct a new ``Model``.

:type domain: set
:param domain: A set of entities representing the domain of discourse of the model.
:type valuation: Valuation
:param valuation: the valuation of the model.
:param prop: If this is set, then we are building a propositional    model and don't require the domain of *V* to be subset of *D*.
c                     [        U[        5      (       d   eXl        X l        UR	                  UR                  5      (       d  [        SUR                  < SU< 35      eg )NzThe valuation domain, z*, must be a subset of the model's domain, )r8   rF   rs   	valuation
issupersetr   )r\   rs   r   s      r!   rX   Model.__init__  sX    &#&&&&"  !1!122##V-  3r    c                 @    SU R                   < SU R                  < S3$ )N(z, )rs   r   rj   s    r!   __repr__Model.__repr__  s     4;;/DNN#5Q77r    c                 :    SU R                    SU R                   3$ )Nz	Domain = z,
Valuation = 
r   rj   s    r!   rk   Model.__str__  s    4;;-'88HIIr    Nc                     [         R                  " U5      nU R                  XBUS9nU(       a  [        5         [        SU SU SU 35        U$ ! [         a%    U(       a  [        5         [        SU SU 35         gf = f)a	  
Read input expressions, and provide a handler for ``satisfy``
that blocks further propagation of the ``Undefined`` error.
:param expr: An ``Expression`` of ``logic``.
:type g: Assignment
:param g: an assignment to individual variables.
:rtype: bool or 'Undefined'
r'   'z' evaluates to z
 under M, z' is undefined under M, r$   )r   r}   satisfyr-   r$   )r\   exprr   r'   parsedr   s         r!   evaluateModel.evaluate  s    	**40FLL%L8E$ugZsCDL 	$7s;<		s   AA ,A>=A>c                 	  ^ ^ [        U[        5      (       a  UR                  5       u  pE[        U[        5      (       a,  T R	                  UT5      n[        UU 4S jU 5       5      nXv;   $ T R	                  UR                  T5      nT R	                  UR                  T5      nXh   $ [        U[        5      (       a!  T R	                  UR                  T5      (       + $ [        U[        5      (       a?  T R	                  UR                  T5      =(       a    T R	                  UR                  T5      $ [        U[        5      (       a?  T R	                  UR                  T5      =(       d    T R	                  UR                  T5      $ [        U[        5      (       aD  T R	                  UR                  T5      (       + =(       d    T R	                  UR                  T5      $ [        U[        5      (       a9  T R	                  UR                  T5      T R	                  UR                  T5      :H  $ [        U[         5      (       a9  T R	                  UR                  T5      T R	                  UR                  T5      :H  $ [        U["        5      (       am  TR%                  5       n	T R&                   HL  n
U	R)                  UR*                  R,                  U
5        T R	                  UR                  U	5      (       a  ML    g   g[        U[.        5      (       am  TR%                  5       n	T R&                   HL  n
U	R)                  UR*                  R,                  U
5        T R	                  UR                  U	5      (       d  ML    g   g[        U[0        5      (       am  TR%                  5       n	T R&                   HL  n
U	R)                  UR*                  R,                  U
5        T R	                  UR                  U	5      (       d  ML    g   g[        U[2        5      (       a\  0 nUR*                  R,                  nT R&                   H2  n
T R	                  UR                  TR)                  X5      5      nXU
'   M4     U$ T R5                  UTU5      $ )a  
Recursive interpretation function for a formula of first-order logic.

Raises an ``Undefined`` error when ``parsed`` is an atomic string
but is not a symbol or an individual variable.

:return: Returns a truth value or ``Undefined`` if ``parsed`` is        complex, and calls the interpretation function ``i`` if ``parsed``        is atomic.

:param parsed: An expression of ``logic``.
:type g: Assignment
:param g: an assignment to individual variables.
c              3   H   >#    U  H  nTR                  UT5      v   M     g 7fr7   )r   )r:   argr   r\   s     r!   r<    Model.satisfy.<locals>.<genexpr>  s     J	S! 4 4	s   "FT)r8   r	   uncurryr   r   r9   functionargumentr   termr   firstsecondr   r   r   r
   r   r   rs   rH   variablenamer   r   r   i)r\   r   r   r'   r   	argumentsfunvalargvalsargvalnew_gucfr   r_   s   ` `           r!   r   Model.satisfy  sI     f344"(.."2H($>??h2J	JJ(( fooq9fooq9~% 122||FKK333..<<a0ST\\&--QR5SS--<<a0RDLLPQ4RR..V\\155X$,,v}}VW:XX..<<a0DLLPQ4RRR 233<<a0DLLPQ4RRR..FFHE[[		&//..2||FKK77  !  011FFHE[[		&//..2<<U33 ! //FFHE[[		&//..2<<U33 !  011B//&&C[[ll6;;c>
 1 ! I66&!U++r    c                    UR                   R                  U R                  R                  ;   a#  U R                  UR                   R                     $ [	        U[
        5      (       a  X!R                   R                     $ [        SU-  5      e)ax  
An interpretation function.

Assuming that ``parsed`` is atomic:

- if ``parsed`` is a non-logical constant, calls the valuation *V*
- else if ``parsed`` is an individual variable, calls assignment *g*
- else returns ``Undefined``.

:param parsed: an ``Expression`` of ``logic``.
:type g: Assignment
:param g: an assignment to individual variables.
:return: a semantic value
zCan't find a value for %s)r   r   r   rx   r8   r   r$   )r\   r   r   r'   s       r!   r   Model.i   sm    $ ??4>>#9#99>>&//"6"677 <==__))** 7&@AAr    c           
         SnXfU-  -   n/ n[        U[        5      (       a  [        U5      n	OUn	XR                  5       ;   Ga  U(       a   [	        5         [	        Xe-  SU SU 3-   5        U R
                   H  n
UR                  5       nUR                  U	R                  U
5        U(       a  US:  a  US-
  nOSnU R                  XU5      nU(       a  [	        USU-  -   5        US:X  a   U(       a  [	        USU S	U S
3-   5        M  M  UR                  U
5        U(       d  M  [	        USU S	U SU 3-   5        M     U Vs1 s H  oiM     nnU$ [        U	R                   SU 35      es  snf )a]  
Generate the entities from the model's domain that satisfy an open formula.

:param parsed: an open formula
:type parsed: Expression
:param varex: the relevant free individual variable in ``parsed``.
:type varex: VariableExpression or str
:param g: a variable assignment
:type g:  Assignment
:return: a set of the entities that satisfy ``parsed``.
z   zOpen formula is 'z' with assignment r   r   z(trying assignment %s)Fz
value of 'z' under z	 is Falsez is z is not free in )r8   rG   r   freer-   rs   r   rH   r   r   ro   r$   )r\   r   varexr   r'   nestingspacerindent
candidatesr   r   r   lowtracer   cresults                   r!   
satisfiersModel.satisfiers  sz    G+,
eS!!5/CC++-%)&1CA3GH [[		#((A&UQY$qyH HVH=&#;e#CCD E>fF88E7)'TTU 
 %%a(ufF88E7$ug'VVW+ !. ",,AaF,
  sxxj(8ABB -s   E,r   r7   )F)Nr   )r   r   r   r   r   rX   r   rk   r   r   r   r   r   r   r    r!   r   r   |  s.    "8J,I,XB49r    r      c           
          [        / SQ5      q[        5       q[	        [        [        5      q[        [        5      q[        5         [        S[        -  5        [        S5        [        S[        -  5        [        S5        [        5         [        S[
        5        [        S[        -  5        / SQnU HZ  nU (       a'  [        5         [
        R                  U[        U 5        M1  [        SU S[
        R                  U[        5       35        M\     g	)
z!Example of a propositional model.))PT)QT)RF*zPropositional Formulas Demoz7(Propositional constants treated as nullary predicates)z
Model m1:
)z(P & Q)z(P & R)z- Pz- Rz- - Pz	- (P & R)z(P | R)z(R | P)z(R | R)z	(- P | R)z	(P | - P)z(P -> Q)z(P -> R)z(R -> P)z	(P <-> P)z	(R <-> R)z	(P <-> R)The value of '' is: N)rR   val1rF   dom1r   m1r   g1r-   multr   )r'   	sentencessents      r!   propdemor  _  s     =>D5D	tT	B	D	B	G	#*	
'(	#*	
CD	G	-	#*I( GKKb%(N4&r{{4/D.EFG r    c           
         SSSSSS14SSS	14S
S14S1 Sk4/q [        [         5      q[        R                  q[        [        [        5      q[        [        SS/5      qU (       Gd*  [        5         [        S[        -  5        [        S5        [        S[        -  5        [        SSS[        5        [        S[        5        / SQnU Vs/ s H  n[        R                  " U5      PM     nn[        5         U H/  n [        SU< S[        R                  U[        5      < 35        M1     / SQnU H[  u  px [        R                  [        R                  " U5      [        5      n	[        S U 5       5      n
[        U SU SX;    35        M]     ggs  snf ! [         a    [        SU-  5         M  f = f! [         a    [        U SU S35         M  f = f) zExample of a first-order model.)adamb1)bettyr  )fidod1girlr  g2boyr  b2dogr  love>   r  r  r  r  r  r  r  r  )xr  )yr  r  zModels Demoz
Model m2:
z--------------
zVariable assignment = )r  r  r  walksr  r  zzThe interpretation of 'z' in m2 is z-The interpretation of '%s' in m2 is Undefined))r  r  )r   )r  )r  )r  r  )r  )r  r  c              3   ~   #    U  H3  n[         R                  [        R                  " U5      [        5      v   M5     g 7fr7   )m2r   r   r}   r  )r:   r   s     r!   r<   folmodel.<locals>.<genexpr>  s+     UPTZ%:%:3%? D DPTs   ;=r   z) evaluates to z) evaluates to UndefinedN)v2rR   val2rs   dom2r   r#  r   r  r-   r	  r   r}   r   r$   r9   )quietr'   exprsr   parsed_exprsr   applicationsfunr0   r   argsvals              r!   folmodelr.    s    		$	t		IJ
B R=D;;D	tT	B	D;4	5BcDjmcDjmXtR0&+?:?@%Q
--a0%@"FPrttFB/1 #
 &IC?j33C8"=UPTUUQtfOG4E3FGH	 &9  A  PENOP  ?Qtf$<=>?s+   	 F;+F6AF5F21F25GGc           
      d   [        SS9  [        5         [        S[        -  5        [        S5        [        S[        -  5        / SQnU Hd  n[        R	                  5         U (       a  [
        R                  U[        U 5        M;  [        SU S[
        R                  U[        5       35        Mf     g)	z>
Interpretation of closed expressions in a first-order model.
Tr(  r  zFOL Formulas Demo)zlove (adam, betty)z(adam = mia)z\x. (boy(x) | girl(x))z\x. boy(x)(adam)z\x y. love(x, y)z\x y. love(x, y)(adam)(betty)z\x y. love(x, y)(adam, betty)z\x y. (boy(x) & love(x, y))z#\x. exists y. (boy(x) & love(x, y))zexists z1. boy(z1)z!exists x. (boy(x) &  -(x = adam))z&exists x. (boy(x) & all y. love(y, x))zall x. (boy(x) | girl(x))z1all x. (girl(x) -> exists y. boy(y) & love(x, y))z3exists x. (boy(x) & all y. (girl(y) -> love(y, x)))z3exists x. (boy(x) & all y. (girl(y) -> love(x, y)))zall x. (dog(x) -> - girl(x))z-exists x. exists y. (love(x, y) & love(x, y))r  r  N)r.  r-   r	  r  r   r#  r   )r'   formulasfmlas      r!   foldemor3    s     4	G	#*	
	#*H* 

KKb%(N4&r{{4/D.EFG r    c                 
   [        5         [        S[        -  5        [        S5        [        S[        -  5        [        SS9  / SQnU (       a  [        [        5        U H$  n[        U5        [        R
                  " U5        M&     U Vs/ s H  n[        R
                  " U5      PM     nnU HL  n[        R                  5         [        SR                  U[        R                  US[        U 5      5      5        MN     gs  snf )	z5Satisfiers of an open formula in a first order model.r  zSatisfiers DemoTr0  )zboy(x)z(x = x)z(boy(x) | girl(x))z(boy(x) & girl(x))zlove(adam, x)zlove(x, adam)z-(x = adam)zexists z22. love(x, z22)exists y. love(y, x)zall y. (girl(y) -> love(x, y))zall y. (girl(y) -> love(y, x))z)all y. (girl(y) -> (boy(x) & love(y, x)))z)(boy(x) & all y. (girl(y) -> love(x, y)))z)(boy(x) & all y. (girl(y) -> love(y, x)))z+(boy(x) & exists y. (girl(y) & love(y, x)))z(girl(x) -> dog(x))zall y. (dog(y) -> (x = y))r5  z&exists y. (love(adam, y) & love(y, x))zThe satisfiers of '{}' are: {}r  N)
r-   r	  r.  r#  r   r}   r  r   r   r   )r'   r1  r2  r   ps        r!   satdemor7    s     
G	#*	
	#*4H, b	dd#  7??hdj##D)hF?

,33Ar}}QRQV7WX	
  @s    D c                     [         [        [        [        S.n X    " US9  g! [         a    U H  n X    " US9  M      gf = f)a/  
Run exists demos.

 - num = 1: propositional logic demo
 - num = 2: first order model demo (only if trace is set)
 - num = 3: first order sentences demo
 - num = 4: satisfaction of open formulas demo
 - any other value: run all the demos

:param trace: trace = 1, or trace = 2 for more verbose tracing
)r            r   N)r  r.  r3  r7  KeyError)numr'   demoss      r!   demor?  (  sD     X'g>E$
 $CJU# $s   " A A __main__r9  r   r7   )FN)r   N)3r   r(   resysrZ   pprintr   nltk.decoratorsr   nltk.sem.logicr   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   	Exceptionr   r$   r'   rD   rL   rP   r*   rR   compiler   r   VERBOSEr   r   r{   r   r   r	  r  r.  r3  r7  r?  r   r   r    r!   <module>rI     s  
  	 
   %    (	I 		 	O$0<! <!D 

<(JJz* ZZ' JJ	
 F!2~ ~BW W| 

*Hb5?x%HX-
`$* z! r    