Theory fnptr_proto
theory fnptr_proto
imports
AutoCorres2_Main.AutoCorres_Main
begin
typedecl environment
consts callback_step::
"8 word list ⇒ environment ⇒ (32 word * environment)"
consts callback_info::
"8 word list ⇒ environment ⇒ (32 word)"
consts callback_void_step::
"environment ⇒ environment"
ML ‹IsarInstall.installed_C_files @{theory}›
text ‹When functions are called within expressions the C-parser analyses which global variables
are affected by those functions (read and write dependencies) and only accepts functions that
have no overlapping and thus potentially conflicting dependencies.
To do this analysis the C-parser looks into the function bodies.
As function prototypes have no bodies the C-Parser by default assumes the "worst" for those
functions: They are considered to read and write everything. So this by default prohibits the
use of function prototypes within expressions.
When you need more flexibility here you can specifiy the dependencies explicitly as demonstrated
in this file.
You can later define specifications for those prototypes and declare them to autocorres
via overloading and command ‹declare_prototype› or more low level with @{attribute autocorres_definition}
Autocorres then generates a proof obligation that this specification behaves according to the
declared dependencies.
›
setup ‹
let
open AstDatatype
in
IsarInstall.add_prototype_dependencies "fnptr_proto.c"
("w", read_anything_write_phantom_machine_state) #>
IsarInstall.add_prototype_dependencies "fnptr_proto.c"
("w1", read_heap_and_phantom_machine_state_write_phantom_machine_state)
end
›
ML ‹IsarInstall.installed_C_files @{theory}›