证明Coq中无穷诱导值的不存在性

证明Coq中无穷诱导值的不存在性,coq,proof,induction,Coq,Proof,Induction,假设我有一个非常简单的归纳类型: Inductive ind : Set := | ind0 : ind | ind1 : ind -> ind. 我想证明某些价值观是不存在的。具体来说,不可能有无根据的值:~存在i,i=ind1i 我在网上找了一下,什么也没找到。我能够写: Fixpoint depth (i : ind) : nat := match i with | ind0 => 0 | ind1 i2 => 1 + dept

假设我有一个非常简单的归纳类型:

Inductive ind : Set :=
    | ind0 : ind
    | ind1 : ind -> ind.
我想证明某些价值观是不存在的。具体来说,不可能有无根据的值:
~存在i,i=ind1i

我在网上找了一下,什么也没找到。我能够写:

Fixpoint depth (i : ind) : nat :=
    match i with
    | ind0 => 0
    | ind1 i2 => 1 + depth i2
    end.

Goal ~exists i, i = ind1 i.
Proof.
    intro. inversion_clear H.
    remember (depth x) as d.
    induction d.
        rewrite H0 in Heqd; simpl in Heqd. discriminate.
        rewrite H0 in Heqd; simpl in Heqd. injection Heqd. assumption.
Qed.

这是可行的,但看起来非常丑陋和不一般。

我认为没有一个通用的方法来证明这些目标。然而,根据我的经验,这似乎不是一个问题。在您的案例中,有一个更简单的证明,使用
一致性
策略:

Inductive ind : Type :=
| ind0 : ind
| ind1 : ind -> ind.

Goal ~exists i, i = ind1 i.
Proof.
  intros [x Hx]. induction x; congruence.
Qed.

我不认为有一个通用的方法来证明这些目标。然而,根据我的经验,这似乎不是一个问题。在您的案例中,有一个更简单的证明,使用
一致性
策略:

Inductive ind : Type :=
| ind0 : ind
| ind1 : ind -> ind.

Goal ~exists i, i = ind1 i.
Proof.
  intros [x Hx]. induction x; congruence.
Qed.

我将证明所有n1的
,n1=succn1为假
,并将其放入自动重写数据库中

Require Import Coq.Setoids.Setoid.

Lemma L1 : forall P1, (P1 <-> P1) <-> True.
Proof. tauto. Qed.

Hint Rewrite L1 : LogHints.

Lemma L2 : forall (S1 : Set) (e1 : S1), e1 = e1 <-> True.
Proof. tauto. Qed.

Hint Rewrite L2 : LogHints.

Lemma L3 : forall n1, O = S n1 <-> False.
Proof.
intros. split.
  intros H1. inversion H1.
  tauto.
Qed.

Lemma L4 : forall n1, S n1 = O <-> False.
Proof.
intros. split.
  intros H1. inversion H1.
  tauto.
Qed.

Lemma L5 : forall n1 n2, S n1 = S n2 <-> n1 = n2.
Proof.
intros. split.
  intros H1. inversion H1 as [H2]. tauto.
  intros H1. rewrite H1. tauto.
Qed.

Hint Rewrite L3 L4 L5 : NatHints.

Lemma L6 : forall n1, n1 = S n1 <-> False.
Proof.
induction n1 as [| n1 H1];
  autorewrite with LogHints NatHints;
  tauto.
Qed.

Lemma L7 : forall n1, S n1 = n1 <-> False.
Proof.
induction n1 as [| n1 H1];
  autorewrite with LogHints NatHints;
  tauto.
Qed.

Hint Rewrite L6 L7 : NatHints.
需要导入Coq.Setoids.Setoid。
引理L1:对于所有P1,(P1)为真。
证明。陶托。Qed。
提示重写L1:日志提示。
引理L2:forall(S1:Set)(e1:S1),e1=e1真。
证明。陶托。Qed。
提示重写L2:LogHints。
引理L3:对于所有n1,O=sn1为假。
证明。
介绍。分裂
介绍H1。反转H1。
陶托。
Qed。
引理L4:对于所有n1,sn1=O假。
证明。
介绍。分裂
介绍H1。反转H1。
陶托。
Qed。
引理L5:对于所有n1n2,sn1=sn2n1=n2。
证明。
介绍。分裂
介绍H1。反转H1为[H2]。陶托。
介绍H1。重写H1。陶托。
Qed。
提示重写L3 L4 L5:NatHints。
引理L6:对于所有n1,n1=sn1为假。
证明。
诱导n1为[| n1 H1];
自动重新写入日志提示;
陶托。
Qed。
引理L7:对于所有n1,S n1=n1为假。
证明。
诱导n1为[| n1 H1];
自动重新写入日志提示;
陶托。
Qed。
提示重写L6 L7:NatHints。

我将证明所有n1的
,n1=succn1为假
,并将其放入自动重写数据库中

Require Import Coq.Setoids.Setoid.

Lemma L1 : forall P1, (P1 <-> P1) <-> True.
Proof. tauto. Qed.

Hint Rewrite L1 : LogHints.

Lemma L2 : forall (S1 : Set) (e1 : S1), e1 = e1 <-> True.
Proof. tauto. Qed.

Hint Rewrite L2 : LogHints.

Lemma L3 : forall n1, O = S n1 <-> False.
Proof.
intros. split.
  intros H1. inversion H1.
  tauto.
Qed.

Lemma L4 : forall n1, S n1 = O <-> False.
Proof.
intros. split.
  intros H1. inversion H1.
  tauto.
Qed.

Lemma L5 : forall n1 n2, S n1 = S n2 <-> n1 = n2.
Proof.
intros. split.
  intros H1. inversion H1 as [H2]. tauto.
  intros H1. rewrite H1. tauto.
Qed.

Hint Rewrite L3 L4 L5 : NatHints.

Lemma L6 : forall n1, n1 = S n1 <-> False.
Proof.
induction n1 as [| n1 H1];
  autorewrite with LogHints NatHints;
  tauto.
Qed.

Lemma L7 : forall n1, S n1 = n1 <-> False.
Proof.
induction n1 as [| n1 H1];
  autorewrite with LogHints NatHints;
  tauto.
Qed.

Hint Rewrite L6 L7 : NatHints.
需要导入Coq.Setoids.Setoid。
引理L1:对于所有P1,(P1)为真。
证明。陶托。Qed。
提示重写L1:日志提示。
引理L2:forall(S1:Set)(e1:S1),e1=e1真。
证明。陶托。Qed。
提示重写L2:LogHints。
引理L3:对于所有n1,O=sn1为假。
证明。
介绍。分裂
介绍H1。反转H1。
陶托。
Qed。
引理L4:对于所有n1,sn1=O假。
证明。
介绍。分裂
介绍H1。反转H1。
陶托。
Qed。
引理L5:对于所有n1n2,sn1=sn2n1=n2。
证明。
介绍。分裂
介绍H1。反转H1为[H2]。陶托。
介绍H1。重写H1。陶托。
Qed。
提示重写L3 L4 L5:NatHints。
引理L6:对于所有n1,n1=sn1为假。
证明。
诱导n1为[| n1 H1];
自动重新写入日志提示;
陶托。
Qed。
引理L7:对于所有n1,S n1=n1为假。
证明。
诱导n1为[| n1 H1];
自动重新写入日志提示;
陶托。
Qed。
提示重写L6 L7:NatHints。

或者,您可以编写证明

Definition IsO (n1 : nat) : Prop :=
  match n1 with
  | O   => True
  | S _ => False
  end.

Definition eq_O {n1 : nat} (H1 : O = n1) : IsO n1 :=
  match H1 with
  | eq_refl => I
  end.

Definition O_S_impl {n1 : nat} (H1 : O = S n1) : False := eq_O H1.

Definition S_S_impl {n1 n2 : nat} (H1 : S n1 = S n2) : n1 = n2 :=
  match H1 with
  | eq_refl => eq_refl
  end.

Fixpoint nat_inf'' {n1 : nat} : n1 = S n1 -> False :=
  match n1 with
  | O   => fun H1 => O_S_impl H1
  | S _ => fun H1 => nat_inf'' (S_S_impl H1)
  end.

Definition nat_inf' (H1 : exists n1, n1 = S n1) : False :=
  match H1 with
  | ex_intro _ H2 => nat_inf'' H2
  end.

Definition nat_inf : ~ exists n1, n1 = S n1 := nat_inf'.

或者,你也可以编写你的证明

Definition IsO (n1 : nat) : Prop :=
  match n1 with
  | O   => True
  | S _ => False
  end.

Definition eq_O {n1 : nat} (H1 : O = n1) : IsO n1 :=
  match H1 with
  | eq_refl => I
  end.

Definition O_S_impl {n1 : nat} (H1 : O = S n1) : False := eq_O H1.

Definition S_S_impl {n1 n2 : nat} (H1 : S n1 = S n2) : n1 = n2 :=
  match H1 with
  | eq_refl => eq_refl
  end.

Fixpoint nat_inf'' {n1 : nat} : n1 = S n1 -> False :=
  match n1 with
  | O   => fun H1 => O_S_impl H1
  | S _ => fun H1 => nat_inf'' (S_S_impl H1)
  end.

Definition nat_inf' (H1 : exists n1, n1 = S n1) : False :=
  match H1 with
  | ex_intro _ H2 => nat_inf'' H2
  end.

Definition nat_inf : ~ exists n1, n1 = S n1 := nat_inf'.

工作完美。今天我学到了一些关于
简介的新知识。谢谢工作完美。今天我学到了一些关于
简介的新知识。谢谢