Function 寻找关于隐式函数类型与显式函数类型的解释

Function 寻找关于隐式函数类型与显式函数类型的解释,function,types,implicit,agda,explicit,Function,Types,Implicit,Agda,Explicit,考虑到以下agda模块签名: module EqList {a ℓ} {A : Set a} {_≈_ : Rel A ℓ} (eq≈ : IsEquivalence _≈_) where 我们可以定义列表中的成员资格、列表包含和列表等价性: _∈_ : REL A (List A) _ _∈_ x = Any (x ≈_) _⊑_ : Rel (List A) _ _⊑_ = _⊆_ on flip _∈_ _≋_ : Rel (List A) _ _≋_ = _⊑_ -[ _×_ ]-

考虑到以下agda模块签名:

module EqList {a ℓ} {A : Set a} {_≈_ : Rel A ℓ} (eq≈ : IsEquivalence _≈_) where
我们可以定义列表中的成员资格、列表包含和列表等价性:

_∈_ : REL A (List A) _
_∈_ x = Any (x ≈_)

_⊑_ : Rel (List A) _
_⊑_ = _⊆_ on flip _∈_

_≋_ : Rel (List A) _
_≋_ = _⊑_ -[ _×_ ]- flip _⊑_
然后我们可以继续证明最后一个关系确实是一个等价关系:

isEq≋ : IsEquivalence _≋_
isEq≋ = record {
  refl = id , id ;
  sym = swap ;
  trans = zip (λ f g → g ∘ f) λ f g → f ∘ g }
及物性的证明是我的问题产生的原因。Agda接受之前的定义,但拒绝以下定义:

trans = zip (flip _∘_) _∘_
错误如下:

({x : A} → Any (_≈_ x) i → Any (_≈_ x) j) !=
((x : A) → Any (_≈_ x) j) because one is an implicit function type
and the other is an explicit function type
when checking that the expression _∘_ has type
(x : j ⊑ k) (y : i ⊑ j) → i ⊑ k
虽然这个错误感觉很奇怪,因为两个证明应该是等价的(用表达式
λx替换表达式
f
)→ f x
应该总是产生相同的结果)我可以理解为什么它会这样:如何实例化
_∘_。但这种解释只是直观的,不是很有说服力,所以我的问题如下:

有人能详细解释为什么typechecker在第一种情况下成功而在第二种情况下不成功吗?


作为旁注,以下是模块的标题,以使本示例自包含:

open import Relation.Binary.Core
open import Data.List hiding (zip)
open import Data.List.Any
open import Relation.Unary using (_⊆_)
open import Function
open import Data.Product

作为第二个补充说明,我知道已经回答了一个类似的问题:


但上述答案并未对这一令人惊讶的行为做出任何深刻解释。

在我看来,Agda在这方面确实可以做得更好。例如,请参见