A Markov logic network (MLN) is a probabilistic logic which applies the ideas of a Markov network to first-order logic, defining probability distributions on possible worlds on any given domain.
In 2002, Ben Taskar, Pieter Abbeel and Daphne Koller introduced relational Markov networks as templates to specify Markov networks abstractly and without reference to a specific domain. Work on Markov logic networks began in 2003 by Pedro Domingos and Matt Richardson. Markov logic networks is a popular formalism for statistical relational learning.
A Markov logic network consists of a collection of formulas from first-order logic, to each of which is assigned a real number, the weight. The underlying idea is that an interpretation is more likely if it satisfies formulas with positive weights and less likely if it satisfies formulas with negative weights.
For instance, the following Markov logic network codifies how smokers are more likely to be friends with other smokers, and how stress encourages smoking:In the previous example, the weight of formula is 2.0 while the weight of formula is 0.5.
Formally, a Markov logic network is a set of pairs of the form where is any first-order formula and is the weight of the formula.
Recall that a domain is a set of elements and variables are interpreted as elements of that set. For instance, . Together with a given domain, a Markov logic network defines a probability distribution on the set of possible worlds, i.e. all interpretations of its predicates on the given domain.
For any -ary predicate symbol that occurs in the Markov logic network and every -tuple of domain elements, is a grounding of . For instance, is a grounding of . These groundings are called ground atoms.
Similarly, a grounding of a formula in an instantiation of in which free variables have been replaced by elements of the domain, with respect to some variable assignment. For instance, is an grounding of . that makes true in that interpretation.
A possible world (also called an interpretation) is given by allocating a Boolean truth value (true or false) to each ground atom.
Then the probability of a possible world is directly proportional to , where is the weight of the -th sentence of the Markov logic network and is the number of groundings of the -th sentence that are true in .

This can also be seen as inducing a Markov network whose nodes are the ground atoms. The feature functions of this network are the groundings of the sentences occurring in the Markov logic network, with value if the grounding is true and 1 otherwise (where again is the weight of the formula).
The probability distributions induced by Markov logic networks can be queried for the probability of a particular event, given by an atomic formula (marginal inference), possibly conditioned by another atomic formula.
Marginal inference can be performed using standard Markov network inference techniques over the minimal subset of the relevant Markov network required for answering the query. Exact inference is known to be #P-complete in the size of the domain.
In practice, the exact probability is often approximated. Techniques for approximate inference include Gibbs sampling, belief propagation, or approximation via pseudolikelihood.
The class of Markov logic networks which use only two variables in any formula allows for polynomial time exact inference by reduction to weighted model counting.