简体   繁体   中英

How do I rewrite negb true to false in Coq?

How do I rewrite negb true to false in Coq?

I've been searching in the libraries for a simply way to rewrite negb true to false .

However, I haven't found anything useful.

I know of simpl. , but I prefer the more basic syntax.

When you search for lemmas the search engine looks in the imported modules only.

That's why you first need to

Require Import Bool.

Then

Search (negb _ = false).

reveals the lemma

negb_false_iff: forall b : bool, negb b = false <-> b = true

You can use the lemma for rewriting if you Require Import Setoid .

Goal negb true = false.
  rewrite negb_false_iff. reflexivity. Qed.

You, probably, don't want to use simpl because you have negb true in some context and simpl messes up your goal/hypotheses, because it unfolds too much and creates large unreadable terms. You can narrow the context in which simpl applies by using it this way:

simpl (negb true).       (* rewrites `negb true` to `false` in the goal *)

or

simpl (negb true) in *.  (* rewrites `negb true` in the goal and hypotheses *)

You already know that simpl will indeed reduce negb true to false . This is because the two are definitionaly equivalent.

With this knowledge you could first prove the statement that you need, then rewrite with it:

assert (H: negb true = false) by reflexivity.
rewrite H.

But even better, you can use change to do all of this in just one line:

change (negb true) with false.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM