Coq “le”的归纳原理`

Coq “le”的归纳原理`,coq,agda,induction,parametric-polymorphism,Coq,Agda,Induction,Parametric Polymorphism,对于感应类型nat,生成的感应原理在其语句中使用构造函数O和S: Inductive nat : Set := O : nat | S : nat -> nat nat_ind : forall P : nat -> Prop, P 0 -> (forall n : nat, P n -> P (S n)) -> forall n : nat, P n 但是对于le,生成的语句不使用构造函数le\u n和le\u S: Inductive le

对于感应类型
nat
,生成的感应原理在其语句中使用构造函数
O
S

Inductive nat : Set :=  O : nat | S : nat -> nat

nat_ind
 : forall P : nat -> Prop,
   P 0 ->
   (forall n : nat, P n -> P (S n)) -> forall n : nat, P n
但是对于
le
,生成的语句不使用构造函数
le\u n
le\u S

Inductive le (n : nat) : nat -> Prop :=
le_n : n <= n | le_S : forall m : nat, n <= m -> n <= S m

le_ind
 : forall (n : nat) (P : nat -> Prop),
   P n ->
   (forall m : nat, n <= m -> P m -> P (S m)) ->
   forall n0 : nat, n <= n0 -> P n0

我想生成一个更方便。但是Coq是如何为其生成的归纳原理选择形状的呢?如果有任何规则,我在参考手册中找不到。其他证明助手(如Agda)如何?

您可以使用命令
Scheme
(请参阅)手动生成归纳类型的归纳原则

该命令有两种风格:

  • 方案方案:=排序属性的归纳
    生成标准归纳方案
  • Scheme Scheme:=排序属性的最小值
    生成更适合归纳谓词的简化归纳方案
如果在
类型
中定义感应类型,则生成的感应原理属于第一类。如果在
Prop
中定义归纳类型(即归纳谓词),则生成的归纳原则属于第二类

要获得在
le
情况下所需的归纳原则,可以在
类型中定义它:

Inductive le (n : nat) : nat -> Type :=
| le_n : le n n
| le_S : forall m : nat, le n m -> le n (S m).

Check le_ind.
(* forall (n : nat) (P : forall n0 : nat, le n n0 -> Prop),
   P n (le_n n) ->
   (forall (m : nat) (l : le n m), P m l -> P (S m) (le_S n m l)) ->
   forall (n0 : nat) (l : le n n0), P n0 l
*)
或者您可以手动要求Coq生成预期的归纳原则:

Inductive le (n : nat) : nat -> Prop :=
| le_n : le n n
| le_S : forall m : nat, le n m -> le n (S m).

Check le_ind.
(* forall (n : nat) (P : nat -> Prop),
   P n ->
   (forall m : nat, le n m -> P m -> P (S m)) ->
   forall n0 : nat, le n n0 -> P n0
*)

Scheme le_ind2 := Induction for le Sort Prop.
Check le_ind2.
(* forall (n : nat) (P : forall n0 : nat, le n n0 -> Prop),
   P n (le_n n) ->
   (forall (m : nat) (l : le n m), P m l -> P (S m) (le_S n m l)) ->
   forall (n0 : nat) (l : le n n0), P n0 l
*)

我不明白这一点:
生成的语句没有使用构造函数le\u n和le\u S
。在对
n@dyukha进行归纳时,我指的是
leu ind
的陈述(即类型)。您可以清楚地看到,
le_n
le_S
不会发生。请尝试访问“交互式定理证明和程序开发,CoqArt:归纳结构演算”,您所要求的内容在第章中描述。14.我只在网上找到了法文版,第14章似乎是关于共引的。顺便说一句,这样一本好书没有得到更好的宣传,真是遗憾。
Inductive le (n : nat) : nat -> Prop :=
| le_n : le n n
| le_S : forall m : nat, le n m -> le n (S m).

Check le_ind.
(* forall (n : nat) (P : nat -> Prop),
   P n ->
   (forall m : nat, le n m -> P m -> P (S m)) ->
   forall n0 : nat, le n n0 -> P n0
*)

Scheme le_ind2 := Induction for le Sort Prop.
Check le_ind2.
(* forall (n : nat) (P : forall n0 : nat, le n n0 -> Prop),
   P n (le_n n) ->
   (forall (m : nat) (l : le n m), P m l -> P (S m) (le_S n m l)) ->
   forall (n0 : nat) (l : le n n0), P n0 l
*)