2015-10-09 05:41:09 +00:00
|
|
|
|
Note to maintainer: sync with tools/release_files/README
|
2014-07-25 01:34:28 +00:00
|
|
|
|
|
|
|
|
|
AutoCorres
|
|
|
|
|
==========
|
|
|
|
|
|
|
|
|
|
AutoCorres is a tool that assists reasoning about C programs
|
|
|
|
|
in [Isabelle/HOL][1]. In particular, it uses Norrish's
|
|
|
|
|
[C-to-Isabelle parser][2] to parse C into Isabelle, and then
|
|
|
|
|
abstracts the result to produce a result that is (hopefully)
|
|
|
|
|
more pleasant to reason about.
|
|
|
|
|
|
2016-03-30 06:22:39 +00:00
|
|
|
|
[1]: https://www.cl.cam.ac.uk/research/hvg/Isabelle/
|
2018-03-01 05:54:05 +00:00
|
|
|
|
[2]: https://ts.data61.csiro.au/software/TS/c-parser/
|
2014-07-25 01:34:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-10-09 05:41:09 +00:00
|
|
|
|
Contents of this README
|
|
|
|
|
-----------------------
|
|
|
|
|
|
|
|
|
|
* Installation
|
|
|
|
|
* Quickstart
|
|
|
|
|
* Development and reporting bugs
|
|
|
|
|
* Options
|
|
|
|
|
* Examples
|
|
|
|
|
* Publications
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Installation
|
|
|
|
|
------------
|
|
|
|
|
|
2019-06-11 05:48:58 +00:00
|
|
|
|
AutoCorres is packaged as a theory for Isabelle2019:
|
2015-10-09 05:41:09 +00:00
|
|
|
|
|
2016-03-30 06:22:39 +00:00
|
|
|
|
https://isabelle.in.tum.de
|
2014-07-25 01:34:28 +00:00
|
|
|
|
|
2017-04-01 12:58:48 +00:00
|
|
|
|
AutoCorres currently supports two platforms: ARM and X64. The platform
|
|
|
|
|
determines the sizes of C integral and pointer types.
|
2014-07-25 01:34:28 +00:00
|
|
|
|
|
2017-04-01 12:58:48 +00:00
|
|
|
|
For ARM, the sizes are:
|
|
|
|
|
- 64 bits: long long
|
|
|
|
|
- 32 bits: pointers, long, int
|
|
|
|
|
- 16 bits: short
|
2015-10-09 05:41:09 +00:00
|
|
|
|
|
2017-04-01 12:58:48 +00:00
|
|
|
|
For X64:
|
|
|
|
|
- 64 bits: pointers, long long, long
|
|
|
|
|
- 32 bits: int
|
|
|
|
|
- 16 bits: short
|
|
|
|
|
|
|
|
|
|
To build or use AutoCorres, you must set the L4V_ARCH environment variable
|
|
|
|
|
according to your choice of platform.
|
|
|
|
|
|
2018-03-01 12:56:50 +00:00
|
|
|
|
To build AutoCorres for ARM, run the following in the L4.verified directory:
|
2017-04-01 12:58:48 +00:00
|
|
|
|
|
2018-03-01 12:56:50 +00:00
|
|
|
|
L4V_ARCH=ARM misc/regression/run_tests.py AutoCorres
|
2015-10-09 05:41:09 +00:00
|
|
|
|
|
2017-04-01 12:58:48 +00:00
|
|
|
|
This builds the C parser and AutoCorres itself.
|
|
|
|
|
|
|
|
|
|
To build AutoCorres for X64:
|
|
|
|
|
|
2018-03-01 12:56:50 +00:00
|
|
|
|
L4V_ARCH=X64 misc/regression/run_tests.py AutoCorres
|
2017-04-01 12:58:48 +00:00
|
|
|
|
|
|
|
|
|
There is also a test suite, which can be run using:
|
2015-10-09 05:41:09 +00:00
|
|
|
|
|
2018-03-01 12:56:50 +00:00
|
|
|
|
L4V_ARCH=ARM misc/regression/run_tests.py AutoCorresTest
|
|
|
|
|
L4V_ARCH=X64 misc/regression/run_tests.py AutoCorresTest
|
2015-10-09 05:41:09 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Quickstart
|
|
|
|
|
----------
|
2014-07-25 01:34:28 +00:00
|
|
|
|
|
2015-10-09 05:41:09 +00:00
|
|
|
|
A brief tutorial can be found in doc/quickstart.
|
|
|
|
|
Run `make AutoCorresDoc` to generate a readable PDF document of
|
|
|
|
|
the tutorial.
|
2014-07-25 01:34:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-10-09 05:41:09 +00:00
|
|
|
|
Development and reporting bugs
|
|
|
|
|
------------------------------
|
2014-07-25 01:34:28 +00:00
|
|
|
|
|
2017-04-01 12:58:48 +00:00
|
|
|
|
AutoCorres is currently maintained by
|
2018-03-01 12:56:50 +00:00
|
|
|
|
Matthew Brecknell <Matthew.Brecknell@data61.csiro.au>.
|
2014-07-25 01:34:28 +00:00
|
|
|
|
|
2015-10-09 05:41:09 +00:00
|
|
|
|
Additionally, the latest development version is available on GitHub
|
|
|
|
|
as part of the L4.verified project:
|
|
|
|
|
|
2016-03-30 06:22:39 +00:00
|
|
|
|
https://github.com/seL4/l4v (in tools/autocorres)
|
2014-07-25 01:34:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Options
|
|
|
|
|
-------
|
|
|
|
|
|
2014-07-28 01:59:57 +00:00
|
|
|
|
AutoCorres supports a variety of options, which are used as follows:
|
2014-07-25 01:34:28 +00:00
|
|
|
|
|
2016-05-27 03:04:18 +00:00
|
|
|
|
autocorres [option, key=val, list=a b c d] "path/to/file.c"
|
|
|
|
|
|
|
|
|
|
`path/to/file.c` is the same path given to `install_C_file`, and
|
|
|
|
|
AutoCorres will define the translated functions in the C-parser's
|
|
|
|
|
generated locale (named `file`).
|
2014-07-25 01:34:28 +00:00
|
|
|
|
|
|
|
|
|
The options are:
|
|
|
|
|
|
2016-05-27 03:04:18 +00:00
|
|
|
|
* `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_heap_abs`: Completely disable _heap abstraction_.
|
|
|
|
|
|
2014-07-25 01:34:28 +00:00
|
|
|
|
* `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.
|
2014-11-27 07:08:44 +00:00
|
|
|
|
See `tests/examples/type_strengthen_tricks.thy`.
|
2014-07-25 01:34:28 +00:00
|
|
|
|
|
2016-05-27 03:04:18 +00:00
|
|
|
|
* `scope = FUNC_NAMES`: Only translate the given functions
|
|
|
|
|
and their callees, up to depth `scope_depth`.
|
|
|
|
|
AutoCorres can be invoked multiple times to translate
|
|
|
|
|
parts of a program. See `tests/examples/Incremental.thy`.
|
2014-07-25 01:34:28 +00:00
|
|
|
|
|
2016-05-27 03:04:18 +00:00
|
|
|
|
* `scope_depth = N`: Call depth for `scope`.
|
2015-10-09 05:41:09 +00:00
|
|
|
|
|
2015-10-01 05:40:28 +00:00
|
|
|
|
Name compatibility options (see `tests/examples/AC_Rename.thy`):
|
2015-09-16 11:18:16 +00:00
|
|
|
|
|
|
|
|
|
* `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="'").
|
|
|
|
|
|
2014-11-27 07:08:44 +00:00
|
|
|
|
Less common options (mainly for debugging):
|
|
|
|
|
|
2014-07-25 01:34:28 +00:00
|
|
|
|
* `keep_going`: Attempt to ignore certain non-critical
|
|
|
|
|
errors.
|
|
|
|
|
|
2014-11-27 07:08:44 +00:00
|
|
|
|
* `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_.
|
|
|
|
|
|
2014-12-02 06:18:15 +00:00
|
|
|
|
* `trace_opt`: As above, but traces internal simplification
|
|
|
|
|
phases (for all functions).
|
|
|
|
|
|
2014-11-27 07:08:44 +00:00
|
|
|
|
* `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.
|
|
|
|
|
|
2016-05-27 03:04:18 +00:00
|
|
|
|
The following options are for interfacing with the seL4 proofs.
|
|
|
|
|
|
|
|
|
|
* `c_locale = NAME`: Run in this locale, rather than the default locale
|
|
|
|
|
created by the C-parser. This locale must behave like the C-parser
|
|
|
|
|
one except that the function bodies may be different.
|
|
|
|
|
|
|
|
|
|
* `no_c_termination`: Generate SIMPL wrappers and correspondence
|
|
|
|
|
proofs that do not require program termination for the SIMPL source.
|
|
|
|
|
|
2014-07-25 01:34:28 +00:00
|
|
|
|
An example of invoking AutoCorres with _all_ of the options
|
|
|
|
|
is as follows:
|
|
|
|
|
|
|
|
|
|
autocorres [
|
|
|
|
|
no_heap_abs = a b,
|
2014-11-27 07:08:44 +00:00
|
|
|
|
force_heap_abs = c d,
|
2015-10-09 05:41:09 +00:00
|
|
|
|
gen_word_heaps,
|
2016-05-27 03:04:18 +00:00
|
|
|
|
skip_heap_abs, (* mutually exclusive with previous options *)
|
2014-07-25 01:34:28 +00:00
|
|
|
|
heap_abs_syntax,
|
2016-05-27 03:04:18 +00:00
|
|
|
|
|
|
|
|
|
unsigned_word_abs = f g h,
|
|
|
|
|
no_signed_word_abs = i j k,
|
|
|
|
|
skip_word_abs, (* mutually exclusive with previous options *)
|
|
|
|
|
|
|
|
|
|
ts_rules = pure nondet,
|
|
|
|
|
ts_force nondet = l m n,
|
|
|
|
|
|
2014-07-25 01:34:28 +00:00
|
|
|
|
scope = o p q,
|
|
|
|
|
scope_depth = 5,
|
2016-05-27 03:04:18 +00:00
|
|
|
|
keep_going,
|
2016-01-21 06:27:22 +00:00
|
|
|
|
c_locale = "my_locale",
|
2016-05-27 03:04:18 +00:00
|
|
|
|
no_c_termination,
|
2014-11-27 07:08:44 +00:00
|
|
|
|
trace_heap_lift = c d,
|
|
|
|
|
trace_word_abs = f h i,
|
|
|
|
|
no_opt,
|
2016-05-27 03:04:18 +00:00
|
|
|
|
|
|
|
|
|
lifted_globals_field_prefix="my_global_",
|
|
|
|
|
lifted_globals_field_suffix="",
|
2015-09-16 11:18:16 +00:00
|
|
|
|
function_name_prefix="my_func_",
|
|
|
|
|
function_name_suffix=""
|
2014-11-27 07:08:44 +00:00
|
|
|
|
] "filename.c"
|
2014-07-25 01:34:28 +00:00
|
|
|
|
|
2015-10-09 05:41:09 +00:00
|
|
|
|
|
|
|
|
|
|
2014-07-25 01:34:28 +00:00
|
|
|
|
Examples
|
|
|
|
|
--------
|
|
|
|
|
|
2015-10-09 05:41:09 +00:00
|
|
|
|
Some examples are in the `tests/examples` directory.
|
2014-07-25 01:34:28 +00:00
|
|
|
|
|
2014-07-28 01:59:57 +00:00
|
|
|
|
Many of these examples are quick-and-dirty proofs, and should not
|
|
|
|
|
necessary be considered the best style.
|
2014-07-25 01:34:28 +00:00
|
|
|
|
|
2014-07-28 01:59:57 +00:00
|
|
|
|
None-the-less, some of the examples available are, in approximate
|
|
|
|
|
increasing level of difficulty:
|
2014-07-25 01:34:28 +00:00
|
|
|
|
|
|
|
|
|
* `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.
|
|
|
|
|
|
2014-07-28 01:59:57 +00:00
|
|
|
|
* `FibProof.thy`: Proof of the Fibonacci function, using
|
2014-07-25 01:34:28 +00:00
|
|
|
|
several different methods.
|
|
|
|
|
|
|
|
|
|
* `ListRev.thy`: Proof of a function that carries out an
|
|
|
|
|
in-place linked list reversal.
|
|
|
|
|
|
2015-10-09 05:41:09 +00:00
|
|
|
|
* `CList.thy`: Another list reversal, based on a proof by
|
|
|
|
|
Mehta and Nipkow. See [the paper][3].
|
|
|
|
|
|
2014-07-25 01:34:28 +00:00
|
|
|
|
* `IsPrime.thy`: Proof of a function that determines if
|
|
|
|
|
the input number is prime.
|
|
|
|
|
|
2015-10-09 05:41:09 +00:00
|
|
|
|
* `Memset.thy`: Proof of a C `memset` implementation.
|
2014-07-25 01:34:28 +00:00
|
|
|
|
|
2015-10-09 05:41:09 +00:00
|
|
|
|
* `Quicksort.thy`: Proof of a simple quicksort
|
2014-07-25 01:34:28 +00:00
|
|
|
|
implementation on an array of `int`s.
|
|
|
|
|
|
|
|
|
|
* `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
|
2015-10-09 05:41:09 +00:00
|
|
|
|
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.
|
|
|
|
|
|
2016-05-27 03:04:18 +00:00
|
|
|
|
* `Incremental.thy`: (experimental) support for incremental translation.
|
|
|
|
|
|
2015-10-09 05:41:09 +00:00
|
|
|
|
|
2014-07-25 01:34:28 +00:00
|
|
|
|
|
2015-10-09 05:41:09 +00:00
|
|
|
|
Publications
|
|
|
|
|
------------
|
2014-07-25 01:34:28 +00:00
|
|
|
|
|
2015-10-09 05:41:09 +00:00
|
|
|
|
L1 (SimplConv), L2 (LocalVarExtract) and TS (TypeStrengthen) were described in
|
2014-07-25 01:34:28 +00:00
|
|
|
|
|
2015-10-09 05:41:09 +00:00
|
|
|
|
"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.
|
2018-03-01 05:54:05 +00:00
|
|
|
|
https://ts.data61.csiro.au/publications/nicta_full_text/5662.pdf
|
2014-07-25 01:34:28 +00:00
|
|
|
|
|
2015-10-09 05:41:09 +00:00
|
|
|
|
HL (heap abstraction) and WA (word abstraction) were described in
|
2014-07-25 01:34:28 +00:00
|
|
|
|
|
2015-10-09 05:41:09 +00:00
|
|
|
|
[3]:
|
|
|
|
|
"Don’t 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.
|
2018-03-01 05:54:05 +00:00
|
|
|
|
https://ts.data61.csiro.au/publications/nicta_full_text/7629.pdf
|
2014-07-25 01:34:28 +00:00
|
|
|
|
|
2015-10-09 05:41:09 +00:00
|
|
|
|
A more comprehensive source is
|
2014-07-25 01:34:28 +00:00
|
|
|
|
|
2015-10-09 05:41:09 +00:00
|
|
|
|
"Automated proof-producing abstraction of C code"
|
|
|
|
|
David Greenaway
|
|
|
|
|
PhD thesis, March 2015.
|
2018-03-01 05:54:05 +00:00
|
|
|
|
https://ts.data61.csiro.au/publications/nicta_full_text/8758.pdf
|