Last active
September 20, 2024 11:36
-
-
Save ncfavier/c86bbd4d535a29fdf2ddb023ec6b4592 to your computer and use it in GitHub Desktop.
Homogeneous = heterogeneous dependent paths in cooltt π
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
import prelude | |
import coercion | |
-- De Morgan-style connections, adapted from https://github.com/RedPRL/redtt/blob/master/library/prelude/connection.red | |
-- Note that these are *strong* connections in the sense that p (i β§ i) = p i, as | |
-- opposed to the weak connections defined in https://arxiv.org/abs/1911.05844. | |
def max | |
(A : type) | |
(p : π β A) | |
: ext i j => A with [ | |
| i=1 β¨ j=1 => p 1 | |
| i=0 => p j | |
| j=0 β¨ i=j => p i | |
] | |
:= i j => | |
let face : π β π β A := k => | |
hfill A 1 {β k} {l => [ | |
| k=1 β¨ l=1 => p 1 | |
| k=0 => p l | |
]} | |
in | |
hcom 1 0 {k => [ | |
| i=1 β¨ j=1 β¨ k=1 => p 1 | |
| i=0 => face k j | |
| j=0 β¨ i=j => face k i | |
]} | |
def min | |
(A : type) | |
(p : π β A) | |
: ext i j => A with [ | |
| j=0 β¨ i=0 => p 0 | |
| i=1 => p j | |
| j=1 β¨ i=j => p i | |
] | |
:= i j => | |
let face : π β π β A := k => | |
hfill A 0 {β k} {l => [ | |
| k=0 β¨ l=0 => p 0 | |
| k=1 => p l | |
]} | |
in | |
hcom 0 1 {k => [ | |
| i=0 β¨ j=0 β¨ k=0 => p 0 | |
| i=1 => face k j | |
| j=1 β¨ i=j => face k i | |
]} | |
-- Homogeneous dependent paths | |
def path-coe (A : π β type) (x : A 0) (y : A 1) : type := | |
path {A 1} {coe/fwd A x} y | |
-- With connections defined, we can mimic the de Morgan proof that | |
-- heterogeneous dependent paths are equal to homogeneous dependent | |
-- paths [1, 2]. | |
def path-pβ‘path-coe (A : π β type) (x : A 0) (y : A 1) | |
: path type {path-p A x y} {path-coe A x y} | |
:= i => path-p {max type A i} {coe A 0 i x} y | |
-- [1]: https://www.cse.chalmers.se/~nad/listings/equality/Equality.Path.html#heterogeneous%E2%89%A1homogeneous | |
-- [2]: https://1lab.dev/1Lab.Path.html#PathP%E2%89%A1Path |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment