Say I have a list
List1={
{1, *, *, *}, {*, 1, *, *}, {*, *, 1, *}, {*, *, *, 1},
{0, *, *, *}, {*, 0, *, *}, {*, *, 0, *}, {*, *, *, 0}
}
Let intersection function meet(a,b) is the function of two variables $a$ and $b$ from the list List1$\times$List1 (the elements of List1 themselves are lists of equal length); The function should do the following:
IF there is no $i$ with ($a_i=1$ and $b_i=0$) OR ($a_i=0$ and $b_i=1$)
then meet(-,-) adds as an element (by Union[-,-])to the List1
the list $m$ of the same length as $a$ and $b$, such that for each $i$If ($a_i=1$ and $b_i=*$) OR ($a_i=*$ and $b_i=1$) OR ($a_i=1$ and $b_i=1$) then $m_i=1$,
else if ($a_i=0$ and $b_i=*$) OR ($a_i=*$ and $b_i=0$) OR ($a_i=0$ and $b_i=0$) then $m_i=0$,
else (if we have $a_i=*$ and $b_i=*$) $m_i=*$
ELSE (i.e. if there is $i$ with $a_i=1$ and $b_i=0$ OR $a_i=0$ and $b_i=1$)
adds nothing to the List1 (does nothing).
I want to iterate meet(-,-) on the List1 to add all such intersections until the operation terminates.
In particular the intersection of two elements of List1
{1, *, *, *}
and
{*, 1, *, *}
is as described above a list (an element)
{1, 1, *, *}
since this element is not yet in List1, then meet({1, *, *, },{, 1, *, *}) adds this element to the List1
while
{1, *, *, 0}
and
{*, 1, *, 1}
have no intersecton (since on 4th place we have 0 and 1 respectively) and hence the function adds nothing to the List1
Finally I want to have List1 equal to
{
{1, 1, 1, 1}, {1, 1, 1, 0}, {1, 1, 1, *}, {1, 1, 0, 1}, {1, 1, 0, 0}, {1, 1, 0, *},
{1, 1, *, 1}, {1, 1, *, 0}, {1, 1, *, *}, {1, 0, 1, 1}, {1, 0, 1, 0}, {1, 0, 1, *},
{1, 0, 0, 1}, {1, 0, 0, 0}, {1, 0, 0, *}, {1, 0, *, 1}, {1, 0, *, 0}, {1, 0, *, *},
{1, *, 1, 1}, {1, *, 1, 0}, {1, *, 1, *}, {1, *, 0, 1}, {1, *, 0, 0}, {1, *, 0, *},
{1, *, *, 1}, {1, *, *, 0}, {1, *, *, *}, {0, 1, 1, 1}, {0, 1, 1, 0}, {0, 1, 1, *},
{0, 1, 0, 1}, {0, 1, 0, 0}, {0, 1, 0, *}, {0, 1, *, 1}, {0, 1, *, 0}, {0, 1, *, *},
{0, 0, 1, 1}, {0, 0, 1, 0}, {0, 0, 1, *}, {0, 0, 0, 1}, {0, 0, 0, 0}, {0, 0, 0, *},
{0, 0, *, 1}, {0, 0, *, 0}, {0, 0, *, *}, {0, *, 1, 1}, {0, *, 1, 0}, {0, *, 1, *},
{0, *, 0, 1}, {0, *, 0, 0}, {0, *, 0, *}, {0, *, *, 1}, {0, *, *, 0}, {0, *, *, *},
{*, 1, 1, 1}, {*, 1, 1, 0}, {*, 1, 1, *}, {*, 1, 0, 1}, {*, 1, 0, 0}, {*, 1, 0, *},
{*, 1, *, 1}, {*, 1, *, 0}, {*, 1, *, *}, {*, 0, 1, 1}, {*, 0, 1, 0}, {*, 0, 1, *},
{*, 0, 0, 1}, {*, 0, 0, 0}, {*, 0, 0, *}, {*, 0, *, 1}, {*, 0, *, 0}, {*, 0, *, *},
{*, *, 1, 1}, {*, *, 1, 0}, {*, *, 1, *}, {*, *, 0, 1}, {*, *, 0, 0}, {*, *, 0, *},
{*, *, *, 1}, {*, *, *, 0}
}
What is a efficient way to do such expansion of an initial list List1 effectively in Wolfram Mathematica?
List2={{1, "*", "*"}, {"*", 1, "*"}, {"*", "*", 0}}
? $\endgroup${1, *, *, 1}
and{*, 1, *, 0}
? $\endgroup$