Skip to content

Instantly share code, notes, and snippets.

@JasonGross
JasonGross / bad.ml
Created November 19, 2013 19:58
Bad ocaml
let gen_const_list ~is_done:(is_done : 'n -> bool) ~pred:(pred : 'n -> 'n)
(size : 'n) (v : 'a) : 'a list =
let rec helper size v =
if is_done size then [] else v::(helper (pred size) v)
in helper size v
let const_list : int -> 'a -> 'a list =
gen_const_list ~is_done:(fun size -> size <= 0) ~pred:(fun n -> n - 1)
module Stupid = struct
@JasonGross
JasonGross / is_equiv_ap.v
Created December 24, 2013 01:22
IsEquiv (ap f)
Require Import HoTT.
Local Open Scope path_scope.
Local Open Scope equiv_scope.
Section ap.
Variables A B : Type.
Variables x y : A.
Variable f : A -> B.
Context `{IsEquiv _ _ f}.
@JasonGross
JasonGross / foo.v
Created December 25, 2013 01:12
apply apparently applies fields
Inductive paths A (x : A) : A -> Type := idpath : paths A x x.
Notation "x = y" := (paths _ x y).
Record Contr (A : Type) :=
{
center : A;
contr : forall y, center = y
}.
@JasonGross
JasonGross / pi_limit.v
Created January 2, 2014 19:19
pi is limit
Set Implicit Arguments.
Section lim.
Variable J : Type.
Variable F : J -> Type.
Variable L : Type.
Variable Phi : forall x, L -> F x.
Definition IsLimit := forall N (Psi : forall x, N -> F x), { u : N -> L & forall x, (fun y => (Phi x) (u y)) = Psi x }.
End lim.
@JasonGross
JasonGross / negnegLEM.v
Created January 9, 2014 00:05
double negated lem
Goal forall T, ~~(T + ~T).
Proof.
intros T negLEM.
cut (~T).
- intro negT.
apply (negLEM (inr negT)).
- intro t.
apply (negLEM (inl t)).
Defined
@JasonGross
JasonGross / eq_univ.v
Created January 12, 2014 20:24
left universal property of equality
Require Import Overture Equivalences.
Goal forall A (a : A) (B : forall x, a = x -> Type) (x : A), Equiv (forall x (p : a = x), B x p) (B a (idpath a)).
Proof.
intros.
apply (equiv_adjointify
(fun f => f _ idpath)
(fun p0 => fun x0 p => match p as p' in (_ = y) return B y p' with
| idpath => p0
end)).
@JasonGross
JasonGross / finite_choice.v
Created January 30, 2014 19:40
Proof that finite sets have choice
Require Import HoTT.HoTT.
Require Import HoTT.hit.minus1Trunc.
Generalizable All Variables.
Set Implicit Arguments.
Local Notation "|| T ||" := (minus1Trunc T).
(*Local Notation "| x |" := (min1 x).*)
Fixpoint Fin (n : nat) : Type :=
@JasonGross
JasonGross / pi_homogenous.v
Created January 31, 2014 00:43
Pi types can be homogenous
Require Import HoTT.HoTT.
Require Import HoTT.hit.minus1Trunc HoTT.hit.Truncations.
Generalizable All Variables.
Set Implicit Arguments.
Class IsHomogenous X (x : X) := is_homogenous : forall y, existT idmap X y = existT idmap X x.
Lemma path_forall_type `{Funext, Univalence} X (Y Y' : X -> Type)
: Y == Y' -> (forall x, Y x) = (forall x, Y' x).
@JasonGross
JasonGross / split_sig_ltac.v
Created February 5, 2014 19:47
Ltac + typeclasses implementation of a partial split_sig tactic
(* Coq's build in tactics don't work so well with things like [iff]
so split them up into multiple hypotheses *)
Ltac split_in_context ident funl funr :=
repeat match goal with
| [ H : context p [ident] |- _ ] =>
let H0 := context p[funl] in let H0' := eval simpl in H0 in assert H0' by (apply H);
let H1 := context p[funr] in let H1' := eval simpl in H1 in assert H1' by (apply H);
clear H
end.
@JasonGross
JasonGross / hott_ltac_split_sig.v
Last active August 29, 2015 13:56
HoTT + Ltac + typeclasses implementation of a split_sig tactic
(* Coq's build in tactics don't work so well with things like [iff]
so split them up into multiple hypotheses *)
Ltac split_in_context ident funl funr :=
repeat match goal with
| [ H : context p [ident] |- _ ] =>
let H0 := context p[funl] in let H0' := eval simpl in H0 in assert H0' by (apply H);
let H1 := context p[funr] in let H1' := eval simpl in H1 in assert H1' by (apply H);
clear H
end.