next up previous
Next: 2.4 Weight Learning Up: 2 Notes on Code Previous: 2.2 Parser


2.3 Logic

The logic/ directory contains classes related to first-order logic. PredicateTemplate represents a predicate declaration, while a Predicate is its definition. Likewise for FunctionTemplate and Function. Observe that the code for Predicate and Function is similar, and we could have made one the superclass of the other. However, we avoided polymorphism for the sake of inlining their functions. A Term represents a constant, a variable or a function. A Predicate contains one or more Terms. Clause is an array of Predicates, and contains the important functions for counting the number of true groundings of a clause, and for finding unknown ground clauses. ClauseFactory creates clauses for structure learning. It includes a function validClause() in which you can specify rules to restrict the kinds of clauses created. ClauseSampler contains an algorithm that estimates the number of true groundings of a clause by sampling the clause's groundings. It uses TrueFalseGroundingsStore to store groundings of predicates. MLN represents a Markov Logic Network with a set of Clauses. clausehelper.h and mlnhelper.h contains the auxiliary data structures used by Clause and MLN respectively. Database provides the truth values of ground Predicates (ground atoms), and keeps the truth values of all ground atoms in memory. GroundPreds is a data structure for holding ground Predicates, and is mainly used for testing purposes. A Domain contains the declared types, constants, predicates, and functions, and provides information about them (e.g., the number of constants of a type). It also holds a pointer to a Database. The class VariableState represents the state of all predicates and clauses while performing learning or inference. Besides holding all ground predicates and clauses generated from its MLN and domain, it contains many data structures and indices which allow fast access to information about the state. It encapsulates the eagerness or laziness of the state (i.e. if all ground clauses are built upfront or just when needed). This allows us to implement inference and learning algorithms based on this state without worrying about the differences in a lazy and an eager implementation.


next up previous
Next: 2.4 Weight Learning Up: 2 Notes on Code Previous: 2.2 Parser
Marc Sumner 2007-01-16