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
// すごいE本の30.6章の「選択的な節を持つ型」 (p.538) をScalaでも | |
object AlternativeClausesType { | |
def main() = { | |
val List(_, _) = convert(('a, 'b)) | |
val (_, _) = convert(List('a, 'b)) | |
val List(_, _) = convert(List('a, 'b)) // <- 型エラーにできる | |
val (_, _) = convert(('a, 'b)) // <- 型エラーにできる | |
} | |
def convert(xy: (Symbol, Symbol)): List[Symbol] = xy match { |
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
Fixpoint true_upto_n__true_everywhere | |
(* FILL IN HERE *) | |
Example true_upto_n_example : | |
(true_upto_n__true_everywhere 3 (fun n => even n)) | |
= (even 3 -> even 2 -> even 1 -> forall m : nat, even m). | |
Proof. reflexivity. 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
import scala.reflect.ClassTag | |
class EqualsWithOnlySameType[A <: EqualsWithOnlySameType[A] : ClassTag) { | |
override def equals(other: Any): Boolean = { | |
other match { | |
case (otherA: A) => super.equals(otherA) | |
case _ => throw new RuntimeException(s"異なる型同士の比較を禁止しています: $this.equals($other)") | |
} | |
} | |
} |
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
val tup22 = (1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1) | |
val ((a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v), w) = (tup22, "hoge") |
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
(** | |
* 自然数の二進表現 | |
* 例: (10010) は O I O O I Z | |
* 一つの数の表現が一意でないことに注意 | |
*) | |
Inductive bin_numb := | |
| I : bin_numb -> bin_numb | |
| O : bin_numb -> bin_numb | |
| Z : bin_numb. |
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
Require Import Program Arith. | |
(** * リストモジュールの拡張 *) | |
Module List. | |
Require Export List. | |
Fixpoint _index_of_loop {A:Type} (eq_dec : forall (x y:A),{x=y}+{x<>y}) a xs i := | |
match xs with | |
| nil => None | |
| x::xs => if eq_dec x a then Some i else _index_of_loop eq_dec a xs (S i) |
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
Definition foo (b : bool) : nat = | |
if b then 0 else 1. |
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
let '(x, y, z) := (1, 2, 3) in | |
... |
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
-R src JapaneseCoqdocSampleProject | |
src/Hoge.v | |
src/Piyo.v | |
-custom "platex Proof.tex; platex Proof.tex" "Proof.tex $(VOFILES) $(VFILES:.v=.tex)" "Proof.dvi" | |
-custom "dvipdfmx Proof.dvi" "Proof.dvi" Proof.pdf |
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
Lemma exo4 : False \/ True. | |
Proof. | |
right. exact I. | |
Qed. |