Skip to content

Instantly share code, notes, and snippets.

@umedaikiti
umedaikiti / definitions.ml
Last active September 9, 2018 05:06
DPLL algorithm
type variable = X of int | Y of int
type assign = variable * bool
type literal = bool * variable
type clause = literal list
type cnf = clause list
type formula =
| And of formula * formula
| Or of formula * formula
| Not of formula
@umedaikiti
umedaikiti / file.js
Created April 22, 2018 03:52
Creating a file using javascript
var buf = new ArrayBuffer(8);
var view = new Int32Array(buf);
view[0] = 0x44434241;
view[1] = 0x48474645;
var file = new File(["test", "あいうえお", buf], "test.txt", {type: "text/plain"});
document.getElementById("download").setAttribute("href", window.URL.createObjectURL(file));
document.getElementById("download").setAttribute("download", file.name);
@umedaikiti
umedaikiti / CCS.v
Last active January 12, 2018 11:19
(*
TODO
- Improve readability and naming
- Complete proofs
*)
Inductive Action :=
| Out : nat -> Action
| In : nat -> Action
| Tau : Action.
@umedaikiti
umedaikiti / carmichael.rs
Created November 20, 2017 05:21
Enumerating Carmichael numbers
#[derive(PartialEq, Copy, Clone)]
enum State {
Unknown,
NotPrime,
NotCarmichael
}
fn main() {
let mut a = [State::Unknown; 1000000];
a[0] = State::NotCarmichael;
Require Import Omega.
Goal ~(exists f : nat -> nat, forall n : nat, f (f n) = n + 1).
Proof.
intro H.
destruct H as [f H].
assert (forall n : nat, f n = n + f 0).
intro n.
induction n.
reflexivity.
simpl.
@umedaikiti
umedaikiti / binary.v
Created June 4, 2017 03:18
Binary addition
Section Binary.
Inductive Bits : nat -> Set :=
| xO : forall {m : nat}, Bits m -> Bits (S m)
| xI : forall {m : nat}, Bits m -> Bits (S m)
| xo : Bits 0
| xi : Bits 0.
Fixpoint to_nat {n : nat} (b : Bits n) : nat := match b with
| xi => 1
@umedaikiti
umedaikiti / tree.v
Last active June 24, 2016 13:27
Defining sigma-labelled ranked trees and unranked trees
Module FiniteRankedTree.
Inductive Forest {A : Set} {sigma : A -> nat} : nat -> Set :=
| leaf : Forest O
| sibl : RankedTree -> forall n, Forest n -> Forest (S n)
with
RankedTree {A : Set} {sigma : A -> nat} : Set := node : forall a, Forest (sigma a) -> RankedTree.
End FiniteRankedTree.
Module RankedTree.
Require Import List.
@umedaikiti
umedaikiti / animation.mac
Last active January 7, 2024 02:44
maximaで遊んだ時のコード
with_slider_draw(k,makelist(i,i,1,7),
proportional_axes = xy,
xrange = [-3,3],
yrange = [-3,3],
xaxis=true,
yaxis=true,
grid = true,
title = "animation" ,
label([sconcat("k=",k-4),-1,2]),
point_type=7,
@umedaikiti
umedaikiti / environment.v
Created December 13, 2015 05:07
ブログ記事用の例
Section s1.
Axiom a : nat.
Variable b : nat.
Definition c : nat := 1.
Let d : nat := 1.
Print All.
@umedaikiti
umedaikiti / hoare.v
Last active October 26, 2015 04:18
Hoare論理っぽいもの
Require Import Arith.
(*
Check eq_nat_dec.
Definition update {A B : Set} (eq_dec : forall x y : A, {x = y} + {x <> y}) (f : A -> B) (x : A) (a : B) : A -> B :=
fun y => match eq_dec x y with
| left _ => a
| right _ => f y
end.
Check nat.