Skip to content

Instantly share code, notes, and snippets.

@SeverTopan
Created July 30, 2020 00:32
Show Gist options
  • Save SeverTopan/4ae6e8c3fafa8f2d327b38d3ab1f529d to your computer and use it in GitHub Desktop.
Save SeverTopan/4ae6e8c3fafa8f2d327b38d3ab1f529d to your computer and use it in GitHub Desktop.
Is it possible to construct cyclic types in Agda?
data A : Set
data B : Set where
b : A → B
data A where
a : B → A
@SeverTopan
Copy link
Author

It seems as though this should be possible if you could somehow construct both A and B at the same time, and have them refer to one another, but I'm not sure if you can do this in Agda.

@SeverTopan
Copy link
Author

record A : Set
record B : Set

record A where
  coinductive
  constructor mka
  field geta : B
open A public

record B where
  coinductive
  constructor mkb
  field getb : A
open B public

a : A
b : B

a .geta = b
b .getb = a

and alternative property

data A : Set

data B : Set where
  b : A  B

data A where
  a : B  A

data  : Set where

¬a : A  
¬b : B  

¬a (a y) = ¬b y
¬b (b x) = ¬a x

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment