Skip to content

Instantly share code, notes, and snippets.

@JakobBruenker
JakobBruenker / Test.agda
Created June 21, 2020 20:39
Equality of Pairs
open import Agda.Builtin.Sigma
open import Agda.Builtin.Equality
lemma : ∀ {a b} {A : Set a} {B : A → Set b} {x x' : A} {p p' : B}
→ (x , p) ≡ (x' , p') → ((x ≡ x') , (p ≡ p'))
lemma = ?
{-
Checking Test (/home/user/agda/combinators/Test.agda).
/home/user/agda/combinators/Test.agda:4,64-65
module Combinators where
open import Agda.Builtin.Nat renaming (Nat to ℕ)
open import Agda.Primitive
open import Agda.Builtin.Bool
open import Agda.Builtin.Equality
open import Agda.Builtin.Sigma
renaming (fst to proj₁; snd to proj₂)
hiding (module Σ)
module Σ = Agda.Builtin.Sigma.Σ
@JakobBruenker
JakobBruenker / Minimal.agda
Created June 22, 2020 17:50
with abstraction error
module Minimal where
open import Agda.Builtin.Nat renaming (Nat to ℕ)
open import Agda.Primitive
open import Agda.Builtin.Bool
open import Agda.Builtin.Equality
open import Agda.Builtin.Sigma
infixr 2 _×_
@JakobBruenker
JakobBruenker / WeakDNE.java
Last active June 27, 2020 03:45
Simple proofs in Java
import java.util.function.Function;
// This is only actually a proof of anything if you assume that null doesn't
// exist, and that all functions are pure and terminate
public class WeakDNE {
// False has no values
public static final class False {
private final Absurd absurdFun;
// Helper interface to encode rank 2 type
{-# LANGUAGE GADTs
, KindSignatures
, DataKinds
, PolyKinds
, TypeFamilies
#-}
import GHC.TypeLits hiding (Nat)
-- | Store a dict saying that one symbol is smaller than another
{-# LANGUAGE DataKinds
, ScopedTypeVariables
, TypeApplications
, TypeFamilies
, PolyKinds
, StandaloneKindSignatures
#-}
module MaybeBug where
{-# LANGUAGE TypeFamilies, UndecidableInstances, KindSignatures, DataKinds, TypeOperators, GADTs, RankNTypes, PolyKinds #-}
import Data.Kind
import Data.Type.Equality
data Nat = Z | S Nat
data SNat :: Nat -> Type where
SZ :: SNat Z
SS :: SNat n -> SNat (S n)
@JakobBruenker
JakobBruenker / Dependent.hs
Last active November 25, 2020 22:19
Comparison of basic length-indexed vectors in Haskell and Java
{-# LANGUAGE GADTs, TypeFamilies, DataKinds, TypeOperators, StandaloneDeriving #-}
module Dependent where
data Nat = Z | S Nat
data Vec (n :: Nat) a where
Nil :: Vec Z a
Cons :: a -> Vec n a -> Vec (S n) a
{-# LANGUAGE NumDecimals, BlockArguments #-}
import System.Environment
import Data.List
f 0 = (length .) . filter
f 1 = count
f 2 = count'
f 3 = count''
@JakobBruenker
JakobBruenker / Main.hs
Created December 20, 2020 14:48
AOC 2020 day 20
{-# LANGUAGE ScopedTypeVariables
, ViewPatterns
, LambdaCase
, BlockArguments
, StandaloneKindSignatures
, GADTs
, TypeOperators
, ImportQualifiedPost
, UndecidableInstances
, DerivingVia