open import Definition.Typed.Restrictions
open import Graded.Modality
module Definition.Typed.Reasoning.Reduction.Well-typed
{ℓ} {M : Set ℓ}
{𝕄 : Modality M}
(R : Type-restrictions 𝕄)
where
open import Definition.Typed R
open import Definition.Typed.Properties R
open import Definition.Typed.RedSteps R
open import Definition.Untyped M
open import Tools.Function
import Tools.PropositionalEquality as PE
private variable
A B t u v : Term _
Γ : Con Term _
infix -1 finally-:⇒*:
infixr -2 step-:⇒*: finally-:⇒*:≡
opaque
step-:⇒*: :
∀ t → Γ ⊢ u :⇒*: v ∷ A → Γ ⊢ t :⇒*: u ∷ A → Γ ⊢ t :⇒*: v ∷ A
step-:⇒*: _ = flip trans-:⇒*:
syntax step-:⇒*: t u⇒v t⇒u = t :⇒*:⟨ t⇒u ⟩ u⇒v
finally-:⇒*: : ∀ t u → Γ ⊢ t :⇒*: u ∷ A → Γ ⊢ t :⇒*: u ∷ A
finally-:⇒*: _ _ t⇒u = t⇒u
syntax finally-:⇒*: t u t⇒u = t :⇒*:⟨ t⇒u ⟩∎ u ∎
{-# INLINE finally-:⇒*: #-}
finally-:⇒*:≡ : ∀ t → u PE.≡ v → Γ ⊢ t :⇒*: u ∷ A → Γ ⊢ t :⇒*: v ∷ A
finally-:⇒*:≡ _ PE.refl t⇒u = t⇒u
syntax finally-:⇒*:≡ t u≡v t⇒u = t :⇒*:⟨ t⇒u ⟩∎≡ u≡v
infix -1 finally-:⇐*:
infixr -2 step-:⇐*: finally-:⇐*:≡
opaque
step-:⇐*: :
∀ v → Γ ⊢ t :⇒*: u ∷ A → Γ ⊢ u :⇒*: v ∷ A → Γ ⊢ t :⇒*: v ∷ A
step-:⇐*: _ = trans-:⇒*:
syntax step-:⇐*: v t⇒u u⇒v = v :⇐*:⟨ u⇒v ⟩ t⇒u
finally-:⇐*: : ∀ u t → Γ ⊢ t :⇒*: u ∷ A → Γ ⊢ t :⇒*: u ∷ A
finally-:⇐*: _ _ t⇒u = t⇒u
syntax finally-:⇐*: u t t⇒u = u :⇐*:⟨ t⇒u ⟩∎ t ∎
{-# INLINE finally-:⇐*: #-}
finally-:⇐*:≡ : ∀ v → u PE.≡ t → Γ ⊢ v :⇒*: u ∷ A → Γ ⊢ v :⇒*: t ∷ A
finally-:⇐*:≡ _ PE.refl v⇒u = v⇒u
syntax finally-:⇐*:≡ v u≡t v⇒u = v :⇐*:⟨ v⇒u ⟩∎≡ u≡t
infix -1 _∎⟨_⟩:⇒:
infixr -2 step-≡ step-≡˘ _≡⟨⟩:⇒:_
step-≡ : ∀ t → Γ ⊢ u :⇒*: v ∷ A → t PE.≡ u → Γ ⊢ t :⇒*: v ∷ A
step-≡ _ u⇒v PE.refl = u⇒v
syntax step-≡ t u⇒v t≡u = t ≡⟨ t≡u ⟩:⇒: u⇒v
step-≡˘ : ∀ t → Γ ⊢ u :⇒*: v ∷ A → u PE.≡ t → Γ ⊢ t :⇒*: v ∷ A
step-≡˘ _ u⇒v PE.refl = u⇒v
syntax step-≡˘ t u⇒v u≡t = t ≡˘⟨ u≡t ⟩:⇒: u⇒v
_≡⟨⟩:⇒:_ : ∀ t → Γ ⊢ t :⇒*: u ∷ A → Γ ⊢ t :⇒*: u ∷ A
_ ≡⟨⟩:⇒: t⇒u = t⇒u
{-# INLINE _≡⟨⟩:⇒:_ #-}
opaque
_∎⟨_⟩:⇒: : ∀ t → Γ ⊢ t ∷ A → Γ ⊢ t :⇒*: t ∷ A
_ ∎⟨ ⊢t ⟩:⇒: = idRedTerm:*: ⊢t
infix -1 finally-:⇒*:∷
infixr -2 step-:⇒*:∷ step-:⇒*:∷≡ step-:⇒*:∷≡˘ _∷_≡⟨⟩:⇒:∷_ finally-:⇒*:∷≡
opaque
step-:⇒*:∷ :
∀ t A → Γ ⊢ u :⇒*: v ∷ A → Γ ⊢ t :⇒*: u ∷ A → Γ ⊢ t :⇒*: v ∷ A
step-:⇒*:∷ _ _ = flip trans-:⇒*:
syntax step-:⇒*:∷ t A u⇒v t⇒u = t ∷ A :⇒*:⟨ t⇒u ⟩∷ u⇒v
step-:⇒*:∷≡ : ∀ t A → Γ ⊢ u :⇒*: v ∷ A → t PE.≡ u → Γ ⊢ t :⇒*: v ∷ A
step-:⇒*:∷≡ _ _ u⇒v PE.refl = u⇒v
syntax step-:⇒*:∷≡ t A u⇒v t≡u = t ∷ A ≡⟨ t≡u ⟩:⇒:∷ u⇒v
step-:⇒*:∷≡˘ : ∀ t A → Γ ⊢ u :⇒*: v ∷ A → u PE.≡ t → Γ ⊢ t :⇒*: v ∷ A
step-:⇒*:∷≡˘ _ _ u⇒v PE.refl = u⇒v
syntax step-:⇒*:∷≡˘ t A u⇒v u≡t = t ∷ A ≡˘⟨ u≡t ⟩:⇒:∷ u⇒v
_∷_≡⟨⟩:⇒:∷_ : ∀ t A → Γ ⊢ t :⇒*: u ∷ A → Γ ⊢ t :⇒*: u ∷ A
_ ∷ _ ≡⟨⟩:⇒:∷ t⇒u = t⇒u
{-# INLINE _∷_≡⟨⟩:⇒:∷_ #-}
finally-:⇒*:∷ : ∀ t A u → Γ ⊢ t :⇒*: u ∷ A → Γ ⊢ t :⇒*: u ∷ A
finally-:⇒*:∷ _ _ _ t⇒u = t⇒u
syntax finally-:⇒*:∷ t A u t⇒u = t ∷ A :⇒*:⟨ t⇒u ⟩∎∷ u ∎
{-# INLINE finally-:⇒*:∷ #-}
finally-:⇒*:∷≡ : ∀ t A → u PE.≡ v → Γ ⊢ t :⇒*: u ∷ A → Γ ⊢ t :⇒*: v ∷ A
finally-:⇒*:∷≡ _ _ PE.refl t⇒u = t⇒u
syntax finally-:⇒*:∷≡ t A u≡v t⇒u = t ∷ A :⇒*:⟨ t⇒u ⟩∎∷≡ u≡v
infix -1 finally-:⇐*:∷
infixr -2 step-:⇐*:∷ step-:⇐*:∷≡ step-:⇐*:∷≡˘ _∷_≡⟨⟩:⇐:∷_ finally-:⇐*:∷≡
opaque
step-:⇐*:∷ :
∀ v A → Γ ⊢ t :⇒*: u ∷ A → Γ ⊢ u :⇒*: v ∷ A → Γ ⊢ t :⇒*: v ∷ A
step-:⇐*:∷ _ _ = trans-:⇒*:
syntax step-:⇐*:∷ v A t⇒u u⇒v = v ∷ A :⇐*:⟨ u⇒v ⟩∷ t⇒u
step-:⇐*:∷≡ : ∀ v A → Γ ⊢ t :⇒*: u ∷ A → v PE.≡ u → Γ ⊢ t :⇒*: v ∷ A
step-:⇐*:∷≡ _ _ t⇒u PE.refl = t⇒u
syntax step-:⇐*:∷≡ v A t⇒u v≡u = v ∷ A ≡⟨ v≡u ⟩:⇐:∷ t⇒u
step-:⇐*:∷≡˘ : ∀ v A → Γ ⊢ t :⇒*: u ∷ A → u PE.≡ v → Γ ⊢ t :⇒*: v ∷ A
step-:⇐*:∷≡˘ _ _ t⇒u PE.refl = t⇒u
syntax step-:⇐*:∷≡˘ v A t⇒u u≡v = v ∷ A ≡˘⟨ u≡v ⟩:⇐:∷ t⇒u
_∷_≡⟨⟩:⇐:∷_ : ∀ u A → Γ ⊢ t :⇒*: u ∷ A → Γ ⊢ t :⇒*: u ∷ A
_ ∷ _ ≡⟨⟩:⇐:∷ t⇒u = t⇒u
{-# INLINE _∷_≡⟨⟩:⇐:∷_ #-}
finally-:⇐*:∷ : ∀ u A t → Γ ⊢ t :⇒*: u ∷ A → Γ ⊢ t :⇒*: u ∷ A
finally-:⇐*:∷ _ _ _ t⇒u = t⇒u
syntax finally-:⇐*:∷ u A t t⇒u = u ∷ A :⇐*:⟨ t⇒u ⟩∎∷ t ∎
{-# INLINE finally-:⇐*:∷ #-}
finally-:⇐*:∷≡ : ∀ v A → u PE.≡ t → Γ ⊢ v :⇒*: u ∷ A → Γ ⊢ v :⇒*: t ∷ A
finally-:⇐*:∷≡ _ _ PE.refl v⇒u = v⇒u
syntax finally-:⇐*:∷≡ v A u≡t v⇒u = v ∷ A :⇐*:⟨ v⇒u ⟩∎∷≡ u≡t
opaque
infix -1 _∷_∎⟨_⟩:⇒:
_∷_∎⟨_⟩:⇒: : ∀ t A → Γ ⊢ t ∷ A → Γ ⊢ t :⇒*: t ∷ A
_ ∷ _ ∎⟨ ⊢t ⟩:⇒: = idRedTerm:*: ⊢t
infix -2
step-:⇒*:-conv step-:⇒*:-conv˘ step-:⇒*:-conv-≡ step-:⇒*:-conv-≡˘
opaque
step-:⇒*:-conv : Γ ⊢ t :⇒*: u ∷ B → Γ ⊢ A ≡ B → Γ ⊢ t :⇒*: u ∷ A
step-:⇒*:-conv t⇒u A≡B = convRed:*: t⇒u (sym A≡B)
syntax step-:⇒*:-conv t⇒u A≡B = ⟨ A≡B ⟩:⇒: t⇒u
opaque
step-:⇒*:-conv˘ : Γ ⊢ t :⇒*: u ∷ B → Γ ⊢ B ≡ A → Γ ⊢ t :⇒*: u ∷ A
step-:⇒*:-conv˘ t⇒u B≡A = convRed:*: t⇒u B≡A
syntax step-:⇒*:-conv˘ t⇒u B≡A = ˘⟨ B≡A ⟩:⇒: t⇒u
step-:⇒*:-conv-≡ : Γ ⊢ t :⇒*: u ∷ B → A PE.≡ B → Γ ⊢ t :⇒*: u ∷ A
step-:⇒*:-conv-≡ t⇒u PE.refl = t⇒u
syntax step-:⇒*:-conv-≡ t⇒u A≡B = ⟨ A≡B ⟩:⇒:≡ t⇒u
step-:⇒*:-conv-≡˘ : Γ ⊢ t :⇒*: u ∷ B → B PE.≡ A → Γ ⊢ t :⇒*: u ∷ A
step-:⇒*:-conv-≡˘ t⇒u PE.refl = t⇒u
syntax step-:⇒*:-conv-≡˘ t⇒u B≡A = ˘⟨ B≡A ⟩:⇒:≡ t⇒u
infix -2
step-∷:⇒*:-conv step-∷:⇒*:-conv˘ step-∷:⇒*:-conv-≡ step-∷:⇒*:-conv-≡˘
step-∷:⇒*:-conv : ∀ A → Γ ⊢ t :⇒*: u ∷ B → Γ ⊢ A ≡ B → Γ ⊢ t :⇒*: u ∷ A
step-∷:⇒*:-conv _ = step-:⇒*:-conv
syntax step-∷:⇒*:-conv A t⇒u A≡B = ∷ A ⟨ A≡B ⟩:⇒: t⇒u
{-# INLINE step-∷:⇒*:-conv #-}
step-∷:⇒*:-conv˘ : ∀ A → Γ ⊢ t :⇒*: u ∷ B → Γ ⊢ B ≡ A → Γ ⊢ t :⇒*: u ∷ A
step-∷:⇒*:-conv˘ _ = step-:⇒*:-conv˘
syntax step-∷:⇒*:-conv˘ A t⇒u B≡A = ∷ A ˘⟨ B≡A ⟩:⇒: t⇒u
{-# INLINE step-∷:⇒*:-conv˘ #-}
step-∷:⇒*:-conv-≡ : ∀ A → Γ ⊢ t :⇒*: u ∷ B → A PE.≡ B → Γ ⊢ t :⇒*: u ∷ A
step-∷:⇒*:-conv-≡ _ t⇒u PE.refl = t⇒u
syntax step-∷:⇒*:-conv-≡ A t⇒u A≡B = ∷ A ⟨ A≡B ⟩:⇒:≡ t⇒u
step-∷:⇒*:-conv-≡˘ :
∀ A → Γ ⊢ t :⇒*: u ∷ B → B PE.≡ A → Γ ⊢ t :⇒*: u ∷ A
step-∷:⇒*:-conv-≡˘ _ t⇒u PE.refl = t⇒u
syntax step-∷:⇒*:-conv-≡˘ A t⇒u B≡A = ∷ A ˘⟨ B≡A ⟩:⇒:≡ t⇒u
infix -2
step-∷:⇐*:-conv step-∷:⇐*:-conv˘ step-∷:⇐*:-conv-≡ step-∷:⇐*:-conv-≡˘
step-∷:⇐*:-conv : ∀ A → Γ ⊢ t :⇒*: u ∷ B → Γ ⊢ A ≡ B → Γ ⊢ t :⇒*: u ∷ A
step-∷:⇐*:-conv _ = step-:⇒*:-conv
syntax step-∷:⇐*:-conv A t⇒u A≡B = ∷ A ⟨ A≡B ⟩:⇐: t⇒u
{-# INLINE step-∷:⇐*:-conv #-}
step-∷:⇐*:-conv˘ : ∀ A → Γ ⊢ t :⇒*: u ∷ B → Γ ⊢ B ≡ A → Γ ⊢ t :⇒*: u ∷ A
step-∷:⇐*:-conv˘ _ = step-:⇒*:-conv˘
syntax step-∷:⇐*:-conv˘ A t⇒u B≡A = ∷ A ˘⟨ B≡A ⟩:⇐: t⇒u
{-# INLINE step-∷:⇐*:-conv˘ #-}
step-∷:⇐*:-conv-≡ : ∀ A → Γ ⊢ t :⇒*: u ∷ B → A PE.≡ B → Γ ⊢ t :⇒*: u ∷ A
step-∷:⇐*:-conv-≡ _ t⇒u PE.refl = t⇒u
syntax step-∷:⇐*:-conv-≡ A t⇒u A≡B = ∷ A ⟨ A≡B ⟩:⇐:≡ t⇒u
step-∷:⇐*:-conv-≡˘ :
∀ A → Γ ⊢ t :⇒*: u ∷ B → B PE.≡ A → Γ ⊢ t :⇒*: u ∷ A
step-∷:⇐*:-conv-≡˘ _ t⇒u PE.refl = t⇒u
syntax step-∷:⇐*:-conv-≡˘ A t⇒u B≡A = ∷ A ˘⟨ B≡A ⟩:⇐:≡ t⇒u