1 Introduction

Łukasiewicz logic originated in the 1920s as a semantically motivated formal system for many-valued logic. This paper works with the infinite-valued Łukasiewicz logic Ł, introduced by Łukasiewicz and Tarski [20]. As with some other non-classical systems, such as intuitionistic logic, the syntax is similar to classical logic, while the valid inferences form a strict subset of those of classical logic.

Validity/provability degrees as a concept in Łukasiewicz logic stem from a research line proposed by Goguen [11]. The paper set the challenge to develop a formal approach allowing to derive partly true conclusions from partly true assumptions. In [26] the task was taken up by Pavelka, who offered a comprehensive formalism based on complete residuated lattices, using essentially diagrams of arbitrary but fixed residuated lattices to capture provability degrees in the syntax. Pavelka used graded termsFootnote 1 and his formal system incorporated rules that explicitly use the algebra on degrees/grades alongside syntactic derivations. For example, a graded modus ponens reads \(\{\langle r, \varphi \rangle , \langle s, \varphi \rightarrow \psi \rangle \}/ \langle r\odot s, \psi \rangle \) with r and s truth constants, \(\varphi \) and \(\psi \) terms, and \(\odot \) the monoidal operation of the residuated lattice. Pavelka’s approach was later simplified by Hájek [12], who proposed an expansion of Łukasiewicz infinite-valued logic with constants for rational elements of [0, 1], and rendered each graded term \(\langle r, \varphi \rangle \) as the implication \(r\rightarrow \varphi \). This was an elegant example of embedding the graded syntax approach in what turns out to be a conservative expansion of Łukasiewicz logic. The resulting logic was named Rational Pavelka logic (\(\mathrm {RPL}\)); see [12, 14, 4, 7].

Assume truth values range in a complete lattice. The validity degree of a term \(\varphi \) under a theory T is the infimum of values \(\varphi \) can get under assignments that make T true. No constants are needed to define this notion. Still, the constants provide a canonical way of introducing provability degrees, the syntactic counterpart; thus we look at the language of \(\mathrm {RPL}\) next to that of Ł.

Both Ł and \(\mathrm {RPL}\) have an equivalent algebraic semantics (in the sense of [5]). In particular, \(\L \) corresponds to the variety of MV-algebras; [6, 9, 24] and the references therein provide resources for their well-developed theory. MV-algebras are strongly linked to Abelian \(\ell \)-groups ([22]); this is manifest in the choice of algebraic language, and we follow MV-algebraists and use the language \(\oplus \) and \(\lnot \) as a reference language for our complexity results. This is also a matter of convenience since some previous results are framed in this language.

We shall use the real-valued (standard) MV-semantics, with the unit interval as the domain and piecewise linear functions as interpretations of the function symbols; one can prove strong completeness for finite theories over Ł w.r.t. this algebra. The algebra has been useful for obtaining complexity results for Ł, since Mundici’s pioneering \(\mathrm {NP}\) completeness result on its SAT problem [23], which also gives \(\mathrm {coNP}\) completeness for theoremhood in Ł. Other complexity results for propositional logic Ł include [1, 2] reducing the decision problems in Ł to the setting of finite MV-chains, [17, 18] dealing with admissible rules, [3, 25], or [8]. All these works target decision problems.

The validity degree task (to determine the validity degree of a term \(\varphi \) under a finite theory T) is a natural optimization problem induced by the many-valued setting and the purpose of this paper is to see where it sits among other optimization problems. Using tools of complexity theory, we classify the validity degree task in propositional Łukasiewicz logic Ł and its extension \(\mathrm {RPL}\), for instances that pair a finite theory T with a term \(\varphi \). Our emphasis is on Ł rather than \(\mathrm {RPL}\): it is far better known, and the existing algebraic methods for Ł provide us with tools. In fact, the few complexity results available for \(\mathrm {RPL}\) rely on reductions to Ł. In [12] Hájek proved that for finite theories in \(\mathrm {RPL}\), validity degrees are rational; his method inspires ours in eliminating the constants, relying on their implicit definability in Ł. Hájek also provided complexity classification for the decision version of the problem in [13], showing that provability from finite theories in propositional \(\mathrm {RPL}\) is \(\mathrm {coNP}\) complete, using mixed integer programming. In [15], the same result is obtained from analogous results for Ł, using the implicit definability of constants directly.

We fill the gap of a basic classification for the optimization problem. Our upper bounds are based on improving Hájek’s rationality proof for validity degrees with establishing an explicit polynomial bound on denominator size, relying on Aguzzoli and Ciabattoni’s paper [2]. Their paper uses the language of Ł; however, the methods of [12, 15] allow us to tackle the rational constants and to derive analogous upper bounds for \(\mathrm {RPL}\), and we do that in Sect. 4; such upper bounds then apply also to any fragments of language, i.a., the MV-language. For lower bounds (Sect. 5), we work with the language of \(\L \), whereby the hardness result applies also to \(\mathrm {RPL}\).

The decision version of the validity degree is \(\mathrm {coNP}\) complete, and the SAT problem for is \(\mathrm {NP}\) complete. Looking at these and similar results on NP completeness of decision versions for other common optimization problems, one might ask what would the appropriate (many-one, poly-time) reduction notion be between the optimization versions, and indeed if such reductions always exist. Krentel [19] defines metric reductions in response to the former question and shows that as far as these reductions are concerned, the answer to the latter is negative unless \(\mathrm {P}=\mathrm {NP}\) (an outline of relevant results is in Sect. 3). Thus there is a sense in which a mere fact that the decision version of a problem is \(\mathrm {NP}\) complete does not provide enough information about the optimization version.

Under standard complexity assumptions, one cannot even approximate the validity degree efficiently: [16, Theorem 7.4] says that no efficient algorithm can compute the validity degree for an empty theory within a distance of \(\delta <1/2\) unless \(\mathrm {P}=\mathrm {NP}\).

The combined results of Sects. 4 and 5 yield the following statement.

Theorem 1

The validity degree task, considered in either Ł or \(\mathrm {RPL}\), is complete for the class \(\mathrm {FP}^{\mathrm {NP}}\) under metric reductions.

This appears to be the first work to shift the focus from decision to optimization problems as regards complexity of fuzzy logics, identifying a relevant complexity class. We find it compelling to investigate complexity problems for non-classical logics that have no counterpart in classical logic, and the validity degree problem, discussed here for Ł, presents one such research direction. (While, e.g., admissible rules present another, now well established one.)

This work is about the propositional fragments of Ł and \(\mathrm {RPL}\), so notions such as language, term/formula, or assignment need to be read appropriately.

2 Łukasiewicz Logic and Rational Pavelka Logic

The basic language of propositional Łukasiewicz logic Ł has two function symbols: unary \(\lnot \) (negation) and binary \(\oplus \) (strong disjunction or sum). Other function symbols are definable: 1 as \(x\oplus \lnot x\) and 0 as \(\lnot 1\); further, \(x\odot y\) is \(\lnot (\lnot x\oplus \lnot y)\) (strong conjunction or product); \(x\rightarrow y\) is \(\lnot x \oplus y\); \(x\equiv y\) is \((x\rightarrow y)\odot (y\rightarrow x)\); \(x\vee y\) is \((x\rightarrow y) \rightarrow y\) or \((y\rightarrow x)\rightarrow x\); and \(x\wedge y\) is \(\lnot (\lnot x \vee \lnot y)\).

The interpretations of \(\oplus \), \(\odot \), \(\wedge \) and \(\vee \) are commutative and associative, so one can write, e.g., \(x_1 \oplus \dots \oplus x_n\) without worrying about order and parentheses. We write \(x^n\) for \(\underbrace{x\odot \dots \odot x}_{n \text { times}}\) and nx for \(\underbrace{x\oplus \dots \oplus x}_{n \text { times}}\). Also, \(\vee \) and \(\wedge \) distribute over each other and \(\odot \) distributes over \(\vee \).

Well-formed Ł-terms are defined as usual. The basic language is a point of reference for complexity considerations in this paper, however we may at times use the expanded language for clarity (as in classical logic).

Definition 1

([2]) For any term \(\varphi (x_1,\dots ,x_n)\), \(\sharp (x)\varphi \) denotes the number of occurrences of the variable x in \(\varphi \), and \(\sharp \varphi = \varSigma _{i=1}^n\sharp (x_i)\varphi \).

The \(\sharp \) function is a good notion of length for terms without iterated \(\lnot \) symbols (\(\lnot \lnot \varphi \equiv \varphi \) is a theorem of \(\mathrm {L}\)). Our complexity results apply also to the language of the Full Lambek calculus with exchange and weakening (\( \mathrm {{FL}}_\mathrm {ew} \)), i.e., \(\{\odot , \rightarrow , \vee , \wedge , 0, 1\}\) (and the MV-symbol \(\oplus \)). Indeed one observes that rendering \(\odot \) and \(\rightarrow \) in the basic language does not affect length; for \(\vee \) and \(\wedge \), any occurrence of these defined symbols can be expanded to the basic language in two different ways (due to commutativity), and this can be used to rewrite any term with these symbols with only polynomial increase in length.

2.1 MV-algebras

The general MV-algebraic semantics will not be needed in this paper, anymore than a formal calculus for Ł. We will work with the standard MV-algebra : the domain is the real interval [0, 1] and with each MV-term \(\varphi (x_1,\dots ,x_n)\) we associate a function \(f_\varphi :[0,1]^n\longrightarrow [0,1]\), defined by induction on term structure with \(f_{\lnot \varphi }\) defined as \(1-f_\varphi \), \(f_{\varphi \oplus \psi }\) as \(\min (1,f_\varphi +f_\psi )\). 1 is the only designated element, accounting for the notions of truth/validity. For any assignment v in , \(v(\varphi \rightarrow \psi )=1\) iff \(v(\varphi )\le v(\psi )\), and thus \(v(\varphi \equiv \psi )=1\) iff \(v(\varphi )=v(\psi )\).

The class of MV-algebras is generated by as a quasivariety; it is also generated by the class of finite MV-chains, the \((k+1)\)-element MV-chain being the subalgebra of on the domain \(\{0,1/k, \dots , (k+1)/k,1\}\).

Provability from finite theories in Ł coincides with the finite consequence relation of . We have bypassed introducing the formal calculus; to provide a meaning to the references to Ł within this paper, let us adopt this as a definition. We lose little since the algorithmic approach only tackles finite theories anyway.

A function \(f:[0,1]^n \rightarrow [0,1]\) is a McNaughton function if it is continuous and piecewise linear with integer coefficients: there are finitely many linear polynomials \(\{p_i\}_{i\in I}\), with \(p_i(\bar{x}) = \varSigma _{j=1}^n a_{ij}\,x_j + b_i\) and \(\bar{a_i}, b_i\) integers for each i, such that for any \(\bar{u}\in [0,1]^n\) there is an \(i\in I\) with \(f(\bar{u})= p_i(\bar{u})\). McNaughton theorem ([21]) says that term-definable functions of coincide with McNaughton functions. The theorem highlights the fact that one can provide a countably infinite array of pairwise non-equivalent MV-terms for any fixed number of variables starting with one, as opposed to the case of Boolean functions.

A polyhedral complex C is a set of polyhedra (cells) such that if A is in C, so are all faces of A, and for AB in C, \(A\cap B\) is a common face of A and B. Given an MV-term \(\varphi (x_1,\dots ,x_n)\) one can build canonically a polyhedral complex \(C(\varphi )\) such that \([0,1]^n=\bigcup C(\varphi )\) and \(f_\varphi \) is linear over each n-dimensional cell of \(C(\varphi )\). The minimum of \(f_\varphi \) is attained at a vertex of an n-dimensional cell of \(C(\varphi )\). [2] derives the upper bound \((\frac{\sharp \varphi }{n})^n\) for the least common denominator of any vertex of any n-dimensional cell of \(C(\varphi )\) (see also [23]). By [1] this is a tight bound on cardinality of MV-chains witnessing non-validity of MV-terms.

For any MV-term \(\varphi \), the 1-region of \(f_\varphi \) is the union of cells of \(C(\varphi )\) such that \(f_\varphi \) attains the value 1 on all points in the cell. (The highest dimension of the cells in the 1-region of \(\varphi \) can range anywhere between 0 and n.) The 1-region of \(f_\varphi \) is compact for any \(\varphi \). One can investigate the minimum of \(f_\psi \) relative to the 1-region of an \(f_\varphi \); details in [2].

2.2 RMV-algebras

The language of \(\mathrm {RPL}\) expands the language \(\{\oplus ,\lnot \}\) of Ł with a set \(\mathcal{Q}= Q\cap [0,1]\) of constants. The constants are represented as ordered pairs of coprime integers in binary. The size of the binary representation of an integer n is denoted |n|.

The standard RMV-algebra has as its MV-reduct and interprets rational constants as themselves. As for Ł above, we identify \(\mathrm {RPL}\) with the finite consequence relation of . If \(\varphi \) is an RMV-term, \(f_\varphi \) is the function defined by \(\varphi \) in .

Let us extend the \(\sharp \) function to obtain a good length notion for RMV-terms. Rational constants can be viewed as atoms but the number of atom occurrences is not a suitable length notion since it ignores the space needed to represent each constant, which can be arbitrary with respect to the term structure.

Definition 2

Let an RMV-term \(\varphi \) have constants \(p_1/q_1,\dots ,p_m/q_m\) and variables \(x_1,\dots ,x_n\). For a rational \(p/q \in [0,1]\), let \(\sharp (p/q)\varphi \) denote the number of occurrences of p/q in \(\varphi \). Define \(\sharp \varphi = \varSigma _{i=1}^n\sharp (x_i)\varphi + \varSigma _{j=1}^m\sharp (p_j/q_j)\varphi (|p_j|+|q_j|)\).

Each rational r in [0, 1] is implicitly definable by an MV-term in Footnote 2: i.e., there is an MV-term \(\varphi (x_1,\dots ,x_k)\) and an \(i \in \{1,\dots ,k\}\) such that, for each assignment v in , we have \(v(x_i)=r\) whenever \(v(\varphi )=1\) (cf. [12, 15]). To implicitly define a rational p/q, with \(1\le p\le q\), in , first define 1/q, using the one-variable term \(z_{1/q}\equiv (\lnot z_{1/q})^{q-1}\), whereupon p/q becomes term-definable under a theory containing this definition of 1/q, namely we have \(z_{p/q} \equiv p {z_{1/q}}\) (cf. the technical results in [28, 10, 16]). With p and q in binary, these implicit definitions are exponential-size in |p| and |q|. One can make them polynomial-size on pain of introducing (a linear number of) new variables.

Lemma 1

([15, Lemma 4.1]) For \(q\in {\mathbb {N}}\), \(q\ge 2\), take the binary representation of \(q-1\), i.e., let \(q-1=\varSigma _{i=0}^m p_i 2^i\) with \(p_i\in \{0,1\}\) and \(p_m=1\). Let \(I=\{i\mid p_i=1\}\). In , the set

$$\begin{aligned} \{ y_0 \equiv \lnot z_{1/q}, y_1 \equiv y_0^2, y_2 \equiv y_1^2, \dots , y_m \equiv y_{m-1}^2, z_{1/q} \equiv \varPi _{i \in I} y_i \} \end{aligned}$$

has a unique satisfying assignment, sending \(z_{1/q}\) to 1/q.

To define 1/q, we need \(|q-1|+1\) variables, and the length of the product in the last equivalence is linear in |q|. Similarly one can achieve a polynomial-size variant of an implicit definition for p/q.

It is shown in [12] how to obtain finite strong completeness of \(\mathrm {RPL}\) w.r.t.  from finite strong completeness of \(\L \) w.r.t. , based on the following statement ([12, Lemma 3.3.13]). Let \(\delta _{p/q}\) be an MV-term that implicitly defines the value p/q in a variable \(z_{p/q}\) in . First, given an RMV-term \(\varphi \) in variables \(x_1,\dots ,x_n\) and constants \(p_1/q_1,\dots ,p_m/q_m\), let \(\delta _\varphi \) stand for \(\delta _{p_1/q_1}\odot \dots \odot \delta _{p_m/q_m}\)Footnote 3, and let \(\varphi ^\star \) result from \(\varphi \) by replacing each constant \(p_i/q_i\) with the variable \(z_{{p_i}/{q_i}}\). Now let \( \{\psi _1,\dots ,\psi _k\} \cup \{\varphi \}\) be a finite set of RMV-terms (in some variables \(x_1,\dots ,x_n\), particularly, with no occurrences of y-variables or z-variables) and let \(\tau \) denote \(\{\psi _1 \odot \dots \odot \psi _k\}\). The statement says that . The reason is that under \(\delta _{\tau \odot \varphi }\), the variables that correspond to the implicitly defined constants behave exactly as the constants would. Moreover, \(\delta _{\tau \odot \varphi }\) is an MV-term.

Lemma 2

Let \(\tau \) and \(\varphi \) be RMV-terms with rational constants \((p_1/q_1,\dots ,p_m/q_m)\). Using the \(\delta \) notation as above, we have:

  1. 1.

    \(\delta _{\tau \odot \varphi }\) has \(\varSigma _{j=1}^m (|p_j|+|q_j-1|) +2m\) variables.

  2. 2.

    the length of \(\delta _{\tau \odot \varphi }\), written as an MV-term featuring \(\oplus \) and \(\lnot \), is at most \(\varSigma _{j=1}^m (8|p_j|+ 8|q_j-1|+4)\).

Finally we are ready to define the validity degree of a term \(\varphi \) in a theory T:

$$ \Vert \varphi \Vert _T = \inf \{v(\varphi ) \mid v \text{ model } \text{ of } T\},$$

where a valuation v is a model of T if it assigns the value 1 to all terms in T. We only consider finite theories; for \(T=\{\psi _1,\dots ,\psi _k\}\) write \(\tau = \psi _1 \odot \dots \odot \psi _k\); then \(\Vert \varphi \Vert _\tau = \min \{v(\varphi ) \mid v \text{ model } \text{ of } \tau \}\). For \(\tau \) inconsistent, \(\Vert \varphi \Vert _\tau =1\). In the rest of this paper, T is finite and represented by the term \(\tau \) as above. We define the optimization problem.

  • Validity Degree

  • Instance: RMV-terms \(\tau \) and \(\varphi \) (possibly without constants).

  • Output: \(\Vert \varphi \Vert _\tau \).

Lemma 3

\(\Vert \varphi \Vert _\tau = \Vert \varphi ^\star \Vert _{(\tau ^\star \odot \delta _{\tau \odot \varphi })}\).

3 Optimization Problems and Metric Reductions

This section briefly sketches our computational paradigm, reproducing some notions and results on the structure of the oracle class \(\mathrm {FP}^{\mathrm {NP}}\) as given in Krentel [19], with a wider framework as provided in [27]. We also introduce an optimization problem from [19] that will be used in Sect. 5.

In this paper we use the term optimization problem for what is sometimes called an evaluation or cost version of a function problem (cf. [27]). In our setting, the output is the validity degree \(\Vert \varphi \Vert _\tau \) (as an extremal value of \(f_\varphi \) on the 1-region of \(f_\tau \)), rather than an assignment at which the extremal value is attained.

Let \(z: {\mathbb {N}}\longrightarrow {\mathbb {N}}\) be smooth.Footnote 4 \(\mathrm {FP}^{\mathrm {NP}}[z(n)]\) is the class of functions computable in polynomial time with an \(\mathrm {NP}\) oracle with at most \(z(\left| {x}\right| )\) oracle calls for instance x. In particular, \(\mathrm {FP}^{\mathrm {NP}}\) stands for \(\mathrm {FP}^{\mathrm {NP}}[n^{O(1)}]\).

Definition 3

([19]) Let \(\varSigma \) be a finite alphabet and \(f,g: \varSigma ^*\longrightarrow {\mathbb {N}}\). A metric reduction from f to g is a pair \((h_1,h_2)\) of polynomial-time computable functions where \(h_1:\varSigma ^*\longrightarrow \varSigma ^*\) and \(h_2:\varSigma ^*\times {\mathbb {N}}\longrightarrow {\mathbb {N}}\), such that \(f(x)=h_2(x,g(h_1(x)))\) for all \(x\in \varSigma ^*\).

The concept of a metric reduction is a natural generalization of polynomial-time many-one reduction to optimization problems. It follows from the definition that for each function z as above, \(\mathrm {FP}^{\mathrm {NP}}[z(n)]\) is closed under metric reductions. The paper [19] provides examples of problems that are complete for \(\mathrm {FP}^{\mathrm {NP}}\) under metric reductions. We define one such problem (see [19]).

  • Weighted Max-SAT

  • Instance: Boolean CNF term \((C_1 \wedge \dots \wedge C_n)(x_1,\dots ,x_k)\) with weights on clauses \(w_1,\dots ,w_n\), each \(w_i\) positive integer in binary.

  • Output: the maximal sum of weights of true clauses over all (Boolean) assignments to the variables \(x_1,\dots ,x_k\).

Theorem 2

([19]) Weighted Max-SAT is \(\mathrm {FP}^{\mathrm {NP}}\) complete.

The paper [19] provides a separation result for problems in \(\mathrm {FP}^{\mathrm {NP}}\), a simple form of which is given below. In particular, under standard complexity assumptions there are no metric reductions from \(\mathrm {FP}^{\mathrm {NP}}\) complete problems (such as Weighted Max-SAT) to some problems in \(\mathrm {FP}^{\mathrm {NP}}[O(\log n)]\), such as the Vertex Cover problem.

Theorem 3

([19]) Assume \(\mathrm {P}\not =\mathrm {NP}\).

Then \(\mathrm {FP}^{\mathrm {NP}}[O(\log \log n)] \subsetneq \mathrm {FP}^{\mathrm {NP}}[O(\log n)] \subsetneq \mathrm {FP}^{\mathrm {NP}}[n^{O(1)}]\).

4 Upper Bound: Validity Degree is in \(\mathrm {FP}^{\mathrm {NP}}\)

We present a polynomial-time oracle computation for Validity Degree, using a \(\mathrm {coNP}\) complete decision version of the problem as an oracle; this yields membership of Validity Degree in \(\mathrm {FP}^{\mathrm {NP}}\). The instances of the problem are pairs \((\tau , \varphi )\) of RMV-terms, i.e., terms with the MV-symbols \(\oplus \) and \(\lnot \) where atoms are variables and rational constants. The following oracle will be used.

  • D-RPL-Graded-Provability

  • Instance: \((\tau ,\varphi ,k)\) with \(\tau ,\varphi \) RMV-terms and k a rational number in [0, 1].

  • Output: \(\tau \vdash _\mathrm {RPL}k \rightarrow \varphi \)?

Note that \(\tau \vdash _\mathrm {RPL}k \rightarrow \varphi \) iff \(k\le \Vert \varphi \Vert _\tau \). By [13], RPL-provability from finite theories (given RMV terms \(\tau \) and \(\varphi \), it is the case that \(\tau \vdash _{\mathrm {RPL}}\varphi \)?) is \(\mathrm {coNP}\) complete. Hence, so is D-RPL-Graded-Provability.

The oracle computation can employ a binary search, given an explicit upper bound on denominators. To obtain a polynomial-time (oracle) computation, the result of [12] that \(\Vert \varphi \Vert _\tau \) is rational is not enough: we need an upper bound \(N(\tau ,\varphi )\) on the denominator that is in itself of polynomial size (in binary).

To expose the algebraic methods employed in this section, let us start with a simpler related problem, interesting in its own right: the natural optimization version of the term satisfiability problem in the standard MV-algebra .

  • Max Value

  • Instance: MV-term \(\varphi (x_1,\dots ,x_n)\).

  • Output: \(\max f_\varphi \) on \([0,1]^n\).

This problem reduces to Validity Degree: one maximizes \(f_\varphi \) by minimizing \(f_{\lnot \varphi }\) under an empty theory. As mentioned in Sect. 1, even this simpler problem cannot be efficiently approximated (see [16, Theorem 7.4]).

Lemma 4

Let \(p_1/q_1\) and \(p_2/q_2\) be two distinct rational numbers and N a positive integer, let \(q_1,q_2\le N\). Then \(\left| {\frac{p_1}{q_1}-\frac{p_2}{q_2}}\right| \ge \frac{1}{N^2}\).

Lemma 5

Let \(a<b\) be rationals and N a positive integer. Assume the interval [ab) contains exactly one rational c with denominator at most N, and other rationals with denominator at most N are at a distance greater than \(b-a\) from c. There is a poly-time algorithm that finds c on input a,b, and N in binary.

Theorem 4

Max Value is in \(\mathrm {FP}^{\mathrm {NP}}\).

Proof

Let \(\varphi (x_1,\dots ,x_n)\) be an MV-term. Then \(f_\varphi \) is maximal on a rational vector \(\langle p_1/q_1,\dots , p_n/q_n\rangle \); the least common denominator of the vector is at most \((\frac{\sharp \varphi }{n})^n\) ([2, Theorem 14]). It follows that the denominator of \(f_\varphi (p_1/q_1,\dots , p_n/q_n)\) is at most \(N(\varphi )=(\frac{\sharp \varphi }{n})^{n}\).

We sketch a polynomial-time algorithm computing \(\max (f_\varphi )\) using binary search on rationals in [0, 1] with denominators at most \(N(\varphi )\), using the generalized satisfiability (GenSAT), known to be \(\mathrm {NP}\) complete ([25]), as oracle: given MV-term \(\varphi \) and a rational \(r\in [0,1]\), is \(\max (f_\varphi ) \ge r\)?

  • Test \(\textsc {GenSAT}(\varphi ,1)\). If so, output 1 and terminate.

  • Otherwise, let \(a=0\), \(b=1\), and \(k=0\).

  • Repeat

  • \(k=k+1\); if \(\textsc {GenSAT}(\varphi , a+b/2)\), let \(a=a+b/2\), otherwise let \(b= a+b/2\)

  • until \(2^k>(N(\varphi ))^2\).

  • Finally, find \(\Vert \varphi \Vert _\tau \) in [ab) relying on Lemma 5.

Assume the algorithm runs through the loop at least once. After the search terminates, k is the least integer s.t. \(2^k> (N(\varphi ))^2\), i.e., \(k>2\log (N(\varphi )) \ge k-1\). hence the number k of passes through the loop is polynomial. Also, the semi-closed interval [ab) of length \(1/2^k<1/(N(\varphi ))^2\) contains \(\max f_\varphi \), and by Lemma 4, \(\max f_\varphi \) is the only value in [ab) with denominator at most \(N(\varphi )\). The values of a and b are \(l/2^k\) and \((l+1)/2^k\) respectively, so |a| and |b| are polynomial in k.

Let us address the Validity Degree problem. The binary search will be analogous, we need to establish an upper bound for the denominators. The following lemma can be obtained from the proof of [2, Theorem 17], a result on finite consequence relation in Ł.

Lemma 6

Let \(\tau \) and \(\varphi \) be MV-terms and let n be the number of variables in these terms. Assume \(M,N\in {\mathbb {N}}\) are coprime non-negative integers such that \(\Vert \varphi \Vert _\tau = M/N\). Then

$$N \le \left( \frac{\sharp \tau +\sharp \varphi }{n}\right) ^{n}$$

Proof

Following [2] and the references therein, one can build, in a canonical way, (n-dimensionalFootnote 5) polyhedral complexes \(C(\tau )\) and \(C(\varphi )\) such that \(\bigcup C(\tau )= [0,1]^n=\bigcup C(\varphi )\), with \(f_\tau \) linear over each n-dimensional cell of \(C(\tau )\) and \(f_\varphi \) linear over each n-dimensional cell of \(C(\varphi )\).

It follows from the analysis of [2] that the minimum of \(f_\varphi \) on the 1-region of \(\tau \) is attained at a vertex (of an n-dimensional cell) of the common refinement of \(C(\tau )\) and \(C(\varphi )\). It can further be derived from that paper that the least common denominator of any vertex in this common refinement is bounded by \((\frac{\sharp \tau +\sharp \varphi }{n})^n\); the proof is analogous to the case when \(\tau \) is void.

Hence, there is a rational vector \(\langle p_1/q_1,\dots , p_n/q_n\rangle \) on which \(f_\tau \) is 1, \(f_\varphi \) attains the value \(\Vert \varphi \Vert _\tau \), and the least common denominator of \(\langle p_1/q_1,\dots , p_n/q_n\rangle \) is \((\frac{\sharp \tau +\sharp \varphi }{n})^n\). It follows that \(N\le \left( \frac{\sharp \tau +\sharp \varphi }{n}\right) ^{n}\).

Denote by \(N(\tau ,\varphi )\) the obtained upper bound on the denominator of \(\Vert \varphi \Vert _\tau \) for MV-terms \(\tau \) and \(\varphi \). To provide an upper bound \(N^\star (\tau , \varphi )\) on the denominator of \(\Vert \varphi \Vert _\tau \) in case \(\tau \) and \(\varphi \) are RMV-terms, we rely on Lemma 3 in order to apply the existing results for MV-terms: namely, we use the upper bounds on \(\Vert \varphi ^\star \Vert _{(\tau ^\star \odot \delta _{\tau \odot \varphi })}\).

Lemma 7

Let \(\tau \) and \(\varphi \) be RMV-terms. \(N^\star (\tau ,\varphi ) = N(\tau ^\star \odot \delta _{\tau \odot \varphi },\varphi ^\star ) =\)

\(=(\frac{\sharp \tau ^\star + \sharp \delta _{\tau \odot \varphi }+ \sharp \varphi ^\star }{n})^{n}\), where n denotes the number of variables in the terms \(\tau ^\star \), \( \delta _{\tau \odot \varphi }\), and \(\varphi ^\star \).

Lemma 8

For \(\tau \) and \(\varphi \) RMV-terms, \(N^\star (\tau ,\varphi )\) is polynomial size in \(\sharp \tau \) and \(\sharp \varphi \).

Theorem 5

Validity Degree is in \(\mathrm {FP}^{\mathrm {NP}}\).

Proof

We provide a polynomial-time Turing reduction of Validity Degree to D-RPL-Graded-Provability; i.e., for RMV-terms \(\tau \) and \(\varphi \) the algorithm computes \(\Vert \varphi \Vert _\tau \) in time polynomial in \(\sharp \tau +\sharp \varphi \), relying on the oracle. The algorithm is based on a binary search analogous to the algorithm for Max Value from Theorem 4.

The initial test is \(\textsc {D-RPL-Graded-Provability}(1,\tau ,\varphi )\), where a positive answer yields \(\Vert \varphi \Vert _\tau =1\).

If this is not the case, the binary search is initiated. The upper bound \(N=N^\star (\tau ,\varphi )\) on denominator of \(\Vert \varphi \Vert _\tau \) is as in Lemma 7 and 8. This provides discrete structure to search in and the terminating condition \(2^k>N^2\).

The final application of Lemma 5 is analogous to the proof of Theorem 4.

5 Lower Bound: Validity Degree Is \(\mathrm {FP}^{\mathrm {NP}}\) Hard

We give a metric reduction of Weighted Max-SAT to Validity Degree. In this section the Validity Degree problem is considered for MV-terms \(\tau \) and \(\varphi \), i.e., we work in the MV-fragment of the RMV language. The lower bound obtained for the MV-language then applies also to RMV-language.

Theorem 6

Validity Degree is \(\mathrm {FP}^{\mathrm {NP}}\) hard under metric reductions.

Proof

For clarity, the proof is divided in two parts. First, we reduce Weighted Max-SAT to Validity Degree in an MV-language with the definable symbols. Subsequently we show how to polynomially translate general MV-terms that occur in the range of the metric reduction to MV-terms in the basic language.

We define the function \(h_1\) from Definition 3, which takes inputs to Weighted Max-SAT and transforms them to inputs to Validity Degree. Consider a classical CNF-term (with language \(\wedge \), \(\vee \), and \(\lnot \)) \(\varphi \) with variables \(x_1,\dots ,x_k\) and weights \(w_1,\dots , w_n\) for the clauses \(C_1,\dots ,C_n\) of \(\varphi \). One obtains the solution to Weighted Max-SAT by maximizing \(\varSigma _{i=1}^n v(C_i) w_i \) over all Boolean assignments v to \(x_1,\dots ,x_k\). To utilize Validity Degree, we need to render this expression in the MV-language and to isolate the Boolean semantics among the broader semantics of .

We define a finite theory T and a term \(\varPhi \) in stages by making several observations. At any stage, T is assumed to include terms specified in the earlier stages.

  1. (a)

    On any input \(\langle \tau ,\varphi \rangle \), Validity Degree gives the minimum of \(f_\varphi \) in over the 1-region of \(f_\tau \). The routine can also compute the maximum of \(f_\varphi \) on the same domain if the input is \(\langle \tau ,\lnot \varphi \rangle \) and the output is subtracted from 1.

  2. (b)

    To force Boolean assignments, for each \(1\le j\le k\) put \(x_j \vee \lnot x_j\) in T. Since \(\vee \) evaluates as \(\max \) in , this condition is true only under (standard MV-) assignments where either \(x_j\) is 1, or \(\lnot x_j\) is 1, i.e., \(x_j\) is 0.

  3. (c)

    The algebra can only correctly add up to the sum 1.Footnote 6 Thus the weights \(w_1,\dots , w_n\) need to be scaled. The computations with weights are bounded by \(w=\varSigma _{i=1}^n w_i\), which is the output of Weighted Max-SAT in case \(\varphi \) is satisfiable, so an appropriate factor to scale by is 1/w. The new weights are \(w_i'=w_i/w\) for each \(i\in \{1,\dots , n\}\) This is an order-preserving transformation of the weights and the new weights are of poly-size in the input size.

  4. (d)

    Multiplication is not available, so \(e(C_i) w_i'\) cannot be expressed with an MV-term. One can however implicitly define some rational expressions as follows.

    • Introduce a new variable b. To implicitly define 1/w in variable b, include in T the system from Lemma 1 that polynomially renders the condition \(b\equiv (\lnot b)^{w-1}\) ; now any model v of T will have \(v(b)=1/w\).

    • For \(1\le i\le n\), introduce a new variable \(y_i\). Include \(y_i\rightarrow b\) in T; any model v of T will have \(v(y_i)\le 1/w\). Further, include in T a polynomial rendering of \(\underbrace{y_i\oplus y_i\oplus \dots \oplus y_i}_{w \text { times}}\equiv C_i\), using Lemma 1; then for any model v of T we have that \(v(C_i)=0\) implies \(v(y_i)=0\), whereas \(v(C_i)=1\) implies \(v(y_i)\ge 1/w\), which in combination with the other condition in this item gives \(v(y_i)= v(C_i)/w\).

    • For \(1\le i\le n\), introduce a new variable \(z_i\). Include in T a polynomial rendering of \(\underbrace{y_i\oplus y_i\oplus \dots \oplus y_i}_{w_i \text { times}}\equiv z_i\), again relying on Lemma 1. Any model v of T will have \(v(z_i) = v(C_i) w_i'\).

To recap, we define T as the following set of MV-terms:

  • \(x_j \vee \lnot x_j\) for each \(j\in \{1,\dots ,k\}\);

  • a polynomial-sized rendering of \(b\equiv (\lnot b)^{w-1}\) (cf. Lemma 1);

  • for \(1\le i\le n\), \(y_i\rightarrow b\) and a poly-sized rendering of \(w y_i \equiv C_i\) (Lemma 1);

  • for \(1\le i\le n\), a poly-sized rendering of \( w_i y_i \equiv z_i\) (Lemma 1).

Let a term \(\tau \) represent T, let \(\varPhi \) stand for \(\lnot (z_1\oplus z_2\oplus \dots \oplus z_n)\). Let \(m=\Vert \varPhi \Vert _\tau \), i.e., m is the rational number that Validity Degree returns on input \(\tau \) and \(\varPhi \). We claim that \((1-m) w\) (the function \(h_2\) from Definition 3) is the solution to the instance \(C_1,\dots ,C_n\) and \(w_1,\dots , w_n\) of Weighted Max-SAT on input.

To see this, observe that the models of \(\tau \) feature precisely all Boolean assignments to variables \(\{x_1,\dots ,x_k\}\). Each such model v extends to the new variables b, \(y_i\) and \(z_i\) (\(1\le i\le n\)), namely \(v(b)=1/w\), \(v(y_i)=(1/w) v(C_i)\), and \(v(z_i)=(w_i/w) v(C_i)\). In particular, if v models T, then the values of b, \(y_i\) and \(z_i\) under v are determined by the values that v assigns to the x-variables (i.e., the “Boolean” variables). Except for b, the sets of variables introduced for each i are pairwise disjoint.

It follows from the construction of \(\tau \) and \(\varPhi \) that any Boolean assignment that yields an extremal value of Weighted Max-SAT also produces an extremal value of Validity Degree and vice versa. It is easy to check that the order-reversing operations (taking \(1-y\) back and forth) and the scaling and descaling work as expected (both are order-preserving). Hence, the reduction correctly computes an input to Validity Degree and correctly renders the result of this routine as an output of Weighted Max-SAT.

Finally, both functions involved are clearly polynomial-time functions.

For the second part of the proof, we notice that \(\varPhi \) is a term in the basic language. As for \(\tau \), recall that one can render \(\varphi \odot \psi \) and \(\varphi \rightarrow \psi \) in the basic language, using the definitions, without changing the number of variable occurrences; this includes the nested occurrences of \(\odot \) in (a rendering of) \((\lnot b)^{w-1}\) (recall that the product in the p-size variant is of cardinality |w|). To rewrite each disjunction \(C_i\) in the basic language, we apply to the following claim.Footnote 7

Claim: let \(\alpha = (\alpha _1\vee \dots \vee \alpha _n)\), where \(\alpha _i\) are terms in the basic language. There is a term \(\beta \) in the basic language Ł-equivalent to \(\alpha \) and such that \(\sharp \beta =2\sharp \alpha \).

To justify the claim, let \(\alpha ^l = \alpha '\vee \alpha _n\), where \(\alpha ' = (\alpha _1\vee \dots \vee \alpha _{n-1})\). Then \(\alpha ^l\) is equivalent to \((\alpha '\rightarrow \alpha _n)\rightarrow \alpha _n\). Repeat this process for \(\alpha '\) unless it coincides with \(\alpha _1\). This produces a term equivalent to \(\alpha \), with \(\rightarrow \) as the only symbol; then rewrite \(\rightarrow \) in the basic language.

6 Closing Remarks

This result attests a key role of algebraic methods for computational complexity upper bounds in propositional Łukasiewicz logic. Syntactic derivations are not even discussed; indeed at present we have no idea how to employ them.

A proof-theoretic counterpart of a validity degree is the provability degree: \(|\varphi |_T = \sup \{ r \mid T \vdash _{\mathrm {RPL}} {r} \rightarrow \varphi \}\), with the provability relation defined by extending Łukasiewicz logic with suitable axioms. Hájek proved Pavelka completeness for \(\mathrm {RPL}\) in [12]: for any choice of T and \(\varphi \), \(|\varphi |_T\) coincides with \(\Vert \varphi \Vert _T\). Our results thereby apply also to provability degrees (for finite theories).

To our knowledge there are no works explicitly dealing with the more pragmatical tasks of providing algorithms computing the validity degree (or maximal value), identifying fragments where they might be efficient, or similar.

We have obtained hardness for \(\mathrm {FP}^{\mathrm {NP}}\) under metric reductions for Validity Degree but not Max Value. A somewhat similar reduction of Weighted Max-SAT to a 0-1 integer programming problem was presented in [19], where roughly speaking, some conditions in the matrix correspond to some of our conditions in the theory. We do not know how to avoid employing the theory, and cannot supply a \(\mathrm {FP}^{\mathrm {NP}}\) hardness proof for Max Value at present.