如何在coq中定义有限域

如何在coq中定义有限域,coq,Coq,我试图在证明检查器coq中定义一个域。我该怎么做 我正在尝试做[0,10]中的V 我试着做了Definition V:=对于R中的所有V,0一个简单的方法可能是 Require Import Omega. Inductive V : Set := mkV : forall (v:nat), 0 <= v /\ v <= 10 -> V. Lemma member0 : V. Proof. apply (mkV 0). omega. Qed. Definition in

我试图在证明检查器coq中定义一个域。我该怎么做

我正在尝试做[0,10]中的
V


我试着做了
Definition V:=对于R中的所有V,0一个简单的方法可能是

Require Import Omega.

Inductive V : Set :=
  mkV : forall (v:nat), 0 <= v /\ v <= 10 -> V.

Lemma member0 : V.
Proof. apply (mkV 0). omega. Qed.

Definition inc (v:V) : nat := match v with mkV n _ => n + 1 end.

Lemma inc_bounds : forall v, 0 <= inc v <= 11.
Proof. intros v; destruct v; simpl. omega. Qed.
我以前没有使用过
Reals
,但上述功能也可以在
R
上实现

Require Import Reals.
Require Import Fourier.
Open Scope R_scope.

Inductive V : R -> Set :=
  mkV : forall (v:R), 0 <= v /\ v <= 10 -> V v.

Lemma member0 : V 0.
Proof. apply (mkV 0). split. right; auto. left; fourier. Qed.

Definition inc {r} (v:V r) : R := r + 1.

Lemma inc_bounds : forall {r:R} (v:V r), 0 <= inc v <= 11.
Proof. intros r v; unfold inc. 
  destruct v as (r,pf). destruct pf. split; fourier. 
Qed.
需要导入real。
需要输入傅里叶变换。
打开范围R\u范围。
感应式V:R->设置:=

mkV:forall(v:R),0一个简单的方法可能是

Require Import Omega.

Inductive V : Set :=
  mkV : forall (v:nat), 0 <= v /\ v <= 10 -> V.

Lemma member0 : V.
Proof. apply (mkV 0). omega. Qed.

Definition inc (v:V) : nat := match v with mkV n _ => n + 1 end.

Lemma inc_bounds : forall v, 0 <= inc v <= 11.
Proof. intros v; destruct v; simpl. omega. Qed.
我以前没有使用过
Reals
,但上述功能也可以在
R
上实现

Require Import Reals.
Require Import Fourier.
Open Scope R_scope.

Inductive V : R -> Set :=
  mkV : forall (v:R), 0 <= v /\ v <= 10 -> V v.

Lemma member0 : V 0.
Proof. apply (mkV 0). split. right; auto. left; fourier. Qed.

Definition inc {r} (v:V r) : R := r + 1.

Lemma inc_bounds : forall {r:R} (v:V r), 0 <= inc v <= 11.
Proof. intros r v; unfold inc. 
  destruct v as (r,pf). destruct pf. split; fourier. 
Qed.
需要导入real。
需要输入傅里叶变换。
打开范围R\u范围。
感应式V:R->设置:=

mkV:forall(v:R),0我相信这样做的自然方式是使用sig类型,Yves在评论中也提到了这一点

V的元素将是R中的数字x,以及证明它们确实应该在集合V中的证明

Require Import Reals Fourier.
Open Scope R_scope.

Definition V_prop (x : R) : Prop := 0 <= x /\ x <= 10.

Definition V : Set := { x : R | V_prop x }.

Lemma V_prop0: V_prop 0.
Proof.
    unfold V_prop; split;
    [right; auto | left; fourier].
Qed.

Definition V0 : V := exist _ 0 V_prop0.
需要导入实数傅立叶。
打开范围R\u范围。

定义V_prop(x:R):prop:=0我相信实现这一点的自然方法是使用sig类型,Yves在评论中也提到了这一点

V的元素将是R中的数字x,以及证明它们确实应该在集合V中的证明

Require Import Reals Fourier.
Open Scope R_scope.

Definition V_prop (x : R) : Prop := 0 <= x /\ x <= 10.

Definition V : Set := { x : R | V_prop x }.

Lemma V_prop0: V_prop 0.
Proof.
    unfold V_prop; split;
    [right; auto | left; fourier].
Qed.

Definition V0 : V := exist _ 0 V_prop0.
需要导入实数傅立叶。
打开范围R\u范围。

定义V_prop(x:R):prop:=0在我看来,这个答案有一个小缺陷。您肯定不想用集合中的值为V的每个元素编制索引。此外,您还可以使用sig类型,例如(sig)(在我看来,这个答案有一个小缺陷。您肯定不想用集合中的值来索引V的每个元素。此外,您还可以使用sig类型,例如(sig(乐趣x:nat=>x自Coq 8.9.0以来,
fourier
策略已被弃用。出于兼容性原因,
fourier
被定义为
lra
策略的同义词(您可能需要
首先需要导入lra.
).自Coq 8.9.0以来,
fourier
策略已被弃用。出于兼容性原因,
fourier
被定义为
lra
策略的同义词(您可能需要
首先导入lra.
)。