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

User-defined rewrite rules #50

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
Prev Previous commit
Next Next commit
Add examples
TheoWinterhalter committed Dec 3, 2020

Verified

This commit was signed with the committer’s verified signature.
commit 2fd637acf093a716d4e354882691ef2543ec81ea
34 changes: 34 additions & 0 deletions text/xxx-rewrite-rules.md
Original file line number Diff line number Diff line change
@@ -123,6 +123,40 @@ with rules
J ?A ?x ?P ?p !{x} (@eq_refl !{A} !{x}) := p.
```

### Higher-inductive types

HoTT users might want to use rewrite rules to define HIT rather than use the
current notion of private inductive types.

```coq
Rewrite Block :=
S¹ : Type ;
base : S¹ ;
loop : base = base ;
elimS¹ : ∀ (P : S¹ → Type) (b : P base) (l : loop # b = b) x, P x ;
elimS¹ₗₒₒₚ : ∀ (P : S¹ → Type) (b : P base) (l : loop # b = b),
apD (elimS¹ P b l) loop = loop
with rules
elimS¹ ?P ?b ?l base := b.
```

### Quotients

We can also postulate quotients with a way to lift functions to the quotient.
This example also illustrates how we could combine this syntax with notations.

```coq
Rewrite Block :=
Quotient : ∀ A, (A → A → Prop) → Type ;
proj : A → A // R ;
quot : ∀ x y, R x y → proj x = proj y ;
rec : ∀ {A R B} (f : A → B), (∀ x y, R x y → f x = f y) → A // R → B
with rules
rec ?f ?q (proj ?x) := f x
where
"A // R" := (Quotient A R).
```

## Possible extensions

Coq [CEP#45]'s integration might make it possible to add rewrite rules to