Skip to content

Instantly share code, notes, and snippets.

@clayrat
Last active October 23, 2020 14:55
Show Gist options
  • Select an option

  • Save clayrat/8f6b52d95ac22f7f83cbf6bee29da07d to your computer and use it in GitHub Desktop.

Select an option

Save clayrat/8f6b52d95ac22f7f83cbf6bee29da07d to your computer and use it in GitHub Desktop.
Sum-product iso in Coq
Section ProdSum.
Variables A B C : Prop.
Class Isomorphism A B :=
MkIsomorphism {
from: A -> B;
to: B -> A;
from_to b: from (to b) = b;
to_from a: to (from a) = a
}.
Definition fromPS : A /\ (B \/ C) -> (A /\ B) \/ (A /\ C).
by case=>a; case=>bc; [left|right].
Defined.
Definition toPS : (A /\ B) \/ (A /\ C) -> A /\ (B \/ C).
by case; case=>a bc; split=>//; [left|right].
Defined.
Theorem prodsum : Isomorphism (A /\ (B \/ C)) ((A /\ B) \/ (A /\ C)).
Proof.
have froto (sp : A /\ B \/ A /\ C): fromPS (toPS sp) = sp
by move: sp; rewrite /fromPS /toPS; case; case.
have tofro (ps : A /\ (B \/ C)): toPS (fromPS ps) = ps
by move: ps; rewrite /fromPS /toPS; case=>a; case.
apply: MkIsomorphism froto tofro.
Qed.
End ProdSum.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment