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

type ApplicationExpression

source code

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

This class is used to represent two related types of logical expressions.

The first is a Predicate Expression, such as "P(x,y)". A predicate expression is comprised of a FunctionVariableExpression or ConstantExpression as the predicate and a list of Expressions as the arguments.

The second is a an application of one expression to another, such as "(\x.dog(x))(fido)".

The reason Predicate Expressions are treated as Application Expressions is that the Variable Expression predicate of the expression may be replaced with another Expression, such as a LambdaExpression, which would mean that the Predicate should be thought of as being applied to the arguments.

The LogicParser will always curry arguments in a application expression. So, "\x y.see(x,y)(john,mary)" will be represented internally as "((\x y.(see(x))(y))(john))(mary)". This simplifies the internals since there will always be exactly one argument in an application.

The str() method will usually print the curried forms of application expressions. The one exception is when the the application expression is really a predicate expression (ie, underlying function is an AbstractVariableExpression). This means that the example from above will be returned as "(\x y.see(x,y)(john))(mary)".

Instance Methods [hide private]
 
__init__(self, function, argument) source code
 
simplify(self)
Returns: beta-converted version of this expression
source code
 
free(self, indvar_only=True)
Return a set of all the free (non-bound) variables in self.
source code
 
_get_type(self) source code
 
_set_type(self, other_type=?, signature=None)
@see Expression._set_type()
source code
 
findtype(self, variable)
@see Expression.findtype()
source code
 
visit(self, function, combinator, default)
Recursively visit sub expressions
source code
 
__eq__(self, other) source code
 
__str__(self) source code
 
uncurry(self)
Uncurry this application expression
source code
 
str(self, syntax=Tokens.NLTK)

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

Properties [hide private]
  type
  args
uncurried arg-list
Method Details [hide private]

__init__(self, function, argument)
(Constructor)

source code 
Parameters:
  • function - Expression, for the function expression
  • argument - Expression, for the argument
Overrides: object.__init__

simplify(self)

source code 
Returns:
beta-converted version of this expression
Overrides: Expression.simplify
(inherited documentation)

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()

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

source code 

@see Expression._set_type()

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

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

__str__(self)
(Informal representation operator)

source code 
Overrides: Expression.__str__

uncurry(self)

source code 

Uncurry this application expression

return: A tuple (base-function, arg-list)


Property Details [hide private]

type

Get Method:
_get_type(self)

args

uncurried arg-list