在证明基本函数应用定律时了解 agda 中的类型推断问题



我正在尝试证明函数应用的恒等法。 我在下面得到关于假定身份函数的黄色突出显示,apfId。 我不明白,_≡_ {A}没有A → A → Set类型吗? 有没有简单的方法来检查 Agda 中的表达式类型,例如 ghci 中的 :t?

———— Error —————————————————————————————————————————————————
/home/wmacmil/agda2020/agda/MLTT/Id.agda:217,49-55
Set₁ != Set
when checking that the expression _≡_ {A} has type A → A → Set

任何建议都非常感谢。

data _≡_ {A : Set} (a : A) : A → Set where
r : a ≡ a
infix 20 _≡_
J : {A : Set}
→ (D : (x y : A) → (x ≡ y) →  Set)
-- → (d : (a : A) → (D a a r ))
→ ((a : A) → (D a a r ))
→ (x y : A)
→ (p : x ≡ y)
------------------------------------
→ D x y p
J D d x .x r = d x

-- ap_
apf : {A B : Set} → {x y : A} → (f : A → B) → (x ≡ y) → f x ≡ f y
apf {A} {B} {x} {y} f p = J D d x y p
where
D : (x y : A) → x ≡ y → Set
D x y p = {f : A → B} → f x ≡ f y
d : (x : A) → D x x r
d = λ x → r 
apfId : {A : Set} {x y : A} (p : x ≡ y) → (apf (_≡_ {A}) p) ≡ p -- it highlights yellow at the _≡_

我误解了HoTT书中的id_A函数为A的恒等类型(通常表示为Id_A x x(,而不是恒等函数idA:A -> A。

最新更新