Package nltk :: Package sem :: Module logic :: Class Expression
[hide private]
[frames] | no frames]

type Expression

source code

         object --+    
                  |    
SubstituteBindingsI --+
                      |
                     Expression
Known Subclasses:

This is the base abstract object for all logical expressions

Instance Methods [hide private]
 
__call__(self, other, *additional) source code
 
applyto(self, other) source code
 
__neg__(self) source code
 
negate(self)
If this is a negated expression, remove the negation.
source code
 
__and__(self, other) source code
 
__or__(self, other) source code
 
__gt__(self, other) source code
 
__lt__(self, other) source code
 
__eq__(self, other) source code
 
__neq__(self, other) source code
 
equiv(self, other, prover=None)
Check for logical equivalence.
source code
 
__hash__(self) source code
(any)
substitute_bindings(self, bindings)
Returns: The object that is obtained by replacing each variable bound by bindings with its values.
source code
 
typecheck(self, signature=None)
Infer and check types.
source code
 
findtype(self, variable)
Find the type of the given variable as it is used in this expression.
source code
 
_set_type(self, other_type=?, signature=None)
Set the type of this expression to be the given type.
source code
 
replace(self, variable, expression, replace_bound=False, alpha_convert=True)
Replace every instance of 'variable' with 'expression'
source code
 
normalize(self)
Rename auto-generated unique variables
source code
 
visit(self, function, combinator, default)
Recursively visit sub expressions
source code
 
__repr__(self) source code
 
__str__(self) source code
 
variables(self)
Return a set of all the variables that are available to be replaced.
source code
 
free(self, indvar_only=True)
Return a set of all the free (non-bound) variables in self.
source code
 
simplify(self)
Returns: beta-converted version of this expression
source code
 
make_VariableExpression(self, variable) source code
 
tp_equals(self, other, prover=None)
Pass the expression (self <-> other) to the theorem prover.
Method Details [hide private]

negate(self)

source code 

If this is a negated expression, remove the negation. Otherwise add a negation.

equiv(self, other, prover=None)

source code 

Check for logical equivalence. Pass the expression (self <-> other) to the theorem prover. If the prover says it is valid, then the self and other are equal.

Parameters:
  • other - an Expression to check equality against
  • prover - a nltk.inference.api.Prover

__hash__(self)
(Hashing function)

source code 
Overrides: object.__hash__
(inherited documentation)

substitute_bindings(self, bindings)

source code 
Returns: (any)
The object that is obtained by replacing each variable bound by bindings with its values. Aliases are already resolved. (maybe?)
Overrides: SubstituteBindingsI.substitute_bindings
(inherited documentation)

typecheck(self, signature=None)

source code 

Infer and check types. Raise exceptions if necessary.

Parameters:
  • signature - dict that maps variable names to types (or string representations of types)
Returns:
the signature, plus any additional type mappings

findtype(self, variable)

source code 

Find the type of the given variable as it is used in this expression. For example, finding the type of "P" in "P(x) & Q(x,y)" yields "<e,t>"

Parameters:
  • variable - Variable

_set_type(self, other_type=?, signature=None)

source code 

Set the type of this expression to be the given type. Raise type exceptions where applicable.

Parameters:
  • other_type - Type to set
  • signature - dict<str, list<AbstractVariableExpression>> store all variable expressions with a given name

replace(self, variable, expression, replace_bound=False, alpha_convert=True)

source code 

Replace every instance of 'variable' with 'expression'

Parameters:
  • variable - Variable The variable to replace
  • expression - Expression The expression with which to replace it
  • replace_bound - boolean Should bound variables be replaced?

visit(self, function, combinator, default)

source code 

Recursively visit sub expressions

Parameters:
  • function - Function to call on each sub expression
  • combinator - Function to combine the results of the function calls
Returns:
result of combination

__repr__(self)
(Representation operator)

source code 
Overrides: object.__repr__
(inherited documentation)

__str__(self)
(Informal representation operator)

source code 
Overrides: object.__str__
(inherited documentation)

variables(self)

source code 

Return a set of all the variables that are available to be replaced. This includes free (non-bound) variables as well as predicates.

Returns:
set of Variables
Overrides: SubstituteBindingsI.variables

free(self, indvar_only=True)

source code 

Return a set of all the free (non-bound) variables in self. Variables serving as predicates are not included.

Parameters:
  • indvar_only - boolean only return individual variables?
Returns:
set of Variables

simplify(self)

source code 
Returns:
beta-converted version of this expression

tp_equals(self, other, prover=None)

 

Pass the expression (self <-> other) to the theorem prover. If the prover says it is valid, then the self and other are equal.

Parameters:
  • other - an Expression to check equality against
  • prover - a nltk.inference.api.Prover