如何在 Coq 中引入 n 个不同的符号
How to introduce n distinct symbols in Coq
我已经创建了组记录。现在我想通过指定组乘法 table.
来构建一个包含 n 个元素(例如 10 个元素)的组
我的问题是我需要 n 个符号作为我组的基础集。我需要 Coq 知道这 n 个元素都是不同的。
到目前为止我想通了
Inductive ground_set : Type := A : ground_set | B : ground_set.
Axiom diff: A<>B.
适用于 n=2。我不知道如何在不创建一些难看的代码的情况下将其扩展到许多元素。
我想有更好的方法来生成这样的集合,但我找不到。
对于 Inductive
定义,您可以免费获得构造函数之间的不等式:
Inductive ground_set : Type := A : ground_set | B : ground_set.
Lemma diff: A <> B.
Proof.
discriminate.
Qed.
胡乱猜测,但可能是这样的:
Inductive ground_set (limit: nat): Set :=
| Elem : forall n, n < limit -> ground_set limit.
Lemma ground_set_discr (limit:nat): forall n p (hn: n < limit) (hp: p < limit),
n <> p -> Elem _ n hn <> Elem _ p hp.
Proof.
intros n p hn hp hdiff h.
inversion h; subst; clear h.
now apply hdiff.
Qed.
确实最好的办法是使用 Vinz 概述的方法。使用一些库会有所帮助,例如,在专门用于有限群推理的 mathcomp 中,您只需编写 'I_n
即可创建具有 n
个不同元素的类型,并且您将免费获得许多属性,例如有限性。
我已经创建了组记录。现在我想通过指定组乘法 table.
来构建一个包含 n 个元素(例如 10 个元素)的组我的问题是我需要 n 个符号作为我组的基础集。我需要 Coq 知道这 n 个元素都是不同的。
到目前为止我想通了
Inductive ground_set : Type := A : ground_set | B : ground_set.
Axiom diff: A<>B.
适用于 n=2。我不知道如何在不创建一些难看的代码的情况下将其扩展到许多元素。
我想有更好的方法来生成这样的集合,但我找不到。
对于 Inductive
定义,您可以免费获得构造函数之间的不等式:
Inductive ground_set : Type := A : ground_set | B : ground_set.
Lemma diff: A <> B.
Proof.
discriminate.
Qed.
胡乱猜测,但可能是这样的:
Inductive ground_set (limit: nat): Set :=
| Elem : forall n, n < limit -> ground_set limit.
Lemma ground_set_discr (limit:nat): forall n p (hn: n < limit) (hp: p < limit),
n <> p -> Elem _ n hn <> Elem _ p hp.
Proof.
intros n p hn hp hdiff h.
inversion h; subst; clear h.
now apply hdiff.
Qed.
确实最好的办法是使用 Vinz 概述的方法。使用一些库会有所帮助,例如,在专门用于有限群推理的 mathcomp 中,您只需编写 'I_n
即可创建具有 n
个不同元素的类型,并且您将免费获得许多属性,例如有限性。