Skip to content

Instantly share code, notes, and snippets.

@cppio
Created May 28, 2026 02:59
Show Gist options
  • Select an option

  • Save cppio/f1a60a70a0ebcab5ab09c2c9f92eacc0 to your computer and use it in GitHub Desktop.

Select an option

Save cppio/f1a60a70a0ebcab5ab09c2c9f92eacc0 to your computer and use it in GitHub Desktop.
Transitity of identity (aka path composition)
{-# OPTIONS --safe --cubical #-}
open import Agda.Builtin.Cubical.Path
module Trans {ℓ} {A : Set ℓ} {x y z : A} (x≡y : x ≡ y) (y≡z : y ≡ z) where
open import Agda.Primitive.Cubical renaming ( primIMin to _∧_
; primIMax to _∨_
; primINeg to ~_
; primHComp to hcomp
)
{-
y---z
| |
| |
x z
-}
trans₁ : x ≡ z
trans₁ i = hcomp (λ { j (i = i0) → x≡y (~ j)
; j (i = i1) → z
}) (y≡z i)
{-
y---y
| |
| |
x z
-}
trans₂ : x ≡ z
trans₂ i = hcomp (λ { j (i = i0) → x≡y (~ j)
; j (i = i1) → y≡z j
}) y
{-
x---y
| |
| |
x z
-}
trans₃ : x ≡ z
trans₃ i = hcomp (λ { j (i = i0) → x
; j (i = i1) → y≡z j
}) (x≡y i)
{-
x-------x
\ /
y---y
| |
| |
z---y
/ \
z-------z
-}
trans₁≡trans₂ : trans₁ ≡ trans₂
trans₁≡trans₂ i j = hcomp (λ { k (j = i0) → x≡y (~ k)
; k (j = i1) → y≡z (~ i ∨ k)
}) (y≡z (~ i ∧ j))
{-
x-------x
\ /
y---x
| |
| |
y---y
/ \
z-------z
-}
trans₂≡trans₃ : trans₂ ≡ trans₃
trans₂≡trans₃ i j = hcomp (λ { k (j = i0) → x≡y (~ i ∧ ~ k)
; k (j = i1) → y≡z k
}) (x≡y (~ i ∨ j))
{-
x-------x y-------x
\ / |\ /|
y---x | y---y |
| | | | | |
| | | | | |
z---y | y---y |
/ \ |/ \|
z-------z z-------y
-}
trans₁≡trans₃ : trans₁ ≡ trans₃
trans₁≡trans₃ i j = hcomp (λ { k (j = i0) → x≡y (~ i ∧ ~ k)
; k (j = i1) → y≡z (~ i ∨ k)
}) (hcomp (λ { k (i = i0) → y≡z (j ∧ k)
; k (i = i1) → x≡y (j ∨ ~ k)
; k (j = i0) → x≡y (~ i ∨ ~ k)
; k (j = i1) → y≡z (~ i ∧ k)
}) y)
{-
x-------x y-------x y-------x
|\ /| |\ / |\ /
| y---y | | y---y | x---x
| | | | | | | | | |
| | | | | | | | | |
| y---y | | z---z | y---y
|/ \| |/ \ |/ \
z-------z y-------z y-------z
-}
trans₁≡trans₃′ : trans₁ ≡ trans₃
trans₁≡trans₃′ i j = hcomp (λ { k (i = i0) → hcomp (λ { l (j = i0) → x≡y (~ k ∨ ~ l)
; l (j = i1) → y≡z (k ∨ ~ l)
; l (k = i0) → y≡z (j ∧ ~ l)
}) (y≡z j)
; k (i = i1) → hcomp (λ { l (j = i0) → x≡y (~ k ∧ l)
; l (j = i1) → y≡z (k ∧ l)
; l (k = i0) → x≡y (j ∨ l)
}) (x≡y j)
; k (j = i0) → x≡y (~ k)
; k (j = i1) → y≡z k
}) y
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment