# State-dependent independence in graphical models

I have a graphical model with binary variables Y, X1, X2, and observed data D.

D depends on Y X1 and X2 depend on Y

When Y is false, X1 and X2 are independent:

(D) <-- (Y) --> (X1)
|
V
(X2)


However, when Y is true, X1 and X2 are not independent and must be modeled in a joint manner:

(D) <-- (Y) --> (X1,X2)


I've tried putting in an "edge" variable E between X1 and X2 that is influenced by Y; I can get the correct behavior when Y is false, but not when Y is true:

(D) <-- (Y) --> (X1)
|       ^
V       E
(X2) <- /


(that is Y --> E and E --> X1 and E --> X2)

If I reverse the directed edges so that they point from X1 and X2 to E, then the moral graph once again always treats X1 and X2 as joint.

So I can't seem to encode state-dependent independence...

Is there established theory about such networks (if so what is this relationship called)? Is there a way to encode or transform the graph with temporary variables or something so that, if you know given D, Y must be false, that you can use the first graph (where X1 and X2 are independent given Y), and have faster inference?

Of course, I should point out that this is a toy example; the real one is huge.

Thank you very much for your help. And sorry for the ascii graphs, I was raised by wolves.