如何处理;假=真;coq定理证明中的命题

如何处理;假=真;coq定理证明中的命题,coq,proof,theorem,Coq,Proof,Theorem,我是coq的新手,正在尝试证明这个定理 Inductive expression : Type := | Var (n : nat) . . Theorem variable_equality : forall x : nat, forall n : nat, ((equals x n) = true) -> (Var x = Var n). 这是平等的定义 Fixpoint equals (n1 : nat) (n2 : nat) := match (n1, n2) w

我是coq的新手,正在尝试证明这个定理

Inductive expression : Type :=
  | Var (n : nat)
.
.

Theorem variable_equality : forall x : nat, forall n : nat,
  ((equals x n) = true) -> (Var x = Var n).
这是平等的定义


Fixpoint equals (n1 : nat) (n2 : nat) :=
  match (n1, n2) with
    | (O, O)      => true
    | (O, S n)    => false
    | (S n, O)    => false
    | (S n, S n') => equals n n'
  end.

到目前为止,这是我的解决方案

Proof.
intros x n. induction x as [| x' IH].
  - destruct n. 
    + reflexivity.
    + simpl. intro. 
我最终得到了这样的结果

1 subgoal 
n : nat
H : false = true
-------------------------
Var 0 = Var (S n)
我理解这个输出意味着如果定理必须是正确的,命题“Var0=Var(sn)”应该跟在命题“false=true”后面,但我不知道如何处理它,并继续我的证明。任何帮助都将不胜感激


提前谢谢

在下列假设中使用
倒装

Goal false=true -> False.
intros H.
inversion H.
Qed.

另一个选项:使用
同余
,而不是
反转

Goal false=true -> False.
  congruence.
Qed.

此策略致力于利用构造器的不相交性。

另一种选择,
歧视
是实现此类目标的专用策略:它应该正好解决此类问题(即假设中不同构造器的相等性),而不是更多

Goal false = true -> False.
discriminate.
Qed.
此外,它是一个终止符,这意味着如果目标在使用后没有得到解决,它就失败了,与
反转
一致
相反,在某些情况下,如果它们没有解决预期的问题,就会以“意外”的方式成功

e、 g

就我个人而言,我使用ssreflect中的[]
(它也是一个终止符)的
来实现此类目标和所有此类“琐碎”目标:

Require Import ssreflect.

Goal false = true -> False.
by [].
Qed.
Goal true = true -> S 1 = S 1.
congruence.
Qed.
Require Import ssreflect.

Goal false = true -> False.
by [].
Qed.