Skip to content

Instantly share code, notes, and snippets.

View JasonGross's full-sized avatar

Jason Gross JasonGross

View GitHub Profile
type nat =
| O
| S of nat
(** val fst : ('a1 * 'a2) -> 'a1 **)
let fst = function
| (x, _) -> x
(* -*- coq-prog-args: ("-indices-matter") -*- *)
(** Initial setup stuff to print sigma types with projections rather than as matches *)
Set Primitive Projections.
Set Universe Polymorphism.
Record sigT {A:Type} (P:A -> Type) : Type :=
existT { pr1 : A ; pr2 : P pr1 }.
Arguments sigT (A P)%type.
Arguments pr1 {A P} _.
Arguments pr2 {A P} _.
Arguments existT {_} _ _ _.
@JasonGross
JasonGross / some_reifs.v
Last active January 2, 2018 19:41
some methods of reification
Require Import Coq.ZArith.ZArith.
Require Import Coq.Lists.List.
Set Implicit Arguments.
Reserved Notation "'dlet' x .. y := v 'in' f"
(at level 200, x binder, y binder, f at level 200, format "'dlet' x .. y := v 'in' '//' f").
Reserved Notation "'nllet' x .. y := v 'in' f"
(at level 200, x binder, y binder, f at level 200, format "'nllet' x .. y := v 'in' '//' f").
Reserved Notation "'elet' x := v 'in' f"
(at level 200, f at level 200, format "'elet' x := v 'in' '//' f").
Definition Let_In {A P} (v : A) (f : forall x : A, P x) : P v
@JasonGross
JasonGross / ltac_big_mem.v
Last active December 22, 2017 18:31
ltac_slow_fresh.v
Global Set Implicit Arguments.
Reserved Notation "'dlet' x .. y := v 'in' f"
(at level 200, x binder, y binder, f at level 200, format "'dlet' x .. y := v 'in' '//' f").
Reserved Notation "'elet' x := v 'in' f"
(at level 200, f at level 200, format "'elet' x := v 'in' '//' f").
Definition Let_In {A P} (v : A) (f : forall x : A, P x) : P v
:= let x := v in f x.
Notation "'dlet' x .. y := v 'in' f" := (Let_In v (fun x => .. (fun y => f) .. )).
Inductive expr {var : Type} : Type :=
@JasonGross
JasonGross / slow_mtac.v
Last active December 21, 2017 21:45
slow-mtac
(** * Expression trees in PHOAS *)
Require Import Coq.ZArith.ZArith.
Global Set Implicit Arguments.
Reserved Notation "'dlet' x .. y := v 'in' f"
(at level 200, x binder, y binder, f at level 200, format "'dlet' x .. y := v 'in' '//' f").
Reserved Notation "'elet' x := v 'in' f"
(at level 200, f at level 200, format "'elet' x := v 'in' '//' f").
Definition Let_In {A P} (v : A) (f : forall x : A, P x) : P v
:= let x := v in f x.
Notation "'dlet' x .. y := v 'in' f" := (Let_In v (fun x => .. (fun y => f) .. )).
@JasonGross
JasonGross / _CoqProject
Last active December 11, 2017 08:25
reification
-R . ReifyByPattern
-I .
comparison.v
reify.v
reify.ml4
reify.mllib
@JasonGross
JasonGross / cs_reif.v
Last active December 8, 2017 23:51
attempt at PHOAS canonical structures reification
Require Import Coq.ZArith.ZArith.
Set Implicit Arguments.
Reserved Notation "'dlet' x .. y := v 'in' f"
(at level 200, x binder, y binder, f at level 200, format "'dlet' x .. y := v 'in' '//' f").
Reserved Notation "'nlet' x .. y := v 'in' f"
(at level 200, x binder, y binder, f at level 200, format "'nlet' x .. y := v 'in' '//' f").
Reserved Notation "'zlet' x .. y := v 'in' f"
(at level 200, x binder, y binder, f at level 200, format "'zlet' x .. y := v 'in' '//' f").
Reserved Notation "'elet' x := v 'in' f"
(at level 200, f at level 200, format "'elet' x := v 'in' '//' f").
@JasonGross
JasonGross / reification-by-parametricity.pdf
Last active May 1, 2018 20:28
Reification by parametricity
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@JasonGross
JasonGross / Clightnotations.v
Last active September 19, 2017 22:32
Notations for compcert clight
Require Import Clightdefs.
Delimit Scope None_scope with None.
Delimit Scope C_scope with C.
Delimit Scope Z_scope with Z.
Delimit Scope camlfloat_of_coqfloat_scope with camlfloat_of_coqfloat.
Delimit Scope camlfloat_of_coqfloat32_scope with camlfloat_of_coqfloat32.
Delimit Scope camlint64_of_coqint_scope with camlint64_of_coqint.
Delimit Scope camlint_of_coqint_scope with camlint_of_coqint.
Delimit Scope expr_scope with expr.
@JasonGross
JasonGross / PHOAS_DTT.v
Last active October 2, 2017 04:22
PHOAS-like dependent types and terms in Coq
Inductive TYPE' : Type -> Type :=
| UNIT' : TYPE' unit
| EMPTY' : TYPE' Empty_set
| SIGMA' {a} (A : TYPE' a) {p} (P : forall v : a, TYPE' (p v)) : TYPE' (@sigT a p)
| PI' {a} (A : TYPE' a) {b} (B : forall v : a, TYPE' (b v)) : TYPE' (forall v : a, b v).
Definition TYPE := { T : _ & TYPE' T }.
Definition interp_TYPE : TYPE -> Type := @projT1 _ _.
Definition UNIT : TYPE := existT _ _ UNIT'.
Definition EMPTY : TYPE := existT _ _ EMPTY'.
Definition SIGMA (A : TYPE) (P : interp_TYPE A -> TYPE) : TYPE