| 1 |
------------------------------------------------------------------------ |
| 2 |
-- The Agda standard library |
| 3 |
-- |
| 4 |
-- An equality postulate which evaluates |
| 5 |
------------------------------------------------------------------------ |
| 6 |
|
| 7 |
{-# OPTIONS --with-K #-} |
| 8 |
|
| 9 |
module Relation.Binary.PropositionalEquality.TrustMe where |
| 10 |
|
| 11 |
open import Agda.Builtin.TrustMe using (primTrustMe) |
| 12 |
open import Relation.Binary.PropositionalEquality.Core using (_≡_; refl) |
| 13 |
|
| 14 |
-- trustMe {x = x} {y = y} evaluates to refl if x and y are |
| 15 |
-- definitionally equal. |
| 16 |
|
| 17 |
trustMe : ∀ {a} {A : Set a} {x y : A} → x ≡ y |
| 18 |
trustMe = primTrustMe |
| 19 |
|
| 20 |
-- "Erases" a proof. The original proof is not inspected. The |
| 21 |
-- resulting proof reduces to refl if the two sides are definitionally |
| 22 |
-- equal. Note that checking for definitional equality can be slow. |
| 23 |
|
| 24 |
erase : ∀ {a} {A : Set a} {x y : A} → x ≡ y → x ≡ y |
| 25 |
erase _ = trustMe |
| 26 |
|
| 27 |
-- A "postulate with a reduction": postulate[ a ↦ b ] a evaluates to b, |
| 28 |
-- while postulate[ a ↦ b ] a′ gets stuck if a′ is not definitionally |
| 29 |
-- equal to a. This can be used to define a postulate of type (x : A) → B x |
| 30 |
-- by only specifying the behaviour at B t for some t : A. Introduced in |
| 31 |
-- |
| 32 |
-- Alan Jeffrey, Univalence via Agda's primTrustMe again |
| 33 |
-- 23 January 2015 |
| 34 |
-- https://lists.chalmers.se/pipermail/agda/2015/007418.html |
| 35 |
|
| 36 |
postulate[_↦_] : ∀ {a b} {A : Set a}{B : A → Set b} → |
| 37 |
(t : A) → B t → (x : A) → B x |
| 38 |
postulate[ a ↦ b ] a′ with trustMe {x = a} {a′} |
| 39 |
postulate[ a ↦ b ] .a | refl = b |