-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proposal: Globals (pre-cursor to Compilation Units) #30
Open
gmalecha
wants to merge
8
commits into
mit-plv:master
Choose a base branch
from
bedrocksystems:compilation-units
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
6b118a3
compilation units.
gmalecha 4dd974a
allow for recursive functions.
gmalecha ae9de05
very rough sketch of what a compilation unit might look like.
gmalecha bafffad
only export the exports
gmalecha c8c1d75
reverting function pointers.
gmalecha 8e9acb2
porting ExprImp.
gmalecha 2ad2788
fixing the broken proofs in the bedrock2 directory
gmalecha dd1f540
verification condition for compilation units.
gmalecha File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
Require Import Coq.Strings.String. | ||
Require Import Coq.ZArith.BinIntDef. | ||
Require Import ExtLib.Data.HList. | ||
Require Import ExtLib.Data.Fin. | ||
Require Import ExtLib.Data.Map.FMapAList. | ||
Require Import bedrock2.Macros bedrock2.Notations bedrock2.Map. | ||
Require Import bedrock2.Syntax. | ||
Require Import bedrock2.Semantics. | ||
|
||
(* Compilation units should be fairly simple | ||
* - the basic idea is that you have "externals", "internals", and "exports" | ||
* - definitions can call externals and internals | ||
* - exports must be a subset of external and internal | ||
* - in the module-level semantics, one type of interaction needs to be | ||
* external call. | ||
* - note(gmm): we don't have to support recursive linking if we want to keep | ||
* the terminating semantics. | ||
*) | ||
|
||
Module module. | ||
Section with_parameters. | ||
Context {p : Syntax.parameters}. | ||
|
||
Variant data : Set := | ||
| Data (_ : list Z). | ||
|
||
Variant definition : Type := | ||
| X (_ : list data) | ||
| Function (_ : list varname * list varname * Syntax.cmd). | ||
|
||
|
||
(* note(gmm): this could be made more uniform with the rest of the development | ||
* if we used `map`. | ||
*) | ||
Record module : Type := | ||
{ imports : list globname | ||
; internal : list globname | ||
; exports : list globname | ||
; definitions : list (globname * definition) | ||
}. | ||
|
||
End with_parameters. | ||
End module. | ||
|
||
(* the meaning of a module is a function of the meaning of the imports to the | ||
* meaning of the outputs. | ||
* note(gmm): an alternative way to represent this to treat calls to imports | ||
* as actions. | ||
*) | ||
|
||
Require Import bedrock2.WeakestPrecondition. | ||
|
||
Section module_semantics. | ||
Variable p : Semantics.parameters. | ||
Variable resolver : globname -> option word. | ||
|
||
Definition func_meaning : Type := | ||
(trace -> Prop) -> | ||
(trace -> Prop) -> | ||
(trace -> trace -> Prop) -> | ||
trace -> | ||
mem -> | ||
list word -> | ||
(trace -> mem -> list word -> Prop) -> Prop. | ||
|
||
Variables (mod : module.module) | ||
(denoteImports : globname -> func_meaning). | ||
|
||
Definition functions : list _ := | ||
(fix functions ls := | ||
match ls with | ||
| nil => nil | ||
| cons (a, module.Function b) ls => | ||
match resolver a with | ||
| Some a => cons (a,b) (functions ls) | ||
| None => functions ls | ||
end | ||
| cons _ ls => functions ls | ||
end) mod.(module.definitions). | ||
|
||
Definition module_definitions (g : globname) | ||
: func_meaning. | ||
refine (fun rely guarantee progress t mem args post => | ||
exists body, List.In (g, body) mod.(module.definitions) /\ | ||
match body with | ||
| module.Function body => | ||
exists n, | ||
WeakestPrecondition.func rely guarantee progress resolver | ||
(fun w t mem args post => | ||
exists g, resolver g = Some w /\ | ||
(List.In g mod.(module.imports) /\ | ||
denoteImports g rely guarantee progress t mem args post) | ||
\/ call_rec rely guarantee progress resolver | ||
functions n w t mem args post) | ||
body | ||
t mem args post | ||
| _ => False | ||
end). | ||
Defined. | ||
|
||
Definition module (g : globname) | ||
: func_meaning := | ||
fun rely guarantee progress t mem args post => | ||
List.In g mod.(module.exports) /\ | ||
module_definitions g rely guarantee progress t mem args post. | ||
|
||
End module_semantics. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like these
ExtLib
dependencies are not needed (but make the build fail)