import Graded.Modality
module Configuration-types.Type-configuration
{a} {M : Set a}
(open Graded.Modality M)
(𝕄 : Modality)
where
open Modality 𝕄
open import Tools.Bool
open import Tools.Empty
open import Tools.Function
open import Tools.Level
open import Tools.Product as Σ
open import Tools.PropositionalEquality
open import Tools.Relation as Dec
open import Tools.Sum
open import Tools.Unit
open import Configuration-types
open import Configuration-types.Omega 𝕄
open import Graded.Modality.Omega-instances
open import Graded.Modality.Properties 𝕄
import Definition.Typechecking.Decidable.Assumptions as TD
open import Definition.Untyped.NotParametrised
open import Definition.Untyped.Properties.NotParametrised
private variable
TC : Type-configuration _
b : Bool
s : Strength
no-type-restrictions :
With-or-without-omega → Bool → Bool → Type-configuration 𝕄
no-type-restrictions omega k equality-reflection = λ where
.TC⁻ → λ where
.level-support → level-type small
.Omega-plus-allowed → Lift _ ⊤
.Unit-allowed → λ _ → Lift _ ⊤
.η-for-Unitʷ → false
.K-allowed → Lift _ (T k)
.Equality-reflection → Lift _ (T equality-reflection)
.Equality-reflection? → Lift? (T? equality-reflection)
.Quot-allowed → ¬ Trivial × With-omega omega
.Opacity-allowed → Lift _ (¬ T equality-reflection)
.Opacity-allowed? → Lift?
(¬? (T? equality-reflection))
.no-opaque-equality-reflection → (_∘→ Lift.lower) ∘→ Lift.lower
.unfolding-mode → transitive
.with-or-without-omega → omega
.Quot-allowed→Omega-allowed → proj₂
.ΠΣ-allowed → λ _ _ _ → Lift _ ⊤
.[]-cong-allowed → λ _ → ¬ Trivial
.[]-cong→Erased → _
.[]-cong→¬Trivial → idᶠ
where
open Type-configuration
open Type-configuration⁻
equal-binder-quantities : Type-configuration 𝕄 → Type-configuration 𝕄
equal-binder-quantities TC = record TC
{ ΠΣ-allowed = λ b p q → ΠΣ-allowed b p q × p ≡ q
; []-cong→Erased = λ ok →
[]-cong→Erased ok .proj₁ , []-cong→Erased ok .proj₂ , refl
}
where
open Type-configuration TC
second-ΠΣ-quantities-𝟘 :
Type-configuration 𝕄 → Type-configuration 𝕄
second-ΠΣ-quantities-𝟘 TC = record TC
{ ΠΣ-allowed = λ b p q → ΠΣ-allowed b p q × q ≡ 𝟘
; []-cong→Erased = λ ok →
[]-cong→Erased ok .proj₁ , []-cong→Erased ok .proj₂ , refl
}
where
open Type-configuration TC
second-ΠΣ-quantities-𝟘-or-ω :
⦃ ok : Has-omega 𝕄 ⦄ →
Type-configuration 𝕄 → Type-configuration 𝕄
second-ΠΣ-quantities-𝟘-or-ω TC = record TC
{ ΠΣ-allowed = λ b p q →
ΠΣ-allowed b p q ×
(p ≡ ω → q ≡ ω) ×
(p ≢ ω → q ≡ 𝟘)
; []-cong→Erased = λ ok →
[]-cong→Erased ok .proj₁
, []-cong→Erased ok .proj₂
, idᶠ
, λ _ → refl
}
where
open Type-configuration TC
strong-types-restricted′ :
(P : BinderMode → M → Set a) →
(∀ {s} → s ≢ 𝕤 → P (BMΣ s) 𝟘) →
Type-configuration 𝕄 → Type-configuration 𝕄
strong-types-restricted′ P hyp TC = record TC
{ TC⁻ = record TC⁻
{ Unit-allowed = λ s →
Unit-allowed s × s ≢ 𝕤
}
; ΠΣ-allowed = λ b p q →
ΠΣ-allowed b p q × P b p
; []-cong-allowed = λ s →
[]-cong-allowed s × s ≢ 𝕤
; []-cong→Erased = λ (ok , s≢𝕤) →
([]-cong→Erased ok .proj₁ , s≢𝕤)
, []-cong→Erased ok .proj₂
, hyp s≢𝕤
; []-cong→¬Trivial =
[]-cong→¬Trivial ∘→ proj₁
}
where
open Type-configuration TC
strong-types-restricted :
Type-configuration 𝕄 → Type-configuration 𝕄
strong-types-restricted =
strong-types-restricted′ (λ b p → b ≡ BMΣ 𝕤 → p ≡ 𝟙)
(λ { hyp refl → ⊥-elim $ hyp refl })
no-strong-types :
Type-configuration 𝕄 → Type-configuration 𝕄
no-strong-types =
strong-types-restricted′ (λ b _ → Lift _ (b ≢ BMΣ 𝕤))
(λ hyp → lift (λ { refl → ⊥-elim $ hyp refl }))
_with-η-for-Unitʷ : Type-configuration 𝕄 → Type-configuration 𝕄
TC with-η-for-Unitʷ = record TC
{ TC⁻ = record TC⁻
{ η-for-Unitʷ = true
}
}
where
open Type-configuration TC
with-[]-cong : Type-configuration 𝕄 → Type-configuration 𝕄
with-[]-cong TC = record TC
{ TC⁻ = record TC⁻
{ Unit-allowed = λ s → Unit-allowed s ⊎ ¬ Trivial
}
; ΠΣ-allowed = λ where
(BMΣ s) p q → ΠΣ-allowed (BMΣ s) p q ⊎
¬ Trivial × p ≡ 𝟘 × q ≡ 𝟘
BMΠ p q → ΠΣ-allowed BMΠ p q
; []-cong-allowed = λ s → []-cong-allowed s ⊎ ¬ Trivial
; []-cong→Erased = [ Σ.map inj₁ inj₁ ∘→ []-cong→Erased
, (λ non-trivial →
inj₂ non-trivial ,
inj₂ (non-trivial , refl , refl))
]
; []-cong→¬Trivial = [ []-cong→¬Trivial , idᶠ ]
}
where
open Type-configuration TC
no-[]-cong : Type-configuration 𝕄 → Type-configuration 𝕄
no-[]-cong TR = record TR
{ []-cong-allowed = λ _ → Lift _ ⊥
; []-cong→Erased = λ ()
; []-cong→¬Trivial = λ ()
}
with-equality-reflection : Type-configuration 𝕄 → Type-configuration 𝕄
with-equality-reflection TC = record TC
{ TC⁻ = record (TC .Type-configuration.TC⁻)
{ Equality-reflection = Lift _ ⊤
; Equality-reflection? = yes _
; Opacity-allowed = Lift _ ⊥
; Opacity-allowed? = no (λ ())
; no-opaque-equality-reflection = λ ()
}
}
no-quotients : Type-configuration 𝕄 → Type-configuration 𝕄
no-quotients TC = record TC
{ TC⁻ =
record (TC .Type-configuration.TC⁻)
{ Quot-allowed = Lift _ ⊥
}
; Quot-allowed→Omega-allowed = λ ()
}
opaque
Assumptions-no-type-restrictions :
{omega : With-or-without-omega} →
Decidable (_≡_ {A = M}) →
TD.Assumptions (no-type-restrictions omega b false)
Assumptions-no-type-restrictions {b} dec = λ where
._≟_ → dec
.Omega-plus-allowed? → yes _
.Unit-allowed? _ → yes _
.ΠΣ-allowed? _ _ _ → yes _
.K-allowed? → case singleton b of λ where
(true , refl) → yes _
(false , refl) → no (λ ())
.[]-cong-allowed? _ →
¬? trivial?
.Quot-allowed? →
¬? trivial? ×-dec With-omega?
.no-equality-reflection (lift ())
where
open TD.Assumptions
opaque
Assumptions-equal-binder-quantities :
TD.Assumptions TC → TD.Assumptions (equal-binder-quantities TC)
Assumptions-equal-binder-quantities as = λ where
._≟_ → A._≟_
.Omega-plus-allowed? → A.Omega-plus-allowed?
.Unit-allowed? → A.Unit-allowed?
.ΠΣ-allowed? b p q → A.ΠΣ-allowed? b p q ×-dec p A.≟ q
.K-allowed? → A.K-allowed?
.[]-cong-allowed? → A.[]-cong-allowed?
.Quot-allowed? → A.Quot-allowed?
.no-equality-reflection → A.no-equality-reflection
where
module A = TD.Assumptions as
open TD.Assumptions
opaque
Assumptions-second-ΠΣ-quantities-𝟘 :
TD.Assumptions TC → TD.Assumptions (second-ΠΣ-quantities-𝟘 TC)
Assumptions-second-ΠΣ-quantities-𝟘 as = λ where
._≟_ → A._≟_
.Omega-plus-allowed? → A.Omega-plus-allowed?
.Unit-allowed? → A.Unit-allowed?
.ΠΣ-allowed? b p q → A.ΠΣ-allowed? b p q ×-dec q A.≟ 𝟘
.K-allowed? → A.K-allowed?
.[]-cong-allowed? → A.[]-cong-allowed?
.Quot-allowed? → A.Quot-allowed?
.no-equality-reflection → A.no-equality-reflection
where
module A = TD.Assumptions as
open TD.Assumptions
opaque
Assumptions-second-ΠΣ-quantities-𝟘-or-ω :
⦃ ok : Has-omega 𝕄 ⦄ →
TD.Assumptions TC → TD.Assumptions (second-ΠΣ-quantities-𝟘-or-ω TC)
Assumptions-second-ΠΣ-quantities-𝟘-or-ω as = λ where
._≟_ → A._≟_
.Omega-plus-allowed? → A.Omega-plus-allowed?
.Unit-allowed? → A.Unit-allowed?
.ΠΣ-allowed? b p q → A.ΠΣ-allowed? b p q
×-dec
(p A.≟ ω →-dec q A.≟ ω)
×-dec
(¬? (p A.≟ ω) →-dec q A.≟ 𝟘)
.K-allowed? → A.K-allowed?
.[]-cong-allowed? → A.[]-cong-allowed?
.Quot-allowed? → A.Quot-allowed?
.no-equality-reflection → A.no-equality-reflection
where
module A = TD.Assumptions as
open TD.Assumptions
opaque
Assumptions-strong-types-restricted′ :
{P : BinderMode → M → Set a}
{ok : ∀ {s} → s ≢ 𝕤 → P (BMΣ s) 𝟘} →
(∀ b p → Dec (P b p)) →
TD.Assumptions TC →
TD.Assumptions (strong-types-restricted′ P ok TC)
Assumptions-strong-types-restricted′ P-dec as = λ where
._≟_ → A._≟_
.Omega-plus-allowed? → A.Omega-plus-allowed?
.Unit-allowed? s → A.Unit-allowed? s
×-dec
¬? (decStrength s 𝕤)
.ΠΣ-allowed? b p q → A.ΠΣ-allowed? b p q
×-dec
P-dec b p
.K-allowed? → A.K-allowed?
.[]-cong-allowed? s → A.[]-cong-allowed? s
×-dec
¬? (decStrength s 𝕤)
.Quot-allowed? → A.Quot-allowed?
.no-equality-reflection → A.no-equality-reflection
where
module A = TD.Assumptions as
open TD.Assumptions
opaque
Assumptions-strong-types-restricted :
TD.Assumptions TC → TD.Assumptions (strong-types-restricted TC)
Assumptions-strong-types-restricted as =
Assumptions-strong-types-restricted′
(λ b p → decBinderMode b (BMΣ 𝕤) →-dec p ≟ 𝟙)
as
where
open TD.Assumptions as
opaque
Assumptions-no-strong-types :
TD.Assumptions TC → TD.Assumptions (no-strong-types TC)
Assumptions-no-strong-types as =
Assumptions-strong-types-restricted′
(λ b _ → Dec.map lift Lift.lower (¬? (decBinderMode b (BMΣ 𝕤))))
as
where
open TD.Assumptions as
opaque
Assumptions-no-quotients :
TD.Assumptions TC → TD.Assumptions (no-quotients TC)
Assumptions-no-quotients as = λ where
._≟_ → A._≟_
.Omega-plus-allowed? → A.Omega-plus-allowed?
.Unit-allowed? → A.Unit-allowed?
.ΠΣ-allowed? → A.ΠΣ-allowed?
.K-allowed? → A.K-allowed?
.[]-cong-allowed? s′ → A.[]-cong-allowed? s′
.Quot-allowed? → no (λ ())
.no-equality-reflection → A.no-equality-reflection
where
module A = TD.Assumptions as
open TD.Assumptions