Debian Codegraph @

src/Codata/Musical/Colist/Relation/Unary/Any.agda

raw
1 ------------------------------------------------------------------------
2 -- The Agda standard library
3 --
4 -- Coinductive lists where at least one element satisfies a predicate
5 ------------------------------------------------------------------------
6
7 {-# OPTIONS --cubical-compatible --guardedness #-}
8
9 module Codata.Musical.Colist.Relation.Unary.Any where
10
11 open import Codata.Musical.Colist.Base
12 open import Codata.Musical.Notation using (♭)
13 open import Data.Nat.Base using (ℕ; zero; suc)
14 open import Function.Base using (_∋_)
15 open import Level using (Level; _⊔_)
16 open import Relation.Binary.PropositionalEquality.Core using (_≡_; refl)
17 open import Relation.Unary using (Pred)
18
19 private
20 variable
21 a b p : Level
22 A : Set a
23 B : Set b
24 P : Pred A p
25
26 data Any {A : Set a} (P : Pred A p) : Pred (Colist A) (a ⊔ p) where
27 here : ∀ {x xs} (px : P x) → Any P (x ∷ xs)
28 there : ∀ {x xs} (pxs : Any P (♭ xs)) → Any P (x ∷ xs)
29
30 index : ∀ {xs} → Any P xs → ℕ
31 index (here px) = zero
32 index (there p) = suc (index p)