This module performs reasoning over probabilistic description logic knowledge bases.
It reads probabilistic knowledge bases in RDF format or in Prolog format, a functional-like
sintax based on definitions of Thea library, and answers queries by finding the set
of explanations or computing the probability.
[1] http://vangelisv.github.io/thea/
See https://github.com/rzese/trill/blob/master/doc/manual.pdf or
http://ds.ing.unife.it/~rzese/software/trill/manual.html for
details.
- author
- - Riccardo Zese
- version
- - 6.0.2
- copyright
- - Riccardo Zese
- license
- - Artistic License 2.0
- load_kb(++FileName:kb_file_name) is det
- The predicate loads the knowledge base contained in the given file.
The knowledge base must be defined in TRILL format, to use also OWL/RDF format
use the predicate owl_rdf/1.
- load_owl_kb(++FileName:kb_file_name) is det
- The predicate loads the knowledge base contained in the given file.
The knowledge base must be defined in pure OWL/RDF format.
- load_owl_kb_from_string(++KB:string) is det
- The predicate loads the knowledge base contained in the given string.
The knowledge base must be defined in pure OWL/RDF format.
- add_kb_prefix(:ShortPref:string, ++LongPref:string) is det[multifile]
- This predicate registers the alias ShortPref for the prefix defined in LongPref.
The empty string '' can be defined as alias.
- add_kb_prefixes(:Prefixes:list) is det[multifile]
- This predicate registers all the alias prefixes contained in Prefixes.
The input list must contain pairs alias=prefix, i.e., [('foo'='http://example.foo#')].
The empty string '' can be defined as alias.
- add_axiom(:Axiom:axiom) is det[multifile]
- This predicate adds the given axiom to the knowledge base.
The axiom must be defined following the TRILL syntax.
- add_axioms(:Axioms:list) is det[multifile]
- This predicate adds the axioms of the list to the knowledge base.
The axioms must be defined following the TRILL syntax.
- remove_kb_prefix(:ShortPref:string, ++LongPref:string) is det[multifile]
- This predicate removes from the registered aliases the one given in input.
- remove_kb_prefix(:Name:string) is det[multifile]
- This predicate takes as input a string that can be an alias or a prefix and
removes the pair containing the string from the registered aliases.
- remove_axiom(:Axiom:axiom) is det[multifile]
- This predicate removes the given axiom from the knowledge base.
The axiom must be defined following the TRILL syntax.
- remove_axioms(++Axioms:list) is det[multifile]
- This predicate removes the axioms of the list from the knowledge base.
The axioms must be defined following the TRILL syntax.
- axiom(:Axiom:axiom) is det[multifile]
- This predicate searches in the loaded knowledge base axioms that unify with Axiom.
- set_tableau_expansion_rules(:DetRules:list, ++NondetRules:list) is det
- This predicate set the rules as taken in input, maintaining order and number of rules.
DetRules is the list of deterministic rules, NondetRules the list of non-deterministic ones.
- instanceOf(:Class:concept_description, ++Ind:individual_name)
- This predicate takes as input the name or the full URI of a class or the definition
of a complex concept as a ground term and name or the full URI of an individual and
returns one explanation for the instantiation of the individual to the given class.
The returning explanation is a set of axioms.
The predicate fails if the individual does not belong to the class.
- instanceOf(:Class:concept_description, ++Ind:individual_name) is det
- This predicate takes as input the name or the full URI of a class or the definition
of a complex concept as a ground term and name or the full URI of an individual and
returns true if the individual belongs to the class, false otherwise.
- property_value(:Prop:property_name, ++Ind1:individual_name, ++Ind2:individual_name, -Expl:list, ++Opt:list)
- This predicate takes as input the name or the full URI of a property and of two individuals
and returns one explanation for the fact Ind1 is related with Ind2 via Prop.
The returning explanation is a set of axioms.
The predicate fails if the two individual are not Prop-related. *
Opt is a list containing options for the execution of the query.
Options can be:
assert_abox(Boolean)
if Boolean is set to true the list of aboxes is asserted with the predicate final_abox/1.
compute_prob(mode,Prob)
if mode is query trill is forced to find all the explanations, and compute the probability of the query is computed and unified with Prob (same as using prob_<query> but it also returns the set of justifications); if mode is expl trill will compute the probability of each single explanation.
max_expl(Value)
to limit the maximum number of explanations to find. Value must be an integer. The predicate will return a list containing at most Value different explanations.
time_limit(Value)
to limit the time for the inference. The predicate will return the explanations found in the time allowed. Value is the number of seconds allowed for the search of explanations.
- property_value(:Prop:property_name, ++Ind1:individual_name, ++Ind2:individual_name, -Expl:list)
- This predicate takes as input the name or the full URI of a property and of two individuals
and returns one explanation for the fact Ind1 is related with Ind2 via Prop.
The returning explanation is a set of axioms.
The predicate fails if the two individual are not Prop-related.
- all_property_value(:Prop:property_name, ++Ind1:individual_name, ++Ind2:individual_name, -Expl:list)
- This predicate takes as input the name or the full URI of a property and of two individuals
and returns all the explanations for the fact Ind1 is related with Ind2 via Prop.
The returning explanations are in the form if a list (set) of set of axioms.
The predicate fails if the individual does not belong to the class.
- property_value(:Prop:property_name, ++Ind1:individual_name, ++Ind2:individual_name) is det
- This predicate takes as input the name or the full URI of a property and of two individuals
and returns true if the two individual are Prop-related, false otherwise.
- sub_class(:Class:concept_description, ++SupClass:concept_description, -Expl:list, ++Opt:list)
- This predicate takes as input two concepts which can be given by the name or the full URI
of two a simple concept or the definition of a complex concept as a ground term and returns
one explanation for the subclass relation between Class and SupClass.
The returning explanation is a set of axioms.
The predicate fails if there is not a subclass relation between the two classes.
Opt is a list containing options for the execution of the query.
Options can be:
assert_abox(Boolean)
if Boolean is set to true the list of aboxes is asserted with the predicate final_abox/1.
compute_prob(mode,Prob)
if mode is query trill is forced to find all the explanations, and compute the probability of the query is computed and unified with Prob (same as using prob_<query> but it also returns the set of justifications); if mode is expl trill will compute the probability of each single explanation.
max_expl(Value)
to limit the maximum number of explanations to find. Value must be an integer. The predicate will return a list containing at most Value different explanations.
time_limit(Value)
to limit the time for the inference. The predicate will return the explanations found in the time allowed. Value is the number of seconds allowed for the search of explanations.
- sub_class(:Class:concept_description, ++SupClass:concept_description, -Expl:list)
- This predicate takes as input two concepts which can be given by the name or the full URI
of two a simple concept or the definition of a complex concept as a ground term and returns
one explanation for the subclass relation between Class and SupClass.
The returning explanation is a set of axioms.
The predicate fails if there is not a subclass relation between the two classes.
- all_sub_class(:Class:concept_description, ++SupClass:concept_description, -Expl:list)
- This predicate takes as input two concepts which can be given by the name or the full URI
of two a simple concept or the definition of a complex concept as a ground term and returns
all the explanations for the subclass relation between Class and SupClass.
The returning explanations are in the form if a list (set) of set of axioms.
The predicate fails if Class is not subclass of SupClass.
- sub_class(:Class:concept_description, ++SupClass:concept_description) is det
- This predicate takes as input two concepts which can be given by the name or the full URI
of two a simple concept or the definition of a complex concept as a ground term and returns
true if Class is a subclass of SupClass, and false otherwise.
- unsat(:Concept:concept_description, -Expl:list, ++Opt:list)
- This predicate takes as input the name or the full URI of a class or the definition of
a complex concept as a ground term and returns one explanation for the unsatisfiability of the concept.
The returning explanation is a set of axioms.
The predicate fails if the concept is satisfiable.
Opt is a list containing options for the execution of the query.
Options can be:
assert_abox(Boolean)
if Boolean is set to true the list of aboxes is asserted with the predicate final_abox/1.
compute_prob(mode,Prob)
if mode is query trill is forced to find all the explanations, and compute the probability of the query is computed and unified with Prob (same as using prob_<query> but it also returns the set of justifications); if mode is expl trill will compute the probability of each single explanation.
max_expl(Value)
to limit the maximum number of explanations to find. Value must be an integer. The predicate will return a list containing at most Value different explanations.
time_limit(Value)
to limit the time for the inference. The predicate will return the explanations found in the time allowed. Value is the number of seconds allowed for the search of explanations.
- unsat(:Concept:concept_description, -Expl:list)
- This predicate takes as input the name or the full URI of a class or the definition of
a complex concept as a ground term and returns one explanation for the unsatisfiability of the concept.
The returning explanation is a set of axioms.
The predicate fails if the concept is satisfiable.
- all_unsat(:Concept:concept_description, -Expl:list)
- This predicate takes as input the name or the full URI of a class or the definition of
a complex concept as a ground term and returns all the explanations for the unsatisfiability of the concept.
The returning explanations are in the form if a list (set) of set of axioms.
The predicate fails if the individual does not belong to the class.
- unsat(:Concept:concept_description) is det
- This predicate takes as input the name or the full URI of a class or the definition of
a complex concept as a ground term and returns true if the concept is unsatisfiable, false otherwise.
- inconsistent_theory(:Expl:list, ++Opt:list)
- This predicate returns one explanation for the inconsistency of the loaded knowledge base.
Opt is a list containing options for the execution of the query.
Options can be:
assert_abox(Boolean)
if Boolean is set to true the list of aboxes is asserted with the predicate final_abox/1.
compute_prob(mode,Prob)
if mode is query trill is forced to find all the explanations, and compute the probability of the query is computed and unified with Prob (same as using prob_<query> but it also returns the set of justifications); if mode is expl trill will compute the probability of each single explanation.
max_expl(Value)
to limit the maximum number of explanations to find. Value must be an integer. The predicate will return a list containing at most Value different explanations.
time_limit(Value)
to limit the time for the inference. The predicate will return the explanations found in the time allowed. Value is the number of seconds allowed for the search of explanations.
- inconsistent_theory(:Expl:list)
- This predicate returns one explanation for the inconsistency of the loaded knowledge base.
- all_inconsistent_theory(:Expl:list)
- This predicate returns all the explanations for the inconsistency of the loaded knowledge base.
The returning explanations are in the form if a list (set) of set of axioms.
The predicate fails if the individual does not belong to the class.
- inconsistent_theory
- This predicate returns true if the loaded knowledge base is inconsistent, otherwise it fails.
- prob_instanceOf(:Class:concept_description, ++Ind:individual_name, --Prob:double) is det
- This predicate takes as input the name or the full URI of a class or the definition
of a complex concept as a ground term and name or the full URI of an individual and
returns the probability of the instantiation of the individual to the given class.
- prob_property_value(:Prop:property_name, ++Ind1:individual_name, ++Ind2:individual_name, --Prob:double) is det
- This predicate takes as input the name or the full URI of a property and of two individuals
and returns the probability of the fact Ind1 is related with Ind2 via Prop.
- prob_sub_class(:Class:concept_description, ++SupClass:class_name, --Prob:double) is det
- This predicate takes as input two concepts which can be given by the name or the full URI
of two a simple concept or the definition of a complex concept as a ground term and returns
the probability of the subclass relation between Class and SupClass.
- prob_unsat(:Concept:concept_description, --Prob:double) is det
- This predicate takes as input the name or the full URI of a class or the definition of
a complex concept as a ground term and returns the probability of the unsatisfiability
of the concept.
- prob_inconsistent_theory(:Prob:double) is det
- If the knowledge base is inconsistent, this predicate returns the probability of the inconsistency.
- resume_query(:Expl:list) is det
- Continues with the search for new justifications for the previous query if a previous query is open.
It only works returning justifications one by one.
- compute_query_prob(:Prob:double) is det
- Computes the probability of the previous query if there is one open.
- reset_query is det
- Closes the open query and reset the reasoner status to prepare it for a new query.
- init_trill(++Alg:reasoner)
- It initializes the algorithms Alg
Re-exported predicates
The following predicates are exported from this file while their implementation is defined in imported modules or non-module files loaded by this module.
- init_em(--Context:int) is det
- Initializes a data structure for performing parameter learning.
It returns an integer in Context that is a pointer to a
context data structure for performing the EM algorithm.
- end_em(++Context:int) is det
- Terminates the context data structure for performing parameter learning.
Context is a pointer to a context data structure for performing
the EM algorithm.
Context must have been returned by a call to init_em/1.
It frees the memory occupied by Context.
- init_ex(++Context:int, --Environment:int) is det
- Initializes an enviroment data structure for storing a BDD.
Context is an integer that is a pointer to a context data structure
created using init_em/1.
Returns an integer Environment that is a pointer to a data structure for
storing a single BDD to be used for the EM algorithm.
- end_ex(++Environment:int) is det
- Terminates the evnironment data structure for storing a BDD.
Environment is a pointer to a data structure returned by init_ex/2.
It frees the memory occupied by the BDD.
- init(--Environment:int) is det
- Initializes a data structure for storing a single BDD.
Returns an integer Environment that is a pointer to a data structure for
storing a single BDD to be used for inference only (no learning).
- end(++Environment:int) is det
- Terminates the environment data structure for storing a single BDD.
Environment is a pointer to a data structure returned by a call
to init/1.
- one(++Environment:int, --One:int) is det
- Returns in One a pointer to a BDD belonging to environment Environment
representing the one Boolean function.
- zero(++Environment:int, --Zero:int) is det
- Returns in Zero a pointer to a BDD belonging to environment Environment
representing the zero Boolean function.
- and(++Environment:int, ++A:int, ++B:int, --AandB:int) is det
- Returns in AandB a pointer to a BDD belonging to environment Environment
representing the conjunction of BDDs A and B.
- or(++Environment:int, ++A:int, ++B:int, --AorB:int) is det
- Returns in AorB a pointer to a BDD belonging to environment Environment
representing the disjunction of BDDs A and B.
- ret_prob(++Environment:int, ++BDD:int, -Probability:float) is det
- Returns the Probability of BDD belonging to environment Environment.
- ret_map_prob(++Environment:int, ++BDD:int, -Probability:float, -MAPState:list) is det
- Returns the MAP state MPAState of BDD and its Probability.
BDD belongs to environment Environment.
- ret_abd_prob(++Environment:int, ++BDD:int, -Probability:float, -Explanation:list) is det
- Returns the abductive Explanation of BDD and its Probability.
BDD belongs to environment Environment.
- bdd_not(++Environment:int, ++A:int, --NotA:int) is det
- Returns in NotA a pointer to a BDD belonging to environment Environment
representing the negation of BDD A.
- equality(++Environment:int, ++Variable:int, ++Value:int, --BDD:int) is det
- Returns in BDD the BDD belonging to environment Environment
that represents the equation Variable=Value.
- em(++Context:int, ++RuleInfo:list, ++ListOfBDDs:list, ++EA:float, ++ER:float, ++Iterations:int, -LL:float, -Parameters:list, -ExampleProbabilities:list) is det
- NumberOfHeads is a list of terms, one for each rule. Each term is either
an integer, indicating the number
of head atoms in the rule, or a list [N] where N
is the number of head atoms. In the first case, the parameters of the rule are tunable,
in the latter they are fixed.
Performs EM learning.
Takes as input the Context, information on the rules,
a list of BDDs each representing one example,
the minimum absolute difference EA and relative difference ER between the
log likelihood of examples in two different iterations and the maximum number of iterations
Iterations.
RuleInfo is a list of elements, one for each rule, with are either
- an integer, indicating the number of heads, in which case the parameters of the
corresponding rule should be randomized,
- a list of floats, in which case the parameters should be set to those indicated
in the list and not changed during learning (fixed parameters)
- [a list of floats], in which case the initial values of the parameters should
be set to those indicated
in the list and changed during learning (initial values of the parameters)
Returns the final log likelihood of examples LL, the list of new Parameters
and a list with the final probabilities of each example.
Parameters is a list whose elements are of the form [N,P] where N is the rule
number and P is a list of probabilities, one for each head atom of rule N,
in reverse order.
- add_var(++Environment:int, ++ProbabilityDistribution:list, ++Rule:int, -Variable:int) is det
- Returns in Variable the index of a new random variable in Environment with
NumberOHeads values and probability distribution ProbabilityDistribution.
- add_abd_var(++Environment:int, ++ProbabilityDistribution:list, ++Rule:int, -Variable:int) is det
- Returns in Variable the index of a new abducible random variable in Environment with
NumberOHeads values and probability distribution ProbabilityDistribution.
- add_query_var(++Environment:int, ++ProbabilityDistribution:list, ++Rule:int, -Variable:int) is det
- Returns in Variable the index of a new random variable to be queried in MAP inference with
NumberOHeads values and probability distribution ProbabilityDistribution.
The variable belongs to Environment.
- make_query_var(++Environment:int, +Variable:int, --BDD:int) is det
- Makes Variable belonging to Environment a query random variable for MAP inference.
Returns in BDD the diagram of the formula encoding the required constraints among the
Boolean random variable that represent Variable.
- create_dot_string(++Env:int, ++BDD:int, -Dot:string) is det
- The predicate returns the BDD in dot format.
- create_dot(++Env:int, ++BDD:int, ++File:string) is det
- The predicate writes the BDD in dot format to
to file FileName.
- rand_seed(+Seed:int) is det
- The pseudo-random number generator is initialized using the argument passed as Seed.
It calls the C function srand.
- orc(++A:couple, ++B:couple, --AorB:couple) is det
- A and B are couples (Environment, BDDA) and (Environment, BDDB) respectively
Returns in AorB a couple (Environment, BDDAorB) where BDDAorB is pointer to a BDD belonging to environment Environment
representing the disjunction of BDDs BDDA and BDDB.
Undocumented predicates
The following predicates are exported, but not or incorrectly documented.
- instanceOf(Arg1, Arg2, Arg3)
- instanceOf(Arg1, Arg2, Arg3, Arg4)
- all_instanceOf(Arg1, Arg2, Arg3)
- kb_prefixes(Arg1)
- onec(Arg1, Arg2)
- zeroc(Arg1, Arg2)
- andc(Arg1, Arg2, Arg3, Arg4)
- andcnf(Arg1, Arg2, Arg3, Arg4)
- bdd_notc(Arg1, Arg2, Arg3)
- ret_probc(Arg1, Arg2, Arg3)
- equalityc(Arg1, Arg2, Arg3, Arg4)
- or_list(Arg1, Arg2, Arg3)
- or_listc(Arg1, Arg2, Arg3)
- gamma_sample(Arg1, Arg2, Arg3)
- gauss_sample(Arg1, Arg2, Arg3)
- uniform_sample(Arg1)
- dirichlet_sample(Arg1, Arg2)
- symmetric_dirichlet_sample(Arg1, Arg2, Arg3)
- discrete_sample(Arg1, Arg2)
- initial_values(Arg1, Arg2)
- add_decision_var(Arg1, Arg2, Arg3)
- probability_dd(Arg1, Arg2, Arg3)
- add_prod(Arg1, Arg2, Arg3, Arg4)
- add_sum(Arg1, Arg2, Arg3, Arg4)
- ret_strategy(Arg1, Arg2, Arg3, Arg4)
- debug_cudd_var(Arg1, Arg2)