如何解决Coq中无效类型等于的目标?

时间:2012-09-01 01:59:53

标签: types equality proof coq

我的证明脚本给了我愚蠢的类型,如nat = boolnat = list unit我需要用来解决相互矛盾的目标。

在正常的数学中,这将是微不足道的。给定集bool := { true, false }nat := { 0, 1, 2, ... }我知道true ∈ bool,但是true ∉ nat, 因此bool ≠ nat。在Coq中,我甚至不知道如何陈述true :̸ nat

问题

有没有办法证明这些平等是错误的?或许,这不可能吗?

(编辑:删除了一长串失败的attemts,仍然可以在历史中看到。)

1 个答案:

答案 0 :(得分:1)

扩展部分解决方案

作为参考,这是我对nat = bool -> False的证明。 (这很长,但我希望很容易看到这个证明的一般结构。)

Goal nat = bool -> False.
  (* For any two types, if they are actually identical, the identity is an
     isomorphism. *)
  assert (forall (T U : Set), T = U ->
              exists (f : T -> U) (g : U -> T),
              (forall t, (g (f t)) = t) /\ (forall u, (f (g u)) = u))
          as Hiso
  by (intros T U H; rewrite H; exists (@id U); exists (@id U);
          split; intro; reflexivity).
  (* our nat = bool *)
  intro HC.
  (* combining the facts gives an iso between nat and bool *)
  pose proof (Hiso nat bool HC); clear HC Hiso.
  inversion H as [phi [phi_inv [Hl Hr]]]; clear H Hr.
  (* this breaks because ||bool|| = 2 while ||nat|| > 2 -- we get collisions *)
  assert (forall m n o,
              phi m = phi n \/ phi n = phi o \/ phi m = phi o)
   by (intros m n o;
        case (phi m); case (phi n); case (phi o); clear; tauto).
  (* building the collision for 0, 1 and 2 *)
  pose proof (H 0 1 2) as HC; clear H.
  (* (false) identity preservation for 0, 1, 2 *)
  pose proof (Hl 0) as H0; pose proof (Hl 1) as H1;
  pose proof (Hl 2) as H2; clear Hl.
  (* case analysis on phi calls yields equalities on non-equal numbers... *)
  destruct (phi 0); destruct (phi 1); destruct (phi 2);
  (* ...rewriting leads to an equality '0 = 2' or '0 = 1' or '1 = 2'... *)
  try (rewrite H2 in H0); try (rewrite H1 in H0); try (rewrite H2 in H1);
  (* ...which can be used to solve by constructor inequality *)
  try inversion H0; inversion H1.
Qed.

正如您所看到的,这对于大型有限类型(即使是自动化的)也不是真的可用 - 这些术语太大了。对此的任何改进都会很棒。