3 ms·
Model checkers are amazing tools. I've been using one for C development for the past two years, and with the model checker, I feel more confident about code I
by nanolith 9y ago
Model checkers are amazing tools. I've been using one for C development for the past two years, and with the model checker, I feel more confident about code I write in C than I do about code in many other languages.
That being said, model checkers find counter-examples. This is not the same as a formal proof. Just because a counter-example cannot be found does not mean that a given property has been proven. It is _extremely_ important to understand that point. Model checking, combined with unit testing, is a formidable tool that should be used whenever possible. But, don't assume that model checking is the same as a proof. The subtle difference does matter, and it can bite you.
It is possible to write formal proofs about software, using Calculus of Constructions, Separation Logic, Hoare Logic, etc. However, this is much harder than using a model checker. For 95% of applications, a model checker is good enough.
- ahelwer 9y agoTo the extent the model corresponds with reality, a given property is proven due to lack of counterexample.
- deleted 9y ago[deleted]
- nanolith 9y agoTo the extent that the model checker is complete and error free, and to the extent that that the model corresponds with that under instrumentation. I've been far down that rabbit hole, and I've found cases where certain model checkers fail to find counterexamples that other model checkers find. Sometimes, this is due to errors in one or more of the checkers. Sometimes this is due to differences in representation. But, ultimately, the argument is epistemological. There is a corollary to the phrase: "Absence of proof isn't proof of absence": absence of a counterexample isn't an absence of a contradiction. As I've said, I love model checkers. But, they are not perfect, nor are they a panacea.
- seattleeng 9y agoThat's very interesting, do you happen to have any toy examples where two model checkers differ?
- OscarCunningham 9y agoThe other day I found an error in the Glucose SAT solver, but only when running with one of the options (-rcheck) changed away from its default setting. Glucose produced an alleged satisfying assignment that didn't actually work. So it's possible for mainstream SAT solvers to have errors, but I imagine their default configurations are very thoroughly tested.
- schoen 9y agoIt's interesting that the SAT solvers haven't put in a check at the very end to confirm that satisfying instances really satisfy the constraints, since that step is of course supposed to be the radically easy one! I guess their authors have had a lot of (usually well-placed) confidence in the solvers' logic and correctness.
- OscarCunningham 9y agoWhen I told them about it they said that the -rcheck code was inherited from MiniSAT. Since it's also not enabled by default it's understandable that it hadn't been as thoroughly checked as usual. I wouldn't blame them if they just dump it instead of fixing it. But yes it is strange that it doesn't verify its outputs. On the other hand SAT solvers want to be as fast as possible and there shouldn't be a need to do it if the solver is operating correctly.
- nanolith 9y agoIn early days of CBMC, it was possible to confuse it and get it to generate incorrect code for MiniSat. This is a representation issue. Those issues have long since been solved. Now CBMC's biggest problem is that of performance, and the developers are diligently working to improve this problem. When Z3 first came out, I built a machine model for a subset of ARMv7 and ran into a few cases that confused Z3, but worked fine in an equivalent MiniSat. However, this was years ago, and it appears -- although I have not verified this -- that the code in Z3 that I narrowed down in preparation to filing a bug report has already been fixed. The machine model has succumbed to bit rot; I abandoned the effort for a model I built on top of Coq. But, it would be interesting to attempt to fire it up again to see if it works now, and if so, use that to perform a binary search to find out when the fix was applied. It shouldn't be hard to create an example where two model checkers differ. Check current bug reports for two model checkers, and build a model that exploits the bug in one model checker but in which the other model checker works. These code bases are complex. They are increasingly infrequent, as the developers working on these model checkers are quite diligent, but subtle errors do exist.
- inputdev 9y agoWhat do you use?
- nanolith 9y agoFor C model checking, I use CBMC. It is a great tool, but it does take some finesse to use well. http://www.cprover.org/cbmc/ http://www.cprover.org/cbmc/
- zzz95 9y agoThis is not true in theory. A model checker (NOT a bounded model checker) either produces a counter-example, a proof of correctness or times-out/gives up if the theory is not decidable. A bounded model checker on the other hand, checks the property for a given depth 'k', and hence the result is not applicable to a complete run. In practice, it is all engineering, so anything can happen unless the model checker has been model checked.