什么是 eq_rect 以及它在 Coq 中的何处定义?
What is eq_rect and where is it defined in Coq?
据我所读,eq_rect
和平等似乎有着深刻的联系。奇怪的是,我无法在手册中找到它的定义。
它从何而来,说明了什么?
如果您使用 Locate eq_rect
,您会发现 eq_rect
位于 Coq.Init.Logic
,但如果您查看该文件,则其中没有 eq_rect
。那么,这是怎么回事?
当你定义归纳类型时,Coq 在很多情况下 自动为你生成 3 个归纳原理,附加 _rect
、_rec
、_ind
到类型的名称。
要理解 eq_rect
的含义,您需要它的类型,
Check eq_rect.
我们开始:
eq_rect
: forall (A : Type) (x : A) (P : A -> Type),
P x -> forall y : A, x = y -> P y
你需要理解Leibniz's equality的概念:
Leibniz characterized the notion of equality as follows:
Given any x
and y
, x = y
if and only if, given any predicate P
, P(x)
if and only if P(y)
.
In this law, "P(x)
if and only if P(y)
" can be weakened to "P(x)
if P(y)
"; the modified law is equivalent to the original, since a statement that applies to "any x
and y
" applies just as well to "any y
and x
".
不那么正式地说,上面的引文说,如果 x
和 y
相等,则它们的每个谓词的 "behavior" 都是相同的。
为了更清楚地看到莱布尼茨等式直接对应于 eq_rect
我们可以将 eq_rect
的参数顺序重新排列为以下等价公式:
eq_rect_reorder
: forall (A : Type) (P : A -> Type) (x y : A),
x = y -> P x -> P y
据我所读,eq_rect
和平等似乎有着深刻的联系。奇怪的是,我无法在手册中找到它的定义。
它从何而来,说明了什么?
如果您使用 Locate eq_rect
,您会发现 eq_rect
位于 Coq.Init.Logic
,但如果您查看该文件,则其中没有 eq_rect
。那么,这是怎么回事?
当你定义归纳类型时,Coq 在很多情况下 自动为你生成 3 个归纳原理,附加 _rect
、_rec
、_ind
到类型的名称。
要理解 eq_rect
的含义,您需要它的类型,
Check eq_rect.
我们开始:
eq_rect
: forall (A : Type) (x : A) (P : A -> Type),
P x -> forall y : A, x = y -> P y
你需要理解Leibniz's equality的概念:
Leibniz characterized the notion of equality as follows: Given any
x
andy
,x = y
if and only if, given any predicateP
,P(x)
if and only ifP(y)
.In this law, "
P(x)
if and only ifP(y)
" can be weakened to "P(x)
ifP(y)
"; the modified law is equivalent to the original, since a statement that applies to "anyx
andy
" applies just as well to "anyy
andx
".
不那么正式地说,上面的引文说,如果 x
和 y
相等,则它们的每个谓词的 "behavior" 都是相同的。
为了更清楚地看到莱布尼茨等式直接对应于 eq_rect
我们可以将 eq_rect
的参数顺序重新排列为以下等价公式:
eq_rect_reorder
: forall (A : Type) (P : A -> Type) (x y : A),
x = y -> P x -> P y