Skip to content
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

Il-to-Il: General otherwise elimination [archival branch] #17

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

nomeata
Copy link

@nomeata nomeata commented May 3, 2023

This is an IL pass that eliminates general uses of otherwise; general in the sense that it can handle overlapping LHS like

relation Step: expr -> expr

rule Step_is_null1:
  (is_null 0) -> True
rule Step_is_null2:
  (is_null n) -> False
  -- otherwise

or rules referring to predicates:

relation Even : Even expr
rule Even_0:
  Even 0
rule Even_SS:
  Even (S (S n))
  -- Even n

rule Step_is_even1:
  (is_even n) -> True
  -- Even n
rule Step_is_even2:
  (is_even n) -> False
  -- otherwise

It uses the apartness check (#16) to clean up the generated rules a bit. It could do more systematic clean up to introduce negated boolean premises in the restricted case, but doesn’t do this yet.

This PR is not for merging, but merely for archival reasons, as Andreas says we actively don’t want to support otherwise in the general form, and don’t want the necessary IL changes (a general form of negated premise).

Instead, I understand he envisions a check in the IL checker to enforce the necessary invariants (“all rules before otherwise have either syntactically equal or obviously apart LHS, and those that have equal LHS only have boolean premises”), and then a IL-to-IL pass that handles precisely those cases.

@nomeata
Copy link
Author

nomeata commented May 11, 2023

So, is it worth reviving this approach?

rossberg added a commit that referenced this pull request Jul 3, 2024
* [interpreter] Handle custom sections and annotations

Co-authored-by: Yuri Iozzelli <[email protected]>

* Fix merge conflict

* Fix lexer priorities

* Fix wast.ml

* Oops

* Update wast.ml

---------

Co-authored-by: Andreas Rossberg <[email protected]>
rossberg added a commit that referenced this pull request Jul 3, 2024
* [interpreter] Handle custom sections and annotations

Co-authored-by: Yuri Iozzelli <[email protected]>

* Fix merge conflict

* Fix lexer priorities

* Fix wast.ml

* Oops

* Update wast.ml

---------

Co-authored-by: Andreas Rossberg <[email protected]>
Alan-Liang pushed a commit to Alan-Liang/spectec that referenced this pull request Sep 2, 2024
Revised and renamed to switching fibers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant