Skip to content

Instantly share code, notes, and snippets.

@fetburner
fetburner / mips.v
Created January 1, 2015 20:24
書き初め
Require Import Arith NArith.
Notation reg := {n : nat | n < 32}.
Notation reg_dec := eq_nat_dec.
Notation i_format := (reg * reg * N)%type.
Notation r_format := (reg * reg * reg)%type.
Inductive inst : Set :=
| ILW : i_format -> inst
| ISW : i_format -> inst
type __ = Obj.t
let __ = let rec f _ = Obj.repr f in Obj.repr f
type bool =
| True
| False
(** val negb : bool -> bool **)
let negb = function
_require "basis.smi"
type coq___ = unit
val app : 'a1 list -> 'a1 list -> 'a1 list
val compOpp : order -> order
datatype compareSpecT =
CompEqT
| CompLtT
@fetburner
fetburner / lambda.v
Created February 18, 2015 17:55
λ計算いろいろ
Require Import Arith List Operators_Properties Relation_Definitions Relation_Operators.
(* 変数名の識別子 *)
Parameter id : Type.
Parameter id_dec : forall x y : id, {x = y} + {x <> y}.
(* λ項の定義 *)
Inductive lambda_term :=
| LVar : id -> lambda_term
| LAbs : id -> lambda_term -> lambda_term
@fetburner
fetburner / chapter5.ml
Last active August 29, 2015 14:15
モナド欲しい
let filter_map f l = List.fold_right (fun x l ->
match f x with
| None -> l
| Some y -> y :: l) l []
let rec unfold_right f init =
match f init with
| None -> []
| Some (x, next) -> x :: unfold_right f next
(** x^2 + y^2 = rとなる(x, y)のリストを返す *)
@fetburner
fetburner / operator.ml
Created April 18, 2015 15:08
演算子順位法
module Id =
struct
type t = string
end
module Token =
struct
type t = Id of Id.t | BinOp of Id.t * (t * t) option | EOI
end
@fetburner
fetburner / tapl3.v
Created April 28, 2015 09:17
TAPLにおけるexcercise 3.5.17の証明
Require Import Arith List Operators_Properties Relation_Definitions Relation_Operators.
(* 項 *)
Inductive term :=
| TmTrue : term
| TmFalse : term
| TmIf : term -> term -> term -> term
| TmZero : term
| TmSucc : term -> term
| TmPred : term -> term
@fetburner
fetburner / Scratch.thy
Created April 30, 2015 13:48
Excercise 2.5の解答
theory Scratch
imports Main
begin
fun sum :: "nat \<Rightarrow> nat" where
"sum 0 = 0" |
"sum (Suc n) = Suc n + sum n"
theorem sum_of_n [simp]: "sum n = n * (n + 1) div 2"
apply (induction n)
@fetburner
fetburner / Scratch.thy
Created May 6, 2015 17:44
乗法の交換法則
theory Scratch
imports Main
begin
fun pls :: "nat \<Rightarrow> nat \<Rightarrow> nat" where
"pls 0 n = n" |
"pls (Suc m) n = Suc (pls m n)"
theorem pls_0_r [simp] : "pls n 0 = n"
apply (induction n)
@fetburner
fetburner / arith.v
Last active August 29, 2015 14:23
タクティックを使わずに乗算の可換律を証明する
Inductive nt :=
| Z : nt
| Suc : nt -> nt.
Definition pls n m :=
nt_rect _
m
(fun _ IH => Suc IH) n.
Definition mul n m :=