author | wenzelm |
Mon, 26 Jun 2023 23:20:32 +0200 | |
changeset 78209 | 50c5be88ad59 |
parent 67399 | eab6ce8368fa |
permissions | -rw-r--r-- |
50087 | 1 |
(* Author: Fabian Immler, TUM *) |
2 |
||
60500 | 3 |
section \<open>Sequence of Properties on Subsequences\<close> |
50087 | 4 |
|
5 |
theory Diagonal_Subsequence |
|
51526 | 6 |
imports Complex_Main |
50087 | 7 |
begin |
8 |
||
9 |
locale subseqs = |
|
10 |
fixes P::"nat\<Rightarrow>(nat\<Rightarrow>nat)\<Rightarrow>bool" |
|
67091 | 11 |
assumes ex_subseq: "\<And>n s. strict_mono (s::nat\<Rightarrow>nat) \<Longrightarrow> \<exists>r'. strict_mono r' \<and> P n (s \<circ> r')" |
50087 | 12 |
begin |
13 |
||
67091 | 14 |
definition reduce where "reduce s n = (SOME r'::nat\<Rightarrow>nat. strict_mono r' \<and> P n (s \<circ> r'))" |
52681
8cc7f76b827a
tuned definition of seqseq; clarified usage of diagseq via diagseq_holds
immler
parents:
51526
diff
changeset
|
15 |
|
8cc7f76b827a
tuned definition of seqseq; clarified usage of diagseq via diagseq_holds
immler
parents:
51526
diff
changeset
|
16 |
lemma subseq_reduce[intro, simp]: |
66447
a1f5c5c26fa6
Replaced subseq with strict_mono
eberlm <eberlm@in.tum.de>
parents:
60500
diff
changeset
|
17 |
"strict_mono s \<Longrightarrow> strict_mono (reduce s n)" |
52681
8cc7f76b827a
tuned definition of seqseq; clarified usage of diagseq via diagseq_holds
immler
parents:
51526
diff
changeset
|
18 |
unfolding reduce_def by (rule someI2_ex[OF ex_subseq]) auto |
8cc7f76b827a
tuned definition of seqseq; clarified usage of diagseq via diagseq_holds
immler
parents:
51526
diff
changeset
|
19 |
|
8cc7f76b827a
tuned definition of seqseq; clarified usage of diagseq via diagseq_holds
immler
parents:
51526
diff
changeset
|
20 |
lemma reduce_holds: |
67091 | 21 |
"strict_mono s \<Longrightarrow> P n (s \<circ> reduce s n)" |
52681
8cc7f76b827a
tuned definition of seqseq; clarified usage of diagseq via diagseq_holds
immler
parents:
51526
diff
changeset
|
22 |
unfolding reduce_def by (rule someI2_ex[OF ex_subseq]) (auto simp: o_def) |
8cc7f76b827a
tuned definition of seqseq; clarified usage of diagseq via diagseq_holds
immler
parents:
51526
diff
changeset
|
23 |
|
66447
a1f5c5c26fa6
Replaced subseq with strict_mono
eberlm <eberlm@in.tum.de>
parents:
60500
diff
changeset
|
24 |
primrec seqseq :: "nat \<Rightarrow> nat \<Rightarrow> nat" where |
50087 | 25 |
"seqseq 0 = id" |
67091 | 26 |
| "seqseq (Suc n) = seqseq n \<circ> reduce (seqseq n) n" |
50087 | 27 |
|
66447
a1f5c5c26fa6
Replaced subseq with strict_mono
eberlm <eberlm@in.tum.de>
parents:
60500
diff
changeset
|
28 |
lemma subseq_seqseq[intro, simp]: "strict_mono (seqseq n)" |
50087 | 29 |
proof (induct n) |
66447
a1f5c5c26fa6
Replaced subseq with strict_mono
eberlm <eberlm@in.tum.de>
parents:
60500
diff
changeset
|
30 |
case 0 thus ?case by (simp add: strict_mono_def) |
57862 | 31 |
next |
66447
a1f5c5c26fa6
Replaced subseq with strict_mono
eberlm <eberlm@in.tum.de>
parents:
60500
diff
changeset
|
32 |
case (Suc n) thus ?case by (subst seqseq.simps) (auto intro!: strict_mono_o) |
57862 | 33 |
qed |
52681
8cc7f76b827a
tuned definition of seqseq; clarified usage of diagseq via diagseq_holds
immler
parents:
51526
diff
changeset
|
34 |
|
8cc7f76b827a
tuned definition of seqseq; clarified usage of diagseq via diagseq_holds
immler
parents:
51526
diff
changeset
|
35 |
lemma seqseq_holds: |
8cc7f76b827a
tuned definition of seqseq; clarified usage of diagseq via diagseq_holds
immler
parents:
51526
diff
changeset
|
36 |
"P n (seqseq (Suc n))" |
8cc7f76b827a
tuned definition of seqseq; clarified usage of diagseq via diagseq_holds
immler
parents:
51526
diff
changeset
|
37 |
proof - |
67091 | 38 |
have "P n (seqseq n \<circ> reduce (seqseq n) n)" |
52681
8cc7f76b827a
tuned definition of seqseq; clarified usage of diagseq via diagseq_holds
immler
parents:
51526
diff
changeset
|
39 |
by (intro reduce_holds subseq_seqseq) |
8cc7f76b827a
tuned definition of seqseq; clarified usage of diagseq via diagseq_holds
immler
parents:
51526
diff
changeset
|
40 |
thus ?thesis by simp |
50087 | 41 |
qed |
42 |
||
66447
a1f5c5c26fa6
Replaced subseq with strict_mono
eberlm <eberlm@in.tum.de>
parents:
60500
diff
changeset
|
43 |
definition diagseq :: "nat \<Rightarrow> nat" where "diagseq i = seqseq i i" |
52681
8cc7f76b827a
tuned definition of seqseq; clarified usage of diagseq via diagseq_holds
immler
parents:
51526
diff
changeset
|
44 |
|
50087 | 45 |
lemma diagseq_mono: "diagseq n < diagseq (Suc n)" |
52681
8cc7f76b827a
tuned definition of seqseq; clarified usage of diagseq via diagseq_holds
immler
parents:
51526
diff
changeset
|
46 |
proof - |
8cc7f76b827a
tuned definition of seqseq; clarified usage of diagseq via diagseq_holds
immler
parents:
51526
diff
changeset
|
47 |
have "diagseq n < seqseq n (Suc n)" |
66447
a1f5c5c26fa6
Replaced subseq with strict_mono
eberlm <eberlm@in.tum.de>
parents:
60500
diff
changeset
|
48 |
using subseq_seqseq[of n] by (simp add: diagseq_def strict_mono_def) |
52681
8cc7f76b827a
tuned definition of seqseq; clarified usage of diagseq via diagseq_holds
immler
parents:
51526
diff
changeset
|
49 |
also have "\<dots> \<le> seqseq n (reduce (seqseq n) n (Suc n))" |
66447
a1f5c5c26fa6
Replaced subseq with strict_mono
eberlm <eberlm@in.tum.de>
parents:
60500
diff
changeset
|
50 |
using strict_mono_less_eq seq_suble by blast |
52681
8cc7f76b827a
tuned definition of seqseq; clarified usage of diagseq via diagseq_holds
immler
parents:
51526
diff
changeset
|
51 |
also have "\<dots> = diagseq (Suc n)" by (simp add: diagseq_def) |
8cc7f76b827a
tuned definition of seqseq; clarified usage of diagseq via diagseq_holds
immler
parents:
51526
diff
changeset
|
52 |
finally show ?thesis . |
8cc7f76b827a
tuned definition of seqseq; clarified usage of diagseq via diagseq_holds
immler
parents:
51526
diff
changeset
|
53 |
qed |
50087 | 54 |
|
66447
a1f5c5c26fa6
Replaced subseq with strict_mono
eberlm <eberlm@in.tum.de>
parents:
60500
diff
changeset
|
55 |
lemma subseq_diagseq: "strict_mono diagseq" |
a1f5c5c26fa6
Replaced subseq with strict_mono
eberlm <eberlm@in.tum.de>
parents:
60500
diff
changeset
|
56 |
using diagseq_mono by (simp add: strict_mono_Suc_iff diagseq_def) |
50087 | 57 |
|
58 |
primrec fold_reduce where |
|
59 |
"fold_reduce n 0 = id" |
|
67091 | 60 |
| "fold_reduce n (Suc k) = fold_reduce n k \<circ> reduce (seqseq (n + k)) (n + k)" |
50087 | 61 |
|
66447
a1f5c5c26fa6
Replaced subseq with strict_mono
eberlm <eberlm@in.tum.de>
parents:
60500
diff
changeset
|
62 |
lemma subseq_fold_reduce[intro, simp]: "strict_mono (fold_reduce n k)" |
50087 | 63 |
proof (induct k) |
66447
a1f5c5c26fa6
Replaced subseq with strict_mono
eberlm <eberlm@in.tum.de>
parents:
60500
diff
changeset
|
64 |
case (Suc k) from strict_mono_o[OF this subseq_reduce] show ?case by (simp add: o_def) |
a1f5c5c26fa6
Replaced subseq with strict_mono
eberlm <eberlm@in.tum.de>
parents:
60500
diff
changeset
|
65 |
qed (simp add: strict_mono_def) |
50087 | 66 |
|
67091 | 67 |
lemma ex_subseq_reduce_index: "seqseq (n + k) = seqseq n \<circ> fold_reduce n k" |
50087 | 68 |
by (induct k) simp_all |
69 |
||
70 |
lemma seqseq_fold_reduce: "seqseq n = fold_reduce 0 n" |
|
71 |
by (induct n) (simp_all) |
|
72 |
||
73 |
lemma diagseq_fold_reduce: "diagseq n = fold_reduce 0 n n" |
|
74 |
using seqseq_fold_reduce by (simp add: diagseq_def) |
|
75 |
||
67091 | 76 |
lemma fold_reduce_add: "fold_reduce 0 (m + n) = fold_reduce 0 m \<circ> fold_reduce m n" |
50087 | 77 |
by (induct n) simp_all |
78 |
||
67091 | 79 |
lemma diagseq_add: "diagseq (k + n) = (seqseq k \<circ> (fold_reduce k n)) (k + n)" |
50087 | 80 |
proof - |
81 |
have "diagseq (k + n) = fold_reduce 0 (k + n) (k + n)" |
|
82 |
by (simp add: diagseq_fold_reduce) |
|
67091 | 83 |
also have "\<dots> = (seqseq k \<circ> fold_reduce k n) (k + n)" |
50087 | 84 |
unfolding fold_reduce_add seqseq_fold_reduce .. |
85 |
finally show ?thesis . |
|
86 |
qed |
|
87 |
||
88 |
lemma diagseq_sub: |
|
67091 | 89 |
assumes "m \<le> n" shows "diagseq n = (seqseq m \<circ> (fold_reduce m (n - m))) n" |
50087 | 90 |
using diagseq_add[of m "n - m"] assms by simp |
91 |
||
66447
a1f5c5c26fa6
Replaced subseq with strict_mono
eberlm <eberlm@in.tum.de>
parents:
60500
diff
changeset
|
92 |
lemma subseq_diagonal_rest: "strict_mono (\<lambda>x. fold_reduce k x (k + x))" |
a1f5c5c26fa6
Replaced subseq with strict_mono
eberlm <eberlm@in.tum.de>
parents:
60500
diff
changeset
|
93 |
unfolding strict_mono_Suc_iff fold_reduce.simps o_def |
52681
8cc7f76b827a
tuned definition of seqseq; clarified usage of diagseq via diagseq_holds
immler
parents:
51526
diff
changeset
|
94 |
proof |
8cc7f76b827a
tuned definition of seqseq; clarified usage of diagseq via diagseq_holds
immler
parents:
51526
diff
changeset
|
95 |
fix n |
8cc7f76b827a
tuned definition of seqseq; clarified usage of diagseq via diagseq_holds
immler
parents:
51526
diff
changeset
|
96 |
have "fold_reduce k n (k + n) < fold_reduce k n (k + Suc n)" (is "?lhs < _") |
66447
a1f5c5c26fa6
Replaced subseq with strict_mono
eberlm <eberlm@in.tum.de>
parents:
60500
diff
changeset
|
97 |
by (auto intro: strict_monoD) |
52681
8cc7f76b827a
tuned definition of seqseq; clarified usage of diagseq via diagseq_holds
immler
parents:
51526
diff
changeset
|
98 |
also have "\<dots> \<le> fold_reduce k n (reduce (seqseq (k + n)) (k + n) (k + Suc n))" |
66447
a1f5c5c26fa6
Replaced subseq with strict_mono
eberlm <eberlm@in.tum.de>
parents:
60500
diff
changeset
|
99 |
by (auto intro: less_mono_imp_le_mono seq_suble strict_monoD) |
52681
8cc7f76b827a
tuned definition of seqseq; clarified usage of diagseq via diagseq_holds
immler
parents:
51526
diff
changeset
|
100 |
finally show "?lhs < \<dots>" . |
8cc7f76b827a
tuned definition of seqseq; clarified usage of diagseq via diagseq_holds
immler
parents:
51526
diff
changeset
|
101 |
qed |
50087 | 102 |
|
67399 | 103 |
lemma diagseq_seqseq: "diagseq \<circ> ((+) k) = (seqseq k \<circ> (\<lambda>x. fold_reduce k x (k + x)))" |
50087 | 104 |
by (auto simp: o_def diagseq_add) |
105 |
||
52681
8cc7f76b827a
tuned definition of seqseq; clarified usage of diagseq via diagseq_holds
immler
parents:
51526
diff
changeset
|
106 |
lemma diagseq_holds: |
67091 | 107 |
assumes subseq_stable: "\<And>r s n. strict_mono r \<Longrightarrow> P n s \<Longrightarrow> P n (s \<circ> r)" |
67399 | 108 |
shows "P k (diagseq \<circ> ((+) (Suc k)))" |
52681
8cc7f76b827a
tuned definition of seqseq; clarified usage of diagseq via diagseq_holds
immler
parents:
51526
diff
changeset
|
109 |
unfolding diagseq_seqseq by (intro subseq_stable subseq_diagonal_rest seqseq_holds) |
8cc7f76b827a
tuned definition of seqseq; clarified usage of diagseq via diagseq_holds
immler
parents:
51526
diff
changeset
|
110 |
|
50087 | 111 |
end |
112 |
||
113 |
end |