To save content items to your account,
please confirm that you agree to abide by our usage policies.
If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account.
Find out more about saving content to .
To save content items to your Kindle, first ensure no-reply@cambridge.org
is added to your Approved Personal Document E-mail List under your Personal Document Settings
on the Manage Your Content and Devices page of your Amazon account. Then enter the ‘name’ part
of your Kindle email address below.
Find out more about saving to your Kindle.
Note you can select to save to either the @free.kindle.com or @kindle.com variations.
‘@free.kindle.com’ emails are free but can only be saved to your device when it is connected to wi-fi.
‘@kindle.com’ emails can be delivered even when you are not connected to wi-fi, but note that service fees apply.
Numbers in Haskell are complicated because in the Haskell world there are many different kinds of number, including:
Int limited-precision integers in at least the range [−229, 229). Integer overflow is not detected.
Integer arbitrary-precision integers
Rational arbitrary-precision rational numbers
Float single-precision floating-point numbers
Double double-precision floating-point numbers
Complex complex numbers (defined in Data.Complex)
Most programs make use of numbers in one way or another, so we have to get at least a working idea of what Haskell offers us and how to convert between the different kinds. That is what the present chapter is about.
The type class Num
In Haskell all numbers are instances of the type class Num:
class (Eq a, Show a) ⇒ Num a where
(+),(−),(*) :: a → a → a
negate :: a → a
abs, signum :: a → a
fromInteger :: Integer → a
The class Num is a subclass of both Eq and Show. That means every number can be printed and any two numbers can be compared for equality. Any number can be added to, subtracted from or multiplied by another number. Any number can be negated. Haskell allows -x to denote negate x; this is the only prefix operator in Haskell.
The functions abs and signum return the absolute value of a number and its sign.
How to play: Fill in the grid so that every row, every column and every 3 × 3 box contains the digits 1–9. There's no maths involved. You solve the puzzle with reasoning and logic.
Advice on how to play Sudoku, the Independent
This chapter is devoted to an extended exercise in the use of lists to solve problems, and in the use of equational reasoning to reason about them and to improve efficiency.
The game of Sudoku is played on a 9 by 9 grid, though other sizes are also possible. Given a matrix, such as that in Figure 5.1, the idea is to fill in the empty cells with the digits 1 to 9 so that each row, column and 3 × 3 box contains the numbers 1 to 9. In general there may be any number of solutions, though in a good Sudoku puzzle there should always be a unique solution. Our aim is to construct a program to solve Sudoku puzzles. Specifically, we will define a function solve for computing a list of all the ways a given grid may be completed. If only one solution is wanted, then we can take the head of the list. Lazy evaluation means that only the first result will then be computed.
We have already met infinite lists in Chapter 4 and even given an induction principle for reasoning about them in Chapter 6. But we haven't really appreciated what can be done with them. In this chapter we want to explain in more detail exactly what an infinite list is, and how they can be represented by cyclic structures. We also describe another useful method for reasoning about infinite lists, and discuss a number of intriguing examples in which infinite and cyclic lists can be used to good effect.
Review
Recall that [m‥] denotes the infinite list of all integers from m onwards:
ghci> [1‥]
[1,2,3,4,5,6,7,{Interrupted}
ghci> zip [1‥] “hallo”
[(1,'h'),(2,'a'),(3,'l'),(4,'l'),(5,'o')]
It would take forever to print [1‥], so we interrupt the first computation. The second example illustrates a simple but typical use of infinite lists in finite computations.
In Haskell, the arithmetic expression [m‥] is translated into enumFrom m, where enumFrom is a method in the Enum class, and defined by
enumFrom :: Integer → [Integer]
enumFrom m = m:enumFrom (m+1)
Thus [m‥] is defined as an instance of a recursively defined function. The computation makes progress because (:) is non-strict in its second argument.
It is important to bear in mind that infinite lists in computing do not have the same properties as infinite sets do in mathematics.
A parser is a function that analyses a piece of text to determine its logical structure. The text is a string of characters describing some value of interest, such as an arithmetic expression, a poem or a spreadsheet. The output of a parser is a representation of the value, such as a tree of some kind for an arithmetic expression, a list of verses for a poem, or something more complicated for a spreadsheet. Most programming tasks involve decoding the input in some way, so parsing is a pervasive component of computer programming. In this chapter we will describe a monadic approach to parsing, mainly designing simple parsers for expressions of various kinds. We will also say a little more about the converse process of encoding the output as a string; in other words, more about the type class Show. This material will be used in the final chapter.
Parsers as monads
Parsers return different values of interest, so as a first cut we can think of a parser as a function that takes a string and returns a value:
type Parser a = String → a
This type is basically the same as that of the standard prelude function
read :: Read a ⇒ String → a
Indeed, read is a parser, though not a very flexible one. One reason is that all the input must be consumed.
This final chapter is devoted to a single programming project, the design and implementation of a simple calculator for carrying out point-free equational proofs. Although the calculator provides only a small subset of the facilities one might want in an automatic proof assistant, and is highly restrictive in a number of other ways, it will nevertheless be powerful enough to prove many of the point-free laws described in previous chapters – well, provided we are prepared to give it a nudge in the right direction if necessary. The project is also a case study in the use of modules. Each component of the calculator, its associated types and functions, is defined in an appropriate module and linked to other modules through explicit import and export lists.
Basic considerations
The basic idea is to construct a single function calculate with type
calculate :: [Law] → Expr → Calculation
The first argument of calculate is a list of laws that may be applied. Each law consists of a descriptive name and an equation. The second argument is an expression and the result is a calculation. A calculation consists of a starting expression and a sequence of steps. Each step consists of the name of a law and the expression that results by applying the left-hand side of the law to the current expression.
The purpose of this short problem paper is to raise the following extremal question on set systems: Which set systems of a given size maximise the number of (n + 1)-element chains in the power set $\mathcal{P}$(1,2,. . .,n)? We will show that for each fixed α > 0 there is a family of α2n sets containing (α + o(1))n! such chains, and that this is asymptotically best possible. For smaller set systems we conjecture that a ‘tower of cubes’ construction is extremal. We finish by mentioning briefly a connection to an extremal problem on posets and a variant of our question for the grid graph.
Rule-based information extraction is an important approach for processing the increasingly available amount of unstructured data. The manual creation of rule-based applications is a time-consuming and tedious task, which requires qualified knowledge engineers. The costs of this process can be reduced by providing a suitable rule language and extensive tooling support. This paper presents UIMA Ruta, a tool for rule-based information extraction and text processing applications. The system was designed with focus on rapid development. The rule language and its matching paradigm facilitate the quick specification of comprehensible extraction knowledge. They support a compact representation while still providing a high level of expressiveness. These advantages are supplemented by the development environment UIMA Ruta Workbench. It provides, in addition to extensive editing support, essential assistance for explanation of rule execution, introspection, automatic validation, and rule induction. UIMA Ruta is a useful tool for academia and industry due to its open source license. We compare UIMA Ruta to related rule-based systems especially concerning the compactness of the rule representation, the expressiveness, and the provided tooling support. The competitiveness of the runtime performance is shown in relation to a popular and freely-available system. A selection of case studies implemented with UIMA Ruta illustrates the usefulness of the system in real-world scenarios.
This paper develops a new adaptive actuator failure compensation algorithm for the control of a cooperative robotic system subject to uncertain actuator failures. The benchmark robotic system has two manipulators to balance a rigid platform, and the right-side manipulator contains one actuator and the left-side manipulator has two actuators (one of which may fail during system operation, but it is uncertain how much, when and which actuator may fail). The developed adaptive actuator failure compensation scheme, based on adaptive integration of three individual failure compensators and direct adaptation of controller parameters, is capable of ensuring desired closed-loop stability and asymptotic output tracking, despite the failure uncertainties. Such an adaptive actuator failure compensation method is extended to control of a general cooperative robotic system. Simulation results are shown to verify the desired adaptive failure compensation control performance.
It is common in robot tracking control that controllers are designed based on the exact kinematic model of the robot manipulator. However, because of measurement errors and changes of states in practice, the original kinematic model is often no longer accurate and will degrade the control result. An adaptive backstepping controller is designed here for parallel robot systems with kinematics and dynamics uncertainties. Backstepping control is used to manage the transformation between the errors in task space and joint space. Adaptive control is utilized to compensate for uncertainties in both dynamics and kinematics. The controller demonstrated good performance in simulation.
Suppose a binary string x = x1 . . . xn is being broadcast repeatedly over a faulty communication channel. Each time, the channel delivers a fixed number m of the digits (m < n) with the lost digits chosen uniformly at random and the order of the surviving digits preserved. How large does m have to be to reconstruct the message?
A Gödel sentence is often described as a sentence saying about itself that it is not provable, and a Henkin sentence as a sentence stating its own provability. We discuss what it could mean for a sentence of arithmetic to ascribe to itself a property such as provability or unprovability. The starting point will be the answer Kreisel gave to Henkin’s problem. We describe how the properties of the supposedly self-referential sentences depend on the chosen coding, the formulae expressing the properties and the way a fixed points for the formulae are obtained. This paper is the first of two papers. In the present paper we focus on provability. In part II, we will consider other properties like Rosser provability and partial truth predicates.
In this sequel to Self-reference in arithmetic I we continue our discussion of the question: What does it mean for a sentence of arithmetic to ascribe to itself a property? We investigate how the properties of the supposedly self-referential sentences depend on the chosen coding, the formulae expressing the properties and the way a fixed point for the expressing formulae are obtained. In this second part we look at some further examples. In particular, we study sentences apparently expressing their Rosser-provability, their own ${\rm{\Sigma }}_n^0$-truth or their own ${\rm{\Pi }}_n^0$-truth. Finally we offer an assessment of the results of both papers.
Agile software development (ASD) has emerged as a result of consolidated values proposed under the lightweight methods of software engineering. Despite bearing some criticisms, the initial deployment and results observed in the practice environment represents its increasing domination over the traditional software development practices. Any ASD method, in particular, requires knowledge-intensive practices and typically employs multi-disciplinary expert team working extended periods of time for weeks on a nearly continuous basis. A huge amount of tacit knowledge creation and exchange happens in the entire process over the project lifecycle, which attracts the attention of research in the domain of knowledge management (KM). In this paper, first, we have mapped the agile values and agile principles, and in its support, we have argued upon and the need for integrated KM infrastructure and proposed a KM model that can be employed within the organization. We have also developed a conceptual framework for knowledge sharing and learning for the individual practitioners for the sustainability of agile team. We attempt to create an organizational learning framework for knowledge creation and exchange among the involved entities in a collaborative practice environment.
The need for reputation assessment is particularly strong in peer-to-peer (P2P) systems because the peers’ personal site autonomy is amplified by the inherent technological decentralization of the environment. However, the decentralization notion makes the problem of designing a P2P-based reputation assessment substantially harder in P2P networks than in centralized settings. Existing reputation systems tackle the reputation assessment process in an ad hoc manner. There is no systematic and coherent way to derive measures and analyze the current reputation systems. In this paper, we propose a reputation assessment process and use it to classify the existing reputation systems. Simulation experiments are conducted and focused on the different methods in selecting the recommendation sources and collecting the recommendations. These two phases can contribute significantly to the overall performance owing to precision, recall, and communication cost.
WiMAX was proposed as the new wireless network standard in recent years. In the wide cover area of WiMAX environment, there are many nodes and interference. In order to obtain the efficiency, the avoidance to the interference is important. In this paper, we propose a two-tier cluster-based route scheduling mechanism on WiMAX Mesh mode. It achieves both fairness and efficiency inside and outside the cluster. The simulation result shows that our mechanism provides great improvement in average delay time and throughput than other research.
System adaptivity is increasingly demanded in high-performance embedded systems, particularly in multimedia system-on-chip (SoC), owing to growing quality-of-service requirements. This paper presents a reactive control model that has been introduced in Gaspard, our framework dedicated to SoC hardware/software co-design. This model aims at expressing adaptivity as well as reconfigurability in systems performing data-intensive computations. It is generic enough to be used for description in the different parts of an embedded system, for example, specification of how different data-intensive algorithms can be chosen according to some computation modes at the functional level; and expression of how hardware components can be selected via the usage of a library of intellectual properties according to execution performances. The transformation of this model toward synchronous languages is also presented, in order to allow an automatic code generation usable for formal verification, based on techniques such as model checking and controller synthesis, as illustrated in the paper. This work, based on Model-Driven Engineering and the standard UML MARTE profile, has been implemented in Gaspard.