Skip to content

Instantly share code, notes, and snippets.

# jcreedcmu/parametricity.txt

Last active April 14, 2024 13:19
Show Gist options
• 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.
to join this conversation on GitHub. Already have an account? Sign in to comment