neurolang.probabilistic.stratification module

neurolang.probabilistic.stratification.get_list_of_intensional_rules(program)

Given a program, it returns a list of intentional rules.

Parameters:
programCPLogicProgram

Program from which we want to obtain the list of intentional rules.

Returns:
list

list of intentional rules

neurolang.probabilistic.stratification.reachable_code_from_query(query, program)

Find the part of the intensional database of the program that is needed to answer a rule-based query Head :- Body such that Head is not necesarrily part of the program.

This is useful if the query is formulated as a rule instead of simply a query predicate (e.g. ans(x, y) :- P(x, z), P(y, z)).

neurolang.probabilistic.stratification.stratify_program(query, program)

Statically analyse the program to isolate its deterministic strat, its probabilistic strats and its post-probabilistic-query deterministic strat.

A query can be solved through stratification if the probabilistic and deterministic parts are well separated. In case there exists one within-language probabilistic query dependency, no probabilistic predicate should appear in the strat that depends on the query.

Parameters:
queryImplication

Query defining the part of the program that needs to be stratified.

programCPLogicProgram

Program that will be stratified.

Returns:
mapping from idb type to Union

Deterministic, probabilistic and post-probabilistic IDBs.

Raises:
UnsupportedProgramError

When a WLQ (within-language query) depends on another WLQ.