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

inhType #10

Open
2 of 5 tasks
eupp opened this issue Oct 21, 2020 · 5 comments
Open
2 of 5 tasks

inhType #10

eupp opened this issue Oct 21, 2020 · 5 comments
Assignees
Labels
enhancement New feature or request

Comments

@eupp
Copy link
Collaborator

eupp commented Oct 21, 2020

Define inhType structure for inhabited type with one selected element.

  • inhType structure and some canonical instances (e.g. for nat, option, list)
  • ext function that extends function defined on subtype to whole inhabited type
    • ext defined for ordinals
    • ext defined for arbitary subType
  • make ext as coercion
@eupp eupp added the enhancement New feature or request label Oct 21, 2020
@eupp eupp reopened this Nov 12, 2020
@eupp
Copy link
Collaborator Author

eupp commented Nov 12, 2020

We haven't finished with this, so it's too early to close the issue.
First, in inhType.v I cannot find any common canonical instances. I assume we might need at least instances for nat, option and list.
Second, ext function is still in an intermediate state. We need to try make it work as coercion, and also generalize it to subType.

@anton-trunov
Copy link
Collaborator

I would actually propose to remove inhType altogether. Here are some considerations:

  • the current implementation does not allow introducing different "default" elements for the same type (e.g. this is done using displays for orders);
  • it's only used now in regmachine.v and nowhere else and it's easy to refactor that file and use a default element of an arbitrary type. Here is the diff
    -Context {val : inhType} {disp} {E : identType disp}.
    +Context {val : eqType} {inh : val} {disp} {E : identType disp}.
    

This way one can use any default element on-the-fly without going through the hassle of using more displays and creating different canonical instances. This approach (called unbundled in the literature) is used in Mathcomp as well, e.g. path or functions with default elements on sequences.

@anton-trunov
Copy link
Collaborator

anton-trunov commented Dec 30, 2020

Here is a branch with inhType removed, just to see the exact changes required:
https://github.com/volodeyka/event-struct/compare/inhtype-removal
(maybe inh could be renamed into something else)

@eupp
Copy link
Collaborator Author

eupp commented Jan 4, 2021

I would actually propose to remove inhType altogether. Here are some considerations:

* the current implementation does not allow introducing different "default" elements for the same type (e.g. this is done using _displays_ for orders);

* it's only used now in `regmachine.v` and nowhere else and it's easy to refactor that file and use a default element of an arbitrary type. Here is the diff
  ```
  -Context {val : inhType} {disp} {E : identType disp}.
  +Context {val : eqType} {inh : val} {disp} {E : identType disp}.
  ```

This way one can use any default element on-the-fly without going through the hassle of using more displays and creating different canonical instances. This approach (called unbundled in the literature) is used in Mathcomp as well, e.g. path or functions with default elements on sequences.

Indeed, we can consider the option of removing inhType.

Originally, the plan was to use it in combination with ext (extension) function.
The idea is that we can extend the "partially" defined function, that is a function defined on some subType (e.g. ordinal of size n) to the whole type (e.g. nat) by mapping all elements outside of the subtype to the default element. With inhType we could have picked the default canonical value automatically.
An example is that we can lift the predicate from subType to the whole type by assigning false to every element outside of the subtype.

We do not use ordinals to encode events anymore, so this functionality is not needed now.
If we assume that we will not need something similar in the future, we can remove the inhType.

@eupp
Copy link
Collaborator Author

eupp commented Oct 15, 2021

There is also pointedType in math-comp/analysis library.

https://github.com/math-comp/analysis/blob/6c627b3ee367665fd5b55097451ef4131a918bb4/theories/classical_sets.v#L971

Maybe we can ask to move it to the main mathcomp repo?

cc @anton-trunov

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants