forked from agda/agda-stdlib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCore.agda
45 lines (32 loc) · 1.37 KB
/
Core.agda
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
------------------------------------------------------------------------
-- The Agda standard library
--
-- Indexed containers core
------------------------------------------------------------------------
{-# OPTIONS --cubical-compatible --safe #-}
module Data.Container.Indexed.Core where
open import Level
open import Data.Product.Base using (Σ; Σ-syntax; _,_; ∃)
open import Relation.Unary
infix 5 _◃_/_
record Container {i o} (I : Set i) (O : Set o) (c r : Level) :
Set (i ⊔ o ⊔ suc c ⊔ suc r) where
constructor _◃_/_
field
Command : (o : O) → Set c
Response : ∀ {o} → Command o → Set r
next : ∀ {o} (c : Command o) → Response c → I
-- The semantics ("extension") of an indexed container.
⟦_⟧ : ∀ {i o c r ℓ} {I : Set i} {O : Set o} → Container I O c r →
Pred I ℓ → Pred O _
⟦ C ◃ R / n ⟧ X o = Σ[ c ∈ C o ] ((r : R c) → X (n c r))
------------------------------------------------------------------------
-- All and any
module _ {i o c r ℓ} {I : Set i} {O : Set o}
(C : Container I O c r) {X : Pred I ℓ} where
-- All.
□ : ∀ {ℓ′} → Pred (Σ I X) ℓ′ → Pred (Σ O (⟦ C ⟧ X)) _
□ P (_ , _ , k) = ∀ r → P (_ , k r)
-- Any.
◇ : ∀ {ℓ′} → Pred (Σ I X) ℓ′ → Pred (Σ O (⟦ C ⟧ X)) _
◇ P (_ , _ , k) = ∃ λ r → P (_ , k r)