neurolang.probabilistic.weighted_model_counting module

Implementation of the weighted model counting approach through knowledge compilation.

class neurolang.probabilistic.weighted_model_counting.DeterministicFactSetTranslation(*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

deterministic_fact_set_constant

pattern_match_expression

pattern_match_expression_parameters

pattern_match_expression_tuple

pattern_match_tuple

walk

deterministic_fact_set_constant(deterministic_set)
type = typing.Any
class neurolang.probabilistic.weighted_model_counting.EliminateSuperfluousProjectionMixin(*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

eliminate_superfluous_projection

pattern_match_expression

pattern_match_expression_parameters

pattern_match_expression_tuple

pattern_match_tuple

walk

eliminate_superfluous_projection(expression)
type = typing.Any
class neurolang.probabilistic.weighted_model_counting.RAQueryOptimiser(*args, **kwargs)

Bases: PushInSelections, ExpressionWalker

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

process_expression

process_iterable_argument

push_and_rename_in_naturaljoin

push_selection_in_extended_projection

push_selection_in_groupby

push_selection_in_left

push_selection_in_leftnaturaljoin_left

push_selection_in_leftnaturaljoin_right

push_selection_in_outernaturaljoin_left

push_selection_in_outernaturaljoin_right

push_selection_in_projection

push_selection_in_replace_null

push_selection_in_right

walk

type = typing.Any
class neurolang.probabilistic.weighted_model_counting.SDDWMCSemiRingSolver(*args, **kwargs)

Bases: EliminateSuperfluousProjectionMixin, RenameOptimizations, DeterministicFactSetTranslation, RelationalAlgebraProvenanceExpressionSemringSolver

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

aggregate

arithmetic_string_expression

concatenate_constant_column

convert_rename_column

cycle_in_build_provenance_algebra_set

deterministic_fact_set

deterministic_fact_set_constant

difference

eliminate_superfluous_projection

eliminate_trivial_number_columns

eliminate_trivial_projection_number_columns

eliminate_trivial_selection_number_columns

extended_projection

generate_sdd_expression

get_new_bernoulli_variable

merge_nested_rename_columns

merge_rename_column_group_by

merge_rename_columns_extended_projection

name_columns_int_rap

name_columns_rap

number_columns_rap

pattern_match_expression

pattern_match_expression_parameters

pattern_match_expression_tuple

pattern_match_tuple

probabilistic_choice_set

probabilistic_fact_set

probabilistic_fact_set_invalid

process_expression

process_iterable_argument

projection_rap

projection_rap_columnint

projection_rap_columnint_subset

prov_arithmetic_operation

prov_concatenate_constant_column

prov_extended_projection

prov_naturaljoin

prov_product

prov_rename_column

prov_rename_columns

prov_union

push_rename_past_groupby

push_rename_past_projection

push_rename_past_selection

ra_constant

ra_difference

ra_equijoin

ra_full_outer_naturaljoin

ra_intersection

ra_left_naturaljoin

ra_name_columns

ra_naturaljoin

ra_number_columns

ra_product

ra_projection

ra_rename_column

ra_rename_columns

ra_symbol

ra_union

remove_trivial_rename

replace_null

selection_between_columns

selection_by_constant

selection_general_selection_by_constant

selection_provenance_set

selection_rap_eq_columnint

selection_rap_eq_columnint_columnint

set_destroy

simplify_renames_name

split_rename_left_naturaljoin

split_rename_naturaljoin

split_rename_outer_naturaljoin

switch_rename_replace_null

walk

wmc_weights

deterministic_fact_set(deterministic_set)
generate_sdd_expression(adjusted_probability, tag_expressions, previous_expression)
get_new_bernoulli_variable(probability)
probabilistic_choice_set(prob_fact_set)
probabilistic_fact_set(prob_fact_set)
probabilistic_fact_set_invalid(prob_fact_set)
type = typing.Any
wmc_weights()
class neurolang.probabilistic.weighted_model_counting.SemiRingRAPToSDD(var_count, symbols_to_literals=None)

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

add

eq

expression_block

mul

neg

or_

pattern_match_expression

pattern_match_expression_parameters

pattern_match_expression_tuple

pattern_match_tuple

symbol

walk

add(expression)
eq(expression)
expression_block(expression)
mul(expression)
neg(expression)
or_(expression)
symbol(expression)
type = typing.Any
class neurolang.probabilistic.weighted_model_counting.WMCSemiRingSolver(*args, **kwargs)

Bases: EliminateSuperfluousProjectionMixin, DeterministicFactSetTranslation, RelationalAlgebraProvenanceExpressionSemringSolver

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

aggregate

arithmetic_string_expression

concatenate_constant_column

cycle_in_build_provenance_algebra_set

deterministic_fact_set

deterministic_fact_set_constant

difference

eliminate_superfluous_projection

extended_projection

name_columns_int_rap

name_columns_rap

number_columns_rap

pattern_match_expression

pattern_match_expression_parameters

pattern_match_expression_tuple

pattern_match_tuple

probabilistic_choice_set

probabilistic_fact_set

probabilistic_fact_set_invalid

process_expression

process_iterable_argument

projection_rap

projection_rap_columnint

projection_rap_columnint_subset

prov_arithmetic_operation

prov_concatenate_constant_column

prov_extended_projection

prov_naturaljoin

prov_product

prov_rename_column

prov_rename_columns

prov_union

ra_constant

ra_difference

ra_equijoin

ra_full_outer_naturaljoin

ra_intersection

ra_left_naturaljoin

ra_name_columns

ra_naturaljoin

ra_number_columns

ra_product

ra_projection

ra_rename_column

ra_rename_columns

ra_symbol

ra_union

replace_null

selection_between_columns

selection_by_constant

selection_general_selection_by_constant

selection_provenance_set

selection_rap_eq_columnint

selection_rap_eq_columnint_columnint

set_destroy

walk

deterministic_fact_set(deterministic_set)
probabilistic_choice_set(prob_choice_set)
probabilistic_fact_set(prob_fact_set)
probabilistic_fact_set_invalid(prob_fact_set)
type = typing.Any
neurolang.probabilistic.weighted_model_counting.build_global_sdd_model_rows(solver, literal_probabilities)
neurolang.probabilistic.weighted_model_counting.generate_probability_table(solver)
neurolang.probabilistic.weighted_model_counting.generate_weights(symbol_probs, literals_to_symbols, extras=0)
neurolang.probabilistic.weighted_model_counting.model_count_and_per_row_probability(model, solver, initial_var_count, n)
neurolang.probabilistic.weighted_model_counting.perform_wmc(solver, sdd_compiler, sdd_program, prob_set_program, prob_set_result)
neurolang.probabilistic.weighted_model_counting.prepare_initial_query(query_predicate)
neurolang.probabilistic.weighted_model_counting.sdd_compilation(prob_set_result)
neurolang.probabilistic.weighted_model_counting.sdd_compilation_and_wmc(prob_set_result, solver)
neurolang.probabilistic.weighted_model_counting.sdd_solver_global_model(solver, set_probabilities)
neurolang.probabilistic.weighted_model_counting.sdd_solver_per_individual_row(solver, set_probabilities)
neurolang.probabilistic.weighted_model_counting.solve_marg_query(rule, cpl)

Solve a MARG query on a CP-Logic program.

Parameters:
queryImplication

Consequent must be of type Condition. MARG query of the form ans(x) :- P(x).

cpl_programCPLogicProgram

CP-Logic program on which the query should be solved.

Returns:
ProvenanceAlgebraSet

Provenance set labelled with probabilities for each tuple in the result set.

neurolang.probabilistic.weighted_model_counting.solve_succ_query(query_predicate, cpl_program, per_row_model=True, run_relational_algebra_solver=True)

Obtain the solution of a SUCC query on a CP-Logic program.

The SUCC query must take the form

SUCC[ P(x) ]

neurolang.probabilistic.weighted_model_counting.solve_succ_query_boolean_diagram(query_predicate, cpl_program, run_relational_algebra_solver=False)

Obtain the solution of a SUCC query on a CP-Logic program.

The SUCC query must take the form

SUCC[ P(x) ]

neurolang.probabilistic.weighted_model_counting.solve_succ_query_sdd_direct(query_predicate, cpl_program, per_row_model=True, run_relational_algebra_solver=True)

Obtain the solution of a SUCC query on a CP-Logic program.

The SUCC query must take the form

SUCC[ P(x) ]