Skip to content

Instantly share code, notes, and snippets.

@clayrat
clayrat / bounded_nat.v
Created June 24, 2022 18:20
smaller inversions
(** Author: Jean-François Monin, Verimag, Université Grenoble Alpes *)
(** ------------------------------------------------------------ *)
(** Similar to finite_set from itp13 with
- [odd/F1] renamed as [even/FO]
- the parameter is the cardinal
- definition of addition (to be used in even_bounded_nat)
*)
Require Import Utf8.
@clayrat
clayrat / noeth.v
Last active June 20, 2022 18:17
Noetherian finite set
(* https://github.com/thery/grobner/blob/master/grobner.v#L1222 *)
(* http://firsov.ee/noeth/ Firsov, Uustalu, Veltri, [2016] "Variations on Noetherianness" *)
From Coq Require Import ssreflect ssrbool ssrfun.
From mathcomp Require Import eqtype ssrnat seq.
Set Implicit Arguments.
Unset Strict Implicit.
Unset Printing Implicit Defensive.
@clayrat
clayrat / ewo.v
Last active May 31, 2022 20:32
Existential Witness Operators aka nat choice
Require Extraction.
From Coq Require Import ssreflect ssrfun ssrbool.
From mathcomp Require Import ssrnat eqtype seq.
(* https://www.ps.uni-saarland.de/~smolka/drafts/icl2021.pdf#chapter.25 *)
Inductive A : Prop := AA of (True -> A).
Definition exf : A -> False.
Proof. by elim. Qed.
@clayrat
clayrat / prop_leq.v
Last active January 19, 2022 02:18
proofs /w equations for refl-style inductive leq on nats
From Equations Require Import Equations.
From Coq Require Import ssreflect ssrfun.
From mathcomp Require Import ssrnat.
Set Implicit Arguments.
Unset Strict Implicit.
Unset Printing Implicit Defensive.
Inductive less_or_eq : nat -> nat -> Prop :=
| refl : forall {n k}, n = k -> less_or_eq n k
| step : forall {n k}, less_or_eq n k -> less_or_eq n k.+1.
@clayrat
clayrat / bove_capretta_ssr.v
Last active June 25, 2022 08:57
Bove-Capretta w/ Equations+SSReflect
(** * The Bove-Capretta method
This method involves building the graph and/or domain of a recursive
definition and to define it by recursion + inversion on that graph,
but not direct pattern matching. We show a difficult example
involving nested recursive calls. *)
From Equations Require Import Equations.
From Coq Require Import ssreflect ssrbool ssrfun.
From mathcomp Require Import ssrnat eqtype.
@clayrat
clayrat / paco_ex_ssr.v
Last active May 12, 2021 19:06
Paco tutorial&examples in SSReflect
(** printing \2/ $\cup$ #∪# *)
(** printing <2= $\subseteq$ #&sube;# *)
(** printing forall $\forall$ #&forall;# *)
(** printing -> $\rightarrow$ #&rarr;# *)
(** printing /\ $\land$ #&and;# *)
From Coq Require Export ssreflect.
From Paco Require Import paco.
Global Set Bullet Behavior "None".
@clayrat
clayrat / cayley.idr
Last active March 13, 2021 01:01
Cayley monoid
module Cayley
-- https://doisinkidney.com/posts/2020-12-27-cayley-trees.html
import Data.Vect
foldlVec : {0 b : Nat -> Type} -> ({0 m : Nat} -> a -> b m -> b (S m)) -> b Z -> Vect n a -> b n
foldlVec f bz [] = bz
foldlVec f bz (x :: xs) = foldlVec {b = b . S} f (f x bz) xs
@clayrat
clayrat / install.txt
Last active December 14, 2020 18:43
Multicore OCaml installation command
opam switch create 4.10.0.multicore \
--packages=ocaml-variants.4.10.0+multicore \
--repositories.multicoremlit.https://github.com/ocaml-multicore/multicore-opam.git,default
@clayrat
clayrat / DpiK.v
Last active November 17, 2020 19:57
sigma injectivity ~= axiom K
(* https://coq.discourse.group/t/dependent-pair-injectivity-equivalent-to-k/1112 *)
(* ported to SSReflect *)
From Coq Require Import ssreflect.
Notation Sig := existT.
Notation pi1 := projT1.
Notation pi2 := projT2.
Definition K X := forall (x : X) (e: x = x), eq_refl = e.
@clayrat
clayrat / deb-lev.idr
Last active March 4, 2021 00:54
well-typed DeBrujin level
module DBLev
import Data.List.Elem
import Decidable.Equality
%default total
-- from https://github.com/agda/agda/blob/master/test/Succeed/Issue985.agda
data Ty = A