neurolang.frontend.query_resolution_expressions module

Query Resolution Expression

Declares FrontEnd Expression class and subclasses. Those classes are used to build Datalog programs in an ergonomic manner, and attention is paid to their representation

class neurolang.frontend.query_resolution_expressions.All(query_builder: QueryBuilderBase, expression: Expression, symbol: Symbol, predicate: Expression)

Bases: Expression

Corresponds to the logical ∀ ∀x: x == x enunciates a truth

Attributes:
type

Returns expression’s type

Methods

__call__(*args, **kwargs)

Returns a FunctionApplication expression, applied to the *args cast as Constant if not Symbol or Expression **kwargs are ignored

help()

Returns help based on Expression's subclass

do

class neurolang.frontend.query_resolution_expressions.Exists(query_builder: QueryBuilderBase, expression: Expression, symbol: Symbol, predicate: Expression)

Bases: Expression

Corresponds to the logical ∃ ∃x: x == 1 enunciates a truth

Attributes:
type

Returns expression’s type

Methods

__call__(*args, **kwargs)

Returns a FunctionApplication expression, applied to the *args cast as Constant if not Symbol or Expression **kwargs are ignored

help()

Returns help based on Expression's subclass

do

class neurolang.frontend.query_resolution_expressions.Expression(query_builder: QueryBuilderBase, expression: Expression)

Bases: object

Generic class representing expressions in the front end An expression can be anything, from a symbol to an operation to a query

Attributes:
type

Returns expression’s type

Methods

__call__(*args, **kwargs)

Returns a FunctionApplication expression, applied to the *args cast as Constant if not Symbol or Expression **kwargs are ignored

help()

Returns help based on Expression's subclass

do

do(name=None)
help() str

Returns help based on Expression’s subclass

property type: Type

Returns expression’s type

class neurolang.frontend.query_resolution_expressions.Fact(query_builder: QueryBuilderBase, expression: Expression, consequent: Expression)

Bases: Expression

A Fact reprsents an information considered as True. It can be seen as the Implication: fact ← True, e.g. Even(2) ← True

Attributes:
type

Returns expression’s type

Methods

__call__(*args, **kwargs)

Returns a FunctionApplication expression, applied to the *args cast as Constant if not Symbol or Expression **kwargs are ignored

help()

Returns help based on Expression's subclass

do

class neurolang.frontend.query_resolution_expressions.Implication(query_builder: QueryBuilderBase, expression: Expression, consequent: Expression, antecedent: Expression)

Bases: Expression

Corresponds to the logical implication: consequent ← antecedent or alternatively consequent if antecedent

Attributes:
type

Returns expression’s type

Methods

__call__(*args, **kwargs)

Returns a FunctionApplication expression, applied to the *args cast as Constant if not Symbol or Expression **kwargs are ignored

help()

Returns help based on Expression's subclass

do

class neurolang.frontend.query_resolution_expressions.Operation(query_builder: QueryBuilderBase, expression: Expression, operator: Expression, arguments: Tuple[Expression, ...], infix: bool = False)

Bases: Expression

An Operation is an Expression representing the application of an operator to a tuple of arguments

Attributes:
type

Returns expression’s type

Methods

__call__(*args, **kwargs)

Returns a FunctionApplication expression, applied to the *args cast as Constant if not Symbol or Expression **kwargs are ignored

help()

Returns help based on Expression's subclass

do

operator_repr = {<built-in function and_>: '∧', <built-in function or_>: '∨', <built-in function invert>: '¬'}
class neurolang.frontend.query_resolution_expressions.Query(query_builder: QueryBuilderBase, expression: Expression, symbol: Symbol, predicate: Expression)

Bases: Expression

A query represents the symbols that verify a given predicate: x | x%2 == 0 with x an int represents even numbers

Attributes:
type

Returns expression’s type

Methods

__call__(*args, **kwargs)

Returns a FunctionApplication expression, applied to the *args cast as Constant if not Symbol or Expression **kwargs are ignored

help()

Returns help based on Expression's subclass

do

class neurolang.frontend.query_resolution_expressions.RightImplication(query_builder: QueryBuilderBase, expression: Expression, antecedent: Expression, consequent: Expression)

Bases: Expression

Corresponds to the logical implication: antecedent → consequent or alternatively if antecedent then consequent In the logic context, used to denote a constraint

Attributes:
type

Returns expression’s type

Methods

__call__(*args, **kwargs)

Returns a FunctionApplication expression, applied to the *args cast as Constant if not Symbol or Expression **kwargs are ignored

help()

Returns help based on Expression's subclass

do

class neurolang.frontend.query_resolution_expressions.Symbol(query_builder: QueryBuilderBase, symbol_name: str)

Bases: Expression

A Symbol represents an atomic Expression. Its is the most recurrent element of queries

Attributes:
expression

Projects to symbol property

neurolang_symbol

Returns backend symbol

symbol

Returns backend symbol from symbol_table

type

Returns expression’s type

value

If any, returns value corresponding to the symbol

Methods

__call__(*args, **kwargs)

Returns a FunctionApplication expression, applied to the *args cast as Constant if not Symbol or Expression **kwargs are ignored

help()

Returns help based on Expression's subclass

do

property expression: Symbol

Projects to symbol property

property neurolang_symbol: Symbol

Returns backend symbol

property symbol: Symbol

Returns backend symbol from symbol_table

property value: Any

If any, returns value corresponding to the symbol

Returns:
Any

see description

Raises:
ValueError

if Symbol doesn’t have a python value

class neurolang.frontend.query_resolution_expressions.TranslateExpressionToFrontEndExpression(query_builder: QueryBuilderBase)

Bases: ExpressionWalker

Walks through a backend Expression to translate it to a frontend Expression

Attributes:
patterns

Property holding an iterator of triplets (pattern, guard, action).

Methods

match(expression)

Find the action for a given expression by going through the patterns.

pattern_match(pattern, expression)

Return True if pattern matches expression.

type

conjunction

constant

exists

fact

forall

implication

negation

pattern_match_expression

pattern_match_expression_parameters

pattern_match_expression_tuple

pattern_match_tuple

process_expression

process_iterable_argument

right_implication

symbol

walk

walk_function_application

conjunction(expression: Expression) Expression
constant(expression: Expression) Any
exists(expression: Expression) Expression
fact(expression: Expression) Fact
forall(expression: Expression) Expression
implication(expression: Expression) Implication
negation(expression: Expression) Expression
right_implication(expression)
symbol(expression: Expression) Expression
type = typing.Any
walk_function_application(expression: Expression) Any
neurolang.frontend.query_resolution_expressions.op_bind(op)
neurolang.frontend.query_resolution_expressions.rop_bind(op)