检查coq中的自然数是否小于或等于

检查coq中的自然数是否小于或等于,coq,Coq,我有一个函数(beq\u nat\u refl),它确定两个自然数的相等性,并给出一个布尔值。但现在我想证明一个引理,说明一个自然数x小于或等于x。 我可以使用上述功能(beq\u nat\u refl)吗 定理beq_nat_refl: 福尔n:纳特, 是的。 leq_nat定理: 对于所有x:nat, 如果你定义x,这就行了。这里有一个简单的方法来证明leq_nat来自类似的定义: Fixpoint leb (n m : nat) : bool := match n, m with

我有一个函数(
beq\u nat\u refl
),它确定两个自然数的相等性,并给出一个布尔值。但现在我想证明一个引理,说明一个自然数
x
小于或等于
x
。 我可以使用上述功能(
beq\u nat\u refl
)吗

定理beq_nat_refl:
福尔n:纳特,
是的。
leq_nat定理:
对于所有x:nat,

如果你定义
x,这就行了。这里有一个简单的方法来证明
leq_nat
来自类似的定义:

Fixpoint leb (n m : nat) : bool :=
  match n, m with
  | 0  , _   => true
  | _  , 0   => false
  | S n, S m => leb n m
  end.

Lemma leb_nat_refl : forall (n : nat), leb n n = true.
Proof.
  induction n; simpl.
  + reflexivity.
  + assumption.
Qed.

Lemma leb_nat_reflect : forall (n : nat), leb n n = true <-> n <= n.
Proof.
  induction n; simpl; split; intros.
  + constructor.
  + reflexivity.
  + constructor.
  + apply IHn. constructor.
Qed.

Theorem leq_nat : forall (n : nat), n <= n.
Proof.
  intros.
  apply leb_nat_reflect.
  apply leb_nat_refl.
Qed.
固定点leb(NM:nat):布尔:=
匹配n,m与
|0,=>true
|_u0=>false
|sn,sm=>leb n m
结束。
引理leb_nat_refl:forall(n:nat),leb n=true。
证明。
诱导n;简单。
+自反性。
+假设。
Qed。

引理leb_nat_reflect:forall(n:nat),leb n n=true n为什么
beq_nat_refl
有任何用处?我想你可以用构造函数来证明你的定理。
Fixpoint leb (n m : nat) : bool :=
  match n, m with
  | 0  , _   => true
  | _  , 0   => false
  | S n, S m => leb n m
  end.

Lemma leb_nat_refl : forall (n : nat), leb n n = true.
Proof.
  induction n; simpl.
  + reflexivity.
  + assumption.
Qed.

Lemma leb_nat_reflect : forall (n : nat), leb n n = true <-> n <= n.
Proof.
  induction n; simpl; split; intros.
  + constructor.
  + reflexivity.
  + constructor.
  + apply IHn. constructor.
Qed.

Theorem leq_nat : forall (n : nat), n <= n.
Proof.
  intros.
  apply leb_nat_reflect.
  apply leb_nat_refl.
Qed.