This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading; | |
using System.Threading.Tasks; | |
namespace Proofcafe | |
{ | |
public static class TaskMonad |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading; | |
using System.Threading.Tasks; | |
namespace Proofcafe | |
{ | |
public static class TaskMonad |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* | |
pukiwikiの内部データのファイル名を可読できる名前に変換する | |
ls /PUKIWIKIDIR/wiki/*.txt | ocaml trans_pukiwiki_fnames.ml | |
*) | |
let outdir = "out/" | |
let verbose = true | |
let (|>) x f = f x | |
let (@@) f x = f x | |
let (!%) = Printf.sprintf |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Inductive repeats {X:Type} : list X -> Prop := | |
| RP_hd : forall x xs, appears_in x xs -> repeats (x::xs) | |
| RP_tl : forall x xs, repeats xs -> repeats (x :: xs) | |
. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object GetBytes { | |
def getBytes() : Iterator[Byte] = { | |
val input = System.in | |
Iterator.continually { | |
val i = input.read() | |
if (i != -1) { | |
Some(i.toByte) | |
} else { | |
None |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* | |
(*なぜかこの関数定義があると下記でSIGALRMが呼ばれなくなる *) | |
let hogehoge f x = Thread.create f x | |
*) | |
let wait () = | |
let m = Mutex.create () in | |
Mutex.lock m; | |
let c = Condition.create () in | |
Condition.wait c m |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(** **** 練習問題:★, optional *) | |
Theorem le_Sn_n : forall n, | |
~ (S n <= n). | |
Proof. | |
intro n. intro H. induction n. | |
inversion H. | |
apply IHn. apply le_S_n. apply H. | |
Qed. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(** **** 練習問題:★★, optional(rsc_trans) *) | |
Theorem rsc_trans : | |
forall (X:Type) (R: relation X) (x y z : X), | |
refl_step_closure R x y -> | |
refl_step_closure R y z -> | |
refl_step_closure R x z. | |
Proof. | |
intros. induction H. | |
apply H0. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(** **** 練習問題:★★★, optional (rtc_rsc_coincide) *) | |
Theorem rtc_rsc_coincide : | |
forall (X:Type) (R: relation X) (x y : X), | |
clos_refl_trans R x y <-> refl_step_closure R x y. | |
Proof. | |
intros. split; intro H. | |
induction H. | |
apply rsc_R. | |
apply H. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* **** Exercise: 3 stars (optimize_0plus_b) *) | |
(** **** 練習問題: ★★★ (optimize_0plus_b) *) | |
(* Since the [optimize_0plus] tranformation doesn't change the value | |
of [aexp]s, we should be able to apply it to all the [aexp]s that | |
appear in a [bexp] without changing the [bexp]'s value. Write a | |
function which performs that transformation on [bexp]s, and prove | |
it is sound. Use the tacticals we've just seen to make the proof | |
as elegant as possible. *) | |
(** [optimize_0plus]の変換が[aexp]の値を変えないことから、 | |
[bexp]の値を変えずに、[bexp]に現れる[aexp]をすべて変換するために |