14 text \<open>We adopt the following convention: \<open>ord\<close> is used for |
14 text \<open>We adopt the following convention: \<open>ord\<close> is used for |
15 strict orders and \<open>order\<close> is used for their reflexive |
15 strict orders and \<open>order\<close> is used for their reflexive |
16 counterparts.\<close> |
16 counterparts.\<close> |
17 |
17 |
18 definition |
18 definition |
19 part_ord :: "[i,i]=>o" (*Strict partial ordering*) where |
19 part_ord :: "[i,i]\<Rightarrow>o" (*Strict partial ordering*) where |
20 "part_ord(A,r) \<equiv> irrefl(A,r) \<and> trans[A](r)" |
20 "part_ord(A,r) \<equiv> irrefl(A,r) \<and> trans[A](r)" |
21 |
21 |
22 definition |
22 definition |
23 linear :: "[i,i]=>o" (*Strict total ordering*) where |
23 linear :: "[i,i]\<Rightarrow>o" (*Strict total ordering*) where |
24 "linear(A,r) \<equiv> (\<forall>x\<in>A. \<forall>y\<in>A. <x,y>:r | x=y | <y,x>:r)" |
24 "linear(A,r) \<equiv> (\<forall>x\<in>A. \<forall>y\<in>A. \<langle>x,y\<rangle>:r | x=y | \<langle>y,x\<rangle>:r)" |
25 |
25 |
26 definition |
26 definition |
27 tot_ord :: "[i,i]=>o" (*Strict total ordering*) where |
27 tot_ord :: "[i,i]\<Rightarrow>o" (*Strict total ordering*) where |
28 "tot_ord(A,r) \<equiv> part_ord(A,r) \<and> linear(A,r)" |
28 "tot_ord(A,r) \<equiv> part_ord(A,r) \<and> linear(A,r)" |
29 |
29 |
30 definition |
30 definition |
31 "preorder_on(A, r) \<equiv> refl(A, r) \<and> trans[A](r)" |
31 "preorder_on(A, r) \<equiv> refl(A, r) \<and> trans[A](r)" |
32 |
32 |
38 |
38 |
39 abbreviation |
39 abbreviation |
40 "Partial_order(r) \<equiv> partial_order_on(field(r), r)" |
40 "Partial_order(r) \<equiv> partial_order_on(field(r), r)" |
41 |
41 |
42 definition |
42 definition |
43 well_ord :: "[i,i]=>o" (*Well-ordering*) where |
43 well_ord :: "[i,i]\<Rightarrow>o" (*Well-ordering*) where |
44 "well_ord(A,r) \<equiv> tot_ord(A,r) \<and> wf[A](r)" |
44 "well_ord(A,r) \<equiv> tot_ord(A,r) \<and> wf[A](r)" |
45 |
45 |
46 definition |
46 definition |
47 mono_map :: "[i,i,i,i]=>i" (*Order-preserving maps*) where |
47 mono_map :: "[i,i,i,i]\<Rightarrow>i" (*Order-preserving maps*) where |
48 "mono_map(A,r,B,s) \<equiv> |
48 "mono_map(A,r,B,s) \<equiv> |
49 {f \<in> A->B. \<forall>x\<in>A. \<forall>y\<in>A. <x,y>:r \<longrightarrow> <f`x,f`y>:s}" |
49 {f \<in> A->B. \<forall>x\<in>A. \<forall>y\<in>A. \<langle>x,y\<rangle>:r \<longrightarrow> <f`x,f`y>:s}" |
50 |
50 |
51 definition |
51 definition |
52 ord_iso :: "[i,i,i,i]=>i" (\<open>(\<langle>_, _\<rangle> \<cong>/ \<langle>_, _\<rangle>)\<close> 51) (*Order isomorphisms*) where |
52 ord_iso :: "[i,i,i,i]\<Rightarrow>i" (\<open>(\<langle>_, _\<rangle> \<cong>/ \<langle>_, _\<rangle>)\<close> 51) (*Order isomorphisms*) where |
53 "\<langle>A,r\<rangle> \<cong> \<langle>B,s\<rangle> \<equiv> |
53 "\<langle>A,r\<rangle> \<cong> \<langle>B,s\<rangle> \<equiv> |
54 {f \<in> bij(A,B). \<forall>x\<in>A. \<forall>y\<in>A. <x,y>:r \<longleftrightarrow> <f`x,f`y>:s}" |
54 {f \<in> bij(A,B). \<forall>x\<in>A. \<forall>y\<in>A. \<langle>x,y\<rangle>:r \<longleftrightarrow> <f`x,f`y>:s}" |
55 |
55 |
56 definition |
56 definition |
57 pred :: "[i,i,i]=>i" (*Set of predecessors*) where |
57 pred :: "[i,i,i]\<Rightarrow>i" (*Set of predecessors*) where |
58 "pred(A,x,r) \<equiv> {y \<in> A. <y,x>:r}" |
58 "pred(A,x,r) \<equiv> {y \<in> A. \<langle>y,x\<rangle>:r}" |
59 |
59 |
60 definition |
60 definition |
61 ord_iso_map :: "[i,i,i,i]=>i" (*Construction for linearity theorem*) where |
61 ord_iso_map :: "[i,i,i,i]\<Rightarrow>i" (*Construction for linearity theorem*) where |
62 "ord_iso_map(A,r,B,s) \<equiv> |
62 "ord_iso_map(A,r,B,s) \<equiv> |
63 \<Union>x\<in>A. \<Union>y\<in>B. \<Union>f \<in> ord_iso(pred(A,x,r), r, pred(B,y,s), s). {<x,y>}" |
63 \<Union>x\<in>A. \<Union>y\<in>B. \<Union>f \<in> ord_iso(pred(A,x,r), r, pred(B,y,s), s). {\<langle>x,y\<rangle>}" |
64 |
64 |
65 definition |
65 definition |
66 first :: "[i, i, i] => o" where |
66 first :: "[i, i, i] \<Rightarrow> o" where |
67 "first(u, X, R) \<equiv> u \<in> X \<and> (\<forall>v\<in>X. v\<noteq>u \<longrightarrow> <u,v> \<in> R)" |
67 "first(u, X, R) \<equiv> u \<in> X \<and> (\<forall>v\<in>X. v\<noteq>u \<longrightarrow> \<langle>u,v\<rangle> \<in> R)" |
68 |
68 |
69 subsection\<open>Immediate Consequences of the Definitions\<close> |
69 subsection\<open>Immediate Consequences of the Definitions\<close> |
70 |
70 |
71 lemma part_ord_Imp_asym: |
71 lemma part_ord_Imp_asym: |
72 "part_ord(A,r) \<Longrightarrow> asym(r \<inter> A*A)" |
72 "part_ord(A,r) \<Longrightarrow> asym(r \<inter> A*A)" |
73 by (unfold part_ord_def irrefl_def trans_on_def asym_def, blast) |
73 by (unfold part_ord_def irrefl_def trans_on_def asym_def, blast) |
74 |
74 |
75 lemma linearE: |
75 lemma linearE: |
76 "\<lbrakk>linear(A,r); x \<in> A; y \<in> A; |
76 "\<lbrakk>linear(A,r); x \<in> A; y \<in> A; |
77 <x,y>:r \<Longrightarrow> P; x=y \<Longrightarrow> P; <y,x>:r \<Longrightarrow> P\<rbrakk> |
77 \<langle>x,y\<rangle>:r \<Longrightarrow> P; x=y \<Longrightarrow> P; \<langle>y,x\<rangle>:r \<Longrightarrow> P\<rbrakk> |
78 \<Longrightarrow> P" |
78 \<Longrightarrow> P" |
79 by (simp add: linear_def, blast) |
79 by (simp add: linear_def, blast) |
80 |
80 |
81 |
81 |
82 (** General properties of well_ord **) |
82 (** General properties of well_ord **) |
100 by (unfold well_ord_def tot_ord_def, blast) |
100 by (unfold well_ord_def tot_ord_def, blast) |
101 |
101 |
102 |
102 |
103 (** Derived rules for pred(A,x,r) **) |
103 (** Derived rules for pred(A,x,r) **) |
104 |
104 |
105 lemma pred_iff: "y \<in> pred(A,x,r) \<longleftrightarrow> <y,x>:r \<and> y \<in> A" |
105 lemma pred_iff: "y \<in> pred(A,x,r) \<longleftrightarrow> \<langle>y,x\<rangle>:r \<and> y \<in> A" |
106 by (unfold pred_def, blast) |
106 by (unfold pred_def, blast) |
107 |
107 |
108 lemmas predI = conjI [THEN pred_iff [THEN iffD2]] |
108 lemmas predI = conjI [THEN pred_iff [THEN iffD2]] |
109 |
109 |
110 lemma predE: "\<lbrakk>y \<in> pred(A,x,r); \<lbrakk>y \<in> A; <y,x>:r\<rbrakk> \<Longrightarrow> P\<rbrakk> \<Longrightarrow> P" |
110 lemma predE: "\<lbrakk>y \<in> pred(A,x,r); \<lbrakk>y \<in> A; \<langle>y,x\<rangle>:r\<rbrakk> \<Longrightarrow> P\<rbrakk> \<Longrightarrow> P" |
111 by (simp add: pred_def) |
111 by (simp add: pred_def) |
112 |
112 |
113 lemma pred_subset_under: "pred(A,x,r) \<subseteq> r -`` {x}" |
113 lemma pred_subset_under: "pred(A,x,r) \<subseteq> r -`` {x}" |
114 by (simp add: pred_def, blast) |
114 by (simp add: pred_def, blast) |
115 |
115 |
119 lemma pred_pred_eq: |
119 lemma pred_pred_eq: |
120 "pred(pred(A,x,r), y, r) = pred(A,x,r) \<inter> pred(A,y,r)" |
120 "pred(pred(A,x,r), y, r) = pred(A,x,r) \<inter> pred(A,y,r)" |
121 by (simp add: pred_def, blast) |
121 by (simp add: pred_def, blast) |
122 |
122 |
123 lemma trans_pred_pred_eq: |
123 lemma trans_pred_pred_eq: |
124 "\<lbrakk>trans[A](r); <y,x>:r; x \<in> A; y \<in> A\<rbrakk> |
124 "\<lbrakk>trans[A](r); \<langle>y,x\<rangle>:r; x \<in> A; y \<in> A\<rbrakk> |
125 \<Longrightarrow> pred(pred(A,x,r), y, r) = pred(A,y,r)" |
125 \<Longrightarrow> pred(pred(A,x,r), y, r) = pred(A,y,r)" |
126 by (unfold trans_on_def pred_def, blast) |
126 by (unfold trans_on_def pred_def, blast) |
127 |
127 |
128 |
128 |
129 subsection\<open>Restricting an Ordering's Domain\<close> |
129 subsection\<open>Restricting an Ordering's Domain\<close> |
249 apply (force intro: apply_type dest: wf_on_not_refl)+ |
249 apply (force intro: apply_type dest: wf_on_not_refl)+ |
250 done |
250 done |
251 |
251 |
252 lemma ord_isoI: |
252 lemma ord_isoI: |
253 "\<lbrakk>f \<in> bij(A, B); |
253 "\<lbrakk>f \<in> bij(A, B); |
254 \<And>x y. \<lbrakk>x \<in> A; y \<in> A\<rbrakk> \<Longrightarrow> <x, y> \<in> r \<longleftrightarrow> <f`x, f`y> \<in> s\<rbrakk> |
254 \<And>x y. \<lbrakk>x \<in> A; y \<in> A\<rbrakk> \<Longrightarrow> \<langle>x, y\<rangle> \<in> r \<longleftrightarrow> <f`x, f`y> \<in> s\<rbrakk> |
255 \<Longrightarrow> f \<in> ord_iso(A,r,B,s)" |
255 \<Longrightarrow> f \<in> ord_iso(A,r,B,s)" |
256 by (simp add: ord_iso_def) |
256 by (simp add: ord_iso_def) |
257 |
257 |
258 lemma ord_iso_is_mono_map: |
258 lemma ord_iso_is_mono_map: |
259 "f \<in> ord_iso(A,r,B,s) \<Longrightarrow> f \<in> mono_map(A,r,B,s)" |
259 "f \<in> ord_iso(A,r,B,s) \<Longrightarrow> f \<in> mono_map(A,r,B,s)" |
265 "f \<in> ord_iso(A,r,B,s) \<Longrightarrow> f \<in> bij(A,B)" |
265 "f \<in> ord_iso(A,r,B,s) \<Longrightarrow> f \<in> bij(A,B)" |
266 by (simp add: ord_iso_def) |
266 by (simp add: ord_iso_def) |
267 |
267 |
268 (*Needed? But ord_iso_converse is!*) |
268 (*Needed? But ord_iso_converse is!*) |
269 lemma ord_iso_apply: |
269 lemma ord_iso_apply: |
270 "\<lbrakk>f \<in> ord_iso(A,r,B,s); <x,y>: r; x \<in> A; y \<in> A\<rbrakk> \<Longrightarrow> <f`x, f`y> \<in> s" |
270 "\<lbrakk>f \<in> ord_iso(A,r,B,s); \<langle>x,y\<rangle>: r; x \<in> A; y \<in> A\<rbrakk> \<Longrightarrow> <f`x, f`y> \<in> s" |
271 by (simp add: ord_iso_def) |
271 by (simp add: ord_iso_def) |
272 |
272 |
273 lemma ord_iso_converse: |
273 lemma ord_iso_converse: |
274 "\<lbrakk>f \<in> ord_iso(A,r,B,s); <x,y>: s; x \<in> B; y \<in> B\<rbrakk> |
274 "\<lbrakk>f \<in> ord_iso(A,r,B,s); \<langle>x,y\<rangle>: s; x \<in> B; y \<in> B\<rbrakk> |
275 \<Longrightarrow> <converse(f) ` x, converse(f) ` y> \<in> r" |
275 \<Longrightarrow> <converse(f) ` x, converse(f) ` y> \<in> r" |
276 apply (simp add: ord_iso_def, clarify) |
276 apply (simp add: ord_iso_def, clarify) |
277 apply (erule bspec [THEN bspec, THEN iffD2]) |
277 apply (erule bspec [THEN bspec, THEN iffD2]) |
278 apply (erule asm_rl bij_converse_bij [THEN bij_is_fun, THEN apply_type])+ |
278 apply (erule asm_rl bij_converse_bij [THEN bij_is_fun, THEN apply_type])+ |
279 apply (auto simp add: right_inverse_bij) |
279 apply (auto simp add: right_inverse_bij) |
435 apply (blast intro: ord_iso_restrict_image elim: predE) |
435 apply (blast intro: ord_iso_restrict_image elim: predE) |
436 done |
436 done |
437 |
437 |
438 (*Tricky; a lot of forward proof!*) |
438 (*Tricky; a lot of forward proof!*) |
439 lemma well_ord_iso_preserving: |
439 lemma well_ord_iso_preserving: |
440 "\<lbrakk>well_ord(A,r); well_ord(B,s); <a,c>: r; |
440 "\<lbrakk>well_ord(A,r); well_ord(B,s); \<langle>a,c\<rangle>: r; |
441 f \<in> ord_iso(pred(A,a,r), r, pred(B,b,s), s); |
441 f \<in> ord_iso(pred(A,a,r), r, pred(B,b,s), s); |
442 g \<in> ord_iso(pred(A,c,r), r, pred(B,d,s), s); |
442 g \<in> ord_iso(pred(A,c,r), r, pred(B,d,s), s); |
443 a \<in> A; c \<in> A; b \<in> B; d \<in> B\<rbrakk> \<Longrightarrow> <b,d>: s" |
443 a \<in> A; c \<in> A; b \<in> B; d \<in> B\<rbrakk> \<Longrightarrow> \<langle>b,d\<rangle>: s" |
444 apply (frule ord_iso_is_bij [THEN bij_is_fun, THEN apply_type], (erule asm_rl predI predE)+) |
444 apply (frule ord_iso_is_bij [THEN bij_is_fun, THEN apply_type], (erule asm_rl predI predE)+) |
445 apply (subgoal_tac "b = g`a") |
445 apply (subgoal_tac "b = g`a") |
446 apply (simp (no_asm_simp)) |
446 apply (simp (no_asm_simp)) |
447 apply (rule well_ord_iso_pred_eq, auto) |
447 apply (rule well_ord_iso_pred_eq, auto) |
448 apply (frule ord_iso_restrict_pred, (erule asm_rl predI)+) |
448 apply (frule ord_iso_restrict_pred, (erule asm_rl predI)+) |
550 apply (rename_tac b y f) |
550 apply (rename_tac b y f) |
551 apply (erule_tac x=b and y=a in linearE, assumption+) |
551 apply (erule_tac x=b and y=a in linearE, assumption+) |
552 (*Trivial case: b=a*) |
552 (*Trivial case: b=a*) |
553 apply clarify |
553 apply clarify |
554 apply blast |
554 apply blast |
555 (*Harder case: <a, xa>: r*) |
555 (*Harder case: \<langle>a, xa\<rangle>: r*) |
556 apply (frule ord_iso_is_bij [THEN bij_is_fun, THEN apply_type], |
556 apply (frule ord_iso_is_bij [THEN bij_is_fun, THEN apply_type], |
557 (erule asm_rl predI predE)+) |
557 (erule asm_rl predI predE)+) |
558 apply (frule ord_iso_restrict_pred) |
558 apply (frule ord_iso_restrict_pred) |
559 apply (simp add: pred_iff) |
559 apply (simp add: pred_iff) |
560 apply (simp split: split_if_asm |
560 apply (simp split: split_if_asm |
659 |
659 |
660 subsection \<open>Lemmas for the Reflexive Orders\<close> |
660 subsection \<open>Lemmas for the Reflexive Orders\<close> |
661 |
661 |
662 lemma subset_vimage_vimage_iff: |
662 lemma subset_vimage_vimage_iff: |
663 "\<lbrakk>Preorder(r); A \<subseteq> field(r); B \<subseteq> field(r)\<rbrakk> \<Longrightarrow> |
663 "\<lbrakk>Preorder(r); A \<subseteq> field(r); B \<subseteq> field(r)\<rbrakk> \<Longrightarrow> |
664 r -`` A \<subseteq> r -`` B \<longleftrightarrow> (\<forall>a\<in>A. \<exists>b\<in>B. <a, b> \<in> r)" |
664 r -`` A \<subseteq> r -`` B \<longleftrightarrow> (\<forall>a\<in>A. \<exists>b\<in>B. \<langle>a, b\<rangle> \<in> r)" |
665 apply (auto simp: subset_def preorder_on_def refl_def vimage_def image_def) |
665 apply (auto simp: subset_def preorder_on_def refl_def vimage_def image_def) |
666 apply blast |
666 apply blast |
667 unfolding trans_on_def |
667 unfolding trans_on_def |
668 apply (erule_tac P = "(\<lambda>x. \<forall>y\<in>field(r). |
668 apply (erule_tac P = "(\<lambda>x. \<forall>y\<in>field(r). |
669 \<forall>z\<in>field(r). \<langle>x, y\<rangle> \<in> r \<longrightarrow> \<langle>y, z\<rangle> \<in> r \<longrightarrow> \<langle>x, z\<rangle> \<in> r)" for r in rev_ballE) |
669 \<forall>z\<in>field(r). \<langle>x, y\<rangle> \<in> r \<longrightarrow> \<langle>y, z\<rangle> \<in> r \<longrightarrow> \<langle>x, z\<rangle> \<in> r)" for r in rev_ballE) |