当“记录”类型在Coq中具有相关联的活页夹时,构造一个新的记录实例

时间:2018-11-25 03:38:09

标签: record coq

我打算在下面的代码中构造一个Vector类型的新vector实例。但是,最初,向量记录类型具有从属标识符绑定器。就像第二个ident binder' or the second field -- 'proof' was dependent on the first ident活页夹'-'mpOf'。当我尝试定义两个质量点的减法时,我发现不可能通过coq核。

Require Export Coq.Reals.Reals.
Open Scope R_scope.

Definition Point:= Type.

Record massPoint: Type := cons{number: R; point: Point}.

Definition isVector (v:massPoint) := exists A B : Point, v = add_MP(cons (-1) A)(cons 1 B).

Record Vector : Type := vecCons { mpOf : massPoint ; proof : isVector mpOf}.

Variable sub_MP: massPoint -> massPoint -> massPoint.


Definition point_sub (p1 p2: massPoint):Vector:=
vecCons (sub_MP p1 p2) proof (sub_MP p1 p2). (* errorsome definition*)

有人知道如何定义point_sub吗?

1 个答案:

答案 0 :(得分:2)

关于证明是什么,您遇到基本的实例化问题。例如,请参见以下代码,并尝试了解您缺少的内容:

Require Import Coq.Reals.Reals.
Open Scope R_scope.

Definition Point := Type.
Record massPoint: Type := cons { number: R; point: Point}.

Variable add_MP: massPoint -> massPoint -> massPoint.
Variable sub_MP: massPoint -> massPoint -> massPoint.

Definition isVector (v : massPoint) :=
  exists A B : Point, v = add_MP (cons (-1) A) (cons 1 B).

Record Vector : Type := vecCons { mpOf : massPoint; proof : isVector mpOf }.

Definition point_sub (p1 p2: massPoint) : Vector.
Proof.
refine (vecCons (sub_MP p1 p2) _).
repeat eexists.