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

Module logic

source code

A version of first order predicate logic, built on top of the typed lambda calculus.

Classes [hide private]
Tokens
Variable
Type
ComplexType
BasicType
EntityType
TruthValueType
EventType
AnyType
TypeException
InconsistentTypeHierarchyException
TypeResolutionException
IllegalTypeException
SubstituteBindingsI
An interface for classes that can perform substitutions for variables.
Expression
This is the base abstract object for all logical expressions
ApplicationExpression
This class is used to represent two related types of logical expressions.
AbstractVariableExpression
This class represents a variable to be used as a predicate or entity
IndividualVariableExpression
This class represents variables that take the form of a single lowercase character (other than 'e') followed by zero or more digits.
FunctionVariableExpression
This class represents variables that take the form of a single uppercase character followed by zero or more digits.
EventVariableExpression
This class represents variables that take the form of a single lowercase 'e' character followed by zero or more digits.
ConstantExpression
This class represents variables that do not take the form of a single character followed by zero or more digits.
VariableBinderExpression
This an abstract class for any Expression that binds a variable in an Expression.
LambdaExpression
QuantifiedExpression
ExistsExpression
AllExpression
NegatedExpression
BinaryExpression
BooleanExpression
AndExpression
This class represents conjunctions
OrExpression
This class represents disjunctions
ImpExpression
This class represents implications
IffExpression
This class represents biconditionals
EqualityExpression
This class represents equality expressions like "(x = y)".
LogicParser
A lambda calculus expression parser.
StringTrie
ParseException
UnexpectedTokenException
ExpectedMoreTokensException
Functions [hide private]
 
boolean_ops()
Boolean operators
source code
 
equality_preds()
Equality predicates
source code
 
binding_ops()
Binding operators
source code
 
unique_variable(pattern=None, ignore=None)
Return a new, unique variable.
source code
 
skolem_function(univ_scope=None)
Return a skolem function over the variables in univ_scope param univ_scope
source code
 
parse_type(type_string) source code
 
typecheck(expressions, signature=None)
Ensure correct typing across a collection of Expressions.
source code
 
VariableExpression(variable)
This is a factory method that instantiates and returns a subtype of AbstractVariableExpression appropriate for the given variable.
source code
 
is_indvar(expr)
An individual variable must be a single lowercase character other than 'e', followed by zero or more digits.
source code
 
is_funcvar(expr)
A function variable must be a single uppercase character followed by zero or more digits.
source code
 
is_eventvar(expr)
An event variable must be a single lowercase 'e' character followed by zero or more digits.
source code
 
demo() source code
 
demo_errors() source code
 
demoException(s) source code
 
printtype(ex) source code
Variables [hide private]
  APP = 'APP'
  _counter = Counter()
  TRUTH_TYPE = t
  ENTITY_TYPE = e
  EVENT_TYPE = v
  ANY_TYPE = ?
Function Details [hide private]

unique_variable(pattern=None, ignore=None)

source code 

Return a new, unique variable. param pattern: Variable that is being replaced. The new variable must be the same type. param term: a set of Variables that should not be returned from this function. return: Variable

typecheck(expressions, signature=None)

source code 

Ensure correct typing across a collection of Expressions.

Parameters:
  • expressions - a collection of expressions
  • signature - dict that maps variable names to types (or string representations of types)

is_indvar(expr)

source code 

An individual variable must be a single lowercase character other than 'e', followed by zero or more digits.

Parameters:
  • expr - str
Returns:
boolean True if expr is of the correct form

is_funcvar(expr)

source code 

A function variable must be a single uppercase character followed by zero or more digits.

Parameters:
  • expr - str
Returns:
boolean True if expr is of the correct form

is_eventvar(expr)

source code 

An event variable must be a single lowercase 'e' character followed by zero or more digits.

Parameters:
  • expr - str
Returns:
boolean True if expr is of the correct form