-
Notifications
You must be signed in to change notification settings - Fork 0
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
Slicing rules for desugaring #41
Comments
@min-nguyen Here’s the sketch from earlier that shows the type of the relation, the form of the judgement, an example rule and the Galois connection that we’ll derive from it. Once you’ve completed the final tidy-up of explorable-viz/fluid#300, we can have a chat about how to get started with formalising desugaring. |
@min-nguyen If you’re happy getting started with this over the next couple of days, a concrete suggestion would be to sketch out a definition of the “desugars to” relation (written |
@min-nguyen See below. I recommend using GitHub branches when working with the formalism – knowing you’re on a branch should allow you to feel more relaxed about making changes! Feel free to ping me about macros or any other LaTeX questions. |
@min-nguyen Notes on desugaring rules that want to reuse the surface language: And on “totalising” an eliminator with a default continuation, needed for the desugaring of partial generators (and which we can also use to add catch-all |
@min-nguyen We sketched the form of the relation, but I don’t think we discussed any specific rules. Something I mentioned last time: we may not need a trace after all for desugaring. Instead we can probably use the original (unsugared) expression, which contains enough information to run the computation backward. (You can actually take this approach with evaluation as well, at least for a deterministic language, but it becomes prohibitively expensive. IIRC, you end up having to do a lot of evaluation during backwards slicing – in fact more than you would do just executing the program once.) So, in the upper part of the diagram above, I’ve given a rule from the desugaring relation. Underneath is the corresponding backward slicing rule. The basic idea behind the bwd rules is to push the annotations on “core” language constructors back onto “surface” language constructors. For now you can just have an intuitive stab at this; when we come to define fwd slicing, we’ll need to make sure (and eventually prove) that the bwd propagation of annotations is sound w.r.t. fwd propagation, and vice versa. Don’t worry about this too much for now. I think it will be useful here (and in the core language) to distinguish expressions which are unannotated all the way down (where the type of the annotations is With that in mind, I’m abusing metavariables a bit here: on the left of the bwd arrow, we should probably think of s as ranging over |
@min-nguyen Ok, I’ve updated the implementation along the lines of what I proposed yesterday. There is now a type class The old I’ve parameterised the I’ve also generalised the |
@min-nguyen Nib was loose on my pencil 🤦 . Thinking some more, having So, in the formalism I think we can say the annotation type is (meta-)unit if it is convenient to do so, but in the implementation we will for now assume it’s always Boolean, even if sometimes we don’t care. |
@min-nguyen Ok, I’ve had a chance to look over what you’ve done. This is looking good – you’ve really made progress. We’ve still a fair way to go to reach the point we need to get to, but that’s not a reflection on what you’ve done, just the normal process of iterating over something until it converges. I have lots of minor suggestions, and a couple of other thoughts that we might need to discuss. If you could aim to process these changes by Friday then we can talk about other things.
The Finally, there’s some thinking to do about annotation-propagation in the slicing rules. The slicing rules we’ve given elsewhere don’t uniformly assume expressions have annotations on them (although the implementation does), but they do propagate annotations on data constructors and constants. We’ll need to do something similar for desugaring. But I think it’s fine to get the structure of the rules right first, and then think about the annotations. |
@min-nguyen Changes from today’s discussion:
Then we’ll be in a position to enrich Fig. 24 to specify how the annotations on an e are converted back into annotations on a t. |
@min-nguyen I’m thinking we should aim for ICFP next year (deadline ~Feb). I’ll email separately about that. First some thoughts on how to move forward with the desugaring formalisation and implementation. These need to be tied together as we move forward and you should be in the driving seat for both, with my guidance. A couple of high-level points, now that things are a bit clearer. First, I think we should treat eliminators as core language only — very similar to the way Haskell pattern-matching compiles to case trees. We already have some of this in place as we had introduce a pattern syntax for list comprehensions and a way of “totalising” these into eliminators. What I propose we do further is allow functions to be defined “equationally”, i.e. as lists of equations with patterns on the LHS. These equations should be turned into an eliminator by merging their patterns. This operation is only partial; if it fails the equations are ill-formed, e.g. because they try to merge constructors from distinct data types. The implementation does this already, so this is just a question of formalising this aspect of the implementation. The upside is that we will have a clean separation of concerns between the surface language (which uses more familiar pattern syntax) and core language (which uses eliminators), and a small but useful contribution of the paper will be to show how Galois slicing works in that setting. The other point concerns list notation (let’s use this term to mean notation like The key observation about list notation is that I think we need to be syntactically explicit about the implied The “list rest” metavariable is the letter ell. I’ve left the typing and evaluation rules for ell for you to do (they’re straightforward). Hopefully this makes some kind of sense; if the rationale for doing things this way isn’t quite clear yet, hopefully it will become so once you start writing down the rules that propagate annotations between the two notations. (Returning to the aside above: if we were to rename I’ll create a new issue for the “equational definitions” desugaring, and create a list of todo’s for list notation and other minor tweaks, this afternoon. (I’m tied up now until about 3pm.) |
@min-nguyen Todo’s relating to list notation and other minor comments:
|
@min-nguyen New to do list (migating 2 remaining tasks from last week):
|
@min-nguyen Adding some todo’s for today’s chat:
If would be great if you could deal with these and make a start on #51 by next Friday. We can also start talking about/defining the lattices induced by the α᾽s, which we’ll need for the Galois connection. |
@min-nguyen Pic from today:
You should be able to have a go at finishing explorable-viz/fluid#115 as well (including migrating any examples of |
@min-nguyen Here you go. Page 12 is a little bit blurry but there’s very little on that page anyway. |
@min-nguyen I think we can consider this task done. Well done, more of a slog than expected, but worth it! |
For explorable-viz/fluid#278 and explorable-viz/fluid#277 we need syntax sugar. Slicing needs to be defined for desugaring.
prove that desugar_fwd and desugar_bwd form a Galois connection– see Desugaring Galois connection #52The text was updated successfully, but these errors were encountered: