我试图证明函数应用的身份法则。 我得到的黄色高亮与所谓的身份函数。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 _≡_
我把浩特书上的id_A函数误解为A的身份类型(通常表示为Id_A x x),而不是身份函数idA : A -> A。