Skip to content

Instantly share code, notes, and snippets.

@brendanzab
brendanzab / intuitionistic.elf
Last active March 17, 2025 11:49
Intuitionistic type theory in Twelf (try in the playground at: https://twelf.org/twelf-wasm/)
%% Intuitionistic type theory in Twelf by Brendan Zabarauskas
%%
%% Inspired by the examples found in “An Equational Logical Framework
%% for Type Theories” https://arxiv.org/abs/2106.01484
tp : type.
el : tp -> type.
%% Equality

Understanding the Phases Applicative

While I was researching how to do level-order traversals of a binary tree in Haskell, I came across a library called tree-traversals which introduced a fancy Applicative instance called Phases. It took me a lot of effort to understand how it works. Although I still have some unresolved issues, I want to share my journey.

Note: I was planning to post this article on Reddit. But I gave up because it was too long so here might be a better place.

See the discussion.

Note: This article is written in a beginner-friendly way. Experts may find it tedious.

{-# language
BlockArguments
, ConstraintKinds
, ImplicitParams
, LambdaCase
, OverloadedStrings
, PatternSynonyms
, Strict
, UnicodeSyntax
#-}
@sjoerdvisscher
sjoerdvisscher / KindCat.hs
Last active October 23, 2023 20:11
Profunctor-based category theory
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE StandaloneKindSignatures #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE TypeApplications #-}

Notes on IAM (Identity and Access Management) and Zero-Trust Architecture

Overall ideas

open import Data.Nat
open import Data.Bool hiding (_<_)
open import Data.List
open import Data.Fin hiding (_<_; _+_)
open import Data.Unit
open import Relation.Nullary
open import Data.Product
open import Relation.Binary.PropositionalEquality
-- What is a semantics? A semantics defines the meaning of terms.
@AndrasKovacs
AndrasKovacs / TTinTTasSetoid.agda
Last active November 3, 2024 21:24
TT in TT using Prop + setoid fibrations
{-# OPTIONS --prop --without-K --show-irrelevant --safe #-}
{-
Challenge:
- Define a deeply embedded faithfully represented syntax of a dependently typed
TT in Agda.
- Use an Agda fragment which has canonicity. This means that the combination of
indexed inductive types & cubical equality is not allowed!
- Prove consistency.
@AndrasKovacs
AndrasKovacs / HIIRT.md
Last active May 9, 2025 12:13
Higher induction-induction-recursion

Inductive-Recursive Types, Generally

I write about inductive-recursive types here. "Generally" means "higher inductive-inductive-recursive" or "quotient inductive-inductive-recursive". This may sound quite gnarly, but fortunately the specification of signatures can be given with just a few type formers in an appropriate framework.

In particular, we'll have a theory of signatures which includes Mike Shulman's higher IR example.

@anuyts
anuyts / category-theory-eq-in-eq-out.md
Last active July 14, 2025 00:57
Equality-in-equality-out category theory in cubical Agda

Equality-in-equality-out category theory in cubical Agda

Now that equality has become computationally relevant but composition of equality remains cumbersome, the statement of various equality laws in the cubical library feels "wrong". Here I want to explore an alternative approach.

What I'm not proposing

To avoid confusion, I want to start by emphasizing what I'm not proposing.

@andrejbauer
andrejbauer / AgdaSolver.agda
Last active November 9, 2024 16:28
How to use Agda ring solvers to prove equations?
{- Here is a short demonstration on how to use Agda's solvers that automatically
prove equations. It seems quite impossible to find complete worked examples
of how Agda solvers are used.
Thanks go to @anormalform who helped out with these on Twitter, see
https://twitter.com/andrejbauer/status/1549693506922364929?s=20&t=7cb1TbB2cspIgktKXU8rng
I welcome improvements and additions to this file.
This file works with Agda 2.6.2.2 and standard-library-1.7.1