Simplification, Optimisation, Implication
Definition: Simplification
The process of replacing a constraint by another which has a simpler form, but is equivalent (in some sense)
Definition: Implication
Constraint C1 implies constraint C2: C1® C2, if every solution of C1 is a solution of C2
Definition: Redundancy
Constraint C2 is redundant with respect to C1 if C1® C2
The elimination of redundant constraints is a form of simplification
The transformation of a constraint to an equivalent normalised form often results in simplification
Projection
It is often the case that we are interested in the possible values of only some of the variables in a constraint
Definition: projection
A projection of a constraint C1 onto a variable set V is a constraint C2 such that
Example: Fourier Elimination Algorithm
Applies to linear inequality constraints
Weak Projection
Some constraint domains do not permit simple projection (essentially, the extra variables permit constraints to be imposed that cannot be imposed without them - see the successor example in the text)
Definition: Simplifier
A simplifier is an algorithm which takes a constraint C1 and a set of variables V and returns a new constraint C2 which is equivalent to C1 with respect to V
Definition: Weak Projection
A simplifier isweakly projecting if the simplication of C1 with respect to V is the smallest constraint which is equivalent to C1 with respect to V
Example: Tree Constraint Simplifier
Assume a tree constraint C is to be simplified with respect to variable set V
Optimisation
Definition: Optimisation Problem
An optimisation problem (C,f) consists of a constraint problem C, together with an objective function f which gives a real value to every valuation of the variables in C
Definition: Optimal Solution
An optimal solution to an optimisation problem (C,f) is a solution of C which has a lower value under f than any other solution of C
Example: Simplex Algorithm
This has been covered (briefly) by John
Constraint Logic Programming
Rules, Facts, Predicates
Rules are written
A :- B.
(read "if B then A" or "A if B")
B (the body) may contain any number of literals (primitive or user-defined constraints),
If B contains no literals, the rule is written
A.
and is called a fact
A (the head) is only allowed to contain one user-defined constraint, of the form
p(X1, ,Xn)
There may be more than one rule for a given predicate p; they are normally all grouped together when a program is written.
Rule Examples
Voltage Divider

Kirchhoff's laws give the equations
V1 = I * R1
VD = I2 * R2
V = V1 + V2
I = I2 + ID
We can write a rule which specifies that the given circuit is a voltage divider:
voltage_divider(V,I,R1,R2,VD,ID) :-
V1 = I * R1,
VD = I2 * R2,
V = V1 + V2,
I = I2 + ID.
Suppose we have 5, 9 and 14W resistors available, and 9 or 12V cells. We can specify this by
resistor(5).
resistor(9).
resistor(12).
cell(9).
cell(12).
If we want an output voltage of between 5.4 and 5.5V, with a divider current of 0.1A, we would specify this as
5.4 £ VD.
VD £ 5.5.
ID = 0.1.
Overall, then, our goal is
voltage_divider(V,I,R1,R2,VD,ID),
resistor(R1),
resistor(R2),
cell(V),
5.4 £ VD,
VD £ 5.5,
ID = 0.1.
We can rewrite the goal using the rules above; there are three possible rewrites for each of the two 'resistor' goals, and two for the 'cell' goal, giving a total of 12; of these, only one reduces to a satisfiable constraint, giving
V=9
R1=5
R2=9
Note that one of the commonest uses of divider circuits arises when the resistances R1 and R2 are combined into a variable resistor with a fixed total resistance R, and a contact sliding along the resistor dividing it into R1 and R2; this is usually drawn:

Factorial Function
N! = 1 if N = 0
N! = N * (N - 1)! If N ³ 1
In constraint logic programming, this would come out as
fac(0, 1).
fac(N, N * F) :-
N >= 1,
fac(N - 1, F).
Given the goal
fac(2, X).
we could rewrite by the second rule to
2=N, X = N * F, N ³ 1, fac(N - 1, F)
and again to
2=N, X = N * F, N ³ 1, N - 1 = N', F = N' * F', N' ³ 1, fac(N' - 1, F')
finally, applying the first rule gives
2=N, X = N * F, N ³ 1, N - 1 = N', F = N' * F', N' ³ 1, N' - 1 = 0, F' = 1
Simplifying with respect to X gives X = 2
Note that the first two rewritings are forced on us, because rewriting by the first rule would immediately give unsatisfiable constraints
However the last step could be replaced with a further rewriting by the second rule, and indeed this process can continue on forever (though no further satisfiable constraints will be found)
In fact, CLP systems virtually always have the strategy of preferentially rewriting by earlier rules where possible (which is why we write the recursive rule last)