Debian Codegraph @

src/Relation/Unary/PredicateTransformer.agda

raw
1 ------------------------------------------------------------------------
2 -- The Agda standard library
3 --
4 -- Predicate transformers
5 ------------------------------------------------------------------------
6
7 {-# OPTIONS --cubical-compatible --safe #-}
8
9 module Relation.Unary.PredicateTransformer where
10
11 open import Data.Product.Base using (∃)
12 open import Function.Base using (_∘_)
13 open import Level hiding (_⊔_)
14 open import Relation.Unary
15 open import Relation.Binary.Core using (REL)
16
17 private
18 variable
19 a b c i ℓ ℓ₁ ℓ₂ ℓ₃ : Level
20 A : Set a
21 B : Set b
22 C : Set c
23
24 ------------------------------------------------------------------------
25 -- Heterogeneous and homogeneous predicate transformers
26
27 PT : Set a → Set b → (ℓ₁ ℓ₂ : Level) → Set _
28 PT A B ℓ₁ ℓ₂ = Pred A ℓ₁ → Pred B ℓ₂
29
30 Pt : Set a → (ℓ : Level) → Set _
31 Pt A ℓ = PT A A ℓ ℓ
32
33 ------------------------------------------------------------------------
34 -- Composition and identity
35
36 infixr 9 _⍮_
37
38 _⍮_ : PT B C ℓ₂ ℓ₃ → PT A B ℓ₁ ℓ₂ → PT A C ℓ₁ _
39 S ⍮ T = S ∘ T
40
41 skip : PT A A ℓ ℓ
42 skip P = P
43
44 ------------------------------------------------------------------------
45 -- Operations on predicates extend pointwise to predicate transformers
46
47 -- The bottom and the top of the predicate transformer lattice.
48
49 abort : PT A B 0ℓ 0ℓ
50 abort = λ _ → ∅
51
52 magic : PT A B 0ℓ 0ℓ
53 magic = λ _ → U
54
55 -- Negation.
56
57 infix 8 ∼_
58
59 ∼_ : PT A B ℓ₁ ℓ₂ → PT A B ℓ₁ ℓ₂
60 ∼ T = ∁ ∘ T
61
62 -- Refinement.
63
64 infix 4 _⊑_ _⊒_ _⊑′_ _⊒′_
65
66 _⊑_ : PT A B ℓ₁ ℓ₂ → PT A B ℓ₁ ℓ₂ → Set _
67 S ⊑ T = ∀ {X} → S X ⊆ T X
68
69 _⊑′_ : PT A B ℓ₁ ℓ₂ → PT A B ℓ₁ ℓ₂ → Set _
70 S ⊑′ T = ∀ X → S X ⊆ T X
71
72 _⊒_ : PT A B ℓ₁ ℓ₂ → PT A B ℓ₁ ℓ₂ → Set _
73 T ⊒ S = T ⊑ S
74
75 _⊒′_ : PT A B ℓ₁ ℓ₂ → PT A B ℓ₁ ℓ₂ → Set _
76 T ⊒′ S = S ⊑′ T
77
78 -- The dual of refinement.
79
80 infix 4 _⋢_
81
82 _⋢_ : PT A B ℓ₁ ℓ₂ → PT A B ℓ₁ ℓ₂ → Set _
83 S ⋢ T = ∃ λ X → S X ≬ T X
84
85 -- Union.
86
87 infixl 6 _⊓_
88
89 _⊓_ : PT A B ℓ₁ ℓ₂ → PT A B ℓ₁ ℓ₂ → PT A B ℓ₁ ℓ₂
90 S ⊓ T = λ X → S X ∪ T X
91
92 -- Intersection.
93
94 infixl 7 _⊔_
95
96 _⊔_ : PT A B ℓ₁ ℓ₂ → PT A B ℓ₁ ℓ₂ → PT A B ℓ₁ ℓ₂
97 S ⊔ T = λ X → S X ∩ T X
98
99 -- Implication.
100
101 infixl 8 _⇛_
102
103 _⇛_ : PT A B ℓ₁ ℓ₂ → PT A B ℓ₁ ℓ₂ → PT A B ℓ₁ ℓ₂
104 S ⇛ T = λ X → S X ⇒ T X
105
106 -- Infinitary union and intersection.
107
108 infix 9 ⨆ ⨅
109
110 ⨆ : ∀ (I : Set i) → (I → PT A B ℓ₁ ℓ₂) → PT A B ℓ₁ _
111 ⨆ I T = λ X → ⋃[ i ∶ I ] T i X
112
113 syntax ⨆ I (λ i → T) = ⨆[ i ∶ I ] T
114
115 ⨅ : ∀ (I : Set i) → (I → PT A B ℓ₁ ℓ₂) → PT A B ℓ₁ _
116 ⨅ I T = λ X → ⋂[ i ∶ I ] T i X
117
118 syntax ⨅ I (λ i → T) = ⨅[ i ∶ I ] T
119
120 -- Angelic and demonic update.
121
122 ⟨_⟩ : REL A B ℓ → PT B A ℓ _
123 ⟨ R ⟩ P = λ x → R x ≬ P
124
125 [_] : REL A B ℓ → PT B A ℓ _
126 [ R ] P = λ x → R x ⊆ P