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.
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:
objectMethods
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]}¶
- class neurolang.datalog.aggregation.ChaseAggregationMixin¶
Bases:
objectAggregation 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:
patternsProperty 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
Trueifpatternmatchesexpression.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:
patternsProperty 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
Trueifpatternmatchesexpression.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)¶