Math Coq中的莱布尼兹性质

Math Coq中的莱布尼兹性质,math,coq,Math,Coq,我对自然数的等式有这样的定义: Fixpoint equal_nat (n m : nat) : bool := match n, m with | O, O => true | O, S _ => false | S _, O => false | S n1, S n2 => equal_nat n1 n2 end. (这几乎是标准定义) 我试图证明以下命题: Proposition equal_nat_correct :

我对自然数的等式有这样的定义:

Fixpoint equal_nat (n m : nat) : bool := 
  match n, m with
    | O, O => true
    | O, S _ => false
    | S _, O => false
    | S n1, S n2 => equal_nat n1 n2
  end.
(这几乎是标准定义)

我试图证明以下命题:

Proposition equal_nat_correct :
  forall a b : nat, a = b <-> equal_nat a b = true.
命题相等但不正确:
对于所有a b:nat,a=b等于a b=true。
我可以做前一半的证明,但不能做另一半。。。你能给我一个提示吗?以下是我迄今为止所做的工作:

Proof.
  intros.
  split.

  (* => *)
  destruct a.
  destruct b.
  reflexivity.
  discriminate.
  intros. destruct H. simpl.
  induction a. reflexivity.
  simpl. assumption.

  (* <= *)
  (* ? *)
Qed.
证明。
介绍。
分裂
(* => *)
破坏a。
破坏b。
自反性。
区别对待
介绍。破坏H.simpl。
归纳法a。自反性。
简单。假设。
(*  *)
回复b。
诱导a为[| a hi];介绍| b |;简单输入*;直觉
区别对待
区别对待

(*这两个部分的想法都是通过
归纳法
,但在你执行之前,你必须小心你的上下文。在你的特殊情况下,你不应该马上介绍
b
。我会这样做前半部分:

intros.
split.
revert b. (* puts b back into the goal, so that it is generalized correctly by induction *)
induction a as [ | a hi ]. (* this just gives explicit names to the term newly created by induction *)
  intro [ | b ]. (* this is equalivalent to intro b. destruct b as [ | b ]. *)
    intros; simpl; reflexivity.
    intros; discriminate.

  intro [ | b ].
    intros; discriminate.
    intros h; injection h; intros h2.
    simpl; apply hi; assumption
简短的版本是:

intros.
split.
revert b.
induction a as [ | a hi]; intros [ | b ]; simpl in *; intuition.
discriminate.
discriminate.
遵循相同的模式(不要忘记在目标中概括
b
),您应该能够完成证明的后半部分

intros.
split.
revert b.
induction a as [ | a hi]; intros [ | b ]; simpl in *; intuition.
discriminate.
discriminate.