https://github.com/ziman/itt-idris
ITT: quantified dependent calculus with inference of all modalities, implemented in Idris 2
https://github.com/ziman/itt-idris
Last synced: 4 months ago
JSON representation
ITT: quantified dependent calculus with inference of all modalities, implemented in Idris 2
- Host: GitHub
- URL: https://github.com/ziman/itt-idris
- Owner: ziman
- Created: 2019-03-07T11:10:16.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2024-12-05T21:04:18.000Z (over 1 year ago)
- Last Synced: 2025-02-01T09:13:31.824Z (over 1 year ago)
- Language: Idris
- Homepage:
- Size: 618 KB
- Stars: 23
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ITT
ITT infers quantity/erasure annotations from pattern matching dependent programs.
ITT supports the following modalities:
* **I** (irrelevance) -- erased at runtime, disregarded in conversion checks
* **E** (erased) -- erased at runtime, subject to conversion checks
* **L** (linear) -- present at runtime, linear
* **R** (unrestricted) -- present at runtime, unrestricted
ITT can infer all of them by interleaving type checking and constraint solving
using an external solver.
The inference algorithm does not need any modality annotations to work.
However, any "primitives" you postulate have no bodies
so the minimal consistent annotation is "everything is irrelevant".
You'll probably want to override this to give more meaning to your primitives.
You can look at [one of the example programs](https://github.com/ziman/itt-idris/blob/master/examples/simple.itt)
and [its output](https://github.com/ziman/itt-idris/blob/master/examples/simple.out).
Here's a [vector length program](https://github.com/ziman/itt-idris/blob/master/examples/vect.itt)
and [its output](https://github.com/ziman/itt-idris/blob/master/examples/vect.out).
## Making it easier
Inference gets easier if you don't need to support all modalities.
* **I** requires interleaving conversion checking and constraint solving,
iteratively, until you reach a fixed point where no new conversions arise.
* **L** requires counting constraints, which interferes with evar equalities.
Namely, you can no longer express equality `p ~ q` as `(p -> q) /\ (q -> p)`.
I use an external SMT solver to get it done.
If you leave out either of the two, you get an easier problem to solve
when inferring annotations.
## Usage
```
$ ./itt examples/simple.itt
```
(Will automatically build if out of date.)