RECURSIVE TERNARY-BASED ALGORITHM FOR COMPUTING PRIME IMPLICANTS OF MULTI-OUTPUT BOOLEAN FUNCTIONS

: The problem of computing the set of prime implicants to represent a Boolean function is a classical problem that is still considered a running problem for research because all known approaches have limitations. The article reviews existing methods for computing prime implicants and highlights their limitations, particularly for multi-output functions and limited scalability due to the growth in memory required to complete the computation. Then it proposes a recursive ternary-based minimization algorithm to compute the prime implicants of multi-output Boolean functions. The algorithm is based on the concept of Programmable Logic Array (PLA) tables, which provide a structured and efficient representation of Boolean functions. The algorithm takes advantage of the ternary logic system to efficiently compute the prime implicants while maintaining scalability for large and complex functions, which has significant implications for digital circuit design and optimization.


Introduction
Boolean functions are mathematical expressions that take one or more binary inputs and produce a single or multiple-bit output. The output value of a Boolean function depends on the values of its input variables and the logical operations applied to them. Boolean functions are widely used in digital design, computer science, and other fields that involve binary logic [1][2][3].
A prime implicant of a single-output Boolean function is a product term (a logical AND of one or more input variables) that covers the function and cannot be further reduced by removing any input variables. In other words, a prime implicant is a minimal product term that is necessary to represent the function in a two-level sum-ofproducts SOP format [4].
Computing prime implicants is an important step in digital circuit design flow because they can be used to simplify the circuit and reduce its complexity. By identifying the prime implicants of a Boolean function, one can find the smallest set of product terms that can represent the function and use it to design simpler, faster, more efficient circuits, and lower cost [5,6].
There are several existing methods for computing prime implicants of a Boolean function. A widely used method to find all possible prime implicants is the Quine-McCluskey method, which performs pairwise comparisons of adjacent minterms in a table. The method is efficient for small functions but the complexity of this approach grows exponentially and becomes very expensive computationally for large functions [7,8].

Original Research
On the other hand, Petrick's method involves converting the function into a set of equations and solving them using matrix operations. The method is more efficient than the Quine-McCluskey method for large functions but can be complex and time-consuming for highly variable functions [9].
Existing exact methods can be computationally expensive for large and highly variable functions [10][11][12], making them impractical for use in some applications, therefore approximate and heuristic algorithms have been proposed to tackle the problem of prime implicants computation scalability. Heuristic approaches including genetic algorithms, simulated annealing, and Tabu search involve randomly generating candidate solutions and iteratively refining them based on fitness functions [13][14][15][16][17]. A heuristic method called the Espresso algorithm is proposed to minimize the Boolean function by iteratively selecting prime implicants that cover the most minterms. This algorithm is efficient and widely used in practice but sometimes it results in suboptimal solutions [18,19].
A mathematical approach to minimize Boolean functions using ternary representation to identify the candidate terms for minimization was proposed in [20]. The problem associated with this approach is the high memory requirement associated with the computation, due to the iterative computation style suggested in the algorithm, which limits the scalability of this approach [20]. A recursive style is considered in this article to tackle the problem.
However, these existing methods have certain limitations that can affect their effectiveness in computing prime implicants, such as computational complexity, inefficient use of resources, limited scope, and suboptimal solutions. Overall, the existing methods for computing prime implicants have their strengths and limitations, and researchers are constantly exploring new algorithms and techniques to address these limitations and improve the efficiency and accuracy of prime implicant computation.
The research problem addressed in this work is the computation of prime implicants for multioutput Boolean functions, which are functions with multiple binary outputs. While existing methods for computing prime implicants are well-established for single-output Boolean functions, they may not be directly applicable to multi-output functions, which require a different approach.
This study aims to present a novel recursive algorithm based on ternary logic for computing prime implicants of multi-output Boolean functions. The proposed algorithm is intended to be highly efficient and precise for functions with any number of outputs. Moreover, it generates a comprehensive set of prime implicants that can be effectively utilized for circuit optimization and design purposes.
The article is organized as follows: Section 2 presents the preliminaries to ensure selfcontainment. Section 3, The Proposed Minimization Algorithm, illustrates the proposed method and outlines the recursive computation of prime implicants using the ternary-based minimization algorithm. In Section 4, the proposed algorithm is discussed, highlighting its distinctive characteristics compared to existing methods. Finally, Section 5 concludes the article.

Background
The objective of this section is to provide readers with a comprehensive understanding of Boolean function representation. Specifically, it covers the basics of two-level SOP form representation and the widely adopted PLA table representation of multi-output Boolean functions. This information is essential for readers to grasp the content of the article, ensuring that it is selfcontained.

Minterms and truth-tables
A truth table of a Boolean function enumerates function values at all the points of the domain. The points of the domain are all possible permutations of binary-valued inputs. A total of = 2 permutations, where N is the number of inputs (function's binary arguments), see e.g. Table 1. This exponential complexity doubles the size of a truth table with each new input variable. A specific permutation of inputs is called a minterm, which is a Boolean conjunction, i.e. Boolean AND operation between all input variables each with the corresponding polarity, i.e. either an inverted or non-inverted literal in the product term. A minterm can be numerically represented by the permutation that is equal to the weighted binary sum of input bit values, i.e.
= ∑ −1 =0 * 2 , where X is a specific permutation (minterm) of the N-bit input vector. For example, the minterm 11 = 1 * 2 3 + 0 * 2 2 + 1 * 2 1 + 1 * 2 0 = (1011) 2 represents the Boolean expression . Another example is the minterm . This exponential growth in complexity makes it practically impossible to use this representation for functions with a large number of inputs. The SOP representation of a function is the disjunction of all minterms.

Cubes and PLA Tables
The minterms 11 and 9 in function demonstrated above are called adjacent minterms, which means that they have exactly one bit-difference in their expressions, i.e. (1011) and (1001). One possible Boolean expression reduction is by extracting the common part of two adjacent minterms and replacing these two minterms with one cube, which is only the common part of the two minterms. For example, the two adjacent minterms 11 and 9 are replaced by one cube (10 − 1). which is equivalent to the Boolean product term . without the literal 1 because it is eliminated from the conjunction. To preserve the position of the eliminated literally in the expression, the character '-' in a cube replaces either 0 or 1. One can achieve the additional reduction by extending the same approach to adjacent pairs of cubes. A larger cube can cover more points in the domain by doing so. For example, the cube (-0-0) can be obtained by combining the adjacent cubes (00-0) and (10-0) or the cubes (-000) and   Table file The sum-of-products SOP representation of a Boolean function is the disjunction of its prime implicants such that it covers all points in the domain. PLA table representation of a multipleoutput Boolean function is based on this minimized two-level SOP representation of Boolean functions, see e.g. Figure 1. The entities of this table are the prime implicants of the two-output function f. In the left column array in the table, we find the list of the cubes that form the function, while the right column contains the function value in response to each cube. This representation is only exponential in the worst case and hence it is suitable to represent larger functions.
The computation of the entities of a PLA table, i.e. the prime implicants, is not an intuitive problem. Quine-McCuskey's method, for instance, requires an exhaustive search to detect adjacent minterms [7,8]. Most approaches are exponential computational problems both time and space-wise.

The Proposed Minimization Algorithm
This section presents the main contribution of this article, which is the explanation of a new algorithm for computing prime implicants. The proposed algorithm addresses two challenges that have not been adequately handled in existing approaches: handling multiple output functions, and dealing with the memory size limit of available computer systems when using exact approaches.
To address these challenges, the proposed algorithm is based on a ternary approach that computes the prime implicants for all output bits in a single computation. The algorithm uses recursion to reduce memory requirements and improve scalability. This approach is more efficient and accurate than existing methods for computing prime implicants.

Ternary Coding of Cubes
Unlike minterms that can be numerically represented, cubes contain the non-numeric symbol '-' to indicate an eliminated literal in the conjunction term. To this end, we can observe that we have a representation with three different symbols {0, 1, -}. Ternary-based algorithms are a type of algorithm that uses a three-valued logic system (i.e., 0, 1, and don't care) to compute the prime implicants of a Boolean function. Unlike binary-based algorithms that use only 0 and 1 values, ternarybased algorithms can also take advantage of the don't care values, which can greatly reduce the computational complexity and memory requirements of the algorithm [20][21][22][23][24][25]. The advantages of ternary-based algorithms include: • Improved Efficiency: Ternary-based algorithms can be more efficient than binary-based algorithms, especially for large and complex functions. By taking advantage of the don't care values, ternarybased algorithms can reduce the number of minterms that need to be compared and merged, which can significantly reduce the computational complexity and memory requirements of the algorithm.
• Scalability: Ternary-based algorithms can be easily scaled to handle functions with any number of inputs and outputs, which makes them well-suited for modern digital circuit design. Overall, ternary-based algorithms offer several advantages over binary-based algorithms for computing prime implicants of Boolean functions and have become an increasingly popular approach in digital circuit design and optimization.
The radix-3 ternary numbering system can be used to represent any cube numerically. In this approach, the don't care bits '-' in the cubes are replaced with a 2, following the suggestion in [9,20]. In this case, there will be a unique positive integer representation for each cube that is computed from the ternary weight sum of the bits, i.e. = ∑ −1 =0 * 3 where is the cube representation of the N-bit ternary vector X.
The product term (  ′  ) has an inverted literal ′ , with two non-inverted literals a and d, while the literal c is missed, indicating an eliminated literal. The PLA table coding of this product term would be a cube (10 − 1). In the suggested ternary coding of this cube '-' symbol has to be replaced by a 2, resulting in the ternarycoded integer (1021) 3 = 34, which is calculated from the ternary-weighted digits' sum of 34 = 1 * 3 3 + 0 * 3 2 + 2 * 3 1 + 1 * 3 0 . The ternary coding of any possible cube in a Boolean function can be exploited in the binary version of the radix-generic minimization algorithm of multiple-valued logic functions, as proposed in [25], as in (1) below: where tk refers to the k th bit position with a value equal to 2, which indicates a don't care, i.e. an eliminated literal in the k th bit position of cube = . The proposed algorithm scans the array of all possible cubes to compute the cubes that cover the function. This approach suffers from the serious drawback of exponential memory growth that practically limits the scalability of the algorithm. It is important to mention that the function f is not limited to single output Boolean function, but rather this relation is applicable to multi-output Boolean functions. In this case, the conjunction and disjunction operators are bitwise AND and OR operators respectively. The computation is recursive as shown in relation (1) above. The recursive computation begins with the function call and the argument ( = 3 − 1), where N represents the number of input bits. The recursion process terminates when the minterm t does not contain any don't care bit.

Recursive Computation of Prime Implicants
To reduce the exponential memory space requirement, an equivalent recursive computation of the same formula (1) can be proposed, without the need to store the values in an array of all possible cubes. Instead, it stores only those cubes that are prime implicants and hence candidate entities in the PLA table.
To test whether a specific cube t of function f is a prime implicant, the function is tested among any possible cube () that may cover the cube t, where  = 2 |∀ 2, i.e. replacing the k th position in the cube t with 2 for each non '-' bit in t. The cube is prime if the following inequality is correct: (2) The result of the disjunction of the function value in response to the cube t with all other adjacent cubes identifies whether t has to be stored with the set of prime implicants in the PLA table.
This recursive computation continues until the base case of a minterm value is passed as an argument to the function call. In this case, the function returns the function value at the specified point in the domain instead of another recursion. The value = 3 − 1 is used for the main function call, i.e. the top-level recursion.

Discussion
The proposed recursive ternary-based algorithm offers several advantages over existing approaches. Firstly, the algorithm is designed to efficiently handle multiple output functions, which is a significant improvement over existing algorithms that were originally designed for single output functions. This ensures that the algorithm can provide comprehensive sets of prime implicants that can be used for circuit design and optimization. Secondly, the algorithm reduces the memory requirement of the computation by employing a recursive approach. Compared to existing approaches, which encounter exponential growth in computation time and memory space, this makes the algorithm more scalable. Additionally, the ternary-based approach used in the algorithm allows for the determination of prime implicants of all output bits within the same computation. This makes the algorithm more efficient and accurate compared to existing approaches that require separate computations for each output bit. Overall, the proposed algorithm provides an efficient and exact approach to computing prime implicants of multi-output Boolean functions. The recursive and ternary-based approach used in the algorithm ensures that it is scalable and can handle large multi-output functions without compromising its accuracy and efficiency.

Conclusions
In conclusion, most of the known methods to compute prime implicants are designed for single-output Boolean functions. The exponential complexity of this problem limits the scalability of most exact methodologies. This is tackled with either heuristic approaches which result in semi-optimum or approximate results, or with extensive usage of memory resources and also intensive computations to obtain exact solutions. In this article, we proposed a recursive ternary-based algorithm for computing prime implicants capable of efficiently handling multioutput Boolean functions. The algorithm provides an exact set of prime implicants. As compared to existing approaches, the proposed algorithm reduces the memory size required to run the computation and increases scalability because of its recursive nature. This reduction in memory requirement is traded-off with extra computational complexity. Therefore, further research efforts may be invested in reducing computational complexity with respect to time, and in generalizing this approach in minimizing Boolean systems that are combined from several interconnected sub-functions.
(www.uomustansiriyah.edu.iq), for their support and resources during this research. The facilities provided by the university were instrumental in the successful completion of this study.

X
The vector of binary-valued inputs N Number of bits in X f(X) A Boolean function of X xi The i th rightmost-bit in the vector X mx The minterm x binary-coded cx The cube x ternary-coded t Ternary-coded integer  Adjacent ternary-coded integer

Conflict of interest
The authors declare that there are no conflicts of interest regarding the publication of this manuscript.

Author Contribution Statement
Author Zaid Al-Wardi: proposed the algorithm.
Author Osama Al-Wardi: analyzed the complexity of the proposed algorithm and developed the software.