Decomposing equality of constructors coq

前端 未结 2 485
离开以前
离开以前 2021-01-18 10:54

Often in Coq I find myself doing the following: I have the proof goal, for example:

some_constructor a c d = some_constructor b c d

And I r

相关标签:
2条回答
  • 2021-01-18 11:48

    You can use Coq's searching capabilities:

      Search (?X _ = ?X _).
      Search (_ _ = _ _).
    

    Among some noise it reveals a lemma

    f_equal: forall (A B : Type) (f : A -> B) (x y : A), x = y -> f x = f y
    

    And its siblings for multi-argument equalities: f_equal2 ... f_equal5 (as of Coq version 8.4).

    Here is an example:

    Inductive silly : Set :=
      | some_constructor : nat -> nat -> nat -> silly
      | another_constructor : nat -> nat -> silly.
    
    Goal forall x y,
        x = 42 ->
        y = 6 * 7 ->
        some_constructor x 0 1 = some_constructor y 0 1.
      intros x y Hx Hy.
      apply f_equal3; try reflexivity.
    

    At this point all you need to prove is x = y.

    0 讨论(0)
  • 2021-01-18 11:50

    In particular, standard Coq provides the f_equal tactic.

    Inductive u : Type := U : nat -> nat -> nat -> u.
    
    Lemma U1 x y z1 z2 : U x y z1 = U x y z2.
    f_equal
    

    Also, ssreflect provides a general-purpose congruence tactic congr.

    0 讨论(0)
提交回复
热议问题