Recursive Types
Recap for Product/Sum TypesPermalink
Brief recap for product and sum to have a consensus on notations.
Product TypesPermalink
IntroductionsPermalink
EliminationsPermalink
Sum TypesPermalink
IntroductionPermalink
EliminationsPermalink
UnitPermalink
Recursive Types in a Partial LanguagePermalink
ExamplesPermalink
Natural NumbersPermalink
We can write
where means “type isomorphism” which means to write functions back and forth that compose to the identity.
From left to right:
From right to left:
It works because anything is observationally equivalent to at type :
ListsPermalink
Any list is either the empty list or a cons with the type and another list.
From left to right:
ConstructionPermalink
What we’ve got here is that: certain types can be characterize as solutions to equations of the form:
solves
solves
which is a/the solution to . i.e.
IntroductionsPermalink
EliminationsPermalink
DynamicsPermalink
Examples using Recursive TypesPermalink
Bridging Recursive Types and ProgramsPermalink
In this language, even though there is no loops, no recursive functions in the terms, we can still get general recursion just from self-referencial types. Meaning that self-referential types will give us self-referential codes. How to do?
- Define a type of self-referential programs, and get from it
- Define the type of self-referential programs from
Self TypesPermalink
The following thing is only used as a bridge between and such that we can define both and from it. It’s only to help the constructions.
In the following rules, could be interpreted as this
in a normal programming language.
represents a self-referential computation of a
IntroductionsPermalink
EliminationsPermalink
DynamicsPermalink
Construct Recursive ProgramsPermalink
Now we have , the above two steps can be rephrased as:
- We want to get a recursive computation of any type, i.e. , from self types
- We want to get self types from recursive types
From Recursive Computation to Self TypesPermalink
We have , and we want:
Solution:
From Self Types to Recursive TypesPermalink
We want to solve:
Solution:
Comments