Convert ~exists to forall in hypothesis

扶醉桌前 提交于 2019-12-07 13:46:58

问题


I'm stuck in situation where I have hypothesis ~ (exists k, k <= n+1 /\ f k = f (n+2)) and wish to convert it into equivalent (I hope so) hypothesis forall k, k <= n+1 -> f k <> f (n+2).

Here is little example:

Require Import Coq.Logic.Classical_Pred_Type.
Require Import Omega.

Section x.
  Variable n : nat.
  Variable f : nat -> nat.
  Hypothesis Hf : forall i, f i <= n+1.
  Variable i : nat.
  Hypothesis Hi : i <= n+1.
  Hypothesis Hfi: f i = n+1.
  Hypothesis H_nex : ~ (exists k, k <= n+1 /\ f k = f (n+2)).
  Goal (f (n+2) <= n).

I tried to use not_ex_all_not from Coq.Logic.Classical_Pred_Type.

Check not_ex_all_not.
not_ex_all_not
     : forall (U : Type) (P : U -> Prop),
       ~ (exists n : U, P n) -> forall n : U, ~ P n

apply not_ex_all_not in H_nex.
Error: Unable to find an instance for the variable n.

I don't understand what this error means, so as a random guess I tried this:

apply not_ex_all_not with (n := n) in H_nex.

It succeeds but H_nex is complete nonsense now:

H_nex : ~ (n <= n+1 /\ f n = f (n + 2))

On the other hand it is easy to solve my goal if H_nex is expressed as forall:

  Hypothesis H_nex : forall k, k <= n+1 -> f k <> f (n+2).
  specialize (H_nex i).
  specialize (Hf (n+2)).
  omega.

I found similar question but failed to apply it to my case.


回答1:


If you want to use the not_ex_all_not lemma, what you want to proof needs to look like the lemma. E.g. you can proof the following first:

Lemma lma {n:nat} {f:nat->nat} : ~ (exists k, k <= n /\ f k = f (n+1)) -> 
                                 forall k, ~(k <= n /\ f k = f (n+1)).
  intro H.
  apply not_ex_all_not.
  trivial.
Qed.

and then proof the rest:

Theorem thm (n:nat) (f:nat->nat) : ~ (exists k, k <= n /\ f k = f (n+1)) -> 
                                  forall k, k <= n -> f k <> f (n+1).
  intro P.
  specialize (lma P). intro Q.
  intro k.
  specialize (Q k).
  tauto.
Qed.  



回答2:


I'm not quite sure what your problem is.

Here is how to show trivially that your implication holds.

Section S.

  Variable n : nat.
  Variable f : nat -> nat.
  Hypothesis H : ~ (exists k, k <= n /\ f k = f (n+1)).
  Goal forall k, k <= n -> f k <> f (n+1).
  Proof.
    intros k H1 H2.
    apply H.
    exists k.
    split; assumption.
  Qed.

End S.

Also your goal is provable by apply Hf., so I'm not sure but you seem to have some confusion...



来源:https://stackoverflow.com/questions/25558208/convert-exists-to-forall-in-hypothesis

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