I'm trying to prove symmetry of propositional identity with the induction principal explicitly in Coq, but can't do it with the induction principle like I can in agda. I don't know how to locally declare a variable in Coq, nor do I know how to unfold a definition, as you can see below. How can I get a proof that resembles the agda one below?
Inductive Id (A : Type) (x : A) : A -> Type :=
| refl : Id A x x.
(* trivial with induction *)
Theorem symId {A} {x y} : Id A x y -> Id A y x.
Proof.
intros.
induction H.
apply refl.
Qed.
Check Id_ind.
(* Id_ind *)
(* : forall (A : Type) (x : A) (P : forall a : A, Id A x a -> Prop), *)
(* P x (refl A x) -> forall (y : A) (i : Id A x y), P y i *)
Theorem D {A} (x y : A) : Id A x y -> Prop.
Proof.
intros.
apply (Id A y x).
Qed.
Theorem d {A} (x : A) : D x x (refl A x).
Proof.
apply refl.
Admitted.
This fails, how can I unfold D so that I can just assert reflexivity?
Theorem symId' {A} {x y} : Id A x y -> Id A y x.
Proof.
intros.
how do I apply to the correct arguements? How can I locally assert D and d via tactics (is there a where or (let a = b in) tactic ?) apply (Id_ind A x (forall a : A, Id A x a -> Prop)).
Here is the agda code I'm trying to emulate
data I (A : Set) (a : A) : A → Set where
r : I A a a
J2 : {A : Set} → (D : (x y : A) → (I A x y) → Set)
→ (d : (a : A) → (D a a r )) → (x y : A) → (p : I A x y) → D x y p
J2 D d x .x r = d x
refl-I : {A : Set} → (x : A) → I A x x
refl-I x = r
symm-I : {A : Set} → (x y : A) → I A x y → I A y x
symm-I {A} x y p = J2 D d x y p
where
D : (x y : A) → I A x y → Set
D x y p = I A y x
d : (a : A) → D a a r
d a = r
Even though the coq and agda J's aren't equal, they are presumably interderivable.