author | Cezary Kaliszyk <cezarykaliszyk@gmail.com> |
Tue, 22 May 2012 14:55:58 +0200 | |
changeset 3173 | 9876d73adb2b |
permissions | -rw-r--r-- |
3173
9876d73adb2b
Executing Lambda Terms
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
1 |
theory Name_Exec |
9876d73adb2b
Executing Lambda Terms
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
2 |
imports "../../Nominal2" |
9876d73adb2b
Executing Lambda Terms
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
3 |
begin |
9876d73adb2b
Executing Lambda Terms
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
4 |
|
9876d73adb2b
Executing Lambda Terms
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
5 |
atom_decl name |
9876d73adb2b
Executing Lambda Terms
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
6 |
|
9876d73adb2b
Executing Lambda Terms
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
7 |
definition Name :: "nat \<Rightarrow> name" where "Name n = Abs_name (Atom (Sort ''Name_Exec.name'' []) n)" |
9876d73adb2b
Executing Lambda Terms
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
8 |
|
9876d73adb2b
Executing Lambda Terms
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
9 |
definition "nat_of_name n = nat_of (Rep_name n)" |
9876d73adb2b
Executing Lambda Terms
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
10 |
|
9876d73adb2b
Executing Lambda Terms
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
11 |
code_datatype Name |
9876d73adb2b
Executing Lambda Terms
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
12 |
|
9876d73adb2b
Executing Lambda Terms
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
13 |
definition [code]: "N0 = Name 0" |
9876d73adb2b
Executing Lambda Terms
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
14 |
definition [code]: "N1 = Name 1" |
9876d73adb2b
Executing Lambda Terms
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
15 |
definition [code]: "N2 = Name 2" |
9876d73adb2b
Executing Lambda Terms
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
16 |
|
9876d73adb2b
Executing Lambda Terms
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
17 |
instantiation name :: equal begin |
9876d73adb2b
Executing Lambda Terms
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
18 |
|
9876d73adb2b
Executing Lambda Terms
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
19 |
definition equal_name_def: "equal_name a b \<longleftrightarrow> nat_of_name a = nat_of_name b" |
9876d73adb2b
Executing Lambda Terms
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
20 |
|
9876d73adb2b
Executing Lambda Terms
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
21 |
instance |
9876d73adb2b
Executing Lambda Terms
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
22 |
by default |
9876d73adb2b
Executing Lambda Terms
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
23 |
(metis (lifting) Rep_name_inject atom_components_eq_iff atom_name_def equal_name_def nat_of_name_def sort_of_atom_eq) |
9876d73adb2b
Executing Lambda Terms
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
24 |
|
9876d73adb2b
Executing Lambda Terms
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
25 |
end |
9876d73adb2b
Executing Lambda Terms
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
26 |
|
9876d73adb2b
Executing Lambda Terms
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
27 |
lemma [simp]: "nat_of_name (Name n) = n" |
9876d73adb2b
Executing Lambda Terms
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
28 |
unfolding nat_of_name_def Name_def |
9876d73adb2b
Executing Lambda Terms
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
29 |
by (simp add: Abs_name_inverse) |
9876d73adb2b
Executing Lambda Terms
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
30 |
|
9876d73adb2b
Executing Lambda Terms
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
31 |
lemma equal_name_code [code]: "(equal_class.equal (Name x) (Name y)) \<longleftrightarrow> (x = y)" |
9876d73adb2b
Executing Lambda Terms
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
32 |
by (auto simp add: equal_name_def) |
9876d73adb2b
Executing Lambda Terms
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
33 |
|
9876d73adb2b
Executing Lambda Terms
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
34 |
lemma atom_name_code[code]: |
9876d73adb2b
Executing Lambda Terms
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
35 |
"atom (Name n) = Atom (Sort ''Name_Exec.name'' []) n" |
9876d73adb2b
Executing Lambda Terms
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
36 |
by (simp add: Abs_name_inject[symmetric] Name_def) |
9876d73adb2b
Executing Lambda Terms
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
37 |
(simp add: atom_name_def Rep_name_inverse) |
9876d73adb2b
Executing Lambda Terms
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
38 |
|
9876d73adb2b
Executing Lambda Terms
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
39 |
lemma permute_name_code[code]: "p \<bullet> n = Name (nat_of (p \<bullet> (atom n)))" |
9876d73adb2b
Executing Lambda Terms
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
40 |
apply (simp add: atom_eqvt) |
9876d73adb2b
Executing Lambda Terms
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
41 |
apply (simp add: atom_name_def Name_def) |
9876d73adb2b
Executing Lambda Terms
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
42 |
by (metis Rep_name_inverse atom_name_def atom_name_sort nat_of.simps sort_of.simps atom.exhaust) |
9876d73adb2b
Executing Lambda Terms
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
43 |
|
9876d73adb2b
Executing Lambda Terms
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
44 |
(* |
9876d73adb2b
Executing Lambda Terms
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
45 |
Test: |
9876d73adb2b
Executing Lambda Terms
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
46 |
definition "t \<longleftrightarrow> 0 = (N0 \<leftrightarrow> N1)" |
9876d73adb2b
Executing Lambda Terms
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
47 |
|
9876d73adb2b
Executing Lambda Terms
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
48 |
export_code t in SML |
9876d73adb2b
Executing Lambda Terms
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
49 |
|
9876d73adb2b
Executing Lambda Terms
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
50 |
value "(N0 \<leftrightarrow> N1) + (N1 \<leftrightarrow> N0) = 0" |
9876d73adb2b
Executing Lambda Terms
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
51 |
*) |
9876d73adb2b
Executing Lambda Terms
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
52 |
|
9876d73adb2b
Executing Lambda Terms
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
53 |
end |
9876d73adb2b
Executing Lambda Terms
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
54 |
|
9876d73adb2b
Executing Lambda Terms
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
55 |
|
9876d73adb2b
Executing Lambda Terms
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents:
diff
changeset
|
56 |