TYPES ’19 in Oslo
Jesper Cockx, Théo Winterhalter and Nicolas Tabareau
14 June 2019
This talk may contain:
\[ \frac{\Gamma \vdash e : x =_A y}{\Gamma \vdash x \equiv y} \]
But when to apply this rule?
Rewrite rules to the rescue!
_+_ : Nat → Nat → Nat zero + n = n (suc m) + n = suc (m + n) +zero : m + 0 ≡ m +zero = ⋯ +suc : m + (suc n) ≡ suc (m + n) +suc = ⋯ {-# REWRITE +zero +suc #-} +-comm : (m n : Nat) → m + n ≡ n + m +-comm zero n = refl +-comm (suc m) n = cong suc (+-comm m n)
record Monoid (A : Set) : Set where field ∅ : A _·_ : A → A → A zero-l : ∅ · y ≡ y zero-r : x · ∅ ≡ x assoc : (x · y) · z ≡ x · (y · z) {-*# REWRITE zero-l assoc #-} -- (*) WIP module _ {A : Set} (m : Monoid A) where open Monoid m test₂ : ((x · ∅) · y) · (∅ · z) ≡ x · (y · z) test₂ = {!refl!}
postulate Exception : Set raise : {A : Set} → Exception → A raise-fun : ∀ e → raise {Π A B} e ≡ λ x → raise {B x} e {-# REWRITE raise-fun #-}
How? Use the options --rewriting
and --confluence-check
*
(*) Now available in Agda, soon also in Coq!
postulate max : Nat → Nat → Nat max-diag : max m m ≡ m max-assoc : max (max k l) m ≡ max k (max l m) {-# REWRITE max-diag max-assoc #-} -- ———— Errors ———————————————————————————————————————— -- Confluence check failed: max (max k l) (max k l) -- reduces to both max k (max l (max k l)) and max k l -- which are not equal because max l (max k l) != l of -- type Nat -- -- Confluence check failed: max (max k k) m reduces to -- both max k (max k m) and max k m which are not equal -- because max k m != m of type Nat
Confluence + no rewriting of type constructors give us the following guarantees:
With termination we regain decidable typechecking
MLTT
MLTT + equality reflection
MLTT + confluent rewrite rules