src/HOL/HOLCF/IOA/meta_theory/Sequence.thy
author wenzelm
Thu, 31 Dec 2015 00:07:42 +0100
changeset 62005 68db98c2cd97
parent 62002 f1599e98c4d0
permissions -rw-r--r--
modernized defs; tuned proofs; tuned whitespace;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
42151
4da4fc77664b tuned headers;
wenzelm
parents: 41476
diff changeset
     1
(*  Title:      HOL/HOLCF/IOA/meta_theory/Sequence.thy
40945
b8703f63bfb2 recoded latin1 as utf8;
wenzelm
parents: 40774
diff changeset
     2
    Author:     Olaf Müller
3071
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
     3
12218
wenzelm
parents: 12114
diff changeset
     4
Sequences over flat domains with lifted elements.
17233
41eee2e7b465 converted specifications to Isar theories;
wenzelm
parents: 14981
diff changeset
     5
*)
3071
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
     6
17233
41eee2e7b465 converted specifications to Isar theories;
wenzelm
parents: 14981
diff changeset
     7
theory Sequence
41eee2e7b465 converted specifications to Isar theories;
wenzelm
parents: 14981
diff changeset
     8
imports Seq
41eee2e7b465 converted specifications to Isar theories;
wenzelm
parents: 14981
diff changeset
     9
begin
3071
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    10
36452
d37c6eed8117 renamed command 'defaultsort' to 'default_sort';
wenzelm
parents: 35907
diff changeset
    11
default_sort type
17233
41eee2e7b465 converted specifications to Isar theories;
wenzelm
parents: 14981
diff changeset
    12
41476
0fa9629aa399 types -> type_synonym
huffman
parents: 41429
diff changeset
    13
type_synonym 'a Seq = "'a lift seq"
3071
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    14
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
    15
definition Consq :: "'a \<Rightarrow> 'a Seq \<rightarrow> 'a Seq"
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
    16
  where "Consq a = (LAM s. Def a ## s)"
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
    17
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
    18
definition Filter :: "('a \<Rightarrow> bool) \<Rightarrow> 'a Seq \<rightarrow> 'a Seq"
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
    19
  where "Filter P = sfilter $ (flift2 P)"
3071
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    20
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
    21
definition Map :: "('a \<Rightarrow> 'b) \<Rightarrow> 'a Seq \<rightarrow> 'b Seq"
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
    22
  where "Map f = smap $ (flift2 f)"
3071
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    23
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
    24
definition Forall :: "('a \<Rightarrow> bool) \<Rightarrow> 'a Seq \<Rightarrow> bool"
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
    25
  where "Forall P = sforall (flift2 P)"
3071
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    26
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
    27
definition Last :: "'a Seq \<rightarrow> 'a lift"
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
    28
  where "Last = slast"
3071
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    29
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
    30
definition Dropwhile :: "('a \<Rightarrow> bool) \<Rightarrow> 'a Seq \<rightarrow> 'a Seq"
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
    31
  where "Dropwhile P = sdropwhile $ (flift2 P)"
3071
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    32
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
    33
definition Takewhile :: "('a \<Rightarrow> bool) \<Rightarrow> 'a Seq \<rightarrow> 'a Seq"
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
    34
  where "Takewhile P = stakewhile $ (flift2 P)"
3071
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    35
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
    36
definition Zip :: "'a Seq \<rightarrow> 'b Seq \<rightarrow> ('a * 'b) Seq"
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
    37
where
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
    38
  "Zip = (fix$(LAM h t1 t2. case t1 of
3071
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    39
               nil   => nil
17233
41eee2e7b465 converted specifications to Isar theories;
wenzelm
parents: 14981
diff changeset
    40
             | x##xs => (case t2 of
41eee2e7b465 converted specifications to Isar theories;
wenzelm
parents: 14981
diff changeset
    41
                          nil => UU
41eee2e7b465 converted specifications to Isar theories;
wenzelm
parents: 14981
diff changeset
    42
                        | y##ys => (case x of
12028
52aa183c15bb replaced Undef by UU;
wenzelm
parents: 10835
diff changeset
    43
                                      UU  => UU
17233
41eee2e7b465 converted specifications to Isar theories;
wenzelm
parents: 14981
diff changeset
    44
                                    | Def a => (case y of
12028
52aa183c15bb replaced Undef by UU;
wenzelm
parents: 10835
diff changeset
    45
                                                  UU => UU
10835
nipkow
parents: 7229
diff changeset
    46
                                                | Def b => Def (a,b)##(h$xs$ys))))))"
3071
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    47
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
    48
definition Flat :: "'a Seq seq \<rightarrow> 'a Seq"
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
    49
  where "Flat = sflat"
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
    50
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
    51
definition Filter2 :: "('a \<Rightarrow> bool) \<Rightarrow> 'a Seq \<rightarrow> 'a Seq"
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
    52
where
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
    53
  "Filter2 P = (fix $ (LAM h t. case t of
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
    54
            nil \<Rightarrow> nil
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
    55
          | x##xs \<Rightarrow> (case x of UU \<Rightarrow> UU | Def y \<Rightarrow> (if P y
10835
nipkow
parents: 7229
diff changeset
    56
                     then x##(h$xs)
17233
41eee2e7b465 converted specifications to Isar theories;
wenzelm
parents: 14981
diff changeset
    57
                     else     h$xs))))"
3071
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
    58
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
    59
abbreviation Consq_syn  ("(_/\<leadsto>_)" [66,65] 65)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
    60
  where "a\<leadsto>s \<equiv> Consq a $ s"
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
    61
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
    62
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
    63
text \<open>List enumeration\<close>
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
    64
syntax
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
    65
  "_totlist"      :: "args => 'a Seq"              ("[(_)!]")
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
    66
  "_partlist"     :: "args => 'a Seq"              ("[(_)?]")
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
    67
translations
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
    68
  "[x, xs!]"     == "x\<leadsto>[xs!]"
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
    69
  "[x!]"         == "x\<leadsto>nil"
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
    70
  "[x, xs?]"     == "x\<leadsto>[xs?]"
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
    71
  "[x?]"         == "x\<leadsto>CONST bottom"
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
    72
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
    73
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
    74
declare andalso_and [simp]
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
    75
declare andalso_or [simp]
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
    76
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
    77
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
    78
subsection "recursive equations of operators"
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
    79
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
    80
subsubsection "Map"
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
    81
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
    82
lemma Map_UU: "Map f$UU =UU"
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
    83
  by (simp add: Map_def)
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
    84
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
    85
lemma Map_nil: "Map f$nil =nil"
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
    86
  by (simp add: Map_def)
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
    87
62001
1f2788fb0b8b more symbols;
wenzelm
parents: 62000
diff changeset
    88
lemma Map_cons: "Map f$(x\<leadsto>xs)=(f x) \<leadsto> Map f$xs"
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
    89
  by (simp add: Map_def Consq_def flift2_def)
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
    90
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
    91
62002
f1599e98c4d0 isabelle update_cartouches -c -t;
wenzelm
parents: 62001
diff changeset
    92
subsubsection \<open>Filter\<close>
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
    93
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
    94
lemma Filter_UU: "Filter P$UU =UU"
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
    95
  by (simp add: Filter_def)
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
    96
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
    97
lemma Filter_nil: "Filter P$nil =nil"
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
    98
  by (simp add: Filter_def)
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
    99
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   100
lemma Filter_cons:
62001
1f2788fb0b8b more symbols;
wenzelm
parents: 62000
diff changeset
   101
  "Filter P$(x\<leadsto>xs)= (if P x then x\<leadsto>(Filter P$xs) else Filter P$xs)"
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   102
  by (simp add: Filter_def Consq_def flift2_def If_and_if)
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   103
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   104
62002
f1599e98c4d0 isabelle update_cartouches -c -t;
wenzelm
parents: 62001
diff changeset
   105
subsubsection \<open>Forall\<close>
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   106
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   107
lemma Forall_UU: "Forall P UU"
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   108
  by (simp add: Forall_def sforall_def)
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   109
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   110
lemma Forall_nil: "Forall P nil"
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   111
  by (simp add: Forall_def sforall_def)
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   112
62001
1f2788fb0b8b more symbols;
wenzelm
parents: 62000
diff changeset
   113
lemma Forall_cons: "Forall P (x\<leadsto>xs)= (P x & Forall P xs)"
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   114
  by (simp add: Forall_def sforall_def Consq_def flift2_def)
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   115
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   116
62002
f1599e98c4d0 isabelle update_cartouches -c -t;
wenzelm
parents: 62001
diff changeset
   117
subsubsection \<open>Conc\<close>
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   118
62001
1f2788fb0b8b more symbols;
wenzelm
parents: 62000
diff changeset
   119
lemma Conc_cons: "(x\<leadsto>xs) @@ y = x\<leadsto>(xs @@y)"
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   120
  by (simp add: Consq_def)
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   121
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   122
62002
f1599e98c4d0 isabelle update_cartouches -c -t;
wenzelm
parents: 62001
diff changeset
   123
subsubsection \<open>Takewhile\<close>
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   124
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   125
lemma Takewhile_UU: "Takewhile P$UU =UU"
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   126
  by (simp add: Takewhile_def)
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   127
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   128
lemma Takewhile_nil: "Takewhile P$nil =nil"
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   129
  by (simp add: Takewhile_def)
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   130
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   131
lemma Takewhile_cons:
62001
1f2788fb0b8b more symbols;
wenzelm
parents: 62000
diff changeset
   132
  "Takewhile P$(x\<leadsto>xs)= (if P x then x\<leadsto>(Takewhile P$xs) else nil)"
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   133
  by (simp add: Takewhile_def Consq_def flift2_def If_and_if)
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   134
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   135
62002
f1599e98c4d0 isabelle update_cartouches -c -t;
wenzelm
parents: 62001
diff changeset
   136
subsubsection \<open>DropWhile\<close>
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   137
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   138
lemma Dropwhile_UU: "Dropwhile P$UU =UU"
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   139
  by (simp add: Dropwhile_def)
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   140
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   141
lemma Dropwhile_nil: "Dropwhile P$nil =nil"
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   142
  by (simp add: Dropwhile_def)
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   143
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   144
lemma Dropwhile_cons:
62001
1f2788fb0b8b more symbols;
wenzelm
parents: 62000
diff changeset
   145
  "Dropwhile P$(x\<leadsto>xs)= (if P x then Dropwhile P$xs else x\<leadsto>xs)"
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   146
  by (simp add: Dropwhile_def Consq_def flift2_def If_and_if)
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   147
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   148
62002
f1599e98c4d0 isabelle update_cartouches -c -t;
wenzelm
parents: 62001
diff changeset
   149
subsubsection \<open>Last\<close>
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   150
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   151
lemma Last_UU: "Last$UU =UU"
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   152
  by (simp add: Last_def)
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   153
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   154
lemma Last_nil: "Last$nil =UU"
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   155
  by (simp add: Last_def)
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   156
62001
1f2788fb0b8b more symbols;
wenzelm
parents: 62000
diff changeset
   157
lemma Last_cons: "Last$(x\<leadsto>xs)= (if xs=nil then Def x else Last$xs)"
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   158
  apply (simp add: Last_def Consq_def)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   159
  apply (cases xs)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   160
  apply simp_all
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   161
  done
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   162
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   163
62002
f1599e98c4d0 isabelle update_cartouches -c -t;
wenzelm
parents: 62001
diff changeset
   164
subsubsection \<open>Flat\<close>
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   165
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   166
lemma Flat_UU: "Flat$UU =UU"
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   167
  by (simp add: Flat_def)
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   168
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   169
lemma Flat_nil: "Flat$nil =nil"
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   170
  by (simp add: Flat_def)
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   171
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   172
lemma Flat_cons: "Flat$(x##xs)= x @@ (Flat$xs)"
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   173
  by (simp add: Flat_def Consq_def)
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   174
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   175
62002
f1599e98c4d0 isabelle update_cartouches -c -t;
wenzelm
parents: 62001
diff changeset
   176
subsubsection \<open>Zip\<close>
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   177
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   178
lemma Zip_unfold:
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   179
  "Zip = (LAM t1 t2. case t1 of
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   180
                  nil   => nil
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   181
                | x##xs => (case t2 of
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   182
                             nil => UU
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   183
                           | y##ys => (case x of
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   184
                                         UU  => UU
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   185
                                       | Def a => (case y of
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   186
                                                     UU => UU
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   187
                                                   | Def b => Def (a,b)##(Zip$xs$ys)))))"
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   188
  apply (rule trans)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   189
  apply (rule fix_eq4)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   190
  apply (rule Zip_def)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   191
  apply (rule beta_cfun)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   192
  apply simp
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   193
  done
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   194
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   195
lemma Zip_UU1: "Zip$UU$y =UU"
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   196
  apply (subst Zip_unfold)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   197
  apply simp
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   198
  done
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   199
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   200
lemma Zip_UU2: "x~=nil ==> Zip$x$UU =UU"
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   201
  apply (subst Zip_unfold)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   202
  apply simp
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   203
  apply (cases x)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   204
  apply simp_all
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   205
  done
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   206
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   207
lemma Zip_nil: "Zip$nil$y =nil"
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   208
  apply (subst Zip_unfold)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   209
  apply simp
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   210
  done
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   211
62001
1f2788fb0b8b more symbols;
wenzelm
parents: 62000
diff changeset
   212
lemma Zip_cons_nil: "Zip$(x\<leadsto>xs)$nil= UU"
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   213
  apply (subst Zip_unfold)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   214
  apply (simp add: Consq_def)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   215
  done
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   216
62001
1f2788fb0b8b more symbols;
wenzelm
parents: 62000
diff changeset
   217
lemma Zip_cons: "Zip$(x\<leadsto>xs)$(y\<leadsto>ys)= (x,y) \<leadsto> Zip$xs$ys"
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   218
  apply (rule trans)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   219
  apply (subst Zip_unfold)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   220
  apply simp
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   221
  apply (simp add: Consq_def)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   222
  done
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   223
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   224
lemmas [simp del] =
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   225
  sfilter_UU sfilter_nil sfilter_cons
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   226
  smap_UU smap_nil smap_cons
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   227
  sforall2_UU sforall2_nil sforall2_cons
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   228
  slast_UU slast_nil slast_cons
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   229
  stakewhile_UU  stakewhile_nil  stakewhile_cons
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   230
  sdropwhile_UU  sdropwhile_nil  sdropwhile_cons
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   231
  sflat_UU sflat_nil sflat_cons
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   232
  szip_UU1 szip_UU2 szip_nil szip_cons_nil szip_cons
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   233
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   234
lemmas [simp] =
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   235
  Filter_UU Filter_nil Filter_cons
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   236
  Map_UU Map_nil Map_cons
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   237
  Forall_UU Forall_nil Forall_cons
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   238
  Last_UU Last_nil Last_cons
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   239
  Conc_cons
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   240
  Takewhile_UU Takewhile_nil Takewhile_cons
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   241
  Dropwhile_UU Dropwhile_nil Dropwhile_cons
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   242
  Zip_UU1 Zip_UU2 Zip_nil Zip_cons_nil Zip_cons
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   243
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   244
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   245
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   246
section "Cons"
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   247
62001
1f2788fb0b8b more symbols;
wenzelm
parents: 62000
diff changeset
   248
lemma Consq_def2: "a\<leadsto>s = (Def a)##s"
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   249
  by (simp add: Consq_def)
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   250
62001
1f2788fb0b8b more symbols;
wenzelm
parents: 62000
diff changeset
   251
lemma Seq_exhaust: "x = UU | x = nil | (? a s. x = a \<leadsto> s)"
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   252
  apply (simp add: Consq_def2)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   253
  apply (cut_tac seq.nchotomy)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   254
  apply (fast dest: not_Undef_is_Def [THEN iffD1])
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   255
  done
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   256
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   257
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   258
lemma Seq_cases: "!!P. [| x = UU ==> P; x = nil ==> P; !!a s. x = a \<leadsto> s  ==> P |] ==> P"
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   259
  apply (cut_tac x="x" in Seq_exhaust)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   260
  apply (erule disjE)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   261
  apply simp
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   262
  apply (erule disjE)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   263
  apply simp
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   264
  apply (erule exE)+
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   265
  apply simp
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   266
  done
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   267
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   268
(*
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   269
fun Seq_case_tac s i = rule_tac x",s)] Seq_cases i
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   270
          THEN hyp_subst_tac i THEN hyp_subst_tac (i+1) THEN hyp_subst_tac (i+2);
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   271
*)
62001
1f2788fb0b8b more symbols;
wenzelm
parents: 62000
diff changeset
   272
(* on a\<leadsto>s only simp_tac, as full_simp_tac is uncomplete and often causes errors *)
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   273
(*
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   274
fun Seq_case_simp_tac s i = Seq_case_tac s i THEN Asm_simp_tac (i+2)
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   275
                                             THEN Asm_full_simp_tac (i+1)
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   276
                                             THEN Asm_full_simp_tac i;
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   277
*)
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   278
62001
1f2788fb0b8b more symbols;
wenzelm
parents: 62000
diff changeset
   279
lemma Cons_not_UU: "a\<leadsto>s ~= UU"
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   280
  apply (subst Consq_def2)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   281
  apply simp
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   282
  done
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   283
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   284
62001
1f2788fb0b8b more symbols;
wenzelm
parents: 62000
diff changeset
   285
lemma Cons_not_less_UU: "~(a\<leadsto>x) << UU"
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   286
  apply (rule notI)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   287
  apply (drule below_antisym)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   288
  apply simp
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   289
  apply (simp add: Cons_not_UU)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   290
  done
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   291
62001
1f2788fb0b8b more symbols;
wenzelm
parents: 62000
diff changeset
   292
lemma Cons_not_less_nil: "~a\<leadsto>s << nil"
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   293
  by (simp add: Consq_def2)
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   294
62001
1f2788fb0b8b more symbols;
wenzelm
parents: 62000
diff changeset
   295
lemma Cons_not_nil: "a\<leadsto>s ~= nil"
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   296
  by (simp add: Consq_def2)
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   297
62001
1f2788fb0b8b more symbols;
wenzelm
parents: 62000
diff changeset
   298
lemma Cons_not_nil2: "nil ~= a\<leadsto>s"
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   299
  by (simp add: Consq_def2)
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   300
62001
1f2788fb0b8b more symbols;
wenzelm
parents: 62000
diff changeset
   301
lemma Cons_inject_eq: "(a\<leadsto>s = b\<leadsto>t) = (a = b & s = t)"
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   302
  apply (simp only: Consq_def2)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   303
  apply (simp add: scons_inject_eq)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   304
  done
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   305
62001
1f2788fb0b8b more symbols;
wenzelm
parents: 62000
diff changeset
   306
lemma Cons_inject_less_eq: "(a\<leadsto>s<<b\<leadsto>t) = (a = b & s<<t)"
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   307
  by (simp add: Consq_def2)
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   308
62001
1f2788fb0b8b more symbols;
wenzelm
parents: 62000
diff changeset
   309
lemma seq_take_Cons: "seq_take (Suc n)$(a\<leadsto>x) = a\<leadsto> (seq_take n$x)"
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   310
  by (simp add: Consq_def)
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   311
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   312
lemmas [simp] =
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   313
  Cons_not_nil2 Cons_inject_eq Cons_inject_less_eq seq_take_Cons
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   314
  Cons_not_UU Cons_not_less_UU Cons_not_less_nil Cons_not_nil
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   315
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   316
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   317
subsection "induction"
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   318
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   319
lemma Seq_induct: "!! P. [| adm P; P UU; P nil; !! a s. P s ==> P (a\<leadsto>s)|] ==> P x"
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   320
  apply (erule (2) seq.induct)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   321
  apply defined
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   322
  apply (simp add: Consq_def)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   323
  done
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   324
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   325
lemma Seq_FinitePartial_ind:
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   326
  "!! P.[|P UU;P nil; !! a s. P s ==> P(a\<leadsto>s) |]
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   327
                  ==> seq_finite x --> P x"
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   328
  apply (erule (1) seq_finite_ind)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   329
  apply defined
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   330
  apply (simp add: Consq_def)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   331
  done
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   332
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   333
lemma Seq_Finite_ind:
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   334
  "!! P.[| Finite x; P nil; !! a s. [| Finite s; P s|] ==> P (a\<leadsto>s) |] ==> P x"
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   335
  apply (erule (1) Finite.induct)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   336
  apply defined
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   337
  apply (simp add: Consq_def)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   338
  done
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   339
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   340
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   341
(* rws are definitions to be unfolded for admissibility check *)
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   342
(*
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   343
fun Seq_induct_tac s rws i = rule_tac x",s)] Seq_induct i
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   344
                         THEN (REPEAT_DETERM (CHANGED (Asm_simp_tac (i+1))))
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   345
                         THEN simp add: rws) i;
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   346
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   347
fun Seq_Finite_induct_tac i = erule Seq_Finite_ind i
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   348
                              THEN (REPEAT_DETERM (CHANGED (Asm_simp_tac i)));
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   349
61424
c3658c18b7bc prod_case as canonical name for product type eliminator
haftmann
parents: 61032
diff changeset
   350
fun pair_tac s = rule_tac p",s)] prod.exhaust
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   351
                          THEN' hyp_subst_tac THEN' Simp_tac;
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   352
*)
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   353
(* induction on a sequence of pairs with pairsplitting and simplification *)
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   354
(*
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   355
fun pair_induct_tac s rws i =
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   356
           rule_tac x",s)] Seq_induct i
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   357
           THEN pair_tac "a" (i+3)
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   358
           THEN (REPEAT_DETERM (CHANGED (Simp_tac (i+1))))
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   359
           THEN simp add: rws) i;
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   360
*)
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   361
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   362
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   363
(* ------------------------------------------------------------------------------------ *)
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   364
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   365
subsection "HD,TL"
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   366
62001
1f2788fb0b8b more symbols;
wenzelm
parents: 62000
diff changeset
   367
lemma HD_Cons [simp]: "HD$(x\<leadsto>y) = Def x"
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   368
  by (simp add: Consq_def)
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   369
62001
1f2788fb0b8b more symbols;
wenzelm
parents: 62000
diff changeset
   370
lemma TL_Cons [simp]: "TL$(x\<leadsto>y) = y"
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   371
  by (simp add: Consq_def)
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   372
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   373
(* ------------------------------------------------------------------------------------ *)
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   374
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   375
subsection "Finite, Partial, Infinite"
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   376
62001
1f2788fb0b8b more symbols;
wenzelm
parents: 62000
diff changeset
   377
lemma Finite_Cons [simp]: "Finite (a\<leadsto>xs) = Finite xs"
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   378
  by (simp add: Consq_def2 Finite_cons)
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   379
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   380
lemma FiniteConc_1: "Finite (x::'a Seq) ==> Finite y --> Finite (x@@y)"
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   381
  apply (erule Seq_Finite_ind)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   382
  apply simp_all
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   383
  done
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   384
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   385
lemma FiniteConc_2: "Finite (z::'a Seq) ==> !x y. z= x@@y --> (Finite x & Finite y)"
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   386
  apply (erule Seq_Finite_ind)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   387
  (* nil*)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   388
  apply (intro strip)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   389
  apply (rule_tac x="x" in Seq_cases, simp_all)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   390
  (* cons *)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   391
  apply (intro strip)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   392
  apply (rule_tac x="x" in Seq_cases, simp_all)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   393
  apply (rule_tac x="y" in Seq_cases, simp_all)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   394
  done
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   395
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   396
lemma FiniteConc [simp]: "Finite(x@@y) = (Finite (x::'a Seq) & Finite y)"
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   397
  apply (rule iffI)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   398
  apply (erule FiniteConc_2 [rule_format])
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   399
  apply (rule refl)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   400
  apply (rule FiniteConc_1 [rule_format])
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   401
  apply auto
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   402
  done
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   403
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   404
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   405
lemma FiniteMap1: "Finite s ==> Finite (Map f$s)"
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   406
  apply (erule Seq_Finite_ind)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   407
  apply simp_all
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   408
  done
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   409
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   410
lemma FiniteMap2: "Finite s ==> ! t. (s = Map f$t) --> Finite t"
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   411
  apply (erule Seq_Finite_ind)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   412
  apply (intro strip)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   413
  apply (rule_tac x="t" in Seq_cases, simp_all)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   414
  (* main case *)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   415
  apply auto
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   416
  apply (rule_tac x="t" in Seq_cases, simp_all)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   417
  done
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   418
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   419
lemma Map2Finite: "Finite (Map f$s) = Finite s"
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   420
  apply auto
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   421
  apply (erule FiniteMap2 [rule_format])
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   422
  apply (rule refl)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   423
  apply (erule FiniteMap1)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   424
  done
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   425
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   426
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   427
lemma FiniteFilter: "Finite s ==> Finite (Filter P$s)"
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   428
  apply (erule Seq_Finite_ind)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   429
  apply simp_all
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   430
  done
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   431
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   432
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   433
(* ----------------------------------------------------------------------------------- *)
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   434
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   435
subsection "Conc"
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   436
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   437
lemma Conc_cong: "!! x::'a Seq. Finite x ==> ((x @@ y) = (x @@ z)) = (y = z)"
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   438
  apply (erule Seq_Finite_ind)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   439
  apply simp_all
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   440
  done
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   441
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   442
lemma Conc_assoc: "(x @@ y) @@ z = (x::'a Seq) @@ y @@ z"
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   443
  apply (rule_tac x="x" in Seq_induct)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   444
  apply simp_all
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   445
  done
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   446
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   447
lemma nilConc [simp]: "s@@ nil = s"
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   448
  apply (induct s)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   449
  apply simp
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   450
  apply simp
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   451
  apply simp
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   452
  apply simp
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   453
  done
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   454
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   455
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   456
(* should be same as nil_is_Conc2 when all nils are turned to right side !! *)
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   457
lemma nil_is_Conc: "(nil = x @@ y) = ((x::'a Seq)= nil & y = nil)"
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   458
  apply (rule_tac x="x" in Seq_cases)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   459
  apply auto
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   460
  done
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   461
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   462
lemma nil_is_Conc2: "(x @@ y = nil) = ((x::'a Seq)= nil & y = nil)"
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   463
  apply (rule_tac x="x" in Seq_cases)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   464
  apply auto
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   465
  done
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   466
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   467
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   468
(* ------------------------------------------------------------------------------------ *)
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   469
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   470
subsection "Last"
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   471
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   472
lemma Finite_Last1: "Finite s ==> s~=nil --> Last$s~=UU"
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   473
  apply (erule Seq_Finite_ind, simp_all)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   474
  done
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   475
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   476
lemma Finite_Last2: "Finite s ==> Last$s=UU --> s=nil"
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   477
  apply (erule Seq_Finite_ind, simp_all)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   478
  apply fast
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   479
  done
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   480
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   481
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   482
(* ------------------------------------------------------------------------------------ *)
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   483
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   484
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   485
subsection "Filter, Conc"
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   486
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   487
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   488
lemma FilterPQ: "Filter P$(Filter Q$s) = Filter (%x. P x & Q x)$s"
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   489
  apply (rule_tac x="s" in Seq_induct, simp_all)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   490
  done
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   491
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   492
lemma FilterConc: "Filter P$(x @@ y) = (Filter P$x @@ Filter P$y)"
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   493
  apply (simp add: Filter_def sfiltersconc)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   494
  done
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   495
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   496
(* ------------------------------------------------------------------------------------ *)
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   497
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   498
subsection "Map"
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   499
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   500
lemma MapMap: "Map f$(Map g$s) = Map (f o g)$s"
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   501
  apply (rule_tac x="s" in Seq_induct, simp_all)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   502
  done
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   503
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   504
lemma MapConc: "Map f$(x@@y) = (Map f$x) @@ (Map f$y)"
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   505
  apply (rule_tac x="x" in Seq_induct, simp_all)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   506
  done
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   507
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   508
lemma MapFilter: "Filter P$(Map f$x) = Map f$(Filter (P o f)$x)"
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   509
  apply (rule_tac x="x" in Seq_induct, simp_all)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   510
  done
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   511
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   512
lemma nilMap: "nil = (Map f$s) --> s= nil"
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   513
  apply (rule_tac x="s" in Seq_cases, simp_all)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   514
  done
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   515
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   516
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   517
lemma ForallMap: "Forall P (Map f$s) = Forall (P o f) s"
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   518
  apply (rule_tac x="s" in Seq_induct)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   519
  apply (simp add: Forall_def sforall_def)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   520
  apply simp_all
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   521
  done
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   522
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   523
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   524
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   525
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   526
(* ------------------------------------------------------------------------------------ *)
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   527
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   528
subsection "Forall"
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   529
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   530
lemma ForallPForallQ1: "Forall P ys & (! x. P x --> Q x) --> Forall Q ys"
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   531
  apply (rule_tac x="ys" in Seq_induct)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   532
  apply (simp add: Forall_def sforall_def)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   533
  apply simp_all
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   534
  done
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   535
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   536
lemmas ForallPForallQ =
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   537
  ForallPForallQ1 [THEN mp, OF conjI, OF _ allI, OF _ impI]
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   538
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   539
lemma Forall_Conc_impl: "(Forall P x & Forall P y) --> Forall P (x @@ y)"
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   540
  apply (rule_tac x="x" in Seq_induct)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   541
  apply (simp add: Forall_def sforall_def)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   542
  apply simp_all
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   543
  done
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   544
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   545
lemma Forall_Conc [simp]:
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   546
  "Finite x ==> Forall P (x @@ y) = (Forall P x & Forall P y)"
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   547
  apply (erule Seq_Finite_ind, simp_all)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   548
  done
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   549
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   550
lemma ForallTL1: "Forall P s  --> Forall P (TL$s)"
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   551
  apply (rule_tac x="s" in Seq_induct)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   552
  apply (simp add: Forall_def sforall_def)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   553
  apply simp_all
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   554
  done
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   555
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   556
lemmas ForallTL = ForallTL1 [THEN mp]
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   557
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   558
lemma ForallDropwhile1: "Forall P s  --> Forall P (Dropwhile Q$s)"
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   559
  apply (rule_tac x="s" in Seq_induct)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   560
  apply (simp add: Forall_def sforall_def)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   561
  apply simp_all
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   562
  done
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   563
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   564
lemmas ForallDropwhile = ForallDropwhile1 [THEN mp]
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   565
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   566
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   567
(* only admissible in t, not if done in s *)
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   568
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   569
lemma Forall_prefix: "! s. Forall P s --> t<<s --> Forall P t"
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   570
  apply (rule_tac x="t" in Seq_induct)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   571
  apply (simp add: Forall_def sforall_def)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   572
  apply simp_all
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   573
  apply (intro strip)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   574
  apply (rule_tac x="sa" in Seq_cases)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   575
  apply simp
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   576
  apply auto
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   577
  done
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   578
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   579
lemmas Forall_prefixclosed = Forall_prefix [rule_format]
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   580
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   581
lemma Forall_postfixclosed: "[| Finite h; Forall P s; s= h @@ t |] ==> Forall P t"
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   582
  by auto
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   583
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   584
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   585
lemma ForallPFilterQR1:
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   586
  "((! x. P x --> (Q x = R x)) & Forall P tr) --> Filter Q$tr = Filter R$tr"
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   587
  apply (rule_tac x="tr" in Seq_induct)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   588
  apply (simp add: Forall_def sforall_def)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   589
  apply simp_all
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   590
  done
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   591
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   592
lemmas ForallPFilterQR = ForallPFilterQR1 [THEN mp, OF conjI, OF allI]
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   593
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   594
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   595
(* ------------------------------------------------------------------------------------- *)
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   596
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   597
subsection "Forall, Filter"
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   598
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   599
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   600
lemma ForallPFilterP: "Forall P (Filter P$x)"
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   601
  by (simp add: Filter_def Forall_def forallPsfilterP)
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   602
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   603
(* holds also in other direction, then equal to forallPfilterP *)
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   604
lemma ForallPFilterPid1: "Forall P x --> Filter P$x = x"
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   605
  apply (rule_tac x="x" in Seq_induct)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   606
  apply (simp add: Forall_def sforall_def Filter_def)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   607
  apply simp_all
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   608
  done
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   609
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   610
lemmas ForallPFilterPid = ForallPFilterPid1 [THEN mp]
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   611
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   612
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   613
(* holds also in other direction *)
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   614
lemma ForallnPFilterPnil1: "!! ys . Finite ys ==>
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   615
   Forall (%x. ~P x) ys --> Filter P$ys = nil "
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   616
  apply (erule Seq_Finite_ind, simp_all)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   617
  done
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   618
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   619
lemmas ForallnPFilterPnil = ForallnPFilterPnil1 [THEN mp]
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   620
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   621
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   622
(* holds also in other direction *)
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   623
lemma ForallnPFilterPUU1: "~Finite ys & Forall (%x. ~P x) ys --> Filter P$ys = UU"
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   624
  apply (rule_tac x="ys" in Seq_induct)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   625
  apply (simp add: Forall_def sforall_def)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   626
  apply simp_all
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   627
  done
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   628
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   629
lemmas ForallnPFilterPUU = ForallnPFilterPUU1 [THEN mp, OF conjI]
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   630
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   631
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   632
(* inverse of ForallnPFilterPnil *)
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   633
48194
1440a3103af0 tuned proofs -- eliminated old-fashioned COMP and rev_contrapos;
wenzelm
parents: 44890
diff changeset
   634
lemma FilternPnilForallP [rule_format]: "Filter P$ys = nil -->
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   635
   (Forall (%x. ~P x) ys & Finite ys)"
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   636
  apply (rule_tac x="ys" in Seq_induct)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   637
  (* adm *)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   638
  apply (simp add: Forall_def sforall_def)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   639
  (* base cases *)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   640
  apply simp
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   641
  apply simp
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   642
  (* main case *)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   643
  apply simp
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   644
  done
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   645
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   646
48194
1440a3103af0 tuned proofs -- eliminated old-fashioned COMP and rev_contrapos;
wenzelm
parents: 44890
diff changeset
   647
(* inverse of ForallnPFilterPUU *)
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   648
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   649
lemma FilternPUUForallP:
48194
1440a3103af0 tuned proofs -- eliminated old-fashioned COMP and rev_contrapos;
wenzelm
parents: 44890
diff changeset
   650
  assumes "Filter P$ys = UU"
1440a3103af0 tuned proofs -- eliminated old-fashioned COMP and rev_contrapos;
wenzelm
parents: 44890
diff changeset
   651
  shows "Forall (%x. ~P x) ys  & ~Finite ys"
1440a3103af0 tuned proofs -- eliminated old-fashioned COMP and rev_contrapos;
wenzelm
parents: 44890
diff changeset
   652
proof
1440a3103af0 tuned proofs -- eliminated old-fashioned COMP and rev_contrapos;
wenzelm
parents: 44890
diff changeset
   653
  show "Forall (%x. ~P x) ys"
1440a3103af0 tuned proofs -- eliminated old-fashioned COMP and rev_contrapos;
wenzelm
parents: 44890
diff changeset
   654
  proof (rule classical)
1440a3103af0 tuned proofs -- eliminated old-fashioned COMP and rev_contrapos;
wenzelm
parents: 44890
diff changeset
   655
    assume "\<not> ?thesis"
1440a3103af0 tuned proofs -- eliminated old-fashioned COMP and rev_contrapos;
wenzelm
parents: 44890
diff changeset
   656
    then have "Filter P$ys ~= UU"
1440a3103af0 tuned proofs -- eliminated old-fashioned COMP and rev_contrapos;
wenzelm
parents: 44890
diff changeset
   657
      apply (rule rev_mp)
1440a3103af0 tuned proofs -- eliminated old-fashioned COMP and rev_contrapos;
wenzelm
parents: 44890
diff changeset
   658
      apply (induct ys rule: Seq_induct)
1440a3103af0 tuned proofs -- eliminated old-fashioned COMP and rev_contrapos;
wenzelm
parents: 44890
diff changeset
   659
      apply (simp add: Forall_def sforall_def)
1440a3103af0 tuned proofs -- eliminated old-fashioned COMP and rev_contrapos;
wenzelm
parents: 44890
diff changeset
   660
      apply simp_all
1440a3103af0 tuned proofs -- eliminated old-fashioned COMP and rev_contrapos;
wenzelm
parents: 44890
diff changeset
   661
      done
1440a3103af0 tuned proofs -- eliminated old-fashioned COMP and rev_contrapos;
wenzelm
parents: 44890
diff changeset
   662
    with assms show ?thesis by contradiction
1440a3103af0 tuned proofs -- eliminated old-fashioned COMP and rev_contrapos;
wenzelm
parents: 44890
diff changeset
   663
  qed
1440a3103af0 tuned proofs -- eliminated old-fashioned COMP and rev_contrapos;
wenzelm
parents: 44890
diff changeset
   664
  show "~ Finite ys"
1440a3103af0 tuned proofs -- eliminated old-fashioned COMP and rev_contrapos;
wenzelm
parents: 44890
diff changeset
   665
  proof
1440a3103af0 tuned proofs -- eliminated old-fashioned COMP and rev_contrapos;
wenzelm
parents: 44890
diff changeset
   666
    assume "Finite ys"
1440a3103af0 tuned proofs -- eliminated old-fashioned COMP and rev_contrapos;
wenzelm
parents: 44890
diff changeset
   667
    then have "Filter P$ys ~= UU"
1440a3103af0 tuned proofs -- eliminated old-fashioned COMP and rev_contrapos;
wenzelm
parents: 44890
diff changeset
   668
      by (rule Seq_Finite_ind) simp_all
1440a3103af0 tuned proofs -- eliminated old-fashioned COMP and rev_contrapos;
wenzelm
parents: 44890
diff changeset
   669
    with assms show False by contradiction
1440a3103af0 tuned proofs -- eliminated old-fashioned COMP and rev_contrapos;
wenzelm
parents: 44890
diff changeset
   670
  qed
1440a3103af0 tuned proofs -- eliminated old-fashioned COMP and rev_contrapos;
wenzelm
parents: 44890
diff changeset
   671
qed
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   672
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   673
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   674
lemma ForallQFilterPnil:
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   675
  "!! Q P.[| Forall Q ys; Finite ys; !!x. Q x ==> ~P x|]
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   676
    ==> Filter P$ys = nil"
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   677
  apply (erule ForallnPFilterPnil)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   678
  apply (erule ForallPForallQ)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   679
  apply auto
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   680
  done
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   681
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   682
lemma ForallQFilterPUU:
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   683
 "!! Q P. [| ~Finite ys; Forall Q ys;  !!x. Q x ==> ~P x|]
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   684
    ==> Filter P$ys = UU "
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   685
  apply (erule ForallnPFilterPUU)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   686
  apply (erule ForallPForallQ)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   687
  apply auto
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   688
  done
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   689
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   690
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   691
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   692
(* ------------------------------------------------------------------------------------- *)
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   693
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   694
subsection "Takewhile, Forall, Filter"
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   695
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   696
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   697
lemma ForallPTakewhileP [simp]: "Forall P (Takewhile P$x)"
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   698
  by (simp add: Forall_def Takewhile_def sforallPstakewhileP)
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   699
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   700
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   701
lemma ForallPTakewhileQ [simp]: "!! P. [| !!x. Q x==> P x |] ==> Forall P (Takewhile Q$x)"
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   702
  apply (rule ForallPForallQ)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   703
  apply (rule ForallPTakewhileP)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   704
  apply auto
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   705
  done
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   706
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   707
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   708
lemma FilterPTakewhileQnil [simp]:
26008
24c82bef5696 eliminated escaped white space;
wenzelm
parents: 25923
diff changeset
   709
  "!! Q P.[| Finite (Takewhile Q$ys); !!x. Q x ==> ~P x |]
24c82bef5696 eliminated escaped white space;
wenzelm
parents: 25923
diff changeset
   710
   ==> Filter P$(Takewhile Q$ys) = nil"
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   711
  apply (erule ForallnPFilterPnil)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   712
  apply (rule ForallPForallQ)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   713
  apply (rule ForallPTakewhileP)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   714
  apply auto
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   715
  done
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   716
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   717
lemma FilterPTakewhileQid [simp]:
26008
24c82bef5696 eliminated escaped white space;
wenzelm
parents: 25923
diff changeset
   718
 "!! Q P. [| !!x. Q x ==> P x |] ==>
24c82bef5696 eliminated escaped white space;
wenzelm
parents: 25923
diff changeset
   719
            Filter P$(Takewhile Q$ys) = (Takewhile Q$ys)"
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   720
  apply (rule ForallPFilterPid)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   721
  apply (rule ForallPForallQ)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   722
  apply (rule ForallPTakewhileP)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   723
  apply auto
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   724
  done
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   725
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   726
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   727
lemma Takewhile_idempotent: "Takewhile P$(Takewhile P$s) = Takewhile P$s"
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   728
  apply (rule_tac x="s" in Seq_induct)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   729
  apply (simp add: Forall_def sforall_def)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   730
  apply simp_all
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   731
  done
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   732
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   733
lemma ForallPTakewhileQnP [simp]: "Forall P s --> Takewhile (%x. Q x | (~P x))$s = Takewhile Q$s"
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   734
  apply (rule_tac x="s" in Seq_induct)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   735
  apply (simp add: Forall_def sforall_def)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   736
  apply simp_all
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   737
  done
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   738
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   739
lemma ForallPDropwhileQnP [simp]: "Forall P s --> Dropwhile (%x. Q x | (~P x))$s = Dropwhile Q$s"
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   740
  apply (rule_tac x="s" in Seq_induct)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   741
  apply (simp add: Forall_def sforall_def)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   742
  apply simp_all
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   743
  done
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   744
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   745
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   746
lemma TakewhileConc1: "Forall P s --> Takewhile P$(s @@ t) = s @@ (Takewhile P$t)"
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   747
  apply (rule_tac x="s" in Seq_induct)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   748
  apply (simp add: Forall_def sforall_def)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   749
  apply simp_all
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   750
  done
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   751
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   752
lemmas TakewhileConc = TakewhileConc1 [THEN mp]
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   753
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   754
lemma DropwhileConc1: "Finite s ==> Forall P s --> Dropwhile P$(s @@ t) = Dropwhile P$t"
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   755
  apply (erule Seq_Finite_ind, simp_all)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   756
  done
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   757
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   758
lemmas DropwhileConc = DropwhileConc1 [THEN mp]
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   759
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   760
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   761
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   762
(* ----------------------------------------------------------------------------------- *)
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   763
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   764
subsection "coinductive characterizations of Filter"
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   765
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   766
lemma divide_Seq_lemma:
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   767
 "HD$(Filter P$y) = Def x
62001
1f2788fb0b8b more symbols;
wenzelm
parents: 62000
diff changeset
   768
    --> y = ((Takewhile (%x. ~P x)$y) @@ (x \<leadsto> TL$(Dropwhile (%a. ~P a)$y)))
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   769
             & Finite (Takewhile (%x. ~ P x)$y)  & P x"
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   770
  (* FIX: pay attention: is only admissible with chain-finite package to be added to
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   771
          adm test and Finite f x admissibility *)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   772
  apply (rule_tac x="y" in Seq_induct)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   773
  apply (simp add: adm_subst [OF _ adm_Finite])
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   774
  apply simp
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   775
  apply simp
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   776
  apply (case_tac "P a")
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   777
   apply simp
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   778
   apply blast
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   779
  (* ~ P a *)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   780
  apply simp
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   781
  done
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   782
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   783
lemma divide_Seq: "(x\<leadsto>xs) << Filter P$y
62001
1f2788fb0b8b more symbols;
wenzelm
parents: 62000
diff changeset
   784
   ==> y = ((Takewhile (%a. ~ P a)$y) @@ (x \<leadsto> TL$(Dropwhile (%a. ~ P a)$y)))
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   785
      & Finite (Takewhile (%a. ~ P a)$y)  & P x"
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   786
  apply (rule divide_Seq_lemma [THEN mp])
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   787
  apply (drule_tac f="HD" and x="x\<leadsto>xs" in  monofun_cfun_arg)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   788
  apply simp
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   789
  done
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   790
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   791
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   792
lemma nForall_HDFilter: "~Forall P y --> (? x. HD$(Filter (%a. ~P a)$y) = Def x)"
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   793
  unfolding not_Undef_is_Def [symmetric]
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   794
  apply (induct y rule: Seq_induct)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   795
  apply (simp add: Forall_def sforall_def)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   796
  apply simp_all
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   797
  done
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   798
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   799
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   800
lemma divide_Seq2: "~Forall P y
62001
1f2788fb0b8b more symbols;
wenzelm
parents: 62000
diff changeset
   801
  ==> ? x. y= (Takewhile P$y @@ (x \<leadsto> TL$(Dropwhile P$y))) &
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   802
      Finite (Takewhile P$y) & (~ P x)"
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   803
  apply (drule nForall_HDFilter [THEN mp])
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   804
  apply safe
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   805
  apply (rule_tac x="x" in exI)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   806
  apply (cut_tac P1="%x. ~ P x" in divide_Seq_lemma [THEN mp])
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   807
  apply auto
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   808
  done
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   809
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   810
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   811
lemma divide_Seq3: "~Forall P y
62001
1f2788fb0b8b more symbols;
wenzelm
parents: 62000
diff changeset
   812
  ==> ? x bs rs. y= (bs @@ (x\<leadsto>rs)) & Finite bs & Forall P bs & (~ P x)"
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   813
  apply (drule divide_Seq2)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   814
  apply fastforce
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   815
  done
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   816
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   817
lemmas [simp] = FilterPQ FilterConc Conc_cong
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   818
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   819
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   820
(* ------------------------------------------------------------------------------------- *)
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   821
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   822
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   823
subsection "take_lemma"
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   824
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   825
lemma seq_take_lemma: "(!n. seq_take n$x = seq_take n$x') = (x = x')"
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   826
  apply (rule iffI)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   827
  apply (rule seq.take_lemma)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   828
  apply auto
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   829
  done
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   830
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   831
lemma take_reduction1:
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   832
  "\<forall>n. ((! k. k < n --> seq_take k$y1 = seq_take k$y2)
62001
1f2788fb0b8b more symbols;
wenzelm
parents: 62000
diff changeset
   833
    --> seq_take n$(x @@ (t\<leadsto>y1)) =  seq_take n$(x @@ (t\<leadsto>y2)))"
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   834
  apply (rule_tac x="x" in Seq_induct)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   835
  apply simp_all
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   836
  apply (intro strip)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   837
  apply (case_tac "n")
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   838
  apply auto
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   839
  apply (case_tac "n")
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   840
  apply auto
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   841
  done
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   842
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   843
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   844
lemma take_reduction:
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   845
  "!! n.[| x=y; s=t; !! k. k<n ==> seq_take k$y1 = seq_take k$y2|]
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   846
    ==> seq_take n$(x @@ (s\<leadsto>y1)) =  seq_take n$(y @@ (t\<leadsto>y2))"
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   847
  by (auto intro!: take_reduction1 [rule_format])
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   848
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   849
(* ------------------------------------------------------------------
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   850
          take-lemma and take_reduction for << instead of =
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   851
   ------------------------------------------------------------------ *)
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   852
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   853
lemma take_reduction_less1:
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   854
  "\<forall>n. ((! k. k < n --> seq_take k$y1 << seq_take k$y2)
62001
1f2788fb0b8b more symbols;
wenzelm
parents: 62000
diff changeset
   855
    --> seq_take n$(x @@ (t\<leadsto>y1)) <<  seq_take n$(x @@ (t\<leadsto>y2)))"
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   856
  apply (rule_tac x="x" in Seq_induct)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   857
  apply simp_all
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   858
  apply (intro strip)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   859
  apply (case_tac "n")
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   860
  apply auto
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   861
  apply (case_tac "n")
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   862
  apply auto
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   863
  done
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   864
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   865
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   866
lemma take_reduction_less:
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   867
  "\<And>n.[| x=y; s=t;!! k. k<n ==> seq_take k$y1 << seq_take k$y2|]
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   868
    ==> seq_take n$(x @@ (s\<leadsto>y1)) <<  seq_take n$(y @@ (t\<leadsto>y2))"
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   869
  by (auto intro!: take_reduction_less1 [rule_format])
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   870
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   871
lemma take_lemma_less1:
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   872
  assumes "!! n. seq_take n$s1 << seq_take n$s2"
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   873
  shows "s1<<s2"
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   874
  apply (rule_tac t="s1" in seq.reach [THEN subst])
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   875
  apply (rule_tac t="s2" in seq.reach [THEN subst])
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   876
  apply (rule lub_mono)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   877
  apply (rule seq.chain_take [THEN ch2ch_Rep_cfunL])
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   878
  apply (rule seq.chain_take [THEN ch2ch_Rep_cfunL])
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   879
  apply (rule assms)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   880
  done
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   881
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   882
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   883
lemma take_lemma_less: "(!n. seq_take n$x << seq_take n$x') = (x << x')"
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   884
  apply (rule iffI)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   885
  apply (rule take_lemma_less1)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   886
  apply auto
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   887
  apply (erule monofun_cfun_arg)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   888
  done
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   889
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   890
(* ------------------------------------------------------------------
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   891
          take-lemma proof principles
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   892
   ------------------------------------------------------------------ *)
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   893
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   894
lemma take_lemma_principle1:
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   895
  "!! Q. [|!! s. [| Forall Q s; A s |] ==> (f s) = (g s) ;
62001
1f2788fb0b8b more symbols;
wenzelm
parents: 62000
diff changeset
   896
            !! s1 s2 y. [| Forall Q s1; Finite s1; ~ Q y; A (s1 @@ y\<leadsto>s2)|]
1f2788fb0b8b more symbols;
wenzelm
parents: 62000
diff changeset
   897
                          ==> (f (s1 @@ y\<leadsto>s2)) = (g (s1 @@ y\<leadsto>s2)) |]
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   898
               ==> A x --> (f x)=(g x)"
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   899
  apply (case_tac "Forall Q x")
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   900
  apply (auto dest!: divide_Seq3)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   901
  done
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   902
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   903
lemma take_lemma_principle2:
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   904
  "!! Q. [|!! s. [| Forall Q s; A s |] ==> (f s) = (g s) ;
62001
1f2788fb0b8b more symbols;
wenzelm
parents: 62000
diff changeset
   905
           !! s1 s2 y. [| Forall Q s1; Finite s1; ~ Q y; A (s1 @@ y\<leadsto>s2)|]
1f2788fb0b8b more symbols;
wenzelm
parents: 62000
diff changeset
   906
                          ==> ! n. seq_take n$(f (s1 @@ y\<leadsto>s2))
1f2788fb0b8b more symbols;
wenzelm
parents: 62000
diff changeset
   907
                                 = seq_take n$(g (s1 @@ y\<leadsto>s2)) |]
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   908
               ==> A x --> (f x)=(g x)"
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   909
  apply (case_tac "Forall Q x")
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   910
  apply (auto dest!: divide_Seq3)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   911
  apply (rule seq.take_lemma)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   912
  apply auto
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   913
  done
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   914
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   915
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   916
(* Note: in the following proofs the ordering of proof steps is very
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   917
         important, as otherwise either (Forall Q s1) would be in the IH as
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   918
         assumption (then rule useless) or it is not possible to strengthen
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   919
         the IH apply doing a forall closure of the sequence t (then rule also useless).
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   920
         This is also the reason why the induction rule (nat_less_induct or nat_induct) has to
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   921
         to be imbuilt into the rule, as induction has to be done early and the take lemma
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   922
         has to be used in the trivial direction afterwards for the (Forall Q x) case.  *)
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   923
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   924
lemma take_lemma_induct:
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   925
"!! Q. [|!! s. [| Forall Q s; A s |] ==> (f s) = (g s) ;
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   926
         !! s1 s2 y n. [| ! t. A t --> seq_take n$(f t) = seq_take n$(g t);
62001
1f2788fb0b8b more symbols;
wenzelm
parents: 62000
diff changeset
   927
                          Forall Q s1; Finite s1; ~ Q y; A (s1 @@ y\<leadsto>s2) |]
1f2788fb0b8b more symbols;
wenzelm
parents: 62000
diff changeset
   928
                          ==>   seq_take (Suc n)$(f (s1 @@ y\<leadsto>s2))
1f2788fb0b8b more symbols;
wenzelm
parents: 62000
diff changeset
   929
                              = seq_take (Suc n)$(g (s1 @@ y\<leadsto>s2)) |]
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   930
               ==> A x --> (f x)=(g x)"
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   931
  apply (rule impI)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   932
  apply (rule seq.take_lemma)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   933
  apply (rule mp)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   934
  prefer 2 apply assumption
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   935
  apply (rule_tac x="x" in spec)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   936
  apply (rule nat.induct)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   937
  apply simp
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   938
  apply (rule allI)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   939
  apply (case_tac "Forall Q xa")
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   940
  apply (force intro!: seq_take_lemma [THEN iffD2, THEN spec])
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   941
  apply (auto dest!: divide_Seq3)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   942
  done
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   943
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   944
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   945
lemma take_lemma_less_induct:
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   946
"!! Q. [|!! s. [| Forall Q s; A s |] ==> (f s) = (g s) ;
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   947
        !! s1 s2 y n. [| ! t m. m < n --> A t --> seq_take m$(f t) = seq_take m$(g t);
62001
1f2788fb0b8b more symbols;
wenzelm
parents: 62000
diff changeset
   948
                          Forall Q s1; Finite s1; ~ Q y; A (s1 @@ y\<leadsto>s2) |]
1f2788fb0b8b more symbols;
wenzelm
parents: 62000
diff changeset
   949
                          ==>   seq_take n$(f (s1 @@ y\<leadsto>s2))
1f2788fb0b8b more symbols;
wenzelm
parents: 62000
diff changeset
   950
                              = seq_take n$(g (s1 @@ y\<leadsto>s2)) |]
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   951
               ==> A x --> (f x)=(g x)"
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   952
  apply (rule impI)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   953
  apply (rule seq.take_lemma)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   954
  apply (rule mp)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   955
  prefer 2 apply assumption
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   956
  apply (rule_tac x="x" in spec)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   957
  apply (rule nat_less_induct)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   958
  apply (rule allI)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   959
  apply (case_tac "Forall Q xa")
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   960
  apply (force intro!: seq_take_lemma [THEN iffD2, THEN spec])
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   961
  apply (auto dest!: divide_Seq3)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   962
  done
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   963
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   964
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   965
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   966
lemma take_lemma_in_eq_out:
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   967
"!! Q. [| A UU  ==> (f UU) = (g UU) ;
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   968
          A nil ==> (f nil) = (g nil) ;
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   969
          !! s y n. [| ! t. A t --> seq_take n$(f t) = seq_take n$(g t);
62001
1f2788fb0b8b more symbols;
wenzelm
parents: 62000
diff changeset
   970
                     A (y\<leadsto>s) |]
1f2788fb0b8b more symbols;
wenzelm
parents: 62000
diff changeset
   971
                     ==>   seq_take (Suc n)$(f (y\<leadsto>s))
1f2788fb0b8b more symbols;
wenzelm
parents: 62000
diff changeset
   972
                         = seq_take (Suc n)$(g (y\<leadsto>s)) |]
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   973
               ==> A x --> (f x)=(g x)"
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   974
  apply (rule impI)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   975
  apply (rule seq.take_lemma)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   976
  apply (rule mp)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   977
  prefer 2 apply assumption
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   978
  apply (rule_tac x="x" in spec)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   979
  apply (rule nat.induct)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   980
  apply simp
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   981
  apply (rule allI)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   982
  apply (rule_tac x="xa" in Seq_cases)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   983
  apply simp_all
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
   984
  done
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   985
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   986
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   987
(* ------------------------------------------------------------------------------------ *)
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   988
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   989
subsection "alternative take_lemma proofs"
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   990
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   991
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   992
(* --------------------------------------------------------------- *)
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   993
(*              Alternative Proof of FilterPQ                      *)
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   994
(* --------------------------------------------------------------- *)
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   995
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   996
declare FilterPQ [simp del]
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   997
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   998
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
   999
(* In general: How to do this case without the same adm problems
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
  1000
   as for the entire proof ? *)
62000
8cba509ace9c more symbols;
wenzelm
parents: 61424
diff changeset
  1001
lemma Filter_lemma1: "Forall (%x. ~(P x & Q x)) s
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
  1002
          --> Filter P$(Filter Q$s) =
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
  1003
              Filter (%x. P x & Q x)$s"
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
  1004
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
  1005
  apply (rule_tac x="s" in Seq_induct)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
  1006
  apply (simp add: Forall_def sforall_def)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
  1007
  apply simp_all
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
  1008
  done
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
  1009
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
  1010
lemma Filter_lemma2: "Finite s ==>
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
  1011
          (Forall (%x. (~P x) | (~ Q x)) s
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
  1012
          --> Filter P$(Filter Q$s) = nil)"
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
  1013
  apply (erule Seq_Finite_ind, simp_all)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
  1014
  done
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
  1015
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
  1016
lemma Filter_lemma3: "Finite s ==>
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
  1017
          Forall (%x. (~P x) | (~ Q x)) s
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
  1018
          --> Filter (%x. P x & Q x)$s = nil"
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
  1019
  apply (erule Seq_Finite_ind, simp_all)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
  1020
  done
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
  1021
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
  1022
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
  1023
lemma FilterPQ_takelemma: "Filter P$(Filter Q$s) = Filter (%x. P x & Q x)$s"
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
  1024
  apply (rule_tac A1="%x. True" and
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
  1025
                   Q1="%x. ~(P x & Q x)" and x1="s" in
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
  1026
                   take_lemma_induct [THEN mp])
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
  1027
  (* better support for A = %x. True *)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
  1028
  apply (simp add: Filter_lemma1)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
  1029
  apply (simp add: Filter_lemma2 Filter_lemma3)
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
  1030
  apply simp
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
  1031
  done
19551
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
  1032
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
  1033
declare FilterPQ [simp]
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
  1034
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
  1035
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
  1036
(* --------------------------------------------------------------- *)
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
  1037
(*              Alternative Proof of MapConc                       *)
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
  1038
(* --------------------------------------------------------------- *)
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
  1039
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
  1040
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
  1041
4103954f3668 converted to isar theory; removed unsound adm_all axiom
huffman
parents: 17233
diff changeset
  1042
lemma MapConc_takelemma: "Map f$(x@@y) = (Map f$x) @@ (Map f$y)"
62005
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
  1043
  apply (rule_tac A1="%x. True" and x1="x" in
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
  1044
      take_lemma_in_eq_out [THEN mp])
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
  1045
  apply auto
68db98c2cd97 modernized defs;
wenzelm
parents: 62002
diff changeset
  1046
  done
3071
981258186b71 New meta theory for IOA based on HOLCF.
mueller
parents:
diff changeset
  1047
19741
f65265d71426 removed legacy ML scripts;
wenzelm
parents: 19551
diff changeset
  1048
62002
f1599e98c4d0 isabelle update_cartouches -c -t;
wenzelm
parents: 62001
diff changeset
  1049
ML \<open>
19741
f65265d71426 removed legacy ML scripts;
wenzelm
parents: 19551
diff changeset
  1050
27208
5fe899199f85 proper context for tactics derived from res_inst_tac;
wenzelm
parents: 27105
diff changeset
  1051
fun Seq_case_tac ctxt s i =
59780
23b67731f4f0 support 'for' fixes in rule_tac etc.;
wenzelm
parents: 59763
diff changeset
  1052
  Rule_Insts.res_inst_tac ctxt [((("x", 0), Position.none), s)] [] @{thm Seq_cases} i
51798
ad3a241def73 uniform Proof.context for hyp_subst_tac;
wenzelm
parents: 51717
diff changeset
  1053
  THEN hyp_subst_tac ctxt i THEN hyp_subst_tac ctxt (i+1) THEN hyp_subst_tac ctxt (i+2);
19741
f65265d71426 removed legacy ML scripts;
wenzelm
parents: 19551
diff changeset
  1054
62001
1f2788fb0b8b more symbols;
wenzelm
parents: 62000
diff changeset
  1055
(* on a\<leadsto>s only simp_tac, as full_simp_tac is uncomplete and often causes errors *)
27208
5fe899199f85 proper context for tactics derived from res_inst_tac;
wenzelm
parents: 27105
diff changeset
  1056
fun Seq_case_simp_tac ctxt s i =
51717
9e7d1c139569 simplifier uses proper Proof.context instead of historic type simpset;
wenzelm
parents: 48194
diff changeset
  1057
  Seq_case_tac ctxt s i
9e7d1c139569 simplifier uses proper Proof.context instead of historic type simpset;
wenzelm
parents: 48194
diff changeset
  1058
  THEN asm_simp_tac ctxt (i+2)
9e7d1c139569 simplifier uses proper Proof.context instead of historic type simpset;
wenzelm
parents: 48194
diff changeset
  1059
  THEN asm_full_simp_tac ctxt (i+1)
9e7d1c139569 simplifier uses proper Proof.context instead of historic type simpset;
wenzelm
parents: 48194
diff changeset
  1060
  THEN asm_full_simp_tac ctxt i;
19741
f65265d71426 removed legacy ML scripts;
wenzelm
parents: 19551
diff changeset
  1061
f65265d71426 removed legacy ML scripts;
wenzelm
parents: 19551
diff changeset
  1062
(* rws are definitions to be unfolded for admissibility check *)
27208
5fe899199f85 proper context for tactics derived from res_inst_tac;
wenzelm
parents: 27105
diff changeset
  1063
fun Seq_induct_tac ctxt s rws i =
59780
23b67731f4f0 support 'for' fixes in rule_tac etc.;
wenzelm
parents: 59763
diff changeset
  1064
  Rule_Insts.res_inst_tac ctxt [((("x", 0), Position.none), s)] [] @{thm Seq_induct} i
51717
9e7d1c139569 simplifier uses proper Proof.context instead of historic type simpset;
wenzelm
parents: 48194
diff changeset
  1065
  THEN (REPEAT_DETERM (CHANGED (asm_simp_tac ctxt (i+1))))
9e7d1c139569 simplifier uses proper Proof.context instead of historic type simpset;
wenzelm
parents: 48194
diff changeset
  1066
  THEN simp_tac (ctxt addsimps rws) i;
19741
f65265d71426 removed legacy ML scripts;
wenzelm
parents: 19551
diff changeset
  1067
27208
5fe899199f85 proper context for tactics derived from res_inst_tac;
wenzelm
parents: 27105
diff changeset
  1068
fun Seq_Finite_induct_tac ctxt i =
60754
02924903a6fd prefer tactics with explicit context;
wenzelm
parents: 59780
diff changeset
  1069
  eresolve_tac ctxt @{thms Seq_Finite_ind} i
51717
9e7d1c139569 simplifier uses proper Proof.context instead of historic type simpset;
wenzelm
parents: 48194
diff changeset
  1070
  THEN (REPEAT_DETERM (CHANGED (asm_simp_tac ctxt i)));
19741
f65265d71426 removed legacy ML scripts;
wenzelm
parents: 19551
diff changeset
  1071
27208
5fe899199f85 proper context for tactics derived from res_inst_tac;
wenzelm
parents: 27105
diff changeset
  1072
fun pair_tac ctxt s =
61424
c3658c18b7bc prod_case as canonical name for product type eliminator
haftmann
parents: 61032
diff changeset
  1073
  Rule_Insts.res_inst_tac ctxt [((("y", 0), Position.none), s)] [] @{thm prod.exhaust}
51798
ad3a241def73 uniform Proof.context for hyp_subst_tac;
wenzelm
parents: 51717
diff changeset
  1074
  THEN' hyp_subst_tac ctxt THEN' asm_full_simp_tac ctxt;
19741
f65265d71426 removed legacy ML scripts;
wenzelm
parents: 19551
diff changeset
  1075
f65265d71426 removed legacy ML scripts;
wenzelm
parents: 19551
diff changeset
  1076
(* induction on a sequence of pairs with pairsplitting and simplification *)
27208
5fe899199f85 proper context for tactics derived from res_inst_tac;
wenzelm
parents: 27105
diff changeset
  1077
fun pair_induct_tac ctxt s rws i =
59780
23b67731f4f0 support 'for' fixes in rule_tac etc.;
wenzelm
parents: 59763
diff changeset
  1078
  Rule_Insts.res_inst_tac ctxt [((("x", 0), Position.none), s)] [] @{thm Seq_induct} i
51717
9e7d1c139569 simplifier uses proper Proof.context instead of historic type simpset;
wenzelm
parents: 48194
diff changeset
  1079
  THEN pair_tac ctxt "a" (i+3)
9e7d1c139569 simplifier uses proper Proof.context instead of historic type simpset;
wenzelm
parents: 48194
diff changeset
  1080
  THEN (REPEAT_DETERM (CHANGED (simp_tac ctxt (i+1))))
9e7d1c139569 simplifier uses proper Proof.context instead of historic type simpset;
wenzelm
parents: 48194
diff changeset
  1081
  THEN simp_tac (ctxt addsimps rws) i;
62002
f1599e98c4d0 isabelle update_cartouches -c -t;
wenzelm
parents: 62001
diff changeset
  1082
\<close>
19741
f65265d71426 removed legacy ML scripts;
wenzelm
parents: 19551
diff changeset
  1083
f65265d71426 removed legacy ML scripts;
wenzelm
parents: 19551
diff changeset
  1084
end