Skip to content

Instantly share code, notes, and snippets.

View ncfavier's full-sized avatar

Naïm Camille Favier ncfavier

View GitHub Profile
@ncfavier
ncfavier / FunextFromQuotients.agda
Last active October 19, 2026 08:45
Erased quotients imply erased function extensionality (for functions into sets)
{-# OPTIONS --safe --cubical-compatible --erasure --erased-quotients --no-import-sorts #-}
open import Agda.Primitive renaming (Set to Type)
open import Agda.Builtin.Equality
open import Agda.Builtin.Erased.Quotient
cong : ∀ {ℓa ℓb} {A : Type ℓa} {B : Type ℓb} {x y} (f : A → B) → x ≡ y → f x ≡ f y
cong f refl = refl
_∙_ : ∀ {ℓ} {A : Type ℓ} {x y z : A} → x ≡ y → y ≡ z → x ≡ z
refl ∙ p = p
module Canonicity where
open import 1Lab.Prelude
open import Data.Sum
-- let T = DTT[B : Ty, t f : Tm B]
-- higher-order T-algebras
record TAlg : Type₁ where
no-eta-equality
field
open import Agda.Builtin.Nat
open import Agda.Builtin.Equality
data ⊥ : Type where
module M (n : Nat) where
-- Γ = (n : Nat)
-- full type : (n : Nat) (a : ⊥) (m : Nat) → n ≡ m → ⊥
foo : (a : ⊥) (m : Nat) → n ≡ m → ⊥
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.GroupoidLaws
open import Cubical.Foundations.Transport
open import Cubical.Foundations.Function
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Univalence
private variable
ℓ : Level
A : Type ℓ
@ncfavier
ncfavier / FreeGroupComm.agda
Last active June 5, 2026 13:27
If the free group on a set A is commutative, then A is a proposition
open import Cubical.Algebra.Group.Free
open import Cubical.Data.Bool
open import Cubical.Data.Empty as ⊥
open import Cubical.Data.List renaming (elim to elimList)
open import Cubical.Data.Sum
open import Cubical.Foundations.Function
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Prelude
open import Cubical.HITs.FreeGroup
open import Cubical.HITs.FreeGroup.NormalForm
open import 1Lab.Prelude
open import 1Lab.Reflection
open import Order.Base
module eq-rel where
record is-equivalence-relation
{ℓ} {A : Type ℓ} ℓ≈ (_≈_ : A → A → Type ℓ≈)
: Type (ℓ ⊔ ℓ≈) where
no-eta-equality
@ncfavier
ncfavier / with.agda
Created March 8, 2026 19:59
Slightly surprising ill-typed with-abstraction. Is it a bug?
postulate
X : Set
u : X
P : X → Set
Q : P u → Set
f : (p : P u) → Q p
f p with u | p
... | a | b = ?
-- f.with : (p : P u) (w : X) (p' : P w) → Q p'
@ncfavier
ncfavier / W.agda
Last active February 24, 2026 17:26
A puzzle about an "extensional" induction principle for W-types
{-# OPTIONS --without-K #-}
module W where
open import Data.Container.Core
open import Data.Container.Relation.Unary.All
open import Data.W
open import Data.Product
open import Relation.Binary.PropositionalEquality
-- Originally asked by Jasper Hugunin at https://stackoverflow.com/questions/79894235
@ncfavier
ncfavier / Russell.agda
Last active January 7, 2026 07:23
Two versions of Russell's paradox in type theory
{-# OPTIONS --type-in-type --with-K #-}
open import Data.Product
open import Relation.Binary.PropositionalEquality
open import Relation.Nullary
open import Data.Empty
{-
Russell's paradox can be encoded in MLTT + K + U:U, as formalised in
https://github.com/KonjacSource/Russell-paradox-in-TT.
@ncfavier
ncfavier / subposet-dot.hs
Created December 26, 2025 14:57
Restrict a dot graph to a subposet.
#!/usr/bin/env nix-shell
#!nix-shell --pure -i runghc -p "haskellPackages.ghcWithPackages (pkgs: with pkgs; [ graphviz topograph ])"
{-
A simple script that reads a dot graph from standard input, restricts
it to the *subposet* on the labels given as arguments (that is, computes
the transitive reduction of a subgraph of its transitive closure) and
prints the result to standard output.
Node and edge labels are destroyed, and the output graph uses input
labels as node IDs.