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

type VariableBinderExpression

source code

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

This an abstract class for any Expression that binds a variable in an Expression. This includes LambdaExpressions and Quantified Expressions

Instance Methods [hide private]
 
__init__(self, variable, term) source code
 
replace(self, variable, expression, replace_bound=False, alpha_convert=True)
Replace every instance of 'variable' with 'expression'
source code
 
alpha_convert(self, newvar)
Rename all occurrences of the variable introduced by this variable binder in the expression to @newvar.
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
 
findtype(self, variable)
@see Expression.findtype()
source code
 
visit(self, function, combinator, default)
Recursively visit sub expressions
source code
 
__eq__(self, other)
Defines equality modulo alphabetic variance.
source code

Inherited from Expression: __and__, __call__, __gt__, __hash__, __lt__, __neg__, __neq__, __or__, __repr__, __str__, applyto, equiv, make_VariableExpression, negate, normalize, simplify, substitute_bindings, tp_equals, typecheck

Inherited from Expression (private): _set_type

Method Details [hide private]

__init__(self, variable, term)
(Constructor)

source code 
Parameters:
  • variable - Variable, for the variable
  • term - Expression, for the term
Overrides: object.__init__

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?
Overrides: Expression.replace

See Also: Expression.replace()

alpha_convert(self, newvar)

source code 

Rename all occurrences of the variable introduced by this variable binder in the expression to @newvar.

Parameters:
  • newvar - Variable, for the new variable

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

See Also: Expression.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
Overrides: Expression.free

See Also: Expression.free()

findtype(self, variable)

source code 

@see Expression.findtype()

Parameters:
  • variable - Variable
Overrides: Expression.findtype

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
Overrides: Expression.visit

See Also: Expression.visit()

__eq__(self, other)
(Equality operator)

source code 

Defines equality modulo alphabetic variance. If we are comparing \x.M and \y.N, then check equality of M and N[x/y].

Overrides: Expression.__eq__