Inference

In brief, inference in Markov Logic Networks (MLNs), is the process of estimating the marginal probability or the most probable truth state of the groundings of some query atoms, given a MLN theory (i.e., a collection of weighted formulas) and a collection of imput ground evidence atoms (i.e., input ground predicates with known truth state).

Types of inference in LoMRF

In order to perform inference, we have to define the following: * The type of the inference. In LoMRF two types of inference can be performed: 1. Marginal inference: computes the probabilities for all possible instantiations of query predicates of being true, given the evidence. 2. Maximum a-posteriori inference (MAP): computes the truth values (0 = False and 1 = True) of all possible instantiations (groundings) that together represent the most probable state. * Input theory file, e.g., theory.mln. * Input evidence, e.g., evidence.db. * Output result file, e.g., output.result. * The atomic signatures (identities) that define the query predicates ('-q' option). Please note that for all query predicates LoMRF takes Open-world assumption. * (Optionally) The atomic signatures (identities) that define predicates with Closed-world assumption ('-cwa' option). By default, all evidence predicates have Closed-world assumption. * (Optionally) The atomic signatures (identities) that define predicates with Open-world assumption ('-owa' option). By default, all non-evidence predicates have Open-world assumption.

Inference using the lomrf command-line tool

To demonstrate the usage of LoMRF from command-line interface, assume that we have one knowledge base file, named as theoy.mln, and one evidence file, named as evidence.db.

In our example knowledge-base we have the following predicates:

Predicate Name Number of arguments Predicate identity Description
Query_A 2 Query_A/2 first query predicate (Open-world assumption)
Query_B 2 Query_B/2 second query predicate (Open-world assumption)
Ev_A 1 EV_A/1 first evidence predicate (Closed-world assumption)
Ev_B 1 EV_B/1 second evidence predicate (Closed-world assumption)
Hidden 1 Hidden/1 non-evidence predicate (Open-world assumption)

As it is presented in the above table, there are two query predicates, Query_A and Query_B, where each one takes two terms as arguments. Therefore their atomic signatures are Query_A/2 and Query_B/2. Similarly, there are two evidence predicates Ev_A and Ev_B that they take one term as argument. Therefore, the atomic signatures of Ev_A and Ev_B are Ev_A/1 and Ev_B/1, respectively. Finally, there is one non-evidence predicate, named as Hidden, that takes one term as argument, thus it's signatures is Hidden/1.

Marginal inference

Marginal inference computes the conditional probability of query predicates, given some evidence.

lomrf infer -inferType marginal -i theory.mln -e evidence.db -r marginal-out.result -q Query_A/2,Query_B/2 -cwa Ev_A/1,Ev_B/1 -owa Hidden/1

Since Hidden/1 is a non-evidence atom and thus does not contain any facts in the evidence.db, we can omit the -owa parameter. Furthermore, when the evidence file (evidence.db) contains at least one fact for Ev_A/1 and Ev_B/1 predicates, then we can also omit the parameter -cwa. In that case, LoMRF can automatically infer which predicates have Open-world or Closed-world assumption. As a result, we can simply give the following parameters and take the same results:

lomrf infer -inferType marginal -i theory.mln -e evidence.db -r marginal-out.result -q Query_A/2,Query_B/2

Also the default inference type for LoMRF is marginal, we can further simplify the example given the following parameters:

lomrf infer -i theory.mln -e evidence.db -r marginal-out.result -q Query_A/2,Query_B/2

The results from marginal inference are stored in the marginal-out.result (see parameter -r)

MAP inference

MAP inference, on the other hand, identifies the most probable assignment among all query predicate instantiations that are consistent with the given evidence. This task reduces to finding the truth assignment of all query predicate instantiations that maximises the sum of weights of satisfied ground clauses. This is equivalent to the weighted maximum satisfiability problem.

lomrf infer -inferType map -i theory.mln -e evidence.db -r map-out.result -q Query_A/2,Query_B/2 -cwa Ev_A/1,Ev_B/1 -owa Hidden/1

or simply:

lomrf infer -inferType map -i theory.mln -e evidence.db -r map-out.result -q Query_A/2,Query_B/2

The results from MAP inference are stored in the map-out.result (see paramter -r)

Probabilistic Inference Examples

See Sections Probabilistic Inference Examples and Temporal Probabilistic Inference Examples. Sources from the examples are located in the LoMRF-data project (follow the instructions in Download Example Data).

Command-line Interface Options

By executing the lomrf infer -h (or lomrf infer --help) command from the command-line interface, we take a print of multiple parameters. Below we explain all LoMRF inference command-line interface parameters:

Basic inference options

Advanced inference options

By default, LoMRF outputs all groundings with their truth values.