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

ENH: parse and expand bound tuples #140

Merged
merged 12 commits into from
Dec 2, 2024
Merged

Commits on Nov 4, 2024

  1. API: change syntax tree to represent also tuply declarations

    and update the code throughout `tlapm`,
    because this commit changes the existing types in the
    module `Expr.T`.
    
    Signed-off-by: Ioannis Filippidis <[email protected]>
    johnyf committed Nov 4, 2024
    Configuration menu
    Copy the full SHA
    893431d View commit details
    Browse the repository at this point in the history
  2. BUG: do not allow unbounded declarations in function definitions

    The change in this commit corrects a bug with function
    definitions. Parsing of function definitions allowed using unbounded
    declarations (and also mixing bounded and unbounded declarations).
    For example, before this change, parsing allowed:
    
    ```tla
    f[x \in S, y] == TRUE
    ```
    
    and even:
    
    ```tla
    f[x] == TRUE
    ```
    
    These syntax errors are detected by SANY.
    In any case, this change ensures that `tlapm` does not parse
    such definitions.
    
    The error was due to calling the function `bounds` within the
    function `ophead`, instead of calling the function `boundeds`
    (which was called before commit
    5958dfa
    in order to handle function constructors within the function
    `atomic_expr`).
    
    This commit also adds tests for this bug.
    
    Signed-off-by: Ioannis Filippidis <[email protected]>
    johnyf committed Nov 4, 2024
    Configuration menu
    Copy the full SHA
    e09abe5 View commit details
    Browse the repository at this point in the history
  3. BUG: do not allow both bounded and unbounded declarations in \E, \A

    because TLA+ does not allow this kind of syntax.
    A single rigid quantifier can include either:
    - only unbounded declarations,
      for example `\E x, y, z:  ...`, or
    - only bounded declarations,
      for example `\A x \in A, y \in B, z \in C:  ...`.
    
    A single rigid quantifier cannot include both bounded and
    unbounded declarations.
    
    This syntax is caught by SANY.
    
    Signed-off-by: Ioannis Filippidis <[email protected]>
    johnyf committed Nov 4, 2024
    Configuration menu
    Copy the full SHA
    b4b68af View commit details
    Browse the repository at this point in the history
  4. TST: that function constructors allow only bounded declarations

    in other words, that the following expression is not allowed:
    
    ```tla
    [x \in S, y |-> TRUE]
    ```
    
    and the following expression is allowed:
    
    ```tla
    [x \in S, y \in S |-> TRUE]
    ```
    
    Also, add a reminder in a comment in the parser code.
    
    Signed-off-by: Ioannis Filippidis <[email protected]>
    johnyf committed Nov 4, 2024
    Configuration menu
    Copy the full SHA
    aee119e View commit details
    Browse the repository at this point in the history
  5. REF: cons during fold, and reverse upon completion

    instead of appending during the fold.
    This approach is more efficient.
    
    Also:
    
    - STY: blankspace formatting
    
    Signed-off-by: Ioannis Filippidis <[email protected]>
    johnyf committed Nov 4, 2024
    Configuration menu
    Copy the full SHA
    2c61f99 View commit details
    Browse the repository at this point in the history
  6. ENH: add class Module.deep_map

    Signed-off-by: Ioannis Filippidis <[email protected]>
    johnyf committed Nov 4, 2024
    Configuration menu
    Copy the full SHA
    371fd71 View commit details
    Browse the repository at this point in the history
  7. ENH: parse and expand tuply declarations

    ## ENH: tuply declarations
    
    This commit adds parsing and translation support for
    tuply declarations that appear in:
    - rigid quantification `\E ... here ...: ` and `\A ... here ...: `
    - choose expressions `CHOOSE ... here ...: `
    - set constructors
      `{... here ... \in ...:  ...}`
    - set constructors `{...:  ... here ...}`
    - function definitions `f[...here...] = ...`
    - function constructors `[... here ... |-> ...]`
    
    Commit 5958dfa introduced
    parsing of tuple declarations in function constructors,
    for example for expressions of the form:
    
    ```tla
    [<<x, y>> \in A \X B |-> x + y]
    ```
    
    This commit rewrites that functionality, and uses the
    new functionality to parse tuple declarations that can
    appear in function definitions, i.e., definitions of the form:
    
    ```tla
    f[<<x, y>> \in A \X B] == x + y
    ```
    
    The parsed tuply declarations are then transformed to either:
    
    - optimized expressions that are simplified and do not
      contain additional `CHOOSE` operators, in the presence of
      a syntactically-recognizable Cartesian product of
      suitable length, or
    
    - the expressions defined by TLA+ semantics (in most cases
      these expressions contain `CHOOSE`), otherwise.
    
    
    This commit also adds tests for the above functionality.
    
    
    ## BUG: correctly represent tuple declarations in function constructors
    
    In general, tuple declarations in function constructors
    are defined using `CHOOSE` with tuple declarations,
    which in turn is defined using unbounded `CHOOSE` and
    quantification.
    
    This was not how function constructors were implemented
    in commit 5958dfa.
    This commit corrects this error. The previous encoding
    is closer to what is currently done when a Cartesian
    product of the appropriate length is recognized in syntax.
    
    
    ## Tuplification
    
    This commit adds a translation of function constructor
    signatures that tuplifies comma-separated declarations,
    and fuses the domain-bounds of such declarations into
    a Cartesian product.
    
    The motivation for doing so is that it enables passing
    such functions (of tuples) to Isabelle and Zenon with
    the existing support that is available in those backends
    (for tuples and Cartesian products), and the proofs succeed.
    
    
    ## Other changes
    
    - DOC: update file `todo.txt`
    
    - ENH: add function `E_visit.name_operators` for
      converting syntax trees with positional operator
      references to syntax trees with operator
      references by name (i.e., conversion of `Ix` nodes
      to `Opaque` nodes).
    
    Signed-off-by: Ioannis Filippidis <[email protected]>
    johnyf committed Nov 4, 2024
    Configuration menu
    Copy the full SHA
    11ef1b0 View commit details
    Browse the repository at this point in the history

Commits on Nov 6, 2024

  1. TST: update parser tests for cases now parsed

    Signed-off-by: Ioannis Filippidis <[email protected]>
    johnyf committed Nov 6, 2024
    Configuration menu
    Copy the full SHA
    5aea669 View commit details
    Browse the repository at this point in the history
  2. MNT: add tuple-declaration cases to patterns

    Signed-off-by: Ioannis Filippidis <[email protected]>
    johnyf committed Nov 6, 2024
    Configuration menu
    Copy the full SHA
    303e7f8 View commit details
    Browse the repository at this point in the history

Commits on Nov 13, 2024

  1. MNT: apply changes from pull request review

    <tlaplus#140>
    
    Signed-off-by: Ioannis Filippidis <[email protected]>
    johnyf committed Nov 13, 2024
    Configuration menu
    Copy the full SHA
    3b69928 View commit details
    Browse the repository at this point in the history
  2. MNT: complete implementation of M_visit.deep_map

    Signed-off-by: Ioannis Filippidis <[email protected]>
    johnyf committed Nov 13, 2024
    Configuration menu
    Copy the full SHA
    e702c3f View commit details
    Browse the repository at this point in the history

Commits on Nov 27, 2024

  1. MNT: rm E_namespaces

    Signed-off-by: Ioannis Filippidis <[email protected]>
    johnyf committed Nov 27, 2024
    Configuration menu
    Copy the full SHA
    7af4592 View commit details
    Browse the repository at this point in the history