equal
deleted
inserted
replaced
|
1 |
|
2 theory Swap = Main: |
|
3 |
|
4 consts |
|
5 swapa :: "(string \<times> string) \<Rightarrow> string \<Rightarrow> string" |
|
6 swapas :: "(string \<times> string)list \<Rightarrow> string \<Rightarrow> string" |
|
7 primrec |
|
8 "swapa (b,c) a = (if b = a then c else (if c = a then b else a))" |
|
9 |
|
10 primrec |
|
11 "swapas [] a = a" |
|
12 "swapas (x#pi) a = swapa x (swapas pi a)" |
|
13 |
|
14 lemma [simp]: |
|
15 "swapas [(a,a)] b=b" |
|
16 apply(auto) |
|
17 done |
|
18 |
|
19 lemma swapas_append: |
|
20 "swapas (pi1@pi2) a = swapas pi1 (swapas pi2 a)" |
|
21 apply(induct_tac pi1, auto) |
|
22 done |
|
23 |
|
24 lemma [simp]: |
|
25 "swapas (rev pi) (swapas pi a) = a" |
|
26 apply(induct_tac pi) |
|
27 apply(simp_all add: swapas_append, auto) |
|
28 done |
|
29 |
|
30 lemma swapas_rev_pi_a: |
|
31 "swapas pi a = b \<Longrightarrow> swapas (rev pi) b = a" |
|
32 apply(auto) |
|
33 done |
|
34 |
|
35 lemma [simp]: |
|
36 "swapas pi (swapas (rev pi) a) = a" |
|
37 apply(rule swapas_rev_pi_a[of "(rev pi)" _ _,simplified]) |
|
38 apply(simp) |
|
39 done |
|
40 |
|
41 lemma swapas_rev_pi_b: |
|
42 "swapas (rev pi) a = b \<Longrightarrow> swapas pi b = a" |
|
43 apply(auto) |
|
44 done |
|
45 |
|
46 lemma swapas_comm: |
|
47 "(swapas (pi@[(a,b)]) c) = (swapas ([(swapas pi a,swapas pi b)]@pi) c)" |
|
48 apply(auto) |
|
49 apply(simp_all only: swapas_append) |
|
50 apply(auto) |
|
51 apply(drule swapas_rev_pi_a, simp) |
|
52 apply(drule swapas_rev_pi_a, simp) |
|
53 done |
|
54 |
|
55 end |