Skip to content

Instantly share code, notes, and snippets.

View wenkokke's full-sized avatar

Wen Kokke wenkokke

View GitHub Profile
@wenkokke
wenkokke / HTCG.hs
Last active December 21, 2015 06:29
An attempt to encode Hybrid Type-Logical Categorial Grammar in Haskell... which fails horribly, as I can't use closed type families in the current release of GHC. I'll have another go at it in November.
{-# LANGUAGE TypeFamilies, TypeOperators #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE FlexibleInstances, FlexibleContexts #-}
{-# LANGUAGE RankNTypes, ExistentialQuantification #-}
{-# LANGUAGE UndecidableInstances, NoMonomorphismRestriction #-}
{-# LANGUAGE FunctionalDependencies #-}
import Prelude hiding (and)
@wenkokke
wenkokke / CCG.lagda
Last active December 21, 2015 13:09
An attempt to encode Combinatory Categorial Grammar in Agda... which isn't as pretty as I'd like, but this is probably due to CCG. ^^
# Encoding CCGs in Agda.
Bla bla bla.
First attempt using type system to check validity of sentences. But sentences may be ambiguous, and
type raising cannot be properly handled due to the implementation of Agda implicits.
Since this blog post is literate Agda, we'll have some administrive business to get out of the way.
\begin{code}
@wenkokke
wenkokke / BubbleSort.lagda
Last active December 23, 2015 21:59
An implementation of bubble sort in Agda.
\begin{code}
open import Level using (_⊔_)
open import Data.Vec using (Vec; []; _∷_)
open import Data.Nat as Nat using (ℕ; zero; suc)
open import Data.Sum using (_⊎_; inj₁; inj₂)
open import Data.Product using (∃; _×_; _,_; proj₁; proj₂)
open import Data.Empty using (⊥-elim)
open import Relation.Nullary
open import Relation.Binary
open import Relation.Binary.PropositionalEquality using (_≡_; refl)
@wenkokke
wenkokke / MergeSort.agda
Last active June 2, 2022 22:14
An implementation of mergesort in Agda.
open import Level using (_⊔_)
open import Function using (_∘_)
open import Data.Vec using (Vec; []; _∷_; foldr)
open import Data.Nat using (ℕ; zero; suc; _+_)
open import Data.Nat.Properties.Simple using (+-right-identity; +-suc)
open import Data.Sum using (_⊎_; inj₁; inj₂)
open import Data.Product using (∃; _×_; _,_; proj₁; proj₂)
open import Data.Empty using (⊥-elim)
open import Relation.Nullary using (Dec; yes; no; ¬_)
open import Relation.Binary using (module DecTotalOrder; DecTotalOrder; Rel)
@wenkokke
wenkokke / Logic.hs
Last active December 28, 2015 18:49
An encoding of N-th order logic in Haskell, where the minimal order is encoded by the term... This all fails pretty horribly (in the sense that it doesn't really achieve what I set out to do, and actually trying to write formulas using this is incredibly painful), but I thought it'd be nice to keep around.
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE OverloadedStrings, FlexibleInstances #-}
{-# LANGUAGE GADTs, DataKinds, KindSignatures, TypeFamilies #-}
module Logic where
import Text.Printf (printf)
import Data.String.Utils (join)
-- | encoding of natural numbers for use with datakinds
data Nat where
@wenkokke
wenkokke / STL.hs
Created December 8, 2013 19:26
Type-safe reification of simply typed lambda terms with atomic types E (entity) and T (boolean) into Haskell functions. I could extend this by replacing these atomic types with a user-provided universe, but then we couldn't encode propositional logic anymore.
{-# LANGUAGE GADTs, RankNTypes, TypeFamilies, DataKinds #-}
{-# LANGUAGE KindSignatures, TypeOperators, MultiParamTypeClasses #-}
module STL where
import Prelude hiding (True,False)
import qualified Data.Bool as B
type Name = String
type Entity = Int
@wenkokke
wenkokke / Tower.tex
Last active January 3, 2016 11:39
A few macros for Barker & Shan-style Tower notation in LaTeX.
\usepackage{array}
\usepackage{stmaryrd}
% display a one-level tower
\newcommand{\tower}[4][]{%
\begin{array}{c|c}
#4 & #3
\\ \hline
\multicolumn{2}{c}{#2}
\\
@wenkokke
wenkokke / witch.sh
Created March 2, 2014 14:27
Small bash script that determines by which packages a Brew package is used.
#!/bin/bash
if [[ -z "$1" ]]; then
echo "usage: witch [package name]"
else
# iterate over all installed packages
for pkg in $( brew list ); do
@wenkokke
wenkokke / prover9_makefile.patch
Created August 24, 2014 10:18
Fixes for one of the Prover9 Makefiles.
--- ./provers.src/Makefile 2013-11-24 18:48:09.000000000 +0100
+++ ./provers.src/Makefile 2013-11-24 18:49:38.000000000 +0100
@@ -63,25 +63,25 @@
$(MAKE) prover9
prover9: prover9.o $(OBJECTS)
- $(CC) $(CFLAGS) -lm -o prover9 prover9.o $(OBJECTS) ../ladr/libladr.a
+ $(CC) $(CFLAGS) -o prover9 prover9.o $(OBJECTS) ../ladr/libladr.a -lm
fof-prover9: fof-prover9.o $(OBJECTS)
@wenkokke
wenkokke / prover9_add_server.patch
Created August 27, 2014 13:17
Patch for Prover9 which adds a server-mode.
diff -bur ./ladr/parse.c ./ladr/parse.c
--- ./ladr/parse.c 2009-03-17 18:04:29.000000000 +0100
+++ ./ladr/parse.c 2014-08-21 03:46:12.000000000 +0200
@@ -554,7 +554,7 @@
c = getc(fp);
- if (c == EOF)
+ if (c == EOF || c == (unsigned char)EOF)
eof = TRUE;