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

[FEATURE] Modify operator inlining for carrying types #224

Closed
konnov opened this issue Sep 23, 2020 · 3 comments
Closed

[FEATURE] Modify operator inlining for carrying types #224

konnov opened this issue Sep 23, 2020 · 3 comments
Assignees
Labels
FTC-Snowcat Feature: Fully-functional type checker Snowcat new New issue to be triaged.

Comments

@konnov
Copy link
Collaborator

konnov commented Sep 23, 2020

Consider the following example:

A(x, y) == x + y

B(x) == A(x, 1) * A(1, y)

The current version of Inliner replaces A in be as follows:

B(x) == (x + 1) * (1 + y)

The new type checker and type inferer give us types before preprocessing. The most important part of the type information is the types of declarations: variable declarations, constant declarations, and operators declarations, including LET-definitions. To be able to carry this type information, we have to modify the inliner in a way that it implicitly introduces constant LET-definitions for the parameters and the result at the call sites:

B(x) ==
  LET A_result1 ==
    LET A_x1 == x IN
    LET A_y1 == 1 IN
    A_x1 + A_y1
  IN
  LET A_result2 ==
    LET A_x2 == x IN
    LET A_y2 == 1 IN
    A_x2 + A_y2
  IN
  A_result1 * A_result2

By doing so, we can define the types of the auxiliary definititions such as A_result1, A_x1, A_y1, ... These types are easily computed from the type contexts that are produced by the type checker. When we have this form, we can apply our usual preprocessing transformations and then re-run the type checker. The types of the auxiliary variables will contain enough information for finding the types of the inlined operator bodies.

@konnov konnov added the new New issue to be triaged. label Sep 23, 2020
@konnov konnov added this to the v0.9.0-tool-tlatypes milestone Sep 23, 2020
@konnov konnov modified the milestones: v0.10.0-tool-typeinfer, v0.11.0-types-in-model-checker Sep 23, 2020
@konnov
Copy link
Collaborator Author

konnov commented Oct 14, 2020

As Jure @Kukovec noticed, this format is very similar to a stack machine. It looks like we are moving towards a particular TLA+ structure in our intermediate representation.

@konnov
Copy link
Collaborator Author

konnov commented Nov 10, 2020

Maybe we need the form:

B(x) ==
  LET A_result1 ==
    LET A_x1 == x IN
    LET A_y1 == 1 IN
    A(x1, y1)
  IN
  LET A_result2 ==
    LET A_x2 == x IN
    LET A_y2 == 1 IN
    A(x2, y2)
  IN
  A_result1 * A_result2

@konnov konnov added the FTC-Snowcat Feature: Fully-functional type checker Snowcat label Dec 6, 2020
@Kukovec
Copy link
Collaborator

Kukovec commented Dec 7, 2020

Closed in #344.

@Kukovec Kukovec closed this as completed Dec 7, 2020
@konnov konnov added this to the backlog2020 milestone Dec 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FTC-Snowcat Feature: Fully-functional type checker Snowcat new New issue to be triaged.
Projects
None yet
Development

No branches or pull requests

2 participants