Skip to content

Instantly share code, notes, and snippets.

@astahfrom
astahfrom / THM0_741.thy
Created November 17, 2017 18:59
Isabelle exception
theory THM0_741 imports Main begin
datatype 'a s = S 'a
datatype 'a t = T ‹'a s›
primrec f :: ‹'a s ⇒ 'a set› where
‹f (S x) = {x}›
primrec g :: ‹'a t ⇒ 'a set› where
@astahfrom
astahfrom / QuickSort.thy
Created May 8, 2017 11:32
QuickSort in Isabelle
theory QuickSort imports Main begin
fun quicksort :: "('a :: ord) list ⇒ 'a list" where
"quicksort [] = []"
| "quicksort (x#xs) = (
let (smaller, greater) = partition (op ≥ x) xs
in quicksort smaller @ x # quicksort greater)"
lemma quicksort_content: "set xs = set (quicksort xs)"
proof (induct xs rule: quicksort.induct)
@astahfrom
astahfrom / simulated_gadts.rs
Created October 4, 2015 10:40
Approximating GADTs in Rust.
use std::marker::PhantomData;
type Is<S, T> = Is_<S, T>;
#[derive(Clone)]
struct Is_ <S, T>(PhantomData<S>, PhantomData<T>);
fn refl<T>() -> Is<T, T> {
Is_(PhantomData, PhantomData)
}
@astahfrom
astahfrom / gist:ea6a7deda0a8b6ddbce5
Created April 25, 2015 20:10
texLiveCore Nix install fail on OS X
make check-TESTS
make[5]: Entering directory '/private/var/folders/f7/41q7cy8928scch2rrqtncdqr0000gn/T/nix-build-texlive-core-2014.drv-0/texlive-bin-2014.20140926.35254/Work/texk/web2c'
make[6]: Entering directory '/private/var/folders/f7/41q7cy8928scch2rrqtncdqr0000gn/T/nix-build-texlive-core-2014.drv-0/texlive-bin-2014.20140926.35254/Work/texk/web2c'
PASS: tangle.test
PASS: bibtex.test
PASS: dvicopy.test
PASS: dvitype.test
PASS: gftodvi.test
PASS: gftopk.test
PASS: gftype.test
@astahfrom
astahfrom / gist:5a7421c32fb7a4c5035c
Created April 21, 2015 17:21
NixOS configuration.nix
{ config, pkgs, ... }:
{
imports = [ ./hardware-configuration.nix ];
boot.kernelModules = [ "applesmc" ];
boot.cleanTmpDir = true;
boot.loader = {
gummiboot.enable = true;
@astahfrom
astahfrom / nix.fish
Created February 3, 2015 16:03
nix.sh translated to fish, so the fish shell can be used as login shell
if test -n $HOME
set NIX_LINK "$HOME/.nix-profile"
# Set the default profile
if test ! -L "$NIX_LINK"
echo "creating $NIX_LINK" >&2
set _NIX_DEF_LINK /nix/var/nix/profiles/default
/nix/store/4yn9bxlscdvbzjmdkhfnxd9a3jm8phns-coreutils-8.23/bin/ln -s "$_NIX_DEF_LINK" "$NIX_LINK"
end