constrain(item >= value)
For example, suppose you have written a probabilistic CKY parser. You want to require that all the rewrite rules with a given left-hand side sum to one. So you write
sum_lhs(Lhs) += rewrite(Lhs,_). % unary rewrite rule sum_lhs(Lhs) += rewrite(Lhs,_,_). % binary rewrite rule constrain(sum_lhs(Lhs)==1) |= ?sum_lhs(Lhs). % we constrain sum_lhs(np) if it was derived, % i.e., if there were any rules with np as lhs
If your rewrite rule probabilities are in the logarithmic domain, you would write
logsum_lhs(Lhs) log+= rewrite(Lhs,_). logsum_lhs(Lhs) log+= rewrite(Lhs,_,_). constrain(logsum_lhs(Lhs)==0) |= ?sum_lhs(Lhs).
Of course, a given version of DynaMITE can only handle certain kinds of constraints. The current version can handle sum-to-one constraints in the log domain, as shown above.
- At the moment, DynaMITE expects a slightly different form:
constrain_eq(item,value). Also at the moment, you need to explicitly declare
:- oldquery(constraints, constrain_eq(_,_)). This will become unnecessary in future (and perhaps even invalid, since