Constraint propagation using Projection rule - constraints

I've found this example of constraint propagation using projection rule
We have
C = { x1 ≠ x2, x1 ≥ x2 }
< C; x1 ∈ {1,2,3}, x2 ∈ {1,2,3} >
They say that applying propagation rule, does not give any simplification.
I'm not sure why this is the case. Shouldn't we get?
< C; x1 ∈ {2,3}, x2 ∈ {1,2} >
Other steps in the example, make sense that to me, e.g.
< C; x1 ∈ {2}, x2 ∈ {1,2,3} >
produces
< C; x1 ∈ {2}, x2 ∈ {1} >

Note that the constraint in your example is x1 >= x2, and not x1 > x2.
Given that the iniital domains are {1,2,3} for both variables, neither x1 >= x2 nor x1 != x2 can be used to draw any conclusions.

Related

How can I define a set of linear constraints for the condition: "if x1 ≤ 0, then x2 ≤ 0"?

As the question suggests, I'm trying to define linear constraints for the condition "if x1 ≤ 0, then x2 ≤ 0" with x1, x2 in [-10, 10]. I have tried doing this as follows, where B1 is a binary variable and M is a very large number:
X2 - M * X1 * B1 ≤ 0
X1 ≤ 11 * B1
-11 * B1 ≤ X1
The idea is that b1=1 if x>0 and b1=0 if x1≤0. However, this is incorrect because when x1 = 0, we have that b1 can be both 0 or 1. I don't know how to change this without using strict inequalities, which is not possible. Can anyone help?
X2 - M * X1 * B1 ≤ 0 looks non-linear to me. Here is my proposal:
x1 ≥ 0.001 - 10.001*b
x2 ≤ 10*(1-b)
b ∈ {0,1}
The 0.001 is there to force b=1 when x1=0.

{0,1} as function type in Isabelle

I'm trying to write a function that takes a second parameter that can be either 0 or 1:
typedef f_2 = "{0::nat,1}"
function proj_add :: "(real × real) × f_2 ⇒ (real × real) × f_2 ⇒ (real × real) × f_2" where
"proj_add ((x1,y1),l) ((x2,y2),j) = ((add (x1,y1) (x2,y2)), (l+j) mod 2)"
if "delta x1 y1 x2 y2 ≠ 0"
| "proj_add ((x1,y1),l) ((x2,y2),j) = ((ext_add (x1,y1) (x2,y2)), (l+j) mod 2)"
if "delta' x1 y1 x2 y2 ≠ 0"
If I write directly {0::nat,1} I get the error inner syntax error.
If I write f_2 I get the error undefined type name f_2.
What is the right way to write this definition in Isabelle?
There is the type bit in the theory HOL-Library.Bit with the two elements 0 and 1. This contains all the setup that's needed to make the 0 and 1 notation work for bits including pattern matching.

Find Constraint network - arc-consistency

I have a question about an arc consistency network example. its nothing with code.
i have a network R with Variables X = {x1, x2, x3, x4, x5, x6, x7, x8} and Domains D = {1,2,3,4}.
This are my constraints:
I have the solution fromy my professor. But i dont understand what happend with C24 / why nothing happend with C24.
I think D2 is 2,3,4 and D4 is default 1,2,3,4. If x2 is not equal x4 (C24), x4 should be 1. I hope someone could help me.
A constraint c(xi,xj) is arc-consistent iff for every value a∈Di there exists a value b∈Dj such that c(a,b) is true (and vice versa with i and j swapped).
If your constraint is xi < xj, then the situation Di={1,2,3}, Dj={1,2,3,4} is not arc-consistent because there is no xi∈{1,2,3} that makes xi < 1 true. To get arc-consistency, you must eliminate 1 from Dj.
However, with the constraint xi ≠ xj and Di={1,2,3}, Dj={1,2,3,4} you already have arc-consistency, because for every xj∈{1,2,3,4} there exists an xi∈{1,2,3} that makes xi ≠ xj true (and for every xi∈{1,2,3} there exists an xj∈{1,2,3,4} that makes xi ≠ xj true).

Using symbol font / math notation in graphviz

[Environment: graphviz 2.38 / Windows 7]
Using dot, I want to produce path diagrams like the following to represent a structural equation model (well, here, just a simple one-factor measurement model). I'd like to use Greek letters for some nodes and edges, and would actually prefer if I could use LaTeX-like notation in the dot file like \ksi, \lambda_1 or \delta_1
This diagram is supposed to represent the three equations
\begin{eqnarray*}
x_{1i} & = & \lambda_1 \xi_{i} + \delta_{1i} \\
x_{2i} & = & \lambda_2 \xi_{i} + \delta_{2i} \\
x_{3i} & = & \lambda_3 \xi_{i} + \delta_{3i}
\end{eqnarray*}
The closest I've come to this is the following .dot file kludge, where I
chose font="Symbol" and replaced the Greek letters by their roman equivalents.
However, this doesn't work with dot -Tpdf or AFAICS any other devices other
than Postscript dot -Tps, giving me an .eps file I have to convert to PDF or PNG.
Question: is there anything better for this situation?
digraph threevar {
rankdir=LR;
size="8,4";
node [fontname="Helvetica" fontsize=14 shape=box];
edge [fontname="Symbol" fontsize=10];
center=1;
{rank=min k }
{rank=same X1 X2 X3 }
{rank=max z1 z2 z3 }
z1 [shape=circle fontname="Symbol" label="d1"];
z2 [shape=circle fontname="Symbol" label="d2"];
z3 [shape=circle fontname="Symbol" label="d3"];
k [fontname="Symbol" label="x" shape="ellipse"];
k -> X1 [label="l1"];
k -> X2 [label="l2"];
k -> X3 [label="l3"];
z1 -> X1;
z2 -> X2;
z3 -> X3;
}
OK, using UTF8 characters directly in the .dot file, I can now avoid the Symbol font kludge (but what I tried for subscripts, e.g., subscript-one,
x2081 just have a small box containing '2081')
Here's the revised file, that now works with both -Tpdf and -Tpng. (The UTF8 characters don't appear properly in this post.)
digraph threevar {
rankdir=LR;
size="8,4";
node [fontsize=14 shape=box];
edge [fontsize=10];
center=1;
{rank=min k }
{rank=same X1 X2 X3 }
{rank=max z1 z2 z3 }
z1 [shape=circle label="d1"];
z2 [shape=circle label="d2"];
z3 [shape=circle label="d3"];
k [label="?" shape="ellipse"];
k -> X1 [label="?1"];
k -> X2 [label="?2"];
k -> X3 [label="?3"];
z1 -> X1;
z2 -> X2;
z3 -> X3;
}
The result is:

Datatype equality in higher order logic

Having the following theory:
theory BitVector
imports Main
begin
datatype bitvector = BTM | BITV bool bitvector
lemma "∀ x1 x2 y1 y2. (BITV x1 x2 = BITV y1 y2) = (x1=y1) ∧ (x2=y2)"
I get the following proof state:
proof (prove): step 0
goal (1 subgoal):
1. ∀x1 x2 y1 y2. (BITV x1 x2 = BITV y1 y2) = (x1 = y1) ∧ x2 = y2
Auto Quickcheck found a counterexample:
x1 = False
x2 = BITV True BTM
y1 = False
y2 = BTM
What kind of equality is this here? It is obvious that it is not the structural equality that is of Standard ML. Or, is there a bug in this formalisation?
Be careful with equality of boolean-type expressions. Due to operator precedence, the proposition of your lemma is actually the following:
lemma "∀ x1 x2 y1 y2. ((BITV x1 x2 = BITV y1 y2) = (x1=y1)) ∧ (x2=y2)"
This is obviously false. What you should write is:
lemma "∀ x1 x2 y1 y2. (BITV x1 x2 = BITV y1 y2) = ((x1=y1) ∧ (x2=y2))"
In fact, due to these operator precedence issues, I prefer using ⟷ for equality of boolean expressions:
lemma "∀ x1 x2 y1 y2. BITV x1 x2 = BITV y1 y2 ⟷ x1 = y1 ∧ x2 = y2"
Moreover, one would normally write a lemma such as this without the HOL universal quantifiers and instead use the following, which is equivalent:
lemma "BITV x1 x2 = BITV y1 y2 ⟷ x1 = y1 ∧ x2 = y2"
All of these lemmas are easily proven by the simplifier, as they are direct consequences of the injectivity lemmas that are automatically provided by the datatype command.
I should also mention that instead of defining bit vectors yourself, you may want to use the predefined formalisation of bit vectors in src/HOL/Word. Some examples exist in src/HOL/Word/Examples.

Resources