Advanced Formal logic / Automata Theory textbook - math

I know this is more a Math/Formal Language/Automata/Computer science question than an a programming one, but I hope I can get some advice on a comprehensible textbook (not an indecipherable monograph) on formal logic beyond Propositional and Predicate Calculus. I’m especially interested in monadic second order logic and Büchi Automata.
For now, I’ve only found Automata theory and its applications by Bakhadyr Khoussainov, Anil Nerode. Automata, logics, and infinite games By Erich Grädel, Thomas Wilke (eds). And Formal Models of Communicating Systems: Languages, Automata, and Monadic Second-Order Logic Benedikt Bollig....Way over my head.

So this is the best curriculum I can come with :
For Beginners in Logic :
Peter J. Cameron, Sets, Logic and Categories, Springer, Springer Undergraduate Mathematics Series, 1999, URL.
James L. Hein, Discrete Structures, Logic, and Computability, Jones & Bartlett Publishers, 2009 (3th ed) URL.
Logic for the computer scientist.
For Beginners in Automata and Formal Langugage :
Michael Sipser, Introduction to the Theory of Computation, Course Technology, 2005 (2nd), URL.
and
Alan P. Parkes, Introduction to Languages, Machines, and Logic, Springer, 2002.
and
Peter Linz, An introduction to formal languages and automata, Jones & Bartlett Publishers, 2000 (3 ed) URL.
and
John E. Hopcroft and Jeffrey D. Ullman, Introduction to Automata Theory, Languages and Computation, Addison Wesley , 1979, (1st ed), ISBN : 0-201-02988-X; URL.
Intermediate level Logic (undergraduate):
D. Ebbinghaus , Mathematical Logic, Springer, URL.
or
Elliott Mendelson, Introduction to Mathematical Logic, URL
Advanced level (Graduate):
Wolfgang Thomas, Languages, Automata and Logic, 1996.
Leoni Libkin, Elements of Finite Model Theory, Springer, 2004, URL, TOC.
For Research
Benedikt Bolli, Formal models of communicating systems, Springer, 2006, URL.
Grädel, Erich; Thomas, Wolfgang; Wilke, Thomas (Eds.), Automata, logics, and infinite games, Springer, 2002, URL,

I've heard good things about Michael Sipser's Introduction to the Theory of Computation. I actually have it right in front of me, although I haven't started reading it yet.

You seem to have specific topic you want from a book, so I looked into the index of some books in Amazon. Although I've never read this one, Theory of Computation by Dexter C. Kozen might interest you.
Büchi automation, 155, 159, 161, 283, 298, 343
determinization, 167-170
monadic second-order theory
of n successors, 154
of successor, 154-159
The covered pages are in Lecture 25 Automata on Infinite Strings and S1S, the first page is available for preview from the link.
Theory of Computation http://ecx.images-amazon.com/images/I/51JKHJGWBRL._BO2,204,203,35,-76_AA240_SH20_OU01_.jpg

This may not be quite what you're looking for, but I learned a great deal from Blackburn et al's Modal Logic, and I learned what I know of automata from Jurafsky and Martin's Speech and Language Processing, esp. Chapter 2. If nothing else, both provide excellent groundwork for further research.

I remember reading about Büchi Automata in Principles of Model Checking, which seems like a pretty good book. Of course, the focus is on the application to model checking, but model checking is mostly logic anyway.

You're going to be a little surprised, but I think the book you're looking for is Foundations of Databases by Abiteboul, Hull and Vianu (also known as the "Alice book", because Alice is painted on its cover and stars in chapter-introduction dialogs with the authors). It's not a book about SQL, but about the theory of databases -- logic and its implementation in programs and functions -- so it spends quite a lot on issues of complexity and computability of query languages; and the authors make a great effort to be friendly and communicative.

Related

"Monad transformers more powerful than effects" - Examples?

The paper "Programming and reasoning with algebraic effects and dependent types" by Edwin C. Brady on effects in Idris contains the (unreferenced) claim that:
Although [effects and monad transformers] are not equivalent in power — monads and monad transformers can express more concepts — many common effectful computations are captured.
What examples are there that can be modelled by monad transformers but not effects?
Continuations can be modelled as monads, using CPS, but they are not algebraic effects as they cannot be modelled using Lawvere theories. See Martin Hyland and John Power, 2007, The Category Theoretic Understanding of Universal Algebra: Lawvere Theories and Monads (pdf), ENTCS 172:437-458.

What is `wholemeal` in functional programming?

Can anybody give a clear explanation? What is a wholemeal programming in functional programming area. All I've found is that wholemeal is a
focusing on entire data structures rather than their elements
but how can it be archived?
(Code examples in such languages as Scala or Ocaml are very desirable.)
"Functional languages excel at wholemeal programming, a term coined by
Geraint Jones. Wholemeal programming means to think big: work with an
entire list, rather than a sequence of elements; develop a solution
space, rather than an individual solution; imagine a graph, rather
than a single path. The wholemeal approach often offers new insights
or provides new perspectives on a given problem. It is nicely
complemented by the idea of projective programming: first solve a more
general problem, then extract the interesting bits and pieces by
transforming the general program into more specialised ones."
I also found this
it helps prevent a disease called "indexitis" and encourages lawful
program construction (from "Pearls of Functional Algorithm Design",
Richard Bird, 2010)
See also (http://www.comlab.ox.ac.uk/ralf.hinze/publications/ICFP09.pdf)
I always found the Hutton/Bird Sudoku solver a good example of wholemeal programming: http://www.cs.nott.ac.uk/~gmh/sudoku.lhs
A fair number of functional pearls (both that in Bird's excellent book that Code Monkey cites and those available here: http://www.haskell.org/haskellwiki/Research_papers/Functional_pearls) will probably also be instructive.

what kind of programming requires math? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 1 year ago.
Improve this question
This is not a "is math required for programming?" question.
I always thought that for programming, a scary amount of complicated math would be involved (I only got as far as intermediate algebra in college because I'm bad with it).
However, I just got my first job as a developer and have found there is not a ton of math above basic arithmetic(as of yet). I also read on a question here in SO that math is more used to ensure the would-be developer can understand complex problems and solve them.
So I guess is there a different kind of programming where a math level above algebra is needed? My guess would be like geometry and other disciplines for video game programming where you create shapes in 3D and play with time and space in environments. What else requires a high level of math?
EDIT: Wow, lot of answers. One of which made me think of another similar question...say in programs like photoshop, what kind of math(or overall work) is involved in making something twist, crop, edit, and color things like images?
I think there are at least two types of answer to this question. Firstly, there are the sorts of programming which is problems which come from a field where maths is important. These include:
finance
science research, e.g. physical modelling
engineering implementations, e.g. stress analysis, chemical engineering
experimental science, e.g. physics, psychology
mathematics itself
cryptography
image processing
signal processing
And then there are the sorts of programming where the target is not necessarily mathematical, but the process of achieving that target needs some maths. These include:
games
optimisation processes
high-complexity systems, e.g. flight control software
high-availability systems, e.g. industrial process monitoring and/or safety
complex data transformations, e.g. compiler design
and so on. Various of these require various levels and aspects of mathematics.
Gaming and simulation are obvious answers. The math is not difficult, but it is clearly there.
For example, say you want to build some sort of asteroids game. You'll need to figure out the position of your space ship. That's an vector. Now you want the ship to travel in a certain direction a certain direction every frame. You'll need to add some sort of delta-x to x, and delta-y to y, so your motion is another vector: . In an asteroids game, you accelerate in the direction you're pointing, so whenever you hit the 'thrust' key, you'll need to calculate the delta of dx and dy, or an acceleration vector,
(yep, this is the same dx from calculus class, but now I'm building robot zombie opposums with it.)
But that's not all. If you act now, I'll throw in some trig. Normally you think of motion and acceleration as angle and distance(r and theta,) but the programming language normally needs these values in dx, dy format. Here's where you'll use some trig: dx = r * cos (theta) and dy = r * sin(theta)
But, let's say you want to have a planet with a gravitational pull? You'll need to approximate gravity in a way that gives you orbit behavior (elliptical orbits, firing changes the altitude of the other side of the orbit, and so on.) This is easiest to do if you understand Newton's law of universal gravitation: f = ((sqrt(m1 * m2))/d^2) * G. This tels you how much 'planetward' force to add to your ship every frame.Multiply this value by a normalized vector pointing from the spaceship to the planet, and add that as a new motion vector.
Believe it or not, I encourage people who don't like math to take game programming courses. Often they discover that math can be (dare I say it) kind of fun when they're using it on problems that involve exploding cows in space.
As another example, think about optimizing a sound wave. The analog wave has an infinite number of points. It's impossible to store them all in a digital signal, so we break the audio signal into a large number of small segments, then measure every segment. If we want a perfect representation, grab an infinitely large number of infinitely small time slices.
Draw this out, and you've created the Riemann sum, the foundational idea of Integration (and in fact of Calculus)
One more example:
A friend of mine (a biology professor) was trying to build a 'sim city'-style simulation of a lake ecosystem. He was a decent programmer, but he got all bogged down in the various calculations. He wanted the user to vary usage of the lake (outboard motors, fishing restrictions, and dumping restrictions) and then to see how that affected levels of Nitrogen and other key elements.
He tried all kinds of crazy if-then structures with nested conditions and ugly Boolean logic, but never had a clean solution.
We took actual data, ran it through Excel, and found a trendline that accurately reflected his data with a simple logarithmic formula.
Hundreds of lines of messy code were replaced with a simple formula.
Here's a few general places:
Graphics
Cryptography
Statistics
Compression
Optimization
There are also a lot of specific problem areas where complex math is required, but this is due more to the nature of the program and less about programming in general. Things like financial applications fall into this.
Any kind of numerical analysis, like in geophysics or petroleum exploration.
I once built a tool for accident investigators that required a lot of trigonometry.
In commercial programming, not so much math as arithmetic.
All programming requires math. I think that the difference between people with mathematical backgrounds and people with programming backgrounds is how they approach and answer problems. However, if you are advancing your programming skills you are likely unknowingly advancing your mathematical skills as well (and vise versa).
If you abstractly look at both programming and mathematics you'll see they're identical in their approaches: they both strive to answer problems using very fundamental building blocks.
There is a pretty famous essay by Edsger W. Dijkstra which he attempts to answer your exact question. It is called: On the Interplay Between Mathematics and Programming.
Game programming (especially 3-D, as you mentioned) has a lot of "more advanced" math. For that matter, any projects where you're modeling a system (e.g. physics simulation).
Crypto also uses different forms of math.
Robotics requires hardcore matrices, and AI requires all kinds of math.
Quite alot of complex(ish) math in the Finance sector. Other than that and Trig for 3d I can't honestly think of much else.
Im sure there are some though.
Many seemingly non-mathematical industries such as Pharmaceuticals (eg. BioInformatics), Agriculture, Marketing and in general, any "Business Intelligence" relies heavily on statistics. System performance, routing, scheduling, fault tolerance -- the list goes on....
Digital signal processing and AI/simulation/agents are others.
Animation via code, especially when you try to model real physics, also needs math.
I'm a Mathematics graduate and I have to say that the only places where I've really seen any Maths being used (above very basic arithmetic) is understanding / simplifying logical statements, so for example things like the equivalence of these two statements:
(!something) && (!otherThing)
!(something || otherThing)
Apart from that the only time that you would need more complex Maths is when you are working with computer graphics or some subject which is Maths based (e.g. finance or computations) - in which case knowing the Maths is more about understanding your subject than it is about the actual programming.
I work on software that's rather similar to CAD software, and a good grasp of geometry and at least an idea of computational geometry is necessary.
I work in computational chemistry. You need a lot of linear algebra and general understanding of techniques such as Taylor expansion, integrals, gradients, Hessians, Fourier transformation (and in general, expansion on a basis set), differential equations. It's not terribly complex math, but you have to know it.
Statistics is used heavily in businesses performing Quality Assurance and Quality Analysis. My first development job was on a contract at the USDA; these were standard "line-of-business" applications except their line-of-business happened to involve a lot of statistical analysis!
Image compression and image recognition both use Fourier series (including classic sine wave series and other orthogonal series such as wavelet transformations) which has some pretty heavy theory usually not covered until a graduate level course in mathematics or engineering.
Non-linear optimization, constrained optimization, and system estimation using hidden models likewise use a significant amount of advanced mathematical analysis.
Computer science is math. Programming is programmers job. They are related, but the two areas don't exactly overlap, so I see the point of your question.
Scientific computing and numerical analysis obviously require a solid base of linear algebra, geometry, advanced calculus and maybe more. And the whole study of algorithm, data structures and their complexity and properties makes use of discrete mathematics, graph theory, as well as calculus and probability. Behind the simple JPEG standard there's a lot of information theory, coding theory, fourier analysis... And these are only some examples.
Although a computer scientist could even work an entire life without writing down a single line of code, as well as the best programmer in the world could know just a little of math, the fact is that computers perform algorithms. And algorithms require math. I suggest you to take a look at Donald Knuth's "The Art of Computer Programming" to have an idea of what is underneath the "simple" programming thing.
I got my masters degree in meteorology, and I can tell you for that field and other applied physics fields, the kind of coding you will be doing requires an immense amount of mathematics. A lot of what you are coding are things like time differential of equations.
For things like writing code for games, however, you're not always going to be doing a lot math in your code. Gaming requires lots of logic. The part of game coding where math comes in is when you have write physics engines and things like that.

How do I become better in math, after being a programmer for several years [duplicate]

This question already has answers here:
Closed 12 years ago.
Possible Duplicate:
How to improve my math skills to become a better programmer
Basic Math Book for a Programmer
I've had quite a weird career till now.
First I graduated from a medical school. Then I went into marketing (pharmaceuticals).
And then umm, after some time, I decided to go for my (till then) hobby and became a "professional" programmer.
I've been quite successful at this ever since. I have quite some languages "under my belt". I earn not bad and I have been involved in the opensource community quite heavily.
The thing is that I suck at math :). Well, not totally of course, as I get my work done. But I don't know how much I suck. And I don't know how to find out.
Math has never really been of any priority during my middle/high school years. I only picked as little as I could afford, because I was always getting ready to go for Medicine. Of course I know the basics of algebra. Things like "normal" and square equations. Also the basics of geometry. But well, there are things that I have missed.
And lately I am being fascinated by things like probability theory, infinity, chaos/order etc. But every time I try to learn something about these topics, I hit a wall of terminology, special symbols, and some special kind of thinking, that is quite like mine (a programmer), but also a lot different (and appears weird to me).
So, what kinds of books would you recommend me? It's very hard to find something suitable. All that I find are either too easy (and boring) or totally impenetrable.
Assuming you have your basic algebra down, I'd start with single variable calculus. I've used several calc books, and found Larson's to be the best. Hope you can find it at a library.
Move on to linear algebra shortly after. This book is free and very good.
Don't worry about mastering everything, you'll probably want to come back to linear algebra.
Then find a book that emphasizes proofs, sets, relations, functions, and axioms. I liked Analysis with an introduction to proof by Lay. Learn proof by induction especially well.
From here, you should be able to break that impenetrable wall you've found yourself against. You will be armed with the terminology to read just about any undergraduate mathematics textbook.
I recommend graph theory, combinatorics, and linear algebra, for their applications in computer science.
Good luck!
Of course I know the basics of
algebra. Things like "normal" and
square equations. Also the basics of
geometry. But well, there are things
that I have missed. And lately I am
being fascinated by things like
probability theory, infinity,
chaos/order etc.
I find that mathematics is a one-way door: if you don't get through early, it's hard to go back. It's not impossible to pick up, but it is more difficult without discipline.
The key is doing problems. You don't just read math books - you do problems to work the mechanics into your brain. If you're just reading, I'd say it's impossible to learn it.
Best to go back to what you know and work up. If you feel okay about basic algebra and geometry, start thinking about intro calculus or statistics. Start with the basic stuff: one variable differential and/or integral calculus or statistics. Do a lot of problems and get comfortable.
If you're a computer scientist, you'll find discrete math, graphs, numerical methods, and linear algebra helpful.
Don't expect to do it quickly, especially if you're casual about it.
I'd recommend two wonderful resources:
Verzani - Using R for Introductory Statistics
Gil Strang MIT Linear Algebra
Both are free; both are excellent.
You might check out some of the free course material available online from MIT.
The basics:
Basic understanding of real and complex numbers, functions, sets etc.
(Real) analysis in one variable
(Real) linear algebra
(Real) analysis in several variables
Discrete mathematics
Vector calculus
Complex analysis
Complex linear algebra
Statistics and probability theory
More advanced stuff:
Abstract algebra
Fourier analysis (much more important than one may think) (Basic video course from Stanford)
Transform theory (other than Fourier analysis)
Differential geometry
Functional analysis
Partial differential equations
Non-linear phenomena and chaos
Investigate available math classes at a local junior college. Typically, they offer them during the day for enrolled students but they sometimes have night classes as well. Talk to the professor to see if your math skills are sufficient for the class before enrolling, however, or you'll be struggling right out of the gate.

How do I think about math in programming? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
I'm not sure if this is for SO or not. I am reading some of my old math textbooks and trying to understand math in general. Not how to figure something. I can do that but rather what is it that math is doing.
I'm sure this is painfully obvious but I never thought about it until I thought more about game programming. Is it right to think about math as the "language" that is used to explain, precisely explain, why things work?
I'm having a hard time asking it and again, I'm sure it's obvious to most, but after years of math I'm finally thinking when someone asks to "find the equation of a line" that people recognized certain characteristics of a line (y=mx+b) in space and found relationship. They needed something beside a huge paragraph (like this one) and something very precise. We call this math and at its base it's nothing more than a symbolic way to represent things.
Really, I was thinking, "I know why they said 'find the equation of a line'."
So now I am thinking, not just googling for a formula that tells me how to turn a curve with a walking man or follow a path, but why and how do I represent this mathematically and then programatically.
Just hoping for comments on math in programming.
To my way of thinking, I create a "model" of some aspect of the world. Examples:
Profit = Income - Expenditure
I throw a ball it's path will be a parabola with equation ...
I then represent the model in a computer program. So some kind of abstaction underpins the program, sometimes the math is so "obvious" we hardly notice it, sometimes (eg. simulation games) it's both very clearly there and pretty darn tricky.
Key idea: math can be used to model reality, most business systems can be viewed as represented as a model of reality.
Having said that, in 30 years of programming the amount of true (algebra, calculus) maths I have done is negligable.
Steve Yegge wrote a very good article that you may find helpful: Math Every Day
I recommend that you look into materials related to the theory of computation. For example:
On Computable Numbers, with an Application to the Entscheidungsproblem - Alan Turing (1936)
The Mathematical Theory of Communication - Claude Shannon (1948)
The General and Logical Theory of Automata - John Von Neumann (1951)
These are not papers for the faint of heart, but they will give you insights into the beautiful relationship between mathematics and computer science.
You might want to start with a textbook on the subject of computation theory before you tackle the papers listed above, e.g.
Introduction to the Theory of Computation - Michael Sipser
Math for a programmer is like a hammer for a carpenter. The carpenter doesn't use the hammer for everything, but if he doesn't have one, there's a lot he can't do.
Not sure what your precise question is ...
Some thoughts:
Programming is nothing but math (Functional programming, Lambda calculus, programming == math)
Math is a kind of language - An abstract description/representation of an expression in thought
Math helps you to formalize expressions: Instead of For all integer numbers x from one to ten the square of x is less than 250 you can write ∀x ∈ {1..10} (x² < 250)
Programming (a programming language) does the same thing and helps to formalize algorithms.
The kind math that is commonly used in computer programms is numeric math, but with some efforts, you can also perform symbolic computations
I think math is really the concepts behind the symbols instead of the symbols themselves, but when most people speak of math, they're not making the distinction. They're just thinking of the symbols. Partly, this is because of they way math is taught in school, where the focus is on the mechanistic manipulation of the symbols to get correct results, rather than what the concepts are.
This is similar to the way non-programmers view programming. They look at a computer program and see gibberish, whereas a programmer in the given language (after more or less effort) understands the behavior the code represents.
Some people are better at retaining the meaning of such symbols than others. I think there are people who might appreciate math more than they think if they could get past that barrier to the concepts.
I agree with Taylor. Math inside computers is a very deep topic with numerical methods. The biggest issues is precision and the fact that 32 bits only get you so far. There are some really cool (and complicated) functions that describe how to find integrals and such with computers, but because we can't be exact with our answers, and because computers are limited with what they can do (add, multiply, etc) there are lots of methods of how to estimate math to a great deal of precision.
If you are interested in that topic, all the more power to you. That was one class I struggled through.
I'm looking at something similar (financial models) - similar in that we come up with mathematical models, and then implement these in code.
The main issue you face from a programming perspective is taking a model that is expressed in mathematical terms (which assume continuity, infinitely small time/space steps etc.) and then translate these into 'discrete' models, that assume finite time/space steps (e.g. the ball moves every 1mm, or every 1ms).
The translation of these models is not necessarily trivial, and you should have a look at appropriate references for these (Numerical Recipes is a classic). The implementation in code is often very different to how you might express the problem in mathematical terms.
I think Math in programming with time, silence and good food such that I have a lot of paper and a pen, friends-to-ask-help and a pile of books from Rudin to Bourbaki on the top of my Macbook on the floor.
I think why is a philosophical question.
As far as how I think of math/programming and the interplay between... I think of them as layers of modeling. At the lowest, 'truest' level there is some fundamental truth, whatever that may be. Then there is the mathematical modeling of this truth, upon which the 'language' of mathematics is developed (fortunately there is only one language?). Then there is another layer, that of modeling and approximations. In the case of y=mx+b, its only a line within one model, it could be anything. Being visual beings, the most beneficial is perhaps geometric (lines, surfaces, etc). Then upon this there is the computational modeling, the numerical methods/analysis if you will.
As to how do i think of things, I like to think in the modeling perspective. That is, I like to conceptually model some process, and then apply the math and then the numerical methods. Middle out development if you will (to draw an N-tier analogy).
As an afterthought, perhaps the modeling could be called engineering.
The best way to get the type of understanding that you're looking for is to work through "story problems" (i.e. problems stated in words rather than equations). From this and your other questions, you're mostly looking at trigonometry.
In short, I would recommend trying the trig book from the Schaum's Outline Series -- they are cheap (~$13) and have lots of problems with solutions.
There are other routes to finding problems in math to solve, such as just make up game design problems to solve. Here are two: 1) show an object moving around a circle at constant speed, and 2) show two object moving along to different lines that don't intersect, and draw a line between them. Or you could get a book that walks you through these types of things. But you've got to work out a number of problems to force you to think things through yourself.

Resources