import Graded.Modality
module Graded.Usage.Restrictions
{a} {M : Set a}
(open Graded.Modality M)
(𝕄 : Modality)
where
open import Graded.Mode 𝕄
open import Graded.Usage.Erased-matches
open import Tools.Bool
open import Tools.Function
open import Tools.Level
open import Tools.PropositionalEquality
open import Tools.Relation
open import Tools.Sum
open import Tools.Empty
private variable
p q r : M
m m′ : Mode
⦃ ok ⦄ : T _
record Usage-restrictions : Set (lsuc a) where
no-eta-equality
field
Prodrec-allowed : Mode → (r p q : M) → Set a
Prodrec-allowed-downwards-closed :
Prodrec-allowed 𝟙ᵐ r p q → Prodrec-allowed 𝟘ᵐ[ ok ] r p q
Unitrec-allowed : Mode → (p q : M) → Set a
Unitrec-allowed-downwards-closed :
Unitrec-allowed 𝟙ᵐ p q → Unitrec-allowed 𝟘ᵐ[ ok ] p q
Emptyrec-allowed : Mode → M → Set a
Emptyrec-allowed-downwards-closed :
Emptyrec-allowed 𝟙ᵐ p → Emptyrec-allowed 𝟘ᵐ[ ok ] p
starˢ-sink : Bool
Id-erased : Set a
Id-erased? : Dec Id-erased
erased-matches-for-J : Mode → Erased-matches
erased-matches-for-J-≤ᵉᵐ :
erased-matches-for-J 𝟙ᵐ ≤ᵉᵐ erased-matches-for-J 𝟘ᵐ[ ok ]
erased-matches-for-K : Mode → Erased-matches
erased-matches-for-K-≤ᵉᵐ :
erased-matches-for-K 𝟙ᵐ ≤ᵉᵐ erased-matches-for-K 𝟘ᵐ[ ok ]
private opaque
·ᵐ-lemma₁ :
(P : Mode → Set a) →
(∀ ⦃ ok ⦄ → P 𝟙ᵐ → P 𝟘ᵐ[ ok ]) →
P m → P (m′ ·ᵐ m)
·ᵐ-lemma₁ {m′ = 𝟙ᵐ} _ _ =
idᶠ
·ᵐ-lemma₁ {m = 𝟙ᵐ} {m′ = 𝟘ᵐ} _ hyp =
hyp
·ᵐ-lemma₁ {m = 𝟘ᵐ[ ok ]} {m′ = 𝟘ᵐ} P hyp =
subst (λ m → P 𝟘ᵐ[ ok ] → P m) 𝟘ᵐ-cong idᶠ
·ᵐ-lemma₂ :
(f : Mode → Erased-matches) →
(∀ ⦃ ok ⦄ → f 𝟙ᵐ ≤ᵉᵐ f 𝟘ᵐ[ ok ]) →
f m ≤ᵉᵐ f (m′ ·ᵐ m)
·ᵐ-lemma₂ {m′ = 𝟙ᵐ} _ _ = ≤ᵉᵐ-reflexive
·ᵐ-lemma₂ {m = 𝟙ᵐ} {m′ = 𝟘ᵐ} _ hyp = hyp
·ᵐ-lemma₂ {m = 𝟘ᵐ} {m′ = 𝟘ᵐ} f _ =
subst (_≤ᵉᵐ_ _) (cong f 𝟘ᵐ-cong) ≤ᵉᵐ-reflexive
opaque
Prodrec-allowed-·ᵐ :
Prodrec-allowed m r p q → Prodrec-allowed (m′ ·ᵐ m) r p q
Prodrec-allowed-·ᵐ =
·ᵐ-lemma₁ (λ m → Prodrec-allowed m _ _ _)
Prodrec-allowed-downwards-closed
opaque
Unitrec-allowed-·ᵐ :
Unitrec-allowed m p q → Unitrec-allowed (m′ ·ᵐ m) p q
Unitrec-allowed-·ᵐ =
·ᵐ-lemma₁ (λ m → Unitrec-allowed m _ _)
Unitrec-allowed-downwards-closed
opaque
Emptyrec-allowed-·ᵐ :
Emptyrec-allowed m p → Emptyrec-allowed (m′ ·ᵐ m) p
Emptyrec-allowed-·ᵐ =
·ᵐ-lemma₁ (λ m → Emptyrec-allowed m _)
Emptyrec-allowed-downwards-closed
Starˢ-sink : Set
Starˢ-sink = T starˢ-sink
¬Starˢ-sink : Set
¬Starˢ-sink = T (not starˢ-sink)
not-sink-and-no-sink : Starˢ-sink → ¬Starˢ-sink → ⊥
not-sink-and-no-sink sink ¬sink with starˢ-sink
… | false = sink
… | true = ¬sink
sink-or-no-sink : Starˢ-sink ⊎ ¬Starˢ-sink
sink-or-no-sink with starˢ-sink
… | false = inj₂ _
… | true = inj₁ _
opaque
erased-matches-for-J-≤ᵉᵐ·ᵐ :
erased-matches-for-J m ≤ᵉᵐ erased-matches-for-J (m′ ·ᵐ m)
erased-matches-for-J-≤ᵉᵐ·ᵐ =
·ᵐ-lemma₂ erased-matches-for-J erased-matches-for-J-≤ᵉᵐ
opaque
erased-matches-for-K-≤ᵉᵐ·ᵐ :
erased-matches-for-K m ≤ᵉᵐ erased-matches-for-K (m′ ·ᵐ m)
erased-matches-for-K-≤ᵉᵐ·ᵐ =
·ᵐ-lemma₂ erased-matches-for-K erased-matches-for-K-≤ᵉᵐ