Skip to content

Instantly share code, notes, and snippets.

View ikedaisuke's full-sized avatar

Ikegami Daisuke ikedaisuke

View GitHub Profile
@ikedaisuke
ikedaisuke / gist:856447
Created March 5, 2011 15:35
reflexitive relation on natural numbers on Agda2
module FooBarNat where
-- cheat on the exam; look the Standard library
Relation : Set -> Set -> Set1
Relation A B = A -> B -> Set
Reflexivity : (A : Set) -> Relation A A -> Set
Reflexivity A P = (i : A) -> P i i
@ikedaisuke
ikedaisuke / gist:866600
Created March 11, 2011 21:18
How to use agda2-make-case
module Agdacase where
data Nat : Set where
zero : Nat
succ : (n : Nat) -> Nat
-- an example : n += 2
succsucc : Nat -> Nat
succsucc n = {! !} -- try to type C-c C-c `in the goal'
-- then you should type the variable `n' in the minibuffer
@ikedaisuke
ikedaisuke / gist:882733
Created March 23, 2011 07:05
reverse (reverse xs) ≡ xs in Agda
{-# OPTIONS --universe-polymorphism #-}
module ReverseReverseId where
open import Data.List
open import Data.List.Properties
open import Relation.Binary.PropositionalEquality
as P using (_≡_; refl; cong)
ReverseReverseId : ∀ {a} {A : Set a} (xs : List A) ->
reverse (reverse xs) ≡ xs
@ikedaisuke
ikedaisuke / gist:883394
Created March 23, 2011 16:28
reverse (reverse xs) ≡ xs in Coq
Require Import Coq.Lists.List.
Lemma rev_Unfold : forall {A:Type} (l:list A) (a:A), rev (a::l) = rev l ++ (cons a nil).
Proof.
intros.
simpl.
reflexivity.
Qed.
Theorem rev_Involutive : forall {A:Type} (l:list A), rev (rev l) = l.
@ikedaisuke
ikedaisuke / gist:895931
Created March 31, 2011 06:51
introduce the law of excluded-middle by RAA in Agda
module EM where
{-
See also
http://www.cs.nott.ac.uk/~txa/g53cfr/l06.html/l06.html
-}
open import Data.Sum using (_⊎_; inj₁; inj₂)
open import Relation.Nullary using (¬_)
RAA : Set₁
@ikedaisuke
ikedaisuke / gist:915931
Created April 12, 2011 17:05
Rotate a square in Gloss
-- An example of Gloss
-- http://www.f13g.com/%A5%D7%A5%ED%A5%B0%A5%E9%A5%DF%A5%F3%A5%B0/Haskell/GLUT/#content_1_2
module Main where
import Graphics.Gloss
main :: IO ()
main
= animateInWindow
@ikedaisuke
ikedaisuke / gist:915964
Created April 12, 2011 17:22
Rotate a square in Haskell GLUT
module Main where
-- http://www.f13g.com/%A5%D7%A5%ED%A5%B0%A5%E9%A5%DF%A5%F3%A5%B0/Haskell/GLUT/#content_1_0
import qualified Control.Monad.State as S
import Graphics.UI.GLUT
type AngleState a = S.StateT GLdouble IO a
timeOut :: Timeout
@ikedaisuke
ikedaisuke / gist:916931
Created April 13, 2011 03:52
Rotate a square in Gloss (with key event (DOWN-key))
module Main where
-- http://www.f13g.com/%A5%D7%A5%ED%A5%B0%A5%E9%A5%DF%A5%F3%A5%B0/Haskell/GLUT/#content_1_4
import Graphics.Gloss.Interface.Game
data State
= State { angle :: Float
, isPositive :: Bool
, picture :: Picture }
@ikedaisuke
ikedaisuke / gist:918522
Created April 13, 2011 21:59
Render particles in Gloss
module Main where
-- http://www.f13g.com/%A5%D7%A5%ED%A5%B0%A5%E9%A5%DF%A5%F3%A5%B0/Haskell/GLUT/#content_1_7
import System.Random
import Graphics.Gloss
import Graphics.Gloss.Interface.Simulate
data Particle
= Particle { position :: Point
@ikedaisuke
ikedaisuke / gist:1087586
Created July 17, 2011 13:23
CoPL Nat Derivation Rules
module Nat where
data Nat : Set where
Z : Nat
S : Nat -> Nat
data _plus_is_ : Nat -> Nat -> Nat -> Set where
P-Zero : (m n : Nat) -> Z plus m is n
P-Succ : (l m n : Nat) -> l plus m is n -> (S l) plus m is (S n)