Skip to content

Instantly share code, notes, and snippets.

View brendanzab's full-sized avatar
😵‍💫
writing elaborators

Brendan Zabarauskas brendanzab

😵‍💫
writing elaborators
View GitHub Profile
@atennapel
atennapel / anormalform.hs
Last active August 30, 2024 12:34
Normalization of polarized lambda calculus to A-normal form
-- Polarized lambda calculus to A-normal form
-- With eta-expansion and call-saturation
type Ix = Int
type Lvl = Int
data Ty = TInt
deriving (Show)
data TFun = TFun [Ty] Ty
deriving (Show)
@AndrasKovacs
AndrasKovacs / Elaboration.md
Last active November 13, 2024 09:33
Basic setup for formalizing elaboration

Basic setup for formalizing elaboration

First attempts

Elaboration is, broadly speaking, taking user-written syntax and converting it to "core" syntax by filling in missing information and at the same time validating that the input is well-formed.

I haven't been fully happy with formalizations that I previously used, so I make a new attempt here. I focus on a minimal dependently typed case.

@DasNaCl
DasNaCl / stlc+nat.v
Created June 25, 2024 12:40
Proof of syntactic type safety for call-by-value STLC extended with natural number constants.
Set Implicit Arguments.
Require Import List Program FunctionalExtensionality.
(** Proof of syntactic type safety for call-by-value STLC extended with ℕ. *)
(** Names/Variables will be identified with a natural number.
λx.λy.y x is represented as λλ0 1 *)
Definition var : Type := nat.
(** There is a need for partial maps, e.g., to keep track of what variable
@jake-87
jake-87 / systemf.md
Last active February 27, 2024 03:09

A somewhat brief overview of typechecking System F

This document comprises an example of typechecking a type system based on System F, in a small ML-like language.

You can skip the below section if you already understand System F itself.

A brief overview of System F

System F is the name given to an extension of the simply typed lambda calclus.

-- Moved to https://agda.monade.li/Goat.html
@AndrasKovacs
AndrasKovacs / SetoidTTinTT.agda
Last active November 3, 2024 19:20
TT in TT using only induction-induction
{-# OPTIONS --without-K #-}
-- version 1, conversion is indexed over conversion
module IndexedConv where
data Con : Set
data Ty : Con → Set
data Sub : Con → Con → Set
data Tm : ∀ Γ → Ty Γ → Set
data Con~ : Con → Con → Set
{-# OPTIONS --guarded #-}
open import Agda.Primitive
open import Relation.Binary.PropositionalEquality using (_≡_; refl; subst; sym; trans)
open import Data.Unit using (⊤; tt)
open import Data.Nat -- using (ℕ; _+_; suc; _<_)
open import Data.Nat.Properties
open import Data.Fin using (Fin; fromℕ; fromℕ<)
open import Data.Vec using (Vec; lookup; []; _∷_; [_]; _++_; map)
{-# OPTIONS --cubical #-}
open import Agda.Builtin.Cubical.Path
open import Agda.Primitive.Cubical
cong : ∀ {ℓ} {A : Set ℓ} {x y : A} {B : A → Set ℓ} (f : (a : A) → B a) (p : x ≡ y)
→ PathP (λ i → B (p i)) (f x) (f y)
cong f p i = f (p i)
open import Data.Nat
@roboguy13
roboguy13 / Cmd.hs
Last active January 8, 2025 03:34
{-# LANGUAGE GADTs #-}
import Control.Monad
-- Note that Cmd values are perfectly "pure" values. There's nothing here that
-- makes them impure.
data Cmd a where
PutStr :: String -> Cmd ()
PutStrLn :: String -> Cmd ()
ReadLn :: Cmd Int
{-# language
BlockArguments
, ConstraintKinds
, ImplicitParams
, LambdaCase
, OverloadedStrings
, PatternSynonyms
, Strict
, UnicodeSyntax
#-}