On Heaviside Binary Logic: a Mathematical Characterization and its Applications

—Major advances in computer capabilities, together with a huge increase in the volume of data being produced every day, have made Artiﬁcial Intelligence an essential technology driving health and wellness growth. Main applications include speech recognition, recommendations systems, computer vision, and medical diagnosis from images. The theoretical concepts asserted by Alan Turing remain, in any case, at the basis of the computation and hence of machine intelligence. Turing Machine, the fundamental computational model, has been proven to be reducible to a logic circuit and, at the same time, portable into a computer program. In this work, the existence of a correspondence between fundamental programming language control structures and mathematical formulation is proven. The proposed interpretation is given through a well-deﬁned logical circuit analytical expression. Relevant geometrical applications having wide implications in engineering branches are presented together with a new Penalty Method for constrained optimization problems handling.


INTRODUCTION
The concept of algorithm [1] was first introduced when David Hilbert posed the Entscheidungsproblem in 1928. Still, it does not have a unique definition. Essentially, it can be regarded as a finite succession of elementary instructions which leads to a result in a finite amount of time. The first and most famous mathematical interpretation was proposed by Kurt Gödel in the early '30s who introduced the notion of recursive functions [2]. Algorithm first characterization took place in 1936 when Alan Turing created a theoretical model, called Turing Machine (TM) [3] in order to prove that Hilbert's problem was unsolvable.
Under specific conditions, any function computed by TM, deterministic or not, can be reduced to a circuit which is composed by a set of Logic Gates (LGs) [4]. Such digital devices implement a Boolean function that takes one or more binary inputs and provides a binary output. Further, patches of circuits can be synthetized into a complicated mathematical objects. For instance, this could either be the transfer function of the electronic circuit or an object that is associated to the truth table of it. Those objects can be inputs of other gates whose definition can be extended to accept and return not only numbers but also functions. The composition of this type of gates results in the description of the whole circuit. In mathematical terms, binary status can be expressed and LGs can be realized as results of specific composition of a certain number of Heaviside Step Functions (HSFs).
This idea can also be applied to programming languages, because they provide an high-level abstraction of the machine language that is mapped into logic circuits.
In fact, Böhm-Jacopini's Theorem [5] states that (i) every algorithm/function can be implemented through sequence, selection and iteration (ii) every TM, up to an extent, is equivalent to a program with only compositions and iterations. This means that it is possible to associate an algorithm to a specific problem, a TM to the algorithm, a logic circuit to the TM and a function to the logic circuit. Therefore, the goal is to correlate an analytical function to the algorithm. HSF emulates the binary selection operation by design. Moreover, iterations can be executed based on essence of operations involved, while sequence is inherently guaranteed.
This concept is particularly suitable in case of analytical/geometrical problems especially in computer graphic, computer vision and geoscience applications. In these fields, one of the fundamental topics is polygons processing which is examined in several studies [6] [7] [8] [9] in literature. Moreover, in [10] two algorithms are designed to discover intersection points between simple polygons. The first is a set-based intersection algorithm while the second is binarysearch-tree-based algorithm which allows the authors to briefly describe a set of possible merging and Boolean operations among polygons. These are also the focus of [11] where the proposed algorithm is also capable to deal with polygons with holes. [12] proposes a GPU-based rasterized polygon intersection area algorithm able to work with complex and large-scale ones. Further, in [13] an algorithm capable of performing clipping, Boolean union and difference between input polygons is presented. Based on entry/exit intersection point property, it uses an efficient data structure and can easily also be adapted to Boolean operations between regions composed by input sets. These kind of geometrical problems have also implications in medical imaging. For instance, in [14] a method is developed for the analytical calculation of the 3D shape and volume of volumes' intersection in order to reconstruct 3D Positron Emission Tomography data. In Robotics geometrical infor-mation about configuration [15], placement, collision [16] or proximity [17] among objects are major concerns. In [18], an algorithm is proposed in order to avoid collisions between a manipulator and an obstacle. These are represented by cylinders and convex plane polygons, respectively, while the intersection among these describes the physical contact. In [19], an algorithm is designed to address another challenging aspect: motion planning. This work takes into account planar polygonal rigid robots that have to move in a polyhedral environment and avoid collisions thanks to decomposability property. The process of determining the robot's position and the obstacles places involves Pointin-Polygon Problem. In [20], instead, the authors propose an algorithm capable of solving this issue and deal with concave and convex polygons of different shapes.
This work tackles these geometrical problems through a set of mathematical solutions. Some of them belong to a cost function which requires to be probed. Optimization techniques [21] and Artificial Intelligence Search Algorithms (SAs) [22], such as Genetic Algorithms (GAs) [23], are able to probe and pick the optimum or quasi-optimum solution in the output space. Therefore, to handle such non-convex and even constrained optimization problems, a new Penalty Method, in combination with GAs [24], is studied.
The present work is organized as follows: Section 2 introduces mathematical definitions and properties of LGs realized through HSF. Section 3 discusses continuous representation of HSF adopted. Section 4 establishes a relation between algorithms and proposed gates. With Section 5, formulation of the solutions to a set of envisioned problems is given. Section 6, instead, presents a new Penalty Method for constrained optimization problems based on examined notions. Section 7, analyses numerical results derived from theoretical concepts discussed. Finally, Section 8 concludes the work and draws future works and research perspectives.

HSF BOOLEAN LOGIC
In this Section, a mathematical characterization is addressed to achieve a proper definition of LGs functions realized by Θ(x), i.e HSF. Information is carried by x, and its binary description is achieved through a discrimination with respect to a threshold, i.e. zero value. In the most complicated case Θ(x) could not be defined for x = 0. On the contrary, the upcoming concepts will result in a exemplification.

HSF Circuit definition
Without loss of generality, let the possible inputs be described with a vector space over a real scalar field, i.e. R D , being O = {x ∈ R D |∃ j : 1...D x j = 0}. Therefore, the definition of the function that encodes the real inputs in binary information is: where Then, it is necessary to define the following sets as: where O r+1 is the analogous of O for any arbitrary input x ∈ R Nr+1 , Θ r acts in the same manner as Θ 0 , and R is the rank, i.e. the number of compositions the HSF Circuit (HSFC) will be made of. Moreover, g r , r : 1...R must be uniform continuous functions. In presence of a chain of compositions, the inner argument of Θ r+1 together with its kernel is: These kernels have to be excluded, because Θ r ( h r ( Θ 0 (x) ∈ Ker(h r )) would not be defined. Obviously, the only argument that has to be checked is h 1 if the rank is R = 1. Therefore, if K is the union of all kernels, the proposed definition of a HSFC H of rank R is: where R r=1 (·) := Θ R • g R • ... • Θ 1 • g 1 , and y = Θ 0 (x) is the input string. If Θ(0) is defined, then the previous definition also holds in K. Indeed, this is a Boolean function with input Θ 0 x . The set of these functions does not have a group structure. However, the set is closed with respect to the composition operation. In the spirit of this notation, the most trivial circuit is the identity which is obtained by setting R = 1 and D = Q: derived from Eq.(4) with: where ξ ∈]0, 1[ D being an arbitrary parameter which takes into account the fact that Θ(0) may not be defined or may be different from zero. This translation allows to have K = K(h 1 ) = K(y − ξ) = ∅. Remark 1. Similar considerations can be done for any set of functions f i : R Ni+1 → B Ni+1 i : 0...R, that encodes in binary the information, by substituting Θ i (·) in the chain of composition. Indeed, Θ i (·) can be another HSFC.

Fundamental HSF Gates
It is worth defining an equivalent LG standard basis Ψ L = {N OT, AN D, OR} with the use of Eq.(4). The HSF representation of Ψ L is defined as the unitary rank (R = 1) basis Ψ H = {N, Λ, Ω}, constituted by the fundamental HSF Gates (HSFGs). These particular circuits are: • NOT: with ξ ∈]0, 1[ D .
As a matter of fact, for a given binary input y, the output of any HSFG of Ψ H is the same of its correspondent LG in Ψ L . Again, the absence of a definition of Θ(0) is taken into account thanks to ξ.

Theorem 1.
Let y∈ B D \K be the input of a HSFG H R . Then, there must exist a logic circuit C such that C(y) = H R (y) where C(y) is the output of C receiving y.
Proof. According to the definition of Ψ H , each function of this set has an I/O relation which has an exact correspondence with the truth table of its analogous in Ψ L . Since Ψ L can reproduce any truth table of any logic circuit C via composition of its LGs, then the same must hold for Ψ H . This means that any HSFG H R determines an I/O relation which must be reproducible through a composition of functions in Ψ L . Corollary 1. NAND is capable of constructing any HSFC via compositions, because it must be as fundamental as Ψ H . The same also holds for NOR. Recalling Remark 1, these can be obtained by composing elements from the Ψ H basis, in the following manner: with ξ ∈]0, 1[.

Corollary 2.
DeMorgan's Theorems are applicable to HSFGs which compose the basis Ψ H .

CONTINUOUS HSF CIRCUIT DEFINITION
The HSF is not suited for contexts and applications in which the differentiability of the functions is required. Several continuous approximations are available but, in this article, the proposed substitution is: where σ is the Sigmoid Function (SF) that has been widely used in engineering and physics application [25] [26]. Furthermore, α is a coefficient that should be set sufficiently high: hereafter it is shown that the difference between the two functions depends on it. Such difference is defined as: where ϑ 0 = Θ(0). It can be compactly reformulated as this formulation δ 0 = 0, independently of ϑ 0 . δ α is an odd function in R * and it is odd in R only if δ 0 = 0: this means that (15) is odd in R. Moreover, δ α goes exponentially to zero ∀x = 0 if α → ∞. At the same time, it goes exponentially to zero ∀α > 0 when x → ±∞ and its 1-norm is 2 ln(2) α . Therefore, the difference between Θ(·) and σ(α·) is small if α is large.
The continuous version of a circuit, namely SF Circuit (SFC), is now seen as a function of a real input: and { g r : [0, 1] Nr → R Nr+1 } r is a set of uniformly continuous functions. Since the logistic function is defined ∀x ∈ R, the circuit can clearly accept any x ∈ R D . Until the end of this Section, the following will be considered as functions of The uniform convergence of a SFC to its correspondent HSFCs can be proven, provided that some considerations are taken into account. The function Θ 0 (x) splits the domain in Q k D-cubes, with k : 1...2 D , and it assumes a constant vector value within each Q * k = Q k \O. Now let R be the rank of a given circuit H R . Since any composition (which H R is made of) factorizes the domain no further than the action of Θ 0 , and since any inner argument of the composition is a constant within the reduced D-cube to have a proper definition of h r in Q * k , it must be that ∀q : Therefore, if the previous happens ∀k : 1..2 D , it must be concluded that dom(H R ) = ∅. This whole argument is an equivalent picture in the input domain of the kernels defined in (2).
Moreover, to get an estimation of the error committed in the evaluation of H R α (x) in place of a given H R (x), the circuits may be regarded as functionals with respect to either σ α or Θ. As a consequence, the notation H[Θ](x) describes Eq.(4) while H[σ α ](x) describes Eq. (16). Now, the equality is trivial, and the variational Taylor series reads: This series is convergent, and it collects both the error and the discontinuity in the functional derivatives. In the case of interest, the parameter is set to one for the equality to hold, but the variation δ α has been proved to be small, so it is expected that the majority of the discrepancy has to be caused by the first orders. Finally, thanks to this analysis, it is possible to define Ψ σ basis which is equivalent to Ψ H but exploiting the logistic function. The fundamental SF Gates (SFGs) that constitute this new basis are N α , Λ α , Ω α for which Corollary 2 still holds.

HSP CONTROL STRUCTURES
Once defined the analytical structure of a general SFG, a correlation can be established between them and algorithms. John E. Savage proved the following, which appears as Theorem 3.8.1 of [4] Theorem 3. Any computation performed by a one-tape Turing machine M, deterministic or nondeterministic, on an input string w in T steps using m b-bit memory cells can be simulated by a circuit C M,T over the standard complete basis Ω of size and depth O(ST) and O(T log S), respectively, where S = mb is the storage capacity in bits of M's tape. For the deterministic TM the inputs to this circuit consist of the values of w. For the nondeterministic TM the inputs consist of w and the Boolean choice input variables whose values are not set in advance.
Based on the above Theorem, the following is proved. Proof. Recalling Böhm-Jacopini's Theorem, P is equivalent to TM M and can be expressed through a combination of the three fundamental control structures: sequence, selection and iteration. Therefore, reminding Theorem 3 it is possible to state that there exists a logic circuit C equivalent to M . Finally, considering Theorem 1 can be claimed that there must exist a HSFC H which is equivalent to C. Hence, control structures must also have a correspondent expression in these terms.
A slight interpretation is presented hereby. However, it does not pretend to be mathematically rigorous as it will considered for future investigations. The proposed characterization is proved to be sufficient for the description of control structures which compose a finite-time algorithm. For this reason, the states of all variables and operations can be expressed through Boolean strings and HSFCs, respectively. This means that a set of commands is translated into a set of HSFCs {H Rr r } r:1...S , and to execute this set in sequence means: where x OU T and x IN are the state variable before and after the sequence. The selection, instead, is inherently addressed by HSF. In fact, given logical conditions which have to be verified, this control structure can be described through a HSFC H R . This returns 1 if the conditions are not satisfied and 0 otherwise. The mathematical expression is: where f 1 and f 0 are the statements executed in false and true cases, respectively.
Finally, for what concerns finite iteration, the definition of a recursive function turns to be necessary: This synthetizes into In fact, once the n-th step is reached, all the others have to be If the iteration ends at the n + 1-th step, then the output is: and this happens if the following condition is satisfied: with L ⊆ B D being the domain of the inputs.

BY INTERSECTING GEOMETRICAL LOCI
In this Section, an interesting geometrical application is studied. The whole mathematical process is deeply described hereby and it is concluded with the equivalent interpretation in terms of HSFGs. Consider a finite set of geometrical loci, described with where x is the generic coordinate in the space R D in which the loci are embedded and q n is a point in the the vector space of parameters which specifies the locus. Addressing the point q n with index n is equal to consider such a point and its dimensionality to be independent from all the others. It is also assumed that f n identifies a closed and compact volume The aim is to find an expression which describes the volume that is effectively encompassed by the set of loci, namely Clearly, the major difficulty stands in the fact that the sum of the measures counts the intersections among different V n a certain number of times, which will be later studied. Obviously, in the trivial case in which no intersections are present Otherwise, in order to obtain µ V from µ S , each intersecting region has to be subtracted in an appropriate way. In other words, intersections have to be counted just once. For instance, consider a D = 2 scenario in which three squares S i , i : 1..3 intersect in region R i , i : 1..3 as shown in Fig.2.
Assuming v as the measure of the unit square, µ S is equal to 48v, while µ V = 30v. Defining R 1 = S 1 ∩S 2 , R 2 = S 2 ∩S 3 and R 3 = S 1 ∩ S 2 ∩ S 3 , it results (in v units) that As previously stated, the measure of each intersection region has to be subtracted a certain number of times that is equal to their multiplicity κ. But first, the characteristic function of the n-th volume has to be introduced: According to the definition of the Heaviside used in this formula, the points verifying f n = 0 count as ϑ 0 that is usually equal to 1 or 1/2, but they also may be not counted at all if ϑ 0 is 0 or NaN. Then, the multiplicity of a point x is defined as follows: In particular, the multiplicity of a point x * which belongs just to one volume is κ(x * ) = 0. Consider a subspace M ⊆ R D V n ⊆ M ∀n. Analytically, the contribution that has to be subtracted from (28) is However, an issue emerges in this formulation since In fact, each point of M that does not belong to any V n has -1 multiplicity, thus incorrectly increasing µ S . A third addendum which rectifies this behaviour is needed: As a matter of fact, the integrand is equal to 1 ∀x f n > 0 ∀n. The parameter ξ is a shift that imposes the aforementioned behaviour. Indeed, points which do not belong to any volume return a value which is different from 0 according to the adopted definition of Heaviside: Basically, as the results in (28)(33)(34) are brought together: (36) The expression above can be rewritten in a more compact manner. It is worth noting that (33) is equivalent to The exchange between the sum and integral signs can be always done if N is finite, and also for N → ∞ under the hypothesis of Fubini's Theorem. Moreover, the first integrand is equal to 1 for every point belonging to V n at fixed n and it is 0 elsewhere. Therefore, the whole first addendum is equivalent to (28). Hence, (36) becomes: Recalling results achieved in Section 2, it is clear that (38) is the following HSFGs composition: which does not correspond to any element of the Ψ H basis. However, it can be described by Algorithm 1 thanks to Theorem 4. Finally, this leads to: which perfectly describes (27). This expression, as stated in Corollary 2, is also equivalent to Remark 2. The characteristic function may not be defined on the locus f n = 0 due to the definition of ϑ 0 . Nonetheless, the measure of a volume does not depend on the value assumed by ϑ 0 because such value concerns the border which is a zero measure set.

Remark 3.
It is worth noting that is sufficient to change the sign of the argument of all HSFs in Eq.(41) to characterize the dual formula for the computation of the intersection among all volumes, that is: Again, recalling Corollary 2, an equivalent expression is that well describes (43).

Error Analysis
The error which is introduced by the use of the logistic function in place of Heaviside is addressed hereby. First, it is necessary to introduce the expression of the error: Considering (18), introduce the variable z = α n (σ α + δ α )(−f n ) − ξ and consider that any term d k d k z, k ≥ 2 is zero, therefore it will not be written. As the same time, it can be reasonably assumed that the perturbation is zero at the border and, as a consequence, terms which are borderrelated are zero too. Hence, it can be written: Moreover, d n dz n δ α (z) = − d n dz n σ α (z) because of the definition of δ α , so the first and third addenda for k ≥ 2 simplify at every term. Let z be equal to z( = 0) = n σ α (−f n ) − ξ and manipulate the following: Finally, as d d z = α n δ(−f n ) and the index of the Taylor series is moved back, it results that

Custom D-dimensional volumes
Another interesting application of Heaviside is the possibility to represent customizable volumes. In fact, the technique presented in previous Section is not limited just to analytical functions. Without loss of generality, consider D = 2. Suppose that this desired area is defined by a closed polygonal chain of N segments, each of them lying on a given line described by f n (or the vertical line x = c, where c is a constant value). Clearly, Θ(f n ) is a binary representation of the inequality f n ≥ 0, because the equation Θ(f n ) = 1 is satisfied only in a subspace of R 2 . Capitalizing the concept of AND HSFG described in Section 2, the customizable area is cast with the following characteristic function: This concept does not rely on choice of f n as these can be anything, as long as X Θ = 1 encompasses a non-zero finite area.

Remark 4.
Reminding results of Section 3, also for this application is possible to define an equivalent SF form X σ , taking advantage of Λ σ .

Remark 5. It should be noticed that
represents a general partition of input domain into a certain number of disjointed sub-domains of arbitrary shape.

Custom D-dimensional borders
According to the formulation proposed so far, a further important result is achieved when the objective is not to calculate the volume but to have an expression of its border. Once again, it is sufficient to exploit the AND HSFG. It is necessary that ϑ 0 = 0 to distinguish the locus of interest in the following manner: where Y Θ is the generic characteristic function which can be composed in one of the several ways previously discussed. In practise, when two face-to-face Heavisides are multiplied, the only geometrical locus that has non-zero value is the desired border. In other words, an equality constraint is imposed as will be seen in the next Section. In particular, if ϑ 0 = {0, 1} then it is just needed: However, it must be noticed that if Y Θ is composed of more than one function, and their borders intersect, then Eq.(52) and (53) are not satisfied at the intersections of borders, except for Eq.(52) when ϑ 0 = 1.
Another way to realize this locus is the substitution defined in (13) so that previous formulation is equivalent to: where Y σ is the characteristic function expressed via SF. Still, intersections do not belong to Γ. If the limit is not taken, an interesting behaviour arises in the proximity of intersections due to the analyticity of σ: For instance, consider the configuration in Fig.3. It consists of a square centered in [2 2] T and a circle in [1 0] T which intersect in [1 1] T . Therefore, the Y σ in Eq.(55) is the sum of the characteristic functions of the square and the circle. The former is made with Eq.(50) and the usual substitution (13), while the latter is done with Eq.(31). As α increases, Γ α gets closer to the real intersection. The presence of the error owed to α results to be negligible, and even advantageous: the proposed formulation represents an optimum analytical approximation of the union border, which in principle (i.e. the exact border) should have no defined gradient at the intersection points.

HSF PENALTY METHOD
In this Section, an alternative representation of constrainedoptimization problems is proposed. This is possible thanks to binary logic granted by HSF. Let us have a cost function A(q) that has to be minimized and it is subject to some equality and inequality constraints Let's pretend, for a while, that the minima of A are different from zero. This hypothesis does not represent a restriction and the lack of it will be handled hereafter. Indeed, usually the cost function has some practical and physical meaning, therefore those minima reasonably lie within a known range. Assuming also that ϑ 0 = 1, it is possible to write the following expression: (56) As in Penalty Methods, the problem is reformulated as an unconstrained one by taking into account a so-called penalty function [27]. The proposed approach takes care of constraints by exploiting AND HSFG. Indeed, previous formulation is equivalent to: As a matter of fact, the resultant function is zero across the whole space where they are not fulfilled, and it coincides with the cost function itself when they are satisfied. Moreover, each equality constraint is enabled through an AND HSFG having in input two face-to-face inequalities. The requirement ϑ 0 = 1 which was stated before is herein clarified. With this assumption, gates return 1 when the weak inequalities g i (q) ≤ 0 are satisfied. As a consequence, it also allows the equality constraints h j (q) to actually work. Otherwise, in both cases zero is provided. This behaviour reproduces the binary logic where the two levels are 0 and A(q) itself. Thus, the usage of the first level has to be denied. Indeed, if some minima are expected to be zeroes of A, it is just needed to shift F sending A into A + c. Clearly, the minimal obtained values have to be shifted back after they have been found. The composition F cannot be globally convex because any of its second-order partial derivatives involves the second derivative of SF with respect to its argument. Therefore, convex optimization methods are not as well-suited as Heuristic SAs. However, these could need to move in a smooth manner between the two spaces (in which the constraints are satisfied or not). To this aim, once again, substitution (13) is necessary and hence SFGs have to be used instead of corresponding HSF forms. In this manner, an exponential slope is given to F, and it will depend on α. In particular, each equality constraint has to be multiplied by a factor 4 because the two σ of which is composed of would give 1/2 each, when it is satisfied. The obtained function F and the optimization process are described by the pseudocode in Algorithm 2.

Algorithm 2 Optimization Process
Input: A, Q, g, h Output: q * 1: SA(F , Q) 2: 3: function F(A, q ∈ Q, g, h) 4: if g i (q) < 0 ... and g m (q) < 0 and h j (q) = 0 ... and h (q) = 0 then 5: return A(q) 6: end if 7: return 0 or asymptotically equal to A(q)e −α 8: end function This method represents an alternative with respect to standard optimization, because the constraints are included in such a way that they are not constraints anymore, but a part of the whole function. Therefore, it is possible to avoid the check of the Karush-Kuhn-Tucker [28] necessary conditions, because they rely on the construction of the Lagrangian while F is formally unconstrained. Thus, computation of weights concerning the classical inclusion of constraints is avoided. Most importantly, as a final remark, this method allows constraints also to be put in any other logical relation.

Curves intersections
A useful geometrical application of proposed HSF Penalty Method (HSFPM) is to find how many and which intersections there are when two or more curves lie in the same locus. The methodology presented hereby is suitable in the case of two curves, but can be iterated in case of more. Consider f 1 , f 2 and X = {x i ∈ R ∀i : 1..N M AX } and Y = {y i ∈ R ∀i : 1..N M AX }, where N M AX is the maximum intersections number (see Bézout's Theorem [29]). The optimization problem can be stated as follows where ζ is a user-defined minimum distance to distinguish intersection points. This is a non-convex optimization problem that is hard to solve even with mathematical approximation. The technique proposed in this Section can be used to reformulate the problem as: A SA can be used to solve this problem.
Basically, every intersection point corresponds to a maxima of the objective function. Moreover, a Θ(·) has been introduced in the objective function derived from (P 1) in order to assure that local maxima are avoided in (P 2), and the function value will now be equal to the number of intersections which the algorithm finds. In fact, every other point which is not a real intersection would not change the discrete function value. However, as it was previously remarked, Θ(·) has to be substituted with σ(α·) in order for the algorithm to decently move in the solution domain and α has to be relatively small. As a consequence, the points in excess would increase the function value in an undefined manner. So, it is necessary to introduce a new integer parameter N which counts the real intersections. As the previous sum and products now extend up to N , one more addendum P is introduced as a penalty cost for having increased N , but in such a way that it must be convenient to pay it if a true intersection is found. To this aim it is necessary to also multiply the objective function for a weight W , such that: The worst case scenario is when the algorithm tries to count a point at a distance ζ from a true intersection as if it was a real one. The requirement in Eq.(58) prevents such unwanted behaviour, as it imposes that when a fake intersection is found the reward gained has to be lower than inflicted penalty. For instance, to achieve this goal, (P 2) can be reformulated as: where J kj is now made with the substitution (13). Despite aforementioned solution, others can be investigated.

NUMERICAL EVALUATION
In this Section, theoretical results discussed in past Sections are evaluated. In particular, a wide experimental campaign has been carried out to analyze each possible application derived from discussed previous notions. GA implemented in MATLAB R2020a is used as SA on a desktop computer equipped with Intel i7 970 and 16GB RAM. For the sake of generality, measurement units are simplified to pure numbers.

Volumes measure error analysis
In order to evaluate results obtained in Section 5.1, a reference scenario is taken into account. Given the general equation of a circle the aim is to compute the union area of C 1 = C(−1, 0, 1) and C 2 = C(1, 0, 1), which are external tangent, placed in a mesh 4x2. This task can be done exploiting Eq.(40): First, the integral has been calculated in MATLAB through the Riemann Summation, with a mesh precision ρ = 10 −4 . The exact result of the area should be 2πR 2 6.28318 but, due to the precision used, the experimental one is 6.28313. This evaluation considers HSFGs that have a discontinuity in 0 that does not represent a problem as stated in Remark 2. However, when SFGs are used, α has an non-negligible impact on the error as discussed in Section 5.1.  As expected Fig.4 shows that, fixed the mesh precision, the error of σ(·), with respect to Θ(·), decreases as α increases. Moreover, the first two orders shown demonstrate that (i) the high-order derivatives accounts for lower α error (ii) for α ≥ 10 the error is negligible.

Custom volume measure
Thanks to this analysis and results obtained in Section 5.2, it is possible to solve problem in the scenario proposed in Similarly, it is possible to build the other two squares S 2 and S 3 , thus obtaining an integrand shown in Fig.5. As previously mentioned, the edges of the volume have a value of 1/2 that is exactly σ(0). Finally, exploiting Eq.(40), with ρ = 10 −3 , α = 10 3 and a mesh 8x8, the calculated area is 29.99998.

HSF Penality Method
To probe results of Section 6 two simulations of different complexity have been done.
The first involves two fixed circles C 1 = C(−2, 0, 1) and C 2 = C(2, 0, 1) placed in a 8x8 mesh. A third one, defined as C 3 = C(x, y, 1) has to be positioned in order to maximize the total covered area. Taking advantage of Eq.(40) and (13), V σ is defined as the SF variant of the Heaviside's one. The task is accomplished by the objective function: where α = 10 3 and ρ = 5×10 −2 . The locus in which the center [x y] T of C 3 has to be placed to maximize the total covered area is shown in Fig.6. As expected, the center should not be in proximity of the two pre-positioned circles. The second experiment emulates a constrained simple scenario in which a drone, equipped with a camera, has to take off and land in the same spot. Throughout the mission, the drone has to pursue a trajectory and scan the maximum possible ground area which is composed of camera shoots over the (x, y)-plane. It is assumed that the drone cannot exceed a maximum speed, it flies at constant altitude and the ratio of acquired images is constant and set to unity.
From an optimization point of view, the problem can be stated as follows: where N is the number of circles C n , whereas X and Y are the sets of centers n : 2..N − 1 coordinates of which trajectory is made of. The start/end points are settled to [−2 − 2] T . Since the acquisition ratio is set to unity, the speed v of the drone corresponds to the distance that is travelled between two consequent points. Motivated by Eq.(56), it is possible to reformulate the problem stated above as: The test has been run in a 4x4 mesh with precision ρ = 10 −2 , N = 7 circles, v M AX = 1.5 and α = 10 2 .
Results of the solution of this problem are shown in Fig.7. Based on solution found by the algorithm, the area covered is ∼11.5. Due to the applied constraint, projected areas are overlapped and cut by the mesh borders. It also results that the adopted speed in each segment is about the maximum possible because, indeed, it minimizes the overlaps.

Custom D-dimentional volumes
In the previous Subsection an interesting pattern has been obtained in terms of covered area. The associated X σ can be useful to test results achieved in Subsection 5.3. The outcome of this simulation is shown in Fig.8, using a 5x5 mesh, ρ = 10 −3 and α = 10 3 . It is worth noting that, even if holes are present in the union of volumes, this is not a problem and a union border Γ can always be realized.

Curves intersections
Another aspect of optimization, discussed in Subsection 6.1, is intersection counting and discovering. Two scenarios have been settled. In the first, two circles C 1 = C(−0.5, 0, 1) and C 2 = C(0.5, 0, 1) are considered. In the second, a circle   intersections (2 and 6 respectively) followed by the related coordinates and then the fake N M AX − N ones. Experimentally, it is important to mention that as the complexity of the involved scenario increases, the research of intersections gets harder in the sense that some runs may not found all of them. In particular, when two or more intersection are close, distinguishing becomes an hard process that could be overcome as fine-tolerance algorithms are used. Another essential note is correlated with custom volumes and, specifically, for what concern oblique segments. On a trial basis, outcomes of simulations confirm that α related to these pieces of volumes should be set not greater than 10 with the aim of speed up the SA operations.

CONCLUSION
The present work discussed a mathematical characterization of binary logic granted by the HSF. Then, an analytical representation through logistic function has been studied. Furthermore, the existence of a correlation between the conceived mathematical structure and a finite-time program has been proved.
Based on these concepts, different geometrical applications and a Penalty Method for constrained optimization problems has been deeply investigated. First, the measure of binary operations among D-volumes is presented. These can also be designed in a custom manner so that a compact region is encompassed by a set of loci. Hence, it is even possible to obtain the border analytical expression of the desired D-volume. Finally, a novel Penalty Method has been realized allowing the reformulation of a constrained nonconvex optimization problem in an unconstrained one.
A wide simulation campaign demonstrated the effectiveness of proposed methodologies which can be employable in many engineering areas such as computer vision and graphics, medical imaging, robotics and automation.
However, several aspects can be further investigated. First of all, a solid correspondence between control structures and proposed HSFGs/SFGs will be addressed. Then, a method to compute the border length of a custom volume will be probed. Current formulation to find intersections could also be improved. Finally, the proposed Penalty Method will be tested with more SAs and compared with other solutions, to settle a proper benchmark.