Last active
April 14, 2024 13:19
-
-
Save jcreedcmu/4c3ae0ad7b48dc2b121d4eb1444154c2 to your computer and use it in GitHub Desktop.
parametricity.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
If I have | |
๐น : โX. X โ X โ X | |
then parametricity tells me | |
(b : ๐น)(f : X โ Y)(xโ xโ : X) โ f (b xโ xโ) = b (f xโ) (f xโ). | |
From this I want to prove | |
bool-rec : (C: ๐น โ Set) (ct : C true) (cf : C false) (b : ๐น) โ C b | |
Let's do a Grothendieck move and think of C instead as a (ฯ : X โ ๐น): | |
bool-rec : (X : Set) (ฯ: X โ ๐น) (ct : ฯโปยน true) (cf : ฯโปยน false) (b : ๐น) โ ฯโปยน b | |
I have ct in the ฯ-preimage of true, and cf in the ฯ-preimage of | |
false. I have an arbitrary b, and I must come up with something in the | |
ฯ-preimage of b. Let x, y : ๐น be given. Let f : X โ ๐น be | |
f z = (ฯ z) [๐น] x y | |
Note this is impredicative. By free theorem, I know | |
f (b [X] ct cf) = b [๐น] (f ct) (f cf) | |
ฯ (b [X] ct cf) [๐น] x y = b [๐น] (ฯ ct [๐น] x y) (ฯ cf [๐น] x y) | |
= b [๐น] (true [๐น] x y) (false [๐น] x y) | |
= b [๐น] x y | |
by extensionality, | |
ฯ (b [X] ct cf) = b | |
and so we have found the desired preimage. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment