open import Graded.Modality
module Definition.Typed.Restrictions
{a} {M : Set a}
(𝕄 : Modality M)
where
open Modality 𝕄
open import Definition.Typed.Variant
open import Definition.Untyped M
open import Definition.Untyped.Properties M
open import Tools.Empty
open import Tools.Function
open import Tools.Level
open import Tools.Product
open import Tools.Relation
open import Tools.PropositionalEquality
open import Tools.Sum
private variable
Γ : Con Term _
record Type-restrictions : Set (lsuc a) where
no-eta-equality
field
type-variant : Type-variant
open Type-variant type-variant public
field
level-support : Level-support
Unit-allowed : Strength → Set a
ΠΣ-allowed : BinderMode → (p q : M) → Set a
Unitˢ-allowed : Set a
Unitˢ-allowed = Unit-allowed 𝕤
Unitʷ-allowed : Set a
Unitʷ-allowed = Unit-allowed 𝕨
Π-allowed : M → M → Set a
Π-allowed = ΠΣ-allowed BMΠ
Σ-allowed : Strength → M → M → Set a
Σ-allowed = ΠΣ-allowed ∘→ BMΣ
Σˢ-allowed : M → M → Set a
Σˢ-allowed = Σ-allowed 𝕤
Σʷ-allowed : M → M → Set a
Σʷ-allowed = Σ-allowed 𝕨
field
Opacity-allowed : Set a
Opacity-allowed? : Dec Opacity-allowed
Erased-allowed : Strength → Set a
Erased-allowed s = Unit-allowed s × Σ-allowed s 𝟘 𝟘
Erasedˢ-allowed = Erased-allowed 𝕤
Erasedʷ-allowed = Erased-allowed 𝕨
field
K-allowed : Set a
[]-cong-allowed : Strength → Set a
[]-cong→Erased : ∀ {s} → []-cong-allowed s → Erased-allowed s
[]-cong→¬Trivial : ∀ {s} → []-cong-allowed s → ¬ Trivial
[]-congˢ-allowed = []-cong-allowed 𝕤
[]-congʷ-allowed = []-cong-allowed 𝕨
field
Equality-reflection : Set a
Equality-reflection? : Dec Equality-reflection
no-opaque-equality-reflection :
Opacity-allowed → ¬ Equality-reflection
data No-equality-reflection : Set a where
no-equality-reflection :
¬ Equality-reflection → No-equality-reflection
opaque
No-equality-reflection⇔ :
No-equality-reflection ⇔ (¬ Equality-reflection)
No-equality-reflection⇔ =
(λ { (no-equality-reflection not-ok) → not-ok })
, no-equality-reflection
opaque
No-equality-reflection? : Dec No-equality-reflection
No-equality-reflection? =
Dec-map (sym⇔ No-equality-reflection⇔) (¬? Equality-reflection?)
opaque
Opacity-allowed→No-equality-reflection :
Opacity-allowed → No-equality-reflection
Opacity-allowed→No-equality-reflection =
no-equality-reflection ∘→ no-opaque-equality-reflection
opaque
No-equality-reflection-or-empty⇔ :
No-equality-reflection or-empty Γ ⇔
(¬ Equality-reflection ⊎ Empty-con Γ)
No-equality-reflection-or-empty⇔ {Γ} =
No-equality-reflection or-empty Γ ⇔⟨ or-empty⇔ ⟩
No-equality-reflection ⊎ Empty-con Γ ⇔⟨ No-equality-reflection⇔ ⊎-cong-⇔ id⇔ ⟩
¬ Equality-reflection ⊎ Empty-con Γ □⇔
opaque
No-equality-reflection-or-empty? :
Dec (No-equality-reflection or-empty Γ)
No-equality-reflection-or-empty? =
No-equality-reflection? or-empty?
opaque
Level-allowed : Set
Level-allowed = level-support ≢ only-literals
opaque
unfolding Level-allowed
Level-allowed? : Dec Level-allowed
Level-allowed? = ¬? (_ ≟-Level-support _)
opaque
unfolding Level-allowed
Level-allowed⇔≢ : Level-allowed ⇔ (level-support ≢ only-literals)
Level-allowed⇔≢ = id⇔
opaque
¬Level-allowed⇔ :
(¬ Level-allowed) ⇔ (level-support ≡ only-literals)
¬Level-allowed⇔ =
(¬ Level-allowed) ⇔⟨ Level-allowed⇔≢ →-cong-⇔ id⇔ ⟩
¬ ¬ level-support ≡ only-literals ⇔⟨ decidable-stable (_ ≟-Level-support _) , flip _$_ ⟩
level-support ≡ only-literals □⇔
opaque
Level-is-small : Set
Level-is-small = level-support ≡ level-type small
opaque
unfolding Level-is-small
Level-is-small⇔ :
Level-is-small ⇔ level-support ≡ level-type small
Level-is-small⇔ = id⇔
opaque
unfolding Level-is-small
Level-is-small? : Dec Level-is-small
Level-is-small? = _ ≟-Level-support _
opaque
Level-is-not-small : Set
Level-is-not-small = level-support ≡ level-type not-small
opaque
unfolding Level-is-not-small
Level-is-not-small⇔ :
Level-is-not-small ⇔ level-support ≡ level-type not-small
Level-is-not-small⇔ = id⇔
opaque
unfolding Level-is-not-small
Level-is-not-small? : Dec Level-is-not-small
Level-is-not-small? = _ ≟-Level-support _
opaque
Level-allowed⇔⊎ :
Level-allowed ⇔ (Level-is-small ⊎ Level-is-not-small)
Level-allowed⇔⊎ =
Level-allowed ⇔⟨ Level-allowed⇔≢ ⟩
level-support ≢ only-literals ⇔⟨ (λ neq → case singleton level-support of λ where
(only-literals , eq) → ⊥-elim (neq eq)
(level-type small , eq) → inj₁ eq
(level-type not-small , eq) → inj₂ eq)
, [ (λ eq₁ eq₂ → case trans (sym eq₁) eq₂ of λ ())
, (λ eq₁ eq₂ → case trans (sym eq₁) eq₂ of λ ())
]
⟩
level-support ≡ level-type small ⊎
level-support ≡ level-type not-small ⇔˘⟨ Level-is-small⇔ ⊎-cong-⇔ Level-is-not-small⇔ ⟩
Level-is-small ⊎ Level-is-not-small □⇔
BindingType-allowed : BindingType → Set a
BindingType-allowed (BM b p q) = ΠΣ-allowed b p q
Unit-with-η : Strength → Set
Unit-with-η s = s ≡ 𝕤 ⊎ Unitʷ-η
opaque
Unit-with-η? : ∀ s → Unit-with-η s ⊎ s ≡ 𝕨 × ¬ Unitʷ-η
Unit-with-η? 𝕤 = inj₁ (inj₁ refl)
Unit-with-η? 𝕨 = case Unitʷ-η? of λ where
(yes η) → inj₁ (inj₂ η)
(no no-η) → inj₂ (refl , no-η)
opaque
Unit-with-η-𝕨→Unitʷ-η : Unit-with-η 𝕨 → Unitʷ-η
Unit-with-η-𝕨→Unitʷ-η (inj₂ η) = η
Unit-with-η-𝕨→Unitʷ-η (inj₁ ())
open Type-restrictions