neurolang.logic.expression_processing module

class neurolang.logic.expression_processing.ExtractFreeVariablesWalker(*args, **kwargs)

Bases: WalkLogicProgramAggregatingSets

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

disjunction

extract_variables_fa

extract_variables_q

extract_variables_s

extract_variables_symbol

logic_operator

negation

pattern_match_expression

pattern_match_expression_parameters

pattern_match_expression_tuple

pattern_match_tuple

quantifier

union

walk

walk_binary_logic_expression

walk_nary

extract_variables_fa(expression)
extract_variables_q(expression)
extract_variables_s(expression)
extract_variables_symbol(expression)
type = typing.Any
class neurolang.logic.expression_processing.ExtractLogicAtoms(*args, **kwargs)

Bases: WalkLogicProgramAggregatingSets

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

disjunction

extract_predicates_fa

logic_operator

negation

pattern_match_expression

pattern_match_expression_parameters

pattern_match_expression_tuple

pattern_match_tuple

quantifier

symbol

union

walk

walk_binary_logic_expression

walk_nary

constant(expression)
extract_predicates_fa(expression)
symbol(expression)
type = typing.Any
class neurolang.logic.expression_processing.ExtractLogicPredicates(*args, **kwargs)

Bases: WalkLogicProgramAggregatingSets

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

disjunction

extract_predicates_fa

logic_operator

negation

pattern_match_expression

pattern_match_expression_parameters

pattern_match_expression_tuple

pattern_match_tuple

quantifier

symbol

union

walk

walk_binary_logic_expression

walk_nary

constant(expression)
extract_predicates_fa(expression)
negation(expression)
symbol(expression)
type = typing.Any
class neurolang.logic.expression_processing.HasExistentialPredicates(*args, **kwargs)

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

existential_predicate

nary

operator

pattern_match_expression

pattern_match_expression_parameters

pattern_match_expression_tuple

pattern_match_tuple

walk

walk_function_application

existential_predicate(expression)
nary(expression)
operator(expression)
type = typing.Any
walk_function_application(expression)
class neurolang.logic.expression_processing.LogicSolver(*args, **kwargs)

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

evaluate_conjunction

evaluate_disjunction

evaluate_implication

evaluate_implication_false_antecedent

evaluate_implication_false_consequent

evaluate_implication_true_antecedent

evaluate_implication_true_consequent

evaluate_negation

pattern_match_expression

pattern_match_expression_parameters

pattern_match_expression_tuple

pattern_match_tuple

walk

evaluate_conjunction(expression)
evaluate_disjunction(expression)
evaluate_implication(expression)
evaluate_implication_false_antecedent(expression)
evaluate_implication_false_consequent(expression)
evaluate_implication_true_antecedent(expression)
evaluate_implication_true_consequent(expression)
evaluate_negation(expression)
type = typing.Any
class neurolang.logic.expression_processing.TranslateToLogic(*args, **kwargs)

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

build_conjunction

build_disjunction

build_negation

pattern_match_expression

pattern_match_expression_parameters

pattern_match_expression_tuple

pattern_match_tuple

translate_logic_operator

walk

build_conjunction(conjunction)
build_disjunction(disjunction)
build_negation(inversion)
translate_logic_operator(expression)
type = typing.Any
class neurolang.logic.expression_processing.WalkLogicProgramAggregatingSets(*args, **kwargs)

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

conjunction

disjunction

logic_operator

negation

pattern_match_expression

pattern_match_expression_parameters

pattern_match_expression_tuple

pattern_match_tuple

quantifier

union

walk

walk_binary_logic_expression

walk_nary

conjunction(expression)
disjunction(expression)
logic_operator(expression)
negation(expression)
quantifier(expression)
type = typing.Any
union(expression)
walk_binary_logic_expression(expression)
walk_nary(expression)
neurolang.logic.expression_processing.extract_logic_atoms(expression)

Extract atoms from expression knowing that it’s in logic format

Parameters:
expressionExpression

expression to extract predicates from

Returns:
OrderedSet

set of all atoms in the expression in lexicographical order.

neurolang.logic.expression_processing.extract_logic_free_variables(expression)

Extract variables from expression assuming it’s in logic format.

Parameters:
expressionExpression
Returns:
OrderedSet

set of all free variables in the expression.

neurolang.logic.expression_processing.extract_logic_predicates(expression)

Extract predicates from expression knowing that it’s in logic format, if predicates are negated then (not predicate) will be the result.ormat

Parameters:
expressionExpression

expression to extract predicates from

Returns:
OrderedSet

set of all predicates in the expression in lexicographical order.

neurolang.logic.expression_processing.has_existential_quantifiers(query)

Check if the logic expression has existentially-quantified variables

Parameters:
queryLogicExpression

Logic expression to check wether existential quantifiers exists inside.

Returns:
bool

True if and only if there is an existentially-quantified variable in the expression.

neurolang.logic.expression_processing.is_logic_function_application(function_application)