For , the chain rule gives and . Applying it twice to the radial function givesUsing , Laplace's equation becomesTwo integrations now giveThese are the general solutions of the specified radial function form on an annulus or a punctured plane. If the solution must extend continuously to the origin, the logarithm term forces , leaving only a constant function.
For the wave equation with wave speed one, D'Alembert's formula with arbitrary twice continuously differentiable initial displacement isThe arbitrary function is essential: only the initial velocity is prescribed. For , this givesBoth travelling terms solve the wave equation, and their time derivatives cancel at . Conversely every classical solution has this form for its initial displacement .
A D flip-flop stores one bit. At its specified active clock edge, it samples and, after its clock-to-Q delay, makes equal to that sampled value. Between active clock edges it retains the stored value. The input must meet the setup and hold time requirements around the sampling edge; a level-sensitive latch would have different behavior.
For a finite-state sequential circuit, encode the present state in a bank of D flip-flops. Feed their outputs and the external inputs to combinational logic computing the next-state function , and connect those outputs to the flip-flop inputs. A common clock signal then performs the simultaneous updateOutput combinational logic computes for a Moore machine or for a Mealy machine. Since any finite next-state and output table is a Boolean function, it has a Boolean circuit implementation. Initialization specifies the starting state, and unused state encodings require either a recovery rule or an initialization assumption. The clock period must accommodate propagation through the D flip-flops and intervening combinational logic before the next sampling edge.
Let mean
concat (map f zss) = f (concat zss). We use structural induction on lazy lists, including the bottom value and allowing arbitrary, possibly partial, inner lists.For
[], the left side is [] and the right side is f [] = []. For the bottom value , both map f and concat are strict functions in the outer spine, and the supplied strictness of makes the right side too.For the cons case, assume and write the new head as
xs. The defining equations and the induction hypothesis giveThe third equality is exactly the supplied list concatenation preservation law. No inspection of xs was required, so the argument includes partial inner lists and undefined elements.This proves the identity for every finite outer spine ending in either
[] or . In the usual pure Haskell semantics, these functions are Scott continuous maps. An infinite outer list is obtained as a limit by finite approximation of a lazy list; both composite functions preserve that limit. Equality on all its finite approximations therefore gives equality on the infinite outer list. Equivalently, is an admissible predicate on lazy lists. ConsequentlyThe continuity assumption is the usual semantic assumption for definable functions here; an extension from finite to infinite inputs cannot be justified by ordinary finite induction alone.On two finite total lists, the equations agree. If either list is empty they return the other; if both have heads, expanding
twiddle twice gives x : y : twiddle xs ys, exactly the third equation for twiddle'. The same finite-prefix reasoning proves agreement on infinite inputs with defined spines.They differ on partial lists. Take the first argument
[1] and the second argument . The original definition can emit its first head immediately:After recognizing the nonempty first argument, twiddle' must inspect the second argument to distinguish its second and third equations. That inspection diverges, soFor example, demanding only the head distinguishes them: the original returns 1, while the primed version diverges. Equality of functions under lazy evaluation requires agreement on these partial inputs too.If is positive and odd, is odd. The function is a strictly increasing function on the real numbers, so it is injective. Every real has the real odd root , so the function is also surjective.
If is positive and even, the exponent is positive and even. Then , while for all real . These facts disprove injectivity and surjectivity, respectively. ThereforeIf the convention is used, gives exponent zero. Interpreting as the constant polynomial makes the function neither injective nor surjective. If is left undefined, that case does not define the stated function on all the real numbers. Neither convention adds a qualifying value of .
The function composition of two bijections is a bijection. Its inverse function is two-sided, soThis is exactly the defining cancellation property of an inverse function, with the whole function composition regarded as one function.
Divide by the proposed comparison function :The ratio is unbounded, so no constant in the definition of Big O notation can work:
Take each partial derivative while holding the other coordinate fixed. Differentiating the polynomial term by term givesSince the function is a polynomial, both orders of the mixed partial derivative agree everywhere.
Assume the variances are finite. Expand the square and apply linearity of expectation:Part (i), applied to the identity functions, makes the bracketed covariance zero by independence of random variables. Hence
The map function changes each element of a list while preserving its order and length. List concatenation removes one level of nesting. Currying changes a function on a pair into a function taking its two arguments separately; uncurrying reverses this conversion:
map :: (a -> b) -> [a] -> [b]
map f [] = []
map f (x:xs) = f x : map f xs
concat :: [[a]] -> [a]
concat [] = []
concat (xs:xss) = xs ++ concat xss
curry :: ((a, b) -> c) -> a -> b -> c
curry f x y = f (x, y)
uncurry :: (a -> b -> c) -> (a, b) -> c
uncurry f (x, y) = f x yThese polymorphic type signatures impose no numerical, equality or ordering constraints: the definitions only inspect list or pair structure and apply a supplied function. In particular,The recursive equations describe the two possible list constructors, so they also explain how the empty case terminates each finite computation.
Both uses of
x in this definition have the same monomorphic type within the body. Write x :: u -> v. The inner application x z forces z :: u and has type v; the outer application x (x z) forces v = u. Thus x :: u -> u. Finally, x (x z) is applied to y, so u must itself be a function type, say a -> b. This givesf :: ((a -> b) -> a -> b) -> a -> (a -> b) -> b
f x y z = x (x z) yThe principal type is thereforeThe argument
x transforms a function into another function of the same type. The body transforms z twice, then applies the resulting function to y; no recursive type equation is required.In the type signature
map :: (u -> v) -> [u] -> [v], the supplied function is concat :: [[a]] -> [a]. Type inference therefore identifies u with [[a]] and v with [a]. Consequently,map concat :: [[[a]]] -> [[a]]Thus is the principal type. For example,
map concat [[[1],[2,3]],[[4],[]]] gives [[1,2,3],[4]]: it concatenates each inner group, preserving the outermost grouping.A tree fold replaces
Empty by a seed and Node by a combining function. The combining function receives the already folded left subtree, the node's label and the already folded right subtree:foldSTree :: (b -> a -> b -> b) -> b -> STree a -> b
foldSTree combine empty Empty = empty
foldSTree combine empty (Node left x right) =
combine (foldSTree combine empty left)
x
(foldSTree combine empty right)Its polymorphic type signature isThe result type need not be the label type: it may be a list, a number or another structure. No ordering constraint is needed because this tree fold follows constructors without comparing labels.
These operations consume the receiver, as expected for this destructive iterator interface. For
exists stops immediately after the first successful test.trait RichIter[T] extends Iter[T] {
def foreach(f: T => Unit): Unit = {
while (hasNext) f(next())
}
def exists(p: T => Boolean): Boolean = {
while (hasNext) {
if (p(next())) return true
}
false
}
def foldLeft[U](x: U)(f: (U, T) => U): U = {
var acc = x
while (hasNext) acc = f(acc, next())
acc
}
}foreach, after iterations the supplied function has been applied in order to exactly the first entries. For exists, every consumed entry has failed the predicate unless the method is returning true. For the left fold, the loop invariant after consuming entries isEach iteration extends the expression by the next entry on the right. For a finite remaining sequence, its unconsumed length is a common loop variant. ThusAn empty iterator invokes no callback, gives false for exists, and returns from the left fold. On an infinite iterator, exists can terminate when it finds a match; the other two operations ordinarily do not terminate. With constant-cost callbacks, finite input of length takes time complexity and constant auxiliary space.Function composition is not always commutative. The reversed function composition may be undefined when the necessary domain of a function and codomain do not match. A counterexample using functions avoids that issue: let and . ThenBoth function compositions exist, and their values differ at every real .