neurolang.expressions#

Expressions for the intermediate representation and auxiliary functions.

Functions

expressions_behave_as_objects()

infer_type(value[, deep])

op_bind(op)

rop_bind(op)

sure_is_not_pattern()

sure_is_not_pattern_()

type_validation_value(value, type_)

Classes

Command(name, args, kwargs)

Constant(value[, auto_infer_type, verify_type])

Definition(*args, **kwargs)

Parent class for all composite operations.

Expression(*args, **kwargs)

ExpressionBlock(expressions)

ExpressionMeta(*args, **kwargs)

Metaclass for expressions.

FunctionApplication(functor, args[, kwargs, ...])

Lambda(args, function_expression)

NonConstant(*args, **kwargs)

Any expression which is not a constant.

ParametricTypeClassMeta(name, bases, ...)

Projection(collection, item[, ...])

Query(head, body)

Statement(lhs, rhs)

Symbol(name)

Symbol of a certain type.

TypedSymbolTableMixin([symbol_table])

Add capabilities to deal with a symbol table.

c

class neurolang.expressions.FunctionApplication(functor, args, kwargs=None, validate_arguments=False, verify_type=True)#
classmethod apply(*args)#

Builds a new expression using a tuple of its parameters

property type#

Get the expression’s type.

For parameterized classes (e.g., FunctionApplication[bool]), the type is stored as a class attribute under _nl_class_type. For non-parameterized classes, it is stored as an instance attribute under _type, defaulting to Unknown. Class-level access (e.g., PM.type for a class PM that inherits from PatternMatcher[int]) also works by reading _nl_class_type from the class hierarchy.

This property avoids instance-attribute shadowing: calling self.type = X in __init__ stores via the setter under _type, and change_type (which changes __class__ to a parameterized class) makes the type available from the class attribute — no need to pop anything from __dict__.

unapply()#

Returns a tuple of parameters used to build the expression.

class neurolang.expressions.Projection(collection, item, auto_infer_projection_type=True)#
classmethod apply(*args)#

Builds a new expression using a tuple of its parameters

property type#

Get the expression’s type.

For parameterized classes (e.g., FunctionApplication[bool]), the type is stored as a class attribute under _nl_class_type. For non-parameterized classes, it is stored as an instance attribute under _type, defaulting to Unknown. Class-level access (e.g., PM.type for a class PM that inherits from PatternMatcher[int]) also works by reading _nl_class_type from the class hierarchy.

This property avoids instance-attribute shadowing: calling self.type = X in __init__ stores via the setter under _type, and change_type (which changes __class__ to a parameterized class) makes the type available from the class attribute — no need to pop anything from __dict__.

unapply()#

Returns a tuple of parameters used to build the expression.

class neurolang.expressions.Statement(lhs, rhs)#
classmethod apply(*args)#

Builds a new expression using a tuple of its parameters

property type#

Get the expression’s type.

For parameterized classes (e.g., FunctionApplication[bool]), the type is stored as a class attribute under _nl_class_type. For non-parameterized classes, it is stored as an instance attribute under _type, defaulting to Unknown. Class-level access (e.g., PM.type for a class PM that inherits from PatternMatcher[int]) also works by reading _nl_class_type from the class hierarchy.

This property avoids instance-attribute shadowing: calling self.type = X in __init__ stores via the setter under _type, and change_type (which changes __class__ to a parameterized class) makes the type available from the class attribute — no need to pop anything from __dict__.

unapply()#

Returns a tuple of parameters used to build the expression.

class neurolang.expressions.Symbol(name)#

Symbol of a certain type.

classmethod apply(*args)#

Builds a new expression using a tuple of its parameters

property type#

Get the expression’s type.

For parameterized classes (e.g., FunctionApplication[bool]), the type is stored as a class attribute under _nl_class_type. For non-parameterized classes, it is stored as an instance attribute under _type, defaulting to Unknown. Class-level access (e.g., PM.type for a class PM that inherits from PatternMatcher[int]) also works by reading _nl_class_type from the class hierarchy.

This property avoids instance-attribute shadowing: calling self.type = X in __init__ stores via the setter under _type, and change_type (which changes __class__ to a parameterized class) makes the type available from the class attribute — no need to pop anything from __dict__.

unapply()#

Returns a tuple of parameters used to build the expression.

class neurolang.expressions.TypedSymbolTable(enclosing_scope=None, readonly=False)#
clear() → None.  Remove all items from D.#
get(k[, d]) → D[k] if k in D, else d.  d defaults to None.#
items() → a set-like object providing a view on D's items#
keys() → a set-like object providing a view on D's keys#
pop(k[, d]) → v, remove specified key and return the corresponding value.#

If key is not found, d is returned if given, otherwise KeyError is raised.

popitem() → (k, v), remove and return some (key, value) pair#

as a 2-tuple; but raise KeyError if D is empty.

setdefault(k[, d]) → D.get(k,d), also set D[k]=d if k not in D#
update([E, ]**F) → None.  Update D from mapping/iterable E and F.#

If E present and has a .keys() method, does: for k in E.keys(): D[k] = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: for k, v in F.items(): D[k] = v

values() → an object providing a view on D's values#
class neurolang.expressions.TypedSymbolTableMixin(symbol_table=None)#

Add capabilities to deal with a symbol table.

class neurolang.expressions.Unknown#

Special type indicating an unknown type.

  • Unknown is compatible with every type.

  • Unknown is less informative than all types.