I am looking for a way to express that two equivalence relations are compatible and can (setoid) rewrite across each other. As an example here's an ordinary proof I wrote that a left inverse implies injectivity
Definition injection {A B : Type} (f : A -> B) :=
forall a1 a2, f a1 = f a2 -> a1 = a2.
Definition left_inverse {A B : Type} (f : A -> B) :=
exists finv: B -> A, forall a: A, finv (f a) = a.
Lemma injection_left_inverse {A B : Type}: forall (f: A -> B), left_inverse f -> injection f.
Proof.
unfold left_inverse, injection.
intros.
destruct H as [finv H'].
assert (H'': finv (f a1) = a1) by (apply H').
rewrite <- H''.
rewrite H0.
rewrite H'.
reflexivity.
Qed.
I'd like to extended to something like this:
Definition injection' {A B : Type} (f : A -> B) (Arel: relation A) (Brel: relation B) :=
forall a1 a2, Brel (f a1) (f a2) -> Arel a1 a2.
Definition left_inverse' {A B : Type} (f : A -> B) (Arel: relation A) (Brel: relation B) :=
exists finv: B -> A, forall a: A, Arel (finv (f a)) a.
Lemma injection_left_inverse' {A B : Type}: forall (f: A -> B) (Arel: relation A) (Brel: relation B),
left_inverse' f Arel Brel -> injection' f Arel Brel.
Proof.
Admitted.
where Arel
and Brel
are some equivalence relations that critically are potentially different but compatible in a way that they should be able to rewrite across each other.
This last part is what I don't know how to express. For a single equivalence relation, I know that I can use Add Parametric Relation
to allow rewriting, but I don't know how to express that these relations are compatible. I assume it is some use of Proper
, but I haven't been able to figure it out exactly.