The Mathematica Journal
Download This Issue
Feature Articles
Graphics Gallery
Tricks of the Trade
In and Out
The Mathematica Programmer
New Products
New Publications
News Bulletins
Editor's Pick
Write Us
About the Journal
Staff and Contributors
Back Issues

Puzzle 2

The Problem

In February 1996, Robert Israel posed the following problem in the newsgroup sci.math.symbolic.

Given the following expression [Graphics:../Images/index_gr_43.gif],


is [Graphics:../Images/index_gr_45.gif] always equal to 1 if one substitutes 0 or 1 for all variables?

The Solution

The question of is [Graphics:../Images/index_gr_46.gif] for all realizations can be answered using Groebner basis techniques in a straightforward fashion. To make this puzzle more interesting, let's not only answer the question stated here, but also the case of any realizations for which [Graphics:../Images/index_gr_47.gif]. The problem turns out to be quite similar to Puzzle #1.

The variables of [Graphics:../Images/index_gr_48.gif] are


In this case there are about 67 million different substitutions.


Let's try a few randomly chosen substitutions.


This looks like the conjecture is true, but of course it is no proof. The resulting numbers will be larger than machine integers.  So, we don't want to try all of the possibilities, since using integer bignum arithmetic will make the whole calculation time consuming.

[Graphics:../Images/index_gr_58.gif] has the structure product+1. For the whole expression to be [Graphics:../Images/index_gr_59.gif], product should be 1. This means we must look for realizations where the factors of the product are [Graphics:../Images/index_gr_60.gif].

[Graphics:../Images/index_gr_61.gif] is a list of the factors of [Graphics:../Images/index_gr_62.gif].


The function make1 calculates the substitution rules for the variables of expr, so the resulting expression is [Graphics:../Images/index_gr_64.gif].


Here is a test of make1.


The function combineRealizations combines two realizations into a new set of feasible ones.


Here is another example.


Having implemented all the necessary functions, we can perform the actual search. We step through all factors and keep only the compatible realizations. To do this efficiently, we need to address the situation where we have too many compatible realizations in the intermediate stages.  To solve this problem we can use a simple rule.  At a given stage, we choose the next set of factors so that the set has the most variables in common with the variables already determined.

We define a function variables that yields the variables of a given realization.


The list actualLength acts as a container for counting the number of realizations permitted in the intermediate steps.


We found only 715 possible solutions that obey our constraint. 715 solutions out of [Graphics:../Images/index_gr_85.gif] possibilities means that only about 0.002 percent of all possible realizations work. This explains why the above experiment, using just a dozen random realizations, failed to give a single 0.

Let us verify the solutions found.


Here is a graphic showing the number of realizations we had in intermediate steps.



We actually can shorten the list of solutions. Looking at them, one sees pairs that are only different in the realization of one variable, which means this variable doesn't matter at all. We will unite them into one solution, replacing 0 or 1 in such pairs by [Graphics:../Images/index_gr_90.gif]. For efficiency, we can use the numbers themselves, dropping the Rule and the variable name (which uniquely follows from its position).


First, we unite solutions which are adjacent after sorting.


With this smaller list, we also can search for nonadjacent pairs.


So, we have only 79 unique realizations. To check this, we can see that by replacing the constant [Graphics:../Images/index_gr_99.gif] with 0 and 1, we are back to our original 715 solutions.


We can display the 79 compactified solutions in the form of a table where a dash "-" indicates that this variable can take either the value 0 or 1.



Converted by Mathematica      October 5, 1999

[Prev Page][Next Page]