author | haftmann |
Fri, 07 Dec 2007 15:08:07 +0100 | |
changeset 25572 | 0c9052719f20 |
parent 25536 | 01753a944433 |
child 25963 | 07e08dad8a77 |
permissions | -rw-r--r-- |
21917 | 1 |
(* ID: $Id$ |
2 |
Author: Florian Haftmann, TU Muenchen |
|
3 |
*) |
|
4 |
||
5 |
header {* A huge set of executable constants *} |
|
6 |
||
7 |
theory ExecutableContent |
|
8 |
imports |
|
9 |
Main |
|
25536 | 10 |
Eval |
23690 | 11 |
"~~/src/HOL/ex/Records" |
21917 | 12 |
AssocList |
13 |
Binomial |
|
14 |
Commutative_Ring |
|
23690 | 15 |
"~~/src/HOL/ex/Commutative_Ring_Complete" |
24530
1bac25879117
Integrated Executable_Rat and Executable_Real theories into
berghofe
parents:
24433
diff
changeset
|
16 |
"~~/src/HOL/Real/RealDef" |
21917 | 17 |
GCD |
18 |
List_Prefix |
|
19 |
Nat_Infinity |
|
20 |
NatPair |
|
24433
4a405457e9d6
added explicit equation for equality of nested environments
haftmann
parents:
24423
diff
changeset
|
21 |
Nested_Environment |
21917 | 22 |
Permutation |
23 |
Primes |
|
24 |
Product_ord |
|
25 |
SetsAndFunctions |
|
26 |
State_Monad |
|
27 |
While_Combinator |
|
28 |
Word |
|
29 |
begin |
|
30 |
||
31 |
definition |
|
32 |
n :: nat where |
|
33 |
"n = 42" |
|
34 |
||
35 |
definition |
|
36 |
k :: "int" where |
|
37 |
"k = -42" |
|
38 |
||
39 |
datatype mut1 = Tip | Top mut2 |
|
40 |
and mut2 = Tip | Top mut1 |
|
41 |
||
25572 | 42 |
primrec |
21917 | 43 |
mut1 :: "mut1 \<Rightarrow> mut1" |
25572 | 44 |
and mut2 :: "mut2 \<Rightarrow> mut2" |
45 |
where |
|
21917 | 46 |
"mut1 mut1.Tip = mut1.Tip" |
25572 | 47 |
| "mut1 (mut1.Top x) = mut1.Top (mut2 x)" |
48 |
| "mut2 mut2.Tip = mut2.Tip" |
|
49 |
| "mut2 (mut2.Top x) = mut2.Top (mut1 x)" |
|
21917 | 50 |
|
51 |
definition |
|
52 |
"mystring = ''my home is my castle''" |
|
53 |
||
54 |
text {* nested lets and such *} |
|
55 |
||
56 |
definition |
|
57 |
"abs_let x = (let (y, z) = x in (\<lambda>u. case u of () \<Rightarrow> (y + y)))" |
|
58 |
||
59 |
definition |
|
60 |
"nested_let x = (let (y, z) = x in let w = y z in w * w)" |
|
61 |
||
62 |
definition |
|
63 |
"case_let x = (let (y, z) = x in case y of () => z)" |
|
64 |
||
65 |
definition |
|
66 |
"base_case f = f list_case" |
|
67 |
||
68 |
definition |
|
69 |
"apply_tower = (\<lambda>x. x (\<lambda>x. x (\<lambda>x. x)))" |
|
70 |
||
71 |
definition |
|
72 |
"keywords fun datatype x instance funa classa = |
|
73 |
Suc fun + datatype * x mod instance - funa - classa" |
|
74 |
||
75 |
hide (open) const keywords |
|
76 |
||
77 |
definition |
|
78 |
"shadow keywords = keywords @ [ExecutableContent.keywords 0 0 0 0 0 0]" |
|
79 |
||
24197 | 80 |
definition |
81 |
foo :: "rat \<Rightarrow> rat \<Rightarrow> rat \<Rightarrow> rat" where |
|
82 |
"foo r s t = (t + s) / t" |
|
83 |
||
84 |
definition |
|
85 |
bar :: "rat \<Rightarrow> rat \<Rightarrow> rat \<Rightarrow> bool" where |
|
86 |
"bar r s t \<longleftrightarrow> (r - s) \<le> t \<or> (s - t) \<le> r" |
|
87 |
||
88 |
definition |
|
89 |
"R1 = Fract 3 7" |
|
90 |
||
91 |
definition |
|
92 |
"R2 = Fract (-7) 5" |
|
93 |
||
94 |
definition |
|
95 |
"R3 = Fract 11 (-9)" |
|
96 |
||
97 |
definition |
|
98 |
"foobar = (foo R1 1 R3, bar R2 0 R3, foo R1 R3 R2)" |
|
99 |
||
100 |
definition |
|
101 |
foo' :: "real \<Rightarrow> real \<Rightarrow> real \<Rightarrow> real" where |
|
102 |
"foo' r s t = (t + s) / t" |
|
103 |
||
104 |
definition |
|
105 |
bar' :: "real \<Rightarrow> real \<Rightarrow> real \<Rightarrow> bool" where |
|
106 |
"bar' r s t \<longleftrightarrow> (r - s) \<le> t \<or> (s - t) \<le> r" |
|
107 |
||
108 |
definition |
|
109 |
"R1' = real_of_rat (Fract 3 7)" |
|
110 |
||
111 |
definition |
|
112 |
"R2' = real_of_rat (Fract (-7) 5)" |
|
113 |
||
114 |
definition |
|
115 |
"R3' = real_of_rat (Fract 11 (-9))" |
|
116 |
||
117 |
definition |
|
118 |
"foobar' = (foo' R1' 1 R3', bar' R2' 0 R3', foo' R1' R3' R2')" |
|
119 |
||
21917 | 120 |
end |