Skip to content

Commit 84bcd07

Browse files
committed
Symmetric conversion exclusive to eta conversion for functions rule
1 parent d822ea4 commit 84bcd07

File tree

2 files changed

+29
-18
lines changed

2 files changed

+29
-18
lines changed

src/Agda/Core/Checkers/Converter.agda

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -214,9 +214,24 @@ convertBranches r BsNil bp = return CBranchesNil
214214
convertBranches r (BsCons bsh bst) bp =
215215
caseBsCons bp (λ where bph bpt ⦃ refl ⦄
216216
CBranchesCons <$> convertBranch r bsh bph <*> convertBranches r bst bpt)
217-
218217
{-# COMPILE AGDA2HS convertBranches #-}
219218

219+
convertEtaGeneric : ⦃ fl : Fuel ⦄
220+
Singleton α
221+
(@0 x : Name)
222+
(f : Term α)
223+
(b : Term (α ▸ x))
224+
TCM (b ≅ (TApp (weakenTerm _ f) (TVar (VZero x))))
225+
convertEtaGeneric r x f b = do
226+
let
227+
subsetProof = subWeaken subRefl
228+
newScope = singBind r
229+
term = TApp (weakenTerm subsetProof f)
230+
(TVar (VZero x))
231+
convertCheck newScope b term
232+
{-# COMPILE AGDA2HS convertEtaGeneric #-}
233+
234+
220235
convertWhnf : ⦃ fl : Fuel ⦄ Singleton α (t q : Term α) TCM (t ≅ q)
221236
convertWhnf r (TVar x) (TVar y) = convVars x y
222237
convertWhnf r (TDef x) (TDef y) = convDefs x y
@@ -231,19 +246,14 @@ convertWhnf r (TPi x tu tv) (TPi y tw tz) = convPis r x y tu tw tv tz
231246
convertWhnf r (TSort s) (TSort t) = convSorts s t
232247
--let and ann shouldn't appear here since they get reduced away
233248
convertWhnf r functionTerm (TLam x b) =
234-
let
235-
subsetProof = (subWeaken subRefl)
236-
newScope = singBind r
237-
term = TApp (weakenTerm subsetProof functionTerm) (TVar (VZero x))
238-
in
239249
do
240-
conversionProof <- convertCheck newScope b term
241-
return (CEtaFunctions x functionTerm b conversionProof)
242-
convertWhnf r a b = do
243-
conversionProof <- convertCheck r b a
244-
return (CSym conversionProof)
245-
-- convertWhnf r (TLam x v) (TVar x') = tcError "implement eta-functions 2"
246-
-- convertWhnf r (TApp _ _) (TLam _ _) = tcError "implement eta-functions 3"
250+
conversionProof <- convertEtaGeneric r x functionTerm b
251+
return (CEtaFunctionsLeft x functionTerm b conversionProof)
252+
convertWhnf r (TLam x b) functionTerm =
253+
do
254+
conversionProof <- convertEtaGeneric r x functionTerm b
255+
return (CEtaFunctionsRight x functionTerm b conversionProof)
256+
convertWhnf r _ _ = tcError "two terms are not the same and aren't convertible"
247257

248258
{-# COMPILE AGDA2HS convertWhnf #-}
249259

src/Agda/Core/Rules/Conversion.agda

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,14 @@ data Conv {α} where
8383
{@0 us vs : TermS α (fieldScope c)}
8484
us ⇔ vs
8585
TCon c us ≅ TCon c vs
86-
CEtaFunctions : (@0 x : Name) (f : Term α) (b : Term (α ▸ x))
86+
CEtaFunctionsLeft : (@0 x : Name) (f : Term α) (b : Term (α ▸ x))
8787
let subsetProof = subWeaken subRefl in
8888
b ≅ (TApp (weakenTerm subsetProof f) (TVar (VZero x)))
89-
f ≅ (TLam x b)
90-
CSym : {a b : Term α}
91-
b ≅ a
92-
a ≅ b
89+
f ≅ (TLam x b)
90+
CEtaFunctionsRight : (@0 x : Name) (f : Term α) (b : Term (α ▸ x))
91+
let subsetProof = subWeaken subRefl in
92+
b ≅ (TApp (weakenTerm subsetProof f) (TVar (VZero x)))
93+
(TLam x b) ≅ f
9394
CRedL : @0 ReducesTo u u'
9495
u' ≅ v
9596
u ≅ v

0 commit comments

Comments
 (0)