Debian Codegraph @

src/Relation/Nullary/Recomputable.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 where
10
11 open import Data.Empty using (⊥)
12 open import Data.Irrelevant using (Irrelevant; irrelevant; [_])
13 open import Data.Product.Base using (_×_; _,_; proj₁; proj₂)
14 open import Level using (Level)
15 open import Relation.Nullary.Negation.Core using (¬_)
16
17 private
18 variable
19 a b : Level
20 A : Set a
21 B : Set b
22
23 ------------------------------------------------------------------------
24 -- Re-export
25
26 open import Relation.Nullary.Recomputable.Core public
27
28
29 ------------------------------------------------------------------------
30 -- Constructions
31
32 -- Irrelevant types are Recomputable
33
34 irrelevant-recompute : Recomputable (Irrelevant A)
35 irrelevant (irrelevant-recompute [ a ]) = a
36
37 -- Corollary: so too is ⊥
38
39 ⊥-recompute : Recomputable ⊥
40 ⊥-recompute = irrelevant-recompute
41
42 _×-recompute_ : Recomputable A → Recomputable B → Recomputable (A × B)
43 (rA ×-recompute rB) p = rA (p .proj₁) , rB (p .proj₂)
44
45 _→-recompute_ : (A : Set a) → Recomputable B → Recomputable (A → B)
46 (A →-recompute rB) f a = rB (f a)
47
48 Π-recompute : (B : A → Set b) → (∀ x → Recomputable (B x)) → Recomputable (∀ x → B x)
49 Π-recompute B rB f a = rB a (f a)
50
51 ∀-recompute : (B : A → Set b) → (∀ {x} → Recomputable (B x)) → Recomputable (∀ {x} → B x)
52 ∀-recompute B rB f = rB f
53
54 -- Corollary: negations are Recomputable
55
56 ¬-recompute : Recomputable (¬ A)
57 ¬-recompute {A = A} = A →-recompute ⊥-recompute
58