Posts tagged "c"
Quote o' the Week: Iversons convention September 2, 2010
Quote o' the Week: It’s [Not] Faster Because It’s C October 12, 2010
Equational programming December 25, 2010
Systems programming November 1, 2011
Creating a Letterpress cheating program in Rust February 25, 2013
Flex- and BisonModules updated (sort of) December 28, 2013
Type-safe C? August 8, 2014
Letterpress cheating in Rust 0.11.0, part 2 August 9, 2014
Letterpress cheating in Rust 1.6: How long has it been?!? January 27, 2016
Quote o' the day: Memory Speed May 23, 2016
This is a quote from Expert C Programming, describing something that I’ve also been complaining about for roughly as long as this book has been in existence. (Remember, it was published in 1994.)
Read more…The pain of learning Rust January 19, 2017
I recently saw several posts from ESR discussing his attempts to learn Rust, for use in rewriting NTPsec: “Rust vs. Go” and “Rust severely disappoints me”, as well as “Rust and the limits of swarm design”. These posts gave me the incentive to write down some thoughts I have on the difficulty of approaching Rust. In pariticular, I have noticed are some commonalities among those who have initial difficulties with Rust’s ownership model.
Read more…Applied Formal Logic: Brute Force String Search June 19, 2017
Need is there, but tools are not.
– zzz95
Let’s play with Frama-C.
Read more…Applied Formal Logic: The bug in Quick Search June 23, 2017
In my last post, I presented a brief introduction to Frama-C and to the process of verifying properties about a very simple C function, a brute force string search. This time around, I intended to do roughly the same thing, using a slightly more complicated function, a faster string searching algorithm. Unfortunately, in doing so, I found a bug in the algorithm. Admittedly, the bug is rather minor and should not affect the actual behavior of an implementation in practice, but still, it is doing something it shouldn’t ought to be doing.
The string searching algorithm I am looking at this time is Quick Search, so named by Daniel M. Sunday in 1990 because it “is a simple, fast, practical algorithm [and] because it can be both coded and debugged quickly” (“A Very Fast Substring Search Algorithm” [PDF]. It is my personal favorite string search because it is, indeed, simple, fast, and practical. Let me quickly show why.
Read more…Applied Formal Logic: Correctness of Quick Search July 16, 2017
When last I left, I had verified that the implementation of Quick Search was safe: the modified algorithm didn’t access memory it shouldn’t, it didn’t have numeric overflows, and it didn’t modify anything outside of its own implementation. And, using Frama-C, the process hadn’t hardly been torturous or even particularly unpleasant at all. The most important tasks were describing the requirements for calling the two functions. Those requirements are…detailed…but nothing more than what an experienced C programmer would have in mind while writing or calling the functions. A final set of shiny set of annotations ensured that the loops and the variable modifications needed by them behaved themselves.
But I hadn’t done anything about proving that the function actually did what it claimed it was supposed to do. It’s not hard to understand (one of the reasons I like Quick Search), but the ANSI/ISO C Specification Language is unfamiliar and I didn’t know how to express what went on, where. Fortunately, Yannick Moy, a software engineer at AdaCore, came to my assistance with an excellent introduction to doing the same thing with SPARK, and Loïc Correnson, one of the creators of Frama-C, popped in with some excellent suggestions (and very flattering comments).
So now, for your software verification pleasure, here is my essay at proving the correctness of Quick Search. It pretty much follows the same pattern as Yannick’s, but I did come up with a slightly different postcondition for make_bad_shift
.
Applied Formal Logic: Verifying Quicksort August 9, 2017
Have you ever tried to solve a problem, gotten stuck, backed off, tried again, changed approaches, failed, and then suddenly, with some approach that you’d already abandoned, solved the problem as sweetly as Penelope Doglington begging for part of your sandwich? I’ve had one of those weeks, and now I honestly don’t know what the problem was. Everything seems to be all better now.
So, here it is: my proof of Quicksort. The proof, which is mine, is mine. And therefore, my proof, which belongs to me, is as follows.
Read more…