open import Definition.Typed.Restrictions
open import Graded.Modality
import Tools.PropositionalEquality as PE
open import Tools.Relation
module Definition.Conversion.Decidable
{a} {M : Set a}
{đ : Modality M}
(R : Type-restrictions đ)
(_â_ : Decidable (PE._âĄ_ {A = M}))
where
open Type-restrictions R
open import Definition.Untyped M
open import Definition.Untyped.Neutral M type-variant
open import Definition.Untyped.Properties M
open import Definition.Typed R
open import Definition.Typed.Properties R
open import Definition.Conversion R
open import Definition.Conversion.Whnf R
open import Definition.Conversion.Soundness R
open import Definition.Conversion.Symmetry R
open import Definition.Conversion.Transitivity R
open import Definition.Conversion.Stability R
open import Definition.Conversion.Conversion R
open import Definition.Typed.Consequences.DerivedRules.Identity R
open import Definition.Typed.Consequences.Syntactic R
open import Definition.Typed.Consequences.Substitution R
open import Definition.Typed.Consequences.Stability R
open import Definition.Typed.Consequences.Injectivity R
open import Definition.Typed.Consequences.Inversion R
open import Definition.Typed.Consequences.Reduction R
open import Definition.Typed.Consequences.Equality R
open import Definition.Typed.Consequences.Inequality R as IE
open import Definition.Typed.Consequences.NeTypeEq R
open import Definition.Typed.Consequences.DerivedRules.Nat R
open import Tools.Fin
open import Tools.Function
open import Tools.Nat using (Nat)
open import Tools.Product
open import Tools.Empty
open import Tools.Sum using (injâ; injâ)
private
variable
â : Nat
Î Î : Con Term â
B F G k kⲠl lⲠ: Term â
p pⲠpâ pâ q qⲠr rⲠ: M
strongVarEq : â {m n A} â Π⢠var n ~ var m â A â n PE.⥠m
strongVarEq (var-refl x xâĄy) = xâĄy
dec~â-app : â {k kâ l lâ F Fâ G Gâ B}
â Π⢠k ⡠Πp , q ⡠F âš G
â Π⢠kâ ⡠Πp , q ⡠Fâ âš Gâ
â Π⢠k ~ kâ â B
â p PE.⥠pâ˛
â Dec (Π⢠l [convâ] lâ ⡠F)
â Dec (â Îť A â Π⢠k â⨠p ⊠l ~ kâ â⨠pⲠ⊠lâ â A)
dec~â-app k kâ k~kâ PE.refl (yes p) =
let whnfA , neK , neL = ne~â k~kâ
â˘A , â˘k , â˘l = syntacticEqTerm (soundness~â k~kâ)
Î FGââĄA = neTypeEq neK k â˘k
in
case Î âĄA Î FGââĄA whnfA of Îť {
(H , E , AâĄÎ HE) â
case injectivity (PE.subst (Îť x â _ ⢠_ ⥠x) AâĄÎ HE Î FGââĄA) of Îť {
(FâĄH , GââĄE , _ , _) â
yes (E [ _ ] , app-cong (PE.subst (Îť x â _ ⢠_ ~ _ â x) AâĄÎ HE k~kâ)
(convConvTerm p FâĄH)) }}
dec~â-app kâ kâ k~kâ _ (no ÂŹp) =
no (Îť { (_ , app-cong x xâ) â
let whnfA , neK , neL = ne~â x
â˘A , â˘k , â˘l = syntacticEqTerm (soundness~â x)
Î FGâĄÎ FâGâ = neTypeEq neK kâ â˘k
FâĄFâ , GâĄGâ , _ = injectivity Î FGâĄÎ FâGâ
in ÂŹp (convConvTerm xâ (sym FâĄFâ)) })
decConvâTerm-â-ins : â {t u tâ˛}
â Π⢠t [convâ] u ⡠â
â Π⢠t ~ tⲠâ â
â Π⢠t ~ u â â
decConvâTerm-â-ins (â-ins x) t~t = x
decConvâTerm-â-ins (ne-ins x xâ () xâ) t~t
decConvâTerm-â-ins (zero-refl x) ([~] _ _ ())
decConvâTerm-â-ins (suc-cong x) ([~] _ _ ())
decConvâTerm-Empty-ins : â {t u tâ˛}
â Π⢠t [convâ] u ⡠Empty
â Π⢠t ~ tⲠâ Empty
â Π⢠t ~ u â Empty
decConvâTerm-Empty-ins (Empty-ins x) t~t = x
decConvâTerm-Empty-ins (ne-ins x xâ () xâ) t~t
decConvâTerm-Σʡ-ins : â {t tⲠu F G H E}
â Π⢠t [convâ] u ⡠Σʡ p , q ⡠F âš G
â Π⢠t ~ tⲠâ Σʡ pⲠ, qⲠ⡠H âš E
â â Îť B â Π⢠t ~ u â B
decConvâTerm-Σʡ-ins (Σʡ-ins x xâ xâ) t~t = _ , xâ
decConvâTerm-Σʡ-ins (prod-cong _ _ _ _ _) ()
decConvâTerm-Σʡ-ins (ne-ins x xâ () xâ) t~t
decConvâTerm-ne-ins : â {t u A}
â Neutral A
â Π⢠t [convâ] u ⡠A
â â Îť B â Π⢠t ~ u â B
decConvâTerm-ne-ins () (â-ins x)
decConvâTerm-ne-ins () (Empty-ins x)
decConvâTerm-ne-ins neA (ne-ins x xâ xâ xâ) = _ , xâ
decConvâTerm-ne-ins () (univ x xâ xâ)
decConvâTerm-ne-ins () (zero-refl x)
decConvâTerm-ne-ins () (suc-cong x)
decConvâTerm-ne-ins () (Ρ-eq xâ xâ xâ xâ xâ
)
decConvâTerm-ne-ins () (Unit-ins x)
decConvâTerm-ne-ins () (Σʡ-ins x xâ xâ)
decConvâTerm-ne-ins () (prod-cong _ _ _ _ _)
decConvâTerm-ne-ins () (ÎŁ-Ρ x xâ xâ xâ xâ xâ
)
decConvâTerm-ne-ins () (Ρ-unit _ _ _ _ _)
decConvâTerm-ne-ins () (starʡ-refl _ _ _)
decConvâTerm-ne-ins () (Id-ins _ _)
decConvâTerm-ne-ins () (rfl-refl _)
decConvâTerm-â : â {t u tâ˛}
â Π⢠t [convâ] u ⡠â
â Π⢠t ~ tⲠâ â
â ÂŹ (Π⢠t ~ u â â)
â âĽ
decConvâTerm-â (â-ins x) t~t ÂŹu~u = ÂŹu~u x
decConvâTerm-â (ne-ins x xâ () xâ) t~t ÂŹu~u
decConvâTerm-â (zero-refl x) ([~] _ _ ()) ÂŹu~u
decConvâTerm-â (suc-cong x) ([~] _ _ ()) ÂŹu~u
decConvâTerm-Σʡ : â {t u tⲠF G FⲠGâ˛}
â Π⢠t [convâ] u ⡠Σʡ p , q ⡠F âš G
â Π⢠t ~ tⲠâ Σʡ pⲠ, qⲠ⡠FⲠ⚠Gâ˛
â (â {B} â ÂŹ (Π⢠t ~ u â B))
â âĽ
decConvâTerm-Σʡ (Σʡ-ins x xâ xâ) t~t ÂŹu~u = ÂŹu~u xâ
decConvâTerm-Σʡ (prod-cong _ _ _ _ _) ()
decConvâTerm-Σʡ (ne-ins x xâ () xâ) t~t ÂŹu~u
decConvâTerm-Unit : â {t tâ˛}
â Π⢠t [convâ] starʡ ⡠Unitʡ
â Π⢠t ~ tⲠâ Unitʡ
â Unitʡ-Ρ
decConvâTerm-Unit (Unit-ins ()) ([~] _ _ k~l)
decConvâTerm-Unit (Ρ-unit _ _ _ _ (injâ ())) ([~] _ _ _)
decConvâTerm-Unit (Ρ-unit _ _ _ _ (injâ Ρ)) ([~] _ _ _) = Ρ
decConvâTerm-Unit (ne-ins x xâ () xâ) ([~] _ _ k~l)
decConvâTerm-Unit (starʡ-refl _ _ _) ()
decConvâTerm-ÎŁ-Ρ : â {t u F G}
â Π⢠t ⡠Σ p , q ⡠F âš G
â Π⢠u ⡠Σ p , q ⡠F âš G
â Product t
â Product u
â Π⢠fst p t [convâ] fst p u ⡠F
â Dec (Π⢠snd p t [convâ] snd p u ⡠G [ fst p t ]â)
â Dec (Π⢠t [convâ] u ⡠Σ p , q ⡠F âš G)
decConvâTerm-ÎŁ-Ρ â˘t â˘u tProd uProd fstConv (yes Q) =
yes (ÎŁ-Ρ â˘t â˘u tProd uProd fstConv Q)
decConvâTerm-ÎŁ-Ρ â˘t â˘u tProd uProd fstConv (no ÂŹQ) =
no (Îť {(ÎŁ-Ρ _ _ _ _ _ Q) â ÂŹQ Q})
dec~â-prodrec :
â {F G C E t tⲠu v FⲠGⲠqâł} â
Dec (Î â (Σʡ p , q ⡠F âš G) ⢠C [convâ] E) â
(Î â (Σʡ p , q ⡠F âš G) ⢠C ⥠E â
Dec (Î â F â G ⢠u [convâ] v âˇ
C [ prodʡ p (var x1) (var x0) ]â²)) â
Π⢠t ~ tⲠâ Σʡ p , q ⡠FⲠ⚠GⲠâ
Π⢠Σʡ p , q ⡠F âš G ⥠Σʡ p , q ⡠FⲠ⚠GⲠâ
p PE.⥠pⲠâ
qⲠPE.⥠qâł â
r PE.⥠rⲠâ
Dec (â Îť B â Π⢠prodrec r p qⲠC t u ~ prodrec rⲠpⲠqâł E tⲠv â B)
dec~â-prodrec (yes C<>E) u<?>v t~tⲠâ˘ÎŁâĄÎŁâ˛ pâĄpⲠqâĄqⲠrâĄrⲠ=
case u<?>v (soundnessConvâ C<>E) of Îť where
(yes u<>v) â case pâĄpⲠof Îť where
PE.refl â case qâĄqⲠof Îť where
PE.refl â case râĄrⲠof Îť where
PE.refl â case reflConEq (wfEq â˘ÎŁâĄÎŁâ˛) of Îť â˘ÎâĄÎ â
case stabilityConvâ (â˘ÎâĄÎ â â˘ÎŁâĄÎŁâ˛) C<>E of Îť C<>EⲠâ
case ÎŁ-injectivity â˘ÎŁâĄÎŁâ˛ of Îť (â˘FâĄFⲠ, â˘GâĄGⲠ, _) â
case stabilityConvâTerm (â˘ÎâĄÎ â â˘FâĄFⲠâ â˘GâĄGâ˛) u<>v of Îť u<>vⲠâ
yes (_ , prodrec-cong C<>EⲠt~tⲠu<>vâ˛)
(no ÂŹu<>v) â no Îť where
(_ , prodrec-cong x xâ xâ) â
case syntacticEqTerm (soundness~â t~tâ˛) of Îť (_ , â˘t , _) â
case syntacticEqTerm (soundness~â xâ) of Îť (_ , â˘tâ , _) â
case ne~â t~tⲠof Îť (_ , neT , _) â
case neTypeEq neT â˘tâ â˘t of Îť â˘ÎŁâłâĄÎŁâ˛ â
case reflConEq (wfEq â˘ÎŁâłâĄÎŁâ˛) of Îť â˘ÎâĄÎ â
case ÎŁ-injectivity (trans â˘ÎŁâłâĄÎŁâ˛ (sym â˘ÎŁâĄÎŁâ˛)) of Îť (â˘FâłâĄF , â˘GâłâĄG , _) â
ÂŹu<>v (stabilityConvâTerm (â˘ÎâĄÎ â â˘FâłâĄF â â˘GâłâĄG) xâ)
dec~â-prodrec (no ÂŹC<>E) u<?>v t~tⲠâ˘ÎŁâĄÎŁâ˛ _ _ _ = no Îť where
(_ , prodrec-cong x xâ xâ) â
case syntacticEqTerm (soundness~â t~tâ˛) of Îť (_ , â˘t , _) â
case syntacticEqTerm (soundness~â xâ) of Îť (_ , â˘tâ , _) â
case ne~â t~tⲠof Îť (_ , neT , _) â
case neTypeEq neT â˘tâ â˘t of Îť â˘ÎŁâłâĄÎŁâ˛ â
case reflConEq (wfEq â˘ÎŁâłâĄÎŁâ˛) of Îť â˘ÎâĄÎ â
ÂŹC<>E (stabilityConvâ (â˘ÎâĄÎ â trans â˘ÎŁâłâĄÎŁâ˛ (sym â˘ÎŁâĄÎŁâ˛)) x)
dec~â-var : â {k kⲠA}
â (x : Fin _)
â Π⢠k ~ kⲠâ A
â Dec (â Îť B â Π⢠var x ~ k â B)
dec~â-var x (var-refl {x = y} xâ xâ) with x ââą˝ y
... | yes PE.refl = yes (_ , var-refl xâ PE.refl)
... | no ÂŹp = no Îť { (_ , var-refl x xâ) â ÂŹp xâ}
dec~â-var x (app-cong _ _) = no Îť { (_ , ())}
dec~â-var x (fst-cong _) = no Îť { (_ , ())}
dec~â-var x (snd-cong _) = no Îť { (_ , ())}
dec~â-var x (natrec-cong _ _ _ _) = no Îť { (_ , ())}
dec~â-var x (prodrec-cong _ _ _) = no Îť { (_ , ())}
dec~â-var x (emptyrec-cong _ _) = no Îť { (_ , ())}
dec~â-var x (unitrec-cong _ _ _ _) = no Îť { (_ , ())}
dec~â-var _ (J-cong _ _ _ _ _ _ _) = no Îť { (_ , ()) }
dec~â-var _ (K-cong _ _ _ _ _ _ _) = no Îť { (_ , ()) }
dec~â-var _ ([]-cong-cong _ _ _ _ _ _) = no Îť { (_ , ()) }
dec~â-appⲠ: â {k l lⲠa A F G}
â Π⢠l ~ lⲠâ A
â (â {l lⲠB} â Π⢠l ~ lⲠâ B â Dec (â Îť C â Π⢠k ~ l â C))
â (â {FⲠu uâ˛} â Π⢠F ⥠FⲠâ Π⢠u [convâ] uⲠ⡠Fâ˛
â Dec (Π⢠a [convâ] u ⡠F))
â Π⢠k ⡠Πp , q ⡠F âš G
â p PE.⥠pâ
â Dec (â Îť C â Π⢠k â⨠pâ ⊠a ~ l â C)
dec~â-appⲠ(app-cong x xâ) dec decⲠâ˘lâ pâĄpâ with dec x
... | no ÂŹp = no Îť{ (_ , app-cong x xâ) â ÂŹp (_ , x)}
dec~â-appⲠ(app-cong x xâ) _ decⲠâ˘lâ PE.refl | yes (C , k~l) =
let whnfA , neK , neL = ne~â k~l
â˘A , â˘k , â˘l = syntacticEqTerm (soundness~â k~l)
_ , â˘lâ , _ = syntacticEqTerm (soundness~â x)
Î FGâĄA = neTypeEq neK â˘lâ â˘k
Î Fâ˛Gâ˛âĄA = neTypeEq neL â˘lâ â˘l
in
case injectivity (trans Î FGâĄA (sym Î Fâ˛Gâ˛âĄA)) of Îť {
(FâĄFⲠ, GâĄGⲠ, PE.refl , _) â
case conv â˘lâ (trans Î Fâ˛Gâ˛âĄA (sym Î FGâĄA)) of Îť {
â˘lâⲠâ
dec~â-app â˘lâ â˘lâⲠk~l PE.refl (decⲠFâĄFⲠxâ) }}
dec~â-appⲠ(var-refl x xâ) _ _ _ _ = no Îť { (_ , ())}
dec~â-appⲠ(fst-cong x) _ _ _ _ = no Îť { (_ , ())}
dec~â-appⲠ(snd-cong x) _ _ _ _ = no Îť { (_ , ())}
dec~â-appⲠ(natrec-cong x xâ xâ xâ) _ _ _ _ = no Îť { (_ , ())}
dec~â-appⲠ(prodrec-cong x xâ xâ) _ _ _ _ = no Îť { (_ , ())}
dec~â-appⲠ(emptyrec-cong x xâ) _ _ _ _ = no Îť { (_ , ())}
dec~â-appⲠ(unitrec-cong _ _ _ _) _ _ _ _ = no Îť { (_ , ())}
dec~â-appⲠ(J-cong _ _ _ _ _ _ _) _ _ _ _ = no Îť { (_ , ()) }
dec~â-appⲠ(K-cong _ _ _ _ _ _ _) _ _ _ _ = no Îť { (_ , ()) }
dec~â-appⲠ([]-cong-cong _ _ _ _ _ _) _ _ _ _ = no Îť { (_ , ()) }
dec~â-fst :
Π⢠k ~ kⲠâ Σˢ p , q ⡠F âš G â
(â {l lⲠB} â Π⢠l ~ lⲠâ B â Dec (â Îť A â Π⢠k ~ l â A)) â
Π⢠l ~ lⲠâ B â
Dec (â Îť A â Π⢠fst p k ~ l â A)
dec~â-fst k~k dec (fst-cong l~l) with dec l~l
... | yes (A , k~l) =
case ne~â k~l of Îť (whnfA , neK , neL) â
case syntacticEqTerm (soundness~â k~l) of Îť (â˘A , â˘k , â˘l) â
case syntacticEqTerm (soundness~â k~k) of Îť (_ , â˘kâ , _) â
case syntacticEqTerm (soundness~â l~l) of Îť (_ , â˘lâ , _) â
case neTypeEq neK â˘kâ â˘k of Îť ÎŁFGâĄA â
case neTypeEq neL â˘lâ â˘l of Îť ÎŁFâ˛Gâ˛âĄA â
case ÎŁâĄA ÎŁFGâĄA whnfA of Îť where
(F , _ , PE.refl) â
case ÎŁ-injectivity ÎŁFâ˛Gâ˛âĄA of Îť where
(_ , _ , PE.refl , _ , _) â
yes (F , fst-cong k~l)
... | no ÂŹp = no (Îť { (_ , fst-cong x) â ÂŹp (_ , x) })
dec~â-fst _ _ (var-refl _ _) = no Îť { (_ , ()) }
dec~â-fst _ _ (app-cong _ _) = no Îť { (_ , ()) }
dec~â-fst _ _ (snd-cong _) = no Îť { (_ , ()) }
dec~â-fst _ _ (natrec-cong _ _ _ _) = no Îť { (_ , ()) }
dec~â-fst _ _ (prodrec-cong _ _ _) = no Îť { (_ , ()) }
dec~â-fst _ _ (emptyrec-cong _ _) = no Îť { (_ , ()) }
dec~â-fst _ _ (unitrec-cong _ _ _ _) = no Îť { (_ , ()) }
dec~â-fst _ _ (J-cong _ _ _ _ _ _ _) = no Îť { (_ , ()) }
dec~â-fst _ _ (K-cong _ _ _ _ _ _ _) = no Îť { (_ , ()) }
dec~â-fst _ _ ([]-cong-cong _ _ _ _ _ _) = no Îť { (_ , ()) }
dec~â-snd :
Π⢠k ~ kⲠâ Σˢ p , q ⡠F âš G â
(â {l lⲠB} â Π⢠l ~ lⲠâ B â Dec (â Îť A â Π⢠k ~ l â A)) â
Π⢠l ~ lⲠâ B â
Dec (â Îť A â Π⢠snd p k ~ l â A)
dec~â-snd {k = k} k~k dec (snd-cong l~l) with dec l~l
... | yes (A , k~l) =
case ne~â k~l of Îť (whnfA , neK , neL) â
case syntacticEqTerm (soundness~â k~l) of Îť (â˘A , â˘k , â˘l) â
case syntacticEqTerm (soundness~â k~k) of Îť (_ , â˘kâ , _) â
case syntacticEqTerm (soundness~â l~l) of Îť (_ , â˘lâ , _) â
case neTypeEq neK â˘kâ â˘k of Îť ÎŁFGâĄA â
case neTypeEq neL â˘lâ â˘l of Îť ÎŁFâ˛Gâ˛âĄA â
case ÎŁâĄA ÎŁFGâĄA whnfA of Îť where
(_ , G , PE.refl) â
case ÎŁ-injectivity ÎŁFâ˛Gâ˛âĄA of Îť where
(_ , _ , PE.refl , _ , _) â
yes (G [ fst _ k ]â , snd-cong k~l)
... | no ÂŹp = no (Îť { (_ , snd-cong xâ) â ÂŹp (_ , xâ) })
dec~â-snd _ _ (var-refl _ _) = no Îť { (_ , ()) }
dec~â-snd _ _ (app-cong _ _) = no Îť { (_ , ()) }
dec~â-snd _ _ (fst-cong _) = no Îť { (_ , ()) }
dec~â-snd _ _ (natrec-cong _ _ _ _) = no Îť { (_ , ()) }
dec~â-snd _ _ (prodrec-cong _ _ _) = no Îť { (_ , ()) }
dec~â-snd _ _ (emptyrec-cong _ _) = no Îť { (_ , ()) }
dec~â-snd _ _ (unitrec-cong _ _ _ _) = no Îť { (_ , ()) }
dec~â-snd _ _ (J-cong _ _ _ _ _ _ _) = no Îť { (_ , ()) }
dec~â-snd _ _ (K-cong _ _ _ _ _ _ _) = no Îť { (_ , ()) }
dec~â-snd _ _ ([]-cong-cong _ _ _ _ _ _) = no Îť { (_ , ()) }
dec~â-natrec : â {l lⲠA C z s n}
â Π⢠l ~ lⲠâ A
â ⢠Î
â (â {CⲠCâł} â Î â â ⢠CⲠ[convâ] Câł â Dec (Î â â ⢠C [convâ] Câ˛))
â (â {t tⲠCâ˛} â Π⢠C [ zero ]â ⥠CⲠâ Π⢠t [convâ] tⲠ⡠CⲠâ Dec (Π⢠z [convâ] t ⡠C [ zero ]â))
â (â {t tⲠCâ˛} â Î â â â C ⢠C [ suc (var x1) ]â² ⥠CⲠâ Î â â â C ⢠t [convâ] tⲠ⡠Câ˛
â Dec (Î â â â C ⢠s [convâ] t ⡠C [ suc (var x1) ]â²))
â (â {t tⲠCâ˛} â Π⢠t ~ tⲠâ CⲠâ Dec (â Îť B â Π⢠n ~ t â B))
â Dec (â Îť B â Π⢠natrec p q r C z s n ~ l â B)
dec~â-natrec {p = p} {q = q} {r = r}
(natrec-cong {p = pâ˛} {q = qâ˛} {r = râ˛} x xâ xâ xâ)
â˘Î decC decZ decS decN
with decC x | decN xâ | p â pⲠ| q â qⲠ| r â râ˛
... | _ | _ | _ | _ | no râ˘rⲠ= no Îť {(_ , natrec-cong _ _ _ _) â râ˘rⲠPE.refl}
... | _ | _ | _ | no qâ˘qⲠ| _ = no Îť {(_ , natrec-cong _ _ _ _) â qâ˘qⲠPE.refl}
... | _ | _ | no pâ˘pⲠ| _ | _ = no Îť {(_ , natrec-cong _ _ _ _) â pâ˘pⲠPE.refl}
... | _ | no ÂŹP | _ | _ | _ = no Îť {(_ , natrec-cong _ _ _ x) â ÂŹP (_ , x)}
... | no ÂŹP | _ | _ | _ | _ = no Îť {(_ , natrec-cong x _ _ _) â ÂŹP x}
... | yes C<>CⲠ| yes (B , n~nâ˛) | yes _ | yes _ | yes _
with decZ (substTypeEq (soundnessConvâ C<>Câ˛) (refl (zeroâąź â˘Î))) xâ
| decS (sucCong (soundnessConvâ C<>Câ˛))
(stabilityConvâTerm ((reflConEq (â˘Î â ââąź â˘Î)) â (sym (soundnessConvâ C<>Câ˛))) xâ)
... | _ | no ÂŹP = no Îť {(_ , natrec-cong _ _ x _) â ÂŹP x}
... | no ÂŹP | _ = no Îť {(_ , natrec-cong _ x _ _) â ÂŹP x}
dec~â-natrec (natrec-cong _ _ _ xâ) _ _ _ _ _
| yes C<>CⲠ| yes (B , n~nâ˛) | yes PE.refl | yes PE.refl | yes PE.refl
| yes z<>zⲠ| yes s<>sⲠ=
let whnfA , neN , neNⲠ= ne~â n~nâ˛
â˘A , â˘n , â˘nⲠ= syntacticEqTerm (soundness~â n~nâ˛)
_ , â˘nâ˛âˇâ , _ = syntacticEqTerm (soundness~â xâ)
â˘ââĄA = neTypeEq neNⲠâ˘nâ˛âˇâ â˘nâ˛
AâĄâ = ââĄA â˘ââĄA whnfA
n~nâł = PE.subst (Îť x â _ ⢠_ ~ _ â x) AâĄâ n~nâ˛
in yes (_ , natrec-cong C<>CⲠz<>zⲠs<>sⲠn~nâł)
dec~â-natrec (var-refl _ _) _ _ _ _ _ = no Îť {(_ , ())}
dec~â-natrec (app-cong _ _) _ _ _ _ _ = no Îť {(_ , ())}
dec~â-natrec (fst-cong _) _ _ _ _ _ = no Îť {(_ , ())}
dec~â-natrec (snd-cong _) _ _ _ _ _ = no Îť {(_ , ())}
dec~â-natrec (prodrec-cong _ _ _) _ _ _ _ _ = no Îť {(_ , ())}
dec~â-natrec (emptyrec-cong _ _) _ _ _ _ _ = no Îť {(_ , ())}
dec~â-natrec (unitrec-cong _ _ _ _) _ _ _ _ _ = no Îť {(_ , ())}
dec~â-natrec (J-cong _ _ _ _ _ _ _) _ _ _ _ _ = no Îť {(_ , ())}
dec~â-natrec (K-cong _ _ _ _ _ _ _) _ _ _ _ _ = no Îť {(_ , ())}
dec~â-natrec ([]-cong-cong _ _ _ _ _ _) _ _ _ _ _ = no Îť {(_ , ())}
mutual
dec~â : â {k l R T kⲠlâ˛}
â Π⢠k ~ kⲠâ R â Π⢠l ~ lⲠâ T
â Dec (â Îť A â Π⢠k ~ l â A)
dec~â (var-refl x xâ) y = dec~â-var _ y
dec~â (app-cong x xâ) y =
dec~â-appⲠy (dec~â x) (Îť FâĄFⲠâ decConvâTermConv FâĄFⲠxâ)
(projâ (projâ (syntacticEqTerm (soundness~â x)))) PE.refl
dec~â (fst-cong k~k) l~l =
dec~â-fst k~k (dec~â k~k) l~l
dec~â (snd-cong k~k) l~l =
dec~â-snd k~k (dec~â k~k) l~l
dec~â (natrec-cong x xâ xâ xâ) y =
dec~â-natrec y (wfEqTerm (soundness~â y)) (decConvâ x)
(Îť z â decConvâTermConv z xâ)
(Îť z â decConvâTermConv z xâ) (dec~â xâ)
dec~â (unitrec-cong {p = p} {q = q} x xâ xâ no-Ρ)
(unitrec-cong {p = pâ˛} {q = qâ˛} xâ xâ xâ
_) =
case dec~â xâ xâ of Îť where
(no ÂŹp) â no Îť{ (_ , unitrec-cong x xâ xâ _) â ÂŹp (_ , xâ)}
(yes (A , k~kâ˛)) â case (decConvâ x xâ) of Îť where
(no ÂŹp) â no Îť{ (_ , unitrec-cong x xâ xâ _) â ÂŹp x}
(yes F<>Fâ˛) â
let FâĄFⲠ= soundnessConvâ F<>Fâ˛
kâĄl = soundness~â xâ
â˘Unit , â˘k , _ = syntacticEqTerm kâĄl
ok = inversion-Unit â˘Unit
â˘Î = wf â˘Unit
FââĄFâ˛â = substTypeEq FâĄFⲠ(refl (starâąź â˘Î ok))
_ , â˘kⲠ, _ = syntacticEqTerm (soundness~â k~kâ˛)
whA , neK , _ = ne~â k~kâ˛
AâĄUnit = neTypeEq neK â˘k â˘kâ˛
k~kâł = PE.subst (Îť x â _ ⢠_ ~ _ â x)
(UnitâĄA AâĄUnit whA)
k~kâ˛
in case (decConvâTerm xâ (convConvâTerm (reflConEq â˘Î) (sym FââĄFâ˛â) xâ
)) of Îť where
(no ÂŹp) â no Îť{ (_ , unitrec-cong x xâ xâ _) â ÂŹp xâ}
(yes u<>uâ˛) â case p â pⲠof Îť where
(no pâpâ˛) â
no Îť { (_ , unitrec-cong x xâ xâ _) â pâpⲠPE.refl }
(yes pâpâ˛) â case q â qⲠof Îť where
(no qâqâ˛) â
no Îť { (_ , unitrec-cong x xâ xâ _) â qâqⲠPE.refl }
(yes PE.refl) â case pâpⲠof Îť where
PE.refl â yes (_ , unitrec-cong F<>FⲠk~kâł u<>uⲠno-Ρ)
dec~â
(prodrec-cong {p = p} {r = r} {qⲠ= q} x xâ xâ)
(prodrec-cong {p = pâ˛} {r = râ˛} {qⲠ= qâ˛} xâ xâ xâ
)
with dec~â xâ xâ | r â rⲠ| p â pⲠ| q â qâ˛
... | yes (B , t~tâ˛) | yes PE.refl | yes PE.refl | yes PE.refl =
case ne~â t~tⲠof Îť (whnfB , neT , neTâ˛) â
case syntacticEqTerm (soundness~â t~tâ˛) of Îť (â˘B , â˘t , â˘tâ˛) â
case syntacticEqTerm (soundness~â xâ) of Îť (â˘ÎŁ , â˘tâ , â˘w) â
case syntacticEqTerm (soundness~â xâ) of Îť (â˘ÎŁâ˛ , â˘tâ˛â , â˘wâ˛) â
case neTypeEq neT â˘t â˘tâ of Îť â˘BâĄÎŁ â
case neTypeEq neTⲠâ˘tⲠâ˘tâ˛â of Îť â˘BâĄÎŁâ˛ â
case ÎŁâĄA (sym â˘BâĄÎŁ) whnfB of Îť where
(_ , _ , PE.refl) â
case trans (sym â˘BâĄÎŁâ˛) â˘BâĄÎŁ of Îť â˘ÎŁâ˛âĄÎŁ â
case ÎŁ-injectivity â˘ÎŁâ˛âĄÎŁ of Îť where
(â˘Fâ˛âĄF , â˘Gâ˛âĄG , _ , PE.refl , _) â case ÎŁ-injectivity â˘BâĄÎŁâ˛ of Îť where
(â˘Fâ˛âĄFâł , _ , _ , _ , _) â
case reflConEq (wf â˘B) of Îť â˘ÎâĄÎ â
dec~â-prodrec
(decConvâ x (stabilityConvâ (â˘ÎâĄÎ â â˘ÎŁâ˛âĄÎŁ) xâ))
(Îť CâĄCⲠâ decConvâTermConv
(substâ²TypeEq-prod CâĄCⲠ(â˘âˇÎ ÎŁâÎ ÎŁ-allowed â˘tâ))
xâ
(stabilityConvâTerm (â˘ÎâĄÎ â â˘Fâ˛âĄF â â˘Gâ˛âĄG) xâ
))
t~tⲠ(sym â˘BâĄÎŁ) PE.refl PE.refl PE.refl
... | no ÂŹP | _ | _ | _ =
no (Îť { (_ , prodrec-cong _ x _) â ÂŹP (_ , x) })
... | _ | no ÂŹrâĄrⲠ| _ | _ =
no (Îť { (_ , prodrec-cong _ _ _) â ÂŹrâĄrⲠPE.refl })
... | _ | _ | no ÂŹpâĄpⲠ| _ =
no (Îť { (_ , prodrec-cong _ _ _) â ÂŹpâĄpⲠPE.refl })
... | _ | _ | _ | no ÂŹqâĄqⲠ=
no (Îť { (_ , prodrec-cong _ _ _) â ÂŹqâĄqⲠPE.refl })
dec~â (prodrec-cong _ _ _) (var-refl _ _) = no Îť { (_ , ()) }
dec~â (prodrec-cong _ _ _) (app-cong _ _) = no Îť { (_ , ()) }
dec~â (prodrec-cong _ _ _) (fst-cong _) = no Îť { (_ , ()) }
dec~â (prodrec-cong _ _ _) (snd-cong _) = no Îť { (_ , ()) }
dec~â (prodrec-cong _ _ _) (natrec-cong _ _ _ _) = no Îť { (_ , ()) }
dec~â (prodrec-cong _ _ _) (emptyrec-cong _ _) = no Îť { (_ , ()) }
dec~â (prodrec-cong _ _ _) (unitrec-cong _ _ _ _) = no Îť{(_ , ())}
dec~â (prodrec-cong _ _ _) (J-cong _ _ _ _ _ _ _) = no Îť { (_ , ()) }
dec~â (prodrec-cong _ _ _) (K-cong _ _ _ _ _ _ _) = no Îť { (_ , ()) }
dec~â (prodrec-cong _ _ _) ([]-cong-cong _ _ _ _ _ _) =
no Îť { (_ , ()) }
dec~â (emptyrec-cong {p = pâ˛} x xâ) (emptyrec-cong {p = pâł} xâ xâ
)
with decConvâ x xâ | dec~â xâ xâ
| pⲠâ pâł
... | yes p | yes (A , k~l) | yes PE.refl =
let whnfA , neK , neL = ne~â k~l
â˘A , â˘k , â˘l = syntacticEqTerm (soundness~â k~l)
_ , â˘lâˇEmpty , _ = syntacticEqTerm (soundness~â xâ)
â˘EmptyâĄA = neTypeEq neK â˘lâˇEmpty â˘k
AâĄEmpty = EmptyâĄA â˘EmptyâĄA whnfA
k~lⲠ= PE.subst (Îť x â _ ⢠_ ~ _ â x) AâĄEmpty k~l
in yes (_ , emptyrec-cong p k~lâ˛)
... | yes p | yes (A , k~l) | no ÂŹpâ˛âĄpâł =
no (Îť { (_ , emptyrec-cong _ _) â ÂŹpâ˛âĄpâł PE.refl })
... | yes p | no ÂŹp | _ =
no (Îť { (_ , emptyrec-cong _ b) â ÂŹp (_ , b) })
... | no ÂŹp | r | _ = no (Îť { (_ , emptyrec-cong a _) â ÂŹp a })
dec~â (emptyrec-cong _ _) (var-refl _ _) = no (Îť { (_ , ()) })
dec~â (emptyrec-cong _ _) (fst-cong _) = no (Îť { (_ , ()) })
dec~â (emptyrec-cong _ _) (snd-cong _) = no (Îť { (_ , ()) })
dec~â (emptyrec-cong _ _) (app-cong _ _) = no (Îť { (_ , ()) })
dec~â (emptyrec-cong _ _) (natrec-cong _ _ _ _) = no (Îť { (_ , ()) })
dec~â (emptyrec-cong _ _) (prodrec-cong _ _ _) = no Îť{(_ , ())}
dec~â (emptyrec-cong _ _) (unitrec-cong _ _ _ _) = no Îť{(_ , ())}
dec~â (emptyrec-cong _ _) (J-cong _ _ _ _ _ _ _) = no Îť { (_ , ()) }
dec~â (emptyrec-cong _ _) (K-cong _ _ _ _ _ _ _) = no Îť { (_ , ()) }
dec~â (emptyrec-cong _ _) ([]-cong-cong _ _ _ _ _ _) =
no Îť { (_ , ()) }
dec~â (unitrec-cong _ _ _ _) (var-refl _ _) = no Îť{(_ , ())}
dec~â (unitrec-cong _ _ _ _) (app-cong _ _) = no Îť{(_ , ())}
dec~â (unitrec-cong _ _ _ _) (fst-cong _) = no Îť{(_ , ())}
dec~â (unitrec-cong _ _ _ _) (snd-cong _) = no Îť{(_ , ())}
dec~â (unitrec-cong _ _ _ _) (natrec-cong _ _ _ _) = no Îť{(_ , ())}
dec~â (unitrec-cong _ _ _ _) (prodrec-cong _ _ _) = no Îť{(_ , ())}
dec~â (unitrec-cong _ _ _ _) (emptyrec-cong _ _) = no Îť{(_ , ())}
dec~â (unitrec-cong _ _ _ _) (J-cong _ _ _ _ _ _ _) = no Îť { (_ , ()) }
dec~â (unitrec-cong _ _ _ _) (K-cong _ _ _ _ _ _ _) = no Îť { (_ , ()) }
dec~â (unitrec-cong _ _ _ _) ([]-cong-cong _ _ _ _ _ _) =
no Îť { (_ , ()) }
dec~â
(J-cong {p = pâ} {q = qâ} AââĄAâ tââĄtâ BââĄBâ uââĄuâ vââĄvâ wâ~wâ
CââĄId-tâ-vâ)
(J-cong {p = pâ} {q = qâ} AââĄAâ tââĄtâ BââĄBâ uââĄuâ vââĄvâ wâ~wâ _) =
case pâ â pâ of Îť {
(no pââ˘pâ) â no $
pââ˘pâ ââ projâ ââ projâ ââ J-congâťÂš ââ projâ
; (yes PE.refl) â
case qâ â qâ of Îť {
(no qââ˘qâ) â no $
qââ˘qâ ââ projâ ââ projâ ââ projâ ââ J-congâťÂš ââ projâ
; (yes PE.refl) â
case decConvâ AââĄAâ AââĄAâ of Îť {
(no Aââ˘Aâ) â no $
Aââ˘Aâ ââ projâ ââ projâ ââ projâ ââ projâ ââ J-congâťÂš ââ projâ
; (yes AââĄAâ) â
case soundnessConvâ AââĄAâ of Îť {
â˘AââĄAâ â
case decConvâTermConv â˘AââĄAâ tââĄtâ tââĄtâ of Îť {
(no tââ˘tâ) â no $
tââ˘tâ ââ projâ ââ projâ ââ projâ ââ projâ ââ projâ ââ
J-congâťÂš ââ projâ
; (yes tââĄtâ) â
case soundnessConvâTerm tââĄtâ of Îť {
â˘tââĄtâ â
case decConvâⲠ(J-motive-context-congⲠâ˘AââĄAâ â˘tââĄtâ)
BââĄBâ BââĄBâ of Îť {
(no Bââ˘Bâ) â no $
Bââ˘Bâ ââ projâ ââ projâ ââ projâ ââ projâ ââ projâ ââ projâ ââ
J-congâťÂš ââ projâ
; (yes BââĄBâ) â
case decConvâTermConv
(J-motive-rfl-cong (soundnessConvâ BââĄBâ) â˘tââĄtâ)
uââĄuâ uââĄuâ of Îť {
(no uââ˘uâ) â no $
uââ˘uâ ââ projâ ââ projâ ââ projâ ââ projâ ââ projâ ââ projâ ââ
projâ ââ J-congâťÂš ââ projâ
; (yes uââĄuâ) â
case decConvâTermConv â˘AââĄAâ vââĄvâ vââĄvâ of Îť {
(no vââ˘vâ) â no $
vââ˘vâ ââ projâ ââ projâ ââ projâ ââ projâ ââ projâ ââ projâ ââ
projâ ââ projâ ââ J-congâťÂš ââ projâ
; (yes vââĄvâ) â
case dec~â wâ~wâ wâ~wâ of Îť {
(no ÂŹwâ~wâ) â no $
ÂŹwâ~wâ ââ (_ ,_) ââ projâ ââ projâ ââ projâ ââ projâ ââ projâ ââ
projâ ââ projâ ââ projâ ââ projâ ââ J-congâťÂš ââ projâ
; (yes (_ , wâ~wâ)) â
case neTypeEq (ne~â wâ~wâ .projâ .projâ)
(syntacticEqTerm (soundness~â wâ~wâ) .projâ .projâ)
(syntacticEqTerm (soundness~â wâ~wâ) .projâ .projâ) of Îť {
CââĄD â
yes
( _
, J-cong AââĄAâ tââĄtâ BââĄBâ uââĄuâ vââĄvâ wâ~wâ
(trans (sym CââĄD) CââĄId-tâ-vâ)
) }}}}}}}}}}}
dec~â (J-cong _ _ _ _ _ _ _) (var-refl _ _) = no (Îť { (_ , ()) })
dec~â (J-cong _ _ _ _ _ _ _) (fst-cong _) = no (Îť { (_ , ()) })
dec~â (J-cong _ _ _ _ _ _ _) (snd-cong _) = no (Îť { (_ , ()) })
dec~â (J-cong _ _ _ _ _ _ _) (app-cong _ _) = no (Îť { (_ , ()) })
dec~â (J-cong _ _ _ _ _ _ _) (natrec-cong _ _ _ _) = no (Îť { (_ , ()) })
dec~â (J-cong _ _ _ _ _ _ _) (prodrec-cong _ _ _) = no Îť{(_ , ())}
dec~â (J-cong _ _ _ _ _ _ _) (emptyrec-cong _ _) = no Îť { (_ , ()) }
dec~â (J-cong _ _ _ _ _ _ _) (unitrec-cong _ _ _ _) = no Îť { (_ , ()) }
dec~â (J-cong _ _ _ _ _ _ _) (K-cong _ _ _ _ _ _ _) = no Îť { (_ , ()) }
dec~â (J-cong _ _ _ _ _ _ _) ([]-cong-cong _ _ _ _ _ _) = no Îť { (_ , ()) }
dec~â (K-cong {p = pâ} AââĄAâ tââĄtâ BââĄBâ uââĄuâ vâ~vâ CââĄId-tâ-tâ ok)
(K-cong {p = pâ} AââĄAâ tââĄtâ BââĄBâ uââĄuâ vâ~vâ _ _) =
case pâ â pâ of Îť {
(no pââ˘pâ) â no $
pââ˘pâ ââ projâ ââ projâ ââ K-congâťÂš ââ projâ
; (yes PE.refl) â
case decConvâ AââĄAâ AââĄAâ of Îť {
(no Aââ˘Aâ) â no $
Aââ˘Aâ ââ projâ ââ projâ ââ projâ ââ K-congâťÂš ââ projâ
; (yes AââĄAâ) â
case soundnessConvâ AââĄAâ of Îť {
â˘AââĄAâ â
case decConvâTermConv â˘AââĄAâ tââĄtâ tââĄtâ of Îť {
(no tââ˘tâ) â no $
tââ˘tâ ââ projâ ââ projâ ââ projâ ââ projâ ââ K-congâťÂš ââ projâ
; (yes tââĄtâ) â
case decConvââ˛
(K-motive-context-congⲠâ˘AââĄAâ (soundnessConvâTerm tââĄtâ))
BââĄBâ BââĄBâ of Îť {
(no Bââ˘Bâ) â no $
Bââ˘Bâ ââ projâ ââ projâ ââ projâ ââ projâ ââ projâ ââ
K-congâťÂš ââ projâ
; (yes BââĄBâ) â
case decConvâTermConv (K-motive-rfl-cong (soundnessConvâ BââĄBâ))
uââĄuâ uââĄuâ of Îť {
(no uââ˘uâ) â no $
uââ˘uâ ââ projâ ââ projâ ââ projâ ââ projâ ââ projâ ââ projâ ââ
K-congâťÂš ââ projâ
; (yes uââĄuâ) â
case dec~â vâ~vâ vâ~vâ of Îť {
(no ÂŹvâ~vâ) â no $
ÂŹvâ~vâ ââ (_ ,_) ââ projâ ââ projâ ââ projâ ââ projâ ââ projâ ââ
projâ ââ projâ ââ K-congâťÂš ââ projâ
; (yes (_ , vâ~vâ)) â
case neTypeEq (ne~â vâ~vâ .projâ .projâ)
(syntacticEqTerm (soundness~â vâ~vâ) .projâ .projâ)
(syntacticEqTerm (soundness~â vâ~vâ) .projâ .projâ) of Îť {
CââĄD â
yes
( _
, K-cong AââĄAâ tââĄtâ BââĄBâ uââĄuâ vâ~vâ
(trans (sym CââĄD) CââĄId-tâ-tâ) ok
) }}}}}}}}
dec~â (K-cong _ _ _ _ _ _ _) (var-refl _ _) = no (Îť { (_ , ()) })
dec~â (K-cong _ _ _ _ _ _ _) (fst-cong _) = no (Îť { (_ , ()) })
dec~â (K-cong _ _ _ _ _ _ _) (snd-cong _) = no (Îť { (_ , ()) })
dec~â (K-cong _ _ _ _ _ _ _) (app-cong _ _) = no (Îť { (_ , ()) })
dec~â (K-cong _ _ _ _ _ _ _) (natrec-cong _ _ _ _) = no (Îť { (_ , ()) })
dec~â (K-cong _ _ _ _ _ _ _) (prodrec-cong _ _ _) = no Îť{(_ , ())}
dec~â (K-cong _ _ _ _ _ _ _) (emptyrec-cong _ _) = no Îť { (_ , ()) }
dec~â (K-cong _ _ _ _ _ _ _) (unitrec-cong _ _ _ _) = no Îť { (_ , ()) }
dec~â (K-cong _ _ _ _ _ _ _) (J-cong _ _ _ _ _ _ _) = no Îť { (_ , ()) }
dec~â (K-cong _ _ _ _ _ _ _) ([]-cong-cong _ _ _ _ _ _) = no Îť { (_ , ()) }
dec~â ([]-cong-cong {s = s} AââĄAâ tââĄtâ uââĄuâ vâ~vâ BââĄId-tâ-uâ ok)
([]-cong-cong {s = sâ˛} AââĄAâ tââĄtâ uââĄuâ vâ~vâ _ _) =
case decConvâ AââĄAâ AââĄAâ of Îť where
(no Aââ˘Aâ) â no Îť where
(_ , []-cong-cong AââĄAâ _ _ _ _ _) â Aââ˘Aâ AââĄAâ
(yes AââĄAâ) â case decConvâTermConv (soundnessConvâ AââĄAâ)
tââĄtâ tââĄtâ of Îť where
(no tââ˘tâ) â no Îť where
(_ , []-cong-cong _ tââĄtâ _ _ _ _) â tââ˘tâ tââĄtâ
(yes tââĄtâ) â case decConvâTermConv (soundnessConvâ AââĄAâ)
uââĄuâ uââĄuâ of Îť where
(no uââ˘uâ) â no Îť where
(_ , []-cong-cong _ _ uââĄuâ _ _ _) â uââ˘uâ uââĄuâ
(yes uââĄuâ) â case dec~â vâ~vâ vâ~vâ of Îť where
(no ÂŹvâ~vâ) â no Îť where
(_ , []-cong-cong _ _ _ vâ~vâ _ _) â ÂŹvâ~vâ (_ , vâ~vâ)
(yes (_ , vâ~vâ)) â
case neTypeEq (ne~â vâ~vâ .projâ .projâ)
(syntacticEqTerm (soundness~â vâ~vâ) .projâ .projâ)
(syntacticEqTerm (soundness~â vâ~vâ)
.projâ .projâ) of Îť {
BââĄC â case decStrength s sⲠof Îť where
(yes PE.refl) â yes
( _
, []-cong-cong AââĄAâ tââĄtâ uââĄuâ vâ~vâ
(trans (sym BââĄC) BââĄId-tâ-uâ) ok
)
(no sâ˘s) â no Îť where
(_ , []-cong-cong _ _ _ _ _ _) â sâ˘s PE.refl }
dec~â ([]-cong-cong _ _ _ _ _ _) (var-refl _ _) = no (Îť { (_ , ()) })
dec~â ([]-cong-cong _ _ _ _ _ _) (fst-cong _) = no (Îť { (_ , ()) })
dec~â ([]-cong-cong _ _ _ _ _ _) (snd-cong _) = no (Îť { (_ , ()) })
dec~â ([]-cong-cong _ _ _ _ _ _) (app-cong _ _) = no (Îť { (_ , ()) })
dec~â ([]-cong-cong _ _ _ _ _ _) (natrec-cong _ _ _ _) = no (Îť { (_ , ()) })
dec~â ([]-cong-cong _ _ _ _ _ _) (prodrec-cong _ _ _) = no Îť{(_ , ())}
dec~â ([]-cong-cong _ _ _ _ _ _) (emptyrec-cong _ _) = no Îť { (_ , ()) }
dec~â ([]-cong-cong _ _ _ _ _ _) (unitrec-cong _ _ _ _) = no Îť { (_ , ()) }
dec~â ([]-cong-cong _ _ _ _ _ _) (J-cong _ _ _ _ _ _ _) = no Îť { (_ , ()) }
dec~â ([]-cong-cong _ _ _ _ _ _) (K-cong _ _ _ _ _ _ _) = no Îť { (_ , ()) }
dec~âⲠ: â {k l R T}
â ⢠Π⥠Î
â Π⢠k ~ k â R â Π⢠l ~ l â T
â Dec (â Îť A â Π⢠k ~ l â A)
dec~âⲠÎâĄÎ k~k l~l = dec~â k~k (stability~â (symConEq ÎâĄÎ) l~l)
dec~â : â {k l R T kⲠlâ˛}
â Π⢠k ~ kⲠâ R â Π⢠l ~ lⲠâ T
â Dec (â Îť A â Π⢠k ~ l â A)
dec~â ([~] _ _ k~l) ([~] _ _ k~lâ) with dec~â k~l k~lâ
dec~â ([~] _ _ k~l) ([~] _ _ k~lâ) | yes (B , k~lâ) =
let â˘B , _ , _ = syntacticEqTerm (soundness~â k~lâ)
C , whnfC , DⲠ= whNorm â˘B
in yes (C , [~] B (red DⲠ, whnfC) k~lâ)
dec~â ([~] _ _ k~l) ([~] _ _ k~lâ) | no ÂŹp =
no (Îť { (_ , [~] Aâ _ k~lâ) â ÂŹp (Aâ , k~lâ) })
decConvâ : â {A B AⲠBâ˛}
â Π⢠A [convâ] AⲠâ Π⢠B [convâ] Bâ˛
â Dec (Π⢠A [convâ] B)
decConvâ ([â] AⲠBⲠD DⲠAâ˛<>Bâ˛)
([â] Aâł Bâł Dâ Dâł Aâ˛<>Bâł)
with decConvâ Aâ˛<>BⲠAâ˛<>Bâł
decConvâ ([â] AⲠBⲠD DⲠAâ˛<>Bâ˛)
([â] Aâł Bâł Dâ Dâł Aâ˛<>Bâł) | yes p =
yes ([â] AⲠAâł D Dâ p)
decConvâ ([â] AⲠBⲠD DⲠAâ˛<>Bâ˛)
([â] Aâł Bâł Dâ Dâł Aâ˛<>Bâł) | no ÂŹp =
no (Îť { ([â] Aâ´ Bâ´ Dâ Dâ´ Aâ˛<>Bâ´) â
let Aâ´âĄBⲠ= whrDet* Dâ D
Bâ´âĄBâł = whrDet* Dâ´ Dâ
in ÂŹp (PE.substâ (Îť x y â _ ⢠x [convâ] y) Aâ´âĄBⲠBâ´âĄBâł Aâ˛<>Bâ´) })
decConvâⲠ: â {A B AⲠBâ˛}
â ⢠Π⥠Î
â Π⢠A [convâ] AⲠâ Π⢠B [convâ] Bâ˛
â Dec (Π⢠A [convâ] B)
decConvâⲠÎâĄÎ A B = decConvâ A (stabilityConvâ (symConEq ÎâĄÎ) B)
decConvâ : â {A B AⲠBâ˛}
â Π⢠A [convâ] AⲠâ Π⢠B [convâ] Bâ˛
â Dec (Π⢠A [convâ] B)
decConvâ (U-refl x) (U-refl xâ) = yes (U-refl x)
decConvâ (â-refl x) (â-refl xâ) = yes (â-refl x)
decConvâ (Empty-refl x) (Empty-refl xâ) = yes (Empty-refl x)
decConvâ (Unit-refl {s = s} x ok) (Unit-refl {s = sâ˛} _ _) =
case decStrength s sⲠof Ν where
(yes PE.refl) â yes (Unit-refl x ok)
(no sâ˘sâ˛) â no (Îť { (Unit-refl x xâ) â sâ˘sⲠPE.refl})
decConvâ (ne x) (ne xâ) with dec~â x xâ
decConvâ (ne x) (ne xâ) | yes (A , k~l) =
let whnfA , neK , neL = ne~â k~l
â˘A , â˘k , _ = syntacticEqTerm (soundness~â k~l)
_ , â˘kâˇU , _ = syntacticEqTerm (soundness~â x)
â˘UâĄA = neTypeEq neK â˘kâˇU â˘k
AâĄU = UâĄA â˘UâĄA
k~lⲠ= PE.subst (Îť x â _ ⢠_ ~ _ â x) AâĄU k~l
in yes (ne k~lâ˛)
decConvâ (ne x) (ne xâ) | no ÂŹp = no (Îť xâ â ÂŹp (U , (decConvâ-ne xâ x)))
decConvâ
(Î ÎŁ-cong {b = bâ} {p = pâ˛} {q = qâ˛} x xâ xâ ok)
(Î ÎŁ-cong {b = bâ} {p = pâł} {q = qâł} xâ xâ xâ
_)
with decConvâ xâ xâ
... | yes p
with decConvâⲠ(reflConEq (wf x) â soundnessConvâ p) xâ xâ
| pⲠâ pâł | qⲠâ qâł | decBinderMode bâ bâ
... | yes pâ | yes PE.refl | yes PE.refl | yes PE.refl =
yes (Î ÎŁ-cong x p pâ ok)
... | no ÂŹp | _ | _ | _ =
no (Îť { (ne ([~] _ _ ())); (Î ÎŁ-cong _ _ p _) â ÂŹp p })
... | _ | no ÂŹpâ˛âĄpâł | _ | _ =
no (Îť { (ne ([~] _ _ ())); (Î ÎŁ-cong _ _ _ _) â ÂŹpâ˛âĄpâł PE.refl })
... | _ | _ | no ÂŹqâ˛âĄqâł | _ =
no (Îť { (ne ([~] _ _ ())); (Î ÎŁ-cong _ _ _ _) â ÂŹqâ˛âĄqâł PE.refl })
... | _ | _ | _ | no bââ˘bâ =
no Îť { (ne ([~] _ _ ())); (Î ÎŁ-cong _ _ _ _) â bââ˘bâ PE.refl }
decConvâ (Î ÎŁ-cong _ _ _ _) (Î ÎŁ-cong _ _ _ _) | no ÂŹp =
no (Îť { (ne ([~] _ _ ())) ; (Î ÎŁ-cong _ p _ _) â ÂŹp p })
decConvâ (Id-cong AââĄAâ tââĄtâ uââĄuâ) (Id-cong AââĄAâ tââĄtâ uââĄuâ) =
case decConvâ AââĄAâ AââĄAâ of Îť where
(no Aââ˘Aâ) â no Îť where
(ne ([~] _ _ ()))
(Id-cong AââĄAâ _ _) â Aââ˘Aâ AââĄAâ
(yes AââĄAâ) â case decConvâTermConv (soundnessConvâ AââĄAâ)
tââĄtâ tââĄtâ of Îť where
(no tââ˘tâ) â no Îť where
(ne ([~] _ _ ()))
(Id-cong _ tââĄtâ _) â tââ˘tâ tââĄtâ
(yes tââĄtâ) â case decConvâTermConv (soundnessConvâ AââĄAâ)
uââĄuâ uââĄuâ of Îť where
(no uââ˘uâ) â no Îť where
(ne ([~] _ _ ()))
(Id-cong _ _ uââĄuâ) â uââ˘uâ uââĄuâ
(yes uââĄuâ) â yes (Id-cong AââĄAâ tââĄtâ uââĄuâ)
decConvâ (U-refl x) (â-refl xâ) = no (Îť { (ne ([~] _ _ ())) })
decConvâ (U-refl x) (Empty-refl xâ) = no (Îť { (ne ([~] _ _ ())) })
decConvâ (U-refl _) (Unit-refl _ _) = no (Îť { (ne ([~] _ _ ())) })
decConvâ (U-refl x) (ne xâ) =
no (Îť xâ â let whnfA , neK , neL = ne~â xâ
in âĽ-elim (IE.Uâ˘ne neK (soundnessConvâ xâ)))
decConvâ (U-refl _) (Î ÎŁ-cong _ _ _ _) = no (Îť { (ne ([~] _ _ ())) })
decConvâ (U-refl _) (Id-cong _ _ _) = no (Îť { (ne ([~] _ _ ())) })
decConvâ (â-refl x) (U-refl xâ) = no (Îť { (ne ([~] _ _ ())) })
decConvâ (â-refl x) (Empty-refl xâ) = no (Îť { (ne ([~] _ _ ())) })
decConvâ (â-refl _) (Unit-refl _ _) = no (Îť { (ne ([~] _ _ ())) })
decConvâ (â-refl x) (ne xâ) =
no (Îť xâ â let whnfA , neK , neL = ne~â xâ
in âĽ-elim (IE.ââ˘ne neK (soundnessConvâ xâ)))
decConvâ (â-refl _) (Î ÎŁ-cong _ _ _ _) = no (Îť { (ne ([~] _ _ ())) })
decConvâ (â-refl _) (Id-cong _ _ _) = no (Îť { (ne ([~] _ _ ())) })
decConvâ (Empty-refl x) (U-refl xâ) = no (Îť { (ne ([~] _ _ ())) })
decConvâ (Empty-refl x) (â-refl xâ) = no (Îť { (ne ([~] _ _ ())) })
decConvâ (Empty-refl _) (Unit-refl _ _) = no (Îť { (ne ([~] _ _ ())) })
decConvâ (Empty-refl x) (ne xâ) =
no (Îť xâ â let whnfA , neK , neL = ne~â xâ
in âĽ-elim (IE.Emptyâ˘neâąź neK (soundnessConvâ xâ)))
decConvâ (Empty-refl _) (Î ÎŁ-cong _ _ _ _) = no (Îť { (ne ([~] _ _ ())) })
decConvâ (Empty-refl _) (Id-cong _ _ _) = no (Îť { (ne ([~] _ _ ())) })
decConvâ (Unit-refl _ _) (U-refl _) = no (Îť { (ne ([~] _ _ ())) })
decConvâ (Unit-refl _ _) (â-refl _) = no (Îť { (ne ([~] _ _ ())) })
decConvâ (Unit-refl _ _) (Empty-refl _) = no (Îť { (ne ([~] _ _ ())) })
decConvâ (Unit-refl _ _) (ne x) =
no (Îť y â let _ , neK , _ = ne~â x
in âĽ-elim (IE.Unitâ˘neâąź neK (soundnessConvâ y)))
decConvâ (Unit-refl _ _) (Î ÎŁ-cong _ _ _ _) = no (Îť { (ne ([~] _ _ ())) })
decConvâ (Unit-refl _ _) (Id-cong _ _ _) = no (Îť { (ne ([~] _ _ ())) })
decConvâ (ne x) (U-refl xâ) =
no (Îť xâ â let whnfA , neK , neL = ne~â x
in âĽ-elim (IE.Uâ˘ne neK (sym (soundnessConvâ xâ))))
decConvâ (ne x) (â-refl xâ) =
no (Îť xâ â let whnfA , neK , neL = ne~â x
in âĽ-elim (IE.ââ˘ne neK (sym (soundnessConvâ xâ))))
decConvâ (ne x) (Empty-refl xâ) =
no (Îť xâ â let whnfA , neK , neL = ne~â x
in âĽ-elim (IE.Emptyâ˘neâąź neK (sym (soundnessConvâ xâ))))
decConvâ (ne x) (Unit-refl _ _) =
no (Îť y â let whnfA , neK , neL = ne~â x
in âĽ-elim (IE.Unitâ˘neâąź neK (sym (soundnessConvâ y))))
decConvâ (ne x) (Î ÎŁ-cong _ _ _ _) =
no (Îť y â let whnfA , neK , neL = ne~â x
in âĽ-elim (IE.Î ÎŁâ˘ne neK (sym (soundnessConvâ y))))
decConvâ (ne A~Aâ˛) (Id-cong _ _ _) =
no Îť AâĄB â
âĽ-elim $
IE.Idâ˘ne (ne~â A~AⲠ.projâ .projâ) (sym (soundnessConvâ AâĄB))
decConvâ (Î ÎŁ-cong _ _ _ _) (U-refl _) = no (Îť { (ne ([~] _ _ ())) })
decConvâ (Î ÎŁ-cong _ _ _ _) (â-refl _) = no (Îť { (ne ([~] _ _ ())) })
decConvâ (Î ÎŁ-cong _ _ _ _) (Empty-refl _) = no (Îť { (ne ([~] _ _ ())) })
decConvâ (Î ÎŁ-cong _ _ _ _) (Unit-refl _ _) = no (Îť { (ne ([~] _ _ ())) })
decConvâ (Î ÎŁ-cong _ _ _ _) (ne x) =
no (Îť y â let whnfA , neK , neL = ne~â x
in âĽ-elim (IE.Î ÎŁâ˘ne neK (soundnessConvâ y)))
decConvâ (Î ÎŁ-cong _ _ _ _) (Id-cong _ _ _) = no (Îť { (ne ([~] _ _ ())) })
decConvâ (Id-cong _ _ _) (U-refl _) = no (Îť { (ne ([~] _ _ ())) })
decConvâ (Id-cong _ _ _) (â-refl _) = no (Îť { (ne ([~] _ _ ())) })
decConvâ (Id-cong _ _ _) (Empty-refl _) = no (Îť { (ne ([~] _ _ ())) })
decConvâ (Id-cong _ _ _) (Unit-refl _ _) = no (Îť { (ne ([~] _ _ ())) })
decConvâ (Id-cong _ _ _) (ne B~Bâ˛) =
no Îť AâĄB â
âĽ-elim $
IE.Idâ˘ne (ne~â B~BⲠ.projâ .projâ) (soundnessConvâ AâĄB)
decConvâ (Id-cong _ _ _) (Î ÎŁ-cong _ _ _ _) = no (Îť { (ne ([~] _ _ ())) })
decConvâ-ne : â {A B Aâ˛}
â Π⢠A [convâ] B
â Π⢠A ~ AⲠâ U
â Π⢠A ~ B â U
decConvâ-ne (U-refl x) ()
decConvâ-ne (â-refl x) ()
decConvâ-ne (Empty-refl x) ()
decConvâ-ne (ne x) A~A = x
decConvâ-ne (Î ÎŁ-cong _ _ _ _) ([~] _ _ ())
decConvâ-ne (Unit-refl _ _) ()
decConvâ-ne (Id-cong _ _ _) ([~] _ _ ())
decConvâTerm : â {t u A tⲠuâ˛}
â Π⢠t [convâ] tⲠ⡠A â Π⢠u [convâ] uⲠ⡠A
â Dec (Π⢠t [convâ] u ⡠A)
decConvâTerm ([â]â B tⲠuⲠD d dⲠt<>u)
([â]â Bâ tâł uâł Dâ dâ dâł t<>uâ)
rewrite whrDet* D Dâ
with decConvâTerm t<>u t<>uâ
decConvâTerm ([â]â B tⲠuⲠD d dⲠt<>u)
([â]â Bâ tâł uâł Dâ dâ dâł t<>uâ)
| yes p = yes ([â]â Bâ tⲠtâł Dâ d dâ p)
decConvâTerm ([â]â B tⲠuⲠD d dⲠt<>u)
([â]â Bâ tâł uâł Dâ dâ dâł t<>uâ)
| no ÂŹp =
no (Îť { ([â]â Bâ tâ´ uâ´ Dâ dâ dâ´ t<>uâ) â
let BââĄBâ = whrDet* Dâ Dâ
tâ´âĄuⲠ= whrDet*Term dâ
(PE.subst (_â˘_â_âˇ_ _ _ _) (PE.sym BââĄBâ) d)
uâ´âĄuâł = whrDet*Term dâ´
(PE.subst (_â˘_â_âˇ_ _ _ _) (PE.sym BââĄBâ) dâ)
in ÂŹp (PE.substâ (Îť x y z â _ ⢠x [convâ] y ⡠z)
tâ´âĄuⲠuâ´âĄuâł BââĄBâ t<>uâ)})
decConvâTermⲠ: â {t u A}
â ⢠Π⥠Î
â Π⢠t [convâ] t ⡠A â Π⢠u [convâ] u ⡠A
â Dec (Π⢠t [convâ] u ⡠A)
decConvâTermⲠÎâĄÎ t u = decConvâTerm t (stabilityConvâTerm (symConEq ÎâĄÎ) u)
decConvâTerm : â {t u A tⲠuâ˛}
â Π⢠t [convâ] tⲠ⡠A â Π⢠u [convâ] uⲠ⡠A
â Dec (Π⢠t [convâ] u ⡠A)
decConvâTerm (zero-refl x) (zero-refl xâ) = yes (zero-refl x)
decConvâTerm (starʡ-refl x xâ no-Ρ) (starʡ-refl _ _ _) =
yes (starʡ-refl x xâ no-Ρ)
decConvâTerm (starʡ-refl _ _ _) (Ρ-unit _ _ _ _ (injâ ()))
decConvâTerm (starʡ-refl _ _ no-Ρ) (Ρ-unit _ _ _ _ (injâ Ρ)) =
âĽ-elim (no-Ρ Ρ)
decConvâTerm (Unit-ins t~tâ˛) (Ρ-unit â˘u _ uUnit _ ok) =
let _ , neT , _ = ne~â t~tâ˛
_ , â˘t , _ = syntacticEqTerm (soundness~â t~tâ˛)
in yes (Ρ-unit â˘t â˘u (ne neT) uUnit ok)
decConvâTerm (Ρ-unit â˘t _ tUnit _ ok) (Unit-ins u~uâ˛) =
let _ , neU , _ = ne~â u~uâ˛
_ , â˘u , _ = syntacticEqTerm (soundness~â u~uâ˛)
in yes (Ρ-unit â˘t â˘u tUnit (ne neU) ok)
decConvâTerm (Ρ-unit â˘t _ tUnit _ ok) (Ρ-unit â˘u _ uUnit _ _) =
yes (Ρ-unit â˘t â˘u tUnit uUnit ok)
decConvâTerm (Ρ-unit _ _ _ _ (injâ ())) (starʡ-refl _ _ _)
decConvâTerm (Ρ-unit _ _ _ _ (injâ Ρ)) (starʡ-refl _ _ no-Ρ) =
âĽ-elim (no-Ρ Ρ)
decConvâTerm â˘rflâĄrfl@(rfl-refl _) (rfl-refl _) = yes â˘rflâĄrfl
decConvâTerm (â-ins x) (â-ins xâ) with dec~â x xâ
decConvâTerm (â-ins x) (â-ins xâ) | yes (A , k~l) =
let whnfA , neK , neL = ne~â k~l
â˘A , â˘k , â˘l = syntacticEqTerm (soundness~â k~l)
_ , â˘lâˇâ , _ = syntacticEqTerm (soundness~â x)
â˘ââĄA = neTypeEq neK â˘lâˇâ â˘k
AâĄâ = ââĄA â˘ââĄA whnfA
k~lⲠ= PE.subst (Îť x â _ ⢠_ ~ _ â x) AâĄâ k~l
in yes (â-ins k~lâ˛)
decConvâTerm (â-ins x) (â-ins xâ) | no ÂŹp =
no (Îť xâ â ÂŹp (â , decConvâTerm-â-ins xâ x))
decConvâTerm (Empty-ins x) (Empty-ins xâ) with dec~â x xâ
decConvâTerm (Empty-ins x) (Empty-ins xâ) | yes (A , k~l) =
let whnfA , neK , neL = ne~â k~l
â˘A , â˘k , â˘l = syntacticEqTerm (soundness~â k~l)
_ , â˘lâˇEmpty , _ = syntacticEqTerm (soundness~â x)
â˘EmptyâĄA = neTypeEq neK â˘lâˇEmpty â˘k
AâĄEmpty = EmptyâĄA â˘EmptyâĄA whnfA
k~lⲠ= PE.subst (Îť x â _ ⢠_ ~ _ â x) AâĄEmpty k~l
in yes (Empty-ins k~lâ˛)
decConvâTerm (Empty-ins x) (Empty-ins xâ) | no ÂŹp =
no (Îť xâ â ÂŹp (Empty , decConvâTerm-Empty-ins xâ x))
decConvâTerm (Unit-ins {s = đ¨} x) (Unit-ins xâ) with dec~â x xâ
... | yes (A , k~l) =
let whA , neT , neU = ne~â k~l
_ , â˘t , _ = syntacticEqTerm (soundness~â k~l)
_ , â˘tⲠ, _ = syntacticEqTerm (soundness~â x)
AâĄUnit = neTypeEq neT â˘tⲠâ˘t
k~lⲠ= PE.subst (Îť x â _ ⢠_ ~ _ â x)
(UnitâĄA AâĄUnit whA) k~l
in yes (Unit-ins k~lâ˛)
... | no ÂŹp =
case Unitʡ-Ρ? of Ν where
(no no-Ρ) â no Îť where
(Unit-ins x) â ÂŹp (_ , x)
(Ρ-unit _ _ _ _ (injâ ()))
(Ρ-unit _ _ _ _ (injâ Ρ)) â no-Ρ Ρ
(yes Ρ) â yes $
Ρ-unit
(syntacticEqTerm (soundness~â x) .projâ .projâ)
(syntacticEqTerm (soundness~â xâ) .projâ .projâ)
(ne (ne~â x .projâ .projâ))
(ne (ne~â xâ .projâ .projâ))
(injâ Ρ)
decConvâTerm (Unit-ins {s = đ¤} t~tâ˛) (Unit-ins u~uâ˛) =
let _ , neT , _ = ne~â t~tâ˛
_ , â˘t , _ = syntacticEqTerm (soundness~â t~tâ˛)
_ , neU , _ = ne~â u~uâ˛
_ , â˘u , _ = syntacticEqTerm (soundness~â u~uâ˛)
in yes (Ρ-unit â˘t â˘u (ne neT) (ne neU) (injâ PE.refl))
decConvâTerm (Σʡ-ins x xâ xâ) (Σʡ-ins xâ xâ xâ
) with dec~â xâ xâ
... | yes (B , t~u) =
let â˘B , â˘t , â˘u = syntacticEqTerm (soundness~â t~u)
whnfB , neT , _ = ne~â t~u
ÎŁâĄB = neTypeEq neT x â˘t
_ , _ , BâĄÎŁâ˛ = ÎŁâĄA ÎŁâĄB whnfB
in yes (Σʡ-ins x xâ (PE.subst (Îť x â _ ⢠_ ~ _ â x) BâĄÎŁâ˛ t~u))
... | no ÂŹp = no (Îť xâ â ÂŹp (decConvâTerm-Σʡ-ins xâ xâ))
decConvâTerm (ne-ins x xâ xâ xâ) (ne-ins xâ xâ
xâ xâ)
with dec~â xâ xâ
decConvâTerm (ne-ins x xâ xâ xâ) (ne-ins xâ xâ
xâ xâ) | yes (A , k~l) =
yes (ne-ins x xâ xâ k~l)
decConvâTerm (ne-ins x xâ xâ xâ) (ne-ins xâ xâ
xâ xâ) | no ÂŹp =
no (Îť xâ â ÂŹp (decConvâTerm-ne-ins xâ xâ))
decConvâTerm (univ x xâ xâ) (univ xâ xâ xâ
)
with decConvâ xâ xâ
decConvâTerm (univ x xâ xâ) (univ xâ xâ xâ
) | yes p =
yes (univ x xâ p)
decConvâTerm (univ x xâ xâ) (univ xâ xâ xâ
) | no ÂŹp =
no (Îť { (ne-ins xâ xâ () xâ)
; (univ xâ xâ xâ) â ÂŹp xâ })
decConvâTerm (suc-cong x) (suc-cong xâ) with decConvâTerm x xâ
decConvâTerm (suc-cong x) (suc-cong xâ) | yes p =
yes (suc-cong p)
decConvâTerm (suc-cong x) (suc-cong xâ) | no ÂŹp =
no (Îť { (â-ins ([~] _ _ ()))
; (ne-ins xâ xâ () xâ
)
; (suc-cong xâ) â ÂŹp xâ })
decConvâTerm (ÎŁ-Ρ â˘t _ tProd _ fstConvT sndConvT)
(ÎŁ-Ρ â˘u _ uProd _ fstConvU sndConvU)
with decConvâTerm fstConvT fstConvU
... | yes P = let â˘F , â˘G = syntacticÎŁ (syntacticTerm â˘t)
fsttâĄfstu = soundnessConvâTerm P
GfsttâĄGfstu = substTypeEq (refl â˘G) fsttâĄfstu
sndConv = decConvâTermConv GfsttâĄGfstu sndConvT sndConvU
in decConvâTerm-ÎŁ-Ρ â˘t â˘u tProd uProd P sndConv
... | no ÂŹP = no (Îť { (ÎŁ-Ρ _ _ _ _ P _) â ÂŹP P } )
decConvâTerm (prod-cong x xâ xâ xâ ok) (prod-cong xâ xâ
xâ xâ _)
with decConvâTerm xâ xâ
... | no ÂŹP = no Îť eq â case prod-congâťÂš eq of Îť
(_ , _ , _ , _ , t , _) â ÂŹP t
... | yes P with decConvâTermConv (substTypeEq (refl xâ) (soundnessConvâTerm P)) xâ xâ
... | yes Q = yes (prod-cong x xâ P Q ok)
... | no ÂŹQ = no Îť eq â case prod-congâťÂš eq of Îť
(_ , _ , _ , _ , _ , u , _) â ÂŹQ u
decConvâTerm (Ρ-eq {p = p} {f = t} xâ xâ xâ xâ xâ
) (Ρ-eq {f = u} xâ xâ xâ xââ xââ)
with decConvâTerm xâ
xââ
... | yes P =
let â˘F , â˘G = syntacticÎ (syntacticTerm xâ)
GâĄG = refl â˘G
in
yes (Ρ-eq xâ xâ xâ xâ $
transConvâTerm GâĄG xâ
(transConvâTerm GâĄG (symConvTerm xâ
)
(transConvâTerm GâĄG P
(transConvâTerm GâĄG xââ
(symConvTerm xââ)))))
... | no ÂŹP = no (Îť { (ne-ins xââ xââ () xââ
)
; (Ρ-eq xââ xââ xââ
xââ xââ) â ÂŹP xââ })
decConvâTerm (Id-ins â˘vâ vâ~vâ) (Id-ins â˘vâ vâ~vâ) =
case dec~â vâ~vâ vâ~vâ of Îť where
(no ÂŹvâ~vâ) â no Îť where
(Id-ins _ vâ~vâ) â ÂŹvâ~vâ (_ , vâ~vâ)
(rfl-refl _) â case vâ~vâ of Îť { ([~] _ _ ()) }
(ne-ins _ _ () _)
(yes (_ , vâ~vâ)) â
case ne~â vâ~vâ of Îť {
(B-whnf , vâ-ne , _) â
case neTypeEq vâ-ne
(syntacticEqTerm (soundness~â vâ~vâ) .projâ .projâ)
(syntacticEqTerm (soundness~â vâ~vâ)
.projâ .projâ) of Îť {
IdâĄB â
case IdâĄWhnf IdâĄB B-whnf of Îť {
(_ , _ , _ , PE.refl) â
yes (Id-ins â˘vâ vâ~vâ) }}}
decConvâTerm (â-ins x) (zero-refl xâ) =
no (Îť xâ â decConvâTerm-â xâ x Îť { ([~] _ _ ()) })
decConvâTerm (â-ins x) (suc-cong xâ) =
no (Îť xâ â decConvâTerm-â xâ x (Îť { ([~] _ _ ()) }))
decConvâTerm (zero-refl x) (â-ins xâ) =
no (Îť xâ â decConvâTerm-â (symConvâTermⲠxâ) xâ (Îť { ([~] _ _ ()) }))
decConvâTerm (zero-refl x) (suc-cong xâ) =
no (Îť { (â-ins ([~] _ _ ())) ; (ne-ins xâ xâ () xâ
) })
decConvâTerm (suc-cong x) (â-ins xâ) =
no (Îť xâ â decConvâTerm-â (symConvâTermⲠxâ) xâ (Îť { ([~] _ _ ()) }))
decConvâTerm (suc-cong x) (zero-refl xâ) =
no (Îť { (â-ins ([~] _ _ ())) ; (ne-ins xâ xâ () xâ
) })
decConvâTerm (Σʡ-ins x xâ xâ) (prod-cong xâ xâ xâ
xâ _) =
no Îť xâ â decConvâTerm-Σʡ xâ xâ (Îť{ ()})
decConvâTerm (prod-cong x xâ xâ xâ _) (Σʡ-ins xâ xâ
xâ) =
no (Îť xâ â decConvâTerm-Σʡ (symConvâTermⲠxâ) xâ (Îť{ ()}))
decConvâTerm (starʡ-refl _ _ no-Ρ) (Unit-ins xâ) =
no Îť y â no-Ρ (decConvâTerm-Unit (symConvâTermⲠy) xâ)
decConvâTerm (Unit-ins x) (starʡ-refl _ _ no-Ρ) =
no Îť y â no-Ρ (decConvâTerm-Unit y x)
decConvâTerm (Id-ins _ vâ~vâ) (rfl-refl _) =
no Îť where
(Id-ins _ ~rfl) â case ne~â ~rfl .projâ .projâ of Îť ()
(rfl-refl _) â case ne~â vâ~vâ .projâ .projâ of Îť ()
(ne-ins _ _ () _)
decConvâTerm (rfl-refl _) (Id-ins _ vâ~vâ) =
no Îť where
(Id-ins _ rfl~) â case ne~â rfl~ .projâ .projâ of Îť ()
(rfl-refl _) â case ne~â vâ~vâ .projâ .projâ of Îť ()
(ne-ins _ _ () _)
decConvâTerm (â-ins x) (ne-ins xâ xâ () xâ)
decConvâTerm (Empty-ins x) (ne-ins xâ xâ () xâ)
decConvâTerm (Σʡ-ins x xâ xâ) (ne-ins xâ xâ () xâ)
decConvâTerm (ne-ins x xâ () xâ) (â-ins xâ)
decConvâTerm (ne-ins x xâ () xâ) (Empty-ins xâ)
decConvâTerm (ne-ins x xâ () xâ) (Unit-ins xâ)
decConvâTerm (ne-ins x xâ () xâ) (Σʡ-ins xâ xâ
xâ)
decConvâTerm (ne-ins x xâ () xâ) (univ xâ xâ
xâ)
decConvâTerm (ne-ins x xâ () xâ) (zero-refl xâ)
decConvâTerm (ne-ins x xâ () xâ) (suc-cong xâ)
decConvâTerm (ne-ins x xâ () xâ) (prod-cong xâ xâ
xâ xâ _)
decConvâTerm (ne-ins x xâ () xâ) (Ρ-eq xâ xâ
xâ xâ xâ)
decConvâTerm (ne-ins x xâ () xâ) (ÎŁ-Ρ xâ xâ
xâ xâ xâ xâ)
decConvâTerm (ne-ins x xâ () xâ) (Ρ-unit _ _ _ _ _)
decConvâTerm (ne-ins _ _ () _) (Id-ins _ _)
decConvâTerm (ne-ins _ _ () _) (rfl-refl _)
decConvâTerm (univ x xâ xâ) (ne-ins xâ xâ () xâ)
decConvâTerm (zero-refl x) (ne-ins xâ xâ () xâ)
decConvâTerm (rfl-refl _) (ne-ins _ _ () _)
decConvâTerm (suc-cong x) (ne-ins xâ xâ () xâ)
decConvâTerm (prod-cong x xâ xâ xâ _) (ne-ins xâ xâ
() xâ)
decConvâTerm (Ρ-eq x xâ xâ xâ xâ) (ne-ins xâ
xâ () xâ)
decConvâTerm (ÎŁ-Ρ x xâ xâ xâ xâ xâ
) (ne-ins xâ xâ () xâ)
decConvâTerm (Id-ins _ _) (ne-ins _ _ () _)
decConvâTerm (Unit-ins x) (ne-ins xâ xâ () xâ)
decConvâTerm (ne-ins x xâ () xâ) (starʡ-refl _ _ _)
decConvâTerm (starʡ-refl _ _ _) (ne-ins xâ xâ () xâ
)
decConvâTerm (Ρ-unit _ _ _ _ _) (ne-ins xâ xâ
() xâ)
decConvâTermConv : â {t u A B tⲠuâ˛}
â Π⢠A ⥠B
â Π⢠t [convâ] tⲠ⡠A
â Π⢠u [convâ] uⲠ⡠B
â Dec (Π⢠t [convâ] u ⡠A)
decConvâTermConv AâĄB t u =
decConvâTerm t (convConvTerm u (sym AâĄB))