Coq convert non exist to forall statement

无人久伴 提交于 2019-12-02 10:10:24

I don't know of a tactic to turn not-exists into forall-not, but you can always just assert and prove it. (If you need that repeatedly, you can pack that up into an Ltac tactic definition or a simple theorem[1].)

Here's three ways of getting this proved. (You should be able to just copy/paste this transcript into CoqIDE or Emacs/ProofGeneral and step through the code.)

[1] There exists a lemma not_ex_all_not in the Library Coq.Logic.Classical_Pred_Type, but loading that would pull in the axiom for classical logic (which isn't even needed here).


(* dummy context to set up H of the correct type, for testing it out *)
Lemma SomeName (term : Type) (P : term -> term -> Prop) :
  (forall x : term, ~ (exists (y : term), P x y /\ ~ P y x)) ->
  True. (* dummy goal *)
Proof.
  intro H.
  (* end dummy context *)

(* Here's the long version, with some explanations: *)

  (* this states the goal, result will be put into the context as H' *)
  assert (forall (x y : term), (P x y /\ ~ P y x) -> False) as H'.
    (* get rid of unneeded variables in context, get new args *)
    clear - H; intros x y Pxy.
    (* unfolding the not shows the computational structure of this *)
    unfold not at 1 in H.
    (* yay... (x, y, Pxy) will produce False via H *)
    (* specialize to x and apply... *)
    apply (H x).
    (* ...and provide the witness. *)
    exists y.  exact Pxy.
    (* done. *)

  (* let's do it again... *)
  clear H'.

(* you can also do it in a single statement: *)

  assert (forall x y, (P x y /\ ~ P y x) -> False) as H'
    by (clear -H; intros x y Pxy; apply (H x (ex_intro _ y Pxy))).

  (* and again... *)
  clear H'.

(* simple stuff like this can also be written by hand: *)

  pose proof (fun x y Pxy => H x (ex_intro _ y Pxy)) as H'; simpl in H'.

(* now you have H' of the right type; optionally get rid of the old H: *)

  clear H; rename H' into H.

You can use unfold not at 1 in H. ~ P is just notation for not P, and not P = (P -> False) by definition. The at 1 part means you only want to unfold the first occurrence of not, and the in H part means you only want to unfold it in hypothesis H.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!