Debian Codegraph @

src/Relation/Nullary/Recomputable/Core.agda

raw
1 ------------------------------------------------------------------------
2 -- The Agda standard library
3 --
4 -- Recomputable types and their algebra as Harrop formulas
5 ------------------------------------------------------------------------
6
7 {-# OPTIONS --cubical-compatible --safe #-}
8
9 module Relation.Nullary.Recomputable.Core where
10
11 open import Agda.Builtin.Equality using (_≡_; refl)
12 open import Level using (Level)
13 open import Relation.Nullary.Irrelevant using (Irrelevant)
14
15 private
16 variable
17 a : Level
18 A : Set a
19
20
21 ------------------------------------------------------------------------
22 -- Definition
23 --
24 -- The idea of being 'recomputable' is that, given an *irrelevant* proof
25 -- of a proposition `A` (signalled by being a value of type `.A`, all of
26 -- whose inhabitants are identified up to definitional equality, and hence
27 -- do *not* admit pattern-matching), one may 'promote' such a value to a
28 -- 'genuine' value of `A`, available for subsequent eg. pattern-matching.
29
30 Recomputable : (A : Set a) → Set a
31 Recomputable A = .A → A
32
33 ------------------------------------------------------------------------
34 -- Fundamental properties:
35 -- given `Recomputable A`, `recompute` is a constant function;
36 -- moreover, the identity, if `A` is propositionally irrelevant.
37
38 module _ (recompute : Recomputable A) where
39
40 recompute-constant : (p q : A) → recompute p ≡ recompute q
41 recompute-constant _ _ = refl
42
43 recompute-irrelevant-id : Irrelevant A → (a : A) → recompute a ≡ a
44 recompute-irrelevant-id irr a = irr (recompute a) a
45