Skip to content

Instantly share code, notes, and snippets.

@roconnor
roconnor / MemoBinTree.v
Last active May 14, 2018 21:39
Memo Trie for funcitons over binary trees in Coq (no support for memoizing structually recursive functions though)
(* In relation to https://cstheory.stackexchange.com/questions/40631/how-can-you-build-a-coinductive-memoization-table-for-recursive-functions-over-b *)
Require Import Vectors.Vector.
Import VectorNotations.
Set Primitive Projections.
Set Implicit Arguments.
Inductive binTree : Set :=
| Leaf : binTree
| Branch : binTree -> binTree -> binTree.
@roconnor
roconnor / MemoOrdBinTree.v
Created May 14, 2018 18:31
Memoization for structurally recursive funcitons over binary trees in Coq (with poor performance).
Require Import Arith.
Require Import Omega.
Set Primitive Projections.
Set Implicit Arguments.
Inductive binTree : Set :=
| Leaf : binTree
| Branch : binTree -> binTree -> binTree.
// Define Computably Enumerable (aka recursively enumerable) predicates.
CESet : (Nat -> o) -> o
CESet := \p. exists f \in PRF2Set. p = (\n. exists m:Nat. 0 < f n m)
// Standard Model
interpT : (Nat -> Nat) -> Term -> Nat
interpT := \v. TermR_(Nat) v 0 (\t. S) (\t. \s. \n, \m. n + m) (\t. \s. \n. \m. n * m)
interpF : (Nat -> Nat) -> Formula -> o
@roconnor
roconnor / PatriciaTrie.v
Created March 5, 2012 19:18
Implementation of Patrica Tries in Coq
Require Import Bvector.
Require Import Eqdep_dec.
Set Implicit Arguments.
Unset Strict Implicit.
Unset Printing Implicit Defensive.
Definition bCompare (x y : bool) : comparison :=
match x, y with
| false, false => Eq