簡體   English   中英

在證明基本的 function 應用規律時了解 agda 中的類型推斷問題

[英]Understanding type inference issues in agda when proving basic function application laws

我正在嘗試證明 function 應用程序的恆等律。 我在下面的假定身份 function, 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 function誤解為A的身份類型(通常表示為Id_A xx),而不是身份function idA: A -> A。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM