Skip to content

Instantly share code, notes, and snippets.

Section __.
Context (A : Type).
Inductive list := cons (_:A) (_:list) | nil.
Check list_ind : forall P : _ -> Prop,
(forall a l, P l -> P (cons a l)) ->
P nil ->
forall l : list, P l.
Inductive btree := branch (_:A) (_:btree) (_:btree) | leaf.
Check btree_ind : forall P : btree -> Prop,
@andres-erbsen
andres-erbsen / funext_from_interval.v
Created November 1, 2018 23:02 — forked from JasonGross/funext_from_interval.v
A derivation of function extensionality from the interval in Coq using private inductives
Module Import Interval.
Unset Elimination Schemes.
(** An [interval] is the quotient of [bool] under the trivial
relation, that [true = false]. Based on the real interval, we
call the left endpoint [zero], the right endpoint [one], and the
proof of equality [seg : zero = one]. *)
Private Inductive interval := zero | one.
Axiom seg : zero = one.
(** The eliminator for the interval says that if you send [zero]
@andres-erbsen
andres-erbsen / .emacs.el
Created February 7, 2018 19:14
Coq IDE for vim users -- it is less painful to put up with evil-mode issues than with the issues of any coq plugin for vim
;; coq
(require 'proof-site "/usr/share/emacs/site-lisp/ProofGeneral/generic/proof-site.el")
(setq coq-mode-abbrev-table '())
(add-hook 'coq-mode-hook #'(lambda () (modify-syntax-entry ?_ "w")))
(add-hook 'coq-mode-hook #'(lambda () (modify-syntax-entry ?' "w")))
;; vim-style shortcuts
(require 'undo-tree)
(require 'evil)
(evil-mode 1)
R.<Px,Py,Qx,Qy,Rx,Ry,a,b> = PolynomialRing(QQ,8)
A=(Px,Py); B=(Qx,Qy); C=(Rx,Ry)
I=R.ideal(Py^2-Px^3-a*Px-b,
Qy^2-Qx^3-a*Qx-b,
Ry^2-Rx^3-a*Rx-b)
def add((x1, y1), (x2,y2)): # incomplete (this is the common case)
return ((y2-y1)^2/(x2-x1)^2-x1-x2,(y2-y1)/(x2-x1)*(x1-(y2-y1)^2/(x2-x1)^2+x1+x2)-y1)
@andres-erbsen
andres-erbsen / addr.go
Created August 27, 2016 03:23
Get public IP address in Go #golang
package main
import (
"net"
"sort"
"strconv"
"strings"
)
func rfc1918private(ip net.IP) bool {
@andres-erbsen
andres-erbsen / rooming.mod
Last active November 23, 2015 21:19
Computers Room Humans
# Rooming people into double rooms and single rooms while considering both
# (lack of) roommate preference and room choice preference.
# Written in GNU MathProg by Andres Erbsen <andreser@mit.edu> in Nov 2015.
# Released to public domain (or licensed under CC0 by user's choice).
# USAGE: glpsol --math singledouble.mod | tr ';' '\n'
set people;
set rooms;
@andres-erbsen
andres-erbsen / authorities.cfg
Created February 3, 2015 22:46
Dename client config with multiple lookup servers.
[consensus]
SignaturesRequired = 2
[freshness]
SignaturesRequired = 2
[verifier "mit"]
PublicKey = CiCheFqDmJ0Pg+j+lypkmmiHrFmRn50rlDi5X0l4+lJRFA==
[verifier "alokat"]
PublicKey = CiD6CFKBpG54dG3OMx6PJ58z5rlNFK24Dx2HMpR7urHIVA==
[consensus]
SignaturesRequired = 2
[freshness]
SignaturesRequired = 2
[verifier "dename@mit.edu"]
PublicKey = CiCheFqDmJ0Pg+j+lypkmmiHrFmRn50rlDi5X0l4+lJRFA==
[verifier "alokat"]
PublicKey = CiD6CFKBpG54dG3OMx6PJ58z5rlNFK24Dx2HMpR7urHIVA==
@andres-erbsen
andres-erbsen / LSAGS with python-charms
Last active September 5, 2017 15:01
LWW Linkable Spontaneous Anonymous Group Signature for Ad Hoc Groups (LSAGS) | From: "Linkable Spontaneous Anonymous Group Signature for Ad Hoc Groups" | Published in: | Available from: http://eprint.iacr.org/2004/027.pdf | Notes: Implemented in one night by one person, so probably NOT good enough * type: signature * setting: cyclic groups of pr…
from charm.toolbox.ecgroup import ECGroup
from charm.toolbox.PKSig import PKSig
from charm.toolbox.ecgroup import G
"""
LWW Linkable Spontaneous Anonymous Group Signature for Ad Hoc Groups (LSAGS)
| From: "Linkable Spontaneous Anonymous Group Signature for Ad Hoc Groups"
| Published in:
| Available from: http://eprint.iacr.org/2004/027.pdf
@andres-erbsen
andres-erbsen / mininet-PKGBUILD
Created April 21, 2013 20:52
PKGBUILD file to package mininet for Arch Linux
# PKGBUILD Maintainer: Andres Erbsen <andres@krutt.org>
pkgname=mininet-git
pkgver=2.0
pkgrel=0
pkgdesc="Mininet network emulator"
url="https://github.com/mininet/mininet/"
arch=('x86_64' 'i686')
license=('custom')
makedepends=('help2man')
depends=('bash' 'python2' 'python2-networkx' 'net-tools' 'iputils' 'iperf')