open import Definition.Typed.Restrictions
open import Graded.Modality
module Definition.Conversion.Whnf
{a} {M : Set a}
{đ : Modality M}
(R : Type-restrictions đ)
where
open Type-restrictions R
open import Definition.Untyped M
open import Definition.Untyped.Neutral M type-variant
open import Definition.Untyped.Whnf M type-variant
open import Definition.Conversion R
open import Tools.Nat
open import Tools.Product as ÎŁ
import Tools.PropositionalEquality as PE
private
variable
m n : Nat
â : DCon (Term 0) m
Î : Con Term n
t : Term _
V : Set a
opaque
neââ :
⊠not : No-equality-reflection ⊠â
Neutral V â t â Neutral No-equality-reflection â t
neââ ⊠not ⊠= neâ (λ _ â not)
mutual
ne~â : â {t u A}
â â » Î âą t ~ u â A
â Neutralâș â t Ă Neutralâș â u
ne~â (var-refl xâ xâĄy) = varâș _ , varâș _
ne~â (defn-refl âąÎ± αâŠâ αâĄÎČ) =
defn αâŠâ , defn (PE.subst (_âŠââ· _ â _) αâĄÎČ Î±âŠâ)
ne~â (app-cong x xâ) = let _ , q , w = ne~â x
in ââ q , ââ w
ne~â (fst-cong x) =
let _ , pNe , rNe = ne~â x
in fstâ pNe , fstâ rNe
ne~â (snd-cong x) =
let _ , pNe , rNe = ne~â x
in sndâ pNe , sndâ rNe
ne~â (natrec-cong x xâ xâ xâ) = let _ , q , w = ne~â xâ
in natrecâ q , natrecâ w
ne~â (prodrec-cong _ g~h _) =
let _ , gNe , hNe = ne~â g~h
in prodrecâ gNe , prodrecâ hNe
ne~â (emptyrec-cong x xâ) = let _ , q , w = ne~â xâ
in emptyrecâ q , emptyrecâ w
ne~â (unitrec-cong _ k~l _ no-η) =
let _ , kNe , lNe = ne~â k~l
in unitrecâ no-η kNe , unitrecâ no-η lNe
ne~â (J-cong _ _ _ _ _ wâ~wâ _) =
ÎŁ.map Jâ Jâ (ne~â wâ~wâ .projâ)
ne~â (K-cong _ _ _ _ vâ~vâ _ _) =
ÎŁ.map Kâ Kâ (ne~â vâ~vâ .projâ)
ne~â ([]-cong-cong _ _ _ vâ~vâ _ _) =
ÎŁ.map []-congâ []-congâ (ne~â vâ~vâ .projâ)
ne~â : â {t u A}
â â » Î âą t ~ u â A
â Whnf â A Ă Neutralâș â t Ă Neutralâș â u
ne~â ([~] _ (_ , whnfB) k~l) = whnfB , ne~â k~l
whnfConvâ : â {A B}
â â » Î âą A [convâ] B
â Whnf â A Ă Whnf â B
whnfConvâ (U-refl x) = Uâ , Uâ
whnfConvâ (â-refl x) = ââ , ââ
whnfConvâ (Empty-refl x) = Emptyâ , Emptyâ
whnfConvâ (Unit-refl x _) = Unitâ , Unitâ
whnfConvâ (ne x) = let _ , neA , neB = ne~â x
in ne-whnf neA , ne-whnf neB
whnfConvâ (Î ÎŁ-cong _ _ _) = Î ÎŁâ , Î ÎŁâ
whnfConvâ (Id-cong _ _ _) = Idâ , Idâ
whnfConvâTerm : â {t u A}
â â » Î âą t [convâ] u â· A
â Whnf â A Ă Whnf â t Ă Whnf â u
whnfConvâTerm (â-ins x) = let _ , neT , neU = ne~â x
in ââ , ne-whnf neT , ne-whnf neU
whnfConvâTerm (Empty-ins x) = let _ , neT , neU = ne~â x
in Emptyâ , ne-whnf neT , ne-whnf neU
whnfConvâTerm (UnitÊ·-ins _ t~u) =
let _ , t-ne , u-ne = ne~â t~u in
Unitâ , ne-whnf t-ne , ne-whnf u-ne
whnfConvâTerm (ÎŁÊ·-ins x xâ xâ) =
let _ , neT , neU = ne~â xâ
in Î ÎŁâ , ne-whnf neT , ne-whnf neU
whnfConvâTerm (ne-ins t u x xâ) =
let _ , neT , neU = ne~â xâ
in ne-whnf x , ne-whnf neT , ne-whnf neU
whnfConvâTerm (univ x xâ xâ) = Uâ , whnfConvâ xâ
whnfConvâTerm (zero-refl x) = ââ , zeroâ , zeroâ
whnfConvâTerm (starÊ·-refl _ _ _) = Unitâ , starâ , starâ
whnfConvâTerm (suc-cong x) = ââ , sucâ , sucâ
whnfConvâTerm (prod-cong _ _ _ _) = Î ÎŁâ , prodâ , prodâ
whnfConvâTerm (η-eq xâ xâ y yâ xâ) = Î ÎŁâ , functionWhnf y , functionWhnf yâ
whnfConvâTerm (ÎŁ-η _ _ pProd rProd _ _) = Î ÎŁâ , productWhnf pProd , productWhnf rProd
whnfConvâTerm (η-unit _ _ tWhnf uWhnf _) = Unitâ , tWhnf , uWhnf
whnfConvâTerm (Id-ins _ vâ~vâ) =
Idâ , ÎŁ.map ne-whnf ne-whnf (ne~â vâ~vâ .projâ)
whnfConvâTerm (rfl-refl _) =
Idâ , rflâ , rflâ