The "nominal_datatype" API (preliminary work)#1908
Merged
mn200 merged 2 commits intoHOL-Theorem-Prover:developfrom Apr 18, 2026
Merged
The "nominal_datatype" API (preliminary work)#1908mn200 merged 2 commits intoHOL-Theorem-Prover:developfrom
mn200 merged 2 commits intoHOL-Theorem-Prover:developfrom
Conversation
Member
|
Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi,
This is a preliminary work (first step) of establishing a user-friendly API for creating nominal datatypes. Currently it's not easy to create them - a lot of boilerplate code must be written. Now I added a function
nominal_datatype(innomdatatype) to automate the initial part of this process. Let me first introduce the API.For the type
term(of λ-calculus), now user can use the following call to create a nominal typetermrepresenting λ-terms with constructorsVAR,APPandLAM:Note that the special type variables
'freeand'boundto denote free and bound names used in the related constructors. Other type variables and parameterized types are considered external types. The above call currently returns 3 values (and aDatatypecall happens inside):tynamesis a list of names of the nominal types being created. The value is["term"]in this case.rep_tis the intermediate representation type, whose value is:term_repcode, defined automatically bylpis a long term holding information about the number of free and bounded names and recursive arguments:That's all it currently can do. Perhaps it's not very impressive for the type
term. But for the two nominal terms of π-calculus, we can do the following now: (NOTE: settingrepcodewill forcely set the type name of the representation type, otherwise it'spi_repcodeby default.)And this will give us the following correct
lpterm, which previously must be written manually:Note that, I have reused the input syntax of the existing
Datatypepackage, and for labelled term there's no way to distinguish between free and bound parameters:which gives the following
lp:Note that
LAMi num 'bound lterm ltermactually means(LAMi num 'bound lterm) lterm, where the firstltermis bounded by the name, while the second is not. And that's why the last line oflphastns = [0] /\ uns = [0], i.e. one parameter is free, the other is bound.The current rule (to interprete the input quotation) is the following: if the type variable
'boundoccurs in a constructor, then the immediately followed nominal type parameter is bounded, while other nominal parameters are considered free. This avoids designing new syntax of the input quotation for now and works for all existing use cases.--Chun