Proof-Caring Code

Design by Contract, Meet Symbolic Execution!

So I have this idea of using Design by Contract for the C language in a kind of (open!)synergy with Symbolic Execution based on KLEE

The idea is that instead of testing, you write (or even better, generate!) symbolic verification "drivers" for your APIs based on their contracts (preconditions and postconditions/return values for now). Briefly, the function preconditions should imply the postconditions (given the actual code).

Because this approach aims to replace testing to a large degree, what better way to present it in a developer-friendly manner than using test-like koans as an inspiration? You know, as previously done here for Ruby, and for many other languages, as a way to learn languages and-and-by TDD.

For now, check this: https://github.com/cornelizbasa/koan-tracts

Instead of having tests fail, you'll be presented with assertion violations accompanied by counterexamples produced by KLEE, such as: http://pastebin.com/4zQhV1Rn.

More stuff coming soon.

P. S. The title is a play (or troll, if you prefer) on proof-carrying code (PCC). Because this approach will just need the contracts, not the proof inside the code, so instead of "carrying" the proof, it just "cares" about it being feasible through KLEE ;-)

To view or add a comment, sign in

More articles by Cornel Izbasa

  • Expert cryptographer and social engineer comes up with "unbreakable password"

    Afford Prefect, native and still inhabitant of Milwaukee, Wisconsin, took the crypto world by storm with his discovery…

    1 Comment
  • A Mostly Altruistic Many-Worlds Interpretation Science Experiment

    I entertain the idea that if we keep performing quantum physics experiments where branching would occur according to…

  • AI and the Midas Touch

    This article is inspired by the analogy made by Stuart Russell between the problem of ensuring AI alignment and the…

  • Quine Java Class

    Quines are programs that output their own source code without any input. Among other things, they emphasize the…

    1 Comment
  • Finding Hamiltonian Cycles with KLEE

    Graphs are black, Cycles are red, KLEE's not a hack, So use it instead. C: http://pastebin.

  • Finding MagicK with KLEE

    If by now you're not convinced that KLEE heralds the coming of the Singularity, check out how it finds a magic square…

  • Solving 8-Queens with KLEE

    You might already know that I'm in <3 with KLEE for a while and just waiting for the right time to propose. So, without…

  • KLEE, the involuntary base64 decoder

    It is not by chance that I use the term involuntary instead of incidental, because this lil' piece of software has…

    3 Comments
  • Solving Einstein's Enigma with KLEE

    ..

    3 Comments
  • Coder (to the tune of Dreamer by Ozzy Osbourne)

    Gazing to my window at the code inside, Wond'rin' will the pull request survive, My feature branch be merged to master…

Explore content categories