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

Reusable definitions #3

Open
ydewit opened this issue Nov 10, 2023 · 1 comment
Open

Reusable definitions #3

ydewit opened this issue Nov 10, 2023 · 1 comment

Comments

@ydewit
Copy link
Owner

ydewit commented Nov 10, 2023

Currently, in the classical implementation of Interaction Nets, there is no streamlined method to reuse smaller net structures. This limitation often results in repetitive copy-pasting of the same definitions, leading to inefficiencies and potential errors.

Proposed Solutions:

  • Textual Representation with Named Definitions:
    Introduce a method to define nets by name in the textual representation of the nets.
    The parser could then expand these named definitions into the final, larger net.
    Concern: This approach might lead to significant memory usage, as the expanded net would occupy memory until runtime reduction occurs.

  • Runtime Representation Enhancement:
    Extend the runtime representation of nets to include references to definitions.
    Implement a mechanism where the expansion of these definitions occurs dynamically during net reduction.
    Advantage: This could allow for unrolling definitions incrementally, one at a time, thereby distributing the memory and processing overhead more evenly.
    Goal: To achieve a balance between reusability and efficiency, minimizing memory waste and optimizing performance.

@ydewit
Copy link
Owner Author

ydewit commented Nov 12, 2023

Additional Considerations for Reusable Definitions:

  • Naming and Structure: Definitions should be named and structured like any other net, capable of having multiple non-principal ports.
  • Evaluation and Normalization: Definitions should be regular nets that can be evaluated to a normal form. There should be support for normalizing definitions both within a single definition and across multiple definitions, possibly leading to optimized, collapsed definitions.
  • Representation of Variables: The representation of variables in definitions needs to be distinct since they do not exist in the store/heap. A simple representation could be a sequence of natural numbers starting from zero (the principal port). These 'vars-to-be' might be instantiated during evaluation or remain unconnected, depending on how they interact with cells during evaluation.
    -Efficient de-referencing: de-referencing a reference to a definition should take into account the other side of the redex. In other words, the definition and the other side of the redex will be evaluated layer by layer until there is nothing to more to do, which is when a var will be allocated.
  • Top-level net is definition: a definition is not a separate structure in a net, but every net is a definition. It just so happens that one of the definitions is special, named main.

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

No branches or pull requests

1 participant