lh-l4v/tools/autocorres
Japheth Lim 324d48b53f autocorres: handle guarded_spec_body construct. See 27a12b871 and VER-464. 2015-11-24 13:58:28 +11:00
..
doc/quickstart autocorres: fix "no \citation" bibtex error 2015-10-21 11:58:13 +11:00
experiments/alloc-proof Import release snapshot. 2014-07-14 21:32:44 +02:00
tests trivial: autocorres: excise old internal names. 2015-10-01 17:55:31 +10:00
tools Consistently use /usr/bin/env to invoke python 2015-10-13 16:42:53 +11:00
AbstractArrays.thy Port AutoCorres to Isabelle 2014-RC0 2014-08-08 17:29:54 +10:00
AutoCorres.thy autocorres: restore simplifier tracing functionality. 2015-10-26 14:18:10 +11:00
AutoCorresAttributes.thy Import release snapshot. 2014-07-14 21:32:44 +02:00
AutoCorresSimpset.thy autocorres: Avoid using "@{context}" simpset internally. 2014-09-16 13:50:59 +10:00
Auto_Separation_Algebra.thy autocorres: rename "ccorres" predicate to "ac_corres". 2015-09-21 18:20:25 +10:00
CCorresE.thy trivial: autocorres: revert some incorrect renaming from 6ab50e000. 2015-10-01 17:06:38 +10:00
CorresXF.thy autocorres: rename "ccorres" predicate to "ac_corres". 2015-09-21 18:20:25 +10:00
DataStructures.thy autocorres: Fix "DataStrctures.thy" to avoid namespace clash in Isabelle 2014. 2014-09-10 11:17:21 +10:00
ExceptionRewrite.thy Import release snapshot. 2014-07-14 21:32:44 +02:00
ExecConcrete.thy Import release snapshot. 2014-07-14 21:32:44 +02:00
HeapLift.thy autocorres: fix rules for heap lifting of arrays. 2015-07-21 18:57:57 +10:00
L1Defs.thy autocorres: handle guarded_spec_body construct. See 27a12b871 and VER-464. 2015-11-24 13:58:28 +11:00
L1Peephole.thy autocorres: no_opt now disables optimisations in SimplConv and TypeStrengthen. 2014-12-04 20:19:26 +11:00
L1Valid.thy Import release snapshot. 2014-07-14 21:32:44 +02:00
L2Defs.thy Port AutoCorres to Isabelle 2014-RC0 2014-08-08 17:29:54 +10:00
L2Opt.thy Import release snapshot. 2014-07-14 21:32:44 +02:00
L2Peephole.thy Import release snapshot. 2014-07-14 21:32:44 +02:00
L4VerifiedLinks.thy trivial: autocorres: revert some incorrect renaming from 6ab50e000. 2015-10-01 17:06:38 +10:00
LegacyAutoCorres.thy autocorres: rename "ccorres" predicate to "ac_corres". 2015-09-21 18:20:25 +10:00
LocalVarExtract.thy Import release snapshot. 2014-07-14 21:32:44 +02:00
Makefile Import release snapshot. 2014-07-14 21:32:44 +02:00
MonadMono.thy Port AutoCorres to Isabelle 2014-RC0 2014-08-08 17:29:54 +10:00
NonDetMonadEx.thy some of the global Isabelle2014 renames 2014-08-09 15:39:20 +10:00
Polish.thy autocorres: add a polish rule for "int (unat _)". 2015-09-02 19:38:59 +10:00
README.md autocorres: update README and packaging scripts for release. 2015-10-09 17:08:08 +11:00
ROOT autocorres: Run without "quick_and_dirty". 2014-10-23 09:13:56 +11:00
SimplBucket.thy Import release snapshot. 2014-07-14 21:32:44 +02:00
SimplConv.thy autocorres: move L2Unfold rules to L1except, 2014-12-11 19:08:24 +11:00
TestSEL4.thy Merge 'master' into 'isabelle-2014'. 2014-09-17 14:21:13 +10:00
TypHeapSimple.thy autocorres: 2015 update 2015-05-21 19:49:11 +10:00
TypeStrengthen.thy Import release snapshot. 2014-07-14 21:32:44 +02:00
WordAbstract.thy autocorres: remove type restriction in WordAbstract rule. 2015-08-31 16:00:44 +10:00
attributes.ML autocorres: add "no_opt" option to turn off some simplifications. 2014-11-24 11:39:21 +11:00
autocorres.ML autocorres: change generated names more consistently. Add example/regression file. 2015-10-01 15:40:28 +10:00
autocorres_data.ML autocorres: record which rules were used by L2Opt; enable using "trace_opt" option. 2014-12-02 14:31:39 +11:00
autocorres_trace.ML autocorres: restore simplifier tracing functionality. 2015-10-26 14:18:10 +11:00
autocorres_util.ML autocorres: change generated names more consistently. Add example/regression file. 2015-10-01 15:40:28 +10:00
exception_rewrite.ML autocorres: 2015 update 2015-05-21 19:49:11 +10:00
function_info.ML autocorres: prune unused functions 2015-05-24 22:21:27 +10:00
heap_lift.ML autocorres: change generated names more consistently. Add example/regression file. 2015-10-01 15:40:28 +10:00
heap_lift_base.ML autocorres: add options to change how names are generated. 2015-09-16 21:46:09 +10:00
l2_opt.ML autocorres: 2015 update 2015-05-21 19:49:11 +10:00
legacy.ML Import release snapshot. 2014-07-14 21:32:44 +02:00
local_var_extract.ML autocorres: change generated names more consistently. Add example/regression file. 2015-10-01 15:40:28 +10:00
mkterm_antiquote.ML Port AutoCorres to Isabelle 2014-RC0 2014-08-08 17:29:54 +10:00
monad_convert.ML autocorres: 2015 update 2015-05-21 19:49:11 +10:00
monad_types.ML more Isabelle2015 update; AInvs up to (excluding) Syscall_AI 2015-04-18 21:51:26 +01:00
pretty_bound_var_names.ML autocorres: 2015 update 2015-05-21 19:49:11 +10:00
prog.ML Import release snapshot. 2014-07-14 21:32:44 +02:00
program_info.ML Merge from master. 2015-05-26 07:47:54 +10:00
record_utils.ML autocorres: 2015 update 2015-05-21 19:49:11 +10:00
simpl_conv.ML autocorres: handle guarded_spec_body construct. See 27a12b871 and VER-464. 2015-11-24 13:58:28 +11:00
simple_lazy.ML Import release snapshot. 2014-07-14 21:32:44 +02:00
statistics.ML Import release snapshot. 2014-07-14 21:32:44 +02:00
trace_antiquote.ML Port AutoCorres to Isabelle 2014-RC0 2014-08-08 17:29:54 +10:00
type_strengthen.ML autocorres: rename "ccorres" predicate to "ac_corres". 2015-09-21 18:20:25 +10:00
utils.ML autocorres: 2015 update 2015-05-21 19:49:11 +10:00
word_abstract.ML autocorres: change generated names more consistently. Add example/regression file. 2015-10-01 15:40:28 +10:00

README.md

Note to maintainer: sync with tools/release_files/README

AutoCorres

AutoCorres is a tool that assists reasoning about C programs in Isabelle/HOL. In particular, it uses Norrish's C-to-Isabelle parser to parse C into Isabelle, and then abstracts the result to produce a result that is (hopefully) more pleasant to reason about.

Contents of this README

  • Installation
  • Quickstart
  • Development and reporting bugs
  • Options
  • Examples
  • Publications

Installation

AutoCorres is packaged as a theory for Isabelle2015:

http://isabelle.in.tum.de

To build it, type

isabelle build -d . AutoCorres

in the root of the L4v repository. This builds the C parser and AutoCorres itself. There is also a test suite, which can be run using:

make AutoCorresTest

in tools/autocorres.

Quickstart

A brief tutorial can be found in doc/quickstart. Run make AutoCorresDoc to generate a readable PDF document of the tutorial.

Development and reporting bugs

AutoCorres is currently maintained by Japheth Lim Japheth.Lim@nicta.com.au.

Additionally, the latest development version is available on GitHub as part of the L4.verified project:

https://github.com/NICTA/l4v (in tools/autocorres)

Options

AutoCorres supports a variety of options, which are used as follows:

autocorres [option, key=val, list=a b c d] "file.c"

The options are:

  • unsigned_word_abs = FUNC_NAMES: Use word abstraction on unsigned integers in the given functions.

  • no_signed_word_abs = FUNC_NAMES: Disable signed word abstraction on the given list of functions.

  • skip_word_abs: Completely disable word abstraction.

  • ts_rules = RULES: Enable type strengthening to the following types. Possible types include pure (pure functional), option (option monad without state), gets (option monad with state) and nondet (non-deterministic state monad).

  • ts_force RULE_NAME = FUNC_NAMES: Force the given functions to be type-strengthened to the given type, even if a "better" type could otherwise be used. See tests/examples/type_strengthen_tricks.thy.

  • no_heap_abs = FUNC_NAMES: Disable heap abstraction on the given list of functions.

  • force_heap_abs = FUNC_NAMES: Attempt heap abstraction on the given list of functions, even if AutoCorres' heuristics believes that they cannot be lifted.

  • heap_abs_syntax: Enable experimental heap abstraction syntactic sugar.

  • skip_word_abs: Completely disable heap abstraction.

Name compatibility options (see tests/examples/AC_Rename.thy):

  • lifted_globals_field_prefix="foo", lifted_globals_field_suffix="foo": Override generated names for global variables during heap abstraction. The default is f -> f_'' (i.e. prefix="", suffix="_''").

  • function_name_prefix="foo", function_name_suffix="foo": Override generated names for abstracted functions. The default is f -> f' (i.e. prefix="", suffix="'").

Less common options (mainly for debugging):

  • keep_going: Attempt to ignore certain non-critical errors.

  • scope: Only parse the given functions and their callees, up to depth scope_depth.

  • trace_heap_lift = FUNC_NAMES: Trace the heap abstraction process for each of the given functions. The traces are stored in the Isabelle theory and can be quite large. See tests/examples/TraceDemo.thy.

  • trace_word_abs = FUNC_NAMES: As above, but traces word abstraction.

  • trace_opt: As above, but traces internal simplification phases (for all functions).

  • no_opt: Disable some optimisation passes that simplify the AutoCorres output.

  • gen_word_heaps: Force heap abstraction to create abstract heaps for standard word types (word8, word16, word32, word64) even if they are not needed.

An example of invoking AutoCorres with all of the options is as follows:

autocorres [
    unsigned_word_abs = f g h,
    no_signed_word_abs = i j k,
    skip_word_abs,  (* mutually exclusive with previous rules *)
    ts_rules = pure nondet,
    ts_force nondet = l m n,
    no_heap_abs = a b,
    force_heap_abs = c d,
    gen_word_heaps,
    skip_heap_abs,  (* mutually exclusive with previous rules *)
    heap_abs_syntax,
    keep_going,
    scope = o p q,
    scope_depth = 5,
    trace_heap_lift = c d,
    trace_word_abs = f h i,
    no_opt,
    lifted_globals_name_prefix="my_global_",
    lifted_globals_name_suffix="",
    function_name_prefix="my_func_",
    function_name_suffix=""
    ] "filename.c"

Examples

Some examples are in the tests/examples directory.

Many of these examples are quick-and-dirty proofs, and should not necessary be considered the best style.

None-the-less, some of the examples available are, in approximate increasing level of difficulty:

  • Simple.thy: Proofs of some simple functions, including max and gcd.

  • Swap.thy: Proof of a simple swap function.

  • MultByAdd.thy: Proof of a function that carries out multiplication using addition.

  • Factorial.thy: Proof of a factorial function, using several different methods.

  • FibProof.thy: Proof of the Fibonacci function, using several different methods.

  • ListRev.thy: Proof of a function that carries out an in-place linked list reversal.

  • CList.thy: Another list reversal, based on a proof by Mehta and Nipkow. See [the paper][3].

  • IsPrime.thy: Proof of a function that determines if the input number is prime.

  • Memset.thy: Proof of a C memset implementation.

  • Quicksort.thy: Proof of a simple quicksort implementation on an array of ints.

  • BinarySearch.thy: Proof of a function that determines if a sorted input array of unsigned int contains the given unsigned int.

  • SchorrWaite.thy: Proof a C implementation of the Schorr-Waite algorithm, using Mehta and Nipkow's high-level proof. See [the paper][3].

  • Memcpy.thy: Proof of a C memcpy implementation. The proof connects the C parser's byte-level heap with AutoCorres's type-safe heap representation.

There are also some examples that aren't about program proofs, but demonstrate AutoCorres features:

  • AC_Rename.thy: how to change AutoCorres-generated names.

  • TraceDemo.thy: how to use the (experimental) tracing.

  • type_strengthen_tricks.thy: configuring type-strengthening.

Publications

L1 (SimplConv), L2 (LocalVarExtract) and TS (TypeStrengthen) were described in

"Bridging the gap: Automatic verified abstraction of C"
David Greenaway, June Andronick, Gerwin Klein
Proceedings of the Third International
        Conference on Interactive Theorem Proving (ITP), August 2012.
http://ssrg.nicta.com.au/publications/nictaabstracts/5662.pdf

HL (heap abstraction) and WA (word abstraction) were described in

[3]: "Dont sweat the small stuff --- Formal verification of C code without the pain" David Greenaway, Japheth Lim, June Andronick, Gerwin Klein Proceedings of the 35th ACM SIGPLAN Conference on Programming Language Design and Implementation. ACM, June 2014. http://ssrg.nicta.com.au/publications/nictaabstracts/7629.pdf

A more comprehensive source is

"Automated proof-producing abstraction of C code"
David Greenaway
PhD thesis, March 2015.
http://ssrg.nicta.com.au/publications/nictaabstracts/8758.pdf