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

Add a dynamic cast in Typing #223

Closed
konnov opened this issue Sep 22, 2020 · 0 comments
Closed

Add a dynamic cast in Typing #223

konnov opened this issue Sep 22, 2020 · 0 comments
Assignees
Labels
Alpha Centauri The first public alpha release FTC-Snowcat Feature: Fully-functional type checker Snowcat new New issue to be triaged.

Comments

@konnov
Copy link
Collaborator

konnov commented Sep 22, 2020

There is at least one idiom that cannot be solved by the type system. Sometimes, a function Int -> Int can be transformed into a sequence. For instance, here is the piece of code from Queens:

IsSolution(queens) ==
  \A i \in 1 .. Len(queens)-1 : \A j \in i+1 .. Len(queens) : 
       ~ Attacks(queens,i,j)

Solutions == { queens \in [1..N -> 1..N] : IsSolution(queens) }

The operator IsSolution needs a sequence, whereas the operator Solutions produces a set of functions from integers to integers. This is not an issue in the untyped semantics of TLA+. However, I do not see a way for a sound transformation of a function into a sequence without an additional test in runtime (e.g., when doing model checking).

We should introduce an operator that allows the user to perform such a transformation in "runtime". In this case, the operator would be called like follows:

Solutions == { queens \in [1..N -> 1..N] : IsSolution(DynCast(queens, "Seq(Int)")) }

Both the type checker and type inferer should check, whether the transformation makes sense, e.g., Int should not be transformed into Set(Int). A concrete implementation of the casting will be left to the implementation,
e.g., the model checker.

@konnov konnov added the new New issue to be triaged. label Sep 22, 2020
@konnov konnov added this to the v0.9.0-tool-tlatypes milestone Sep 22, 2020
@konnov konnov modified the milestones: v0.10.0-tool-typeinfer, v0.9.0-tool-typecheck Sep 23, 2020
@konnov konnov added the FTC-Snowcat Feature: Fully-functional type checker Snowcat label Dec 6, 2020
@konnov konnov modified the milestones: v0.9.0-tool-typecheck, backlog2021 Dec 11, 2020
@konnov konnov modified the milestones: backlog2021, January iteration Jan 4, 2021
@konnov konnov added the Alpha Centauri The first public alpha release label Feb 5, 2021
@konnov konnov closed this as completed in 04f8493 Feb 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Alpha Centauri The first public alpha release FTC-Snowcat Feature: Fully-functional type checker Snowcat new New issue to be triaged.
Projects
None yet
Development

No branches or pull requests

3 participants