Coq 如何正确地将定义放入定理中?

Coq 如何正确地将定义放入定理中?,coq,type-theory,Coq,Type Theory,我已经完成了霍特书中定理2.8.1的coq证明(如下所示)。它工作,但我得到这个警告 Toplevel input, characters 0-4: <warning> Warning: Nested proofs are deprecated and will stop working in a future Coq version [deprecated-nested-proofs,deprecated]</warning> 使用pose定义术语应该有效:(尽管可能

我已经完成了霍特书中定理2.8.1的coq证明(如下所示)。它工作,但我得到这个警告

Toplevel input, characters 0-4:
<warning>
Warning: Nested proofs are deprecated and will stop working in a future Coq
version [deprecated-nested-proofs,deprecated]</warning>

使用
pose
定义术语应该有效:(尽管可能有其他方法)

需要导出HoTT。
定理th_2_8_1:
对于所有(xy:单位),单位x=y。
证明。
姿势(g:=fun(xy:Unit)(p:x=y)=>将p与idpath匹配=>tt-end)。
姿势(f:=乐趣(x y:单位)(s:单位)=>
将x,y,s返回(x=y)与tt,tt,tt=>idpath end)匹配。
姿势(字母1:=乐趣(x y:单位)(s:单位)=>
匹配x,y,s返回((g x y)o(f x y))s=s
使用tt,tt,tt=>idpath end)。
姿势(P:=有趣
(f:forall(xy:Unit)(s:Unit),x=y)
(g:forall(xy:Unit)(p:x=y,Unit)
(x y:单位)
(p:x=y)
=>
((f x y)o(g x y))p=p)。
姿势(h:=乐趣(x:单位)=>
匹配x返回P f g x idpath
使用tt=>idpath idpath end)。
姿势(字母2:=fun(xy:Unit)(p:x=y)=>(J单位(pfg)h)xyp)。
简介xy。
存在(f x y)。
应用(构建等效单位(x=y)(f x y)(g x y)(alpha2 x y)(alpha1 x y))。
感应x0。

重写我要说的是,不要太担心那个警告,你可以用
-w弃用嵌套校样
标志禁用它。谢谢你的提示。但我还是想摆脱它们,这不仅是因为它将使我的代码版本在未来变得依赖,而且特别是因为应该有更好的方法来做到这一点,因为我是初学者,我想学习并使用适当的命令。我认为嵌套定义不会很快消失。
Require Export HoTT.

Definition J (A:Type) (P : forall (x y:A), x = y -> Type)
           (h : forall x:A, P x x idpath) :
  forall (x y:A) (p:x=y), P x y p
  :=
    fun x y p => match p with idpath => h x end.

Theorem th_2_8_1 :
  forall (x y:Unit), Unit <~> x=y.
Proof.

  Definition g (x y:Unit)(p:x=y) : Unit :=
    match p with idpath => tt end.

  Definition f (x y:Unit)(s:Unit) : x=y :=
    match x,y,s with tt,tt,tt => idpath end.

  Definition alpha1 (x y:Unit)(s:Unit) : ((g x y) o (f x y))s = s
    :=
      match x,y,s with tt,tt,tt => idpath end.

  Definition P (f : forall (x y:Unit)(s:Unit), x=y) 
               (g : forall (x y:Unit)(p:x=y), Unit)
               (x y:Unit) (p:x=y) : Type
    :=
      ((f x y) o (g x y)) p = p.

  Definition h (x:Unit) : P f g x x idpath
    :=
      match x with tt => idpath idpath end.

  Definition alpha2 (x y:Unit)(p:x=y): ((f x y) o (g x y)) p = p :=
    (J Unit (P f g) h) x y p.


  intros x y.
  exists (f x y).
  apply(BuildIsEquiv Unit (x=y) (f x y) (g x y) (alpha2 x y) (alpha1 x y)).

  induction x0.
  rewrite <- (f x y).
  induction x.
  simpl.
  apply(idpath idpath).
  apply(tt).
Defined
Require Export HoTT.

Theorem th_2_8_1 :
  forall (x y:Unit), Unit <~> x=y.
Proof.

  pose(g:=fun (x y:Unit)(p:x=y) => match p with idpath => tt end).

  pose(f := fun (x y:Unit)(s:Unit) =>
              match x,y,s return (x=y) with tt,tt,tt => idpath end).

  pose( alpha1 := fun (x y:Unit)(s:Unit) =>
      match x,y,s return ((g x y) o (f x y))s = s
      with tt,tt,tt => idpath end).

  pose(P := fun
             (f : forall (x y:Unit)(s:Unit), x=y)
             (g : forall (x y:Unit)(p:x=y), Unit)
             (x y:Unit)
             (p:x=y)
    =>
      ((f x y) o (g x y)) p = p).

  pose(h := fun (x:Unit) =>
       match x return P f g x x idpath
       with tt => idpath idpath end).

  pose(alpha2 := fun (x y:Unit)(p:x=y) => (J Unit (P f g) h) x y p).


  intros x y.
  exists (f x y).
  apply(BuildIsEquiv Unit (x=y) (f x y) (g x y) (alpha2 x y) (alpha1 x y)).

  induction x0.
  rewrite <- (f x y).
  induction x.
  simpl.
  apply(idpath idpath).
  apply(tt).
Defined.