neurolang.probabilistic.probabilistic_ra_utils module

class neurolang.probabilistic.probabilistic_ra_utils.DeterministicFactSet(relation)

Bases: RelationalAlgebraOperation

Methods

__call__(*args, **kwargs)

Call self as a function.

apply(*args)

Builds a new expression using a tuple of its parameters

type

unapply()

Returns a tuple of parameters used to build the expression.

cast

change_type

columns

get_wrapped_attribute

type = typing.Any
class neurolang.probabilistic.probabilistic_ra_utils.GetProbabilisticSetAtom(symbol_table)

Bases: PatternWalker

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

default

pattern_match_expression

pattern_match_expression_parameters

pattern_match_expression_tuple

pattern_match_tuple

projection

resolve_symbol

walk

default(expression)
projection(expression)
resolve_symbol(expression)
type = typing.Any
class neurolang.probabilistic.probabilistic_ra_utils.NonLiftable(non_liftable_query)

Bases: RelationalAlgebraOperation

Represents a logic-based probabilistic query which could not be lifted into a safe plan.

Methods

__call__(*args, **kwargs)

Call self as a function.

apply(*args)

Builds a new expression using a tuple of its parameters

type

unapply()

Returns a tuple of parameters used to build the expression.

cast

change_type

columns

get_wrapped_attribute

type = typing.Any
class neurolang.probabilistic.probabilistic_ra_utils.ProbabilisticChoiceSet(relation, probability_column)

Bases: RelationalAlgebraOperation

Methods

__call__(*args, **kwargs)

Call self as a function.

apply(*args)

Builds a new expression using a tuple of its parameters

type

unapply()

Returns a tuple of parameters used to build the expression.

cast

change_type

columns

get_wrapped_attribute

type = typing.Any
class neurolang.probabilistic.probabilistic_ra_utils.ProbabilisticFactSet(relation, probability_column)

Bases: RelationalAlgebraOperation

Methods

__call__(*args, **kwargs)

Call self as a function.

apply(*args)

Builds a new expression using a tuple of its parameters

type

unapply()

Returns a tuple of parameters used to build the expression.

cast

change_type

columns

get_wrapped_attribute

type = typing.Any
neurolang.probabilistic.probabilistic_ra_utils.classify_and_wrap_symbols(ra_set_dict, query_predicate, symbol_table, wrapper)
neurolang.probabilistic.probabilistic_ra_utils.generate_probabilistic_symbol_table_for_query(cpl_program, query_predicate)

Generate a symbol table adding a fresh symbol for each probabilistic/deterministic table and wrapping it into one of the classes DeterministicFactSet, ProbabilisticFactSet, ProbabilisticChoiceSet

Parameters:
cpl_programneurolang.probabilistic.cplogic.CPLogicProgram

CPLogic program representation indexing the query’s symbols.

query_predicateneurolang.logic.LogicOperator

Logic expression representing a query from where to extract the predicates which are represented as Symbols.

Returns:
dict or Mapping

symbol table with relationship symbols of query_predicate. The tables has neurolang.expressions.Symbol as keys and relational algebra representations as values

neurolang.probabilistic.probabilistic_ra_utils.is_atom_a_deterministic_relation(atom: Expression, symbol_table: Mapping[Any, Expression]) bool

Returns if a particular expression is a deterministic relation

Parameters:
atomExpression

neurolang Expression

symbol_tableMapping[Any, Expression]

mapping maching symbols to expressions.

Returns:
bool

True if the Expression is a relational algebra expression containing a single deterministic relation.

neurolang.probabilistic.probabilistic_ra_utils.is_atom_a_probabilistic_choice_relation(atom: Expression, symbol_table: Mapping[Any, Expression]) bool

Returns if a particular expression is a choice relation

Parameters:
atomExpression

neurolang Expression

symbol_tableMapping[Any, Expression]

mapping maching symbols to expressions.

Returns:
bool

True if the Expression is a relational algebra expression containing a single choice relation.

neurolang.probabilistic.probabilistic_ra_utils.is_atom_a_probabilistic_fact_relation(atom: Expression, symbol_table: Mapping[Any, Expression]) bool

Returns if a particular expression is a tuple independent fact set relation

Parameters:
atomExpression

neurolang Expression

symbol_tableMapping[Any, Expression]

mapping maching symbols to expressions.

Returns:
bool

True if the Expression is a relational algebra expression containing a single independent fact set relation.