The real problem is when the one who wrote the function is not aware of con- current programming. Example: A numerical equation solver was implemented in C, and then it was packaged together with other routines in a library. To optimize the code for the hardware at that time, the temporary variables of the algorithm were declared static. The function was then successfully used for years on an old- style UNIX machine, where each program only contains one point of execution (except for the signal handlers). Then, the library was compiled and linked with applications running on the newer so called multi-threaded UNIX dialects, such as Sun Solaris, HP-UX 10 and later, and later versions of IRIX from SGI. It was also used on the Microsoft Win32 platform. In all these cases, when using the equation solver concurrently from different parts of the application, the results were sometimes wrong. In this case, the function was correct as a program, but not correct when used in a concurrent program where some interleavings resulted in undesired mixing of temporary data from different equations.
Everyone actively involved in proof formalization experiences the incessant barrage of problems that have been solved multiple times before and that other users will have to solve multiple times again, because the solutions are not systematic. To counter this, the DRY “Don’t Repeat Yourself” principle of programming, formulated in [HT00], has been carried to a refreshing extreme by Carette in his proof assistant design. For example, in his designs, a morphism is defined only once, eliminating the need for separate definitions of a morphism of modules, of algebras, of varieties, and so forth. Carette’s other design maxims include “math has a lot of structure; use it” and “abstract mathematical structures produce the best code” [CES11]. Indeed, mathematicians turn to abstraction to bring out relevant structure. This applies to computer code and math- ematical reasoning alike. American Math Society guidelines for mathematical writing apply directly to the computer: “omit any computation which is routine. . . . Merely indi- cate the starting point, describe the procedure, and state the outcome” [DCF + 62] (except that computations should be automated rather than entirely omitted).
Each chapter has a summary where I try to give the more cursory reader a run- down on the happenings in the chapter and their importance for future work. Most chapters suggest some exercises; however, they are not spelled out formally, because I firmly believe that one should experiment on one’s own. Because we are building the techniques from scratch, I have refrained from making and using a massive class library, even though some examples could have benefited from it. If you want to understand object-oriented programming, it is more important to first master the techniques and consider your options in code design; dependence on somebody else’s library for your developments should come a bit later.
Like all modern GUI frameworks, wxWidgets benefits from heavy use of object- oriented programming concepts. Each window is represented as a C++ object; these objects have well-defined behavior, and can receive and react to events. What the user sees is the visual manifestation of this interacting system of objects. Your job as a developer is to orchestrate these objects’ collective behavior, a task made easier by the default behaviors that wxWidgets implements for you. Of course, it’s no coincidence that object-oriented programming and GUIs mesh well—they grew up together. The object-oriented language Smalltalk designed by Alan Kay and others in the 1970s was an important milestone in GUI history, making innovations in user interface technology as well as lan- guage design, and although wxWidgets uses a different language and API, the principles employed are broadly the same.
In my younger years, I was fortunate to meet a few outstanding scientists and to have an opportunity to take their classes and talk to them. I learned logic from Nikolai Shanin (1919– 2011), Sergei Maslov (1939–1982) and Grigori Mints (1939–2014), and artificial intelligence from John McCarthy (1927–2011) and Raymond Reiter (1939–2002). The most important influence on my professional work, next to that of my teachers, came from Michael Gelfond, an old friend and one of the founding fathers of answer set programming. Michael has read a draft of this book and suggested many ways to improve it. Useful comments have been provided also by Amelia Harrison, Roland Kaminski, Joohyung Lee, and Alfred Zhong.
Most games rely almost exclusively on surface blits for their drawing (as opposed to drawing with individual pixels). For example, consider the game Civilization: Call To Power (which was ported to Linux using SDL). Other than the lines used to indicate paths and gridpoints, every character and building that you can see is stored in memory with surfaces, and they are drawn on the screen with blits. All of the game’s artwork was created by artists and stored in files. The game assembles its screen images almost entirely out of these predrawn graphics. We will now examine a series of SDL video-programming examples. It would be a good idea to compile and run each of these examples and to tweak them until you understand how they work. Don’t worry about typing in all of the examples; they are available on the book’s Web page. Throughout the rest of the chapter (and throughout chapters to come) we’ll make note of important structures and functions with references like this:
What is at issue here is a fundamental tension in the very notion of modular programming. On the one hand we wish to separate modules from one another so that they may be treated independently. This re- quires that the signatures of these modules be self-contained. Unbound references to a structure — such as Point — ties that signature to a spe- cific implementation, in violation of our desire to treat modules separately from one another. On the other hand we wish to combine modules together to form programs. Doing so requires that the composition be coherent, which is achieved by the use of sharing specifications. What sharing spec- ifications do for you is to provide an after the fact means of tying together several different abstractions to form a coherent whole. This approach to the problem of coherence is a unique — and uniquely effective — feature of the ML module system.
sort s. As a matter of terminology, a nullary operator is one that takes no arguments, a unary operator takes one, a binary operator two, and so forth. The concept of a variable is central, and therefore deserves special em- phasis. As in mathematics a variable is an unknown object drawn from some domain, its range of signficance. In school mathematics the (often implied) range of significance is the set of real numbers. Here variables range over ast’s of a specified sort. Being an unknown, the meaning of a variable is given by substitution, the process of “plugging in” an object from the do- main for the variable in a formula. So, in school, we might plug in π for x in a polynomial, and calculate the result. Here we would plug in an ast of the appropriate sort for a variable in an ast to obtain another ast. The process of substitution is easily understood for ast’s, because it amounts to a “physical” replacement of the variable by an ast within another ast. We will shortly consider a generalization of the concept of ast for which the substitution process is somewhat more complex, but the essential idea is the same, and bears repeating: a variable is given meaning by substitution.
Computer Programming is defined as the process of creating computer software using programming languages. Just like we speak and understand English or Spanish or French, computers can understand programs written in certain languages. These are called programming languages. In the beginning there were just a few programming languages and they were really easy to learn and comprehend. But as computers and software became more and more sophisticated, programming languages evolved fast, gathering more complex concepts along the way. As a result most modern programming languages and their concepts are pretty challenging to grasp by a beginner. This fact has started discouraging people from learning or attempting computer programming.
Failure to understand the difference between scope and visibility causes more problems for new Ada programmers than any other single topic. It is an idea central to the design of all Ada software. There is an entire ALRM chapter devoted to it, Chapter 8. A with clause puts a library unit into scope; but none of the resources of that unit are directly visible to a client. This is different from a #include in the C family of languages. Separating scope from visibility is an important software engineering concept. It is seldom designed into other programming languages. This book has many coded examples that illustrate visibility rules. Ada has several techniques for making in-scope elements directly visible.
Mathematics is a language, specifically it is the language of Science. Like any language, mathe- matics has letters (known as numbers) that are used to make up words (known as expressions), and sentences (known as equations). The punctuation marks of mathematics are the differ- ent signs and symbols that are used, for example, the plus sign (+), the minus sign (-), the multiplication sign ( × ), the equals sign (=) and so on. There are also rules that explain how the numbers should be used together with the signs to make up equations that express some meaning.
Given how long the Fundamental Theorem of Algebra has been around, you should not be surprised that there are many proofs of it. There have even been entire books devoted solely to exploring the mathematics behind various distinct proofs. Different proofs arise from attempting to understand the statement of the theorem from the viewpoint of different branches of mathematics. This quickly leads to many non-trivial interactions with such fields of mathematics as Real and Complex Analysis, Topology, and (Modern) Abstract Algebra. The diversity of proof techniques available is yet another indication of how fundamental and deep the Fundamental Theorem of Algebra really is.
mathematical ideas from probability and other fields, musicians back to the Baroque period employed mathematical principles when manipulating melodies and harmonies. Understanding the probability and group theory behind their methods—many details of which were not written down by mathematicians until long after they were used in music—will help us understand the mathematical structures hidden in the music we hear every day. After a composer completes a piece and an ensemble performs it, the final product is most often delivered to our ears digitally, via an MP3 file or a CD. In either case, mathematics plays a crucial role behind the scenes to make the listening experience an enjoyable one. In the case of MP3 (and similar technologies), the harmonic analysis of overtones helps in the compression of files that would otherwise require more lengthy downloads or larger drives. In the case of CDs and DVDs, error-correcting codes and other mathematical techniques are used not only to detect the errors that are unavoidable in the disc-writing process but actually to correct those errors! Incredibly, these mathematical algorithms ensure that the more than 50,000 errors that occur on a typical audio CD will be corrected before sound comes out of your stereo system! In fact, the digitization of music (and musical scores) allows us to accomplish tasks hardly imaginable a generation ago, including fixing out-of- tune notes on the fly and finding a composition knowing only a short melody. In the final stop on our tour of the musical experience, we will delve into the available evidence for how the brain processes both mathematics and music. By examining similarities between the two subjects on many different levels, from infant development, to how the brain works with patterns, to the level of abstraction, to creativity and beauty, we will arrive at the ultimate connection between the subjects: that similar patterns of thought underlie both mathematics and music.