Skip to content

Commit 169f2b2

Browse files
committed
unsafe swapVarTermStrengthened
1 parent 2e9a73d commit 169f2b2

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

src/Agda/Core/TCMInstances.agda

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,11 @@ caseTCM {b = b} (MkTCM runTCMb) j (MkTCM runTCMa) = MkTCM caseAux
6262
where caseAux : TCEnv Either TCError b
6363
caseAux env with runTCMa env
6464
... | Left _ = runTCMb env
65-
... | Right x = Right (j x)
65+
... | Right x = Right (j x)
66+
67+
caseTCMTCM : {@0 a b : Set} TCM b (a TCM b) TCM a TCM b
68+
caseTCMTCM {b = b} (MkTCM runTCMb) j (MkTCM runTCMa) = MkTCM caseAux
69+
where caseAux : TCEnv Either TCError b
70+
caseAux env with runTCMa env
71+
... | Left _ = runTCMb env
72+
... | Right x = let MkTCM runTCMj = j x in runTCMj env

src/Agda/Core/Unification.agda

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,24 @@ module Swap where
543543
TCM (Σ0 _ λ α' Context α' × Renaming α α')
544544
swapVarTerm Γ x u = swapVarList Γ x (varInTerm u)
545545

546+
maybe≡ : {@0 ℓ₁ ℓ₂} {@0 a : Set ℓ₁} {@0 b : Set ℓ₂} (mb : Maybe a) ((x : a) Just x ≡ mb b) b b
547+
maybe≡ Nothing j n = n
548+
maybe≡ (Just x) j n = j x refl
549+
550+
opaque
551+
unfolding
552+
swapVarTermStrengthened :: Context α) ((⟨ x ⟩ xp) : NameIn α) (u : Term α)
553+
TCM (Σ0 _ λ α' Context α' × (Σ[ σ ∈ Renaming α α' ]
554+
(Σ[ u₀ ∈ Term (cutDrop (σ xp)) ] Strengthened (subst (renamingToSubst (rezzScope Γ) σ) u) u₀)))
555+
swapVarTermStrengthened Γ (⟨ x ⟩ xp) u =
556+
caseTCMTCM (MkTCM (λ _ Left "term cannot be swapped with var"))
557+
(λ (⟨ α' ⟩ (Γ' , σ))
558+
let u' : Term α'
559+
u' = subst (renamingToSubst (rezzScope Γ) σ) u in
560+
maybe≡ (strengthen subCutDrop u')
561+
(λ u₀ e MkTCM (λ _ Right (⟨ α' ⟩ (Γ' , (σ , (u₀ , (subCutDrop , e)))))))
562+
(MkTCM (λ _ Left "impossible : check swapVarTermStrengthened code")))
563+
(swapVarTerm Γ (⟨ x ⟩ xp) u)
546564

547-
-- (Σ[ σ ∈ Renaming α α' ] (Σ[ u₀ ∈ Term (cutDrop (σ xp)) ] Strengthened u u₀)))
548565
{- End of module Swap -}
549566
open Swap

0 commit comments

Comments
 (0)