neurolang.datalog.basic_representation module¶
Compiler for the intermediate representation of a Datalog program.
The DatalogProgram class processes the
intermediate representation of a program and extracts
the extensional, intensional, and builtin
sets.
- class neurolang.datalog.basic_representation.DatalogProgram(symbol_table=None)¶
Bases:
DatalogProgramMixin,ExpressionWalker- Attributes:
- included_constants
- included_functions
patternsProperty holding an iterator of triplets
(pattern, guard, action).
Methods
constant_equalsinfer_iterable_type(iterable)Infer the type of iterable elements without modifying the iterable.
match(expression)Find the action for a given expression by going through the
patterns.pattern_match(pattern, expression)Return
Trueifpatternmatchesexpression.union_of_cq(expression)This pattern is here to avoid processing the full program when one rule is rewritten.
add_extensional_predicate_from_tuples
add_included_constants_and_functions_to_symbol_table
builtins
extensional_database
fact
intensional_database
new_set
pattern_match_expression
pattern_match_expression_parameters
pattern_match_expression_tuple
pattern_match_tuple
pop_scope
predicate_terms
process_expression
process_iterable_argument
push_scope
statement_intensional
symbol
walk
- protected_keywords = {}¶
- type = typing.Any¶
- class neurolang.datalog.basic_representation.Fact(consequent)¶
Bases:
Implication- Attributes:
- fact
Methods
__call__(*args, **kwargs)Call self as a function.
apply(*args)Builds a new expression using a tuple of its parameters
unapply()Returns a tuple of parameters used to build the expression.
cast
change_type
get_wrapped_attribute
- property fact¶
- type = typing.Any¶
- class neurolang.datalog.basic_representation.Implication(consequent, antecedent)¶
Bases:
LogicOperatorExpression of the form P(x) ← Q(x)
Methods
__call__(*args, **kwargs)Call self as a function.
apply(*args)Builds a new expression using a tuple of its parameters
unapply()Returns a tuple of parameters used to build the expression.
cast
change_type
get_wrapped_attribute
- type = typing.Any¶
- class neurolang.datalog.basic_representation.NullConstant(value, auto_infer_type=True, verify_type=True)¶
Bases:
ConstantMethods
__call__(*args, **kwargs)Call self as a function.
apply(*args)Builds a new expression using a tuple of its parameters
unapply()Returns a tuple of parameters used to build the expression.
cast
change_type
get_wrapped_attribute
- type = typing.Any¶
- class neurolang.datalog.basic_representation.Undefined(value, auto_infer_type=True, verify_type=True)¶
Bases:
ConstantMethods
__call__(*args, **kwargs)Call self as a function.
apply(*args)Builds a new expression using a tuple of its parameters
unapply()Returns a tuple of parameters used to build the expression.
cast
change_type
get_wrapped_attribute
- type = typing.Any¶
- class neurolang.datalog.basic_representation.WrappedRelationalAlgebraSet(iterable=None, row_type=<class 'neurolang.type_system.Unknown'>, verify_row_type=True, **kwargs)¶
Bases:
WrappedRelationalAlgebraSetMixin,RelationalAlgebraSet- Attributes:
- arity
- columns
- row_type
Methods
clear()This is slow (creates N new iterators!) but effective.
isdisjoint(other)Return True if two sets have a null intersection.
pop()Return the popped value.
projection(*columns)Projects the set on the given list of columns.
remove(value)Remove an element.
selection(select_criteria)Select the elements based on the given selet_criteria.
selection_columns(select_criteria)Select the elements where column pairs indicated as key, value items of the select_criteria are equal.
add
as_numpy_array
as_pandas_dataframe
copy
create_view_from
cross_product
dee
discard
dum
equijoin
fetch_one
groupby
is_constant_tuple_or_tuple_of_constants
is_dee
is_dum
is_empty
itervalues
unwrap
unwrapped_iter
- unwrap()¶