Theorem. The problem in the post is NP-hard, by reduction from Subset-Sum.
Of course it follows that the problem is unlikely to have a poly-time algorithm as requested by op.
Here is the intuition. The problem in the post is
- Is there a permutation matrix in the span of a given set of matrices?
This is essentially the same as
- Is there a permutation matrix that (thinking of the matrix as a vector) satisfies some given linear constraints?
This in turn is the same as
- Is there a perfect matching (in a complete bipartite graph) whose incidence vector satisfies some given linear constraints?
Reducing Subset-Sum to the latter problem is a standard exercise.
Here is the detailed proof.
Define the following intermediate problem:
Matching-Sum:
input: Complete, bipartite graph G=(U,V,E)G=(U,V,E) with non-negative
integer edge weights, and non-negative integer target TT.
output: Does GG contain a perfect matching of weight exactly TT?
Lemma 1. Subset-Sum poly-time reduces to Matching-Sum.
Proving this is a standard homework exercise. The proof is at the end.
Lemma 2. Matching-Sum poly-time reduces to the problem in the post.
Proof of Lemma 2. Fix a Matching-Sum input: a complete bipartite graph G=(U,V,E)G=(U,V,E) with non-negative integer edge weights w:U×V→N+w:U×V→N+, and target T∈N+T∈N+, where U={u1,…,un}U={u1,…,un} and V={v1,…,vn}V={v1,…,vn}. For each i,j∈{1,2,…,n}i,j∈{1,2,…,n}, define M(ij)M(ij) to be the matrix in R(n+1)×(n+1)R(n+1)×(n+1) where M(ij)ij=TM(ij)ij=T, and M(ij)n+1,n+1=w(ui,vj)M(ij)n+1,n+1=w(ui,vj), and all other entries are zero. The reduction outputs the following set of matrices:
{M(ij):i,j∈{1,…,n}}.
{M(ij):i,j∈{1,…,n}}.
This defines the reduction.
Claim. The span of this set of matrices consists of
those matrices M∈R(n+1)×(n+1)M∈R(n+1)×(n+1) satisfying
the linear constraints Mh,n+1=Mn+1,h=0Mh,n+1=Mn+1,h=0 for all h≤nh≤n and
the linear constraint ∑ni=1∑nj=1Mijw(ui,vj)=TMn+1,n+1.
∑ni=1∑nj=1Mijw(ui,vj)=TMn+1,n+1.
(Proof of claim. By inspection each matrix M(ij)M(ij) in the set satisfies these constraints, so every linear combination of those matrices does. Conversely, if M∈R(n+1)×(n+1)M∈R(n+1)×(n+1) satisfies the constraints, then MM equals the linear combination M′=∑ni=1∑nj=1αijM(ij)M′=∑ni=1∑nj=1αijM(ij) of the matrices, where αij=Mij/M(ij)ij=Mij/Tαij=Mij/M(ij)ij=Mij/T. Note in particular that, by the various definitions and the linear constraints,
M′n+1,n+1=∑ijαijw(ui,vj)=∑ijMijw(ui,vj)/T=(TMn+1,n+1)/T=Mn+1,n+1.
M′n+1,n+1=∑ijαijw(ui,vj)=∑ijMijw(ui,vj)/T=(TMn+1,n+1)/T=Mn+1,n+1.
This proves the claim.)
Now we show the reduction is correct. That is, the given graph GG has a weight-TT matching if and only if the set of matrices spans a permutation matrix.
(Only if.) First suppose the given graph GG has a weight-TT perfect matching M′M′. Let M∈{0,1}(n+1)×(n+1)M∈{0,1}(n+1)×(n+1) be the corresponding n×nn×n permutation matrix, with an extra row and column added such that Mn+1,n+1=1Mn+1,n+1=1 and Mh,n+1=Mn+1,h=0Mh,n+1=Mn+1,h=0 for all h≤nh≤n.
Then ∑ni=1∑nj=1Mijw(ui,vj)∑ni=1∑nj=1Mijw(ui,vj) is the weight of M′M′, that is, TT, and Mn+1,n+1=1Mn+1,n+1=1, so the linear constraints in the claim hold, and the span of the given set of matrices contains the permutation matrix MM.
(If.) Conversely, suppose the span contains any permutation matrix MM. By the claim, the only non-zero entry in row n+1n+1 or column n+1n+1 is Mn+1,n+1Mn+1,n+1, so (as MM is a permutation matrix) it must be that Mn+1,n+1=1Mn+1,n+1=1. So deleting the last row and column gives an n×nn×n permutation matrix. Let M′M′ be the perfect matching of GG corresponding to that n×nn×n permutation matrix. The weight of M′M′ is ∑ni=1∑nj=1Mijw(ui,vj)∑ni=1∑nj=1Mijw(ui,vj), which (by the claim) is TMn+1,n+1=TTMn+1,n+1=T. So the given graph has a weight-TT matching, proving Lemma 2. ◻ □
Here's the delayed proof of Lemma 1:
Proof of Lemma 1. Given Subset-Sum instance (w,T)∈Nn+×N+(w,T)∈Nn+×N+, the reduction outputs the Matching-Sum instance (G=(U,V,E),T)(G=(U,V,E),T) where U={u1,u2,…,u2n}U={u1,u2,…,u2n}, V={v1,v2,…,v2n}V={v1,v2,…,v2n}, for each i∈{1,…,n}i∈{1,…,n}, edge (ui,vi)(ui,vi) has weight wiwi, and all remaining edges have weight zero.
For any perfect matching with edge weights summing to TT, the set S={i:(ui,vi)∈M,i≤n}S={i:(ui,vi)∈M,i≤n} is a solution to the given Subset-Sum instance (as these are the only non-zero weight edges in MM).
Conversely, given any solution to the Subset-Sum instance, say S⊆{1,…,n}S⊆{1,…,n} with ∑i∈Swi=T∑i∈Swi=T, the set of edges {(ui,vi):i∈S}{(ui,vi):i∈S} is a partial matching with weight TT, and it extends easily to a weight-TT perfect matching by adding, for example, the following set of (zero-weight) edges:
{(ui+n,vi+n):i∈S}∪⋃i∈{1,…,n}∖S{(ui,vi+n),(ui+n,vi)}.
{(ui+n,vi+n):i∈S}∪⋃i∈{1,…,n}∖S{(ui,vi+n),(ui+n,vi)}.
This proves Lemma 1. The theorem follows from Lemmas 1 and 2. ◻ □
p.s. As an aside, according to this answer, the restriction of Matching-Sum to instances with polynomially-bounded edge weights is in P. But I'm sure that the restriction of the problem in the post to matrices with polynomially-bounded (integer) entries remains NP hard.