Earlier quoted context omitted.
I don't think you have any chance of approaching formal methods if the notation is a stumbling block. The difficulty and verbosity of formal proofs is huge even with the very concise mathematical notation. And learning the notation itself is a very small stumbling block compared to learning the actual theorems and logic that you need to use. So while I am not a fan of mathematical notation for general programming (wh…
there has to be a better way for a beginner to learn Lean even with the faintest high school mathematics recollection. I can still do theorem proving in Idris excluding the mathematical notation and still learn concepts such as totality, covering, equality etc
What I've Learned About Formal Methods in Half a Year
51–60 of 72 posts
Re: What I've Learned About Formal Methods in Half a Year
#52If I had complete enough specifications for any interesting program that formal methods would be interesting, I think I would just be easier to hit compile on that spec. Yes, there are a subset of interesting bugs related to edge cases, but the real problematic bugs are when what the software does does not match what was expected, even if nobody really could articulate what was expected in the first place. The art of…
> I think I would just be easier to hit compile on that spec I have a hard time not being similarly skeptical about formal methods. They promise the ultimate holy grail of software development - release software with zero defects - but demand what appears to be years of study before you actually see results. On the one hand, there's lots of examples of techniques and tactics that promise amazing results if you "put i…
- Back then, CPU power for the prover was a big problem. That's been fixed. We were too early in the days of a 1 MIPS VAX.
- Prover theory is much better. We were using the Oppen-Nelson prover, the original SAT system. Now that's routine technology.
- Loose languages are a problem. You have to nail down all "undefined behavior", and either detect it and forbid it, or give it precise semantics.
- Integrate the verification annotation into the programming language. Not as comments. It should be at least syntax and type checked when the program is compiled, and it should use essentially the same syntax as the language to which it is attached. Otherwise the annotations get out of date and nobody uses them.
- Break big assertions into lots of little assertions. Don't AND them. This improves the diagnostics.
- Debug the verification in the source language, by adding asserts. The verification system usually treats asserts as a proof goal, and assumes they are true for the code that follows. You narrow down the problem into a small area in that way. If you need to prove something hard, get to the point where you have "assert(a); assert(b);", and need to prove that A implies B. Then you use an offline prover. Don't work on the code problems in a prover directly.
- You're not done until you get 100%. If you write "assert(false);", there is only one error but the verification is totally meaningless.
- Don't get carried away with the formalism. Verification systems tend to be built by people who think formalism is cool. That is a negative for getting work done.
- Undecidability and the halting problem are not issues. If your program is anywhere near undecidable, it's broken. Microsoft took the position with their Static Driver Verifier that if the verifier can't decide termination easily, it doesn't get to be a signed kernel driver.
- Some things are hard to specify, and some things aren't. A database is an example of a complicated system that's not too hard to specify. The specification is a full table search of giant arrays. The implementation doesn't do it that way, but it's supposed to behave as if it does. The other extreme would be a GUI program.
[1] http://www.animats.com/papers/verifier/verifiermanual.pdf
Re: What I've Learned About Formal Methods in Half a Year
#53Earlier quoted context omitted.
I think the interesting part isn't in a single component's edge cases at all, but in how complex webs of many, many things interact. I've yet to see a hard debugging problem that didn't boil down to something like, in the best of possible worlds: "component A expected something to meet promise FOO when it calls component B, because that's obvious, right?" combined with "component B just passes requests and routes res…
That's actually what many formal tools excel at. Of course, you have to do have to define "never promised that behavior" which is extra work that nobody wants to do.
This came out of aerospace, where it's taken seriously. If A won't interoperate with B, you check the interface spec. If A is out of compliance, A has to be fixed. If B is out of compliance, B has to be fixed. If you can't tell, the interface spec has to be fixed. This is why you can unplug Pratt and Whitney engines from an airplane and plug in Rolls-Royce engines.
This worked in the era when the buyer had more clout than the seller. Now, if A won't interoperate with B, it's the problem of whomever is smaller.
Re: What I've Learned About Formal Methods in Half a Year
#54Earlier quoted context omitted.
Something else important to note: this proof of commutativity of addition on natural numbers is definitely _not_ how you normally write these proofs in Lean. Here is a closer approximation to how someone would actually write the proof in Lean: lemma add_comm (a b : ℕ) : a + b = b + a := begin induction a with a IH, rw (add_zero b), rw (zero_add b), trivial, rw (add_succ b a), rw (succ_add a b), rw IH, trivial end
thank you for explaining, but do i need a special keyboard just to type out the natural number type?
Re: What I've Learned About Formal Methods in Half a Year
#55Would have preferred the code samples to not be in Lisp (ostensibly also new to the reader, if formal methods are), and also more sparingly used.
Re: What I've Learned About Formal Methods in Half a Year
#56Earlier quoted context omitted.
That's actually what many formal tools excel at. Of course, you have to do have to define "never promised that behavior" which is extra work that nobody wants to do.
Yes. That's "design by contract", which is extremely useful for determining who's at fault. This came out of aerospace, where it's taken seriously. If A won't interoperate with B, you check the interface spec. If A is out of compliance, A has to be fixed. If B is out of compliance, B has to be fixed. If you can't tell, the interface spec has to be fixed. This is why you can unplug Pratt and Whitney engines from an ai…
Wait wut? Are you talking about their embedded software or the hardware itself? Because if you're talking about the hardware, I'm about to be dumbfounded that there are formal verifications of hardware, my mind is about to be blown.
Re: What I've Learned About Formal Methods in Half a Year
#57I'm not sure if the author is here, or if my comment attempt was successful. So, can I suggest you take a look at a third leg of the formal methods stool? If you are familiar with C, check out Frama-C ( https://frama-c.com/ ) and the WP and RTE plugins. The approach is based on Tony Hoare and EWD's axiomatic semantics ( https://en.wikipedia.org/wiki/Hoare_logic ). It does not have a good memory management story, as f…
Sorry to hear you had issues with my comment system. Comments are invisible until I manually approve them, but I'm not seeing anything new in the database right now. Did you get any sort of error code? The system should let you know if e.g., the answer to the captcha was wrong. I do mention SPARK at the end of the article. I'm not familiar with Frama-C so I'll check that and your blog posts out. Thanks for sharing!
Sorry I missed the mention of SPARK. TLA+, although I haven't fiddled with it as much, is more similar to Alloy than anything else. SPARK actually works on Ada code.
Re: What I've Learned About Formal Methods in Half a Year
#58Earlier quoted context omitted.
That's actually what many formal tools excel at. Of course, you have to do have to define "never promised that behavior" which is extra work that nobody wants to do.
Yes. That's "design by contract", which is extremely useful for determining who's at fault. This came out of aerospace, where it's taken seriously. If A won't interoperate with B, you check the interface spec. If A is out of compliance, A has to be fixed. If B is out of compliance, B has to be fixed. If you can't tell, the interface spec has to be fixed. This is why you can unplug Pratt and Whitney engines from an ai…
Re: What I've Learned About Formal Methods in Half a Year
#59I've always thought theorem proving to be about proving equality of the function and the result. Lean to me is not only obscure but unapproachable by someone from a non-mathematical background. Take this snippet for instance theorem nat.add_comm : ∀ (n m : ℕ), n + m = m + n := λ (n m : ℕ), nat.brec_on m (λ (m : ℕ) (_F : nat.below (λ (m : ℕ), ∀ (n : ℕ), n + m = m + n) m) (n : ℕ), nat.cases_on m (λ (_F : nat.below (λ (…
For whom is that a goal? Are there really that many individuals at the intersection of "I need to use a theorem prover" and "I don't have formal mathematical training"?
Re: What I've Learned About Formal Methods in Half a Year
#60We use formal at Apple to verify hardware. We are always looking for good people in this area.
Do you have more to share? I use Alloy at work and research and would love to learn about how Apple uses FM.
10 years ago formal had just started to be viable in run of the mill semiconductor verification (as opposed to throwing a bunch of specialist PhD grads at the problem); Jasper Gold was the first tool I heard of that worked well enough. pre-formal, the approach was to write a bunch of tests with input stimulators and validity checkers and/or assertions, and then work on the stimulators until you reached 100%coverage (signing off the cases that couldn't happen). That's not just line coverage, but each branch of an if, each component of a boolean expression must toggle, each bit of a signal must toggle, etc.
Reaching 100% coverage was a tedious exercise so the first use of formal was as a sumplement, to find the last,most difficult test cases that completed your coverage (or prove that the cases were impossible). The next use was to try and prove directly that assertions or test failures could not occur, or provide a counterexample. this is all based on the tool being able to read low level verilog or systemC code.
What it couldn't do at the time, which would be interesting to know if it can now, is as follows: Often, you actually have a higher level model of the behavior of your system. The RTL code is written to have the same behavior (manually, because it takes expertise to choose RTL code that will work efficiently). Ideally, provers would simply prove that your RTL has the same behavior.