Debian Codegraph @

src/Data/List/Relation/Unary/Sorted/TotalOrder.agda

raw
1 ------------------------------------------------------------------------
2 -- The Agda standard library
3 --
4 -- Sorted lists
5 ------------------------------------------------------------------------
6
7 {-# OPTIONS --cubical-compatible --safe #-}
8
9 open import Relation.Binary.Bundles using (TotalOrder)
10
11 module Data.List.Relation.Unary.Sorted.TotalOrder
12 {a ℓ₁ ℓ₂} (totalOrder : TotalOrder a ℓ₁ ℓ₂) where
13
14 open TotalOrder totalOrder renaming (Carrier to A)
15
16 open import Data.List.Base using (List; []; _∷_)
17 open import Data.List.Relation.Unary.Linked as Linked using (Linked)
18 open import Level using (_⊔_)
19 open import Relation.Unary as U using (Pred; _⊆_)
20 open import Relation.Binary.Definitions as B
21
22 ------------------------------------------------------------------------
23 -- Definition
24
25 Sorted : Pred (List A) (a ⊔ ℓ₂)
26 Sorted xs = Linked _≤_ xs
27
28 ------------------------------------------------------------------------
29 -- Operations
30
31 module _ {x y xs} where
32
33 head : Sorted (x ∷ y ∷ xs) → x ≤ y
34 head = Linked.head
35
36 tail : Sorted (x ∷ xs) → Sorted xs
37 tail = Linked.tail
38
39 ------------------------------------------------------------------------
40 -- Properties of predicates preserved by Sorted
41
42 sorted? : B.Decidable _≤_ → U.Decidable Sorted
43 sorted? = Linked.linked?
44
45 irrelevant : B.Irrelevant _≤_ → U.Irrelevant Sorted
46 irrelevant = Linked.irrelevant
47
48 satisfiable : U.Satisfiable Sorted
49 satisfiable = Linked.satisfiable