COQ中如何合并证明功能

发布于 2025-01-24 16:22:21 字数 282 浏览 4 评论 0 原文

在以下简单定理中,直接以证明功能的形式给出了证明。我想了解这两个术语是如何反映我的概念的两个术语,并将其结合成返回预期类型的​​最终证明功能。

Lemma simple : forall i, i <= S i.
Proof
  fun i => (le_S i i) (le_n i).

似乎(le_s ii)构造函数返回了一个函数,然后将(le_n i)作为参数。有人可以解释在这里如何起作用的证明功能组合如何工作吗?

In the following simple theorem the proof is given directly in the form of a proof function. I'd like to understand how the two terms, parenthesized to reflect my concept, combine into a final proof function that returns the expected type.

Lemma simple : forall i, i <= S i.
Proof
  fun i => (le_S i i) (le_n i).

It seems as if the (le_S i i) constructor term returned a function which then would accept (le_n i) as a parameter. Could someone be kind to explain how proof function combination works here?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

无悔心 2025-01-31 16:22:21

(LE_S II)是一个函数的值。它期望作为参数的另一个值,此处(le_n i),类型(i&lt; = i),因为 le_n 的类型是 forall n:nat,(n&lt; = n)(le_s ii)的值应用于此参数的是类型(i&lt; = s I),正如您可以从 le_s <的类型中看到的那样/代码>。引理中的 forall 在用于定义简单的最终值中说明了 fun

(le_S i i) is a value that is a function. It expects as argument another value, here (le_n i), of type (i <= i), since the type of le_n is forall n : nat, (n <= n). The value of (le_S i i) applied to this argument is of type (i <= S i), as you could see from the type of le_S. The forall in the lemma explains the fun in the final value used to define simple.

眼睛会笑 2025-01-31 16:22:21

您可能需要阅读()。

基本上,在COQ证明中,功能是以某种命题为论点的证据(以证人的形式)作为参数,并为新的派生主张提供证据(证人)。

如果您执行检查LE_S。,您会得到

le_S
     : forall n m : nat, n <= m -> n <= S m

le_s 是一个功能,它需要两个NAT和见证人 n&lt; = m 并产生一个见证 n&lt; = s M

在您中,示例 le_n i i&lt; = i 的见证。

请注意, - &gt; 符号对于通常的功能具有相同的含义,例如检查Nat.Add。

Nat.add
     : nat -> nat -> nat

与证明相同。 a - &gt; b 在两种情况下都意味着 a 到类型 b 的功能。

You might want to read (https://en.wikipedia.org/wiki/Curry–Howard_correspondence).

Basically in Coq proofs are functions which take evidence (in form of a witness) for some proposition as arguments and produce evidence (a witness) for a new derived proposition.

If you do Check le_S. you get

le_S
     : forall n m : nat, n <= m -> n <= S m

So le_S is a function which takes two nats and a witness for n <= m and produces a witness for n <= S m.

In you example le_n i is a witness for i <= i.

Please note that the ->symbol has the same meaning for usual functions like Check Nat.add.

Nat.add
     : nat -> nat -> nat

as for proofs. a -> b in both cases means function from type a to type b.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文