利用Coq场公理

利用Coq场公理,coq,Coq,我正在使用Coq字段模块进行实验,试图直接从字段公理证明以下简单恒等式:对于所有v,0v==v。我看到0和=都有现有的符号,所以我尝试了这个(但失败): 我收到了以下错误消息: Unknown scope delimiting key R_scope. 当我看到,R\u范围肯定在那里, 所以我肯定遗漏了什么。事实上,这些符号在一个部分中,这意味着它们无法从外部获得 此外,所有这些定义都是由字段结构参数化的,因此如果您想证明关于字段的一般结果,您需要在本地声明(或实例化)这些参数 我不确定它是否

我正在使用Coq字段模块进行实验,试图直接从字段公理证明以下简单恒等式:
对于所有v,0v==v
。我看到
0
=
都有现有的符号,所以我尝试了这个(但失败):

我收到了以下错误消息:

Unknown scope delimiting key R_scope.
当我看到,
R\u范围
肯定在那里,
所以我肯定遗漏了什么。

事实上,这些符号在一个部分中,这意味着它们无法从外部获得

此外,所有这些定义都是由字段结构参数化的,因此如果您想证明关于字段的一般结果,您需要在本地声明(或实例化)这些参数

我不确定它是否真的应该这样使用。我的建议是在Github上打开一个问题,询问setoid_环插件的用途

Require Import Coq.setoid_ring.Field_theory.
Require Import Coq.setoid_ring.Ring_theory.
Require Import Setoid.

Section MyFieldTheory.

(* Theory parameterized by a field R *)
Variable (R:Type)
         (rO:R) (rI:R)
         (radd rmul rsub : R -> R -> R)
         (ropp : R -> R)
         (rdiv : R -> R -> R)
         (rinv : R -> R)
         (req : R -> R -> Prop)
.
Variable Rfield : field_theory rO rI radd rmul rsub ropp rdiv rinv req.
Variable Reqeq : Equivalence req.
Variable Reqext : ring_eq_ext radd rmul ropp req.

(* Field notations *)
Notation "0" := rO : R_scope.
Notation "1" := rI : R_scope.
Infix "+" := radd : R_scope.
Infix "*" := rmul : R_scope.
Infix "==" := req : R_scope.

(* Use these notations by default *)
Local Open Scope R_scope.


(* Example lemma *)

Lemma mul_0_l: forall v, (0 * v == 0).
Proof.
  intros v.
  apply ARmul_0_l with rI radd rsub ropp.
  apply F2AF, AF_AR in Rfield; auto.
Qed.

关于符号 请注意,引号是
表示法
/
中缀
命令语法的一部分

Infix "+" := radd : R_scope.
您现在可以只写
x+y
,不加引号

将作用域分配给您的符号(例如,通过上面的
:R\u scope
注释)是一种很好的做法,因为这样可以实现消除同一符号不同含义歧义的机制。特别是,提供符号的主要两种方法是:

  • 本地打开范围R\u范围。
    使所有
    R\u范围
    符号可用于当前文件

  • Bind Scope R\u Scope with which.
    将定界键
    which
    与作用域
    R\u Scope
    关联。定界键是在
    %
    符号之后打开给定表达式中的作用域的键,因此您可以编写
    (0==0*v)%whatever
    ,无论
    R\u作用域
    以前是否使用
    本地打开作用域
    打开

以下是一个基于@Li yao Xia的(失败的)尝试:

(***********)
(* IMPORTS *)
(***********)
Require Import Coq.setoid_ring.Field_theory.
Require Import Coq.setoid_ring.Ring_theory.

(**********)
(* SCOPES *)
(**********)
Delimit Scope R_scope with ring.

(************)
(* SECTIONS *)
(************)
Section MyFieldTheory.

(* Theory parameterized by a field R *)
Variable (R:Type)
         (rO:R) (rI:R)
         (radd rmul rsub : R -> R -> R)
         (ropp : R -> R)
         (rdiv : R -> R -> R)
         (rinv : R -> R)
         (req : R -> R -> Prop)
.
Variable Rfield : field_theory rO rI radd rmul rsub ropp rdiv rinv req.

(*******************)
(* Field notations *)
(*******************)
Notation "0" := rO   : R_scope.
Notation "1" := rI   : R_scope.
Infix    "+" := radd : R_scope.
Infix    "*" := rmul : R_scope.
(*******************)
(* Field notations *)
(*******************)
Infix "==" := req (at level 70, no associativity) : R_scope.

(* Use these notations by default *)
Local Open Scope R_scope.


(* Example lemma *)

Lemma mul_0_l: forall v, (0 * v == 0).
Proof.
  intros v.
  apply ARmul_0_l with rI radd rsub ropp.
  apply Rfield.
在我的假设中:

Rfield : field_theory 0 1 radd rmul rsub ropp rdiv rinv req
目标是:

almost_ring_theory 0 1 radd rmul rsub ropp req
我想一定有这样的说法:
场理论->几乎环理论
。 但是当我尝试
应用Rfield
时,我得到了:

In environment
R : Type
rO, rI : R
radd, rmul, rsub : R -> R -> R
ropp : R -> R
rdiv : R -> R -> R
rinv : R -> R
req : R -> R -> Prop
Rfield : field_theory 0 1 radd rmul rsub ropp rdiv rinv req
v : R
Unable to unify "field_theory 0 1 radd rmul rsub ropp rdiv rinv req" with
 "almost_ring_theory 0 1 radd rmul rsub ropp req".

0v=v
?你是说
0v=0
1v=v
?@HTNW谢谢,我修正了打字错误。。。这是
0v==0
我仍然对
“0”
说:
没有对字符串“0”的解释有问题。
这里实际上有几个问题。一个是这些符号实际上是不可用的,另一个是在符号中使用双引号存在混淆。我更新了我的答案以提供更多的细节。我将我的尝试作为一个单独的答案发布,但我仍然无法使它起作用:((我更新了我的答案,并提供了完整的证据。我需要添加以下假设:
req
是一个等价(
equality req
)并且它与字段/环运算(
ring\u eq\u ext
)是一致的),然后转换字典的引理是
F2AF
AF_AR
(这里很可能还有其他可能的引理序列)。我尝试
在Rfield中应用SF2AF
,但没有起作用:
无法应用类型为“forall(R:type)(rO-rI:R)(radd-rmul-rdiv:R->R->R->R)(rinv:R->R)的引理(需求:R->R->Prop),关系类。等价需求->半场理论rO rRadd rmul rdiv rinv需求->几乎场理论rO rRadd rmul(SRsub radd)(SRopp(R:=R))rdiv rinv需求“关于“场理论0 1 rDul rsub ropp rdiv rinv需求”类型的假设
In environment
R : Type
rO, rI : R
radd, rmul, rsub : R -> R -> R
ropp : R -> R
rdiv : R -> R -> R
rinv : R -> R
req : R -> R -> Prop
Rfield : field_theory 0 1 radd rmul rsub ropp rdiv rinv req
v : R
Unable to unify "field_theory 0 1 radd rmul rsub ropp rdiv rinv req" with
 "almost_ring_theory 0 1 radd rmul rsub ropp req".