Skip to content

Instantly share code, notes, and snippets.

View qnighy's full-sized avatar

Masaki Hara qnighy

View GitHub Profile
Require Import Arith.
Require Import List.
Fixpoint sum_to(n : nat) : nat :=
match n with
| O => O
| S m => n + sum_to m
end.
Definition nn_to_nat(nn : nat * nat) : nat :=
Require Import Relations.
Definition clos_refl_trans2(A : Type) (R : relation A) : relation A
:= fun x y =>
forall R' : relation A,
(forall x y, R x y -> R' x y) ->
reflexive _ R' -> transitive _ R' -> R' x y.
Lemma clos_refl_trans2_iff :
forall A (R : relation A) x y,
Require Import Arith.
Require Import Lists.List.
Require Import Omega.
Theorem t1 : (forall P, P \/ ~P) -> (forall P, ~~P -> P).
Proof.
intros LEM P; destruct (LEM P); tauto.
Qed.
Theorem t2 : forall (A:Type) (P:A->Prop), (~exists x:A, P x) -> (forall x:A, ~P x).
#!/usr/bin/ruby
# -*- coding: utf-8 -*-
chopsticks = Array.new(5) {Mutex.new}
threads = Array.new(5) {|i|
Thread.new {
loop {
chopsticks[i].synchronize {
puts "take left #{i}"
@qnighy
qnighy / subgoal-qed.v
Last active August 29, 2015 14:01
サブゴールは消滅するがQedに失敗する証明の試みの例
(* サブゴールは消滅するがQedに失敗する証明の試みの例 *)
(* これらはQedに失敗しているので証明とはいえない *)
Lemma f : True -> False.
Proof.
fix 1.
assumption.
Fail Qed.
Abort.
@qnighy
qnighy / trees.v
Created May 10, 2014 05:51
二分木と多分木の同型対応
Inductive T2 : Type :=
| T2Empty : T2
| T2Node : T2 -> T2 -> T2.
Inductive Tm : Type :=
| TmNode : list Tm -> Tm.
Fixpoint f(t:T2) : Tm :=
match t with
| T2Empty => TmNode nil
@qnighy
qnighy / prop-church.v
Created May 10, 2014 09:07
基本的な命題のchurch encoding
Definition True' : Prop := forall P : Prop, P -> P.
Definition False' : Prop := forall P : Prop, P.
Definition and'(A B : Prop) := forall P : Prop, (A -> B -> P) -> P.
Definition or'(A B : Prop) := forall P : Prop, (A -> P) -> (B -> P) -> P.
Lemma True'_iff : True <-> True'.
Proof.
unfold True'.
intuition auto.
@qnighy
qnighy / Vector_of_tuple.v
Created May 12, 2014 11:28
Ssreflect.tuple.tuple_ofとCoq.Vectors.Vector.Vector.tの相互変換
Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq fintype.
Require Import tuple finfun finset.
Require Import Coq.Vectors.Vector.
Lemma beheadE n T (x : T) (t : n.-tuple T) :
behead_tuple [tuple of x :: t] = t.
Proof.
by apply val_inj.
Qed.
@qnighy
qnighy / 11.v
Created June 8, 2014 13:48
11.v
Require Import Arith.
Fixpoint sum_odd(n:nat) : nat :=
match n with
| O => O
| S m => 1 + m + m + sum_odd m
end.
Goal forall n, sum_odd n = n * n.
Proof.
Definition tautology : forall P : Prop, P -> P
:= fun P H => H.
Definition Modus_tollens : forall P Q : Prop, ~Q /\ (P -> Q) -> ~P
:= fun P Q H0 H1 =>
let (H2, H3) := H0 in
H2 (H3 H1).
Definition Disjunctive_syllogism : forall P Q : Prop, (P \/ Q) -> ~P -> Q
:= fun P Q H0 H1 =>