Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Coq 如何证明(2^2)%R=4%R_Coq - Fatal编程技术网

Coq 如何证明(2^2)%R=4%R

Coq 如何证明(2^2)%R=4%R,coq,Coq,如何在Coq中证明以下内容 Require Import Coq.Reals.Reals. Definition f (x:R) :R := pow x 2. Lemma f_2: f 2 = 4%R. Proof. Admitted. 首先需要通过展开函数f来公开其定义: Require Import Coq.Reals.Reals. (* "Require Import Reals." would be OK as well. *) Definition f (x : R) : R

如何在Coq中证明以下内容

Require Import Coq.Reals.Reals.

Definition f (x:R) :R := pow x 2.

Lemma f_2: f 2 = 4%R.
Proof.
Admitted.

首先需要通过展开函数f来公开其定义:

Require Import Coq.Reals.Reals.  (* "Require Import Reals." would be OK as well. *)
Definition f (x : R) : R := pow x 2.

Lemma f_2 : f 2 = 4%R.
Proof.
unfold f.
然后你会得到:

1 subgoal

  ============================
  (2 ^ 2)%R = 4%R
在公理化领域实现这一目标的一种惯用方法是依靠环战术:


有关此策略的更多详细信息,请参阅。

方法1:使用强大的策略

环战术足够强大,可以轻松统一2^2和4。你必须展开f,因为它不是一个环形操作

Lemma f_2: f 2 = 4%R.
Proof.
  unfold f.
  ring.
Qed.
方法2:艰难的道路。要查看简单语句f2=4中隐含的所有内容,暂时关闭符号将有所帮助。我还打开了作用域R\u作用域,因此不需要到处都使用%R后缀

我们得到类似于eq f IZR Zpos xO xH IZR Zpos xO xH的东西

IZR是将整数转换为实数的函数。让我们把它和f一起展开

现在我们可以重新打开符号,我们的目标是IPR 2^2=IPR 4。因此,继续展开知识产权。IPR将正整数转换为实数

Lemma f_2: f 2 = 4.
Proof.
  unfold f; cbn.
  change 4 with (2 * 2).
  rewrite Rmult_1_r.
  reflexivity.
Qed.
目标是IPR_2 1^2=IPR_2 2。IPR_2还将正整数转换为实数,但引入了因子2。它基本上是IPR的一个方便功能。把它也打开

最后我们讨论基本常数。目标是R1+R1^2=R1+R1*R1+R1。让我们简化电源。像cbn这样的简化策略之一是可行的。目标变成R1+R1*R1+R1*1=R1+R1*R1+R1。最后,我们可以使用x*1=x。搜索*更好,搜索?x*1=?x,我发现Rmult_1_r是我们想要的。使用重写Rmulti_1_r,然后使用自反性

当然,所有这些展开步骤都是纯计算的,所以我们可以跳到最后,用2*2表示变化4,但4被定义为2*2肯定不是很明显,除非你已经熟悉整数如何转化为实数

Lemma f_2: f 2 = 4.
Proof.
  unfold f; cbn.
  change 4 with (2 * 2).
  rewrite Rmult_1_r.
  reflexivity.
Qed.
Lemma f_2: f 2 = 4.
Proof.
  unfold f; cbn.
  change 4 with (2 * 2).
  rewrite Rmult_1_r.
  reflexivity.
Qed.