Commit Graph

940 Commits

Author SHA1 Message Date
Gerwin Klein 12c9c2bc21
lib: apply consistent style to OptionMonad
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-02-06 09:57:37 +11:00
Gerwin Klein ed0cd5b282
lib+aarch64 ainvs: make opt_pred a definition
The projection operators should be definitions so that they are stable
under simp and case splits. This enables later projection stacks to
use abbreviations that remain stable.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-02-06 09:56:37 +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 3467e685b6 lib: remove opt_mapE from global [elim!] set
While we do want to break up full OptionMonad terms in assumptions, we
do not usually want to break up projections.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-02-02 17:56:55 +11:00
Gerwin Klein a13db04598
lib: README.md files for the new sessions
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-01-25 11:49:59 +11:00
Gerwin Klein 1893d00f83
lib: move general lemma to Lib
lifted_if_collapse has no dependencies that require it to be in
NonDetMonadLemmaBucket.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-01-25 11:48:39 +11:00
Gerwin Klein e3c2e878b9
lib+proof+autocorres: consolidate when[E]/unless[E]_wp naming
wp rules for most operators such as return, get, gets are named
return_wp, get_wp, etc. Then when, whenE, unless, unlessE operators had
an additional hoare_.. prefix that this commit removes for more
consistency.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-01-25 11:48:39 +11:00
Gerwin Klein 49c93e64ee
lib: eliminate hoare_gets_post
duplicate of hoare_gets_sp

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-01-25 11:48:39 +11:00
Gerwin Klein 625c6e359d
lib+proof: eliminate hoare_ex_wp
duplicate of hoare_vcg_ex_lift

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-01-25 11:48:38 +11:00
Gerwin Klein 9103f2b700
lib: remove unused duplicate lemma name
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-01-25 11:48:38 +11:00
Gerwin Klein a2a79ad3c4
lib: always prefer Main to HOL.HOL import
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-01-25 11:48:38 +11:00
Gerwin Klein b4b9a00a28
lib+refine: eliminate select_singleton_is_return
Also make select_singleton [simp], because it is later declared
globally [simp] anyway.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-01-25 11:48:38 +11:00
Gerwin Klein b1daf38dda
lib+crefine: eliminate list_case_return2
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-01-25 11:48:38 +11:00
Gerwin Klein 6bf7c92d22
lib+crefine: zipWith lemma [simp] consolidation
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-01-25 10:19:41 +11:00
Gerwin Klein 40dc7eaa01
lib+autocorres: remove last AutoCorres Lib dependency
Moving `Monad_Equations.thy` and `More_NonDetMonadVCG.thy` into Monads
session enables us to remove the Lib and CLib session dependencies in
AutoCorres.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-01-25 10:19:03 +11:00
Gerwin Klein 2d2cadb86b
lib+proof+tools: move LemmaBucket_C into CParser
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-01-25 10:18:11 +11:00
Gerwin Klein cb34fc3c4c
lib: introduce Basics session
This session currently contains only one theory (CLib), which we want
to include both in Lib and later independently in CParser/AutoCorres.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-01-25 10:18:11 +11:00
Gerwin Klein c9259eb8a4
lib: reduce dependencies of LemmaBucket_C
Remove Lib dependency. Introduce a new theory CLib which contains base
lemmas needed in LemmaBucket_C.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-01-25 10:13:46 +11:00
Gerwin Klein 0f71104ca9
lib+autocorres: move NatBitwise to AutoCorres
Since most bitwise operations are now available by default for nat,
only word abstraction in AutoCorres depends on NatBitwise.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-01-25 10:13:45 +11:00
Gerwin Klein a9fd0142be
all: adjust theory imports for TypHeapLib change
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-01-25 10:13:45 +11:00
Gerwin Klein 1ea235c152
lib+c-parser: move TypHeapLib into CParser
It has no other lib dependencies and over time should probably be
merged directly into umm theories. For now, move the entire file
and keep dependency structure.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-01-25 10:13:44 +11:00
Gerwin Klein b92974d93f
lib: theory import fixes for new sessions
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-01-24 11:30:05 +11:00
Gerwin Klein 0aa42207e5
lib/monads: move Datatype_Schematic into wp
Not at monad definition itself, more tool setup for WPFix.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-01-24 11:30:05 +11:00
Gerwin Klein cc0ca9118e
lib: introduce Monads session
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-01-24 11:30:05 +11:00
Gerwin Klein 2722fdcfc1
lib: move more monad thys into Monads directory
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-01-24 11:30:05 +11:00
Gerwin Klein bba173cb99
lib+READMEs: rename Monad_WP to Monads
In preparation for a separate Monads session.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-01-24 11:30:05 +11:00
Gerwin Klein 34c427d09d
lib: add separate Eisbach_Tools session
The idea is to collect Eisbach extensions and things like Apply_Trace,
Apply_Debug etc here.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-01-24 11:30:04 +11:00
Gerwin Klein 0aa2914b84
lib/monads: move empty_fail_guard into NonDetMonadVCG
So that it is available together with the other empty_fail lemmas.
Eventually, these should go into their own theory.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-01-24 11:21:47 +11:00
Gerwin Klein 238acb46bb
lib+tools: MLUtils -> ML_Utils for consistency
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-01-20 13:43:39 +11:00
Gerwin Klein d86d577657
lib: make ML_Utils a separate session
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-01-20 13:43:39 +11:00
Gerwin Klein f0f19375f7
lib: rename ml-helpers to ML_Utils
In preparation for making it its own separate session.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-01-20 11:26:48 +11:00
Gerwin Klein 7424005a66
lib: make theLeft/theRight/isLeft/isRight abbreviations
Since the creation of these constants the sum type has been updated to
come with its own discriminators and selectors. We use these, but keep
our longer names as abbreviations.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-01-19 17:41:11 +11:00
Gerwin Klein 9c3a7faefd
lib+proofs: s/non_fail_/no_fail/
Some of the no_fail lemmas had he wrong name (non_fail instead of
no_fail).

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-01-19 17:02:10 +11:00
Gerwin Klein 79eccd3c10
lib+spec+proofs: proof fixes for NonDetMonadLemmaBucket split
Very minor changes, but in many modules.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-01-19 17:01:34 +11:00
Gerwin Klein fc5af7e402
lib: rename More_Monad to Monad_Lists and fix style
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-01-19 17:01:25 +11:00
Gerwin Klein d86acc885a
lib: move wp lemmas for mapM et al into More_Monad
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-01-19 17:01:13 +11:00
Gerwin Klein d275068826
lib: move empty_fail lemmas up into NonDetMonadVCG
This enables a few more moves of remaining lemmas in
NonDetMonadLemmaBucket into the theories they belong thematically.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-01-19 17:01:12 +11:00
Gerwin Klein f19364a38b
lib: split NonDetMonadLemmaBucket into multiple theories
- organizes the material
- enables more concurrency
- allows us to pick and choose which parts to import

Currently NonDetMonadLemmaBucket still imports Lib to keep the overall
exports from this theory unchanged, but none of the factored-out
theories depend on Lib.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-01-19 17:01:12 +11:00
Gerwin Klein de9cb04a11
lib: factor out monad dependencies
Factors out definitions and lemmas that are used in monads from Lib.thy
into a separate theory Monad_Lib, which itself does not have further
dependencies.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-01-19 17:00:14 +11:00
Michael McInerney 619e941631 c-parser+crefine+clib: move is_aligned_c_guard to c-parser session
Signed-off-by: Michael McInerney <michael.mcinerney@proofcraft.systems>
2023-01-12 11:48:59 +10:30
Gerwin Klein 3960115459
lib+proofs+sys-init+tools: proof updates for Fun_Pred_Syntax
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-01-09 14:54:11 +11:00
Gerwin Klein 369a926e4d
lib: factor out and generalise bool syntax for functions
pred_conj, pred_disj, and pred_neg only worked for functions with a
single argument and did not have the standard boolean laws available.

This commit factors out these declarations into their own theory, so
they can be used independently. It generalises them to functions of
arbitrarily many arguments, using the existing instance of fun in class
boolean_algebra.

We also factor out top/bottom, but leave them as abbreviations for now,
because the impact of changing them to the type class is too large.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-01-09 14:54:06 +11:00
Michael McInerney 03426eada0 lib: add hoare_from_abs rule
This also moves ex_abs_underlying from Corres_Method.thy to
ExtraCorres.thy and adds a variant of corres_underlying_split

Signed-off-by: Michael McInerney <michael.mcinerney@proofcraft.systems>
2022-11-10 16:09:13 +11:00
Michael McInerney 9b33cfad36 update copyright
Signed-off-by: Michael McInerney <michael.mcinerney@proofcraft.systems>
2022-11-09 15:52:50 +11:00
Corey Lewis 7e44994a55 isabelle2022 lib: update Concurrency
Signed-off-by: Corey Lewis <corey.lewis@proofcraft.systems>
2022-11-09 11:45:46 +11:00
Corey Lewis c6b137dfba isabelle2022 lib: update Lib
Signed-off-by: Corey Lewis <corey.lewis@proofcraft.systems>
2022-11-09 11:45:46 +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
Rafal Kolanski 87fadfcca5 lib: monadic rewrite: adjust single pass and symb exec methods
During deployment of these tactics, two problems appeared:
* monadic_rewrite_single_pass
  * would try to step after the action completed, which sometimes worked,
    yielding unpredictable results
  * finalise was called on monadic_rewrite goals generated by action,
    which was fine with the `solves <wpsimp>` default, but yielded
    unpredictable results with user-supplied finalise methods
* monadic_rewrite_symb_exec
  * did not schematise the precondition before attempting to apply the
    rule, resulting in lack of progress when it was expected;
    this now yields an extra subgoal in rare obvious-precondition
    cases, but is more user-friendly in the general case

Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2022-11-02 05:05:44 +11:00
Rafal Kolanski 40e5f2b700 lib: monadic rewrite: overhaul tactics
In single-pass methods and symb_exec* methods, the finalise method
argument is optional, defaulting to solves<wpsimp> which is good enough
for most side-conditions and many WP goals.

`monadic_rewrite_symb_exec_l/r_known` methods internally supply the
instantiated theorem variable name, allowing specifying the
instantiation directly:
`monadic_rewrite_symb_exec_l cte_cap`

Symbolic execution removes no-name eta terms so that the actual variable
name in the monad is used, reducing need for rename_tac.

Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2022-11-02 05:05:44 +11:00