Debian Codegraph @

src/Data/Vec/Relation/Unary/Unique/Propositional/Properties.agda

raw
1 ------------------------------------------------------------------------
2 -- The Agda standard library
3 --
4 -- Properties of unique vectors (setoid equality)
5 ------------------------------------------------------------------------
6
7 {-# OPTIONS --cubical-compatible --safe #-}
8
9 module Data.Vec.Relation.Unary.Unique.Propositional.Properties where
10
11 open import Data.Vec.Base using (Vec; map; take; drop; tabulate; lookup)
12 open import Data.Vec.Relation.Unary.All as All using (All; []; _∷_)
13 open import Data.Vec.Relation.Unary.AllPairs as AllPairs using (AllPairs)
14 open import Data.Vec.Relation.Unary.Unique.Propositional using (Unique)
15 import Data.Vec.Relation.Unary.Unique.Setoid.Properties as Setoid
16 open import Data.Fin.Base using (Fin)
17 open import Data.Nat.Base using (_+_)
18 open import Data.Nat.Properties using (<⇒≢)
19 open import Data.Product.Base using (_×_; _,_)
20 open import Data.Product.Relation.Binary.Pointwise.NonDependent using (≡⇒≡×≡)
21 open import Function.Base using (id; _∘_)
22 open import Level using (Level)
23 open import Relation.Binary.Core using (Rel)
24 open import Relation.Binary.Bundles using (Setoid)
25 open import Relation.Binary.PropositionalEquality.Core
26 using (refl; _≡_; _≢_; sym)
27 open import Relation.Binary.PropositionalEquality.Properties using (setoid)
28 open import Relation.Unary using (Pred; Decidable)
29 open import Relation.Nullary.Negation.Core using (¬_)
30
31 private
32 variable
33 a b c p : Level
34
35 ------------------------------------------------------------------------
36 -- Introduction (⁺) and elimination (⁻) rules for list operations
37 ------------------------------------------------------------------------
38 -- map
39
40 module _ {A : Set a} {B : Set b} where
41
42 map⁺ : ∀ {f} → (∀ {x y} → f x ≡ f y → x ≡ y) →
43 ∀ {n} {xs : Vec A n} → Unique xs → Unique (map f xs)
44 map⁺ = Setoid.map⁺ (setoid A) (setoid B)
45
46 ------------------------------------------------------------------------
47 -- take & drop
48
49 module _ {A : Set a} where
50
51 drop⁺ : ∀ {n} m {xs : Vec A (m + n)} → Unique xs → Unique (drop m xs)
52 drop⁺ = Setoid.drop⁺ (setoid A)
53
54 take⁺ : ∀ {n} m {xs : Vec A (m + n)} → Unique xs → Unique (take m xs)
55 take⁺ = Setoid.take⁺ (setoid A)
56
57 ------------------------------------------------------------------------
58 -- tabulate
59
60 module _ {A : Set a} where
61
62 tabulate⁺ : ∀ {n} {f : Fin n → A} → (∀ {i j} → f i ≡ f j → i ≡ j) → Unique (tabulate f)
63 tabulate⁺ = Setoid.tabulate⁺ (setoid A)
64
65 ------------------------------------------------------------------------
66 -- lookup
67
68 module _ {A : Set a} where
69
70 lookup-injective : ∀ {n} {xs : Vec A n} → Unique xs → ∀ i j → lookup xs i ≡ lookup xs j → i ≡ j
71 lookup-injective = Setoid.lookup-injective (setoid A)