0

I have been dealing with this problem for days but still no solution. Let me explain it on a simple example.

Assume there is an array of integers with length 8. Every cell can take certain values. First 4 cells can take 0 or 1 and the other half can take 0, 1 or 2. These 3 arrays can be some examples.

{1,1,0,1,2,1,0,2}
{1,0,0,1,0,0,2,2}
{0,0,0,0,2,0,0,1}

However there are some constraints to construct the arrays as follows:

constraint1 = {0,0,-,-,-,-,-,-}  // !(constraint1[0]==0 && constraint1[1]==0) 
constraint2 = {-,1,0,-,-,-,-,-}  // !(constraint2[1]==1 && constraint2[2]==0) 
constraint3 = {-,-,-,-,1,1,-,0}  // !(constraint3[4]==1 && constraint3[5]==1 && constraint3[7]==0) 

For better understanding;

{0,1,0,2,0,1,0,0}  // this is not valid, because it violates the constraint2
{0,0,2,2,1,1,0,1}  // this is not valid, because it violates the constraint1
{1,1,1,0,0,1,0,0}  // this is valid, because it violates none of the constraints

The question is that I need to find the number of inferred t-tuples (t-length) from these constraints. For example, assume that one of the generated array which does not violate any of the constraints is called myArray. If you look at constraint1, it indicates that if myArray[0] is 0, no matter what myArray[1] has to be 1. Because myArray[1] can take only 0 and 1 and if it gets 0, then it will violate the constraint1. Hence;

myArray[0]=0 => myArray[1]=1

Now if we look at the constraint2 , it says that if myArray[1] is 1 then myArray[2] can not be 0. Since in our case we already choose that myArray[1] is 1, myArray[2] will be 0.

myArray[1]=1 => myArray[2]=0

When these implications are combined, one more constraint is formed as;

myArray[0]=0 => myArray[1]=1 => myArray[2]=0
myArray[0]=0 => myArray[2]=0  // new constraint
{2,-,0,-,-,-,-,-}

I want to strictly emphasize that this is a very simple example only to illustrate you the problem. In my case, the length of the arrays are changing between 50-200. Number constraints can be anything between 0 and 500 (maybe even more). I also want to emphasize that all I need is number of the inferred constraints, no need to find them.

Here are some approaches that I have tried;

1) Find the truth table of the options for constraints those have same at least one common option. Then, look for all t-tuples. It turned out that the space is very big.

2) Find all the solution which does not violates constraints in mathematica (satisfiable problem), then look for which t-tuples are missing. It can not find even one solution.

The problem is that in these approaches I have tried to generate whole space which I do not need. Is there any better ideas to find number of t-tuples (constraints) without enumerating whole space?

genclik27
  • 323
  • 1
  • 7
  • 18
  • Doesn't your third example violate both constraint 2 and 3? Did you mean `[1,1,0,0,1,1,0,0]`? By the way, when talking about Python you may want to use Python's list syntax, curly brackets are used for sets. – filmor Dec 06 '14 at 09:33
  • Never mind, had it the wrong way round... – filmor Dec 06 '14 at 09:34

0 Answers0