Repository navigation
Conversation
…easily, bit of cleanup, few notations for some toy examples
N.B. : TODO: switch the domain of value from Nat to Z to be able to write factorial and odd/even. |
This should be fine.
Partial maps might be better in both cases but we can have the effect actually raise the error so that errors don't show up in the implementation.
Either way. Dropping it or keeping it, as long as it is consistent shouldn't matter. Ultimately, it would be nice to have a language with a heap.
The other option is to give an effect transformer from Definition to_param {E} {Estate : StateE ~> E} {... } : ImpEff ~> E :=
fun _ e => match e with ... end.
|
|
|
||
| (* YZ: Ascii.ascii_of_nat is not what we want, unreadable *) | ||
| Definition gen_local (n: nat): string := | ||
| "local_" ++ (String (Ascii.ascii_of_nat n) ""). |
There was a problem hiding this comment.
ExtLib has a Show instance for nat.
| end. | ||
| End fmap_block. | ||
|
|
||
| (* CR essentially corresponds to an open (asm) program. |
There was a problem hiding this comment.
I was actually wondering if we should take this as the primitive representation of asm programs.
| To double check. | ||
| *) | ||
| Open Scope string_scope. | ||
| Fixpoint compileCR (s : stmt) {L} (k : block L) {struct s} : CR L. |
There was a problem hiding this comment.
All the re-associating in this definition has me wondering if we should define some new variant types for LocalOrImport and such.
| c_main is the current entry point. | ||
| *) | ||
| Record CR {imports : Type} : Type := | ||
| { c_label : Type (* Internal labels *) |
There was a problem hiding this comment.
The downside of this representation is that we can't really do anything interesting with it except for denote it since we can't inspect the c_label type. After we finish this, it might be better to switch labels to nat and make c_blocks be a finite map. This would allow us to implement transformations such as jump-tunneling, block merging, etc.
| let p3 := run_env _ p2 empty in | ||
| let p4 := run_env _ p3 empty in | ||
| p4. | ||
| Definition run (p: program) : itree emptyE (env * (memory * unit)) := |
There was a problem hiding this comment.
@Zdancewic personally, I like this way to write it better. It also has the benefit that type class resolution doesn't loop forever.
…ctually type check
|
Note that switching the representation of programs in Asm to the old definition of CR required to split their denotation in two, first to denote the program and then the main itself, since the latter is now a block and no longer a label. |
…t with SZ. Note: need to interpret away the state before proving eutt
…hrough the introduction of new admitted lemma
…ng easy lemmas is a good catharsis after this afternoon hard stuff
- Simplify several proofs directly using this new `eutt`.
Make default the more corecursive version of `eutt`.
|
Is the plan to hold this until the deadline? |
|
that sounds like a good plan! |
Change the def of "eutt"
Yannick and I wrote this compiler together. Yannick is working on cleaning up some of the definitions and we'll verify it. There are a few things left to do:
Some possible extensions:
break,continue, etc.This isn't ready to merge yet