有限组的元素

时间:2019-01-18 17:13:48

标签: coq

我想通过以下代码定义组的最小值和最大值,但这有问题。请引导我。

Definition groupmin (sn maxlimit maxsn: nat) : nat := 
   let avg := div maxlimit maxsn in 
   (sn*avg) - (avg - 1).

 Definition groupmax (sn maxlimit maxsn: nat) : nat := 
   let avg := div maxlimit maxsn in sn*avg.

1 个答案:

答案 0 :(得分:0)

显然,您假设存在诸如div函数之类的东西。在裸Coq中,未加载任何库,则不存在此类功能。

要具有类似于自然数除法的功能,建议您加载Arith库。然后,您将被允许使用符号a / b进行除法。

这里是一个例子:

Require Import Arith.
Check (fun x y => x / y).
(* this returns : fun x y : nat => x / y : nat -> nat -> nat *)
Compute (12 / 5).
(* this returns : = 2 : nat *)
Locate "_ / _".
(* this returns : "x / y" := Nat.div x y : nat_scope *)

我仍然不明白您所说的最小和最大数量是什么意思,但是至少您应该能够编写一些系统会接受的Coq代码。