Skip to content

Instantly share code, notes, and snippets.

View gallais's full-sized avatar

G. Allais gallais

View GitHub Profile
@gallais
gallais / boring.v
Created January 29, 2016 15:30
In Coq you have to name subterms you want to recurse on
(*
Fixpoint boringFail (m : nat) : True :=
match m with
| S (S m) => boringFail (S m)
| _ => I
end.
*)
Fixpoint boringWork (m : nat) : True :=
match m with
@gallais
gallais / TicTacToe.hs
Created February 20, 2016 15:33
A simple game of Tic-Tac-Toe using Haskell's gloss
import Data.Maybe
import Control.Monad
import Control.Applicative
import Graphics.Gloss
import Graphics.Gloss.Interface.Pure.Game
type Coordinates = (Int, Int)
data Player = Nought | Cross
@gallais
gallais / NthElement.hs
Last active February 27, 2016 22:50
Nth element of a sorted tree
{-# LANGUAGE GADTs #-}
module NthElement where
import Data.Functor
import Control.Applicative
import Control.Monad
import Control.Monad.Trans.State
data Tree a where
@gallais
gallais / AVLString.agda
Last active March 28, 2016 22:28
Quick an Dirty transformation of the STO instance for String
open import Level
import Data.AVL.Sets
open import Data.String as String
open import Relation.Binary using (module StrictTotalOrder)
open import Data.Product
open import Function
open import Relation.Binary
@gallais
gallais / LEM.agda
Created April 17, 2016 08:29
Postulating the LEM in Agda
module LEM where
open import Data.Empty
open import Data.Product
open import Function
open import Relation.Nullary
∄⇒∀ : {A : Set} {B : A → Set} →
¬ (∃ λ a → B a) →
∀ a → ¬ (B a)
Require Import Arith.
Require Import List.
Local Open Scope list_scope.
Inductive SubListsRel (n : nat) : forall (ns : list nat)
(mss : list (list nat)), Prop :=
| base : SubListsRel n nil (nil :: nil)
| consEq : forall ns m mss,
@gallais
gallais / Thin.v
Created May 3, 2016 17:54
Thinning using Sozeau's equations
Require Import Equations.
Inductive Fin : nat -> Type :=
| fz {n : nat} : Fin (S n)
| fs {n : nat} : Fin n -> Fin (S n).
Lemma FinO_elim : Fin O -> False.
Proof.
inversion 1.
Qed.
@gallais
gallais / Datatype.agda
Created May 21, 2016 16:59
Constant access n-Sums
module Datatype where
open import Data.Empty hiding (⊥-elim)
open import Data.Nat
open import Data.Bool
open import Data.List
open import Relation.Nullary
¬n<0 : {n : ℕ} → ¬ (n < 0)
¬n<0 ()
@gallais
gallais / Rinv_and_R0.v
Created June 14, 2016 12:41
Various equivalences
Require Import Reals.
Open Scope R_scope.
Goal forall x, x <> 0 -> 1 / x <> 0.
intros.
unfold Rdiv; rewrite Rmult_1_l.
apply Rinv_neq_0_compat.
assumption.
Qed.
@gallais
gallais / Vec.hs
Created June 27, 2016 12:09
Vectors in Haskell
{-# LANGUAGE GADTs #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE TypeFamilies #-}
module Vec where