1

For example, I have this hypothesis in my context:

Heq: (a =? b) &&
     (c =? d) &&
     (e =? f) = true

that I would like to transform to this:

Heq: (a = b) /\
     (c = d) /\
     (e = f)

I have seen this post coq tactic for replacing bools with Prop but it was not really strightforward to me to use those tactics because there is no Is_true in the expression in my context.

Edit:

Heq is modified by adding = true since I made a mistake first time reading it from the context.

  • Does your goal change if you enable `Set Printing Coercions.` in your file? – Arthur Azevedo De Amorim Sep 29 '20 at 21:03
  • No, it doesn't change. – Dan Johnson Sep 29 '20 at 21:10
  • What I want to do is to eventually `destruct Heq as (HeqA & HeqB & HeqC)` to prove three subgoals that are `a = b`, `c = d`, and `e = f`. It shouldn't be that complicated, right? The problem is I cannot destruct `Heq` with its current format of type bool. – Dan Johnson Sep 29 '20 at 21:17
  • It is strange that it doesn't change, because you cannot assert that a hypothesis has type `bool` directly. The `Is_true` function that you mentioned is declared as a coercion in some Coq libraries, which causes Coq to use it when it needs to convert a boolean to a proposition. These coercions are not displayed by default, and the option I mentioned should display them. Without the coercion, the hypothesis would not type check... – Arthur Azevedo De Amorim Sep 29 '20 at 21:21
  • Could it be related to the way `Heq` is loaded into the context? I'm unfolding a function in which it has `if (a =? b) && (c =? d) && (e =? f) then ... else ...` expression, and this `Heq` comes from destructing that `if` as in `destruct ((a =? b) && (c =? d) && (e =? f)) eqn:Heq.` – Dan Johnson Sep 29 '20 at 21:44
  • Did you mean to add a `... = true` to the first `Heq`? – Arthur Azevedo De Amorim Sep 29 '20 at 22:35
  • @ArthurAzevedoDeAmorim I believe SSReflect puts a `bool >-> Sortclass` coercion into the context. I think the hypothesis is actually `Heq : is_true (_ : bool)` where `is_true` is defined in `Init.Datatypes`. – HTNW Sep 30 '20 at 01:02
  • @HTNW That was my original guess, but the OP said that no coercions show up when asking to print them. – Arthur Azevedo De Amorim Sep 30 '20 at 03:17
  • Thank you both! Actually after your comments, I doubled checked and realized `Heq` has ended with `= true` that I had missed before due to bad formatting of CoqIde. So, I could use `apply Bool.andb_true_iff` and `destruct` to get what I want. – Dan Johnson Sep 30 '20 at 15:11
  • @Dan Johnson, can you post an answer to this question. The last 3 lines of your last comment would be enough, but it helps everybody if this question appears as a solved one. Then you can accept your own answer. This will avoid that prospective helpers have to read all the comments before they understant the question is solved. Anyway, have fun using Coq. – Yves Oct 01 '20 at 06:51
  • @Yves, sure thing, will do. – Dan Johnson Oct 01 '20 at 21:37

1 Answers1

1

I have solved it by:

apply Bool.andb_true_iff in Heq.

which adds = true to the last two bool expressions and replace the second && with /\.

I then split the Heq expression into two sub-expressions by:

destruct Heq as (HeqA & HeqB).

and did the same thing on the remaining left bool sub-expression:

apply Bool.andb_true_iff in HeqA. 
destruct HeqA as (HeqA & HeqC).

Finally, I converted the bool equality into Prop equality by:

apply beq_nat_true in HeqA.
apply beq_nat_true in HeqB.
apply beq_nat_true in HeqC.