555 points · by rspivak · 8y ago · 67 comments
Or did I oversee it? Is in there?
First, the purpose of a class like this is to prepare students for further coursework in algorithms and automata/complexity. You need logic, graphs and combinatorics for those a lot more than you need linear algebra.
Second, the math department teaches a class in linear algebra. This is a collection of topics that you wouldn't ordinarily find in undergraduate math classes.
Third, there's a limit on how much linear algebra you can cover in part of a course like this. Better to give it its own semester so you can treat the subject in some reasonable breadth.
>Second, the math department teaches a class in linear algebra. This is a collection of topics that you wouldn't ordinarily find in undergraduate math classes.
x math department doesn't have classes on graph theory, combinatorics, or prob & stats?
Discrete mathematics is a grab bag of topics, and it's more fair to say that a discrete math course pulls in selected topics from other areas than to say it provides a focused coverage of any of them. At the depth each topic is taught, you couldn't pull it out into its own semester's worth of lectures. On the other hand, it would be very difficult to compact linear algebra into a discrete math course. Learning linear algebra already requires you to introduce a bunch of new concepts, like fields and vector spaces, linear equations, linear transformations, matrix representation and matrix operations, determinants, inner products...
Equally importantly, linear algebra doesn't really "fit" with the topics of discrete mathematics, pedagogically speaking. It fits well with a treatment of multivariable calculus, but that's only a small part of what's taught in discrete math courses. If you wanted to teach linear algebra in a course covering a bunch of topics, you'd probably want to do a "topics in abstract algebra" course that works through groups, rings, modules, linear algebra and multilinear algebra. But then you're going well beyond what a non-math major should encounter in an undergraduate setting.
Really, linear algebra stands on its own very well. In my opinion it should receive focused coverage and not be mixed with anything else. While graph theory and combinatorics can easily receive the same coverage, their treatment is usually pushed back to advanced undergraduate or graduate level courses because engineers don't usually work with them beyond what's covered in discrete math (which is exactly why we have discrete math as a standalone course). In fact, MIT actually lists linear algebra and multivariable calculus as prerequisites for the focused courses on combinatorics. The same applies for probability theory: you can't really learn probability theory (beyond discrete) without first learning analysis.
Much of this course is covered in undergraduate math classes, except at much greater depth (especially algebra and probability theory), and over the span of several courses.
For linear algebra, see https://ocw.mit.edu/courses/mathematics/18-06-linear-algebra...
I'll admit I don't know how the MIT CS curriculum is structured, but I suppose it is in there, just not in this particular course.
Source: https://www.eecs.mit.edu/curriculum2016 and I'm a 6-3
edit: originally had posted, "This is a discrete math textbook."
One might argue that linear algebra is slightly more niche than stuff like graph theoretic algorithms. There are applications to broadly useful things like gradient descent, but that seems to fall under numerical linear algebra which probably deserves its own course in the Applied Math department.
N.b. just playing devil's advocate, I don't have a strong opinion either way.
There's also the CMU intro to proofs/reasoning lecture notes here https://infinitedescent.xyz/ though you would learn much of this material from the introduction of Apostol's Calculus. The advantage of the CMU lecture notes is the author based it on his findings in evidence based learning IIRC.
Out of most math texts, this is very accessible and mind-expanding. Even if you don't get everything on the first pass, you'll come out with a lot of interesting insight into the field.
I don't know your level, but I don't recall anything too insurmountable for someone with a decent base in math.
For the context of my opinion: my favorite math textbook for computer science is Chapter 1, Section 1.2 of The Art of Computer Programming ("Mathematical Preliminaries"). That's pretty dense though, so I usually recommend Concrete Mathematics, which was also (co)authored by Knuth. The benefit of Concrete Mathematics is that it spreads the information out with more examples and better exposition. It also includes an expanded section on probability. But in my opinion, the failing (if you could call it that) of both is that there isn't a dedicated section on set theory. I really think that should be covered alongside the introduction to various types of proof.
Which brings me back to this textbook...I personally think it spends too much time building logic and proof machinery in the first chapter. Sets and functions have sections that are only pages long, but there is a large focus on logic. I understand it's a mathematics for computer science treatment and not a pure mathematics treatment, but that's actually pretty dry in my opinion - I think a treatment that focuses more on sets is more intuitive. One of the things I like about Knuth is that he covers these topics in a slightly irreverent and humorous way. He also engages the reader by jumping more directly into arithmetic operations, functions, basic number theory, the binomial theorem and combinatorics, etc.
Some of this is admittedly my own bias. I've never enjoyed staring at things like e.g. truth tables. It's important to know, but this actually seems excessively formal for a discrete mathematics course. Reading through the algebra of propositions isn't exactly riveting. I think that, for self-study at least, exposition and organization of topics is just as important (probably more so) than complete coverage of topics. All of the material you'd want to know is there, it's just that the treatment might be a bit suboptimal for self-study. It probably depends on what you find interesting and how quickly you'd like to do interesting things with what you're learning. It would probably also be beneficial if some people who have actually learned from this textbook for their first encounter with the material could chime in, because that might be more relevant to your question.
It's heavy on sets and functions, turning sets into types to manipulate in Standard ML so the reader can understand what's going on intuitively. I also liked Knuth's crash course in The Art of Programming and it is hard to read other books when you're used to Knuth's clear and precise explanations mixed with dry humor keeping you engaged.
Concrete math requires MUCH more background than this book. Besides the real gems and clever tricks Mathematics for Computer Science appear after the fourth chapter.
It offers so many 'hacks' to working with numbers, which I could imagine would make code more efficient and avoid unnecessary computations when dealing with very large numbers.
Separately, my increased mental efficiency with problems involving numbers is really surprising. There have been interview questions I've read about in the past where I've thought "someone must be a genius to be able to answer that through mental math," and it all makes so much more sense now! It's taught me about dozens of visualizations that can break down these problems in much more manageable ways.
As an example of a mental maths problem on my midterm: How many numbers between 1 and 99,999 have digits that add up to 10? (23,500 would work whereas 23,510 would not). While initially I would have no clue how to answer this, learning about the balls-in-bins method solves it in an incredibly simple manner.
"The analogy between good proofs and good programs extends beyond structure. The same rigorous thinking needed for proofs is essential in the design of criti- cal computer systems. When algorithms and protocols only “mostly work” due to reliance on hand-waving arguments, the results can range from problematic to catastrophic. An early example was the Therac 25, a machine that provided radia- tion therapy to cancer victims, but occasionally killed them with massive overdoses due to a software race condition. A more recent (August 2004) example involved a single faulty command to a computer system used by United and American Airlines that grounded the entire fleet of both companies—and all their passengers! It is a certainty that we’ll all one day be at the mercy of critical computer systems designed by you and your classmates. So we really hope that you’ll develop the ability to formulate rock-solid logical arguments that a system actually does what you think it does!"
My hope is that I find enough feedback on good/bad of cheap or free resources on this topic that I can determine some default recommendations for people curious. The problems can be addressed with supplementary material. Eventually, the defaults would be good enough that the process would happen faster. A larger number of people centering on the same resources might become a community for helping new people. That might increase the inflow. Simultaneously, some percentage of these people are working on tools, esp automated, to make the proof process more productive. Over time, we might have a much larger segment of people working on formal verification than we do now. Maybe even large enough to sustain more tool development by contributions or licensing.
So, that's why I'm looking at books like this with what I think they might help us achieve. I'm way too out of my depth to know if it will work. I just know accessibility, better learning materials, and network effects always help.
Example tools below for sequential programs, concurrency, and hardware:
https://en.wikipedia.org/wiki/SPARK_(programming_language)
https://learntla.com/introduction/
http://prod.sandia.gov/techlib/access-control.cgi/2014/14205...
Something I find very useful as a developer is to see how tools work on concrete examples. For formal verification, this is well examplified by the document "ACSL by Example" about Frama-C:
https://github.com/fraunhoferfokus/acsl-by-example/blob/mast...
This has inspired other researchers to do the same for SPARK, but currently they have done only the code/proofs, not yet the doc around it:
https://github.com/yoogx/spark_examples/tree/master/spark-by...
As I like that approach a lot, that's something I have adopted for the static analysis tools we develop around Ada and SPARK:
http://docs.adacore.com/codepeer-docs/users_guide/_build/htm...
https://docs.adacore.com/spark2014-docs/html/ug/en/source/gn...
This shares with the O'Reilly Cookbook series (https://ssearch.oreilly.com/?q=cookbook) the goals to get very concrete immediately, on code that the reader might have to write or have already written.
https://lobste.rs/newest/nickpsecurity
The stories section of that link has examples including recent ones on floating point and interior point. The interior point paper you might find interesting since they have a specific specification and coding style to achieve full automation.
https://hal.archives-ouvertes.fr/hal-01681134/document
You might also find Lea Wittie's work on Clay interesting. I was looking at her dissertation in case one could use SPARK in similar way to model I/O or concurrency.
https://www.cs.dartmouth.edu/~trdata/reports/TR2004-526.pdf
re your concrete examples
I like that you're all doing that. That does help a lot. I plan to do my part to some degree in the near-ish future: I bought the High-Integrity Applications book for SPARK and Stavely's Toward Zero-Defect Programming for Cleanroom.
http://infohost.nmt.edu/~al/cseet-paper.html
SPARK book looks well-written but kind of packed with info esp on the language. Might take some time for me to learn. The Cleanroom book is highly approachable with the method mostly being algebraic focused on human understanding with symbolic-style verification of some control flow mechanisms. That was from a skim, though, with full method maybe being harder. My plan is to get back into feel of doing this stuff by trying Cleanroom first followed by using what SPARK book teaches me on all the same stuff. Both during and after learning SPARK, I'll use it on little functions like in the ACSL by Example book. Note that this assumes some other research doesn't take higher priority for me like my Brute-Force Assurance concept that mixes languages with their verification tooling.
I took the first steps of trying to get the SPARK GPL environment downloaded and installed. That wasn't working for some reason. It's harder than necessary to install: should be a well-packed installer like most things are on major Linux distros (esp Ubuntu) if wanting maximum adoption/experimentation. Since newest stuff from download link failed, I pulled older stuff through Synaptic which at least got GNAT working on doublec's Hello World example below. SPARK 2014 refused to run on it, though.
https://bluishcoder.co.nz/2017/04/27/installing-gnat-and-spa...
So, I gotta get SPARK working on my machine before trying to learn it. Sucks that it's been this difficult. I'll try again later this week.
Start from page 1 and iterate from there.
So we shall now explain how to read the book.
The right way is to put it on your desk in the day, below your pillow in the night,
devoting yourself to the reading,
and solving the exercises till you know it by heart.Then when someone mentions a term from the course, you know roughly what to expect and where to find details. Also, you know how big a bite you're taking. "Quantum Mechanics" might be several books. "Vector Calculus" maybe a few chapters. "De Morgan's laws" maybe a few pages.
It's just like any other math you do. Does anyone memorize all the trig relations, Laplace transforms, and geometric relations? Of course not. But you've seen at least one large example of every topic and you can reconstruct it from there.
It could be an entire book, though :)