Mathematical Foundation of a Functional Implementation of the CNF Algorithm
Abstract
:1. Introduction
 ...
 {
 do {
 ${\alpha}_{orig}=\alpha $
 …
 } while (${\alpha}_{orig}!=\alpha $);
 return($\alpha $)
 }
2. Basic Definitions and Preliminary Results
3. Distributivity
 1.
 $alt\left(\alpha \right)=0$.
 2.
 $\alpha \in K(A(X\left)\right)$.
 $\alpha \in A\left(X\right)$; in this case $dak\left(\alpha \right)\equiv \alpha $ is what Lemma 2 states.
 There exist formulas $\phi $ and $\psi $ in $K(A(X\left)\right)$ of complexities lower than those of $\alpha $ such that $\alpha \equiv K\phi \psi $. For the calculation of $dak\left(\alpha \right)$, it is only possible to start with Rule (5):$$\begin{array}{cccc}\hfill dak\left(\alpha \right)& \equiv dak\left(K\phi \psi \right)\hfill & \hfill \phantom{\rule{1.em}{0ex}}& \\ \hfill \phantom{\rule{1.em}{0ex}}& \equiv Kdak\left(\phi \right)dak\left(\psi \right)\hfill & \hfill \phantom{\rule{1.em}{0ex}}& \mathrm{by}\phantom{\rule{4.pt}{0ex}}\mathrm{Rule}\phantom{\rule{4.pt}{0ex}}\left(5\right)\hfill \\ \hfill \phantom{\rule{1.em}{0ex}}& \equiv K\phi \psi \hfill & \hfill \phantom{\rule{1.em}{0ex}}& \mathrm{induc}.\phantom{\rule{4.pt}{0ex}}\mathrm{hyp}.\hfill \\ \hfill \phantom{\rule{1.em}{0ex}}& \equiv \alpha \hfill & \hfill \phantom{\rule{1.em}{0ex}}\end{array}$$
 1.
 $\alpha \equiv x\in X$; in this case, $dak\left(\alpha \right)\equiv x\in X$ and since $X\subseteq K(A(X\left)\right)$, we deduce according to Lemma 1 that $alt\left(\alpha \right)=0$, which proves the result in this case.
 2.
 $\alpha \equiv AK\phi \psi \xi $; therefore, $\alpha \notin K(A(X\left)\right)$ and$$\begin{array}{cc}\hfill alt\left(\alpha \right)& =1+max\{alt(K\phi \psi ),alt(\xi \left)\right\}\hfill \\ \hfill \phantom{\rule{1.em}{0ex}}& =1+max\{alt(\phi ),alt(\psi ),alt(\xi \left)\right\}\hfill \end{array}$$On the other hand, $dak\left(\alpha \right)\equiv Kdak\left(A\phi \xi \right)dak\left(A\psi \xi \right)$ so that$$alt(dak(\alpha \left)\right)=max\{alt(dak\left(A\phi \xi \right)),alt(dak\left(A\psi \xi \right)\left)\right\}$$For short, we will call $\beta $ to $A\phi \xi $ and $\gamma $ to $A\psi \xi $. Let us bear in mind the following:
 (a)
 $K\in \beta $; then $alt\left(\beta \right)=1+max\{alt(\phi ),alt(\xi \left)\right\}$ and $\beta \notin K(A(X\left)\right)$. Since $comp\left(\beta \right)<comp\left(\alpha \right)$, the induction hypothesis allows us to establish that:$$\begin{array}{cc}\hfill alt(dak(\beta \left)\right)& =alt\left(\beta \right)1\hfill \\ \mathrm{(9)}& \hfill \phantom{\rule{1.em}{0ex}}& =1+max\{alt(\phi ),alt(\xi \left)\right\}1\hfill \mathrm{(10)}& \hfill \phantom{\rule{1.em}{0ex}}& =max\{alt(\phi ),alt(\xi \left)\right\}\hfill \end{array}$$
 (b)
 $K\notin \beta $; then $\phi ,\xi ,\beta \in A\left(X\right)$. According to Lemma 2, then $dak\left(\beta \right)\equiv \beta $ and, according to Lemma 1,$$\begin{array}{cc}\hfill alt(dak(\beta \left)\right)& =alt\left(\beta \right)=0\hfill \end{array}$$$$\begin{array}{cc}\hfill alt\left(\phi \right)& =0\hfill \end{array}$$$$\begin{array}{cc}\hfill alt\left(\xi \right)& =0\hfill \end{array}$$
We will now analyse equality (8) on a casebycase basis: (a)
 $K\in \beta $ and $K\in \gamma $; then$$\begin{array}{cccc}\hfill alt(dak(\alpha \left)\right)\phantom{\rule{1.em}{0ex}}& =max\{alt(dak\left(\beta \right)),alt(dak\left(\gamma \right)\left)\right\}\hfill & \hfill \phantom{\rule{1.em}{0ex}}& \mathrm{by}\phantom{\rule{4.pt}{0ex}}\left(8\right)\hfill \\ \hfill \phantom{\rule{1.em}{0ex}}& =max\{alt(\phi ),alt(\psi ),alt(\xi \left)\right\}\hfill & \hfill \phantom{\rule{1.em}{0ex}}& \mathrm{by}\phantom{\rule{4.pt}{0ex}}\left(10\right)\hfill \\ \hfill \phantom{\rule{1.em}{0ex}}& =alt\left(\alpha \right)1\hfill \end{array}$$
 (b)
 $K\notin \beta $ and $K\in \gamma $; then$$\begin{array}{cccc}\hfill alt(dak(\alpha \left)\right)\phantom{\rule{1.em}{0ex}}& =max\{alt(dak\left(\beta \right)),alt(dak\left(\gamma \right)\left)\right\}\hfill & \hfill \phantom{\rule{1.em}{0ex}}& \mathrm{by}\phantom{\rule{4.pt}{0ex}}\left(8\right)\hfill \\ \hfill \phantom{\rule{1.em}{0ex}}& =max\{0,alt(dak\left(\gamma \right)\left)\right\}\hfill & \hfill \phantom{\rule{1.em}{0ex}}& \mathrm{by}\phantom{\rule{4.pt}{0ex}}\left(11\right)\hfill \\ \hfill \phantom{\rule{1.em}{0ex}}& =alt(dak(\gamma \left)\right)\hfill & \hfill \phantom{\rule{1.em}{0ex}}& \\ \hfill \phantom{\rule{1.em}{0ex}}& =max\{alt(\psi ),alt(\xi \left)\right\}\hfill & \hfill \phantom{\rule{1.em}{0ex}}& \mathrm{by}\phantom{\rule{4.pt}{0ex}}\left(10\right)\hfill \\ \hfill \phantom{\rule{1.em}{0ex}}& =alt\left(\psi \right)\phantom{\rule{1.em}{0ex}}\hfill & \hfill \phantom{\rule{1.em}{0ex}}& \mathrm{by}\phantom{\rule{4.pt}{0ex}}\left(13\right)\hfill \\ \hfill \phantom{\rule{1.em}{0ex}}& =max\{0,alt(\psi ),0\}\hfill & \hfill \phantom{\rule{1.em}{0ex}}& \\ \hfill \phantom{\rule{1.em}{0ex}}& =max\{alt(\phi ),alt(\psi ),alt(\xi \left)\right\}\hfill & \hfill \phantom{\rule{1.em}{0ex}}& \mathrm{by}\phantom{\rule{4.pt}{0ex}}\left(11\right)\phantom{\rule{4.pt}{0ex}}\mathrm{and}\phantom{\rule{4.pt}{0ex}}\left(13\right)\hfill \\ \hfill \phantom{\rule{1.em}{0ex}}& =alt\left(\alpha \right)1\hfill & \hfill \phantom{\rule{1.em}{0ex}}& \mathrm{by}\phantom{\rule{4.pt}{0ex}}\left(7\right)\hfill \end{array}$$
 (c)
 $K\in \beta $ and $K\notin \gamma $; this situation is treated as the case in paragraph 2b.
 (d)
 $K\notin \beta $ and $K\notin \gamma $; in this case $\beta ,\gamma \in A\left(X\right)$ and $\alpha \in K(A(X\left)\right)$. By what Lemma 3 states, $dak\left(\alpha \right)\equiv \alpha $ and, as Lemma 1 states, $alt\left(\alpha \right)=0$; so $alt(dak(\alpha \left)\right)=0$.
 3.
 $\alpha \equiv A\xi K\phi \psi $; this situation is treated as the case in paragraph 2.
 4.
 $\alpha \equiv A\phi \psi $; neither $\phi $ nor $\psi $ begin with K but $K\in \alpha $; without loss of generality, suppose that $alt\left(\psi \right)\le alt\left(\phi \right)$, whence $K\in \phi $ and $\phi $ begins with A, i.e., $\phi \notin K(A(X\left)\right)$. Then $alt\left(\alpha \right)=1+alt\left(\phi \right)$ and$$\begin{array}{cccc}\hfill alt(dak(\alpha \left)\right)\phantom{\rule{1.em}{0ex}}& =alt(Adak(\phi )dak(\psi \left)\right)\hfill & \hfill \phantom{\rule{1.em}{0ex}}& \mathrm{by}\phantom{\rule{4.pt}{0ex}}\mathrm{Rule}\phantom{\rule{4.pt}{0ex}}\left(4\right)\hfill \\ \hfill \phantom{\rule{1.em}{0ex}}& =1+max\{alt(dak\left(\phi \right)),alt(dak\left(\psi \right)\left)\right\}\hfill & \hfill \phantom{\rule{1.em}{0ex}}& \\ \hfill \phantom{\rule{1.em}{0ex}}& =1+alt(dak(\phi \left)\right)\hfill & \hfill \phantom{\rule{1.em}{0ex}}& \\ \hfill \phantom{\rule{1.em}{0ex}}& =1+alt\left(\phi \right)1\hfill & \hfill \phantom{\rule{1.em}{0ex}}& \mathrm{hyp}.\phantom{\rule{4.pt}{0ex}}\mathrm{induc}.\phantom{\rule{4.pt}{0ex}}\mathrm{and}\phantom{\rule{4.pt}{0ex}}\mathrm{conditions}\phantom{\rule{4.pt}{0ex}}\mathrm{of}\phantom{\rule{4.pt}{0ex}}\phi \hfill \\ \hfill \phantom{\rule{1.em}{0ex}}& =alt\left(\phi \right)\hfill & \hfill \phantom{\rule{1.em}{0ex}}& \\ \hfill \phantom{\rule{1.em}{0ex}}& =alt\left(\alpha \right)1\hfill \end{array}$$
 5.
 $\alpha \equiv K\phi \psi $; without loss of generality, suppose that $alt\left(\psi \right)\le alt\left(\phi \right)$. If $alt\left(\phi \right)=0$, then $alt\left(\psi \right)=0$, $\phi ,\psi ,\alpha \in K(A(X\left)\right)$ and so $alt\left(\alpha \right)=0$ (see Lemma 1). If $alt\left(\phi \right)\ne 0$, i.e., $\phi \notin K(A(X\left)\right)$, then $\alpha \notin K(A(X\left)\right)$. Thus,$$\begin{array}{cccc}\hfill alt(dak(\alpha \left)\right)\phantom{\rule{1.em}{0ex}}& =alt(Kdak(\phi )dak(\psi \left)\right)\phantom{\rule{1.em}{0ex}}\hfill & \hfill \phantom{\rule{1.em}{0ex}}& \mathrm{by}\phantom{\rule{4.pt}{0ex}}\mathrm{Rule}\phantom{\rule{4.pt}{0ex}}\left(5\right)\hfill \\ \hfill \phantom{\rule{1.em}{0ex}}& =max\{alt(dak\left(\phi \right)),alt(dak\left(\psi \right)\left)\right\}\phantom{\rule{1.em}{0ex}}\hfill & \hfill \phantom{\rule{1.em}{0ex}}& \mathrm{def}.\phantom{\rule{4.pt}{0ex}}\mathrm{of}\phantom{\rule{4.pt}{0ex}}alt\hfill \\ \hfill \phantom{\rule{1.em}{0ex}}& =alt(dak(\phi \left)\right)\hfill & \hfill \phantom{\rule{1.em}{0ex}}& \\ \hfill \phantom{\rule{1.em}{0ex}}& =alt\left(\phi \right)1\hfill & \hfill \phantom{\rule{1.em}{0ex}}& \mathrm{induc}.\phantom{\rule{4.pt}{0ex}}\mathrm{hyp}.\phantom{\rule{4.pt}{0ex}}\mathrm{and}\phantom{\rule{4.pt}{0ex}}\mathrm{conditions}\phantom{\rule{4.pt}{0ex}}\mathrm{of}\phantom{\rule{4.pt}{0ex}}\phi \hfill \\ \hfill \phantom{\rule{1.em}{0ex}}& =max\{alt(\phi ),alt(\psi \left)\right\}1\phantom{\rule{1.em}{0ex}}\hfill & \hfill \phantom{\rule{1.em}{0ex}}& \\ \hfill \phantom{\rule{1.em}{0ex}}& =alt\left(\alpha \right)1\hfill & \hfill \phantom{\rule{1.em}{0ex}}& \mathrm{def}.\phantom{\rule{4.pt}{0ex}}\mathrm{of}\phantom{\rule{4.pt}{0ex}}alt\hfill \end{array}$$
 1.
 $dak\left(\alpha \right)\equiv \alpha $.
 2.
 $\alpha \in K(A(X\left)\right)$.
 3.
 $alt\left(\alpha \right)=0$.
 If $\alpha \in P\left(\mathbf{L}\right)$ and $n=alt\left(\alpha \right)$, then n is the smallest natural m satisfying ${dak}^{m}\left(\alpha \right)\in K(A\left(X\right))$.
 $n=0$; if $\alpha \in P\left(\mathbf{L}\right)$ and $0=alt\left(\alpha \right)$, then by Corollary 1, we know that $\alpha \in K(A(X\left)\right)$, i.e., ${dak}^{0}\left(\alpha \right)\in K(A\left(X\right))$, since ${dak}^{0}$ is the identity map. Since 0 is the smallest natural number, the set of natural numbers smaller than it is empty, from which we conclude the assertion.
 Suppose that $0<n$, that $Q(n1)$ is true, and that $\alpha \in P\left(\mathbf{L}\right)$ is fixed but arbitrary under the condition that $n=alt\left(\alpha \right)$. As we know from Theorem 1 and Corollary 1, it holds that$$alt(dak(\alpha \left)\right)=alt\left(\alpha \right)1=n1$$By (14) and the induction hypothesis, we have, in particular, that$${dak}^{n}\left(\alpha \right)={dak}^{n1}(dak\left(\alpha \right))\in K(A\left(X\right))$$On the other hand, let m be a natural number, such that $m<n$. Three cases can occur:
 *
 $m=n1$; then:$$\begin{array}{cc}\hfill alt\left({dak}^{n1}\left(\alpha \right)\right)& =alt\left(\alpha \right)n+1\hfill \\ \hfill \phantom{\rule{1.em}{0ex}}& =nn+1\hfill \\ \hfill \phantom{\rule{1.em}{0ex}}& =1\hfill \end{array}$$
 *
 $0<m<n1$; by Theorem 1, we know that $alt(dak(\alpha \left)\right)=n1$, and since $m1<m<n1$, by the induction hypothesis, we have$${dak}^{m}\left(\alpha \right)={dak}^{m1}(dak\left(\alpha \right))\notin K(A\left(X\right))$$
 *
 $m=0$; ${dak}^{0}\left(\alpha \right)=\alpha $, and since $alt\left(\alpha \right)=n>0$, we deduce that ${dak}^{0}\left(\alpha \right)\notin K(A\left(X\right))$.
4. Associativity
 1.
 $\alpha \in K\left(X\right)$ if, and only if, $ar\left(\alpha \right)=1$.
 2.
 $\alpha \in A\left(X\right)$ if, and only if, $kr\left(\alpha \right)=1$.
 3.
 $\alpha \in X$ if, and only if, $kr\left(\alpha \right)=1=ar\left(\alpha \right)$.
 4.
 $K\left(X\right)\cap A\left(X\right)=X$.
 $n=0$; then let —as the only case of interest— $\alpha \equiv x\in X$. By Definition 4, $ar\left(\alpha \right)=1$, so $Q\left(0\right)$ is true.
 $n>0$; if $\alpha \in K\left(X\right)$ and $n>0$, there must exist $\phi ,\psi \in K\left(X\right)$ such that $\alpha \equiv K\phi \psi $. Then$$\begin{array}{cccc}\hfill ar\left(\alpha \right)& =max\{ar(\phi ),ar(\psi \left)\right\}\hfill & \hfill \phantom{\rule{1.em}{0ex}}& \mathrm{Definition}4\phantom{\rule{4.pt}{0ex}}\hfill \\ \hfill \phantom{\rule{1.em}{0ex}}& =max\{1,1\}\hfill & \hfill \phantom{\rule{1.em}{0ex}}& \mathrm{induc}.\phantom{\rule{4.pt}{0ex}}\mathrm{hyp}.\hfill \\ \hfill \phantom{\rule{1.em}{0ex}}& =1\hfill \end{array}$$
 $n=0$; then let —as the only case of interest— $\alpha \equiv x\in X$. Since $X\subseteq K\left(X\right)$ it follows that $Q\left(0\right)$ is true.
 $n>0$; let $\alpha \in P\left(\mathbf{L}\right)$ such that $comp\left(\alpha \right)=n$ and $ar\left(\alpha \right)=1$. In principle, the following are possible:
 
 there exist $\phi ,\psi \in P\left(\mathbf{L}\right)$, such that $\alpha \equiv K\phi \psi $; then$$\begin{array}{cccc}\hfill 1& =ar\left(\alpha \right)\hfill & \hfill \phantom{\rule{1.em}{0ex}}& \\ \hfill \phantom{\rule{1.em}{0ex}}& =max\{ar(\phi ),ar(\psi \left)\right\}\hfill & \hfill \phantom{\rule{1.em}{0ex}}& \\ \hfill \phantom{\rule{1.em}{0ex}}& \Rightarrow ar\left(\phi \right)=1=ar\left(\psi \right)\hfill & \hfill \phantom{\rule{1.em}{0ex}}& \\ \hfill \phantom{\rule{1.em}{0ex}}& \Rightarrow \phi ,\psi \in K\left(X\right)\hfill & \hfill \phantom{\rule{1.em}{0ex}}& \mathrm{induc}.\phantom{\rule{4.pt}{0ex}}\mathrm{hyp}.\hfill \\ \hfill \phantom{\rule{1.em}{0ex}}& \Rightarrow \alpha \in K\left(X\right)\hfill & \hfill \phantom{\rule{1.em}{0ex}}\end{array}$$
 
 there exist $\phi ,\psi \in P\left(\mathbf{L}\right)$, such that $\alpha \equiv A\phi \psi $; then$$\begin{array}{cccc}\hfill 1& =ar\left(\alpha \right)\hfill & \hfill \phantom{\rule{1.em}{0ex}}& \\ \hfill \phantom{\rule{1.em}{0ex}}& =max\{ar(\phi ),1+ar(\psi \left)\right\}\hfill & \hfill \phantom{\rule{1.em}{0ex}}& \\ \hfill \phantom{\rule{1.em}{0ex}}& \ge 0\hfill & \hfill \phantom{\rule{1.em}{0ex}}& \\ \hfill \phantom{\rule{1.em}{0ex}}& \Rightarrow \mathrm{therefore}\phantom{\rule{4.pt}{0ex}}\mathrm{this}\phantom{\rule{4.pt}{0ex}}\mathrm{case}\phantom{\rule{4.pt}{0ex}}\mathrm{is}\phantom{\rule{4.pt}{0ex}}\mathrm{not}\phantom{\rule{4.pt}{0ex}}\mathrm{possible}\hfill & \hfill \phantom{\rule{1.em}{0ex}}\end{array}$$
so that $Q\left(n\right)$ is true.
 1.
 If $\alpha \in K\left(X\right)\setminus X$ then $0\le kr\left(\alpha \right)$.
 2.
 If $\alpha \in A\left(X\right)\setminus X$ then $0\le ar\left(\alpha \right)$.
 3.
 $ar\left(\alpha \right)=1$ and $kr\left(\alpha \right)=1$ if, and only if, $\alpha \in X$.
 1.
 $ar\left(\alpha \right)=1$ and $kr\left(\alpha \right)=0$ if, and only if, $\alpha \in kl\left(X\right)\setminus X$.
 2.
 $ar\left(\alpha \right)=0$ and $kr\left(\alpha \right)=1$ if, and only if, $\alpha \in al\left(X\right)\setminus X$.
 1.
 $ar\left(\alpha \right)=0$ and $kr\left(\alpha \right)=0$.
 2.
 $\alpha \in lcnf\left(X\right)\setminus (al(X)\cup kl(X\left)\right)$.
 1.
 $akr\left(\alpha \right)\le 0$.
 2.
 $\alpha \in lcnf\left(X\right)$.
 1.
 $ar\left(\alpha \right)=1=kr\left(\alpha \right)$; as stated in Lemma 5, $\alpha \in X$.
 2.
 $ar\left(\alpha \right)=1$ and $kr\left(\alpha \right)=0$; as stated in Lemma 6, $\alpha \in kl\left(X\right)\setminus X$.
 3.
 $ar\left(\alpha \right)=0$ and $kr\left(\alpha \right)=1$; as stated in Lemma 6, $\alpha \in al\left(X\right)\setminus X$.
 4.
 $ar\left(\alpha \right)=0$ and $kr\left(\alpha \right)=0$; as stated in Lemma 7, $\alpha \in lcnf\left(X\right)\setminus (al(X)\cup kl(X\left)\right)$.
 and hence, $\alpha \in lcnf\left(X\right)$. However, 1 is a necessary condition for 2, which follows as a consequence of the aforementioned lemmas. □
 1.
 If $\alpha \in A\left(X\right)$ then $lasc\left(\alpha \right)\in A\left(x\right)$.
 2.
 If $\alpha \in K\left(X\right)$ then $lasc\left(\alpha \right)\in K\left(x\right)$.
 1.
 $ar(lasc\left(\alpha \right))=\left(\right)open="\lfloor "\; close="\rfloor ">\frac{ar\left(\alpha \right)}{2}$
 2.
 $kr(lasc\left(\alpha \right))=\left(\right)open="\lfloor "\; close="\rfloor ">\frac{kr\left(\alpha \right)}{2}$
 3.
 $akr(lasc\left(\alpha \right))=\left(\right)open="\lfloor "\; close="\rfloor ">\frac{akr\left(\alpha \right)}{2}$
 $n=0$; must be $\alpha \in A\left(X\right)$, the formula for which is $ar(lasc\left(\alpha \right))=\left(\right)open="\lfloor "\; close="\rfloor ">\frac{ar\left(\alpha \right)}{2}$, as set out in Lemma 9.
 $n>0$; let —as the only case of interest— $\alpha \equiv K\phi \rho $ for certain $\phi ,\rho \in K(A(X\left)\right)$. Let us distinguish the following cases:
 
 $\rho \in A\left(X\right)$; then:$$\begin{array}{cccc}\hfill ar(lasc(\alpha \left)\right)& =ar(lasc(K\phi \rho \left)\right)=ar(Klasc(\phi )lasc(\rho \left)\right)\hfill & \hfill \phantom{\rule{1.em}{0ex}}& \\ \hfill \phantom{\rule{1.em}{0ex}}& =max\{ar(lasc\left(\phi \right)),ar(lasc\left(\rho \right)\left)\right\}\hfill & \hfill \phantom{\rule{1.em}{0ex}}& \\ \hfill \phantom{\rule{1.em}{0ex}}& =max\left(\right)open="\{"\; close="\}">\left(\right)open="\lfloor "\; close="\rfloor ">\frac{ar\left(\phi \right)}{2},\left(\right)open="\lfloor "\; close="\rfloor ">\frac{ar\left(\rho \right)}{2}\hfill \end{array}\hfill \phantom{\rule{1.em}{0ex}}& \mathrm{induc}.\phantom{\rule{4.pt}{0ex}}\mathrm{hyp}.\phantom{\rule{4.pt}{0ex}}\mathrm{and}\phantom{\rule{4.pt}{0ex}}\mathrm{Lemma}\phantom{\rule{4.pt}{0ex}}9\hfill $$
 
 $\rho \notin A\left(X\right)$; then $\alpha \equiv K\phi K\psi \xi $ for certain $\psi ,\xi \in K(A(X\left)\right)$. In this case,$$\begin{array}{cccc}\hfill ar(lasc(\alpha \left)\right)& =ar(lasc(K\phi K\psi \xi \left)\right)=ar(Klasc(K\phi \psi )lasc(\xi \left)\right)\hfill & \hfill \phantom{\rule{1.em}{0ex}}& \\ \hfill \phantom{\rule{1.em}{0ex}}& =max\{ar(lasc\left(K\phi \psi \right)),ar(lasc\left(\xi \right)\left)\right\}\hfill & \hfill \phantom{\rule{1.em}{0ex}}& \\ \hfill \phantom{\rule{1.em}{0ex}}& =max\left(\right)open="\{"\; close="\}">\left(\right)open="\lfloor "\; close="\rfloor ">\frac{ar\left(K\phi \psi \right)}{2},\left(\right)open="\lfloor "\; close="\rfloor ">\frac{ar\left(\xi \right)}{2}\hfill \end{array}\hfill \phantom{\rule{1.em}{0ex}}& \mathrm{induc}.\phantom{\rule{4.pt}{0ex}}\mathrm{hyp}\hfill $$
 $n=0$; must be $\alpha \in A\left(X\right)$, the formula for which is $kr(lasc\left(\alpha \right))=\left(\right)open="\lfloor "\; close="\rfloor ">\frac{kr\left(\alpha \right)}{2}$, as set out in Remark 7.
 $n>0$; let —as the only case of interest— $\alpha \equiv K\phi \rho $ for certain $\phi ,\rho \in K(A(X\left)\right)$. Let us distinguish the following cases:
 
 $\rho \in A\left(X\right)$; then$$\begin{array}{cccc}\hfill kr(lasc(\alpha \left)\right)& =kr(lasc(K\phi \rho \left)\right)\hfill & \hfill \phantom{\rule{1.em}{0ex}}& \\ \hfill \phantom{\rule{1.em}{0ex}}& =kr(Klasc(\phi )lasc(\rho \left)\right)\hfill & \hfill \phantom{\rule{1.em}{0ex}}& \\ \hfill \phantom{\rule{1.em}{0ex}}& =max\{kr(lasc\left(\phi \right)),1+kr(lasc\left(\rho \right)\left)\right\}\hfill & \hfill \phantom{\rule{1.em}{0ex}}& \\ \hfill \phantom{\rule{1.em}{0ex}}& =max\left(\right)open="\{"\; close="\}">\left(\right)open="\lfloor "\; close="\rfloor ">\frac{kr\left(\phi \right)}{2},0\hfill \end{array}\hfill \phantom{\rule{1.em}{0ex}}& =\left(\right)open="\lfloor "\; close="\rfloor ">\frac{max\{kr(\phi ),0\}}{2}\hfill \\ \hfill \phantom{\rule{1.em}{0ex}}& $$
 
 $\rho \notin A\left(X\right)$; then $\alpha \equiv K\phi K\psi \xi $ for certain $\psi ,\xi \in K(A(X\left)\right)$. In this case,$$\begin{array}{cccc}\hfill kr(lasc(\alpha \left)\right)& =kr(lasc(K\phi K\psi \xi \left)\right)=kr(Klasc(K\phi \psi )lasc(\xi \left)\right)\hfill & \hfill \phantom{\rule{1.em}{0ex}}& \\ \hfill \phantom{\rule{1.em}{0ex}}& =max\{kr(lasc\left(K\phi \psi \right)),1+kr(lasc\left(\xi \right)\left)\right\}\hfill & \hfill \phantom{\rule{1.em}{0ex}}& \\ \hfill \phantom{\rule{1.em}{0ex}}& =max\left(\right)open="\{"\; close="\}">\left(\right)open="\lfloor "\; close="\rfloor ">\frac{kr\left(K\phi \psi \right)}{2},1+\left(\right)open="\lfloor "\; close="\rfloor ">\frac{kr\left(\xi \right)}{2}\hfill \end{array}\hfill \phantom{\rule{1.em}{0ex}}& \mathrm{induc}.\phantom{\rule{4.pt}{0ex}}\mathrm{hyp}.\hfill $$
 1.
 $\alpha \in al\left(X\right)$
 2.
 $lasc\left(\alpha \right)\equiv \alpha $
 3.
 $ar\left(\alpha \right)\le 0$
 $n=0$; must be $\alpha \equiv x\in X$ and then $lasc\left(\alpha \right)\equiv lasc\left(x\right)\equiv x\equiv \alpha $.
 $n>0$; let —as the only case of interest— $\alpha \equiv A\phi x$, where $\phi \in al\left(X\right)$ and $x\in X$. Then$$\begin{array}{cccc}\hfill lasc\left(\alpha \right)& \equiv lasc\left(A\phi x\right)\hfill & \hfill \phantom{\rule{1.em}{0ex}}& \\ \hfill \phantom{\rule{1.em}{0ex}}& \equiv Alasc\left(\phi \right)lasc\left(x\right)\hfill & \hfill \phantom{\rule{1.em}{0ex}}& \\ \hfill \phantom{\rule{1.em}{0ex}}& \equiv A\phi x\hfill & \hfill \phantom{\rule{1.em}{0ex}}& \mathrm{induc}.\phantom{\rule{4.pt}{0ex}}\mathrm{hyp}.\phantom{\rule{4.pt}{0ex}}\mathrm{and}\phantom{\rule{4.pt}{0ex}}\mathrm{Definition}\phantom{\rule{4.pt}{0ex}}5\hfill \\ \hfill \phantom{\rule{1.em}{0ex}}& \equiv \alpha \hfill & \hfill \phantom{\rule{1.em}{0ex}}\end{array}$$
 $ar\left(\alpha \right)=1$ and $kr\left(\alpha \right)=1$; then $\alpha \in X\subseteq al\left(X\right)$ (see Lemma 5).
 $ar\left(\alpha \right)=0$ and $kr\left(\alpha \right)=1$; then $\alpha \in al\left(X\right)\setminus X$ (see Lemma 6).
 1.
 $\alpha \in lcnf\left(X\right)$.
 2.
 $dak\left(\alpha \right)\equiv \alpha $ and $lasc\left(\alpha \right)\equiv \alpha $.
 3.
 $alt\left(\alpha \right)=0$ and $akr\left(\alpha \right)\le 0$.
 $n=0$; must be $\alpha \equiv x\in X$ and then $dak\left(\alpha \right)\equiv dak\left(x\right)\equiv x\equiv \alpha $ and similarly, $lasc\left(\alpha \right)\equiv \alpha $. It follows that $Q\left(0\right)$ is true.
 $n>0$; let—as the only case of interest— $\alpha \equiv K\phi \psi $, where $\phi \in lcnf\left(X\right)$ and $\psi \in al\left(X\right)$. Then$$\begin{array}{cccc}\hfill dak\left(\alpha \right)& \equiv dak\left(K\phi \psi \right)\hfill & \hfill \phantom{\rule{1.em}{0ex}}& \\ \hfill \phantom{\rule{1.em}{0ex}}& \equiv Kdak\left(\phi \right)dak\left(\psi \right)\hfill & \hfill \phantom{\rule{1.em}{0ex}}& \\ \hfill \phantom{\rule{1.em}{0ex}}& \equiv K\phi dak\left(\psi \right)\hfill & \hfill \phantom{\rule{1.em}{0ex}}& \mathrm{induc}.\phantom{\rule{4.pt}{0ex}}\mathrm{hyp}.\hfill \\ \hfill \phantom{\rule{1.em}{0ex}}& \equiv K\phi \psi \hfill & \hfill \phantom{\rule{1.em}{0ex}}& \mathrm{Remark}\phantom{\rule{4.pt}{0ex}}1\phantom{\rule{4.pt}{0ex}}\mathrm{and}\phantom{\rule{4.pt}{0ex}}\mathrm{induc}.\phantom{\rule{4.pt}{0ex}}\mathrm{hyp}.\hfill \\ \hfill \phantom{\rule{1.em}{0ex}}& \equiv \alpha \hfill & \hfill \phantom{\rule{1.em}{0ex}}& \\ \hfill lasc\left(\alpha \right)& \equiv lasc\left(K\phi \psi \right)\hfill & \hfill \phantom{\rule{1.em}{0ex}}& \\ \hfill \phantom{\rule{1.em}{0ex}}& \equiv Klasc\left(\phi \right)lasc\left(\psi \right)\hfill & \hfill \phantom{\rule{1.em}{0ex}}& \\ \hfill \phantom{\rule{1.em}{0ex}}& \equiv K\phi lasc\left(\psi \right)\hfill & \hfill \phantom{\rule{1.em}{0ex}}& \mathrm{induc}.\phantom{\rule{4.pt}{0ex}}\mathrm{hyp}.\hfill \\ \hfill \phantom{\rule{1.em}{0ex}}& \equiv K\phi \psi \hfill & \hfill \phantom{\rule{1.em}{0ex}}& \mathrm{Lemma}\phantom{\rule{4.pt}{0ex}}10\hfill \\ \hfill \phantom{\rule{1.em}{0ex}}& \equiv \alpha \hfill & \hfill \phantom{\rule{1.em}{0ex}}\end{array}$$
5. Conclusions
 As we commented before, according to Definition 3, Definition 5, and Remark 2, the result of the two for loops in Algorithm 1 is a formula equivalent to the one that each of the loops took as a starting point. Thus, in each application of the algorithm, the result obtained retains the semantic meaning of the form it took as initial data.
 Each for loop in Algorithm 1 acts if and only if a change in the formula is necessary, i.e., if m > 0. In this case, the precalculated length of each of the two loops (respectively, alt, according to Defintion 2, and akr, acording to Definition 4) is exactly the minimum necessary to obtain the intended purpose of the loop. This extreme is guaranteed by Corollary 2 and Corollary 3. In short, under this approach, the length of the two for loops is optimal.
 The algorithm achieves what it sets out to do, as stated in Corollary 2 and Corollary 3.
 In each of the for loops of Algorithm 1, the comparison between the result formula of each round and that of the previous one, which was carried out in the classical formulation of the algorithm (reproduced in summary and pseudocode in Section 1) in order to decide whether the work has been completed, has disappeared. In its place, a single operation has appeared for each loop, before its start, consisting of the traversal and reading of a single formula, namely the loop data formula. In the general case, a priori this is an improvement over the classical formulation of the CNF algorithm, which in pseudocode we summarily reproduced in Section 1. Very unfavorable examples can be consulted in the readme.md of our GitHub repository https://github.com/ringstellung/CNF (accessed on 23 September 2023), and you can see how it is confronted by our Haskell implementation.
 Definition 3 and Definition 5 are an unpublished presentation of the wellknown core of the CNF algorithm. We believe we have included, with great concreteness, the concept of “recursive substitution” inspired by the usual style of lambda calculus. We believe we have found the appropriate language to be able to express in a very precise way, eliminating all ambiguity, a process usually described with certain formal licenses.
Algorithm 1 CNF simplified algorithm for formulas in $P\left(\mathbf{L}\right)$ 

Author Contributions
Funding
Data Availability Statement
Acknowledgments
Conflicts of Interest
Abbreviations
CNF  conjunctive normal form 
DNF  disjunctive normal form 
PNF  prenex normal form 
POS  product of sums 
SOP  sum of products 
SAT  Boolean satisfiability 
iff  if and only if 
def.  definition 
induc hyp.  induction hypothesis 
resp.  respectively 
p.  page 
pp.  pages 
References
 Tseitin, G.S. On the Complexity of Derivation in Propositional Calculus. In Automation of Reasoning. 2 Classical Papers on Computational Logic 1967–1970; Bolç, L., Bundy, A., Siekmann, J., Sloman, A., Eds.; Springer: Berlin/Heidelberg, Germany, 1983; pp. 466–483. [Google Scholar]
 Hill, F.J.; Peterson, G.R. Introduction to Switching Theory and Logical Design; John Wiley & Sons: Hoboken, NJ, USA, 1981. [Google Scholar]
 Whitesitt, J.E. Boolean Algebra and Its Applications; AddisonWesley Publishing Company: Boston, MA, USA, 1962. [Google Scholar]
 Gorbátov, V.A. Fundamentos de la Matemática Discreta; Mir: Moscow, Russia, 1988. [Google Scholar]
 Büning, H.K.; Lettmann, T. Propositional Logic: Deduction and Algorithms; Cambridge University Press: Cambridge, UK, 1999. [Google Scholar]
 Gill, A. Applied Algebra for the Computer Sciences; PrenticeHall: Hoboken, NJ, USA, 1976. [Google Scholar]
 Jackson, P.; Sheridan, D. Clause form Conversions for Boolean Circuits. In SAT 2004, LNCS 3542; Hoos, H.H., Mitchell, D.G., Eds.; Springer: Berlin/Heidelberg, Germany, 2005; pp. 183–198. [Google Scholar]
 Łukasiewicz, J. Elements of Mathematical Logic; Pergamon Press: Oxford, UK, 1966. [Google Scholar]
 Lipovača, M. Learn You a Haskell for Great Good; No Starch Press: San Francisco, CA, USA, 2011. [Google Scholar]
 Monk, J.D. Mathematical Logic; Springer: Berlin/Heidelberg, Germany, 1976. [Google Scholar]
 Bourbaki, N. Théorie des Ensembles; Eléments de Mathématique; Hermann: Paris, France, 1977. [Google Scholar]
 Kunen, K. The Foundations of Mathematics; Mathematical Logic and Foundations; College Publications: Norcross, GA, USA, 2009; Volume 19. [Google Scholar]
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. 
© 2023 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).
Share and Cite
GarcíaOlmedo, F.M.; GarcíaMiranda, J.; GonzálezRodelas, P. Mathematical Foundation of a Functional Implementation of the CNF Algorithm. Algorithms 2023, 16, 459. https://doi.org/10.3390/a16100459
GarcíaOlmedo FM, GarcíaMiranda J, GonzálezRodelas P. Mathematical Foundation of a Functional Implementation of the CNF Algorithm. Algorithms. 2023; 16(10):459. https://doi.org/10.3390/a16100459
Chicago/Turabian StyleGarcíaOlmedo, Francisco Miguel, Jesús GarcíaMiranda, and Pedro GonzálezRodelas. 2023. "Mathematical Foundation of a Functional Implementation of the CNF Algorithm" Algorithms 16, no. 10: 459. https://doi.org/10.3390/a16100459