0

I'm interested in how the Coq tactics symmetry and transitivity actually work. I've read the Coq manual but this only describes what they do, not how they operate on a proof and change the proof states. As an example of what I'm looking for, in Interactive Theorem Proving and Program Development, the authors state that "The reflexivity tactic actually is synonymous with apply refl_equal" (p. 124). But, the author refers the reader to the reference manual for symmetry and transitivity. I haven't found a good description of things that these two tactics are synonymous with in the same way.

For clarification, the reason why I ask is that I have defined a path space paths {A : UU} : A -> A -> UU notated a = b (like in UniMath) which acts like an equivalence relation except for that a = b is not a proposition but a type. For this reason I was unable to add this relation as an equivalence relation using Add Parametric Relation. I'm trying to cook up a version of symmetry and transitivity with Ltac for this path space relation but I don't know how to change the proof state; knowing how symmetry and transitivity actually work might help.

1 Answers1

1

These tactics only apply the lemmas corresponding to symmetry and transitivity of the relation it finds in the goal. These are found using the type classes mechanism.

For instance you could declare

From Coq Require Import RelationClasses.

Instance trans : Transitive R.

which would ask you to prove R is transitive and then you would be able to use the tactic transitivity to prove R x y.

Théo Winterhalter
  • 4,908
  • 2
  • 18
  • 34
  • The problem I have with this is that I don't strictly speaking have a relation, i.e., something of the form ```A -> A -> Prop```. Rather I have something ```A -> A -> UU```, where ```UU``` is the universe. When I try your suggestion I get a universe inconsistency error. More specifically ```Cannot enforce UU.u0 <= Prop``` – IsAdisplayName Feb 07 '22 at 20:34
  • 2
    You can still define your own tactic that applies the corresponding lemma, e.g. `Ltac ureflexivity := apply paths_refl.` (and you could adapt it to be more generic using a typeclass as in CRelationClasses in the stdlib). In any case Unimath does not use the stdlib so you will need to redo some work. – kyo dralliam Feb 07 '22 at 21:09
  • @kyodralliam Thanks, I got the reflexivity figured out. But, since I don't know how ```transitivity``` and ```symmetry``` are defined, I'm not sure how to define these. Maybe I'll just try a similar thing and see how it works. I'm just wondering if my proofs will be essentially different in some way (I'm using transparent proofs show how the tactics operate might be important). – IsAdisplayName Feb 08 '22 at 00:17
  • 2
    Do you need your `symmetry` to be generic? If it's just for your `paths` type, then `apply paths_sym` should work. I mean, these tactics are defined as I said, they just apply the corresponding symmetry lemma. – Théo Winterhalter Feb 08 '22 at 07:01
  • Awesome, thank you! Manually defining it via Ltac works perfect. I accepted your answer since it describes the way the tactics are defined. Though, strictly speaking, its the method detailed in these comments that works for the type of "relation" I had, i.e something with with type ```A -> A -> UU``` – IsAdisplayName Feb 09 '22 at 11:50