1 (* Title: ZF/UNITY/Monotonicity.thy |
1 (* Title: ZF/UNITY/Monotonicity.thy |
2 ID: $Id$ |
2 ID: $Id \<in> Monotonicity.thy,v 1.1 2003/05/28 16:13:42 paulson Exp $ |
3 Author: Sidi O Ehmety, Cambridge University Computer Laboratory |
3 Author: Sidi O Ehmety, Cambridge University Computer Laboratory |
4 Copyright 2002 University of Cambridge |
4 Copyright 2002 University of Cambridge |
5 |
5 |
6 Monotonicity of an operator (meta-function) with respect to arbitrary set relations. |
6 Monotonicity of an operator (meta-function) with respect to arbitrary set relations. |
7 *) |
7 *) |
8 |
8 |
9 Monotonicity = GenPrefix + MultisetSum + |
9 header{*Monotonicity of an Operator WRT a Relation*} |
|
10 |
|
11 theory Monotonicity = GenPrefix + MultisetSum: |
|
12 |
10 constdefs |
13 constdefs |
11 mono1 :: [i, i, i, i, i=>i] => o |
14 |
12 "mono1(A, r, B, s, f) == |
15 mono1 :: "[i, i, i, i, i=>i] => o" |
13 (ALL x:A. ALL y:A. <x, y>:r --> <f(x), f(y)>:s) & (ALL x:A. f(x):B)" |
16 "mono1(A, r, B, s, f) == |
|
17 (\<forall>x \<in> A. \<forall>y \<in> A. <x,y> \<in> r --> <f(x), f(y)> \<in> s) & (\<forall>x \<in> A. f(x) \<in> B)" |
14 |
18 |
15 (* monotonicity of a 2-place meta-function f *) |
19 (* monotonicity of a 2-place meta-function f *) |
16 |
20 |
17 mono2 :: [i, i, i, i, i, i, [i,i]=>i] => o |
21 mono2 :: "[i, i, i, i, i, i, [i,i]=>i] => o" |
18 "mono2(A, r, B, s, C, t, f) == (ALL x:A. ALL y:A. ALL u:B. ALL v:B. |
22 "mono2(A, r, B, s, C, t, f) == |
19 <x, y>:r & <u,v>:s --> <f(x, u), f(y,v)>:t) & |
23 (\<forall>x \<in> A. \<forall>y \<in> A. \<forall>u \<in> B. \<forall>v \<in> B. |
20 (ALL x:A. ALL y:B. f(x,y):C)" |
24 <x,y> \<in> r & <u,v> \<in> s --> <f(x,u), f(y,v)> \<in> t) & |
|
25 (\<forall>x \<in> A. \<forall>y \<in> B. f(x,y) \<in> C)" |
21 |
26 |
22 (* Internalized relations on sets and multisets *) |
27 (* Internalized relations on sets and multisets *) |
23 |
28 |
24 SetLe :: i =>i |
29 SetLe :: "i =>i" |
25 "SetLe(A) == {<x, y>:Pow(A)*Pow(A). x <= y}" |
30 "SetLe(A) == {<x,y> \<in> Pow(A)*Pow(A). x <= y}" |
26 |
31 |
27 MultLe :: [i,i] =>i |
32 MultLe :: "[i,i] =>i" |
28 "MultLe(A, r) == multirel(A, r - id(A)) Un id(Mult(A))" |
33 "MultLe(A, r) == multirel(A, r - id(A)) Un id(Mult(A))" |
29 |
34 |
|
35 |
|
36 |
|
37 lemma mono1D: |
|
38 "[| mono1(A, r, B, s, f); <x, y> \<in> r; x \<in> A; y \<in> A |] ==> <f(x), f(y)> \<in> s" |
|
39 by (unfold mono1_def, auto) |
|
40 |
|
41 lemma mono2D: |
|
42 "[| mono2(A, r, B, s, C, t, f); |
|
43 <x, y> \<in> r; <u,v> \<in> s; x \<in> A; y \<in> A; u \<in> B; v \<in> B |] |
|
44 ==> <f(x, u), f(y,v)> \<in> t" |
|
45 by (unfold mono2_def, auto) |
|
46 |
|
47 |
|
48 (** Monotonicity of take **) |
|
49 |
|
50 lemma take_mono_left_lemma: |
|
51 "[| i le j; xs \<in> list(A); i \<in> nat; j \<in> nat |] |
|
52 ==> <take(i, xs), take(j, xs)> \<in> prefix(A)" |
|
53 apply (case_tac "length (xs) le i") |
|
54 apply (subgoal_tac "length (xs) le j") |
|
55 apply (simp) |
|
56 apply (blast intro: le_trans) |
|
57 apply (drule not_lt_imp_le, auto) |
|
58 apply (case_tac "length (xs) le j") |
|
59 apply (auto simp add: take_prefix) |
|
60 apply (drule not_lt_imp_le, auto) |
|
61 apply (drule_tac m = i in less_imp_succ_add, auto) |
|
62 apply (subgoal_tac "i #+ k le length (xs) ") |
|
63 apply (simp add: take_add prefix_iff take_type drop_type) |
|
64 apply (blast intro: leI) |
|
65 done |
|
66 |
|
67 lemma take_mono_left: |
|
68 "[| i le j; xs \<in> list(A); j \<in> nat |] |
|
69 ==> <take(i, xs), take(j, xs)> \<in> prefix(A)" |
|
70 by (blast intro: Nat.le_in_nat take_mono_left_lemma) |
|
71 |
|
72 lemma take_mono_right: |
|
73 "[| <xs,ys> \<in> prefix(A); i \<in> nat |] |
|
74 ==> <take(i, xs), take(i, ys)> \<in> prefix(A)" |
|
75 by (auto simp add: prefix_iff) |
|
76 |
|
77 lemma take_mono: |
|
78 "[| i le j; <xs, ys> \<in> prefix(A); j \<in> nat |] |
|
79 ==> <take(i, xs), take(j, ys)> \<in> prefix(A)" |
|
80 apply (rule_tac b = "take (j, xs) " in prefix_trans) |
|
81 apply (auto dest: prefix_type [THEN subsetD] intro: take_mono_left take_mono_right) |
|
82 done |
|
83 |
|
84 lemma mono_take [iff]: |
|
85 "mono2(nat, Le, list(A), prefix(A), list(A), prefix(A), take)" |
|
86 apply (unfold mono2_def Le_def, auto) |
|
87 apply (blast intro: take_mono) |
|
88 done |
|
89 |
|
90 (** Monotonicity of length **) |
|
91 |
|
92 lemmas length_mono = prefix_length_le |
|
93 |
|
94 lemma mono_length [iff]: |
|
95 "mono1(list(A), prefix(A), nat, Le, length)" |
|
96 apply (unfold mono1_def) |
|
97 apply (auto dest: prefix_length_le simp add: Le_def) |
|
98 done |
|
99 |
|
100 (** Monotonicity of Un **) |
|
101 |
|
102 lemma mono_Un [iff]: |
|
103 "mono2(Pow(A), SetLe(A), Pow(A), SetLe(A), Pow(A), SetLe(A), op Un)" |
|
104 by (unfold mono2_def SetLe_def, auto) |
|
105 |
|
106 (* Monotonicity of multiset union *) |
|
107 |
|
108 lemma mono_munion [iff]: |
|
109 "mono2(Mult(A), MultLe(A,r), Mult(A), MultLe(A, r), Mult(A), MultLe(A, r), munion)" |
|
110 apply (unfold mono2_def MultLe_def) |
|
111 apply (auto simp add: Mult_iff_multiset) |
|
112 apply (blast intro: munion_multirel_mono munion_multirel_mono1 munion_multirel_mono2 multiset_into_Mult)+ |
|
113 done |
|
114 |
|
115 lemma mono_succ [iff]: "mono1(nat, Le, nat, Le, succ)" |
|
116 by (unfold mono1_def Le_def, auto) |
|
117 |
|
118 ML{* |
|
119 val mono1D = thm "mono1D"; |
|
120 val mono2D = thm "mono2D"; |
|
121 val take_mono_left_lemma = thm "take_mono_left_lemma"; |
|
122 val take_mono_left = thm "take_mono_left"; |
|
123 val take_mono_right = thm "take_mono_right"; |
|
124 val take_mono = thm "take_mono"; |
|
125 val mono_take = thm "mono_take"; |
|
126 val length_mono = thm "length_mono"; |
|
127 val mono_length = thm "mono_length"; |
|
128 val mono_Un = thm "mono_Un"; |
|
129 val mono_munion = thm "mono_munion"; |
|
130 val mono_succ = thm "mono_succ"; |
|
131 *} |
|
132 |
30 end |
133 end |