Commit Graph

138 Commits

Author SHA1 Message Date
Gerwin Klein ad24d954aa word lib: fix broken style introduced from AFP
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-10-06 14:59:27 +11:00
Gerwin Klein 6721c7a15e lib: sync Word_Lib with AFP
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-10-06 14:29:15 +11:00
Gerwin Klein 9f7e8f8351
word_lib: anti-monotonicity of shiftr
Co-authored-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-09-27 14:28:35 +10:00
Corey Lewis b8714328cb word_lib+crefine: add and_one_neq_simps and adjust proofs
Signed-off-by: Corey Lewis <corey.lewis@proofcraft.systems>
2023-04-18 13:23:42 +10:00
Gerwin Klein 1d2e75fd81
word_lib: lemma to turn < into bitwise reasoning
word_less_bit_eq turns `<` into a bitwise expression on abstract word
length to make it easier to reason about the relationship of < and bit
operations (boolean, but also shift etc).

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-04-11 13:17:54 +10:00
Gerwin Klein d4a63b2784
word_lib: more docs on word_bitwise and word_eqI
The Eisbach method command doesn't seem to allow providing a doc
string. Instead at least place a comment right next to the definition
so that people can find that when they discover the method name with
print_methods.

Update doc string of word_bitwise to clarify where it is useful.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-04-11 13:17:53 +10:00
Gerwin Klein b72e177677
word_lib: laws about min, max, and NOT
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-04-11 13:17:53 +10:00
Gerwin Klein d163d41b63
word_lib: some cleanup in More_Word
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-04-11 13:17:53 +10:00
Gerwin Klein 20ef209b30
word_lib: boolean operations and arithmetic
Adds generic (ring_bit_operations) relationships between boolean and
arithmetic operations. These automatically hold for word and int.

In particular:

   x + y = (x OR y) + (x AND y)
   x + y = (x XOR y) + 2 * (x AND y)
   x XOR y = (x OR y) - (x AND y)

Similar laws for OR, AND, and -.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-04-11 13:17:53 +10:00
Gerwin Klein d1858007d2
word_lib: all binary boolean inequalities
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-04-11 13:17:53 +10:00
Gerwin Klein 4bae25bb93
word_lib: sgn and abs instances for word
Provide sgn (sign, mapping to -1, 0, 1) and abs (absolute value)
functions for 'a word by instantiating the relevant type classes.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-04-11 13:17:53 +10:00
Gerwin Klein ac1cda74f9
word_lib: remove warning
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-04-11 13:17:49 +10:00
Corey Lewis 75db914627
word_lib: new lemmas about mask, AND, and shift
Signed-off-by: Corey Lewis <corey.lewis@proofcraft.systems>
2023-03-29 11:05:25 +11:00
Gerwin Klein 0bee918631
Word_Lib: enable "eval" for word quantifiers (#574)
Enable use of "eval" and "value" for formulas that quantify over word
values. The code generator will exhaustively run all possible values.

For small word sizes, this works in very reasonable time. E.g. try

    lemma "∀(x::8 word) y. x + y = (x AND y) + (x OR y)"
      by eval

or

    value "∀(x::4 word) y z. y mod z = 0 ⟶
                             (x * y) div z = x * (y div z)"

Note that as usual for "eval" and "value" terms have to be close, i.e.
you need to use object logic quantifiers.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-02-10 08:54:18 +11:00
Gerwin Klein e5036721df
lib+ainvs+aarch64 ainvs: cleanup + move lemmas into lib
- make kheap crunch for do_machine_op generic
- make None_Some_strg available generically in LevityCatch
- move word lemmas up into Word_Lib
- move wp lemmas up into lib + minor lib cleanup

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-02-06 09:56:37 +11:00
Gerwin Klein 4001debe25
lib+ainvs: clean up LevityCatch_AI
- move proof methods spec and bspec to Eisbach_Methods
- move general lemmas to Lib
- move word lemmas to Word_Lemmas_Internal
- update proof style

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-02-06 09:56:36 +11:00
Gerwin Klein e101f37cfc isabelle2022: import Word_Lib AFP changes
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-11-09 11:45:46 +11:00
Gerwin Klein a45d32e574 word-lib: remove unused if/option lemma
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-10-20 17:51:27 +11:00
Gerwin Klein 4bb5899359 word_lib: move in lemma from l4v
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-03-29 08:38:25 +11:00
Gerwin Klein 2d930d69db word_lib: fix non-terminal `auto` violations
Not acceptable in either AFP or l4v.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-03-29 08:38:25 +11:00
Gerwin Klein 896434499e word_lib: fix license headers
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-03-29 08:38:25 +11:00
Gerwin Klein c953ab0396 word_lib/proofs: bundle word simp set changes
Add a bundle for global word simp set changes -- unfortunately we
can't actually do this globally, because they are mostly simp rule
removals which will be overwritten by theory merges. So this new
l4v_word_lib bundle will have to be activated/unbundled multiple times.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-03-29 08:38:25 +11:00
Gerwin Klein 65fbeb5b01 isabelle2021-1 word_lib: add lemmas from l4v
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-03-29 08:38:25 +11:00
Gerwin Klein 71e78ac126 isabelle2021-1 word_lib: make bit_simps [simp]
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-03-29 08:38:25 +11:00
Gerwin Klein c9f8e023f4 isabelle2021-1 word_lib: tweak word_eqI method
More controlled simpset setup, so we don't get warnings if we have
bit_simps in the simpset already.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-03-29 08:38:25 +11:00
Gerwin Klein a0bf14024e isabelle2021-1 word_lib: sync from AFP
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-03-29 08:38:25 +11:00
Gerwin Klein bba7dd942b word_lib internal: update from definition tweaks
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-03-29 08:38:25 +11:00
Gerwin Klein 15d9167521 word_lib: provide more backwards compatible names
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-03-29 08:38:25 +11:00
Gerwin Klein 60126b5591 word_lib: use more general bit_simps in word_eqI
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-03-29 08:38:25 +11:00
Gerwin Klein 25d2da46e1 isabelle2021-1: Word_Lib adjustments for l4v
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-03-29 08:38:25 +11:00
Gerwin Klein 1b15714cbf isabelle2021-1: sync Word_Lib from afp
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-03-29 08:38:25 +11:00
Gerwin Klein d3ecd0e451 aarch64 lib: add 64 bit word setup
This is equal to the setup for RISCV64 and X64.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-02-03 16:13:45 +11:00
Gerwin Klein 203af59e29 word_lib: make sure Word_Lib setup is not shadowed
The theory import order is important for name shadowing, including
default rules for induction and cases. This commit makes sure we
get the Word_Lib version by default, not the HOL.Word version.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2021-09-30 16:53:17 +10:00
Gerwin Klein ac325266b8 Word_Lib: make word_and_max_simps 64bit clean
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2021-09-30 16:53:17 +10:00
Gerwin Klein 414eb5ce3d Word_Lib: simplify numeral + Suc 0 expressions
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2021-09-30 16:53:17 +10:00
Gerwin Klein be4d042525 isabelle-2021: add no_0_dvd bundle
Terms of the form "of_nat x = 0" get rewritten into
"~x dvd 2^LENGTH('a)", which is almost never what you want for
concrete word sizes. This bundle makes it easy to remove those rules
locally.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2021-09-30 16:53:17 +10:00
Gerwin Klein 42e174ce1f isabelle-2021: additional word lemmas
These were needed in the rest of the Isabelle2021 update.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2021-09-30 16:53:17 +10:00
Gerwin Klein 0dba5d8331 word_lib: sync with AFP
This commit makes set_bit possible to instantiate for type nat.

Signed-off-by: Gerwin Klein <gerwin.klein@data61.csiro.au>
2021-09-30 16:53:17 +10:00
Gerwin Klein ee8dbcb09c isabelle-2021: AutoCorres update
includes Word_Lib tweaks

Signed-off-by: Gerwin Klein <gerwin.klein@data61.csiro.au>
2021-09-30 16:53:17 +10:00
Gerwin Klein 4afa4734a5 word_lib: remove unused theories
Signed-off-by: Gerwin Klein <gerwin.klein@data61.csiro.au>
2021-09-30 16:53:17 +10:00
Gerwin Klein 8715767431 word_lib: reduce warnings
Signed-off-by: Gerwin Klein <gerwin.klein@data61.csiro.au>
2021-09-30 16:53:17 +10:00
Gerwin Klein 84fc895f21 word_lib: Word_x shadow each other
Word_32 and Word_64 shouldn't be included at the same time, they
both define default word_size and other notions. This commit refactors
them to be usable independently and also makes the type names available
independently from all of the Word_x theories.

Signed-off-by: Gerwin Klein <gerwin.klein@data61.csiro.au>
2021-09-30 16:53:17 +10:00
Gerwin Klein 9d7efd75e2 isabelle-2021: cparser+tests update
This includes a tweak to Word_Lib to simplify ucast(-1) which
is now a term that occurs more often.

Signed-off-by: Gerwin Klein <gerwin.klein@data61.csiro.au>
2021-09-30 16:53:17 +10:00
Gerwin Klein dadb0b9f0a isabelle-2021: sync Word_Lib from AFP
Signed-off-by: Gerwin Klein <gerwin.klein@data61.csiro.au>
2021-09-30 16:53:17 +10:00
Ryan Barry a99a2bf739 various: resolve some existing fixmes
Signed-off-by: Ryan Barry <ryan.barry@unsw.edu.au>
2021-07-22 10:44:43 +10:00
Mitchell Buckley 2cf89e20c8 Cleanup some FIXMEs in AInvs and related sessions
Mostly moving lemmas up into various lemma bucket theories. Also:
* replace cte_wp_at_eqD with cte_wp_at_norm (equal lemmas)
* pd_shifting_gen generalise pd_shifting' in 2 architectures
* remove some redundant crunch lemmas

Signed-off-by: Mitchell Buckley <Mitchell.Buckley@data61.csiro.au>
2021-07-16 14:13:07 +10:00
Mitchell Buckley 6386f753fa riscv: use `uint8_t` for `register_t`
`register_t` only needs to be able to index into the TCB user context
array, which has 35 entries on RISC-V. Therefore `uint8_t` is
sufficient.

Using the smallest possible type for `register_t` helps with binary
verification. This shrinks static read-only data, which in turn reduces
the complexity of binary verification proof search.

This commit verifies the corresponding C kernel patch.

Co-authored-by: Zoltan Kocsis <Zoltan.Kocsis@data61.csiro.au>
Signed-off-by: Mitchell Buckley <Mitchell.Buckley@data61.csiro.au>
Signed-off-by: Zoltan Kocsis <Zoltan.Kocsis@data61.csiro.au>
2021-03-24 08:47:19 +11:00
Matthew Brecknell 4278e99aa4 riscv crefine: generalise and move some lemmas
Signed-off-by: Matthew Brecknell <Matthew.Brecknell@data61.csiro.au>
2021-03-23 22:40:46 +11:00
Gerwin Klein a45adef66a all: remove theory import path references
In Isabelle2020, when isabelle jedit is started without a session
context, e.g. `isabelle jedit -l ASpec`, theory imports with path
references cause the isabelle process to hang.

Since sessions now declare directories, Isabelle can find those files
without path reference and we therefore remove all such path references
from import statements. With this, `jedit` and `build` should work with
and without explicit session context as before.

Signed-off-by: Gerwin Klein <gerwin.klein@data61.csiro.au>
2020-11-02 10:16:17 +10:00
Gerwin Klein 600836ec7f word_lib: re-sync with AFP; fix broken document
Also switched on document generation so we don't miss these in the future.

Signed-off-by: Gerwin Klein <gerwin.klein@data61.csiro.au>
2020-10-27 15:52:31 +10:00