Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/date/2.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 小于等于函数_Coq_Logical Foundations - Fatal编程技术网

Coq 小于等于函数

Coq 小于等于函数,coq,logical-foundations,Coq,Logical Foundations,我正在通过coq课程。解决问题: 具有较少或相等的功能: Fixpoint leb (n m : nat) : bool := match n with | O => true | S n' => match m with | O => false | S m' => leb n' m' end end. Definition blt_nat (n m : nat) : bool (* REPLACE

我正在通过coq课程。解决问题:

具有较少或相等的功能:

Fixpoint leb (n m : nat) : bool :=
  match n with
  | O => true
  | S n' =>
      match m with
      | O => false
      | S m' => leb n' m'
      end
  end.
Definition blt_nat (n m : nat) : bool
  (* REPLACE THIS LINE WITH ":= _your_definition_ ." *). Admitted.
创建“小于”功能:

Fixpoint leb (n m : nat) : bool :=
  match n with
  | O => true
  | S n' =>
      match m with
      | O => false
      | S m' => leb n' m'
      end
  end.
Definition blt_nat (n m : nat) : bool
  (* REPLACE THIS LINE WITH ":= _your_definition_ ." *). Admitted.
据我所知,它应该是这样工作的:

if (n == m)
   return false
else
    return (leb n m)
我创造了这个:

Definition blt_nat (n m : nat) : bool
  match n with
  | m => false
  | _ => leb n m
  end.
但它不起作用-输出:“错误:此子句是多余的。”对于行:

| _ => leb n m

请帮助。

使用
匹配。。。使用…end
,我们只需检查特定数据类型的构造函数,并了解它是如何基于其构造函数构建的。因此,您无法将一个nat数据类型与另一个nat数据类型进行匹配。您可以在中找到其他示例


我对
coq
没有经验,但我怀疑第一个案例
|m=>…
m
不匹配,而是匹配任何值并调用该值
m
(覆盖原始
m
)。这可能会有帮助: