Did you know ... Search Documentation:
Pack trill -- prolog/trill.pl
PublicShow source

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
- 5.2.1
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.
 instanceOf(:Class:concept_description, ++Ind:individual_name, -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 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)
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.
 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)
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.
 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)
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.
 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)
This predicate returns one explanation for the inconsistency of the loaded knowledge base.
 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.

Re-exported predicates

The following predicates are re-exported from other modules

 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.
 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.
 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_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.
 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.
 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.
 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.
 ret_prob(++Environment:int, ++BDD:int, -Probability:float) is det
Returns the Probability of BDD belonging to environment Environment.
 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.
 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.
 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.
 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.
 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_vit_prob(++Environment:int, ++BDD:int, -Probability:float, -MPEState:list) is det
Returns the MPE (Viterbi) state MPEState of BDD and its Probability. BDD belongs to environment Environment.
 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.
 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(++Env:int, ++BDD:int, ++File:string) is det
The predicate writes the BDD in dot format to to file FileName.
 create_dot_string(++Env:int, ++BDD:int, -Dot:string) is det
The predicate returns the BDD in dot format.
 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.
 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.

Undocumented predicates

The following predicates are exported, but not or incorrectly documented.

 init_trill(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)
 compute_best_strategy(Arg1, Arg2, Arg3, Arg4, Arg5)
 debug_cudd_var(Arg1, Arg2)