ecboghiu / inflation

Implementations of the Inflation Technique for Causal Inference.
GNU General Public License v3.0
22 stars 3 forks source link

Hexagon inflation of the triangle recognizes p(a,b,c) as knowable monomial #137

Closed apozas closed 5 months ago

apozas commented 5 months ago

Describe the bug When writing the hexagon inflation of the triangle, we know that p(a,b,c) cannot be associated to any probability in the inflation, because no marginal of the hexagon realizes a triangle. When writing the LP that would naturally correspond to this inflation, the list known_monomials includes p(a,b,c)

To Reproduce

from inflation import InflationProblem, InflationLP

ip = InflationProblem(dag={"l1": ["A", "B"],
                           "l2": ["B", "C"],
                           "l3": ["C", "A"]},
                      outcomes_per_party=[2, 2, 2],
                      inflation_level_per_source=[2, 2, 2])

lp = InflationLP(ip)

print(lp.known_moments)

# [..., P[A=0 B=0 C=0], ...]

In fact, this already happens with what one would expect to be the code for the cut inflation:

from inflation import InflationProblem, InflationLP

ip = InflationProblem(dag={"l1": ["A", "B"],
                           "l2": ["B", "C"],
                           "l3": ["C", "A"]},
                      outcomes_per_party=[2, 2, 2],
                      inflation_level_per_source=[1, 1, 2])

lp = InflationLP(ip)

print(lp.known_moments)

# [1 P[A=0] P[B=0] P[C=0] P[A=0 B=0] P[A=0 C=0] P[A=0]*P[C=0] P[B=0 C=0]
# P[A^{1,1}_1_0_1=0 B^{1,1}_1_1_0=0 C^{1,2}_0_1_2=0] P[A=0 B=0 C=0]]

Expected behavior We know that the ring inflations are the most general inflations of ring networks (right?), so calling the second-level of the corresponding hierarchy (namely the first snippet I wrote) should give the hexagon inflation.

Also, related: if it's not the ring inflations that the code above generates, which inflations is it generating?

apozas commented 5 months ago

In fact, is it possible that the code above is creating not just the hexagon inflation, but the hierarchy up to level 2? This is, is it creating an inflation that consists of the hexagon (level 2) and the triangle (level 1)? If this is the case, then the code is actually working as it should, indeed.

ecboghiu commented 5 months ago

Yes, I think your understanding is correct. The code works by generating all possible sequences of events which are compatible. By considering all possible sequences of compatible events we take all possible inflations up to some length of sequence of events. I think the length of sequence of events is by default maximal, not sure if local levels for LPs have been implemented yet.

apozas commented 5 months ago

Yes, indeed. Now I have confirmed that the behavior is the one we are guessing (it builds not just the ring inflation at the specified level, but all the previous ones as well). Thank you, and sorry for this.