neurolang.datalog.aggregation module

Support for aggregations according to [1]. For instance the encoding of P(x, count<y>):-Q(x, y) in intermediate representation Implication(P(x, AggregationApplication(count, y), Q(x, y)) produces the set P(x, z) where z is the number of tuples (x, ...) in the set Q.

[1]

T. J. Green, S. S. Huang, B. T. Loo, W. Zhou, Datalog and Recursive Query Processing. FNT in Databases. 5, 105–195 (2012).

class neurolang.datalog.aggregation.BuiltinAggregationMixin

Bases: object

Methods

constant_max

constant_mean

constant_std

constant_sum

function_count

constant_max = C{amax: typing.Callable[[neurolang.type_system.Unknown, neurolang.type_system.Unknown, neurolang.type_system.Unknown, neurolang.type_system.Unknown, neurolang.type_system.Unknown, neurolang.type_system.Unknown], neurolang.type_system.Unknown]}
constant_mean = C{mean: typing.Callable[[neurolang.type_system.Unknown, neurolang.type_system.Unknown, neurolang.type_system.Unknown, neurolang.type_system.Unknown, neurolang.type_system.Unknown, neurolang.type_system.Unknown], neurolang.type_system.Unknown]}
constant_std = C{std: typing.Callable[[neurolang.type_system.Unknown, neurolang.type_system.Unknown, neurolang.type_system.Unknown, neurolang.type_system.Unknown, neurolang.type_system.Unknown, neurolang.type_system.Unknown, neurolang.type_system.Unknown], neurolang.type_system.Unknown]}
constant_sum = C{sum: typing.Callable[[neurolang.type_system.Unknown], neurolang.type_system.Unknown]}
function_count(*iterables: Iterable) int
class neurolang.datalog.aggregation.ChaseAggregationMixin

Bases: object

Aggregation Chase Mixin to add support for aggregation to a Chase class. Can be used with StratifiedChase.

Methods

check_constraints

compute_result_set

eliminate_already_computed

check_constraints(instance_update)
compute_result_set(rule, substitutions, instance, restriction_instance=None)
eliminate_already_computed(consequent, instance, substitutions)
class neurolang.datalog.aggregation.DatalogWithAggregationMixin(*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

pattern_match_expression

pattern_match_expression_parameters

pattern_match_expression_tuple

pattern_match_tuple

statement_intensional_aggregation

walk

statement_intensional_aggregation(expression)
type = typing.Any
class neurolang.datalog.aggregation.TranslateToLogicWithAggregation(*args, **kwargs)

Bases: TranslateToLogic

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_conjunction_from_expression_block

build_disjunction

build_negation

pattern_match_expression

pattern_match_expression_parameters

pattern_match_expression_tuple

pattern_match_tuple

transform_function_application_consequent_to_aggregation

translate_logic_operator

translate_true_implication

walk

transform_function_application_consequent_to_aggregation(rule)
type = typing.Any
neurolang.datalog.aggregation.is_builtin_aggregation_functor(functor)