Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2008/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
Types 如何在coq中定义自定义归纳原则?_Types_Coq_Agda_Coq Tactic_Induction - Fatal编程技术网

Types 如何在coq中定义自定义归纳原则?

Types 如何在coq中定义自定义归纳原则?,types,coq,agda,coq-tactic,induction,Types,Coq,Agda,Coq Tactic,Induction,这是我之前问过的一个后续问题,但现在我只是尝试实现我自己的平等类型归纳原则,如果没有某种模式匹配,我不知道该怎么做。我在下面的定义中避免使用诱导策略,因为这显然会导致一种鸡对蛋的难题。除了indction之外,还有其他一些基本策略,以及通过普通的定义J2:=…,有没有可能做到这一点 (* define a similair induction principle from this agda code*) J2 : {A : Set} → (D : (x y : A) → (I A x y) →

这是我之前问过的一个后续问题,但现在我只是尝试实现我自己的平等类型归纳原则,如果没有某种模式匹配,我不知道该怎么做。我在下面的定义中避免使用诱导策略,因为这显然会导致一种鸡对蛋的难题。除了indction之外,还有其他一些基本策略,以及通过普通的定义J2:=…,有没有可能做到这一点

(* define a similair induction principle from this agda code*)
J2 : {A : Set} → (D : (x y : A) → (I A x y) →  Set)
  →  (d : (a : A) → (D a a r )) → (x y : A) → (p : I A x y) → D x y p
J2 D d x .x r = d x
这将产生以下错误,并且我不确定如何指示p必须是没有诱导策略的refl

1 subgoal (ID 34)

  A : Type
  D : forall x y : A, Id A x y -> Prop
  d : forall a : A, D a a (refl A a)
  y : A
  p : Id A y y
  ============================
  D y y p
这将产生以下错误

Error:
In environment
A : Type
D : forall x y : A, Id A x y -> Prop
d : forall a : A, D a a (refl A a)
y : A
p : Id A y y
Unable to unify "D y y (refl A y)" with "D y y p".
Error:
Unable to apply lemma of type "forall a : A, D a a (refl A a)"
on hypothesis of type "A".
最后,一个伴随错误,当我尝试在y中编写
apply d
时,我得到以下错误

Error:
In environment
A : Type
D : forall x y : A, Id A x y -> Prop
d : forall a : A, D a a (refl A a)
y : A
p : Id A y y
Unable to unify "D y y (refl A y)" with "D y y p".
Error:
Unable to apply lemma of type "forall a : A, D a a (refl A a)"
on hypothesis of type "A".

为什么typechecker不高兴?

使用
析构函数p
而不是
反转p
,它以一种简单的方式进行模式匹配

反演
仅适用于目标中未使用证明条件的假设。此处目标中使用了
p

除了indction之外,还有其他一些基本策略,以及通过普通的定义J2:=…,有没有可能做到这一点

(* define a similair induction principle from this agda code*)
J2 : {A : Set} → (D : (x y : A) → (I A x y) →  Set)
  →  (d : (a : A) → (D a a r )) → (x y : A) → (p : I A x y) → D x y p
J2 D d x .x r = d x
让我回答你问题的第二部分:

Inductive Id (A : Type) (x : A) : A -> Type :=
  | refl : Id A x x.

Definition J2 {A} :
  forall
    (D : forall (x y : A), Id A x y -> Prop)
    (d : forall (a : A), (D a a (refl A a)))
    (x y : A) (p : Id A x y),
    D x y p
:=
  fun D d x y p =>
    match p in Id _ _ y
            return D x y p
    with
    | refl _ _ => d x
    end.

如果您不知道,您可以使用
未设置的消除方案禁用归纳原则的生成。
有一种方法可能有效。但是,
倒装法
总的来说有点乱……作为@AntonTrunov对这个伟大答案的额外评论,我们应该永远记住,战术是构式演算基础语言上唯一的助手。因此,许多Agda程序在Coq语法中有一个等价物,而没有使用策略。@Yves是否有任何出版物或资源全面介绍了Coq中从策略到原始Coc语法的转换?例如,如何查看通过某种策略序列给出的证明生成的证明项。在证明进行过程中,当证明结束并保存时(使用
定义的
Qed
),可以调用命令
显示证明。
,您可以使用
Print*name of thm*
查看构造演算中的术语。