decide equality for Mutually Recursive Types in Coq?
Question
Is there any way to use the decide equality tactic with mutually recursive types in Coq?
For example, if I've got something like this:
Inductive LTree : Set := | LNil | LNode (x: LTree) (y: RTree) with RTree : Set := | RNil | RNode (x: LTree) (y: RTree).forall x y : LTree, {x = y} + {x <> y}forall x y : LTree, {x = y} + {x <> y}x, y, x0: LTree
H: forall x1 : LTree, {x0 = x1} + {x0 <> x1}
y0: RTree
x1: LTree
y1: RTree
a: x0 = x1{y0 = y1} + {y0 <> y1}
This leaves me with the goal:
But I can't solve that until I've derived equality for RTree, which will have the same problem.
Answer
You can use decide equality in this case if you prove the two lemmas for LTrees and RTrees simultaneously:
eq_LTree: forall x y : LTree, {x = y} + {x <> y}
eq_RTree: forall x y : RTree, {x = y} + {x <> y}forall x y : LTree, {x = y} + {x <> y}eq_LTree: forall x y : LTree, {x = y} + {x <> y}
eq_RTree: forall x y : RTree, {x = y} + {x <> y}forall x y : RTree, {x = y} + {x <> y}eq_LTree: forall x y : LTree, {x = y} + {x <> y}
eq_RTree: forall x y : RTree, {x = y} + {x <> y}forall x y : LTree, {x = y} + {x <> y}eq_LTree: forall x y : LTree, {x = y} + {x <> y}
eq_RTree: forall x y : RTree, {x = y} + {x <> y}forall x y : RTree, {x = y} + {x <> y}decide equality.eq_LTree: forall x y : LTree, {x = y} + {x <> y}
eq_RTree: forall x y : RTree, {x = y} + {x <> y}forall x y : LTree, {x = y} + {x <> y}decide equality. Qed.eq_LTree: forall x y : LTree, {x = y} + {x <> y}
eq_RTree: forall x y : RTree, {x = y} + {x <> y}forall x y : RTree, {x = y} + {x <> y}
Q: This is strange, Guarded complains after the first decide equality, but then Qed is not rejected.
A: Never mind, I found a thread on coq-club discussing this particular problem.