Lics 13 A
Lics 13 A
Abstract—We initiate the study of regular real analysis, in base 3; (B) if x contains a 1, then replaces every digit
or the analysis of real functions that can be encoded by after the first 1 by a 0; (C) replaces all 2s with 1s; and
automata on infinite words. It is known that ω-automata (D) interprets the result as a binary number, and returns
can be used to represent relations between real vectors,
reals being represented in exact precision as infinite this number (Cf. Example 1 and Fig. 2). Aside from
streams. The regular functions studied here constitute the being among the most well-known examples of fractal
functional subset of such relations. functions, this function is a frequently-cited example
We show that some classic questions in function analysis of a real function that is uniformly continuous but not
can become elegantly computable in the context of regu- absolutely continuous. At the same time, it is difficult to
lar real analysis. Specifically, we present an automata-
theoretic technique for reasoning about limit behaviors express this function in traditional analytical notation;
of regular functions, and obtain, using this method, a neither is it easy to use the traditional calculus to infer
decision procedure to verify the continuity of a regular its nontrivial analytical properties (e.g., continuity).
function. Several other decision procedures for regular Second, even for the functions that the traditional
functions—for finding roots, fixpoints, minima, etc.—are notation can express, automated mathematical reasoning
also presented. At the same time, we show that the class of
regular functions is quite rich, and includes functions that can pose a challenge. Consider the triangle waveform
are highly challenging to encode using traditional symbolic (Fig. 1), a fundamental class of waves in electrical engi-
notation. neering. Analytical representations of the characteristic
function ∆(x) of a triangular wave with period 2 and
I. I NTRODUCTION varying between −1 and 1 include
Real analysis is the branch of mathematics dealing 2
with real numbers and functions over these. In par- ∆(x) = sin−1 [sin(πx)]
π
ticular, real analysis studies analytic properties of real = 1 − 4|1/2 − frac(x/2 + 1/4)|
functions and sequences, including convergence and
limits of sequences of real numbers, the calculus of where frac(x) is the fractional part of x. However, we
the real numbers, continuity, smoothness and related do not know of any natural, efficient procedure for
properties of real-valued functions. Calculus is a branch deciding properties such as the continuity of expessions
of real analysis that focuses, in essence, on the compu- involving sin−1 (·), sin(·) or frac(·).
tational aspects of real analysis. The notation underlying In this paper, we study an alternative, finite represen-
calculus has evolved primarily to facilitate symbolic tation of functions of type Rk → Rl as automata on
computation by hand. Therefore, the notation based on infinite words. Functions expressible this way will be
polynomials, ratios, radicals, exponentials, logarithms, called regular real functions.
and the like is intimately familiar to us. It is well known that automata on infinite words can
While the standard notation of calculus continues represent regular relations over real numbers, encoded
to serve well for numerous applications to the natural as infinite streams of digits. Such representations have
sciences, there are at least two reasons why alternative been used, for example, to develop decision procedures
representations of real functions are of interest. First, for real addition [1] and ω-automatic structures [2]. Our
the traditional notation finds it difficult to express many idea is to represent real regular functions as regular
natural functions. Consider for example the Cantor functional relations on the reals.
function, which: (A) takes an input x ∈ [0, 1] expressed This new notation is quite conducive to efficient
automated analysis. Indeed, the study of such automated
This research was supported by NSF grants CCF-1156059 (CA- analysis algorithms, rather than the expressiveness of the
REER), CCF-1162076, CNS-0953941 (CAREER), CNS-1049862,
and CCF-1139011; NSF Expeditions in Computing project 1139011; automata-based notation, forms the primary focus of this
BSF grant 9800096; and a gift from Intel. paper. Our central technical contribution is an automata-
real concern of this work. Our study, instead, can be
viewed as being part of computable analysis, which
is concerned with the parts of analysis that can be
carried out in a computable manner [8]. Our focus is
on representation of functions as finite automata and
the algorithmic consequences of such a representation.
Our focus here is also different than that of automatic
Figure 1. The triangle wave function.
structures [9], [2], [10]. In automatic structures the
focus is on relational structures where the domain and
relations can be represented by finite automata, as the
theoretic technique for reasoning about limit behaviors first-order theory of such structures is decidable. Here
of regular functions, which we apply in a PTIME we focus on functions that can be represented by finite
(O(n4 )) decision procedure for verifying that a regular automata, and our interest is in developing algorithms
function is continuous. The same procedure can verify for their analytic properties.
in PTIME that a regular function enjoys K-Lipschitz- Recently, some of us have studied algorithmic analy-
continuity, a strong form of uniform continuity that sis of real functions encoded as programs [11], [12],
implies differentiability almost everywhere. A corollary [13], [14]. The procedures studied in those papers
is that a continuous regular function is also Lipschitz- are sound but incomplete. In contrast, here we study
continuous. With minor modifications, the procedure analysis of functions represented by finite automata,
can approximate, up to a constant factor, the optimal and obtain efficient decision procedures for problems
K for which the function is K-Lipschitz. that are obviously undecidable in a Turing-complete
We also give an O(n2 )-time procedure for deciding notation.
the continuity of regular functions that can be repre- Topological notions like continuity have been previ-
sented by deterministic automata. Finally, we present ously considered [15], [16] for automata representing
procedures for linear rational arithmetic over functions, functions from words to words. In particular, Carton et
inverting a function, finding a function’s roots and fixed al. [16] study the continuity of functions over words rep-
points, and globally optimizing a function. resented by synchronized rational relations. Our work
At the same time, we show our automata notation can be seen to study the implications of interpreting the
allows the encoding of functions that are extremely input and output words of such functions as reals, with
challenging to describe in a symbolic notation. For distances between them given by the Euclidean metric.
example, the Cantor function is now represented as a
simple automaton that operates on inputs encoded in II. R EGULAR REAL FUNCTIONS
base 3 and generates outputs encoded in base 2. Other In this section, we define ω-automata that recognize
functions in this category include functions defined on functions between real vector spaces. This definition
fractals such as the Cantor set, and functions that mask depends on a representation of reals as infinite words;
bits in their real-valued inputs. The representation also now we define this representation.
allows the simple encoding of some functions like the Modeling reals by ω-words: Let β ≥ 2 be an
triangle waveform that are expressible in the traditional integer-valued base. Let the digits under this base be
symbolic notation, but not in a way that is amenable to d0 , . . . , dβ−1 , in increasing order, and let Digβ =
automated symbolic reasoning. {d0 , . . . , dβ−1 }. Let value(dj ) : j for j ∈ [0, β −1]. Let
The paper is organized as follows. In Sec. II, we de- positions in an ω-word be numbered 0, 1, . . . , and for
fine the class of regular real functions. Sec. IV, our main any ω-word w, let w(i) denote the symbol in the i-th
technical section, presents our decision procedures. We position of w. Also, for x ∈ R, let Int x,β and Frac x,β
conclude with some discussion in Sec. V. be the unique ω-words over Digβ such that
∞
Related Work: Muller studied real functions computable X
online by a finite automaton [3], and Konecný studied |x| = β i value(Int x,β (i))
i=0
real functions computable by finite transducers [4]. ∞
Rutten’s study [5] of power series from an automata- +
X
β −i value(Frac x,β (i − 1))
theoretic perspective explored the expressive power of i=1
automata representing analytic objects. Also, the idea
of representing exact reals by streams has been pursued Frac x,β ∈
/ (Digβ )∗ (dβ−1 )ω
in depth [6], [7]. In contrast, expressiveness is not the Int x,β ∈ (Digβ )∗ dω
0
2
Thus, Int x,β (i) and Frac x,β (i) are respectively the i-th Definition 1 (Function automata, regular real functions).
least significant digit in the base-β representation of the Let β and γ, both positive integers greater than 1,
integer part of x, and the i-th most significant digit in respectively be the input base and the output base. Let
the base-β representation of the fractional part of x. k, l > 0 be integral dimensions. A function automaton
Now, let Σβ = Digβ × Digβ . Under base β, we of type Rk → Rl and over bases (β, γ) is a nondeter-
represent a real x by a word ρx,β = sgn · w, where: ministic Büchi automaton over (Σkβ × Σlγ ) ∪ {+, −}k+l
1) sgn denotes the sign symbol. It equals the symbol such that the following conditions hold:
+ if x ≥ 0, and − otherwise. (1) for all inputs w ∈ Rkβ , there is at most one output
2) w is the unique ω-word over Σβ such that for all w0 ∈ Rlγ such that hhw, w0 ii ∈ L(A); and
i > 0, ρx,β (i) = (Int x,β (i), Frac x,β (i)). (2) for all inputs w ∈ Rkβ , there exists an output w0 ∈
The set of all words ρx,β is denoted by Rβ . Rlγ such that hhw, w0 ii ∈ L(A).
To define vectors, we need some more notation. Let
The (analytical) semantics of A is the function [[A]] :
k > 0 be a constant, integral dimension, let Σkβ =
Qk k k
Rk → Rl such that for all x ∈ Rk , y ∈ Rl ,
i=1 Σβ , and for σ = (x1 , . . . , xk ) ∈ Σβ ∪ {+, −} ,
define Proj j (σ) = xj for all j. For σ1 ∈ Σkβ1 ∪ [[A]](x) = y iff hhρx,β , ρy,γ ii ∈ L(A).
{+, −}k1 , σ2 ∈ Σkβ2 ∪ {+, −}k2 , let
A function f : Rk → Rl is regular under input base β
hhσ1 , σ2 ii = (Proj 1 (σ1 ), . . . , Proj k1 (σ1 ), and output base γ iff it is the analytical semantics of a
Proj 1 (σ2 ), . . . , Proj k2 (σ2 )). function automaton as above.
For words w1 ∈ (Σkβ1 ∪ {+, −}k1 )ω and w2 ∈ Our definition of regular functions is naturally gen-
(Σkβ2 ∪ {+, −}k2 )ω , let hhw1 , w2 ii be the word w such eralized to one where different components of the input
that for all i, w(i) = hhw1 (i), w2 (i)ii. We abbreviate and output vectors of a function are coded in different
hhw1 , hhw2 , . . . , wk ii . . .iiii by hhw1 , . . . , wk ii. bases. All the results of this paper hold even under this
Now, a vector x ∈ Rk is represented by a word generalization. However, to keep our notation simple,
ρx,β = hhw1 , . . . , wk ii such that wi = ρx(i),β . The set we continue working with Definition 1.
of all words ρx,β , for some x, is denoted by Rkβ . For We will also find useful a definition of regular sets of
w ∈ Rkβ , we let [[w]] be x ∈ Rk such that ρx,β = w. real vectors. Let us fix a base β. We let an automaton
Modeling functions: We define regular functions as over (length-k) real vectors be a Büchi automaton V
restrictions of synchronized rational relations [17], or such that L(V) ⊆ Rkβ . The semantics of V is the set
word relations that are accepted by finite automata [[V]] such that [[V]] = {x : ρx ∈ L(V)}. A set of real
operating on a product alphabet. The automata chosen vectors is regular under base β if it equals [[V]], for some
for our definition are nondeterministic, and accept via automaton V as above.
the Büchi condition. Also, we allow the component Recognizing sets and functions: The recognition
words of our relations to be over different bases. problem for regular functions (similarly, regular sets
Recall that a Büchi automaton over a finite alphabet of real vectors) is to determine, given an arbitrary
Σ is a tuple A = (Q, Σ, q0 , −→, G), where Q is a finite Büchi automaton A, whether A is a function automaton
set of states, q0 ∈ Q is the initial state, −→⊆ Q×Σ×Q (similarly, automaton over real vectors). We have:
is an edge relation, and G ⊆ Q is a set of repeating
a Theorem 1. The recognition problem for regular sets
states. We write q1 −→ q2 if (q1 , a, q2 ) ∈−→, and let
of vectors can be solved in O(n2 ) time. The recognition
the size of A be (|Q| + | −→ |). A run of A on w ∈ Σω
problem for regular functions is in PSPACE.
is a word η ∈ Qω such that: (1) η(0) = q0 ; and (2) for
w(i)
all i, qi −→ qi+1 . The run η is accepting of some state Proof: (Sketch) We sketch a proof of the second
in G appears infinitely often in η. The language L(A) statement. Given an automaton Ain , we construct an
of A is the set of words on which A has an accepting automaton A that only runs on words of form hhw1 , w2 ii
run. where w1 ∈ Rkβ , w2 ∈ Rlγ , and accepts such a word iff
Also, let us lift the map Proj j as follows. Let w ∈ Ain does. This is done by intersecting Ain with k copies
(Σm m ω
β ∪ {+, −} ) , and let w1 , . . . , wm be such that
of an automaton recognizing words in Rβ that represent
w(i) = (w1 (i), . . . , wm (i)) for all i ≥ 0. For 1 ≤ j ≤ valid real number encodings and l copies of Rγ that
j 0 ≤ m, we define Proj [j,j 0 ] (w) = hhwj , . . . , wj 0 ii. represent valid words in base γ. To check if condition
(1) in Definition 1 holds, we construct a product A0 that
3
(b, 1),
(b, 1)
(0), (0) (∗), (0) s1 t1
(∗, 0), (∗, 0), (b, 0), (b, 0),
(1), (1) (0, 0) (0, 0) (b, 0) (b, 0)
start s0 s1
start s0 start t0 t3
(b1 , b2 ),
(2), (1) (∗, 1), (∗, 1), (b, 1), (b, 1), (b1 , b2 )
(0, 0) (0, 0) (b, 1) (b, 1)
s2 t2
(b, 0),
(b, 0)
Figure 2. (Top) A plot of the cantor function on the [0, 1) interval.
(Bottom) A regular function representation with input base 3 and
output base 2. The integer part since the inputs are in the [0, 1) Figure 3. Automaton representing a function fC which is non-zero
interval. Each edge is labeled by a pair (i), (j) where i is the base 3 outside the modified Cantor set. Note that that we have two start states
input bit and j is the base 2 output bit. ∗ denotes a don’t-care digit s0 and t0 . Each transition is labeled as (i, r), (i0 , r0 ) where (i, r)
(0, 1 or 2) represents the integer and fractional parts of the input; and (i0 , r0 )
represents integer/fractional parts of the output. Here b denotes a 0
or 1 bit that has the same value in the input and output. We omit the
transitions reading the sign of the input.
operates over the alphabet Σk+2l and satisfies
L(A0 ) = {hhw1 , w2 , w3 ii : hhw1 , w2 ii ∈ L(A),
hhw1 , w3 ii ∈ L(A), w2 6= w3 }.
Condition (1) in Def. 1 holds iff the language of this
automaton is empty, which can be checked in quadratic
time. To check condition (2), we construct an automaton
A0 such that L(A0 ) = {w : ∃w0 .hhw, w0 ii ∈ L(A)},
then check that A0 contains the language Rkβ of all valid
words encoding real valued k−vectors.
III. E XAMPLES
In this section, we present some regular functions, Figure 4. (Left) Function fC on the modified Cantor set and (Right)
A bitmasking function applying xi ∧ xi−1 on successive bits of the
showcasing some functions that can be represented binary expansion.
succinctly by automata, but are challenging to describe
in traditional symbolic notation.
2) For each interval [`, u) ⊆ R encountered, we
Example 1 (Cantor function). Consider the Cantor recursively apply the procedure on intervals [`, ` +
function CF (x), which is a popular example of a (u−`) 3(u−`)
4 ) and [` + 4 , u).
fractal function and a function that is uniformly but not
Let C be the set obtained in the limit, which we will
absolutely continuous, and is defined as follows:
call the modified Cantor set. The set C is represented
1) Express x in base 3. by real numbers r such that the fractional parts of the
2) If x contains a 1, replace every digit after the first binary expansion of r lies in the language (00|11)ω .
1 by 0. Consider the following piecewise function fC :
3) Replace all 2s with 1s.
4) Interpret the result as a binary number. The result x if x 6∈ C
fC (x) =
CF (x) is this number. 0 otherwise
A plot of CF (x) is provided in Fig. 2. It is easy to
Figure 3 shows an automaton with input base 2
express CF (x) by a function automaton over input base
and output base 2 that recognizes the function fC .
3 and output base 2—the automaton is shown in Fig. 2
Note that the automaton has two start states, and uses
as well.
nondeterminism to guess upfront whether the input is
Example 2 (Modified Cantor Set). Consider the Cantor expected to belong to C or otherwise.
set, defined informally as the limit of the following Example 3 (Triangle waveform). Consider the triangle
recursive subdivision process: waveform ∆(x) (Fig. 1) with period 2 and varying
1) Start with an interval [n, n + 1) where n ∈ Z. between −1 and 1. One definition of this function is
4
∆(x) = 1 − 4|1/2 − frac(x/2 + 1/4)|, where frac(x) is a set S of length-k vectors such that the input base of
the fractional part of x. A equals the base of V. The set f (S) is regular, and
This function is easily encoded using an automaton A an automaton for it can be constructed in O(n2 ) time.
with input and output bases 2. Note that there is a simple
Regular functions are closed under linear arithmetic
automaton encoding the absolute value function | · |: it
operations of addition, subtraction and scaling by ra-
just reads the sign of the input x and switches it from −
tionals. These results are interesting given that it is
to + if needed. An automaton for frac(x) is also easy
known that addition over rationals is not expressible
to construct. Now we construct A using procedures for
using automata over finite words [18]. Recent work
composing and doing arithmetic over regular functions
by Abu Zaid et al. demonstrates the surprising result
that we give in Sec. IV.
that if for any chosen representation for real numbers
Example 4 (Bit Masking Functions). Consider the addition is ω−automatic then multiplication is not, and
function that operates on the binary expansion of the vice-versa [19]. It follows that regular functions are
fractional part by setting the value of the current bit not closed under multiplication under the representation
fi0 of the output to be fi ∧ fi−1 . Likewise, for the chosen in this paper.
integer part, we have b0i ← bi ∧ bi+1 . The boundary
Theorem 4. Given function automata A1 and A2 over
case for i = 0 for the fractional part is handled by
the same input/output bases, one can construct in O(n2 )
setting f00 ← f0 ∧ b0 . Figure 4 plots this function over
time function automata A+ and A− such that [[A+ ]] =
a range of inputs in (−16, 16). Note the fractal (self-
[[A1 ]] + [[A2 ]] and [[A− ]] = [[A1 ]] − [[A2 ]].
similar) nature of this function. In fact, such functions
which are readily expressible by finite state machines Theorem 5. Given a function automaton A1 and a
defy an easy analytical closed form characterization in rational scalar x (encoded in the same base as the input
terms of familiar algebraic or transcendental functions. base of A1 ), one can construct in O(n2 ) time a function
automaton A such that [[A]] = x[[A1 ]].
IV. A CALCULUS OF REGULAR REAL FUNCTIONS
This section presents our “calculus”: a set of deci- B. Reasoning about limit behaviors: Continuity and
sion procedures for reasoning about regular functions. Lipschitz-continuity
The central contribution here is an automata-theoretic Classical analysis is fundamentally the study of limit
method for reasoning about limit behaviors of regular behaviors of functions. Now we present the centerpiece
functions, which we apply in a decision procedure to of this paper: an automata-theoretic method for rea-
verify the continuity of a regular function f (Sec. IV-B). soning about limit behaviors of regular functions. We
A. Elementary operations show our method in action by using it in a PTIME
decision procedure for verifying continuity, the most
We start by giving procedures for some elementary fundamental of analytic properties. The same procedure
operations on regular functions. Our first procedure is can decide Lipschitz-continuity.
for composing two regular functions: For simplicity, we restrict ourselves here to regular
Theorem 2 (Composition). Given function automata functions of type (0, 1) → (0, 1).1 Such functions can
A1 and A2 over the same input/output bases, one can be represented by automata that make sure that the
construct in O(n2 ) time a function automaton A such integral parts of the input and output are always of the
that [[A]] = [[A1 ]] ◦ [[A2 ]]. form (d0 )ω . In fact, we assume that these integral parts,
as well as the initial sign bit, do not exist at all—i.e.,
Proof: We first add an extra input to A1 to yield a real is just represented by an infinite word over the
A01 that operates over a triple hhw1 , w, w2 ii by simply set of digits Dig. A function is then represented by
ignoring w2 and accepting the input if hhw1 , wii is an automaton over the alphabet Dig × Dig, where the
accepted by A1 . Likewise, A02 is obtained by adding first component represents the input bit and the second
an extra input so that hhw1 , w, w2 ii is accepted by A02 component represents the output.
iff hhw, w2 ii is accepted by A2 . We intersect A01 and A02 ,
and project the middle input w. This yields the required Definition 2 (Continuity, Lipschitz). A function f :
function composition. (0, 1) → (0, 1) is continuous at y ∈ (0, 1) if
A variant of the above construction shows that: limx→y f (x) = f (y). By an alternate definition,
Theorem 3 (Application). Let A be an automaton 1 This assumption is only for simpler exposition. Our results extend
accepting f : Rk → Rl , and V an automaton encoding to general regular functions f : Rk → Rl .
5
f is continuous if for any sequence {xn }n∈N of concerns this output. We now provide a proof of the
points in (0, 1), we have limn→∞ xn = y =⇒ theorem above, starting with the forward direction.
limn→∞ f (xn ) = f (y). By yet another definition (the
Lemma 1. If there exists a reachable state s of A such
Weierstrass definition), f is continuous at y if
that for strings α : 01ω and γ : 10ω , outs (α) 6=
∀ > 0 : ∃δ > 0 : ∀x : outs (γ) then the function f is discontinuous.
y − δ < x < y + δ ⇒ f (y) − < f (x) < f (y) + .
Proof: Consider the sequence of inputs αi :
The function f is K-Lipschitz (or Lipschitz- 0(1)i 0ω for i = 1, 2, . . . , ∞. We note that since A is
continuous with Lipschitz constant K) if for all x, y ∈ deterministic, the output produced by A starting at state
(0, 1) such that x 6= y, |f (x)−f
|x−y|
(y)|
< K. s when fed the string αi will coincide with the output
from α upto i or more places. Let the output from α
It is well-known that for any function f , if f is
and γ deviate after N digits. Due to determinism we
Lipschitz-continuous, then f is continuous everywhere.
conclude that the outputs for αN +1 , αN +2 , . . . deviate
Now note that a decision procedure for continuity of
from the output for γ.
regular functions follows from the Weierstrass defini-
Now let π be some finite prefix that allows us to reach
tion: because regular functions are closed under addition
the state s starting from the initial state s0 . Consider the
and Büchi automata permit elimination of quantifiers
real value represented by x : (πγ) and the sequence of
over words, we can construct an automaton accepting
real values represented by xi : (παi ). We note that xi →
the set of points at which a function is continuous.
x as i → ∞. However, |f (xi ) − f (x)| > 2−(1+N +|π|) .
However, due to quantifier alternation in the definition,
Therefore, f is discontinuous at x.
the complexity of this procedure is EXPSPACE [20]. In
contrast, the method we present is in PTIME (O(n4 )). We now prove the other direction of the implication.
It is completely different from the above naive approach We note that, in general, every discontinuity of f is
in that it relies on the definition of continuity in terms witnessed by the input r and a sequence x1 , x2 , . . .
of limit sequences. such that xj → r as j → ∞ and f (xj ) 6→ f (r). The
Now we proceed to our decision procedure. First we following claim is quite useful in proving the reverse
give a fast, O(n2 )-time procedure for the case when the direction. Let wr be the word in (0+1)ω that represents
automaton encoding the function is deterministic. For r and zj represent xj .
notational simplicity, we restrict ourselves in the rest of Lemma 2. Assume that wr has infinitely many 0s
this section to the case where the input and output bases and infinitely many 1s. For any sequence xj → r,
are both 2. However, the results are easily extended to let Kj ≥ 0 be the length of the longest common
general input/output bases. subsequence between the ω-words zj and wr . It follows
1) Continuity Analysis: Deterministic Automaton: that Kj → ∞ as j → ∞.
Let us define deterministic function automata in the
standard way. For a deterministic automaton A, and Lemma 3. If f is discontinuous at r then r must be
reachable state s, let outs (w) represent the output real represented by a string of the form π0ω .
number obtained for the input string with fractional part Proof: We split cases on wr , the word representa-
w and integer part 0ω , with the automaton initialized to tion of r. (case-1) wr has infinitely many zeros and
state s. infinitely many ones. From Lemma 2 above, zj and
Theorem 6. The function represented by A is contin- wr coincide to arbitrarily many positions as j → ∞.
uous if and only if for every reachable state s in A, Therefore, the determinism of A guarantees that a dis-
outs (01ω ) = outs (10ω ). continuity cannot occur at r since if the inputs coincide
to Kj places, then so must the outputs.
The reader may notice that the fractional part 01ω (case-2) The only possible case is that wr has finitely
in base 2 does not represent a valid real number. many 1s (finitely many zeros is not a possible represen-
However, this fact is immaterial to our theorem. The tation of a real). Therefore r must be represented by a
fact that the automaton is deterministic means that it string of the form π0ω .
produces outputs for αi : 01i 0ω for each i ∈ N.
Finally, we can prove the reverse direction.
We can invoke pumping lemma and the properties of
deterministic Büchi languages to show that A must Lemma 4. If a function is discontinuous then there
necessarily produce some output for the string 01ω exists a reachable state s of A such that outs (10ω ) 6=
starting from any reachable state s. Continuity analysis outs (01ω ).
6
Theorem 6 extends to bases β ≥ 2. For base 3, we tant than the language accepted is the labeling function
require that at each state the outputs for the string α1 : performed by the run of Aw , which precisely pinpoints
10ω coincide with γ1 : 02ω , and the output for α2 : 20ω the first point of difference between the sequences
be equal to γ2 : 12ω . representing (x, y). In this regard, we may also regard
Aw as a finite state transducer outputting a label S or
Example 5. Consider the automaton for the Can-
D upon encountering each bit of (x, y).
tor function from Example 1 (see Fig. 2). We ver-
ify continuity by comparing the output on states s0 1) Consider inputs x = 010011101 . . . and y =
and s1 for the strings αj , γj for j = 1, 2. State 0010011000 . . .. We note that the first position of
s1 has an output 0ω regardless of the input. For s0 , difference is at the second significant digit (implic-
outs0 (10ω ) = 10ω and outs0 (01ω ) = 01ω . Both 10ω itly, all digits are after the radix point). Therefore,
and 01ω are binary representations of 21 (we ignore the we require each run of Aw to be of the form S2 Dω .
fact that the latter input/output pair are disallowed in 2) On the other hand, consider the input x =
our formalism). Next, we observe that outs0 (20ω ) = 0010000ω and y = 000111 . . .. The significant
10ω and outs0 (12ω ) = 10ω . Therefore, we verify that difference here is actually at the sixth digit, even
the Cantor function is continuous. though the two inputs seem to have diverged at
the third significant place. This subtlety arises for
Theorem 7. Given a deterministic regular function A inputs that fit the pattern (0+1)∗ 10ω , wherein there
the complexity of checking continuity is O(|A|2 ). is an infinite trail of zeros. Therefore, we expect
each run of Aw upon input (x, y) to be of the form
2) Continuity Analysis: Nondeterministic Automata:
S6 Dω .
Now we consider continuity analysis for the more
general case where the automaton encoding a regular We now describe the construction of Aw . For the sake
function f is nondeterministic. In fact, what we give of presentation, we do not show all the parts of the
is an automata-based construction to search for a real construction, appealing instead to well known closure
number x ∈ (0, 1) at which the function is discontin- properties of ω- automata.
uous. In more detail, the construction simulates two We construct Aw by composing together the follow-
sequences {xi } and {yi } that converge to x in the ing components:
limit as i → ∞, such that, f (xi ) and f (yi ) converge 1) Let A|x−y| represent the function automaton that
to different limits, or diverge. The main technique is computes |x − y|. This is obtained by composing
to define an automaton AR that accepts a four-tuple the functions f (x, y) = (x − y) and g(z) = |z|.
of reals (x, y, f (x), f (y)). The automaton’s states are 2) Let A1 represent the automaton with two states
labelled by propositions to track positional differences S, D, standing for same and different, respectively,
between the binary expansions of x, y and f (x), f (y) that remains in the S state as long as the input is
respectively. A discontinuity is found when the position 0 and transitions to a D state as soon as a 1 is
of divergence between x, y can be pushed arbitrarily encountered:
far away from the radix point whereas the divergence 0 ∗
between f (x), f (y) can be made to stay within some
initial bound. Such a pattern is established by finding a 1
lasso in AR . start S D
Our construction uses a widget automaton Aw for
tracking positional differences between two input se- The overall automaton Aw is obtained by composing
quences in Σω . This automaton recognizes a relation the automaton for A|x−y| with the automaton A1 to
over inputs x, y ∈ (0, 1). The states of Aw are par- track the first position of difference, as explained above.
titioned into two sets S (standing for “Same”) and D The composition is intended to simulate the computa-
(standing for “Different”). tion of |x − y| by A|x−y| upon encountering x, y. The
Aw has the following key property: For each input result is fed to A1 operating on the output of A|x−y| . A
(x, y) such that 2−(1+K) ≤ |x − y| < 2−K for some standard product construction between A|x−y| and A1
K ≥ 0, every resulting run remains in a S state for achieves the composition. The output of A|x−y| is then
the first K + 1 steps and then transitions to a D state, projected away.
remaining in a D state for the rest of the run. Each state of Aw is a pair consisting of a state of
Formally, the language accepted by Aw is Lw = A|x−y| and A1 . A state of Aw is said to be a S state
{(x, y) | x 6= y, x, y ∈ (0, 1)}. However, more impor- if the component corresponding to A1 of the state is S.
7
Likewise, a state of Aw is said to be a D state if the SI , DO DI , DO
component of Aw is said to be D. π2 πa
Lemma 5. For any inputs x, y, where 2−K > |x −
y| ≥ 2−(1+K) then every accepting run of Aw remains SI DO
s0 s1 s2
in a S state for the first K + 1 steps and in a D state start SI , SO SI , DO DI , DO
π1 π3
for the remainder of the run.
Proof: Aw works (conceptually) by first computing
A|x−y| and then feeding the output to A1 . Since |x − Figure 5. A (SI , DO ) lasso for finding discontinuity.
y| is a function, the output for a given x, y is unique.
Likewise, note that A1 is deterministic. Therefore, for 2) A (SI , DO ) cycle π2 from s1 onto itself.
a given output |x − y|, the run induced on A1 is unique. 3) A path π3 from s1 to a repeating state s2 satisfying
Furthermore, if |x−y| ∈ [2−K , 2−(1+K) ), then |x−y| is (DI , DO ) that lies in a cycle.
of the form 0K 1(0+1)ω . Therefore, A1 has a run of the 4) An accepting cycle πa containing s2 .
form SK+1 Dω . As a result, for the overall composition The main result of our approach is based on the
Aw , any resulting run (note that A|x−y| need not be following theorem:
deterministic) has a prefix of K + 1 states labelled S
and the remainder of the states labelled as D. Theorem 8. Function f is discontinuous if and only if,
The next step of the procedure constructs an automa- AR has a (SI , DO ) lasso.
ton AR representing a relation R between four real Proof: We will show that if such a path exists, then
numbers (x, y, z, w) such that: f is indeed discontinuous. Next we will show that if f
1) z = f (x) and w = f (y). This is obtained as an is discontinuous, then such a lasso can be found.
interaction between two copies of the automaton We recall that f is continuous iff for every sequence
for f , one for each of the equalities. Extra tapes {xi } converging to x, the sequence {f (xi )} converges
added to the first copy enforcing z = f (x), to to f (x). Our approach will demonstrate two different
accommodate y, w, and likewise x, z tapes added sequences converging to some x, wherein, the values of
to the second copy enforcing w = f (y). the functions converge to different values.
2) We take the product with Aw (x, y) and Aw (z, w) (⇐) Assume that a (SI , DO ) lasso, as described in
to mark the positional differences between the Figure 5, can be found in the automaton AR .
inputs x, y and the outputs f (x), f (y). We consider sequences {xi }, {yi } that follow the
We label a state in the product automaton AR as path π(n) : π1 π2n π3 πaω for each n > 0. Let Nj
SI if the component corresponding to Aw (x, y) is a S represent the length of a path πj for j = 1, 2, 3. Let
state and DI otherwise. Likewise, we label a state SO V (x, π) represent the value of x along a path segment
if the component Aw (z, w) is part of a S state and DO π (assuming that the implicit radix point lies just before
otherwise. the path).
Informally, a state labelled SI in AR tells us that the The value of x represented by π(n) is
inputs x, y have not diverged. Likewise a state labelled xn = V (x, π1 ) + 21−N1 (1 − 2−nN2 −1 )V (x, π2 )
DI tells us that the inputs have diverged sometime in +2−N1 −nN2 V (x, π3 ) + 21−N1 −nN2 −N3 V (x, πa ) .
the past. The same consideration applies to the SO and
DO labels. Likewise, the value of y represented by π(n) is
We assume that all states in AR are reachable from yn = V (y, π1 ) + 21−N1 (1 − 2−nN2 −1 )V (y, π2 )
the initial state and furthermore, every state in AR can +2−N1 −nN2 V (y, π3 ) + 21−N1 −nN2 −N3 V (y, πa ) .
reach a repeating cycle. States that do not satisfy these
criteria can be removed from AR without modifying its Note that since π1 , π2 are part of SI , we have
language. V (x, π1 ) = V (y, π1 ), V (x, π2 ) = V (y, π2 ) .
To decide if f is discontinuous, we search for a
(SI , DO ) lasso in AR —i.e., a substructure of AR with Consider the limits of the sequence xn , yn , as n → ∞.
the following components (see Figure 5): Specifically,
1) A path π1 from some start state s0 satisfying SI to limn→∞ xn = V (x, π1 ) + 21−N1 V (x, π2 )
a state s1 satisfying (SI , DO ). The states involved = V (y, π1 ) + 21−N1 V (y, π2 )
in the path π1 are all SI states. = limn→∞ yn
8
Likewise, we note that V (f (x), π1 ) 6= V (f (y), π2 ). Now we note that:
Therefore, for all n,
Theorem 10. If a regular function f is continuous then
2
|f (xn ) − f (yn )| > 2−N1 . it is K-Lipschitz with K < 2O(n ) , where n is the size
of the automaton representing f . Further, in this case
Therefore, we have our decision procedure can compute at no extra cost a
( lim f (xn )) − ( lim f (yn )) > 2−N1 . K such that K ≤ γKmin , where Kmin is the minimum
n→∞ n→∞ Lipschitz constant for which f is Lipschitz-continuous,
Therefore, f is discontinuous at x = V (x, π1 ) + and γ is the output base.
21−N1 V (x, π2 ).
Proof: The proof of the first statement simply
(⇒) We will now prove that if AR does not have
copies the (⇒) direction of the proof of Theorem 8.
a (SI , DO ) lasso, then the function f is Lipschitz
We prove the rest for γ = 2. If f is continuous,
continuous. I.e.,
then our procedure can compute using a graph search
|f (x) − f (y)| the maximum length Ns of the fragment π2 in any
(∃ K) (∀ x, y)(x 6= y) ⇒ ≤K.
|x − y| run of AR (π2 and AR are as before). Let the K in
It is well-known that Lipschitz continuity implies conti- the theorem statement equal 2Ns . Now observe that
nuity. Consider any two inputs x, y such that x 6= y. The if Kmin < K/2 = 2Ns −1 , this maximum length is
tuple (x, y, f (x), f (y)) has an accepting run through (Ns − 1) rather than Ns , which is a contradiction.
AR . Each run starts in a (SI , SO ) state and ends up in We note that by Rademacher’s theorem [21], a K-
a (DI , DO ) repeating cycle. We differentiate two types Lipschitz function f : Rk → Rl is differentiable almost
of accepting runs: everywhere (i.e., the set of all its nondifferentiable
points has measure 0). It follows that a continuous
1) The run reaches a DO state at the same step or after
regular function is differentiable almost everywhere.
reaching a DI state. We note that in this case, the
Can we verify that a regular function is differentiable
output diverges at the same step or after the inputs
everywhere? Note that a witness to a function’s non-
do. Therefore, |f (x) − f (y)| ≤ |x − y|.
differentiability is a pair of sequences that show that
2) The run reaches a (SI , DO ) state before reaching a
the limit limh→0 D(x, h) where D(x, h) = f (x+h)−f (x)
(DI , DO ) state. The diagram below illustrates the h
does not exist. If D was a regular function, our approach
prefix of such a run:
for reasoning about limits would extend to this problem
π1 π2 as well. The challenge, however, is that D(x, h) con-
start SI , SO SI , DO DI , DO tains a division, which cannot in general be encoded by
finite automata.
In this case, there are no cycles involving (SI , DO ) C. Inversion, roots, fixpoints, optimization
states, or else, we will have a (SI , DO ) lasso in
AR . Therefore, the length of the run segment π2 An appealing feature of regular functions is that their
is bounded by Ns , the number of states satisfy- roots can be found easily. Before we show why, observe
ing (SI , DO ). As a result, in this case, we have that regular functions are easily invertible:
|f (x) − f (y)| < 2−|π1 | while |x − y| > 2−|π1 |−Ns . Theorem 11. Given a function automaton A for a
2
Therefore, |f (x)−f (y)|
|x−y| < 2Ns = 2O(N ) . bijective regular function f : Rk → Rl , we can
construct a function automaton for f −1 in O(n) time.
Observe that the essential idea in the above proof—
Proof: We simply swap the inputs and outputs of
capturing a limit of the form limx→0 g(x) using a cycle hhσ1 ,σ2 ii
in an automaton that can be “pumped” arbitrarily many A—i.e., we replace each transition q −→ q 0 in A,
hhσ2 ,σ1 ii
times—is not restricted to continuity. We can apply this where σ1 ∈ Σk , σ2 ∈ Σl , by the transition q −→
idea to other properties that involve limits as well. q . As f is bijective, this modified automaton A0 is a
0
9
Now consider the problem of computing the roots of [4] M. Konecný, “Real functions computable by finite au-
a regular function f —i.e., the set of all solutions to the tomata using affine representations,” Theor. Comput. Sci.,
equation f (x) = 0. We have: vol. 284, no. 2, pp. 373–396, 2002.
Theorem 12. The set R of roots of a regular function [5] J. Rutten, “Automata, power series, and coinduction:
Taking input derivatives seriously,” in ICALP, 1999, pp.
f is regular as well. Given an automaton A for f , an 645–654.
automaton for R can be constructed in O(|A|) time.
[6] H.-J. Boehm, R. Cartwright, M. Riggle, and
Proof: Let A0 be the automaton that accepts M. O’Donnell, “Exact real arithmetic: A case study in
hhw, 0ii for arbitrary string w and output 0. The size higher order programming,” in LISP and Functional
of A0 is fixed given the dimensionality of the output Programming, 1986, pp. 162–173.
for f . We intersect A with A0 and project the second [7] P. Potts, A. Edalat, and M. Escardó, “Semantics of exact
(output) component away from the result. The resulting real arithmetic,” in LICS, 1997, pp. 248–257.
automaton accepts the set of roots of A.
The above proof can be easily modified to show that: [8] K. Weihrauch, Computable analysis: an introduction.
Springer, 2000.
Theorem 13. The set F of fixpoints of a regular
[9] B. Khoussainov and A. Nerode, “Automatic presenta-
function f is regular as well. Given an automaton A for
tions of structures,” in LCC, 1994, pp. 367–392.
f , an automaton for F can be constructed in O(|A|)
time. [10] B. Khoussainov, A. Nies, S. Rubin, and F. Stephan, “Au-
tomatic structures: Richness and limitations,” Logical
It is also easy to globally optimize a regular function. Methods in Computer Science, vol. 3, no. 2, 2007.
Given a regular function f , let us seek the set of
minima (maxima) of f —i.e., inputs x for which f (x) [11] S. Chaudhuri, S. Gulwani, and R. Lublinerman, “Conti-
nuity analysis of programs,” in POPL, 2010, pp. 57–70.
is minimized (maximized). We have:
[12] S. Chaudhuri, S. Gulwani, R. Lublinerman, and
Theorem 14. If f is a regular function, then the set S. NavidPour, “Proving programs robust,” in SIGSOFT
µf of minima of f is regular as well. Further, given an FSE, 2011, pp. 102–112.
automaton for f , we can construct in exponential time
an automaton for µf . [13] S. Chaudhuri, S. Gulwani, and R. Lublinerman, “Conti-
nuity and robustness of programs,” CACM, vol. 55, no. 8,
V. C ONCLUSION pp. 107–115, 2012.
In this paper, we have introduced ω-automata as a [14] S. Chaudhuri and A. Solar-Lezama, “Smooth interpreta-
representation of real functions. We have given exam- tion,” in PLDI, 2010, pp. 279–291.
ples of nontrivial functions (e.g., the Cantor function)
[15] C. Prieur, “How to decide continuity of rational functions
expressible this way, and presented a PTIME method on infinite words,” Theor. Comput. Sci., vol. 276, no. 1-2,
for deciding the continuity of a regular function. pp. 445–447, 2002.
We leave open two questions. First, is it decidable to
check whether a regular function is differentiable? For [16] O. Carton, O. Finkel, and P. Simonnet, “On the conti-
nuity set of an omega rational function,” ITA, vol. 42,
reasons given at the end of Sec. IV-B, this problem is no. 1, pp. 183–196, 2008.
challenging. Second, is there a simple characterization
of the class of continuous or differentiable regular [17] C. Elgot and J. Mezei, “On relations defined by gen-
functions? Note that the Cantor function is an example eralized finite automata,” IBM Journal of Research and
Development, vol. 9, no. 1, pp. 47–68, 1965.
of a nontrivial regular function that is also continuous.
[18] T. Tsankov, “The additive group of the rationals does
R EFERENCES
not have an automatic presentation,” Journal of Symbolic
[1] B. Boigelot, S. Jodogne, and P. Wolper, “An effective Logic, vol. 76, no. 4, pp. 1341–1351, 2011.
decision procedure for linear arithmetic over the integers
and reals,” ACM Trans. Comput. Log., vol. 6, no. 3, pp. [19] F. Abu Zaid, E. Grädel, and Ł. Kaiser, “The Field of
614–633, 2005. Reals is not omega-Automatic,” in STACS’12, 2012.
[2] A. Blumensath and E. Grädel, “Automatic structures,” in [20] A. P. Sistla, M. Vardi, and P. Wolper, “The complemen-
LICS, 2000, pp. 51–62. tation problem for büchi automata with appplications to
temporal logic,” Theor. Comput. Sci., vol. 49, pp. 217–
[3] J. Muller, “Some characterizations of functions com- 237, 1987.
putable in on-line arithmetic,” IEEE Trans. Computers,
vol. 43, no. 6, pp. 752–755, 1994. [21] E. DiBenedetto, Real analysis. Springer, 2002.
10