Skip to content

Instantly share code, notes, and snippets.

@clayrat
Created February 27, 2025 21:43
Show Gist options
  • Save clayrat/69fe096b4d5280ccf5113c1fdd055ec3 to your computer and use it in GitHub Desktop.
Save clayrat/69fe096b4d5280ccf5113c1fdd055ec3 to your computer and use it in GitHub Desktop.
Cograph
{-# OPTIONS --safe #-}
module Cograph where
open import Prelude
record Graph {A B : 𝒰} (f : A β†’ B) : 𝒰 where
field
x : A
y : B
sub : f x = y
open Graph public
data Cograph {A B : 𝒰} (f : A β†’ B) : 𝒰 where
arg : A β†’ Cograph f
res : B β†’ Cograph f
quo : βˆ€ {a b} β†’ f a = b β†’ arg a = res b
f : β„• β†’ Maybe β„•
f n = just (2 + n)
foo : Graph f
foo .x = 2
foo .y = just 4
foo .sub = refl
bar : Cograph f
bar = arg 2
baz : Cograph f
baz = res (just 4)
quux : bar = baz
quux = quo refl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment