<p>If I understand the question correctly, the problem is easy (once we understand the problem).</p>

<p>As I understand it, you are given a finite set <i>X</i>⊆<i>A</i><sub>1</sub>×…×<i>A</i><sub><i>n</i></sub> and want to find the “best” set <i>I</i>⊆{1,…,<i>n</i>} of indices that is feasible, where we say that a set <i>I</i> is <em>feasible</em> when <i>X</i> can be written as the direct product of the sets <i>A</i><sub><i>i</i></sub> for <i>i</i>∈<i>I</i> and some set of (<i>n</i>−|<i>I</i>|)-tuples (where indices are permuted appropriately).</p>

<p>You consider two formulations of the meaning of “best”: (1) the product ∏<sub><i>i</i>∈<i>I</i></sub> |<i>A</i><sub><i>i</i></sub>| is maximized, (2) the size |<i>I</i>| is maximized.  However, it does not matter which criterion you use because both can be maximized at the same time.</p>

<p>For each <i>i</i>=1,…,<i>n</i>, test whether the singleton set {<i>i</i>} is feasible (this can be done efficiently).  Let <i>J</i> be the set of indices <i>i</i> such that {<i>i</i>} is feasible.  It is easy to see that <i>J</i> is also feasible, and moreover <i>J</i> is the maximum with respect to inclusion among the feasible sets of indices.  Therefore, the index set <i>J</i> maximizes both criteria (1) and (2) stated above.</p>

CC BY-SA 2.5
2011-01-29T23:47:18.927Z
Your solution looks right to me, thanks!  I'd like to know what you had in mind for testing the feasibility of the singletons "efficiently".  The only method I can think of is pretty much "brute force": classify the elements of *X* by their i-th coordinate; {i} is feasible only if all the partitions have the same cardinality; if this is the case, test for equality the set of all (n-1) tuples obtained from the elements of the first partition by discarding their i-th components against the corresponding sets of the remaining partitions.  If all tests pass, {i} is feasible.  Is that it?
kjo
CC BY-SA 2.5
2011-01-29T23:51:52.597Z
@kjo: Yes, that is what I had in mind.  (I would first sort the elements of X with respect to the coordinates except for the i-th, which makes the rest of the test slightly easier, but that is a minor detail.)
Tsuyoshi Ito
CC BY-SA 2.5
2011-01-31T13:05:14.843Z
one more question: the math symbols in your reply don't look like the ones in my question; did you use mathjax?  if not, what did you use?  do you have a good collection of such symbols for cut-and-paste? thnx
kjo
CC BY-SA 2.5
2011-02-01T18:32:05.070Z
@kjo: No, I did not use MathJax in this answer.  I usually avoid MathJax whenever possible because processing MathJax takes some time.  I use Microsoft Office IME which allows me to enter Japanese text, and it has a secondary functionality to enter mathematical and other symbols.  I also have an HTML file with many Unicode symbols.  It was in my local hard drive, but I have put it on the web: http://www.iqc.ca/~tito/unicode-character-index/.  Please let me know if you find it useful.
Tsuyoshi Ito
CC BY-SA 2.5
2011-01-29T22:07:34.927Z
2011-01-30T00:48:49.763Z
2011-01-30T00:48:49.763Z
Tsuyoshi Ito
<p>(NB: I asked this question in Math Overflow, and based on the one reply [a comment, actually] that it received so far, I realized that this may be a more appropriate forum for it.  I've added a few comments to this post, connecting the problem to the theory of databases.)</p>

<p>I'm interested in factoring a finite set of $n$-tuples as the Cartesian product of two "factor sets", of which the first factor is itself the Cartesian product of some of the set's projection images, and the second factor is an unfactorizable "remainder".</p>

<p>To describe the problem more precisely, let $X$ be a non-empty, finite set of $n$-tuples, and let $A_1,...,A_n$ be the images of $X$ upon projection onto its various coordinates.  Hence, $X \subset \prod_{i=1}^{n} A_i $.  Furthermore, assume that this inclusion is strict; that is, $X \neq \prod_{i=1}^{n} A_i $.  (From this it follows that $n &gt; 1$.)  If $\sigma$ is some permutation of $\{1,...,n\}$, let $X_\sigma$ denote the set of $n$-tuples derived from $X$ by permuting the coordinates of its elements according to $\sigma$: $X_\sigma = \{(x_{\sigma(1)},...,x_{\sigma(n)})|(x_1,...,x_n)\in X \}$.  (See the end of this post for a restatement of the problem using OLAP terminology.)</p>

<p>For any $n$-permutation $\sigma$, I'm interested in factorizations of $X_\sigma$ having the form $X_\sigma = (\prod_{i=1}^{k} A_{\sigma(i)}) \times Z$, where $0 \leq k \lt n$ and $Z \subsetneq \prod_{i=k+1}^{n} A_{\sigma(i)}$.  This factorization means that every $n$-tuple in $X_\sigma$ can be written (obviously uniquely) as the concatenation of one $k$-tuple from $\prod_{i=1}^{k} A_{\sigma(i)}$ and one $(n-k)$-tuple from $Z \subsetneq \prod_{i=k+1}^{n} A_{\sigma(i)}$, and, conversely, every concatenation of such tuples represents some element of $X_\sigma$.  (If $k = 0$, then $Z = X_\sigma$; i.e. the factorization is a trivial one.)</p>

<p>I am primarily interested in factorizations for which the factor $\prod_{i=1}^{k} A_{\sigma(i)}$ has maximal cardinality, over all possible choices of $\sigma$ and $k$.  I am also interested in factorizations for which $k$ is maximal, over all possible choices of $\sigma$.  [Edit: both criteria actually lead to the same result; see Tsuyoshi Ito's answer.]</p>

<p>[(This bracketed paragraph is intended by way of background; it is tangential to the questions of this post.  Please disregard it if it is not useful or clear.)  One area where this problem arises is in the theory of databases and OLAP: given a facts table $X$ with $n$ dimension (aka "metadata") columns, how can it be "most efficiently" converted to a collection of perfectly dense (i.e. no empty cells) multidimensional data "(hyper)cubes" having identical domains.  (These domains correspond to the sets $A_{\sigma(1)},...,A_{\sigma(k)}$ above.)  This formulation leaves the optimization criterion fuzzy.  I use the term "efficient" here to describe solutions that pack "as much information as possible" in the regular hypercubes, but even with this clarification the criterion is ill-defined, because "most information" could be defined as "the greatest number of cells" or "the greatest number of dimensions" (i.e. potential explanatory factors) for the regular hypercubes.  These correspond to the two classes of factorizations I described in the previous paragraph.]</p>

<p>I'm looking for keywords I may use to search for algorithms to compute such maximal factorizations, given some concrete set of $n$-tuples $X$.  Do such factorizations, or the problem of computing them, have a name?  Are their complexity classes known?  Any pointers to the relevant literature would be appreciated!</p>

<p>~kj</p>

CC BY-SA 2.5
2011-01-29T18:28:04.787Z
[Crosspost](http://mathoverflow.net/questions/53670/cartesian-factorization-of-a-finite-set-of-n-tuples) in MO.
Hsien-Chih Chang 張顯之
CC BY-SA 2.5
2011-01-29T20:54:44.923Z
The definition of ≅ looks exactly identical to the definition of = to me.  Can you clarify the difference between ≅ and =?
Tsuyoshi Ito
CC BY-SA 2.5
2011-01-29T23:31:14.947Z
My use of ≅ was left over from an earlier version of the write-up, in which the LHS of the factorization expression was just *X*, and the ≅ was meant to denote that a reordering of dimensions may be necessary.  I've fixed it now.  Sorry for the confusion.
kjo
<cc.complexity-theory><ds.algorithms><co.combinatorics><db.databases>
Cartesian factorization of a finite set of n-tuples
kjo
# Cartesian factorization of a finite set of n-tuples

(Asked by: username_0 on 2011-01-29)

(NB: I asked this question in Math Overflow, and based on the one reply [a comment, actually] that it received so far, I realized that this may be a more appropriate forum for it. I've added a few comments to this post, connecting the problem to the theory of databases.)

I'm interested in factoring a finite set of $n$-tuples as the Cartesian product of two "factor sets", of which the first factor is itself the Cartesian product of some of the set's projection images, and the second factor is an unfactorizable "remainder".

To describe the problem more precisely, let $X$ be a non-empty, finite set of $n$-tuples, and let $A\_1,...,A\_n$ be the images of $X$ upon projection onto its various coordinates. Hence, $X \subset \prod\_{i=1}^{n} A\_i $. Furthermore, assume that this inclusion is strict; that is, $X \neq \prod\_{i=1}^{n} A\_i $. (From this it follows that $n > 1$.) If $\sigma$ is some permutation of $\{1,...,n\}$, let $X\_\sigma$ denote the set of $n$-tuples derived from $X$ by permuting the coordinates of its elements according to $\sigma$: $X\_\sigma = \{(x\_{\sigma(1)},...,x\_{\sigma(n)})|(x\_1,...,x\_n)\in X \}$. (See the end of this post for a restatement of the problem using OLAP terminology.)

For any $n$-permutation $\sigma$, I'm interested in factorizations of $X\_\sigma$ having the form $X\_\sigma = (\prod\_{i=1}^{k} A\_{\sigma(i)}) \times Z$, where $0 \leq k \lt n$ and $Z \subsetneq \prod\_{i=k+1}^{n} A\_{\sigma(i)}$. This factorization means that every $n$-tuple in $X\_\sigma$ can be written (obviously uniquely) as the concatenation of one $k$-tuple from $\prod\_{i=1}^{k} A\_{\sigma(i)}$ and one $(n-k)$-tuple from $Z \subsetneq \prod\_{i=k+1}^{n} A\_{\sigma(i)}$, and, conversely, every concatenation of such tuples represents some element of $X\_\sigma$. (If $k = 0$, then $Z = X\_\sigma$; i.e. the factorization is a trivial one.)

I am primarily interested in factorizations for which the factor $\prod\_{i=1}^{k} A\_{\sigma(i)}$ has maximal cardinality, over all possible choices of $\sigma$ and $k$. I am also interested in factorizations for which $k$ is maximal, over all possible choices of $\sigma$. [Edit: both criteria actually lead to the same result; see username_2's answer.]

[(This bracketed paragraph is intended by way of background; it is tangential to the questions of this post. Please disregard it if it is not useful or clear.) One area where this problem arises is in the theory of databases and OLAP: given a facts table $X$ with $n$ dimension (aka "metadata") columns, how can it be "most efficiently" converted to a collection of perfectly dense (i.e. no empty cells) multidimensional data "(hyper)cubes" having identical domains. (These domains correspond to the sets $A\_{\sigma(1)},...,A\_{\sigma(k)}$ above.) This formulation leaves the optimization criterion fuzzy. I use the term "efficient" here to describe solutions that pack "as much information as possible" in the regular hypercubes, but even with this clarification the criterion is ill-defined, because "most information" could be defined as "the greatest number of cells" or "the greatest number of dimensions" (i.e. potential explanatory factors) for the regular hypercubes. These correspond to the two classes of factorizations I described in the previous paragraph.]

I'm looking for keywords I may use to search for algorithms to compute such maximal factorizations, given some concrete set of $n$-tuples $X$. Do such factorizations, or the problem of computing them, have a name? Are their complexity classes known? Any pointers to the relevant literature would be appreciated!

~kj

**Tags:** cc.complexity-theory, ds.algorithms, co.combinatorics, db.databases

> **Comments:**
> **username_1**: [Crosspost](http://mathoverflow.net/questions/53670/cartesian-factorization-of-a-finite-set-of-n-tuples) in MO.  
> **username_2**: The definition of ≅ looks exactly identical to the definition of = to me.  Can you clarify the difference between ≅ and =?  
> **username_0**: My use of ≅ was left over from an earlier version of the write-up, in which the LHS of the factorization expression was just *X*, and the ≅ was meant to denote that a reordering of dimensions may be necessary.  I've fixed it now.  Sorry for the confusion.  

---

## 1 answers

### Answer by username_2 on 2011-01-29. Score: 10 | Accepted answer

If I understand the question correctly, the problem is easy (once we understand the problem).

As I understand it, you are given a finite set *X*⊆*A*1×…×*A**n* and want to find the “best” set *I*⊆{1,…,*n*} of indices that is feasible, where we say that a set *I* is *feasible* when *X* can be written as the direct product of the sets *A**i* for *i*∈*I* and some set of (*n*−|*I*|)-tuples (where indices are permuted appropriately).

You consider two formulations of the meaning of “best”: (1) the product ∏*i*∈*I* |*A**i*| is maximized, (2) the size |*I*| is maximized. However, it does not matter which criterion you use because both can be maximized at the same time.

For each *i*=1,…,*n*, test whether the singleton set {*i*} is feasible (this can be done efficiently). Let *J* be the set of indices *i* such that {*i*} is feasible. It is easy to see that *J* is also feasible, and moreover *J* is the maximum with respect to inclusion among the feasible sets of indices. Therefore, the index set *J* maximizes both criteria (1) and (2) stated above.

> **Comments:**
> **username_0**: Your solution looks right to me, thanks!  I'd like to know what you had in mind for testing the feasibility of the singletons "efficiently".  The only method I can think of is pretty much "brute force": classify the elements of *X* by their i-th coordinate; {i} is feasible only if all the partitions have the same cardinality; if this is the case, test for equality the set of all (n-1) tuples obtained from the elements of the first partition by discarding their i-th components against the corresponding sets of the remaining partitions.  If all tests pass, {i} is feasible.  Is that it?  
> **username_2**: @username_0: Yes, that is what I had in mind.  (I would first sort the elements of X with respect to the coordinates except for the i-th, which makes the rest of the test slightly easier, but that is a minor detail.)  
> **username_0**: one more question: the math symbols in your reply don't look like the ones in my question; did you use mathjax?  if not, what did you use?  do you have a good collection of such symbols for cut-and-paste? thnx  
> **username_2**: @username_0: No, I did not use MathJax in this answer.  I usually avoid MathJax whenever possible because processing MathJax takes some time.  I use Microsoft Office IME which allows me to enter Japanese text, and it has a secondary functionality to enter mathematical and other symbols.  I also have an HTML file with many Unicode symbols.  It was in my local hard drive, but I have put it on the web: http://www.iqc.ca/~tito/unicode-character-index/.  Please let me know if you find it useful.  

---

