The quadratic M-convexity testing problem111A preliminary version of this paper has appeared in the proceedings of the 10th Japanese-Hungarian Symposium on Discrete Mathematics and Its Applications (JH 2017).
Yuni Iwamasa222Department of Mathematical Informatics,
Graduate School of Information Science and Technology,
University of Tokyo, Tokyo, 113-8656, Japan.
Email: [email protected]
Abstract
M-convex functions,
which are a generalization of valuated matroids,
play a central role in discrete convex analysis.
Quadratic M-convex functions constitute a basic and important subclass of M-convex functions,
which has a close relationship with phylogenetics as well as valued constraint satisfaction problems.
In this paper,
we consider the quadratic M-convexity testing problem (QMCTP),
which is the problem of deciding whether a given quadratic function on {0,1}n is M-convex.
We show that QMCTP is co-NP-complete in general,
but is polynomial-time solvable under a natural assumption.
Furthermore,
we propose an O(n2)-time algorithm for solving QMCTP in the polynomial-time solvable case.
**Keywords: **
discrete convex analysis, M-convex, testing problem
1 Introduction
A function f on {0,1}n is said to be M-convex [7]
if it satisfies the following generalization of matroid exchange axiom:
Exchange Axiom:
For x,y∈dom f and i∈supp(x)∖supp(y), there exists j∈supp(y)∖supp(x) such that
[TABLE]
where \textrm{dom }f:=\{x\in\{0,1\}^{n}\mid\text{f(x) takes a finite value}\} is the effective domain of f, supp(x):={i∣xi=1} for x=(x1,x2,…,xn)∈{0,1}n,
and χi is the ith unit vector.
In general, M-convex functions are defined on the integer lattice Zn.
In this paper,
we restrict ourselves to M-convex functions defined on {0,1}n, which are equivalent to the negative of valuated matroids introduced by Dress–Wenzel [3, 4].
M-convex functions play a central role in discrete convex analysis [8].
Indeed, M-convex functions appear in many areas such as operations research, economics, and game theory (see e.g., [8, 9, 10]).
Quadratic M-convex functions also appear in many areas,
and constitute a basic and important class of discrete functions.
Quadratic M-convex functions have a close relationship with tree metrics [5],
which is an important concept for mathematical analysis in phylogenetics (see e.g., [12]).
Recently, Iwamasa–Murota–Živný [6] have revealed hidden quadratic M-convexity in valued constraint satisfaction problems (VCSPs) with joint winner property [2],
and presented a perspective to their polynomial-time solvability from discrete convex analysis.
In this paper,
we consider the quadratic M-convexity testing problem (QMCTP) defined as follows.
Let R:=R∪{+∞} and [n]:={1,2,…,n} for a positive integer n with n≥4.
Given:
ai∈R for i∈[n], aij∈R for 1≤i<j≤n, and a positive integer r with 2≤r≤n−2.
Question:
Is the quadratic function f:{0,1}n→R defined by
[TABLE]
M-convex?
Notice that if r=1 or r=n−1,
then f of the form (1) is always a linear function.
Here we assume that aij=aji for distinct i,j∈[n] and dom f is nonempty.
In this paper, functions can take the infinite value +∞,
where a<+∞, a+∞=+∞ for a∈R,
and 0⋅(+∞)=0.
In the case where aij takes a finite value for all distinct i,j∈[n],
the following theorem is immediate from [8, Theorem 6.4] (see also [8, Proposition 6.8]).
Theorem 1.1** ([8]; see also [11, Theorem 5.2]).**
Suppose that aij takes a finite value for all distinct i,j∈[n].
Then a function of the form (1) is M-convex if and only if
[TABLE]
holds for every distinct i,j,k,l∈[n].
By Theorem 1.1,
if aij is a finite value for all distinct i,j∈[n],
then QMCTP is solvable in polynomial time.
However, if aij can take the infinite value +∞ for some distinct i,j∈[n],
there exists an example such that the condition (2) does not characterize M-convexity.
Indeed, define f:{0,1}5→R by
[TABLE]
Then f is M-convex; this can be verified by the definition of M-convexity.
However, the condition (2) is violated since a12+a34<min{a13+a24,a14+a23}
with a12+a34=0, a13+a24=1, and a14+a23=2.
Thus, in the general case, the complexity of QMCTP is not settled yet.
A quadratic function of the form (1) with an infinite quadratic coefficient arises naturally from a binary VCSP function.
A binary VCSP function F satisfying the joint winner property can be transformed to
a function represented as the sum two special M-convex functions of the form (1) with an infinite quadratic coefficient.
This fact explains the polynomial-time solvability of F (see [6] for details).
The class of functions represented as the sum of two general quadratic M-convex functions corresponds to a new tractable class of binary VCSPs.
Thus we need to consider QMCTP in the general case
for the first step to identify such a new tractable class.
In this paper, we settle QMCTP by showing the following negative result.
Theorem 1.2**.**
QMCTP* is co-NP-complete.*
We also prove a positive result under the following natural condition.
Condition A:
For any i∈[n],
there exists x∈dom f with xi=1.
Theorem 1.3**.**
If Condition A holds,
QMCTP is solvable in O(n2) time.
Note that checking Condition A is an NP-complete problem,
since it is almost equivalent to checking the existence of a stable set of size r−1.
The remainder of this paper is organized as follows.
In Section 2,
we prove Theorem 1.2
and introduce three types of functions.
In Section 3,
we present a characterization of M-convexity under Condition A for three types.
This characterization implies Theorem 1.1.
In Section 4,
we propose an O(n2)-time algorithm for each type of QMCTP,
and prove the validity of these algorithms.
Thus, we show Theorem 1.3.
2 Co-NP-Completeness of QMCTP
In this section,
we show the co-NP-completeness of QMCTP in the general case.
In order to show Theorem 1.2,
we prepare some lemmas.
In the terminology of discrete convex analysis, a set X⊆{0,1}n is said to be M-convex if
for x,y∈X and i∈supp(x)∖supp(y), there exists j∈supp(y)∖supp(x) such that x−χi+χj,y+χi−χj∈X.
That is, an M-convex set X is nothing but the base family of some matroid
if we identify a 0-1 vector with a subset of [n].
Note that if f is M-convex, then dom f is M-convex.
Lemma 2.1**.**
Suppose that f is a function of the form (1) such that dom f is M-convex.
For some distinct i,j∈[n], assume that there exist x,y∈dom f with xi=1 and yj=1.
Then, if aij<+∞,
there exists z∈dom f with zi=zj=1.
Proof.
Take x,y∈dom f with ∣supp(x)∖supp(y)∣ minimum satisfying xi=yj=1.
It suffices to show ∣supp(x)∖supp(y)∣=0.
Suppose, to the contrary, that ∣supp(x)∖supp(y)∣>0.
First we assume ∣supp(x)∖supp(y)∣≥2.
Then there exists i′=i such that i′∈supp(x)∖supp(y).
By the M-convexity of dom f for x, y, and i′,
there exists j′∈supp(y)∖supp(x) such that x−χi′+χj′∈dom f.
If j′=j, then x′:=x−χi′+χj satisfies xi′=xj′=1, a contradiction.
If j′=j, then x′:=x−χi′+χj′ satisfies
xi′=yj=1 and ∣supp(x′)∖supp(y)∣<∣supp(x)∖supp(y)∣.
This is also a contradiction to the choice of x and y.
Hence we have ∣supp(x)∖supp(y)∣=1=∣supp(y)∖supp(x)∣.
Since x,y∈dom f, it holds that akl,aik,ajk<+∞ for any k,l∈supp(x−χi)(=supp(y−χj)).
Moreover, we have aij<+∞ by the assumption.
Hence we obtain z:=x−χk+χj∈dom f for k∈supp(x−χi).
Hence z satisfies zi=zj=1, a contradiction.
Thus, we have ∣supp(x)∖supp(y)∣=0.
□
For a function f of the form (1),
we define an undirected graph Gf=([n],Ef)
by Ef:={{i,j}∣i,j∈[n], i=j, aij=+∞}.
Notice that Condition A holds if and only if,
for each i∈[n],
there is a stable set in Gf of size r containing i.
Lemma 2.2**.**
Suppose that Condition A holds.
Then dom f is an M-convex set if and only if
each connected component of Gf is a complete graph.
Proof.
(if part).
Let A1,A2,…,Am be the connected components of Gf.
Then dom f is represented by dom f={x∈{0,1}n∣∑ixi=r, ∣supp(x)∩Ap∣≤1 for all p∈[m]}.
Hence dom f can be regarded as the base family of a partition matroid.
This implies that dom f is M-convex.
(only-if part).
We prove the contrapositive.
Suppose that some connected component of Gf is not complete.
That is, there exist distinct i,j,k∈[n] such that {i,j},{j,k}∈Ef and {i,k}∈Ef.
By Condition A, aik<+∞, and Lemma 2.1,
there exists x∈dom f with xi=xk=1.
Take any x,y∈dom f with xi=xk=1 and yj=1.
Since aij=ajk=+∞, we have supp(x)∖supp(y)⊇{i,k}.
Then for all j′∈supp(y)∖supp(x),
it holds that x−χi+χj′∈dom f or y+χi−χj′∈dom f.
Indeed,
if j′=j, then x−χi+χj∈dom f holds from akj=+∞,
and if j′=j, then y+χi−χj′∈dom f holds from aij=+∞.
This implies that dom f is not M-convex.
□
Here we consider the following problem (P),
which is the problem for testing the M-convexity of dom f:
Given:
A graph G=(V,E) having a stable set of cardinality r.
Question:
Let T:=⋃{S⊆V∣S is a stable set of G with ∣S∣=r}.
Is each connected component of the subgraph of G induced by T a complete graph?
Lemma 2.3**.**
The problem (P) is co-NP-complete.
Proof.
It is clear that the problem (P) is in co-NP.
We show the co-NP-hardness of (P) by reduction from the stable set problem,
which is an NP-complete problem:
Given G=(V,E) and a positive integer k≤∣V∣,
we determine whether G contains a stable set of size at least k.
For a given graph G=(V,E) and a positive integer m, define Gm:=(V∪Vm,E∪Em) by ∣Vm∣=m, Vm∩V=∅, and Em:={{i,j}∣i∈V, j∈Vm}.
Let Tm:=⋃{S⊆V∪Vm∣S is a stable set of Gm with ∣S∣=m}.
Since Vm is a stable set of Gm satisfying ∣Vm∣=m,
we have Tm⊇Vm.
If Tm⊋Vm,
the subgraph of Gm induced by Tm is not complete by the definition of Em.
Hence each connected component of the subgraph of Gm induced by Tm is complete if and only if
G does not have a stable set of cardinality at least m.
Therefore we have the cardinality of a maximum stable set of G by solving (P) for Gk (k=∣V∣,∣V∣−1,…,1).
Indeed, the first k such that we output “no” by solving (P) for Gk is equal to the cardinality of a maximum stable set.
Since the maximum stable set problem has a polynomial-time reduction to the complement of (P),
(P) is co-NP-hard.
□
We are now ready to prove Theorem 1.2.
Proof of Theorem 1.2.
It is clear that QMCTP is in co-NP.
We show the co-NP-hardness of QMCTP by reduction from the problem (P).
Let G=([n],E) be a graph having a stable set of cardinality r.
We define fG by
[TABLE]
where aij:=+∞ for {i,j}∈E and aij:=0 for {i,j}∈E.
Note that x∈dom f if and only if supp(x) is a stable set of G.
We have dom fG=∅
by the assumption that G has a stable set of cardinality r.
We define X by X:=⋃{S⊆[n]∣S is a stable set of G of size r}.
Then there exists x∈dom fG with xi=1 if and only if i∈X.
For x∈{0,1}X,
define x~∈{0,1}n by x~i:=xi if i∈X and x~i:=0 if i∈[n]∖X.
Moreover define fG∣X(x):=fG(x~) for x∈{0,1}X.
By the definition of X,
fG is M-convex (i.e., dom fG is M-convex) if and only if
fG∣X is M-convex (i.e., dom fG∣X is M-convex).
Furthermore, by Lemma 2.2, fG∣X is M-convex if and only if each connected component of the subgraph of G induced by X is complete.
This means that we can solve (P) by solving QMCTP for fG.
□
3 Characterization of Quadratic M-Convexity
In this section, we present a characterization of M-convexity under Condition A, which implies Theorem 1.1.
By Lemma 2.2,
we see that the following Condition B is necessary for the M-convexity.
Condition B:
Each connected component of Gf is a complete graph.
Therefore, in this section,
we can assume that a function f of the form (1) satisfies Conditions A and B.
Let A1,A2,…,Am be the vertex sets of the connected components of Gf of size at least two,
and define A0:=[n]∖⋃p=1mAp,
which denotes the set of isolated vertices.
Then we classify the types of f as follows.
Type I:
∣A0∣+m≥r+2.
Type II:
∣A0∣+m=r+1.
Type III:
∣A0∣+m=r.
If ∣A0∣+m<r,
then we have dom f=∅.
Hence we exclude this case.
Theorem 3.1**.**
Suppose that a function f of the form (1) satisfies Conditions A and B.
Then the following hold.
(I):
f* of Type I is M-convex if and only if it holds that*
[TABLE]
for every distinct i,j,k,l∈[n].
(II):
f* of Type II is M-convex if and only if it holds that*
[TABLE]
for every p∈[m], distinct i,k∈Ap, and distinct j,l∈[n]∖Ap.
(III):
f* of Type III is M-convex if and only if it holds that*
[TABLE]
for every distinct p,q∈[m], distinct i,k∈Ap, and distinct j,l∈Aq.
Moreover, if f is an M-convex function of Type II or III,
then f is a linear function on dom f,
that is,
there exist pi∈R for each i∈[n] and α∈R satisfying
f(x)=∑ipixi+α for any x=(x1,x2,…,xn)∈dom f.
The function defined in (3) is an example of Type II.
If aij is finite value for all distinct i,j∈[n],
the function f is of Type I.
Hence Theorem 3.1 implies Theorem 1.1 as the finite case.
By Theorem 3.1,
we see that QMCTP is solvable in polynomial time under Conditions A and B.
In the proof of Theorem 3.1,
we use the following facts about the local exchange axiom
characterizing M-convexity, which are immediate corollaries of [8, Theorem 6.4] (see also [8, Proposition 6.8]).
Theorem 3.2** ([8]).**
A function f:{0,1}n→R with dom f⊆{x∈{0,1}n∣∑ixi=r} is M-convex if and only if
dom f is M-convex and
[TABLE]
holds for all z∈{0,1}n and all distinct i,j,k,l∈[n] such that z+χi+χj,z+χk+χl∈dom f.
Lemma 3.3**.**
A function f of the form (1) is M-convex if and only if
for every distinct i,j,k,l∈[n] such that there exists z∈{0,1}n with z+χi+χj,z+χk+χl∈dom f,
it holds that
[TABLE]
Recall that, for a function f of the form (1),
dom f is always M-convex,
since we assume that f satisfies Conditions A and B.
By Lemma 3.3,
the condition (2) in Theorem 1.1 (or the condition (4) in Theorem 3.1) is sufficient for M-convexity.
However, this is not necessary in general.
Proof of Lemma 3.3.
Take any z∈{0,1}n and distinct i,j,k,l∈[n] such that z+χi+χj,z+χk+χl∈dom f.
By Theorem 3.2, it suffices to show that for such i,j,k,l,
[TABLE]
holds if and only if aij+akl≥min{aik+ajl,ail+ajk} holds
(note that the inequality aij+akl≥min{aik+ajl,ail+ajk} is independent of the choice of z).
Define g:{0,1}n→R by
[TABLE]
for x=(x1,x2,…,xn)∈{0,1}n.
Then we have
[TABLE]
Since f(z+χi+χj) and f(z+χk+χl) take finite values,
each term of (7) and (8), i.e.,
g(z), aij, akl, and aip,ajp,akp,alp for p∈supp(z), also takes a finite value.
Hence we obtain
[TABLE]
□
For the function f defined in (3),
we can see that there is no z∈{0,1}5 such that z+χ1+χ2 and z+χ3+χ4 both belong to dom f.
This is the reason why the inequality a12+a34≥min{a13+a24,a14+a23} is not necessary for the M-convexity of f.
A function f is said to be M-concave if −f is M-convex.
The following theorem (M-separation theorem) holds.
Theorem 3.4** ([8, Theorem 8.15]).**
Suppose that f:{0,1}n→R∪{+∞} is M-convex and g:{0,1}n→R∪{−∞} is M-concave satisfying dom f∩dom g=∅ and g(x)≤f(x) for any x∈dom f∩dom g.
Then there exist α∗∈R and p∗∈Rn such that
[TABLE]
We are now ready to prove Theorem 3.1.
Proof of Theorem 3.1.
First we show a characterization of M-convexity.
For i∈[n] denote by Bi the connected component of Gf containing i.
That is, Bi={i} for i∈A0, and Bi=Ap for i∈Ap.
Note that x∈dom f if and only if ∑ixi=r and ∣supp(x)∩Ap∣≤1 for p∈[m].
If aij=+∞ or akl=+∞,
then it holds that f(z+χi+χj)=+∞ or f(z+χk+χl)=+∞ for all z∈{0,1}n.
In the following, we consider each type in turn.
Type I.
We show that for all distinct i,j,k,l∈[n] with aij<+∞ and akl<+∞,
there exists z∈{0,1}n such that z+χi+χj,z+χk+χl∈dom f.
∣A0∖(Bi∪Bj∪Bk∪Bl)∣+∣{A1,A2,…,Am}∖{Bi,Bj,Bk,Bl}∣≥r−2 holds since ∣A0∣+m≥r+2.
Therefore we can take z∈{0,1}n satisfying supp(z)⊆[n]∖(Bi∪Bj∪Bk∪Bl), ∣supp(z)∩Ap∣≤1 for p∈[m], and ∑izi=r−2.
Then z+χi+χj,z+χk+χl∈dom f holds for such z.
By Lemma 3.3,
f is M-convex if and only if for every distinct i,j,k,l∈[n] with aij,akl<+∞,
it holds that aij+akl≥min{aik+ajl,ail+ajk}.
Moreover, if aij=+∞ or akl=+∞,
then aij+akl≥min{aik+ajl,ail+ajk} automatically holds.
Hence f is M-convex if and only if for every distinct i,j,k,l∈[n],
it holds that aij+akl≥min{aik+ajl,ail+ajk}.
Type II.
We show that for distinct i,j,k,l∈[n] with aij,akl<+∞, there exists z∈{0,1}n such that z+χi+χj,z+χk+χl∈dom f
if and only if (Bi∪Bj)∩(Bk∪Bl)=∅ holds
(note that we have Bi∩Bj=Bk∩Bl=∅ since aij,akl<+∞).
Suppose (Bi∪Bj)∩(Bk∪Bl)=∅ (i.e., Bi, Bj, Bk, and Bl are all disjoint).
Then ∣A0∣+m≥4.
Hence r≥3 since ∣A0∣+m=r+1.
Furthermore we obtain ∣A0∖(Bi∪Bj∪Bk∪Bl)∣+∣{A1,A2,…,Am}∖{Bi,Bj,Bk,Bl}∣=r−3.
Hence for all z∈{0,1}n such that ∑izi=r−2 and ∣supp(z)∩Ap∣≤1 for p∈[m] with Ap=Bi,Bj,Bk,Bl, it holds that ∣supp(z)∩(Bi∪Bj∪Bk∪Bl)∣=∅.
This means z+χi+χj∈dom f or z+χk+χl∈dom f.
Thus, for i,j,k,l∈[n] with (Bi∪Bj)∩(Bk∪Bl)=∅, there is no z satisfying z+χi+χj,z+χk+χl∈dom f.
Suppose (Bi∪Bj)∩(Bk∪Bl)=∅.
Without loss of generality, we also suppose Bi∩Bk=∅.
Then there exists p∈[m] such that Bi=Bk=Ap.
Since ∣A0∣+m=r+1,
we have ∣A0∖(Bi∪Bj∪Bk∪Bl)∣+∣{A1,A2,…,Am}∖{Bi,Bj,Bk,Bl}∣=∣A0∖(Bj∪Bl)∣+∣{A1,A2,…,Am}∖{Ap,Bj,Bl}∣≥r−2.
Therefore we can take z∈{0,1}n satisfying supp(z)⊆[n]∖(Bi∪Bj∪Bk∪Bl), ∣supp(z)∩Ap∣≤1 for p∈[m], and ∑izi=r−2.
Then z+χi+χj,z+χk+χl∈dom f holds for such z.
By Lemma 3.3,
f is M-convex if and only if for every p∈[m], distinct i,k∈Ap, and distinct j,l∈[n]∖Ap,
it holds that aij+akl≥min{aik+ajl,ail+ajk}.
Since aik=+∞, the above inequality can be represented as aij+akl≥ail+ajk.
Moreover, by replacing j with l,
we have aij+akl≤ail+ajk.
Hence f is M-convex if and only if for every p∈[m], distinct i,k∈Ap, and distinct j,l∈[n]∖Ap,
it holds that aij+akl=ail+ajk.
Type III.
We show that for distinct i,j,k,l∈[n] with aij,akl<+∞, there exists z∈{0,1}n such that z+χi+χj,z+χk+χl∈dom f
if and only if Bi∪Bj=Bk∪Bl holds.
Suppose Bi∪Bj=Bk∪Bl.
Without loss of generality,
we also suppose Bi=Bk and Bi=Bl.
Then ∣A0∣+m≥3.
Hence r≥3 since ∣A0∣+m=r.
Furthermore we obtain ∣A0∖(Bi∪Bj∪Bk∪Bl)∣+∣{A1,A2,…,Am}∖{Bi,Bj,Bk,Bl}∣≤∣A0∖(Bi∪Bk∪Bl)∣+∣{A1,A2,…,Am}∖{Bi,Bk,Bl}∣=r−3.
Hence for all z∈{0,1}n such that ∑izi=r−2 and ∣supp(z)∩Ap∣≤1 for p∈[m] with Ap=Bi,Bj,Bk,Bl, it holds that ∣supp(z)∩(Bi∪Bj∪Bk∪Bl)∣=∅.
This means z+χi+χj∈dom f or z+χk+χl∈dom f.
Thus, for i,j,k,l∈[n] with (Bi∪Bj)∩(Bk∪Bl)=∅, there is no z satisfying z+χi+χj,z+χk+χl∈dom f.
Suppose Bi∪Bj=Bk∪Bl.
Without loss of generality, we also suppose Bi=Bk and Bj=Bl.
Then there exist distinct p,q∈[m] such that Bi=Bk=Ap and Bj=Bl=Aq.
Since ∣A0∣+m=r,
we have ∣A0∖(Bi∪Bj∪Bk∪Bl)∣+∣{A1,A2,…,Am}∖{Bi,Bj,Bk,Bl}∣=∣A0∣+∣{A1,A2,…,Am}∖{Ap,Aq}∣=r−2.
Therefore we can take z∈{0,1}n satisfying supp(z)⊆[n]∖(Bi∪Bj∪Bk∪Bl), ∣supp(z)∩Ap∣≤1 for p∈[m], and ∑izi=r−2.
Then z+χi+χj,z+χk+χl∈dom f holds for such z.
By Lemma 3.3,
f is M-convex if and only if for every distinct p,q∈[m], distinct i,k∈Ap, and distinct j,l∈Aq,
it holds that aij+akl≥min{aik+ajl,ail+ajk}.
Since aik=ajl=+∞, the above inequality can be represented as aij+akl≥ail+ajk.
Moreover, by replacing j with l,
we have aij+akl≤ail+ajk.
Hence f is M-convex if and only if for every distinct p,q∈[m], distinct i,k∈Ap, and distinct j,l∈Aq,
it holds that aij+akl=ail+ajk.
Linearity.
Then we show linearity of an M-convex function f of Type II or III.
By the characterization of Type II or III,
the function g defined by
[TABLE]
is M-concave for an M-convex function f of Type II or III.
By Theorem 3.4,
there exist α∗∈R and p∗∈Rn such that
[TABLE]
This means that f is a linear function on dom f.
□
4 Testing Quadratic M-Convexity in Quadratic Time
In this section,
we present an O(n2)-time algorithm for QMCTP under the assumption that a function f of the form (1) satisfies Condition A (and Condition B).
By Theorem 3.1,
it suffices to give an O(n2)-time algorithm for checking the condition (4), (5), or (6) in Theorem 3.1 for each type, respectively.
4.1 Algorithms
Our idea used in a proposed algorithm for Type I is that
the quadratic coefficients (aij)i,j∈[n] of input f are transformed into another (a^ij)i,j∈[n]
which has an easily checkable property if (aij)i,j∈[n] satisfies (4).
For Types II and III,
we give simpler conditions equivalent to (5) and (6),
and check the new one.
We say that (aij)i,j∈[n] satisfies the anti-tree metric property if (aij)i,j∈[n] satisfies (4),
that is,
aij+akl≥min{aik+ajl,ail+ajk} holds for all distinct i,j,k,l∈[n].
We also say that (aij)i,j∈[n] satisfies the anti-ultrametric property if aij≥min{aik,ajk} holds for all distinct i,j,k∈[n].
Algorithm I (for Type I).
Step 1:
Define α:=min{aij∣i,j∈[n]},
bi:=min{aij∣j∈[n]∖{i}}−α for i∈[n],
and a^ij:=aij for distinct i,j∈[n].
Step 2:
Update a^ij←a^ij−bi−bj for distinct i,j∈[n].
Step 3:
If (a^ij)i,j∈[n] satisfies the anti-ultrametric property,
output that “f is M-convex.”
Otherwise, output that “f is not M-convex.”
□
In Algorithms II and III, denote Ap by [np] for each p∈[r],
where np:=∣Ap∣.
Algorithm II (for Type II).
Step:
For all p∈[r],
if aij+ai+1,j+1=ai+1,j+ai,j+1 holds for every i∈[np−1] and j∈{np+1,np+2,…,n−1},
output that “f is M-convex.”
Otherwise, output that “f is not M-convex.”
□
Algorithm III (for Type III).
Step:
For all distinct p,q∈[r],
if aij+ai+1,j+1=ai+1,j+ai,j+1 holds for every i∈[np−1] and j∈[nq−1],
output that “f is M-convex.”
Otherwise, output that “f is not M-convex.”
□
Theorem 4.1**.**
Algorithms I, II, and III work correctly and run in O(n2) time.
We can check whether f satisfies Condition B,
i.e., each connected component of Gf is a complete graph, in O(n2) time.
Thus, by Theorem 4.1,
we obtain Theorem 1.3.
In the rest of this section,
we give the proof of Theorem 4.1.
It is clear that the running time of Algorithms II and III are O(n2).
In Section 4.2, we show the validity of Algorithms I, II, and III,
and show that we can check the anti-ultrametric property of given (a^ij)i,j∈[n] in O(n2) time in Step 3 of Algorithm I.
4.2 Proof of Theorem 4.1
For brevity of notation,
we denote min{aij∣j∈[n]∖{i}} by minjaij.
4.2.1 Validity of Algorithm I.
Observe that if (aij)i,j∈[n] satisfies the anti-tree metric property,
so does (a^ij)i,j∈[n] defined by
[TABLE]
for some i∗∈[n] and b∈R.
This means that the (inverse) operation of Step 2 does not change the anti-tree metric property.
Furthermore, It is known that the anti-ultrametric property is stronger than the anti-tree metric property [5, 12].
Thus, if Algorithm I returns the output “f is M-convex,”
then (aij)i,j∈[n] satisfies the anti-tree metric property.
Therefore, the validity of Algorithm I is established by proving that Algorithm I returns “f is M-convex”
whenever (aij)i,j∈[n] satisfies the anti-tree metric property.
We need some lemmas to show this statement.
In the following, suppose that (aij)i,j∈[n] satisfies the anti-tree metric property.
Recall that α:=min{aij∣i,j∈[n]}.
Lemma 4.2**.**
Suppose that minjaij=α holds for all i∈[n].
Then (aij)i,j∈[n] satisfies the anti-ultrametric property.
Proof.
Suppose, to the contrary, that there exist distinct i,j,k∈[n] with aij<min{aik,ajk}.
Then aik>α<ajk holds.
Hence, by the assumption,
there exists l∈[n]∖{i,j,k} satisfying akl=α.
Then we obtain aik>aij<ajk and ajl≥akl≤ail.
Thus, for such i,j,k,l∈[n],
it holds that aik+ajl>aij+akl<ail+ajk.
This contradicts the anti-tree metric property of (aij)i,j∈[n].
□
By Lemma 4.2,
it suffices to show that if (aij)i,j∈[n] satisfies the anti-tree metric property,
it holds that minja^ij=α for any i∈[n] after Step 2 of Algorithm I.
In the following, we prove this.
Lemma 4.3**.**
Suppose that minj′aij′=aij>α holds
for i,j∈[n].
Then there exists k∈[n] such that ajk=α.
Proof.
We show this by induction on n (the number of variables of f).
In the case of n=4,
it suffices to prove that if min{a12,a13,a14}=a12>α,
we have min{a23,a24}=α.
Suppose, to the contrary, that min{a23,a24}>α.
By the assumption and min{a12,a13,a14,a23,a24,a34}=α,
we obtain a34=α.
Then, since min{a12,a13,a14}=a12,
we have a14≥a12≤a13,
and since min{a23,a24}>α,
we have a23>a34<a24.
Therefore we have a14+a23>a12+a34<a13+a24.
This contradicts the anti-tree metric property of (aij)i,j∈[n].
In the case of n≥5,
it suffices to prove that if min{a12,a13,…,a1n}=a12>α,
we have min{a23,a24,…,a2n}=α.
Suppose, to the contrary, that min{a23,a24,…,a2n}=a23>α.
Since (aij)i,j∈[n] defines an M-convex function,
(aij)i,j∈{2,3,…,n} also defines an M-convex function.
Moreover, since min{a12,a13,…,a1n}>α,
we have min{aij∣i,j∈{2,3,…,n}}=α.
By min{a23,a24,…,a2n}=a23>α and the induction hypothesis,
there exists k∈{2,3,…,n} such that a3k=α (without loss of generality assume k=4).
Since min{a12,a13,…,a1n}=a12 and min{a23,a24,…,a2n}>α,
it holds that a14≥a12≤a13 and a23>a34<a24.
Therefore we have a14+a23>a12+a34<a13+a24.
This contradicts the anti-tree metric property of (aij)i,j∈[n].
□
Define Gmin:=(Vmin,Emin) by Emin:={{i,j}∣aij=α} and Vmin:={i∈[n]∣i∈∃e∈Emin}.
Lemma 4.4**.**
Gmin* is connected.
Moreover, for all i,j∈Vmin,
there exists an i-j path having at most two edges in Gmin.*
Proof.
It suffices to prove that there exists an i-j path having at most two edges in Gmin for all distinct i,j∈Vmin.
Suppose, to the contrary, that Gmin does not have an i-j path with at most two edges for some i,j∈Vmin.
Hence we have {i,j}∈Emin.
Furthermore there exist k,l∈Vmin such that {i,k},{j,l}∈Emin∋{i,l},{j,k}.
For such i,j,k,l,
we obtain aij+akl>aik+ajl<ail+ajk, a contradiction.
□
Lemma 4.5**.**
Suppose that minj′aij′=aij>α holds
for i,j∈[n].
Define bi:=aij−α.
Then aik−bi≥mini′ai′k holds for all k∈[n]∖{i}.
Proof.
Take any k∈[n]∖{i}.
If mini′ai′k=α,
then it holds that aik−bi=aik−aij+α≥α=mini′ai′k.
This means that if k=j,
the statement holds by Lemma 4.3.
Hence, in the following, suppose mini′ai′k>α
(note that k=j holds).
If aik=mini′ai′k,
we have minj′aij′=α by Lemma 4.3.
This contradicts minj′aij′=aij>α.
Thus we obtain aik>mini′ai′k.
We consider the following three cases.
(Case 1: mini′ai′k=ajk).
By Lemma 4.3,
ajl=α holds for some l∈[n]∖{i,j,k}.
Since (aij)i,j∈[n] satisfies the anti-tree metric property,
we have aik+ajl≥min{aij+akl,ail+ajk}.
Moreover, by minj′aij′=aij and mini′ai′k=ajk,
it holds that ail≥aij and akl≥ajk, respectively.
Hence aik+ajl≥min{aij+akl,ail+ajk}≥aij+ajk holds.
Since ajl=α and bi=aij−α hold,
we obtain aik−bi≥ajk=mini′ai′k.
(Case 2: mini′ai′k=akl for some l=j and ajl=α).
Since (aij)i,j∈[n] satisfies the anti-tree metric property,
we have aik+ajl≥min{aij+akl,ail+ajk}.
Moreover, by minj′aij′=aij and mini′ai′k=akl,
it holds that ail≥aij and ajk≥akl, respectively.
Hence aik+ajl≥min{aij+akl,ail+ajk}≥aij+akl holds.
Since ajl=α and bi=aij−α hold,
we obtain aik−bi≥akl=mini′ai′k.
(Case 3: mini′ai′k=akl for some l=j and ajl>α).
By Lemma 4.3,
we have j,l∈Vmin
since minj′aij′=aij>α and
mini′ai′k=akl>α.
By Lemma 4.4,
there exists a j-l path having at most two edges.
Then the assumption of ajl>α means that there exists p∈[n]∖{i,j,k,l} such that ajp=alp=α.
Since (aij)i,j∈[n] satisfies the anti-tree metric property, it holds that aik+ajp≥min{aip+ajk,aij+akp}.
By minj′aij′=aij and mini′ai′k=akl,
it holds that aip≥aij and akp≥akl, respectively.
Moreover, by ajk≥akl,
we have aik+ajp≥min{aip+ajk,aij+akp}≥aij+akl.
Since ajp=α and bi=aij−α hold,
we obtain aik−bi≥akl=mini′ai′k.
□
Let (a^ij)i,j∈[n] be the quadratic coefficients after Step 2,
that is, a^ij=aij−bi−bj for distinct i,j∈[n].
We show that minja^ij=α for any i∈[n].
Take any i∈[n].
Since bi≥0,
it holds that minja^ij≤minjaij−bi=α.
Next we prove minja^ij≥α.
If minjaij=α,
we have bi=0.
Hence we obtain minja^ij=minj{aij−bj}≥α.
If minjaij>α,
by Lemma 4.5,
we obtain minja^ij≥minj{minkajk−bj}=α.
4.2.2 Time Complexity of Algorithm I.
It is clear that Steps 1 and 2 in Algorithm I can be done in O(n2) time.
In the following,
we devise an O(n2)-time algorithm for determining whether (a^ij)i,j∈[n] satisfies the anti-ultrametric property,
while a direct verification of checking the anti-ultrametric property in Step 3 takes O(n3) time.
First we present a key lemma for designing an O(n2)-time algorithm.
This fact is well known [5, 6] and the point here is to allow the infinite value.
Lemma 4.6** ([6, Lemma 8]).**
(a^ij)i,j∈[n]* satisfies the anti-ultrametric property if and only if
there exist some laminar family L on [n] and some cU∈R for U∈L such that*
[n]∈L,
if U⊊U′, then cU>cU′ holds,
a^ij=cU(i,j)* holds for any distinct i,j∈[n],
where U(i,j) is the minimal element in L including {i,j}.*
By Lemma 4.6, we obtain the following natural procedure Decompose,
which updates a laminar family L and defines cU∈R for U∈L.
Suppose that we are given U⊆[n] and w∈R.
Procedure: Decompose(U,w).
Step 1:
If ∣U∣≤1 or w=+∞, then stop.
Step 2:
Take any i∈U.
Define e:=min{a^ij∣j∈U∖{i}} and X:=argmin{a^ij∣j∈U∖{i}}.
Step 3:
If e>w, then L←L∪{U}, cU:=e, and w←e.
Step 4:
Execute Decompose(X,w) and Decompose(U∖X,w).
□
For initialization, let L:={[n]} and c[n]:=α.
Observe that if (a^ij)i,j∈[n] satisfies the anti-ultrametric property,
Decompose([n],α) constructs an appropriate laminar family L and cU for U∈L corresponding to (a^ij)i,j∈[n].
Moreover Decompose([n],α) runs in O(n2) time.
We are ready to describe an algorithm for checking the anti-ultrametric property as follows.
Algorithm A (for checking the anti-ultrametric property).
Step 1:
Define L:={[n]} and c[n]:=α.
Step 2:
Execute Decompose([n],α).
Step 3:
Make a copy of L and denote it by L′,
that is, L′:={U′∣U∈L} (the base set of L′ is also [n]).
Step 4:
While L′=∅, do the following:
Step 4-1:
Take any minimal element U′∈L′.
Define aij′:=cU for {i,j}⊆U and {i,j}∩U′=∅.
Step 4-2:
Let U+∈L be the minimal element in L with U⊊U+.
Update U+′←U+′∖U.
Step 4-3:
Update L′←L′∖U′.
Step 5:
If (a^ij)i,j∈[n]=(aij′)i,j∈[n],
then output “(a^ij)i,j∈[n] satisfies the anti-ultrametric property.”
Otherwise, output “(a^ij)i,j∈[n] does not satisfy the anti-ultrametric property.”
□
In Step 4 of Algorithm A,
note that we define the value of aij′ exactly once for every distinct i,j∈[n].
Hence the time complexity of Step 4 is O(n2) time.
Thus, we see that Algorithm A runs in O(n2) time.
By Lemma 4.6, the validity of Algorithm A is clear.
Therefore we obtain the following theorem.
Theorem 4.7**.**
Algorithm A works correctly and runs in O(n2) time.
By Theorem 4.7,
we can determine whether (a^ij)i,j∈[n] satisfies the anti-ultrametric property in O(n2) time.
Remark 4.8**.**
The procedure Decompose has already been proposed in the preprint version of [5] in the context of M-convexity, and [1, 13] in the context of ultrametrics.
However, these papers deal with a different case where aij takes a finite value for all distinct i,j∈[n]
and the effective domain is subset of general integral vectors.
Remark 4.9**.**
We can devise another simpler O(n2)-time algorithm for Type I
if aij takes a finite value for all distinct i,j∈[n].
Indeed,
for the finite case,
it is known that (aij)i,j∈[n] satisfies the anti-tree metric property if and only if
(a^ij)i,j∈[n−1] satisfies the anti-ultrametric property,
where a^ij:=aij−ain−ajn for all distinct i,j∈[n−1] (see e.g., [12]).
Hence it suffices to check the anti-ultrametric property of (a^ij)i,j∈[n].
However, in the general case,
the above algorithm does not work,
since the relation between anti-tree metric property and anti-ultrametric property fails.
For example,
consider the case of a15=+∞, a12=a34=2, a13=a24=a45=1, a14=a23=a25=a35=0.
Then (aij)i,j∈[5] does not satisfy the anti-tree metric property since a12+a34(=4)>a13+a24(=2)>a14+a23(=0).
However, (a^ij)i,j∈[4] satisfies the anti-ultrametric property
since a^12=a^13=a^14=−∞, a^23=a^24=0, and a^34=1.
4.2.3 Validity of Algorithms II and III.
Let N and M be positive integers.
It suffices to prove that aij+akl=ail+akj holds for every i,k∈[N] with i<k and j,l∈[M] with j<l
if aij+ai+1,j+1=ai+1,j+ai,j+1 holds for every i∈[N−1] and j∈[M−1].
We show this by induction on (k−i)+(l−j).
For s≥1 and t≥1, take any i,k∈[N] with k=i+s and j,l∈[M] with l=j+t.
The case s+t=2 holds by the assumption.
Suppose s+t≥3.
Without loss of generality, s≥2.
By the induction hypothesis,
we have aij+ak−1,l=ail+ak−1,j and ak−1,j+akl=ak−1,l+akj.
Hence we obtain aij+akl=ail+akj.
This completes the induction step.
Acknowledgments
The author thanks Hiroshi Hirai and Kazuo Murota for careful reading and numerous helpful comments.
The author also thanks the referees for helpful comments.
In particular, Algorithms II and III (for Types II and III, respectively) are suggested by one of the referees.
This research was supported by JSPS Research Fellowship for Young Scientists.