Mathematical Problems in Engineering

Volume 2015 (2015), Article ID 687152, 8 pages

http://dx.doi.org/10.1155/2015/687152

## The Formalization of Discrete Fourier Transform in HOL

^{1}Beijing Key Laboratory of Electronic System Reliability Technology, Capital Normal University, Beijing 100048, China^{2}College of Information Science and Technology, Beijing University of Chemical Technology, Beijing 100029, China

Received 6 March 2015; Revised 7 June 2015; Accepted 25 June 2015

Academic Editor: Jean-François Monin

Copyright © 2015 Zhiping Shi et al. This is an open access article distributed under the Creative Commons Attribution License, which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly cited.

#### Abstract

Traditionally, Discrete Fourier Transform (DFT) is performed with numerical or symbolic computation, which cannot guarantee 100% accurate analysis which may be necessary for safety-critical applications. Machine theorem proving is one of the formal methods that perform accurate analysis with completeness to some extent. This paper proposes the formalization of DFT in a higher-order logic theorem prover named HOL. We propose the formal definition of DFT and verify the fundamental properties of DFT. Two case studies are presented to illustrate usefulness and correctness of the formalized DFT, including formal verifications of Fast Fourier Transform (FFT) and cosine frequency shift.

#### 1. Introduction

Fourier Transform (FT), through which signal is transformed from time domain to frequency one, is a fundamental and core method for signal processing. DFT is the discrete version of FT on both time domain and frequency domain which is adapted to the actual environment of computers and digital signal processing (DSP) chips. DFT has been widely used in many fields such as spectral analysis, data compressing, digital communication, signal processing, and the solution of partial differential equations [1, 2]. Therefore tremendous algorithms and packages have been implemented to perform DFT. The algorithms and packages are based on numerical or symbolic computation. The numerical computation intuitively produces approximate solutions because floating-point numbers are used to represent reals in computers. Computer algebra systems (CAS) such as MATLAB, Maple, and Mathematica offer a large collection of powerful algebraic packages and can efficiently perform symbolic computation precisely without round-off. But CAS still can output incorrect results because they have no mechanism to check correctness of results mathematically. Errors can arise in mismatching the side conditions of functions, the determination of equality of two expressions, or the definedness of expressions with respect to symbolic parameters [3, 4]. Moreover both numerical and symbolic computations are implemented in unverified huge computer programs, which are bug prone. Thus the analysis of DFT based on the above mentioned techniques cannot be relied upon for safety-critical applications of which even tiny errors can cause loss of human lives.

Formal methods have succeeded in precise analysis and verification of hardware and software systems in the past decades. Theorem proving, one of the formal methods, models the systems in logic and then reasons and verifies the model’s properties using axioms, theorems, and inference rules in the logic. The proof is performed in a theorem prover [5, 6]. The precise analysis and verification of systems employing DFT need the formal implementation of DFT in a theorem prover. Formal methods have been successfully applied in the precise analyses and verifications of hardware and software systems in the past decades. As a formal method, theorem proving can be used to model the systems based on logic and then to reason and verify the model’s properties using axioms, theorems, and inference rules in the logic. Generally, the proving tasks are performed in a theorem prover [5, 6]. For example, one needs to implement DFT formally in a theorem prover to perform the precise analyses and verifications based on DFT. In recent years, some formalization and verification [7–10] have been done on Fast Fourier Transform (FFT), which is the most popular and efficient DFT method. All these works focused on the specific formal implementations of FFT at different levels in diverse algorithms. Bjesse [7] verified FFT hardware at the netlist level. Capretta [8] formalized FFT at the power list level in the Coq theorem prover, while Gamboa [9] performed similar work in ACL2. Akbarpour and Tahar [10] formally verified FFT at different abstraction levels including the real specification level, the floating and fixed-point description level, and the RT and netlist gate levels, and they also analyzed the round-off accumulation errors. Although FFT may be the most widely used implementation of DFT, it cannot take place of DFT completely. DFT has its own theoretical advantages and is much simpler than FFT in both theory and algorithm. Therefore, compared with FFT, DFT has been all along a dominant method in theoretical analysis, especially when theorem proving is used to analyze the functions and properties of a system model. The applications of DFT in theorem proving are very important in the early stages of engineering design. Generally, DFT can be adopted to perform real-time computation on local data in the process of sampling, while FFT computation can only be done when all the data is obtained. Besides, DFT has more advantages over FFT in the choice of sampling rate, the memory consumption of data, and so forth. To the best of our knowledge, no work has been done previously to formalize DFT in any theorem prover. In the present paper, DFT is for the first time formalized in the HOL theorem prover. To some extent, the present work is to develop a theoretical tool rather than to just provide an application. Systematic and detailed formalization of DFT is presented here to support flexible formal analyses of various systems.

The HOL system is a well-developed theorem prover from the University of Cambridge. It is equipped with the formalized mathematic theories needed for DFT such as real analysis [11], complex field [12], and matrix theory [13, 14]. The rest of the paper is organized as follows. After the formal definition of DFT in Section 2, the fundamental properties of DFT are formalized and verified in Section 3. And then in Section 4, two case studies are presented to illustrate the usefulness of the proposed formalization of DFT, including formal analysis of FFT and the cosine frequency shift. Section 5 concludes the paper.

#### 2. Formal Definition of DFT

For a real or complex sequence with length of in time domain, DFT transforms it to a new complex sequence with the same length in frequency domain. The mathematical definition of DFT can be written as follows:where , is the frequency spectrum. For simplification, it is substituted by in the rest of the paper. The definition can be formalized in HOL as follows.

*Definition 1. *DFT_def,where accumulates the complex sequence from number 0 item for items. The function is the base- exponential function in which stands for the imaginary unit and stands for . The above mentioned symbols keep the same meanings in the rest of this paper.

When , the inverse DFT (IDFT) can be expressed as follows:The IDFT can be formalized as follows.

*Definition 2. *IDFT_def ,where stands for the DFT sequence of with length of .

#### 3. Formal Verification of the Properties

In this section, the classical properties of DFT are formalized and verified based on Definition 1 in HOL. The formal verification of the properties can check whether or not the definition is correct and reasonable, and moreover the verified properties turn into theorems in HOL and they can be utilized directly to facilitate formal analysis of DFT based systems.

##### 3.1. Some Useful Lemmas

To conveniently read and understand formalizations of properties of DFT, some useful lemmas verified in HOL are presented in this subsection. ConsiderThe formalization is as follows.

Lemma 3. *Equality of two complex functions’ cumulative sum * * ,**where functions and are functions from the natural numbers to complex numbers for convenience to DFT.*

Intuitively, is an -periodic complex sequence. It holds thatThe formalization is as follows.

Lemma 4. *Periodicity of is* * .*

*For a complex number , IM returns the imaginary component of . One has*

*Lemma 5. Inverse operation of imaginary parts of complex numbers .*

*Suppose is a complex function; it holds that The formalization is as follows.*

*Lemma 6. Compound operation and accumulating operation .*

*For the conjugate operator and accumulating function, there is a similar property as follows:where stands for the conjugate operator of complex numbers. The formalization is as follows.*

*Lemma 7. Conjugate operation and accumulating operation ,where the function returns the conjugate of a complex number.*

*Accumulation of a series of complex numbers can be performed on the real and imaginary parts, respectively. Considerwhere the functions RE and IM return the real and imaginary components of a complex number, respectively. The formalization is as follows.*

*Lemma 8. Accumulating operation of complex numbers , .*

*3.2. Implicit Periodicity*

*3.2. Implicit Periodicity**DFT is derived from the Discrete Fourier Series. Considering is an -periodic sequence, suppose is a series with -periodic extension. Then for = DFT(), is periodic. One hasThe formal description is as follows.*

*Theorem 9. DFT_PERIODIC .*

*3.3. Linearity*

*3.3. Linearity**For two -length sequences and , and are their DFT sequences. The linearity is as follows:We verified this property as the following theorem.*

*Theorem 10. DFT_LINEAR + .*

*The linearity of DFT shows that it can be applied in discrete linear system. The proof is based on Definition 1 and Lemma 3.*

*3.4. Symmetry*

*3.4. Symmetry**The time domain and frequency domain of DFT are conjugated dually and written asThe formal description is as follows.*

*Theorem 11. DFT_SYMM .*

*During verifying the theorem, we need to introduce a subgoal:in order to simplify the goal. Then apply some general operation rules in real script and Lemma 3 to make this theorem proved.*

*3.5. Conjugated Symmetry*

*3.5. Conjugated Symmetry**The sequence after DFT is of conjugated symmetry. ConsiderThe formal description is as follows.*

*Theorem 12. DFT_CONJ_SYMM .*

*3.6. Frequency Shift*

*3.6. Frequency Shift**The phase shift of the sequence in the time domain corresponds to the circular shift of the sequence in the frequency domain. The frequency shift contains the left shift and the right shift. They can be used in formal verification of cosine frequency shift. One hasThe left shift and the right shift are formalized into Theorems 13 and 14, respectively.*

*Theorem 13. DFT_FREQUENCY_LSHIFT *

*Theorem 14. DFT_FREQUENCY_RSHIFT .*

*3.7. Time Shift*

*3.7. Time Shift**Because of the duality property between the time domain and the frequency one, the circular shift of in the time domain corresponds to the phase shift of in the frequency domain. ConsiderThe formal description is as follows.*

*Theorem 15. DFT_TIME_SHIFT .*

*3.8. Convolution*

*3.8. Convolution**The convolution can be obtained as the product’s IDFT of two sequences’ DFT. The property facilitates a remarkable simplification. For two -length sequences and , their circular convolution is defined as follows:The formal definition is as follows.*

*Definition 16. *DFT_CONVOLUTION .

Let be DFT of ; the circular convolution theorem holds as follows:The formal theorem is as follows.

*Theorem 17. DFT_CONVOLUTION_TIME .*

*According to the theorem, the convolution can be calculated from the IDFT of . Benefiting from Fast FT algorithms, the computing complexity can be reduced greatly.*

*4. Applications*

*4. Applications**To illustrate the correctness and usefulness of our work, we formally verify FFT and cosine frequency shift as examples in this section. DFT always has been implemented by employing FFT, which is one of the most important algorithms. The formal verification of FFT is the basis to verify applications which employed FFT. Frequency shift is a significant property which should be taken into account at DFT applications. The two examples are chosen for their representativeness.*

*4.1. FFT*

*4.1. FFT**Without question, DFT is extremely useful in many fields but it often takes too long time to compute DFT directly by the definition, especially for long date sequences. Therefore, many FFT algorithms had been developed to perform DFT quickly. Directly computing DFT of an -length sequence takes arithmetical operations; by comparison, FFT algorithms take arithmetical operations to produce the same result. According to Formula (1) of DFT, the rotating operator , which is a periodic complex exponential sequence, enables the complexity reduction.*

*For the periodic complex-power sequence , it holds conjugated symmetry and reducibility as follows:The formalization is as follows.*

*Lemma 18. WN_CONJ_SYMM ,*

*The formalization is as follows.*

*Lemma 19. WN_REDUCE .*

*Because of the conjugated symmetry of the rotating operator, some multiplying terms can be merged and the amount of the multiplications reduces by a half roughly; because of the periodicity and the reducibility of the rotating operator, a DFT of a long length sequence can be factorized into multiple DFTs of short sequences, where the shorter the sequence, the lower the computing complexity. Based on the ideas above mentioned, many FFT algorithms had been developed. In this section, we formally verify the well-known radix-2 Cooley-Tukey algorithm.*

*From the reducibility of , taking -length DFT and , it holds thatThe formalization is as follows.*

*Lemma 20. WN_REDUCE_HALF .*

*For computing DFT of -length sequence , , the sequence is divided into two length subsequences in terms of the parity of , as follows:*

*Suppose that , , ; FFT can be described as follows:*

*FFT is consisting of the inversion processing and the butterfly shaped computation. And according to the above expressions, the FFT of is the concatenation of Formula (23). The formal description of FFT is shown in Algorithm 1.*