thys3/src/ClosedForms.thy
author Christian Urban <christian.urban@kcl.ac.uk>
Sat, 09 Jul 2022 14:11:07 +0100
changeset 563 c92a41d9c4da
parent 496 f493a20feeb3
permissions -rw-r--r--
updated paper and theories to include n-times
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
495
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     1
theory ClosedForms 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     2
  imports "BasicIdentities"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     3
begin
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     4
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     5
lemma flts_middle0:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     6
  shows "rflts (rsa @ RZERO # rsb) = rflts (rsa @ rsb)"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     7
  apply(induct rsa)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     8
  apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     9
  by (metis append_Cons rflts.simps(2) rflts.simps(3) rflts_def_idiot)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    10
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    11
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    12
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    13
lemma simp_flatten_aux0:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    14
  shows "rsimp (RALTS rs) = rsimp (RALTS (map rsimp rs))"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    15
  by (metis append_Nil head_one_more_simp identity_wwo0 list.simps(8) rdistinct.simps(1) rflts.simps(1) rsimp.simps(2) rsimp_ALTs.simps(1) rsimp_ALTs.simps(3) simp_flatten spawn_simp_rsimpalts)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    16
  
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    17
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    18
inductive 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    19
  hrewrite:: "rrexp \<Rightarrow> rrexp \<Rightarrow> bool" ("_ h\<leadsto> _" [99, 99] 99)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    20
where
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    21
  "RSEQ  RZERO r2 h\<leadsto> RZERO"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    22
| "RSEQ  r1 RZERO h\<leadsto> RZERO"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    23
| "RSEQ  RONE r h\<leadsto>  r"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    24
| "r1 h\<leadsto> r2 \<Longrightarrow> RSEQ  r1 r3 h\<leadsto> RSEQ r2 r3"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    25
| "r3 h\<leadsto> r4 \<Longrightarrow> RSEQ r1 r3 h\<leadsto> RSEQ r1 r4"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    26
| "r h\<leadsto> r' \<Longrightarrow> (RALTS (rs1 @ [r] @ rs2)) h\<leadsto> (RALTS  (rs1 @ [r'] @ rs2))"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    27
(*context rule for eliminating 0, alts--corresponds to the recursive call flts r::rs = r::(flts rs)*)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    28
| "RALTS  (rsa @ [RZERO] @ rsb) h\<leadsto> RALTS  (rsa @ rsb)"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    29
| "RALTS  (rsa @ [RALTS rs1] @ rsb) h\<leadsto> RALTS (rsa @ rs1 @ rsb)"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    30
| "RALTS  [] h\<leadsto> RZERO"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    31
| "RALTS  [r] h\<leadsto> r"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    32
| "a1 = a2 \<Longrightarrow> RALTS (rsa@[a1]@rsb@[a2]@rsc) h\<leadsto> RALTS (rsa @ [a1] @ rsb @ rsc)"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    33
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    34
inductive 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    35
  hrewrites:: "rrexp \<Rightarrow> rrexp \<Rightarrow> bool" ("_ h\<leadsto>* _" [100, 100] 100)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    36
where 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    37
  rs1[intro, simp]:"r h\<leadsto>* r"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    38
| rs2[intro]: "\<lbrakk>r1 h\<leadsto>* r2; r2 h\<leadsto> r3\<rbrakk> \<Longrightarrow> r1 h\<leadsto>* r3"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    39
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    40
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    41
lemma hr_in_rstar : "r1 h\<leadsto> r2 \<Longrightarrow> r1 h\<leadsto>* r2"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    42
  using hrewrites.intros(1) hrewrites.intros(2) by blast
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    43
 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    44
lemma hreal_trans[trans]: 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    45
  assumes a1: "r1 h\<leadsto>* r2"  and a2: "r2 h\<leadsto>* r3"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    46
  shows "r1 h\<leadsto>* r3"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    47
  using a2 a1
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    48
  apply(induct r2 r3 arbitrary: r1 rule: hrewrites.induct) 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    49
  apply(auto)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    50
  done
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    51
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    52
lemma hrewrites_seq_context:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    53
  shows "r1 h\<leadsto>* r2 \<Longrightarrow> RSEQ r1 r3 h\<leadsto>* RSEQ r2 r3"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    54
  apply(induct r1 r2 rule: hrewrites.induct)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    55
   apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    56
  using hrewrite.intros(4) by blast
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    57
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    58
lemma hrewrites_seq_context2:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    59
  shows "r1 h\<leadsto>* r2 \<Longrightarrow> RSEQ r0 r1 h\<leadsto>* RSEQ r0 r2"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    60
  apply(induct r1 r2 rule: hrewrites.induct)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    61
   apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    62
  using hrewrite.intros(5) by blast
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    63
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    64
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    65
lemma hrewrites_seq_contexts:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    66
  shows "\<lbrakk>r1 h\<leadsto>* r2; r3 h\<leadsto>* r4\<rbrakk> \<Longrightarrow> RSEQ r1 r3 h\<leadsto>* RSEQ r2 r4"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    67
  by (meson hreal_trans hrewrites_seq_context hrewrites_seq_context2)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    68
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    69
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    70
lemma simp_removes_duplicate1:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    71
  shows  " a \<in> set rsa \<Longrightarrow> rsimp (RALTS (rsa @ [a])) =  rsimp (RALTS (rsa))"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    72
and " rsimp (RALTS (a1 # rsa @ [a1])) = rsimp (RALTS (a1 # rsa))"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    73
  apply(induct rsa arbitrary: a1)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    74
     apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    75
    apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    76
  prefer 2
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    77
  apply(case_tac "a = aa")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    78
     apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    79
    apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    80
  apply (metis Cons_eq_appendI Cons_eq_map_conv distinct_removes_duplicate_flts list.set_intros(2))
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    81
  apply (metis append_Cons append_Nil distinct_removes_duplicate_flts list.set_intros(1) list.simps(8) list.simps(9))
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    82
  by (metis (mono_tags, lifting) append_Cons distinct_removes_duplicate_flts list.set_intros(1) list.simps(8) list.simps(9) map_append rsimp.simps(2))
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    83
  
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    84
lemma simp_removes_duplicate2:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    85
  shows "a \<in> set rsa \<Longrightarrow> rsimp (RALTS (rsa @ [a] @ rsb)) = rsimp (RALTS (rsa @ rsb))"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    86
  apply(induct rsb arbitrary: rsa)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    87
   apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    88
  using distinct_removes_duplicate_flts apply auto[1]
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    89
  by (metis append.assoc head_one_more_simp rsimp.simps(2) simp_flatten simp_removes_duplicate1(1))
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    90
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    91
lemma simp_removes_duplicate3:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    92
  shows "a \<in> set rsa \<Longrightarrow> rsimp (RALTS (rsa @ a # rsb)) = rsimp (RALTS (rsa @ rsb))"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    93
  using simp_removes_duplicate2 by auto
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    94
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    95
(*
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    96
lemma distinct_removes_middle4:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    97
  shows "a \<in> set rsa \<Longrightarrow> rdistinct (rsa @ [a] @ rsb) rset = rdistinct (rsa @ rsb) rset"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    98
  using distinct_removes_middle(1) by fastforce
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    99
*)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   100
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   101
(*
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   102
lemma distinct_removes_middle_list:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   103
  shows "\<forall>a \<in> set x. a \<in> set rsa \<Longrightarrow> rdistinct (rsa @ x @ rsb) rset = rdistinct (rsa @ rsb) rset"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   104
  apply(induct x)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   105
   apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   106
  by (simp add: distinct_removes_middle3)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   107
*)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   108
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   109
inductive frewrite:: "rrexp list \<Rightarrow> rrexp list \<Rightarrow> bool" ("_ \<leadsto>f _" [10, 10] 10)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   110
  where
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   111
  "(RZERO # rs) \<leadsto>f rs"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   112
| "((RALTS rs) # rsa) \<leadsto>f (rs @ rsa)"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   113
| "rs1 \<leadsto>f rs2 \<Longrightarrow> (r # rs1) \<leadsto>f (r # rs2)"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   114
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   115
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   116
inductive 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   117
  frewrites:: "rrexp list \<Rightarrow> rrexp list \<Rightarrow> bool" ("_ \<leadsto>f* _" [10, 10] 10)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   118
where 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   119
  [intro, simp]:"rs \<leadsto>f* rs"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   120
| [intro]: "\<lbrakk>rs1 \<leadsto>f* rs2; rs2 \<leadsto>f rs3\<rbrakk> \<Longrightarrow> rs1 \<leadsto>f* rs3"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   121
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   122
inductive grewrite:: "rrexp list \<Rightarrow> rrexp list \<Rightarrow> bool" ("_ \<leadsto>g _" [10, 10] 10)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   123
  where
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   124
  "(RZERO # rs) \<leadsto>g rs"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   125
| "((RALTS rs) # rsa) \<leadsto>g (rs @ rsa)"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   126
| "rs1 \<leadsto>g rs2 \<Longrightarrow> (r # rs1) \<leadsto>g (r # rs2)"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   127
| "rsa @ [a] @ rsb @ [a] @ rsc \<leadsto>g rsa @ [a] @ rsb @ rsc" 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   128
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   129
lemma grewrite_variant1:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   130
  shows "a \<in> set rs1 \<Longrightarrow> rs1 @ a # rs \<leadsto>g rs1 @ rs"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   131
  apply (metis append.assoc append_Cons append_Nil grewrite.intros(4) split_list_first)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   132
  done
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   133
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   134
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   135
inductive 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   136
  grewrites:: "rrexp list \<Rightarrow> rrexp list \<Rightarrow> bool" ("_ \<leadsto>g* _" [10, 10] 10)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   137
where 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   138
  [intro, simp]:"rs \<leadsto>g* rs"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   139
| [intro]: "\<lbrakk>rs1 \<leadsto>g* rs2; rs2 \<leadsto>g rs3\<rbrakk> \<Longrightarrow> rs1 \<leadsto>g* rs3"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   140
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   141
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   142
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   143
(*
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   144
inductive 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   145
  frewrites2:: "rrexp list \<Rightarrow> rrexp list \<Rightarrow> bool" ("_ <\<leadsto>f* _" [10, 10] 10)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   146
where 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   147
 [intro]: "\<lbrakk>rs1 \<leadsto>f* rs2; rs2 \<leadsto>f* rs1\<rbrakk> \<Longrightarrow> rs1 <\<leadsto>f* rs2"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   148
*)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   149
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   150
lemma fr_in_rstar : "r1 \<leadsto>f r2 \<Longrightarrow> r1 \<leadsto>f* r2"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   151
  using frewrites.intros(1) frewrites.intros(2) by blast
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   152
 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   153
lemma freal_trans[trans]: 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   154
  assumes a1: "r1 \<leadsto>f* r2"  and a2: "r2 \<leadsto>f* r3"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   155
  shows "r1 \<leadsto>f* r3"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   156
  using a2 a1
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   157
  apply(induct r2 r3 arbitrary: r1 rule: frewrites.induct) 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   158
  apply(auto)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   159
  done
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   160
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   161
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   162
lemma  many_steps_later: "\<lbrakk>r1 \<leadsto>f r2; r2 \<leadsto>f* r3 \<rbrakk> \<Longrightarrow> r1 \<leadsto>f* r3"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   163
  by (meson fr_in_rstar freal_trans)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   164
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   165
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   166
lemma gr_in_rstar : "r1 \<leadsto>g r2 \<Longrightarrow> r1 \<leadsto>g* r2"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   167
  using grewrites.intros(1) grewrites.intros(2) by blast
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   168
 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   169
lemma greal_trans[trans]: 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   170
  assumes a1: "r1 \<leadsto>g* r2"  and a2: "r2 \<leadsto>g* r3"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   171
  shows "r1 \<leadsto>g* r3"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   172
  using a2 a1
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   173
  apply(induct r2 r3 arbitrary: r1 rule: grewrites.induct) 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   174
  apply(auto)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   175
  done
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   176
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   177
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   178
lemma  gmany_steps_later: "\<lbrakk>r1 \<leadsto>g r2; r2 \<leadsto>g* r3 \<rbrakk> \<Longrightarrow> r1 \<leadsto>g* r3"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   179
  by (meson gr_in_rstar greal_trans)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   180
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   181
lemma gstar_rdistinct_general:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   182
  shows "rs1 @  rs \<leadsto>g* rs1 @ (rdistinct rs (set rs1))"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   183
  apply(induct rs arbitrary: rs1)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   184
   apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   185
  apply(case_tac " a \<in> set rs1")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   186
   apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   187
  apply(subgoal_tac "rs1 @ a # rs \<leadsto>g rs1 @ rs")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   188
  using gmany_steps_later apply auto[1]
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   189
  apply (metis append.assoc append_Cons append_Nil grewrite.intros(4) split_list_first)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   190
  apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   191
  apply(drule_tac x = "rs1 @ [a]" in meta_spec)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   192
  by simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   193
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   194
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   195
lemma gstar_rdistinct:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   196
  shows "rs \<leadsto>g* rdistinct rs {}"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   197
  apply(induct rs)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   198
   apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   199
  by (metis append.left_neutral empty_set gstar_rdistinct_general)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   200
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   201
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   202
lemma grewrite_append:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   203
  shows "\<lbrakk> rsa \<leadsto>g rsb \<rbrakk> \<Longrightarrow> rs @ rsa \<leadsto>g rs @ rsb"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   204
  apply(induct rs)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   205
   apply simp+
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   206
  using grewrite.intros(3) by blast
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   207
  
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   208
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   209
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   210
lemma frewrites_cons:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   211
  shows "\<lbrakk> rsa \<leadsto>f* rsb \<rbrakk> \<Longrightarrow> r # rsa \<leadsto>f* r # rsb"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   212
  apply(induct rsa rsb rule: frewrites.induct)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   213
   apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   214
  using frewrite.intros(3) by blast
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   215
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   216
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   217
lemma grewrites_cons:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   218
  shows "\<lbrakk> rsa \<leadsto>g* rsb \<rbrakk> \<Longrightarrow> r # rsa \<leadsto>g* r # rsb"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   219
  apply(induct rsa rsb rule: grewrites.induct)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   220
   apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   221
  using grewrite.intros(3) by blast
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   222
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   223
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   224
lemma frewrites_append:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   225
  shows " \<lbrakk>rsa \<leadsto>f* rsb\<rbrakk> \<Longrightarrow> (rs @ rsa) \<leadsto>f* (rs @ rsb)"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   226
  apply(induct rs)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   227
   apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   228
  by (simp add: frewrites_cons)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   229
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   230
lemma grewrites_append:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   231
  shows " \<lbrakk>rsa \<leadsto>g* rsb\<rbrakk> \<Longrightarrow> (rs @ rsa) \<leadsto>g* (rs @ rsb)"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   232
  apply(induct rs)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   233
   apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   234
  by (simp add: grewrites_cons)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   235
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   236
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   237
lemma grewrites_concat:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   238
  shows "\<lbrakk>rs1 \<leadsto>g rs2; rsa \<leadsto>g* rsb \<rbrakk> \<Longrightarrow> (rs1 @ rsa) \<leadsto>g* (rs2 @ rsb)"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   239
  apply(induct rs1 rs2 rule: grewrite.induct)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   240
    apply(simp)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   241
  apply(subgoal_tac "(RZERO # rs @ rsa) \<leadsto>g (rs @ rsa)")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   242
  prefer 2
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   243
  using grewrite.intros(1) apply blast
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   244
    apply(subgoal_tac "(rs @ rsa) \<leadsto>g* (rs @ rsb)")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   245
  using gmany_steps_later apply blast
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   246
  apply (simp add: grewrites_append)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   247
  apply (metis append.assoc append_Cons grewrite.intros(2) grewrites_append gmany_steps_later)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   248
  using grewrites_cons apply auto
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   249
  apply(subgoal_tac "rsaa @ a # rsba @ a # rsc @ rsa \<leadsto>g* rsaa @ a # rsba @ a # rsc @ rsb")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   250
  using grewrite.intros(4) grewrites.intros(2) apply force
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   251
  using grewrites_append by auto
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   252
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   253
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   254
lemma grewritess_concat:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   255
  shows "\<lbrakk>rsa \<leadsto>g* rsb; rsc \<leadsto>g* rsd \<rbrakk> \<Longrightarrow> (rsa @ rsc) \<leadsto>g* (rsb @ rsd)"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   256
  apply(induct rsa rsb rule: grewrites.induct)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   257
   apply(case_tac rs)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   258
    apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   259
  using grewrites_append apply blast   
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   260
  by (meson greal_trans grewrites.simps grewrites_concat)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   261
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   262
fun alt_set:: "rrexp \<Rightarrow> rrexp set"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   263
  where
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   264
  "alt_set (RALTS rs) = set rs \<union> \<Union> (alt_set ` (set rs))"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   265
| "alt_set r = {r}"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   266
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   267
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   268
lemma grewrite_cases_middle:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   269
  shows "rs1 \<leadsto>g rs2 \<Longrightarrow> 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   270
(\<exists>rsa rsb rsc. rs1 =  (rsa @ [RALTS rsb] @ rsc) \<and> rs2 = (rsa @ rsb @ rsc)) \<or>
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   271
(\<exists>rsa rsc. rs1 = rsa @ [RZERO] @ rsc \<and> rs2 = rsa @ rsc) \<or>
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   272
(\<exists>rsa rsb rsc a. rs1 = rsa @ [a] @ rsb @ [a] @ rsc \<and> rs2 = rsa @ [a] @ rsb @ rsc)"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   273
  apply( induct rs1 rs2 rule: grewrite.induct)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   274
     apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   275
  apply blast
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   276
  apply (metis append_Cons append_Nil)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   277
  apply (metis append_Cons)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   278
  by blast
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   279
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   280
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   281
lemma good_singleton:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   282
  shows "good a \<and> nonalt a  \<Longrightarrow> rflts [a] = [a]"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   283
  using good.simps(1) k0b by blast
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   284
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   285
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   286
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   287
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   288
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   289
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   290
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   291
lemma all_that_same_elem:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   292
  shows "\<lbrakk> a \<in> rset; rdistinct rs {a} = []\<rbrakk>
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   293
       \<Longrightarrow> rdistinct (rs @ rsb) rset = rdistinct rsb rset"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   294
  apply(induct rs)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   295
   apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   296
  apply(subgoal_tac "aa = a")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   297
   apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   298
  by (metis empty_iff insert_iff list.discI rdistinct.simps(2))
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   299
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   300
lemma distinct_early_app1:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   301
  shows "rset1 \<subseteq> rset \<Longrightarrow> rdistinct rs rset = rdistinct (rdistinct rs rset1) rset"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   302
  apply(induct rs arbitrary: rset rset1)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   303
   apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   304
  apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   305
  apply(case_tac "a \<in> rset1")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   306
   apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   307
   apply(case_tac "a \<in> rset")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   308
    apply simp+
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   309
  
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   310
   apply blast
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   311
  apply(case_tac "a \<in> rset1")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   312
   apply simp+
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   313
  apply(case_tac "a \<in> rset")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   314
   apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   315
   apply (metis insert_subsetI)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   316
  apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   317
  by (meson insert_mono)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   318
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   319
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   320
lemma distinct_early_app:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   321
  shows " rdistinct (rs @ rsb) rset = rdistinct (rdistinct rs {} @ rsb) rset"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   322
  apply(induct rsb)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   323
   apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   324
  using distinct_early_app1 apply blast
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   325
  by (metis distinct_early_app1 distinct_once_enough empty_subsetI)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   326
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   327
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   328
lemma distinct_eq_interesting1:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   329
  shows "a \<in> rset \<Longrightarrow> rdistinct (rs @ rsb) rset = rdistinct (rdistinct (a # rs) {} @ rsb) rset"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   330
  apply(subgoal_tac "rdistinct (rdistinct (a # rs) {} @ rsb) rset = rdistinct (rdistinct rs {} @ rsb) rset")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   331
   apply(simp only:)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   332
  using distinct_early_app apply blast 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   333
  by (metis append_Cons distinct_early_app rdistinct.simps(2))
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   334
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   335
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   336
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   337
lemma good_flatten_aux_aux1:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   338
  shows "\<lbrakk> size rs \<ge>2; 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   339
\<forall>r \<in> set rs. good r \<and> r \<noteq> RZERO \<and> nonalt r; \<forall>r \<in> set rsb. good r \<and> r \<noteq> RZERO \<and> nonalt r \<rbrakk>
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   340
       \<Longrightarrow> rdistinct (rs @ rsb) rset =
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   341
           rdistinct (rflts [rsimp_ALTs (rdistinct rs {})] @ rsb) rset"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   342
  apply(induct rs arbitrary: rset)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   343
   apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   344
  apply(case_tac "a \<in> rset")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   345
   apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   346
   apply(case_tac "rdistinct rs {a}")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   347
    apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   348
    apply(subst good_singleton)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   349
     apply force
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   350
  apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   351
    apply (meson all_that_same_elem)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   352
   apply(subgoal_tac "rflts [rsimp_ALTs (a # rdistinct rs {a})] = a # rdistinct rs {a} ")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   353
  prefer 2
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   354
  using k0a rsimp_ALTs.simps(3) apply presburger
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   355
  apply(simp only:)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   356
  apply(subgoal_tac "rdistinct (rs @ rsb) rset = rdistinct ((rdistinct (a # rs) {}) @ rsb) rset ")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   357
    apply (metis insert_absorb insert_is_Un insert_not_empty rdistinct.simps(2))
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   358
   apply (meson distinct_eq_interesting1)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   359
  apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   360
  apply(case_tac "rdistinct rs {a}")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   361
  prefer 2
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   362
   apply(subgoal_tac "rsimp_ALTs (a # rdistinct rs {a}) = RALTS (a # rdistinct rs {a})")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   363
  apply(simp only:)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   364
  apply(subgoal_tac "a # rdistinct (rs @ rsb) (insert a rset) =
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   365
           rdistinct (rflts [RALTS (a # rdistinct rs {a})] @ rsb) rset")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   366
   apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   367
  apply (metis append_Cons distinct_early_app empty_iff insert_is_Un k0a rdistinct.simps(2))
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   368
  using rsimp_ALTs.simps(3) apply presburger
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   369
  by (metis Un_insert_left append_Cons distinct_early_app empty_iff good_singleton rdistinct.simps(2) rsimp_ALTs.simps(2) sup_bot_left)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   370
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   371
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   372
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   373
  
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   374
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   375
lemma good_flatten_aux_aux:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   376
  shows "\<lbrakk>\<exists>a aa lista list. rs = a # list \<and> list = aa # lista; 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   377
\<forall>r \<in> set rs. good r \<and> r \<noteq> RZERO \<and> nonalt r; \<forall>r \<in> set rsb. good r \<and> r \<noteq> RZERO \<and> nonalt r \<rbrakk>
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   378
       \<Longrightarrow> rdistinct (rs @ rsb) rset =
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   379
           rdistinct (rflts [rsimp_ALTs (rdistinct rs {})] @ rsb) rset"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   380
  apply(erule exE)+
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   381
  apply(subgoal_tac "size rs \<ge> 2")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   382
   apply (metis good_flatten_aux_aux1)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   383
  by (simp add: Suc_leI length_Cons less_add_Suc1)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   384
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   385
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   386
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   387
lemma good_flatten_aux:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   388
  shows " \<lbrakk>\<forall>r\<in>set rs. good r \<or> r = RZERO; \<forall>r\<in>set rsa . good r \<or> r = RZERO; 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   389
           \<forall>r\<in>set rsb. good r \<or> r = RZERO;
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   390
     rsimp (RALTS (rsa @ rs @ rsb)) = rsimp_ALTs (rdistinct (rflts (rsa @ rs @ rsb)) {});
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   391
     rsimp (RALTS (rsa @ [RALTS rs] @ rsb)) =
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   392
     rsimp_ALTs (rdistinct (rflts (rsa @ [rsimp (RALTS rs)] @ rsb)) {});
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   393
     map rsimp rsa = rsa; map rsimp rsb = rsb; map rsimp rs = rs;
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   394
     rdistinct (rflts rsa @ rflts rs @ rflts rsb) {} =
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   395
     rdistinct (rflts rsa) {} @ rdistinct (rflts rs @ rflts rsb) (set (rflts rsa));
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   396
     rdistinct (rflts rsa @ rflts [rsimp (RALTS rs)] @ rflts rsb) {} =
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   397
     rdistinct (rflts rsa) {} @ rdistinct (rflts [rsimp (RALTS rs)] @ rflts rsb) (set (rflts rsa))\<rbrakk>
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   398
    \<Longrightarrow>    rdistinct (rflts rs @ rflts rsb) rset =
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   399
           rdistinct (rflts [rsimp (RALTS rs)] @ rflts rsb) rset"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   400
  apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   401
  apply(case_tac "rflts rs ")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   402
   apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   403
  apply(case_tac "list")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   404
   apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   405
   apply(case_tac "a \<in> rset")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   406
    apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   407
  apply (metis append.left_neutral append_Cons equals0D k0b list.set_intros(1) nonalt_flts_rd qqq1 rdistinct.simps(2))
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   408
   apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   409
  apply (metis Un_insert_left append_Cons append_Nil ex_in_conv flts_single1 insertI1 list.simps(15) nonalt_flts_rd nonazero.elims(3) qqq1 rdistinct.simps(2) sup_bot_left)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   410
  apply(subgoal_tac "\<forall>r \<in> set (rflts rs). good r \<and> r \<noteq> RZERO \<and> nonalt r")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   411
   prefer 2
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   412
  apply (metis Diff_empty flts3 nonalt_flts_rd qqq1 rdistinct_set_equality1)  
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   413
  apply(subgoal_tac "\<forall>r \<in> set (rflts rsb). good r \<and> r \<noteq> RZERO \<and> nonalt r")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   414
   prefer 2
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   415
  apply (metis Diff_empty flts3 good.simps(1) nonalt_flts_rd rdistinct_set_equality1)  
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   416
  by (smt (verit, ccfv_threshold) good_flatten_aux_aux)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   417
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   418
  
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   419
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   420
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   421
lemma good_flatten_middle:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   422
  shows "\<lbrakk>\<forall>r \<in> set rs. good r \<or> r = RZERO; \<forall>r \<in> set rsa. good r \<or> r = RZERO; \<forall>r \<in> set rsb. good r \<or> r = RZERO\<rbrakk> \<Longrightarrow>
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   423
rsimp (RALTS (rsa @ rs @ rsb)) = rsimp (RALTS (rsa @ [RALTS rs] @ rsb))"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   424
  apply(subgoal_tac "rsimp (RALTS (rsa @ rs @ rsb)) = rsimp_ALTs (rdistinct (rflts (map rsimp rsa @ 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   425
map rsimp rs @ map rsimp rsb)) {})")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   426
  prefer 2
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   427
  apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   428
  apply(simp only:)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   429
    apply(subgoal_tac "rsimp (RALTS (rsa @ [RALTS rs] @ rsb)) = rsimp_ALTs (rdistinct (rflts (map rsimp rsa @ 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   430
[rsimp (RALTS rs)] @ map rsimp rsb)) {})")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   431
  prefer 2
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   432
   apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   433
  apply(simp only:)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   434
  apply(subgoal_tac "map rsimp rsa = rsa")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   435
  prefer 2
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   436
  apply (metis map_idI rsimp.simps(3) test)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   437
  apply(simp only:)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   438
  apply(subgoal_tac "map rsimp rsb = rsb")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   439
   prefer 2
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   440
  apply (metis map_idI rsimp.simps(3) test)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   441
  apply(simp only:)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   442
  apply(subst k00)+
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   443
  apply(subgoal_tac "map rsimp rs = rs")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   444
   apply(simp only:)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   445
   prefer 2
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   446
  apply (metis map_idI rsimp.simps(3) test)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   447
  apply(subgoal_tac "rdistinct (rflts rsa @ rflts rs @ rflts rsb) {} = 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   448
rdistinct (rflts rsa) {} @ rdistinct  (rflts rs @ rflts rsb) (set (rflts rsa))")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   449
   apply(simp only:)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   450
  prefer 2
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   451
  using rdistinct_concat_general apply blast
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   452
  apply(subgoal_tac "rdistinct (rflts rsa @ rflts [rsimp (RALTS rs)] @ rflts rsb) {} = 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   453
rdistinct (rflts rsa) {} @ rdistinct  (rflts [rsimp (RALTS rs)] @ rflts rsb) (set (rflts rsa))")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   454
   apply(simp only:)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   455
  prefer 2
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   456
  using rdistinct_concat_general apply blast
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   457
  apply(subgoal_tac "rdistinct (rflts rs @ rflts rsb) (set (rflts rsa)) = 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   458
                     rdistinct  (rflts [rsimp (RALTS rs)] @ rflts rsb) (set (rflts rsa))")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   459
   apply presburger
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   460
  using good_flatten_aux by blast
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   461
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   462
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   463
lemma simp_flatten3:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   464
  shows "rsimp (RALTS (rsa @ [RALTS rs] @ rsb)) = rsimp (RALTS (rsa @ rs @ rsb))"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   465
  apply(subgoal_tac "rsimp (RALTS (rsa @ [RALTS rs] @ rsb)) = 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   466
                     rsimp (RALTS (map rsimp rsa @ [rsimp (RALTS rs)] @ map rsimp rsb)) ")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   467
  prefer 2
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   468
   apply (metis append.left_neutral append_Cons list.simps(9) map_append simp_flatten_aux0)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   469
  apply (simp only:)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   470
  apply(subgoal_tac "rsimp (RALTS (rsa @ rs @ rsb)) = 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   471
rsimp (RALTS (map rsimp rsa @ map rsimp rs @ map rsimp rsb))")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   472
  prefer 2
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   473
   apply (metis map_append simp_flatten_aux0)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   474
  apply(simp only:)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   475
  apply(subgoal_tac "rsimp  (RALTS (map rsimp rsa @ map rsimp rs @ map rsimp rsb)) =
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   476
 rsimp (RALTS (map rsimp rsa @ [RALTS (map rsimp rs)] @ map rsimp rsb))")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   477
  
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   478
   apply (metis (no_types, lifting) head_one_more_simp map_append simp_flatten_aux0)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   479
  apply(subgoal_tac "\<forall>r \<in> set (map rsimp rsa). good r \<or> r = RZERO")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   480
   apply(subgoal_tac "\<forall>r \<in> set (map rsimp rs). good r \<or> r = RZERO")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   481
    apply(subgoal_tac "\<forall>r \<in> set (map rsimp rsb). good r \<or> r = RZERO")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   482
  
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   483
  using good_flatten_middle apply presburger
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   484
  
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   485
  apply (simp add: good1)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   486
  apply (simp add: good1)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   487
  apply (simp add: good1)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   488
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   489
  done
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   490
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   491
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   492
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   493
  
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   494
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   495
lemma grewrite_equal_rsimp:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   496
  shows "rs1 \<leadsto>g rs2 \<Longrightarrow> rsimp (RALTS rs1) = rsimp (RALTS rs2)"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   497
  apply(frule grewrite_cases_middle)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   498
  apply(case_tac "(\<exists>rsa rsb rsc. rs1 = rsa @ [RALTS rsb] @ rsc \<and> rs2 = rsa @ rsb @ rsc)")  
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   499
  using simp_flatten3 apply auto[1]
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   500
  apply(case_tac "(\<exists>rsa rsc. rs1 = rsa @ [RZERO] @ rsc \<and> rs2 = rsa @ rsc)")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   501
  apply (metis (mono_tags, opaque_lifting) append_Cons append_Nil list.set_intros(1) list.simps(9) rflts.simps(2) rsimp.simps(2) rsimp.simps(3) simp_removes_duplicate3)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   502
  by (smt (verit) append.assoc append_Cons append_Nil in_set_conv_decomp simp_removes_duplicate3)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   503
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   504
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   505
lemma grewrites_equal_rsimp:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   506
  shows "rs1 \<leadsto>g* rs2 \<Longrightarrow> rsimp (RALTS rs1) = rsimp (RALTS rs2)"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   507
  apply (induct rs1 rs2 rule: grewrites.induct)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   508
  apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   509
  using grewrite_equal_rsimp by presburger
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   510
  
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   511
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   512
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   513
lemma grewrites_last:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   514
  shows "r # [RALTS rs] \<leadsto>g*  r # rs"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   515
  by (metis gr_in_rstar grewrite.intros(2) grewrite.intros(3) self_append_conv)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   516
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   517
lemma simp_flatten2:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   518
  shows "rsimp (RALTS (r # [RALTS rs])) = rsimp (RALTS (r # rs))"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   519
  using grewrites_equal_rsimp grewrites_last by blast
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   520
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   521
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   522
lemma frewrites_alt:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   523
  shows "rs1 \<leadsto>f* rs2 \<Longrightarrow> (RALT r1 r2) # rs1 \<leadsto>f* r1 # r2 # rs2"  
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   524
  by (metis Cons_eq_appendI append_self_conv2 frewrite.intros(2) frewrites_cons many_steps_later)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   525
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   526
lemma early_late_der_frewrites:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   527
  shows "map (rder x) (rflts rs) \<leadsto>f* rflts (map (rder x) rs)"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   528
  apply(induct rs)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   529
   apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   530
  apply(case_tac a)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   531
       apply simp+
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   532
  using frewrite.intros(1) many_steps_later apply blast
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   533
     apply(case_tac "x = x3")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   534
      apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   535
  using frewrites_cons apply presburger
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   536
  using frewrite.intros(1) many_steps_later apply fastforce
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   537
  apply(case_tac "rnullable x41")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   538
     apply simp+
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   539
     apply (simp add: frewrites_alt)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   540
  apply (simp add: frewrites_cons)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   541
   apply (simp add: frewrites_append)
563
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
   542
  apply (simp add: frewrites_cons)
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
   543
  apply (auto simp add: frewrites_cons)
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
   544
  using frewrite.intros(1) many_steps_later by blast
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
   545
  
495
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   546
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   547
lemma gstar0:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   548
  shows "rsa @ (rdistinct rs (set rsa)) \<leadsto>g* rsa @ (rdistinct rs (insert RZERO (set rsa)))"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   549
  apply(induct rs arbitrary: rsa)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   550
   apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   551
  apply(case_tac "a = RZERO")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   552
   apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   553
  
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   554
  using gr_in_rstar grewrite.intros(1) grewrites_append apply presburger
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   555
  apply(case_tac "a \<in> set rsa")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   556
   apply simp+
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   557
  apply(drule_tac x = "rsa @ [a]" in meta_spec)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   558
  by simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   559
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   560
lemma grewrite_rdistinct_aux:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   561
  shows "rs @ rdistinct rsa rset \<leadsto>g* rs @ rdistinct rsa (rset \<union> set rs)"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   562
  apply(induct rsa arbitrary: rs rset)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   563
   apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   564
  apply(case_tac " a \<in> rset")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   565
   apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   566
  apply(case_tac "a \<in> set rs")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   567
  apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   568
   apply (metis Un_insert_left Un_insert_right gmany_steps_later grewrite_variant1 insert_absorb)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   569
  apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   570
  apply(drule_tac x = "rs @ [a]" in meta_spec)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   571
  by (metis Un_insert_left Un_insert_right append.assoc append.right_neutral append_Cons append_Nil insert_absorb2 list.simps(15) set_append)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   572
  
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   573
 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   574
lemma flts_gstar:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   575
  shows "rs \<leadsto>g* rflts rs"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   576
  apply(induct rs)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   577
   apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   578
  apply(case_tac "a = RZERO")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   579
   apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   580
  using gmany_steps_later grewrite.intros(1) apply blast
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   581
  apply(case_tac "\<exists>rsa. a = RALTS rsa")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   582
   apply(erule exE)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   583
  apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   584
   apply (meson grewrite.intros(2) grewrites.simps grewrites_cons)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   585
  by (simp add: grewrites_cons rflts_def_idiot)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   586
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   587
lemma more_distinct1:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   588
  shows "       \<lbrakk>\<And>rsb rset rset2.
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   589
           rset2 \<subseteq> set rsb \<Longrightarrow> rsb @ rdistinct rs rset \<leadsto>g* rsb @ rdistinct rs (rset \<union> rset2);
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   590
        rset2 \<subseteq> set rsb; a \<notin> rset; a \<in> rset2\<rbrakk>
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   591
       \<Longrightarrow> rsb @ a # rdistinct rs (insert a rset) \<leadsto>g* rsb @ rdistinct rs (rset \<union> rset2)"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   592
  apply(subgoal_tac "rsb @ a # rdistinct rs (insert a rset) \<leadsto>g* rsb @ rdistinct rs (insert a rset)")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   593
   apply(subgoal_tac "rsb @ rdistinct rs (insert a rset) \<leadsto>g* rsb @ rdistinct rs (rset \<union> rset2)")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   594
    apply (meson greal_trans)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   595
   apply (metis Un_iff Un_insert_left insert_absorb)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   596
  by (simp add: gr_in_rstar grewrite_variant1 in_mono)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   597
  
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   598
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   599
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   600
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   601
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   602
lemma frewrite_rd_grewrites_aux:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   603
  shows     "       RALTS rs \<notin> set rsb \<Longrightarrow>
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   604
       rsb @
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   605
       RALTS rs #
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   606
       rdistinct rsa
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   607
        (insert (RALTS rs)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   608
          (set rsb)) \<leadsto>g* rflts rsb @
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   609
                          rdistinct rs (set rsb) @ rdistinct rsa (set rs \<union> set rsb \<union> {RALTS rs})"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   610
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   611
   apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   612
  apply(subgoal_tac "rsb @
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   613
    RALTS rs #
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   614
    rdistinct rsa
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   615
     (insert (RALTS rs)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   616
       (set rsb)) \<leadsto>g* rsb @
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   617
    rs @
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   618
    rdistinct rsa
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   619
     (insert (RALTS rs)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   620
       (set rsb)) ")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   621
  apply(subgoal_tac " rsb @
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   622
    rs @
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   623
    rdistinct rsa
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   624
     (insert (RALTS rs)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   625
       (set rsb)) \<leadsto>g*
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   626
                      rsb @
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   627
    rdistinct rs (set rsb) @
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   628
    rdistinct rsa
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   629
     (insert (RALTS rs)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   630
       (set rsb)) ")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   631
    apply (smt (verit, ccfv_SIG) Un_insert_left flts_gstar greal_trans grewrite_rdistinct_aux grewritess_concat inf_sup_aci(5) rdistinct_concat_general rdistinct_set_equality set_append)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   632
   apply (metis append_assoc grewrites.intros(1) grewritess_concat gstar_rdistinct_general)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   633
  by (simp add: gr_in_rstar grewrite.intros(2) grewrites_append)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   634
  
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   635
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   636
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   637
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   638
lemma list_dlist_union:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   639
  shows "set rs \<subseteq> set rsb \<union> set (rdistinct rs (set rsb))"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   640
  by (metis rdistinct_concat_general rdistinct_set_equality set_append sup_ge2)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   641
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   642
lemma r_finite1:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   643
  shows "r = RALTS (r # rs) = False"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   644
  apply(induct r)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   645
  apply simp+
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   646
   apply (metis list.set_intros(1))
563
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
   647
  apply blast
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
   648
  by simp
495
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   649
  
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   650
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   651
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   652
lemma grewrite_singleton:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   653
  shows "[r] \<leadsto>g r # rs \<Longrightarrow> rs = []"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   654
  apply (induct "[r]" "r # rs" rule: grewrite.induct)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   655
    apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   656
  apply (metis r_finite1)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   657
  using grewrite.simps apply blast
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   658
  by simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   659
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   660
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   661
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   662
lemma concat_rdistinct_equality1:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   663
  shows "rdistinct (rs @ rsa) rset = rdistinct rs rset @ rdistinct rsa (rset \<union> (set rs))"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   664
  apply(induct rs arbitrary: rsa rset)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   665
   apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   666
  apply(case_tac "a \<in> rset")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   667
   apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   668
  apply (simp add: insert_absorb)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   669
  by auto
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   670
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   671
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   672
lemma grewrites_rev_append:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   673
  shows "rs1 \<leadsto>g* rs2 \<Longrightarrow> rs1 @ [x] \<leadsto>g* rs2 @ [x]"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   674
  using grewritess_concat by auto
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   675
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   676
lemma grewrites_inclusion:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   677
  shows "set rs \<subseteq> set rs1 \<Longrightarrow> rs1 @ rs \<leadsto>g* rs1"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   678
  apply(induct rs arbitrary: rs1)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   679
  apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   680
  by (meson gmany_steps_later grewrite_variant1 list.set_intros(1) set_subset_Cons subset_code(1))
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   681
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   682
lemma distinct_keeps_last:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   683
  shows "\<lbrakk>x \<notin> rset; x \<notin> set xs \<rbrakk> \<Longrightarrow> rdistinct (xs @ [x]) rset = rdistinct xs rset @ [x]"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   684
  by (simp add: concat_rdistinct_equality1)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   685
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   686
lemma grewrites_shape2_aux:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   687
  shows "       RALTS rs \<notin> set rsb \<Longrightarrow>
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   688
       rsb @
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   689
       rdistinct (rs @ rsa)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   690
        (set rsb) \<leadsto>g* rsb @
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   691
                       rdistinct rs (set rsb) @
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   692
                       rdistinct rsa (set rs \<union> set rsb \<union> {RALTS rs})"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   693
  apply(subgoal_tac " rdistinct (rs @ rsa) (set rsb) =  rdistinct rs (set rsb) @ rdistinct rsa (set rs \<union> set rsb)")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   694
   apply (simp only:)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   695
  prefer 2
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   696
  apply (simp add: Un_commute concat_rdistinct_equality1)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   697
  apply(induct rsa arbitrary: rs rsb rule: rev_induct)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   698
   apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   699
  apply(case_tac "x \<in> set rs")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   700
  apply (simp add: distinct_removes_middle3)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   701
  apply(case_tac "x = RALTS rs")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   702
   apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   703
  apply(case_tac "x \<in> set rsb")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   704
   apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   705
    apply (simp add: concat_rdistinct_equality1)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   706
  apply (simp add: concat_rdistinct_equality1)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   707
  apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   708
  apply(drule_tac x = "rs " in meta_spec)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   709
  apply(drule_tac x = rsb in meta_spec)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   710
  apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   711
  apply(subgoal_tac " rsb @ rdistinct rs (set rsb) @ rdistinct xs (set rs \<union> set rsb) \<leadsto>g* rsb @ rdistinct rs (set rsb) @ rdistinct xs (insert (RALTS rs) (set rs \<union> set rsb))")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   712
  prefer 2
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   713
   apply (simp add: concat_rdistinct_equality1)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   714
  apply(case_tac "x \<in> set xs")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   715
   apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   716
   apply (simp add: distinct_removes_last)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   717
  apply(case_tac "x \<in> set rsb")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   718
   apply (smt (verit, ccfv_threshold) Un_iff append.right_neutral concat_rdistinct_equality1 insert_is_Un rdistinct.simps(2))
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   719
  apply(subgoal_tac "rsb @ rdistinct rs (set rsb) @ rdistinct (xs @ [x]) (set rs \<union> set rsb) = rsb @ rdistinct rs (set rsb) @ rdistinct xs (set rs \<union> set rsb) @ [x]")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   720
  apply(simp only:)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   721
  apply(case_tac "x = RALTS rs")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   722
    apply(subgoal_tac "rsb @ rdistinct rs (set rsb) @ rdistinct xs (set rs \<union> set rsb) @ [x] \<leadsto>g* rsb @ rdistinct rs (set rsb) @ rdistinct xs (set rs \<union> set rsb) @ rs")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   723
  apply(subgoal_tac "rsb @ rdistinct rs (set rsb) @ rdistinct xs (set rs \<union> set rsb) @ rs \<leadsto>g* rsb @ rdistinct rs (set rsb) @ rdistinct xs (set rs \<union> set rsb) ")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   724
      apply (smt (verit, ccfv_SIG) Un_insert_left append.right_neutral concat_rdistinct_equality1 greal_trans insert_iff rdistinct.simps(2))
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   725
  apply(subgoal_tac "set rs \<subseteq> set ( rsb @ rdistinct rs (set rsb) @ rdistinct xs (set rs \<union> set rsb))")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   726
  apply (metis append.assoc grewrites_inclusion)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   727
     apply (metis Un_upper1 append.assoc dual_order.trans list_dlist_union set_append)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   728
  apply (metis append_Nil2 gr_in_rstar grewrite.intros(2) grewrite_append)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   729
   apply(subgoal_tac " rsb @ rdistinct rs (set rsb) @ rdistinct (xs @ [x]) (insert (RALTS rs) (set rs \<union> set rsb)) =  rsb @ rdistinct rs (set rsb) @ rdistinct (xs) (insert (RALTS rs) (set rs \<union> set rsb)) @ [x]")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   730
  apply(simp only:)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   731
  apply (metis append.assoc grewrites_rev_append)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   732
  apply (simp add: insert_absorb)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   733
   apply (simp add: distinct_keeps_last)+
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   734
  done
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   735
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   736
lemma grewrites_shape2:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   737
  shows "       RALTS rs \<notin> set rsb \<Longrightarrow>
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   738
       rsb @
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   739
       rdistinct (rs @ rsa)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   740
        (set rsb) \<leadsto>g* rflts rsb @
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   741
                       rdistinct rs (set rsb) @
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   742
                       rdistinct rsa (set rs \<union> set rsb \<union> {RALTS rs})"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   743
  apply (meson flts_gstar greal_trans grewrites.simps grewrites_shape2_aux grewritess_concat)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   744
  done
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   745
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   746
lemma rdistinct_add_acc:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   747
  shows "rset2 \<subseteq> set rsb \<Longrightarrow> rsb @ rdistinct rs rset \<leadsto>g* rsb @ rdistinct rs (rset \<union> rset2)"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   748
  apply(induct rs arbitrary: rsb rset rset2)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   749
   apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   750
  apply (case_tac "a \<in> rset")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   751
   apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   752
  apply(case_tac "a \<in> rset2")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   753
   apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   754
  apply (simp add: more_distinct1)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   755
  apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   756
  apply(drule_tac x = "rsb @ [a]" in meta_spec)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   757
  by (metis Un_insert_left append.assoc append_Cons append_Nil set_append sup.coboundedI1)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   758
  
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   759
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   760
lemma frewrite_fun1:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   761
  shows "       RALTS rs \<in> set rsb \<Longrightarrow>
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   762
       rsb @ rdistinct rsa (set rsb) \<leadsto>g* rflts rsb @ rdistinct rsa (set rsb \<union> set rs)"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   763
  apply(subgoal_tac "rsb @ rdistinct rsa (set rsb) \<leadsto>g* rflts rsb @ rdistinct rsa (set rsb)")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   764
   apply(subgoal_tac " set rs \<subseteq> set (rflts rsb)")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   765
  prefer 2
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   766
  using spilled_alts_contained apply blast
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   767
   apply(subgoal_tac "rflts rsb @ rdistinct rsa (set rsb) \<leadsto>g* rflts rsb @ rdistinct rsa (set rsb \<union> set rs)")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   768
  using greal_trans apply blast
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   769
  using rdistinct_add_acc apply presburger
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   770
  using flts_gstar grewritess_concat by auto
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   771
  
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   772
lemma frewrite_rd_grewrites:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   773
  shows "rs1 \<leadsto>f rs2 \<Longrightarrow> 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   774
\<exists>rs3. (rs @ (rdistinct rs1 (set rs)) \<leadsto>g* rs3) \<and> (rs @ (rdistinct rs2 (set rs)) \<leadsto>g* rs3) "
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   775
  apply(induct rs1 rs2 arbitrary: rs rule: frewrite.induct)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   776
    apply(rule_tac x = "rsa @ (rdistinct rs ({RZERO} \<union> set rsa))" in exI)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   777
    apply(rule conjI)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   778
  apply(case_tac "RZERO \<in> set rsa")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   779
  apply simp+
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   780
  using gstar0 apply fastforce
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   781
     apply (simp add: gr_in_rstar grewrite.intros(1) grewrites_append)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   782
    apply (simp add: gstar0)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   783
    prefer 2
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   784
    apply(case_tac "r \<in> set rs")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   785
  apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   786
    apply(drule_tac x = "rs @ [r]" in meta_spec)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   787
    apply(erule exE)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   788
    apply(rule_tac x = "rs3" in exI)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   789
   apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   790
  apply(case_tac "RALTS rs \<in> set rsb")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   791
   apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   792
   apply(rule_tac x = "rflts rsb @ rdistinct rsa (set rsb \<union> set rs)" in exI)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   793
   apply(rule conjI)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   794
  using frewrite_fun1 apply force
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   795
  apply (metis frewrite_fun1 rdistinct_concat sup_ge2)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   796
  apply(simp)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   797
  apply(rule_tac x = 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   798
 "rflts rsb @
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   799
                       rdistinct rs (set rsb) @
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   800
                       rdistinct rsa (set rs \<union> set rsb \<union> {RALTS rs})" in exI)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   801
  apply(rule conjI)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   802
   prefer 2
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   803
  using grewrites_shape2 apply force
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   804
  using frewrite_rd_grewrites_aux by blast
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   805
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   806
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   807
lemma frewrite_simpeq2:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   808
  shows "rs1 \<leadsto>f rs2 \<Longrightarrow> rsimp (RALTS (rdistinct rs1 {})) = rsimp (RALTS (rdistinct rs2 {}))"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   809
  apply(subgoal_tac "\<exists> rs3. (rdistinct rs1 {} \<leadsto>g* rs3) \<and> (rdistinct rs2 {} \<leadsto>g* rs3)")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   810
  using grewrites_equal_rsimp apply fastforce
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   811
  by (metis append_self_conv2 frewrite_rd_grewrites list.set(1))
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   812
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   813
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   814
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   815
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   816
(*a more refined notion of h\<leadsto>* is needed,
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   817
this lemma fails when rs1 contains some RALTS rs where elements
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   818
of rs appear in later parts of rs1, which will be picked up by rs2
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   819
and deduplicated*)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   820
lemma frewrites_simpeq:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   821
  shows "rs1 \<leadsto>f* rs2 \<Longrightarrow>
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   822
 rsimp (RALTS (rdistinct rs1 {})) = rsimp (RALTS ( rdistinct rs2 {})) "
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   823
  apply(induct rs1 rs2 rule: frewrites.induct)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   824
   apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   825
  using frewrite_simpeq2 by presburger
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   826
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   827
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   828
lemma frewrite_single_step:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   829
  shows " rs2 \<leadsto>f rs3 \<Longrightarrow> rsimp (RALTS rs2) = rsimp (RALTS rs3)"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   830
  apply(induct rs2 rs3 rule: frewrite.induct)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   831
    apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   832
  using simp_flatten apply blast
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   833
  by (metis (no_types, opaque_lifting) list.simps(9) rsimp.simps(2) simp_flatten2)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   834
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   835
lemma grewrite_simpalts:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   836
  shows " rs2 \<leadsto>g rs3 \<Longrightarrow> rsimp (rsimp_ALTs rs2) = rsimp (rsimp_ALTs rs3)"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   837
  apply(induct rs2 rs3 rule : grewrite.induct)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   838
  using identity_wwo0 apply presburger
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   839
  apply (metis frewrite.intros(1) frewrite_single_step identity_wwo0 rsimp_ALTs.simps(3) simp_flatten)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   840
  apply (smt (verit, ccfv_SIG) gmany_steps_later grewrites.intros(1) grewrites_cons grewrites_equal_rsimp identity_wwo0 rsimp_ALTs.simps(3))
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   841
  apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   842
  apply(subst rsimp_alts_equal)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   843
  apply(case_tac "rsa = [] \<and> rsb = [] \<and> rsc = []")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   844
   apply(subgoal_tac "rsa @ a # rsb @ rsc = [a]")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   845
  apply (simp only:)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   846
  apply (metis append_Nil frewrite.intros(1) frewrite_single_step identity_wwo0 rsimp_ALTs.simps(3) simp_removes_duplicate1(2))
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   847
   apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   848
  by (smt (verit, best) append.assoc append_Cons frewrite.intros(1) frewrite_single_step identity_wwo0 in_set_conv_decomp rsimp_ALTs.simps(3) simp_removes_duplicate3)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   849
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   850
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   851
lemma grewrites_simpalts:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   852
  shows " rs2 \<leadsto>g* rs3 \<Longrightarrow> rsimp (rsimp_ALTs rs2) = rsimp (rsimp_ALTs rs3)"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   853
  apply(induct rs2 rs3 rule: grewrites.induct)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   854
   apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   855
  using grewrite_simpalts by presburger
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   856
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   857
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   858
lemma simp_der_flts:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   859
  shows "rsimp (RALTS (rdistinct (map (rder x) (rflts rs)) {})) = 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   860
         rsimp (RALTS (rdistinct (rflts (map (rder x) rs)) {}))"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   861
  apply(subgoal_tac "map (rder x) (rflts rs) \<leadsto>f* rflts (map (rder x) rs)")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   862
  using frewrites_simpeq apply presburger
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   863
  using early_late_der_frewrites by auto
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   864
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   865
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   866
lemma simp_der_pierce_flts_prelim:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   867
  shows "rsimp (rsimp_ALTs (rdistinct (map (rder x) (rflts rs)) {})) 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   868
       = rsimp (rsimp_ALTs (rdistinct (rflts (map (rder x) rs)) {}))"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   869
  by (metis append.right_neutral grewrite.intros(2) grewrite_simpalts rsimp_ALTs.simps(2) simp_der_flts)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   870
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   871
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   872
lemma basic_regex_property1:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   873
  shows "rnullable r \<Longrightarrow> rsimp r \<noteq> RZERO"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   874
  apply(induct r rule: rsimp.induct)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   875
  apply(auto)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   876
  apply (metis idiot idiot2 rrexp.distinct(5))
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   877
  by (metis der_simp_nullability rnullable.simps(1) rnullable.simps(4) rsimp.simps(2))
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   878
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   879
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   880
lemma inside_simp_seq_nullable:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   881
  shows 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   882
"\<And>r1 r2.
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   883
       \<lbrakk>rsimp (rder x (rsimp r1)) = rsimp (rder x r1); rsimp (rder x (rsimp r2)) = rsimp (rder x r2);
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   884
        rnullable r1\<rbrakk>
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   885
       \<Longrightarrow> rsimp (rder x (rsimp_SEQ (rsimp r1) (rsimp r2))) =
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   886
           rsimp_ALTs (rdistinct (rflts [rsimp_SEQ (rsimp (rder x r1)) (rsimp r2), rsimp (rder x r2)]) {})"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   887
  apply(case_tac "rsimp r1 = RONE")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   888
   apply(simp)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   889
  apply(subst basic_rsimp_SEQ_property1)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   890
   apply (simp add: idem_after_simp1)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   891
  apply(case_tac "rsimp r1 = RZERO")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   892
  
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   893
  using basic_regex_property1 apply blast
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   894
  apply(case_tac "rsimp r2 = RZERO")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   895
  
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   896
  apply (simp add: basic_rsimp_SEQ_property3)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   897
  apply(subst idiot2)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   898
     apply simp+
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   899
  apply(subgoal_tac "rnullable (rsimp r1)")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   900
   apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   901
  using rsimp_idem apply presburger
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   902
  using der_simp_nullability by presburger
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   903
  
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   904
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   905
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   906
lemma grewrite_ralts:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   907
  shows "rs \<leadsto>g rs' \<Longrightarrow> RALTS rs h\<leadsto>* RALTS rs'"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   908
  by (smt (verit) grewrite_cases_middle hr_in_rstar hrewrite.intros(11) hrewrite.intros(7) hrewrite.intros(8))
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   909
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   910
lemma grewrites_ralts:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   911
  shows "rs \<leadsto>g* rs' \<Longrightarrow> RALTS rs h\<leadsto>* RALTS rs'"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   912
  apply(induct rule: grewrites.induct)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   913
  apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   914
  using grewrite_ralts hreal_trans by blast
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   915
  
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   916
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   917
lemma distinct_grewrites_subgoal1:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   918
  shows "  
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   919
       \<lbrakk>rs1 \<leadsto>g* [a]; RALTS rs1 h\<leadsto>* a; [a] \<leadsto>g rs3\<rbrakk> \<Longrightarrow> RALTS rs1 h\<leadsto>* rsimp_ALTs rs3"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   920
  apply(subgoal_tac "RALTS rs1 h\<leadsto>* RALTS rs3")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   921
  apply (metis hrewrite.intros(10) hrewrite.intros(9) rs2 rsimp_ALTs.cases rsimp_ALTs.simps(1) rsimp_ALTs.simps(2) rsimp_ALTs.simps(3))
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   922
  apply(subgoal_tac "rs1 \<leadsto>g* rs3")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   923
  using grewrites_ralts apply blast
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   924
  using grewrites.intros(2) by presburger
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   925
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   926
lemma grewrites_ralts_rsimpalts:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   927
  shows "rs \<leadsto>g* rs' \<Longrightarrow> RALTS rs h\<leadsto>* rsimp_ALTs rs' "
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   928
  apply(induct rs rs' rule: grewrites.induct)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   929
   apply(case_tac rs)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   930
  using hrewrite.intros(9) apply force
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   931
   apply(case_tac list)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   932
  apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   933
  using hr_in_rstar hrewrite.intros(10) rsimp_ALTs.simps(2) apply presburger
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   934
   apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   935
  apply(case_tac rs2)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   936
   apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   937
   apply (metis grewrite.intros(3) grewrite_singleton rsimp_ALTs.simps(1))
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   938
  apply(case_tac list)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   939
   apply(simp)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   940
  using distinct_grewrites_subgoal1 apply blast
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   941
  apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   942
  apply(case_tac rs3)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   943
   apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   944
  using grewrites_ralts hrewrite.intros(9) apply blast
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   945
  by (metis (no_types, opaque_lifting) grewrite_ralts hr_in_rstar hreal_trans hrewrite.intros(10) neq_Nil_conv rsimp_ALTs.simps(2) rsimp_ALTs.simps(3))
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   946
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   947
lemma hrewrites_alts:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   948
  shows " r h\<leadsto>* r' \<Longrightarrow> (RALTS (rs1 @ [r] @ rs2)) h\<leadsto>* (RALTS  (rs1 @ [r'] @ rs2))"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   949
  apply(induct r r' rule: hrewrites.induct)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   950
  apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   951
  using hrewrite.intros(6) by blast
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   952
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   953
inductive 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   954
  srewritescf:: "rrexp list \<Rightarrow> rrexp list \<Rightarrow> bool" (" _ scf\<leadsto>* _" [100, 100] 100)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   955
where
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   956
  ss1: "[] scf\<leadsto>* []"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   957
| ss2: "\<lbrakk>r h\<leadsto>* r'; rs scf\<leadsto>* rs'\<rbrakk> \<Longrightarrow> (r#rs) scf\<leadsto>* (r'#rs')"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   958
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   959
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   960
lemma srewritescf_alt: "rs1 scf\<leadsto>* rs2 \<Longrightarrow> (RALTS (rs@rs1)) h\<leadsto>* (RALTS (rs@rs2))"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   961
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   962
  apply(induct rs1 rs2 arbitrary: rs rule: srewritescf.induct)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   963
   apply(rule rs1)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   964
  apply(drule_tac x = "rsa@[r']" in meta_spec)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   965
  apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   966
  apply(rule hreal_trans)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   967
   prefer 2
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   968
   apply(assumption)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   969
  apply(drule hrewrites_alts)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   970
  by auto
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   971
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   972
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   973
corollary srewritescf_alt1: 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   974
  assumes "rs1 scf\<leadsto>* rs2"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   975
  shows "RALTS rs1 h\<leadsto>* RALTS rs2"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   976
  using assms
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   977
  by (metis append_Nil srewritescf_alt)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   978
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   979
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   980
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   981
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   982
lemma trivialrsimp_srewrites: 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   983
  "\<lbrakk>\<And>x. x \<in> set rs \<Longrightarrow> x h\<leadsto>* f x \<rbrakk> \<Longrightarrow> rs scf\<leadsto>* (map f rs)"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   984
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   985
  apply(induction rs)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   986
   apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   987
   apply(rule ss1)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   988
  by (metis insert_iff list.simps(15) list.simps(9) srewritescf.simps)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   989
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   990
lemma hrewrites_list: 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   991
  shows
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   992
" (\<And>xa. xa \<in> set x \<Longrightarrow> xa h\<leadsto>* rsimp xa) \<Longrightarrow> RALTS x h\<leadsto>* RALTS (map rsimp x)"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   993
  apply(induct x)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   994
   apply(simp)+
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   995
  by (simp add: srewritescf_alt1 ss2 trivialrsimp_srewrites)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   996
(*  apply(subgoal_tac "RALTS x h\<leadsto>* RALTS (map rsimp x)")*)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   997
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   998
  
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
   999
lemma hrewrite_simpeq:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1000
  shows "r1 h\<leadsto> r2 \<Longrightarrow> rsimp r1 = rsimp r2"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1001
  apply(induct rule: hrewrite.induct)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1002
            apply simp+
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1003
  apply (simp add: basic_rsimp_SEQ_property3)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1004
  apply (simp add: basic_rsimp_SEQ_property1)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1005
  using rsimp.simps(1) apply presburger
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1006
        apply simp+
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1007
  using flts_middle0 apply force
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1008
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1009
  
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1010
  using simp_flatten3 apply presburger
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1011
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1012
  apply simp+
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1013
  apply (simp add: idem_after_simp1)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1014
  using grewrite.intros(4) grewrite_equal_rsimp by presburger
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1015
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1016
lemma hrewrites_simpeq:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1017
  shows "r1 h\<leadsto>* r2 \<Longrightarrow> rsimp r1 = rsimp r2"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1018
  apply(induct rule: hrewrites.induct)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1019
   apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1020
  apply(subgoal_tac "rsimp r2 = rsimp r3")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1021
   apply auto[1]
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1022
  using hrewrite_simpeq by presburger
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1023
  
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1024
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1025
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1026
lemma simp_hrewrites:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1027
  shows "r1 h\<leadsto>* rsimp r1"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1028
  apply(induct r1)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1029
       apply simp+
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1030
    apply(case_tac "rsimp r11 = RONE")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1031
     apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1032
     apply(subst basic_rsimp_SEQ_property1)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1033
  apply(subgoal_tac "RSEQ r11 r12 h\<leadsto>* RSEQ RONE r12")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1034
  using hreal_trans hrewrite.intros(3) apply blast
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1035
  using hrewrites_seq_context apply presburger
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1036
    apply(case_tac "rsimp r11 = RZERO")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1037
     apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1038
  using hrewrite.intros(1) hrewrites_seq_context apply blast
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1039
    apply(case_tac "rsimp r12 = RZERO")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1040
     apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1041
  apply(subst basic_rsimp_SEQ_property3)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1042
  apply (meson hrewrite.intros(2) hrewrites.simps hrewrites_seq_context2)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1043
    apply(subst idiot2)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1044
       apply simp+
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1045
  using hrewrites_seq_contexts apply presburger
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1046
   apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1047
   apply(subgoal_tac "RALTS x h\<leadsto>* RALTS (map rsimp x)")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1048
  apply(subgoal_tac "RALTS (map rsimp x) h\<leadsto>* rsimp_ALTs (rdistinct (rflts (map rsimp x)) {}) ")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1049
  using hreal_trans apply blast
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1050
    apply (meson flts_gstar greal_trans grewrites_ralts_rsimpalts gstar_rdistinct)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1051
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1052
   apply (simp add: grewrites_ralts hrewrites_list)
563
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1053
  by simp_all
495
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1054
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1055
lemma interleave_aux1:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1056
  shows " RALT (RSEQ RZERO r1) r h\<leadsto>*  r"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1057
  apply(subgoal_tac "RSEQ RZERO r1 h\<leadsto>* RZERO")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1058
  apply(subgoal_tac "RALT (RSEQ RZERO r1) r h\<leadsto>* RALT RZERO r")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1059
  apply (meson grewrite.intros(1) grewrite_ralts hreal_trans hrewrite.intros(10) hrewrites.simps)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1060
  using rs1 srewritescf_alt1 ss1 ss2 apply presburger
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1061
  by (simp add: hr_in_rstar hrewrite.intros(1))
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1062
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1063
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1064
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1065
lemma rnullable_hrewrite:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1066
  shows "r1 h\<leadsto> r2 \<Longrightarrow> rnullable r1 = rnullable r2"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1067
  apply(induct rule: hrewrite.induct)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1068
            apply simp+
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1069
     apply blast
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1070
    apply simp+
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1071
  done
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1072
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1073
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1074
lemma interleave1:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1075
  shows "r h\<leadsto> r' \<Longrightarrow> rder c r h\<leadsto>* rder c r'"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1076
  apply(induct r r' rule: hrewrite.induct)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1077
            apply (simp add: hr_in_rstar hrewrite.intros(1))
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1078
  apply (metis (no_types, lifting) basic_rsimp_SEQ_property3 list.simps(8) list.simps(9) rder.simps(1) rder.simps(5) rdistinct.simps(1) rflts.simps(1) rflts.simps(2) rsimp.simps(1) rsimp.simps(2) rsimp.simps(3) rsimp_ALTs.simps(1) simp_hrewrites)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1079
          apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1080
          apply(subst interleave_aux1)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1081
          apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1082
         apply(case_tac "rnullable r1")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1083
          apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1084
  
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1085
          apply (simp add: hrewrites_seq_context rnullable_hrewrite srewritescf_alt1 ss1 ss2)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1086
  
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1087
         apply (simp add: hrewrites_seq_context rnullable_hrewrite)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1088
        apply(case_tac "rnullable r1")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1089
  apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1090
  
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1091
  using hr_in_rstar hrewrites_seq_context2 srewritescf_alt1 ss1 ss2 apply presburger
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1092
  apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1093
  using hr_in_rstar hrewrites_seq_context2 apply blast
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1094
       apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1095
  
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1096
  using hrewrites_alts apply auto[1]
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1097
  apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1098
  using grewrite.intros(1) grewrite_append grewrite_ralts apply auto[1]
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1099
  apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1100
  apply (simp add: grewrite.intros(2) grewrite_append grewrite_ralts)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1101
  apply (simp add: hr_in_rstar hrewrite.intros(9))
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1102
   apply (simp add: hr_in_rstar hrewrite.intros(10))
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1103
  apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1104
  using hrewrite.intros(11) by auto
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1105
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1106
lemma interleave_star1:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1107
  shows "r h\<leadsto>* r' \<Longrightarrow> rder c r h\<leadsto>* rder c r'"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1108
  apply(induct rule : hrewrites.induct)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1109
   apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1110
  by (meson hreal_trans interleave1)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1111
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1112
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1113
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1114
lemma inside_simp_removal:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1115
  shows " rsimp (rder x (rsimp r)) = rsimp (rder x r)"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1116
  apply(induct r)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1117
       apply simp+
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1118
    apply(case_tac "rnullable r1")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1119
     apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1120
  
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1121
  using inside_simp_seq_nullable apply blast
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1122
    apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1123
  apply (smt (verit, del_insts) idiot2 basic_rsimp_SEQ_property3 der_simp_nullability rder.simps(1) rder.simps(5) rnullable.simps(2) rsimp.simps(1) rsimp_SEQ.simps(1) rsimp_idem)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1124
   apply(subgoal_tac "rder x (RALTS xa) h\<leadsto>* rder x (rsimp (RALTS xa))")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1125
  using hrewrites_simpeq apply presburger
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1126
  using interleave_star1 simp_hrewrites apply presburger
563
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1127
  by simp_all
495
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1128
  
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1129
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1130
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1131
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1132
lemma rders_simp_same_simpders:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1133
  shows "s \<noteq> [] \<Longrightarrow> rders_simp r s = rsimp (rders r s)"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1134
  apply(induct s rule: rev_induct)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1135
   apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1136
  apply(case_tac "xs = []")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1137
   apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1138
  apply(simp add: rders_append rders_simp_append)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1139
  using inside_simp_removal by blast
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1140
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1141
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1142
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1143
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1144
lemma distinct_der:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1145
  shows "rsimp (rsimp_ALTs (map (rder x) (rdistinct rs {}))) = 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1146
         rsimp (rsimp_ALTs (rdistinct (map (rder x) rs) {}))"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1147
  by (metis grewrites_simpalts gstar_rdistinct inside_simp_removal rder_rsimp_ALTs_commute)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1148
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1149
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1150
  
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1151
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1152
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1153
lemma rders_simp_lambda:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1154
  shows " rsimp \<circ> rder x \<circ> (\<lambda>r. rders_simp r xs) = (\<lambda>r. rders_simp r (xs @ [x]))"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1155
  using rders_simp_append by auto
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1156
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1157
lemma rders_simp_nonempty_simped:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1158
  shows "xs \<noteq> [] \<Longrightarrow> rsimp \<circ> (\<lambda>r. rders_simp r xs) = (\<lambda>r. rders_simp r xs)"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1159
  using rders_simp_same_simpders rsimp_idem by auto
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1160
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1161
lemma repeated_altssimp:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1162
  shows "\<forall>r \<in> set rs. rsimp r = r \<Longrightarrow> rsimp (rsimp_ALTs (rdistinct (rflts rs) {})) =
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1163
           rsimp_ALTs (rdistinct (rflts rs) {})"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1164
  by (metis map_idI rsimp.simps(2) rsimp_idem)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1165
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1166
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1167
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1168
lemma alts_closed_form: 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1169
  shows "rsimp (rders_simp (RALTS rs) s) = rsimp (RALTS (map (\<lambda>r. rders_simp r s) rs))"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1170
  apply(induct s rule: rev_induct)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1171
   apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1172
  apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1173
  apply(subst rders_simp_append)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1174
  apply(subgoal_tac " rsimp (rders_simp (rders_simp (RALTS rs) xs) [x]) = 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1175
 rsimp(rders_simp (rsimp_ALTs (rdistinct (rflts (map (rsimp \<circ> (\<lambda>r. rders_simp r xs)) rs)) {})) [x])")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1176
   prefer 2
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1177
  apply (metis inside_simp_removal rders_simp_one_char)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1178
  apply(simp only: )
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1179
  apply(subst rders_simp_one_char)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1180
  apply(subst rsimp_idem)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1181
  apply(subgoal_tac "rsimp (rder x (rsimp_ALTs (rdistinct (rflts (map (rsimp \<circ> (\<lambda>r. rders_simp r xs)) rs)) {}))) =
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1182
                     rsimp ((rsimp_ALTs (map (rder x) (rdistinct (rflts (map (rsimp \<circ> (\<lambda>r. rders_simp r xs)) rs)) {})))) ")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1183
  prefer 2
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1184
  using rder_rsimp_ALTs_commute apply presburger
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1185
  apply(simp only:)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1186
  apply(subgoal_tac "rsimp (rsimp_ALTs (map (rder x) (rdistinct (rflts (map (rsimp \<circ> (\<lambda>r. rders_simp r xs)) rs)) {})))
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1187
= rsimp (rsimp_ALTs (rdistinct (map (rder x) (rflts (map (rsimp \<circ> (\<lambda>r. rders_simp r xs)) rs))) {}))")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1188
   prefer 2
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1189
  
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1190
  using distinct_der apply presburger
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1191
  apply(simp only:)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1192
  apply(subgoal_tac " rsimp (rsimp_ALTs (rdistinct (map (rder x) (rflts (map (rsimp \<circ> (\<lambda>r. rders_simp r xs)) rs))) {})) =
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1193
                      rsimp (rsimp_ALTs (rdistinct ( (rflts (map (rder x) (map (rsimp \<circ> (\<lambda>r. rders_simp r xs)) rs)))) {}))")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1194
   apply(simp only:)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1195
  apply(subgoal_tac " rsimp (rsimp_ALTs (rdistinct (rflts (map (rder x) (map (rsimp \<circ> (\<lambda>r. rders_simp r xs)) rs))) {})) = 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1196
                      rsimp (rsimp_ALTs (rdistinct (rflts ( (map (rsimp \<circ> (rder x) \<circ> (\<lambda>r. rders_simp r xs)) rs))) {}))")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1197
    apply(simp only:)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1198
  apply(subst rders_simp_lambda)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1199
    apply(subst rders_simp_nonempty_simped)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1200
     apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1201
    apply(subgoal_tac "\<forall>r \<in> set  (map (\<lambda>r. rders_simp r (xs @ [x])) rs). rsimp r = r")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1202
  prefer 2
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1203
     apply (simp add: rders_simp_same_simpders rsimp_idem)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1204
    apply(subst repeated_altssimp)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1205
     apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1206
  apply fastforce
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1207
   apply (metis inside_simp_removal list.map_comp rder.simps(4) rsimp.simps(2) rsimp_idem)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1208
  using simp_der_pierce_flts_prelim by blast
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1209
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1210
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1211
lemma alts_closed_form_variant: 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1212
  shows "s \<noteq> [] \<Longrightarrow> rders_simp (RALTS rs) s = rsimp (RALTS (map (\<lambda>r. rders_simp r s) rs))"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1213
  by (metis alts_closed_form comp_apply rders_simp_nonempty_simped)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1214
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1215
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1216
lemma rsimp_seq_equal1:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1217
  shows "rsimp_SEQ (rsimp r1) (rsimp r2) = rsimp_ALTs (rdistinct (rflts [rsimp_SEQ (rsimp r1) (rsimp r2)]) {})"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1218
  by (metis idem_after_simp1 rsimp.simps(1))
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1219
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1220
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1221
fun sflat_aux :: "rrexp  \<Rightarrow> rrexp list " where
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1222
  "sflat_aux (RALTS (r # rs)) = sflat_aux r @ rs"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1223
| "sflat_aux (RALTS []) = []"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1224
| "sflat_aux r = [r]"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1225
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1226
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1227
fun sflat :: "rrexp \<Rightarrow> rrexp" where
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1228
  "sflat (RALTS (r # [])) = r"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1229
| "sflat (RALTS (r # rs)) = RALTS (sflat_aux r @ rs)"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1230
| "sflat r = r"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1231
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1232
inductive created_by_seq:: "rrexp \<Rightarrow> bool" where
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1233
  "created_by_seq (RSEQ r1 r2) "
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1234
| "created_by_seq r1 \<Longrightarrow> created_by_seq (RALT r1 r2)"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1235
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1236
lemma seq_ders_shape1:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1237
  shows "\<forall>r1 r2. \<exists>r3 r4. (rders (RSEQ r1 r2) s) = RSEQ r3 r4 \<or> (rders (RSEQ r1 r2) s) = RALT r3 r4"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1238
  apply(induct s rule: rev_induct)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1239
   apply auto[1]
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1240
  apply(rule allI)+
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1241
  apply(subst rders_append)+
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1242
  apply(subgoal_tac " \<exists>r3 r4. rders (RSEQ r1 r2) xs = RSEQ r3 r4 \<or> rders (RSEQ r1 r2) xs = RALT r3 r4 ")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1243
   apply(erule exE)+
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1244
   apply(erule disjE)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1245
    apply simp+
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1246
  done
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1247
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1248
lemma created_by_seq_der:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1249
  shows "created_by_seq r \<Longrightarrow> created_by_seq (rder c r)"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1250
  apply(induct r)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1251
  apply simp+
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1252
  
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1253
  using created_by_seq.cases apply blast
563
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1254
      apply(auto)
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1255
  apply (meson created_by_seq.cases rrexp.distinct(23) rrexp.distinct(25))
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1256
  using created_by_seq.simps apply blast
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1257
  apply (meson created_by_seq.simps)
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1258
  using created_by_seq.intros(1) apply blast
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1259
  apply (metis (no_types, lifting) created_by_seq.simps k0a list.set_intros(1) list.simps(8) list.simps(9) rrexp.distinct(31))
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1260
  apply (simp add: created_by_seq.intros(1))
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1261
  using created_by_seq.simps apply blast
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1262
  by (simp add: created_by_seq.intros(1))
495
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1263
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1264
lemma createdbyseq_left_creatable:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1265
  shows "created_by_seq (RALT r1 r2) \<Longrightarrow> created_by_seq r1"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1266
  using created_by_seq.cases by blast
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1267
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1268
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1269
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1270
lemma recursively_derseq:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1271
  shows " created_by_seq (rders (RSEQ r1 r2) s)"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1272
  apply(induct s rule: rev_induct)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1273
   apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1274
  using created_by_seq.intros(1) apply force
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1275
  apply(subgoal_tac "created_by_seq (rders (RSEQ r1 r2) (xs @ [x]))")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1276
  apply blast
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1277
  apply(subst rders_append)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1278
  apply(subgoal_tac "\<exists>r3 r4. rders (RSEQ r1 r2) xs = RSEQ r3 r4 \<or> 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1279
                    rders (RSEQ r1 r2) xs = RALT r3 r4")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1280
   prefer 2
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1281
  using seq_ders_shape1 apply presburger
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1282
  apply(erule exE)+
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1283
  apply(erule disjE)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1284
   apply(subgoal_tac "created_by_seq (rders (RSEQ r3 r4) [x])")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1285
    apply presburger
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1286
  apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1287
  using created_by_seq.intros(1) created_by_seq.intros(2) apply presburger
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1288
  apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1289
  apply(subgoal_tac "created_by_seq r3")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1290
  prefer 2
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1291
  using createdbyseq_left_creatable apply blast
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1292
  using created_by_seq.intros(2) created_by_seq_der by blast
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1293
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1294
  
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1295
lemma recursively_derseq1:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1296
  shows "r = rders (RSEQ r1 r2) s \<Longrightarrow> created_by_seq r"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1297
  using recursively_derseq by blast
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1298
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1299
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1300
lemma sfau_head:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1301
  shows " created_by_seq r \<Longrightarrow> \<exists>ra rb rs. sflat_aux r = RSEQ ra rb # rs"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1302
  apply(induction r rule: created_by_seq.induct)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1303
  apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1304
  by fastforce
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1305
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1306
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1307
lemma vsuf_prop1:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1308
  shows "vsuf (xs @ [x]) r = (if (rnullable (rders r xs)) 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1309
                                then [x] # (map (\<lambda>s. s @ [x]) (vsuf xs r) )
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1310
                                else (map (\<lambda>s. s @ [x]) (vsuf xs r)) ) 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1311
             "
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1312
  apply(induct xs arbitrary: r)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1313
   apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1314
  apply(case_tac "rnullable r")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1315
  apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1316
  apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1317
  done
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1318
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1319
fun  breakHead :: "rrexp list \<Rightarrow> rrexp list" where
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1320
  "breakHead [] = [] "
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1321
| "breakHead (RALT r1 r2 # rs) = r1 # r2 # rs"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1322
| "breakHead (r # rs) = r # rs"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1323
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1324
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1325
lemma sfau_idem_der:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1326
  shows "created_by_seq r \<Longrightarrow> sflat_aux (rder c r) = breakHead (map (rder c) (sflat_aux r))"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1327
  apply(induct rule: created_by_seq.induct)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1328
   apply simp+
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1329
  using sfau_head by fastforce
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1330
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1331
lemma vsuf_compose1:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1332
  shows " \<not> rnullable (rders r1 xs)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1333
       \<Longrightarrow> map (rder x \<circ> rders r2) (vsuf xs r1) = map (rders r2) (vsuf (xs @ [x]) r1)"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1334
  apply(subst vsuf_prop1)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1335
  apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1336
  by (simp add: rders_append)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1337
  
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1338
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1339
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1340
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1341
lemma seq_sfau0:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1342
  shows  "sflat_aux (rders (RSEQ r1 r2) s) = (RSEQ (rders r1 s) r2) #
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1343
                                       (map (rders r2) (vsuf s r1)) "
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1344
  apply(induct s rule: rev_induct)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1345
   apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1346
  apply(subst rders_append)+
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1347
  apply(subgoal_tac "created_by_seq (rders (RSEQ r1 r2) xs)")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1348
  prefer 2
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1349
  using recursively_derseq1 apply blast
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1350
  apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1351
  apply(subst sfau_idem_der)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1352
  
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1353
   apply blast
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1354
  apply(case_tac "rnullable (rders r1 xs)")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1355
   apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1356
   apply(subst vsuf_prop1)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1357
  apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1358
  apply (simp add: rders_append)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1359
  apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1360
  using vsuf_compose1 by blast
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1361
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1362
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1363
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1364
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1365
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1366
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1367
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1368
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1369
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1370
thm sflat.elims
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1371
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1372
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1373
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1374
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1375
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1376
lemma sflat_rsimpeq:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1377
  shows "created_by_seq r1 \<Longrightarrow> sflat_aux r1 =  rs \<Longrightarrow> rsimp r1 = rsimp (RALTS rs)"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1378
  apply(induct r1 arbitrary: rs rule:  created_by_seq.induct)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1379
   apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1380
  using rsimp_seq_equal1 apply force
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1381
  by (metis head_one_more_simp rsimp.simps(2) sflat_aux.simps(1) simp_flatten)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1382
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1383
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1384
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1385
lemma seq_closed_form_general:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1386
  shows "rsimp (rders (RSEQ r1 r2) s) = 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1387
rsimp ( (RALTS ( (RSEQ (rders r1 s) r2 # (map (rders r2) (vsuf s r1))))))"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1388
  apply(case_tac "s \<noteq> []")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1389
  apply(subgoal_tac "created_by_seq (rders (RSEQ r1 r2) s)")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1390
  apply(subgoal_tac "sflat_aux (rders (RSEQ r1 r2) s) = RSEQ (rders r1 s) r2 # (map (rders r2) (vsuf s r1))")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1391
  using sflat_rsimpeq apply blast
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1392
    apply (simp add: seq_sfau0)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1393
  using recursively_derseq1 apply blast
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1394
  apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1395
  by (metis idem_after_simp1 rsimp.simps(1))
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1396
  
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1397
lemma seq_closed_form_aux1a:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1398
  shows "rsimp (RALTS (RSEQ (rders r1 s) r2 # rs)) =
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1399
           rsimp (RALTS (RSEQ (rders_simp r1 s) r2 # rs))"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1400
  by (metis head_one_more_simp rders.simps(1) rders_simp.simps(1) rders_simp_same_simpders rsimp.simps(1) rsimp_idem simp_flatten_aux0)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1401
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1402
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1403
lemma seq_closed_form_aux1:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1404
  shows "rsimp (RALTS (RSEQ (rders r1 s) r2 # (map (rders r2) (vsuf s r1)))) =
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1405
           rsimp (RALTS (RSEQ (rders_simp r1 s) r2 # (map (rders r2) (vsuf s r1))))"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1406
  by (smt (verit, best) list.simps(9) rders.simps(1) rders_simp.simps(1) rders_simp_same_simpders rsimp.simps(1) rsimp.simps(2) rsimp_idem)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1407
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1408
lemma add_simp_to_rest:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1409
  shows "rsimp (RALTS (r # rs)) = rsimp (RALTS (r # map rsimp rs))"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1410
  by (metis append_Nil2 grewrite.intros(2) grewrite_simpalts head_one_more_simp list.simps(9) rsimp_ALTs.simps(2) spawn_simp_rsimpalts)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1411
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1412
lemma rsimp_compose_der2:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1413
  shows "\<forall>s \<in> set ss. s \<noteq> [] \<Longrightarrow> map rsimp (map (rders r) ss) = map (\<lambda>s.  (rders_simp r s)) ss"  
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1414
  by (simp add: rders_simp_same_simpders)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1415
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1416
lemma vsuf_nonempty:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1417
  shows "\<forall>s \<in> set ( vsuf s1 r). s \<noteq> []"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1418
  apply(induct s1 arbitrary: r)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1419
   apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1420
  apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1421
  done
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1422
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1423
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1424
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1425
lemma seq_closed_form_aux2:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1426
  shows "s \<noteq> [] \<Longrightarrow> rsimp ( (RALTS ( (RSEQ (rders_simp r1 s) r2 # (map (rders r2) (vsuf s r1)))))) = 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1427
         rsimp ( (RALTS ( (RSEQ (rders_simp r1 s) r2 # (map (rders_simp r2) (vsuf s r1))))))"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1428
  
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1429
  by (metis add_simp_to_rest rsimp_compose_der2 vsuf_nonempty)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1430
  
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1431
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1432
lemma seq_closed_form: 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1433
  shows "rsimp (rders_simp (RSEQ r1 r2) s) = 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1434
           rsimp (RALTS ((RSEQ (rders_simp r1 s) r2) # (map (rders_simp r2) (vsuf s r1))))"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1435
proof (cases s)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1436
  case Nil
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1437
  then show ?thesis 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1438
    by (simp add: rsimp_seq_equal1[symmetric])
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1439
next
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1440
  case (Cons a list)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1441
  have "rsimp (rders_simp (RSEQ r1 r2) s) = rsimp (rsimp (rders (RSEQ r1 r2) s))"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1442
    using local.Cons by (subst rders_simp_same_simpders)(simp_all)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1443
  also have "... = rsimp (rders (RSEQ r1 r2) s)"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1444
    by (simp add: rsimp_idem)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1445
  also have "... = rsimp (RALTS (RSEQ (rders r1 s) r2 # map (rders r2) (vsuf s r1)))"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1446
    using seq_closed_form_general by blast
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1447
  also have "... = rsimp (RALTS (RSEQ (rders_simp r1 s) r2 # map (rders r2) (vsuf s r1)))"  
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1448
    by (simp only: seq_closed_form_aux1)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1449
  also have "... = rsimp (RALTS (RSEQ (rders_simp r1 s) r2 # map (rders_simp r2) (vsuf s r1)))"  
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1450
    using local.Cons by (subst seq_closed_form_aux2)(simp_all)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1451
  finally show ?thesis .
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1452
qed
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1453
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1454
lemma q: "s \<noteq> [] \<Longrightarrow> rders_simp (RSEQ r1 r2) s = rsimp (rders_simp (RSEQ r1 r2) s)"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1455
  using rders_simp_same_simpders rsimp_idem by presburger
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1456
  
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1457
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1458
lemma seq_closed_form_variant: 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1459
  assumes "s \<noteq> []"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1460
  shows "rders_simp (RSEQ r1 r2) s = 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1461
             rsimp (RALTS (RSEQ (rders_simp r1 s) r2 # (map (rders_simp r2) (vsuf s r1))))"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1462
  using assms q seq_closed_form by force
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1463
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1464
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1465
fun hflat_aux :: "rrexp \<Rightarrow> rrexp list" where
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1466
  "hflat_aux (RALT r1 r2) = hflat_aux r1 @ hflat_aux r2"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1467
| "hflat_aux r = [r]"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1468
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1469
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1470
fun hflat :: "rrexp \<Rightarrow> rrexp" where
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1471
  "hflat (RALT r1 r2) = RALTS ((hflat_aux r1) @ (hflat_aux r2))"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1472
| "hflat r = r"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1473
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1474
inductive created_by_star :: "rrexp \<Rightarrow> bool" where
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1475
  "created_by_star (RSEQ ra (RSTAR rb))"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1476
| "\<lbrakk>created_by_star r1; created_by_star r2\<rbrakk> \<Longrightarrow> created_by_star (RALT r1 r2)"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1477
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1478
fun hElem :: "rrexp  \<Rightarrow> rrexp list" where
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1479
  "hElem (RALT r1 r2) = (hElem r1 ) @ (hElem r2)"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1480
| "hElem r = [r]"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1481
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1482
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1483
lemma cbs_ders_cbs:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1484
  shows "created_by_star r \<Longrightarrow> created_by_star (rder c r)"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1485
  apply(induct r rule: created_by_star.induct)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1486
   apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1487
  using created_by_star.intros(1) created_by_star.intros(2) apply auto[1]
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1488
  by (metis (mono_tags, lifting) created_by_star.simps list.simps(8) list.simps(9) rder.simps(4))
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1489
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1490
lemma star_ders_cbs:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1491
  shows "created_by_star (rders (RSEQ r1 (RSTAR r2)) s)"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1492
  apply(induct s rule: rev_induct)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1493
   apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1494
   apply (simp add: created_by_star.intros(1))
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1495
  apply(subst rders_append)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1496
  apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1497
  using cbs_ders_cbs by auto
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1498
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1499
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1500
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1501
lemma hfau_pushin: 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1502
  shows "created_by_star r \<Longrightarrow> hflat_aux (rder c r) = concat (map hElem (map (rder c) (hflat_aux r)))"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1503
  apply(induct r rule: created_by_star.induct)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1504
   apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1505
  apply(subgoal_tac "created_by_star (rder c r1)")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1506
  prefer 2
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1507
  apply(subgoal_tac "created_by_star (rder c r2)")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1508
  using cbs_ders_cbs apply blast
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1509
  using cbs_ders_cbs apply auto[1]
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1510
  apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1511
  done
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1512
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1513
lemma stupdate_induct1:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1514
  shows " concat (map (hElem \<circ> (rder x \<circ> (\<lambda>s1. RSEQ (rders r0 s1) (RSTAR r0)))) Ss) =
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1515
          map (\<lambda>s1. RSEQ (rders r0 s1) (RSTAR r0)) (star_update x r0 Ss)"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1516
  apply(induct Ss)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1517
   apply simp+
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1518
  by (simp add: rders_append)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1519
  
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1520
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1521
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1522
lemma stupdates_join_general:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1523
  shows  "concat (map hElem (map (rder x) (map (\<lambda>s1. RSEQ (rders r0 s1) (RSTAR r0)) (star_updates xs r0 Ss)))) =
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1524
           map (\<lambda>s1. RSEQ (rders r0 s1) (RSTAR r0)) (star_updates (xs @ [x]) r0 Ss)"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1525
  apply(induct xs arbitrary: Ss)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1526
   apply (simp)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1527
  prefer 2
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1528
   apply auto[1]
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1529
  using stupdate_induct1 by blast
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1530
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1531
lemma star_hfau_induct:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1532
  shows "hflat_aux (rders (RSEQ (rder c r0) (RSTAR r0)) s) =   
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1533
      map (\<lambda>s1. RSEQ (rders r0 s1) (RSTAR r0)) (star_updates s r0 [[c]])"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1534
  apply(induct s rule: rev_induct)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1535
   apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1536
  apply(subst rders_append)+
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1537
  apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1538
  apply(subst stupdates_append)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1539
  apply(subgoal_tac "created_by_star (rders (RSEQ (rder c r0) (RSTAR r0)) xs)")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1540
  prefer 2
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1541
  apply (simp add: star_ders_cbs)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1542
  apply(subst hfau_pushin)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1543
   apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1544
  apply(subgoal_tac "concat (map hElem (map (rder x) (hflat_aux (rders (RSEQ (rder c r0) (RSTAR r0)) xs)))) =
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1545
                     concat (map hElem (map (rder x) ( map (\<lambda>s1. RSEQ (rders r0 s1) (RSTAR r0)) (star_updates xs r0 [[c]])))) ")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1546
   apply(simp only:)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1547
  prefer 2
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1548
   apply presburger
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1549
  apply(subst stupdates_append[symmetric])
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1550
  using stupdates_join_general by blast
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1551
563
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1552
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1553
495
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1554
lemma starders_hfau_also1:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1555
  shows "hflat_aux (rders (RSTAR r) (c # xs)) = map (\<lambda>s1. RSEQ (rders r s1) (RSTAR r)) (star_updates xs r [[c]])"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1556
  using star_hfau_induct by force
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1557
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1558
lemma hflat_aux_grewrites:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1559
  shows "a # rs \<leadsto>g* hflat_aux a @ rs"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1560
  apply(induct a arbitrary: rs)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1561
       apply simp+
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1562
   apply(case_tac x)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1563
    apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1564
  apply(case_tac list)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1565
  
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1566
  apply (metis append.right_neutral append_Cons append_eq_append_conv2 grewrites.simps hflat_aux.simps(7) same_append_eq)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1567
   apply(case_tac lista)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1568
  apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1569
  apply (metis (no_types, lifting) append_Cons append_eq_append_conv2 gmany_steps_later greal_trans grewrite.intros(2) grewrites_append self_append_conv)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1570
  apply simp
563
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1571
  by simp_all
495
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1572
  
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1573
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1574
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1575
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1576
lemma cbs_hfau_rsimpeq1:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1577
  shows "rsimp (RALT a b) = rsimp (RALTS ((hflat_aux a) @ (hflat_aux b)))"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1578
  apply(subgoal_tac "[a, b] \<leadsto>g* hflat_aux a @ hflat_aux b")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1579
  using grewrites_equal_rsimp apply presburger
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1580
  by (metis append.right_neutral greal_trans grewrites_cons hflat_aux_grewrites)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1581
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1582
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1583
lemma hfau_rsimpeq2:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1584
  shows "created_by_star r \<Longrightarrow> rsimp r = rsimp ( (RALTS (hflat_aux r)))"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1585
  apply(induct r)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1586
       apply simp+
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1587
  
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1588
    apply (metis rsimp_seq_equal1)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1589
  prefer 2
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1590
   apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1591
  apply(case_tac x)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1592
   apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1593
  apply(case_tac "list")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1594
   apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1595
  
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1596
  apply (metis idem_after_simp1)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1597
  apply(case_tac "lista")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1598
  prefer 2
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1599
   apply (metis hflat_aux.simps(8) idem_after_simp1 list.simps(8) list.simps(9) rsimp.simps(2))
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1600
  apply(subgoal_tac "rsimp (RALT a aa) = rsimp (RALTS (hflat_aux (RALT a aa)))")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1601
  apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1602
  apply(subgoal_tac "rsimp (RALT a aa) = rsimp (RALTS (hflat_aux a @ hflat_aux aa))")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1603
  using hflat_aux.simps(1) apply presburger
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1604
  apply simp
563
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1605
  using cbs_hfau_rsimpeq1 apply(fastforce)
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1606
  by simp
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1607
  
495
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1608
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1609
lemma star_closed_form1:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1610
  shows "rsimp (rders (RSTAR r0) (c#s)) = 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1611
rsimp ( ( RALTS ( (map (\<lambda>s1. RSEQ (rders r0 s1) (RSTAR r0) ) (star_updates s r0 [[c]]) ) )))"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1612
  using hfau_rsimpeq2 rder.simps(6) rders.simps(2) star_ders_cbs starders_hfau_also1 by presburger
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1613
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1614
lemma star_closed_form2:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1615
  shows  "rsimp (rders_simp (RSTAR r0) (c#s)) = 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1616
rsimp ( ( RALTS ( (map (\<lambda>s1. RSEQ (rders r0 s1) (RSTAR r0) ) (star_updates s r0 [[c]]) ) )))"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1617
  by (metis list.distinct(1) rders_simp_same_simpders rsimp_idem star_closed_form1)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1618
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1619
lemma star_closed_form3:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1620
  shows  "rsimp (rders_simp (RSTAR r0) (c#s)) =   (rders_simp (RSTAR r0) (c#s))"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1621
  by (metis list.distinct(1) rders_simp_same_simpders star_closed_form1 star_closed_form2)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1622
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1623
lemma star_closed_form4:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1624
  shows " (rders_simp (RSTAR r0) (c#s)) = 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1625
rsimp ( ( RALTS ( (map (\<lambda>s1. RSEQ (rders r0 s1) (RSTAR r0) ) (star_updates s r0 [[c]]) ) )))"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1626
  using star_closed_form2 star_closed_form3 by presburger
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1627
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1628
lemma star_closed_form5:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1629
  shows " rsimp ( ( RALTS ( (map (\<lambda>s1. RSEQ (rders r0 s1) (RSTAR r0) ) Ss         )))) = 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1630
          rsimp ( ( RALTS ( (map (\<lambda>s1. rsimp (RSEQ (rders r0 s1) (RSTAR r0)) ) Ss ))))"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1631
  by (metis (mono_tags, lifting) list.map_comp map_eq_conv o_apply rsimp.simps(2) rsimp_idem)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1632
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1633
lemma star_closed_form6_hrewrites:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1634
  shows "  
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1635
 (map (\<lambda>s1.  (RSEQ (rsimp (rders r0 s1)) (RSTAR r0)) ) Ss )
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1636
 scf\<leadsto>*
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1637
(map (\<lambda>s1. rsimp (RSEQ (rders r0 s1) (RSTAR r0)) ) Ss )"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1638
  apply(induct Ss)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1639
  apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1640
  apply (simp add: ss1)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1641
  by (metis (no_types, lifting) list.simps(9) rsimp.simps(1) rsimp_idem simp_hrewrites ss2)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1642
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1643
lemma star_closed_form6:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1644
  shows " rsimp ( ( RALTS ( (map (\<lambda>s1. rsimp (RSEQ (rders r0 s1) (RSTAR r0)) ) Ss )))) = 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1645
          rsimp ( ( RALTS ( (map (\<lambda>s1.  (RSEQ (rsimp (rders r0 s1)) (RSTAR r0)) ) Ss ))))"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1646
  apply(subgoal_tac " map (\<lambda>s1.  (RSEQ (rsimp (rders r0 s1)) (RSTAR r0)) ) Ss  scf\<leadsto>*
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1647
                      map (\<lambda>s1.  rsimp (RSEQ  (rders r0 s1) (RSTAR r0)) ) Ss ")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1648
  using hrewrites_simpeq srewritescf_alt1 apply fastforce
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1649
  using star_closed_form6_hrewrites by blast
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1650
563
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1651
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1652
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1653
495
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1654
lemma stupdate_nonempty:
563
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1655
  shows "\<forall>s \<in> set Ss. s \<noteq> [] \<Longrightarrow> \<forall>s \<in> set (star_update c r Ss). s \<noteq> []"
495
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1656
  apply(induct Ss)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1657
  apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1658
  apply(case_tac "rnullable (rders r a)")
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1659
   apply simp+
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1660
  done
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1661
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1662
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1663
lemma stupdates_nonempty:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1664
  shows "\<forall>s \<in> set Ss. s\<noteq> [] \<Longrightarrow> \<forall>s \<in> set (star_updates s r Ss). s \<noteq> []"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1665
  apply(induct s arbitrary: Ss)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1666
   apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1667
  apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1668
  using stupdate_nonempty by presburger
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1669
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1670
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1671
lemma star_closed_form8:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1672
  shows  
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1673
"rsimp ( ( RALTS ( (map (\<lambda>s1. RSEQ (rsimp (rders r0 s1)) (RSTAR r0) ) (star_updates s r0 [[c]]) ) ))) = 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1674
 rsimp ( ( RALTS ( (map (\<lambda>s1. RSEQ ( (rders_simp r0 s1)) (RSTAR r0) ) (star_updates s r0 [[c]]) ) )))"
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1675
  by (smt (verit, ccfv_SIG) list.simps(8) map_eq_conv rders__onechar rders_simp_same_simpders set_ConsD stupdates_nonempty)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1676
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1677
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1678
lemma star_closed_form:
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1679
  shows "rders_simp (RSTAR r0) (c#s) = 
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1680
rsimp ( RALTS ( (map (\<lambda>s1. RSEQ (rders_simp r0 s1) (RSTAR r0) ) (star_updates s r0 [[c]]) ) ))"
563
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1681
  apply(case_tac s)
495
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1682
   apply simp
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1683
   apply (metis idem_after_simp1 rsimp.simps(1) rsimp.simps(6) rsimp_idem)
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1684
  using star_closed_form4 star_closed_form5 star_closed_form6 star_closed_form8 by presburger
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1685
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1686
563
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1687
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1688
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1689
fun nupdate :: "char \<Rightarrow> rrexp \<Rightarrow>  (string * nat) option  list \<Rightarrow> (string * nat) option  list" where
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1690
  "nupdate c r [] = []"
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1691
| "nupdate c r (Some (s, Suc n) # Ss) = (if (rnullable (rders r s)) 
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1692
                                          then Some (s@[c], Suc n) # Some ([c], n) # (nupdate c r Ss) 
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1693
                                          else Some ((s@[c]), Suc n)  # (nupdate c r Ss) 
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1694
                                        )"
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1695
| "nupdate c r (Some (s, 0) # Ss) =  (if (rnullable (rders r s)) 
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1696
                                        then Some (s@[c], 0) # None # (nupdate c r Ss) 
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1697
                                        else Some ((s@[c]), 0)  # (nupdate c r Ss) 
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1698
                                      ) "
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1699
| "nupdate c r (None # Ss) = (None # nupdate c r Ss)"
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1700
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1701
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1702
fun nupdates :: "char list \<Rightarrow> rrexp \<Rightarrow> (string * nat) option list \<Rightarrow> (string * nat) option list"
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1703
  where
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1704
  "nupdates [] r Ss = Ss"
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1705
| "nupdates (c # cs) r Ss = nupdates cs r (nupdate c r Ss)"
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1706
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1707
fun ntset :: "rrexp \<Rightarrow> nat \<Rightarrow> string \<Rightarrow> (string * nat) option list" where
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1708
  "ntset r (Suc n)  (c # cs) = nupdates cs r [Some ([c], n)]"
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1709
| "ntset r 0 _ = [None]"
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1710
| "ntset r _ [] = []"
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1711
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1712
inductive created_by_ntimes :: "rrexp \<Rightarrow> bool" where
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1713
  "created_by_ntimes RZERO"
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1714
| "created_by_ntimes (RSEQ ra (RNTIMES rb n))"
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1715
| "\<lbrakk>created_by_ntimes r1; created_by_ntimes r2\<rbrakk> \<Longrightarrow> created_by_ntimes (RALT r1 r2)"
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1716
| "\<lbrakk>created_by_ntimes r \<rbrakk> \<Longrightarrow> created_by_ntimes (RALT r RZERO)"
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1717
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1718
fun highest_power_aux :: "(string * nat) option list \<Rightarrow> nat \<Rightarrow> nat" where
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1719
  "highest_power_aux [] n = n"
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1720
| "highest_power_aux (None # rs) n = highest_power_aux rs n"
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1721
| "highest_power_aux (Some (s, n) # rs) m = highest_power_aux rs (max n m)"
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1722
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1723
fun hpower :: "(string * nat) option list \<Rightarrow> nat" where
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1724
  "hpower rs =  highest_power_aux rs 0"
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1725
                        
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1726
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1727
lemma nupdate_mono:
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1728
  shows " (highest_power_aux (nupdate c r optlist) m) \<le> (highest_power_aux optlist m)"
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1729
  apply(induct optlist arbitrary: m)
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1730
   apply simp
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1731
  apply(case_tac a)
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1732
   apply simp
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1733
  apply(case_tac aa)
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1734
  apply(case_tac b)
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1735
   apply simp+
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1736
  done
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1737
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1738
lemma nupdate_mono1:
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1739
  shows "hpower (nupdate c r optlist) \<le> hpower optlist"
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1740
  by (simp add: nupdate_mono)
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1741
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1742
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1743
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1744
lemma cbn_ders_cbn:
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1745
  shows "created_by_ntimes r \<Longrightarrow> created_by_ntimes (rder c r)"
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1746
  apply(induct r rule: created_by_ntimes.induct)
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1747
    apply simp
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1748
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1749
  using created_by_ntimes.intros(1) created_by_ntimes.intros(2) created_by_ntimes.intros(3) apply presburger
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1750
  
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1751
  apply (metis created_by_ntimes.simps rder.simps(5) rder.simps(7))
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1752
  using created_by_star.intros(1) created_by_star.intros(2) apply auto[1]
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1753
  using created_by_ntimes.intros(1) created_by_ntimes.intros(3) apply auto[1]
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1754
  by (metis (mono_tags, lifting) created_by_ntimes.simps list.simps(8) list.simps(9) rder.simps(1) rder.simps(4))
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1755
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1756
lemma ntimes_ders_cbn:
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1757
  shows "created_by_ntimes (rders (RSEQ r' (RNTIMES r n)) s)"
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1758
  apply(induct s rule: rev_induct)
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1759
   apply simp
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1760
  apply (simp add: created_by_ntimes.intros(2))
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1761
  apply(subst rders_append)
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1762
  using cbn_ders_cbn by auto
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1763
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1764
lemma always0:
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1765
  shows "rders RZERO s = RZERO"
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1766
  apply(induct s)
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1767
  by simp+
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1768
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1769
lemma ntimes_ders_cbn1:
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1770
  shows "created_by_ntimes (rders (RNTIMES r n) (c#s))"
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1771
  apply(case_tac n)
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1772
   apply simp
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1773
  using always0 created_by_ntimes.intros(1) apply auto[1]
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1774
  by (simp add: ntimes_ders_cbn)
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1775
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1776
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1777
lemma ntimes_hfau_pushin: 
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1778
  shows "created_by_ntimes r \<Longrightarrow> hflat_aux (rder c r) = concat (map hflat_aux (map (rder c) (hflat_aux r)))"
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1779
  apply(induct r rule: created_by_ntimes.induct)
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1780
  apply simp+
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1781
  done
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1782
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1783
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1784
abbreviation
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1785
  "opterm r SN \<equiv>     case SN of
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1786
                                Some (s, n) \<Rightarrow> RSEQ (rders r s) (RNTIMES r n)
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1787
                            |   None \<Rightarrow> RZERO
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1788
                     
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1789
              
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1790
"
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1791
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1792
fun nonempty_string :: "(string * nat) option \<Rightarrow> bool" where
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1793
  "nonempty_string None = True"
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1794
| "nonempty_string (Some ([], n)) = False"
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1795
| "nonempty_string (Some (c#s, n)) = True"
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1796
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1797
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1798
lemma nupdate_nonempty:
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1799
  shows "\<lbrakk>\<forall>opt \<in> set Ss. nonempty_string opt \<rbrakk> \<Longrightarrow> \<forall>opt \<in> set (nupdate c r Ss). nonempty_string opt"
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1800
  apply(induct c r Ss rule: nupdate.induct)
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1801
     apply(auto)
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1802
  apply (metis Nil_is_append_conv neq_Nil_conv nonempty_string.simps(3))
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1803
  by (metis Nil_is_append_conv neq_Nil_conv nonempty_string.simps(3))
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1804
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1805
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1806
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1807
lemma nupdates_nonempty:
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1808
  shows "\<lbrakk>\<forall>opt \<in> set Ss. nonempty_string opt \<rbrakk> \<Longrightarrow> \<forall>opt \<in> set (nupdates s r Ss). nonempty_string opt"
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1809
  apply(induct s arbitrary: Ss)
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1810
   apply simp
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1811
  apply simp
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1812
  using nupdate_nonempty by presburger
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1813
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1814
lemma nullability1: shows "rnullable (rders r s) = rnullable (rders_simp r s)"
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1815
  by (metis der_simp_nullability rders.simps(1) rders_simp.simps(1) rders_simp_same_simpders)
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1816
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1817
lemma nupdate_induct1:
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1818
  shows 
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1819
  "concat (map (hflat_aux \<circ> (rder c \<circ> (opterm r)))  sl ) = 
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1820
   map (opterm r) (nupdate c r sl)"
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1821
  apply(induct sl)
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1822
   apply simp
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1823
  apply(simp add: rders_append)
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1824
  apply(case_tac "a")
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1825
   apply simp+
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1826
  apply(case_tac "aa")
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1827
  apply(case_tac "b")
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1828
  apply(case_tac "rnullable (rders r ab)")
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1829
  apply(subgoal_tac "rnullable (rders_simp r ab)")
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1830
    apply simp
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1831
  using rders.simps(1) rders.simps(2) rders_append apply presburger
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1832
  using nullability1 apply blast
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1833
   apply simp
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1834
  using rders.simps(1) rders.simps(2) rders_append apply presburger
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1835
  apply simp
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1836
  using rders.simps(1) rders.simps(2) rders_append by presburger
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1837
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1838
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1839
lemma nupdates_join_general:
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1840
  shows  "concat (map hflat_aux (map (rder x) (map (opterm r) (nupdates xs r Ss))  )) =
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1841
           map (opterm r) (nupdates (xs @ [x]) r Ss)"
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1842
  apply(induct xs arbitrary: Ss)
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1843
   apply (simp)
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1844
  prefer 2
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1845
   apply auto[1]
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1846
  using nupdate_induct1 by blast
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1847
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1848
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1849
lemma nupdates_join_general1:
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1850
  shows  "concat (map (hflat_aux \<circ> (rder x) \<circ> (opterm r)) (nupdates xs r Ss)) =
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1851
           map (opterm r) (nupdates (xs @ [x]) r Ss)"
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1852
  by (metis list.map_comp nupdates_join_general)
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1853
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1854
lemma nupdates_append: shows 
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1855
"nupdates (s @ [c]) r Ss = nupdate c r (nupdates s r Ss)"
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1856
  apply(induct s arbitrary: Ss)
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1857
   apply simp
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1858
  apply simp
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1859
  done
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1860
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1861
lemma nupdates_mono:
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1862
  shows "highest_power_aux (nupdates s r optlist) m \<le> highest_power_aux optlist m"
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1863
  apply(induct s rule: rev_induct)
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1864
   apply simp
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1865
  apply(subst nupdates_append)
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1866
  by (meson le_trans nupdate_mono)
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1867
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1868
lemma nupdates_mono1:
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1869
  shows "hpower (nupdates s r optlist) \<le> hpower optlist"
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1870
  by (simp add: nupdates_mono)
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1871
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1872
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1873
(*"\<forall>r \<in> set (nupdates s r [Some ([c], n)]). r = None \<or>( \<exists>s' m. r = Some (s', m) \<and> m \<le> n)"*)
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1874
lemma nupdates_mono2:
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1875
  shows "hpower (nupdates s r [Some ([c], n)]) \<le> n"
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1876
  by (metis highest_power_aux.simps(1) highest_power_aux.simps(3) hpower.simps max_nat.right_neutral nupdates_mono1)
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1877
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1878
lemma hpow_arg_mono:
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1879
  shows "m \<ge> n \<Longrightarrow> highest_power_aux rs m \<ge> highest_power_aux rs n"
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1880
  apply(induct rs arbitrary: m n)
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1881
   apply simp
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1882
  apply(case_tac a)
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1883
   apply simp
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1884
  apply(case_tac aa)
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1885
  apply simp
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1886
  done
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1887
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1888
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1889
lemma hpow_increase:
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1890
  shows "highest_power_aux (a # rs') m \<ge> highest_power_aux rs' m"
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1891
  apply(case_tac a)
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1892
   apply simp
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1893
  apply simp
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1894
  apply(case_tac aa)
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1895
  apply(case_tac b)
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1896
   apply simp+
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1897
  apply(case_tac "Suc nat > m")
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1898
  using hpow_arg_mono max.cobounded2 apply blast
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1899
  using hpow_arg_mono max.cobounded2 by blast
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1900
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1901
lemma hpow_append:
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1902
  shows "highest_power_aux (rsa @ rsb) m  = highest_power_aux rsb (highest_power_aux rsa m)"
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1903
  apply (induct rsa arbitrary: rsb m)
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1904
   apply simp
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1905
  apply simp
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1906
  apply(case_tac a)
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1907
   apply simp
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1908
  apply(case_tac aa)
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1909
  apply simp
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1910
  done
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1911
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1912
lemma hpow_aux_mono:
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1913
  shows "highest_power_aux (rsa @ rsb) m \<ge> highest_power_aux rsb m"
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1914
  apply(induct rsa arbitrary: rsb rule: rev_induct)
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1915
  apply simp
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1916
  apply simp
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1917
  using hpow_increase order.trans by blast
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1918
 
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1919
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1920
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1921
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1922
lemma hpow_mono:
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1923
  shows "hpower (rsa @ rsb) \<le> n \<Longrightarrow> hpower rsb \<le> n"
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1924
  apply(induct rsb arbitrary: rsa)
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1925
   apply simp
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1926
  apply(subgoal_tac "hpower rsb \<le> n")
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1927
  apply simp
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1928
  apply (metis dual_order.trans hpow_aux_mono)
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1929
  by (metis hpow_append hpow_increase hpower.simps nat_le_iff_add trans_le_add1)
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1930
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1931
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1932
lemma hpower_rs_elems_aux:
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1933
  shows "highest_power_aux rs k \<le> n \<Longrightarrow> \<forall>r\<in>set rs. r = None \<or> (\<exists>s' m. r = Some (s', m) \<and> m \<le> n)"
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1934
apply(induct rs k arbitrary: n rule: highest_power_aux.induct)
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1935
    apply(auto)
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1936
  by (metis dual_order.trans highest_power_aux.simps(1) hpow_append hpow_aux_mono linorder_le_cases max.absorb1 max.absorb2)
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1937
495
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  1938
563
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1939
lemma hpower_rs_elems:
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1940
  shows "hpower rs \<le> n \<Longrightarrow> \<forall>r \<in> set rs. r = None \<or>( \<exists>s' m. r = Some (s', m) \<and> m \<le> n)"
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1941
  by (simp add: hpower_rs_elems_aux)
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1942
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1943
lemma nupdates_elems_leqn:
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1944
  shows "\<forall>r \<in> set (nupdates s r [Some ([c], n)]). r = None \<or>( \<exists>s' m. r = Some (s', m) \<and> m \<le> n)"
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1945
  by (meson hpower_rs_elems nupdates_mono2)
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1946
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1947
lemma ntimes_hfau_induct:
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1948
  shows "hflat_aux (rders (RSEQ (rder c r) (RNTIMES r n)) s) =   
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1949
      map (opterm r) (nupdates s r [Some ([c], n)])"
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1950
  apply(induct s rule: rev_induct)
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1951
   apply simp
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1952
  apply(subst rders_append)+
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1953
  apply simp
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1954
  apply(subst nupdates_append)
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1955
  apply(subgoal_tac "created_by_ntimes (rders (RSEQ (rder c r) (RNTIMES r n)) xs)")
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1956
  prefer 2
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1957
  apply (simp add: ntimes_ders_cbn)
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1958
  apply(subst ntimes_hfau_pushin)
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1959
   apply simp
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1960
  apply(subgoal_tac "concat (map hflat_aux (map (rder x) (hflat_aux (rders (RSEQ (rder c r) (RNTIMES r n)) xs)))) =
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1961
                     concat (map hflat_aux (map (rder x) ( map (opterm r) (nupdates xs r [Some ([c], n)])))) ")
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1962
   apply(simp only:)
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1963
  prefer 2
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1964
   apply presburger
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1965
  apply(subst nupdates_append[symmetric])  
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1966
  using nupdates_join_general by blast
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1967
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1968
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1969
(*nupdates s r [Some ([c], n)]*)
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1970
lemma ntimes_ders_hfau_also1:
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1971
  shows "hflat_aux (rders (RNTIMES r (Suc n)) (c # xs)) = map (opterm r) (nupdates xs r [Some ([c], n)])"
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1972
  using ntimes_hfau_induct by force
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1973
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1974
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1975
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1976
lemma hfau_rsimpeq2_ntimes:
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1977
  shows "created_by_ntimes r \<Longrightarrow> rsimp r = rsimp ( (RALTS (hflat_aux r)))"
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1978
  apply(induct r)
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1979
       apply simp+
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1980
  
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1981
    apply (metis rsimp_seq_equal1)
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1982
  prefer 2
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1983
   apply simp
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1984
  apply(case_tac x)
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1985
   apply simp
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1986
  apply(case_tac "list")
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1987
   apply simp
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1988
  
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1989
  apply (metis idem_after_simp1)
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1990
  apply(case_tac "lista")
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1991
  prefer 2
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1992
   apply (metis hflat_aux.simps(8) idem_after_simp1 list.simps(8) list.simps(9) rsimp.simps(2))
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1993
  apply(subgoal_tac "rsimp (RALT a aa) = rsimp (RALTS (hflat_aux (RALT a aa)))")
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1994
  apply simp
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1995
  apply(subgoal_tac "rsimp (RALT a aa) = rsimp (RALTS (hflat_aux a @ hflat_aux aa))")
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1996
  using hflat_aux.simps(1) apply presburger
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1997
  apply simp
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1998
  using cbs_hfau_rsimpeq1 apply(fastforce)
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  1999
  by simp
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2000
  
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2001
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2002
lemma ntimes_closed_form1:
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2003
  shows "rsimp (rders (RNTIMES r (Suc n)) (c#s)) = 
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2004
rsimp ( ( RALTS (  map (opterm r) (nupdates s r [Some ([c], n)]) )))"
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2005
  apply(subgoal_tac "created_by_ntimes (rders (RNTIMES r (Suc n)) (c#s))")
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2006
   apply(subst hfau_rsimpeq2_ntimes)
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2007
  apply linarith
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2008
  using ntimes_ders_hfau_also1 apply auto[1]
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2009
  using ntimes_ders_cbn1 by blast
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2010
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2011
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2012
lemma ntimes_closed_form2:
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2013
  shows  "rsimp (rders_simp (RNTIMES r (Suc n)) (c#s) ) = 
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2014
rsimp ( ( RALTS ( (map (opterm r ) (nupdates s r [Some ([c], n)]) ) )))"
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2015
  by (metis list.distinct(1) ntimes_closed_form1 rders_simp_same_simpders rsimp_idem)
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2016
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2017
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2018
lemma ntimes_closed_form3:
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2019
  shows  "rsimp (rders_simp (RNTIMES r n) (c#s)) =   (rders_simp (RNTIMES r n) (c#s))"
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2020
  by (metis list.distinct(1) rders_simp_same_simpders rsimp_idem)
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2021
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2022
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2023
lemma ntimes_closed_form4:
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2024
  shows " (rders_simp (RNTIMES r (Suc n)) (c#s)) = 
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2025
rsimp ( ( RALTS ( (map (opterm r ) (nupdates s r [Some ([c], n)]) )  )))"
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2026
  using ntimes_closed_form2 ntimes_closed_form3 
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2027
  by metis
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2028
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2029
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2030
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2031
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2032
lemma ntimes_closed_form5:
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2033
  shows " rsimp (  RALTS (map (\<lambda>s1. RSEQ (rders r0 s1) (RNTIMES r n) )         Ss)) = 
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2034
          rsimp (  RALTS (map (\<lambda>s1. rsimp (RSEQ (rders r0 s1) (RNTIMES r n)) ) Ss))"
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2035
  by (smt (verit, ccfv_SIG) list.map_comp map_eq_conv o_apply simp_flatten_aux0)
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2036
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2037
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2038
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2039
lemma ntimes_closed_form6_hrewrites:
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2040
  shows "  
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2041
(map (\<lambda>s1. (RSEQ (rsimp (rders r0 s1)) (RNTIMES r0 n)) ) Ss )
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2042
 scf\<leadsto>*
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2043
(map (\<lambda>s1. rsimp (RSEQ (rders r0 s1) (RNTIMES r0 n)) ) Ss )"
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2044
  apply(induct Ss)
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2045
  apply simp
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2046
  apply (simp add: ss1)
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2047
  by (metis (no_types, lifting) list.simps(9) rsimp.simps(1) rsimp_idem simp_hrewrites ss2)
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2048
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2049
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2050
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2051
lemma ntimes_closed_form6:
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2052
  shows " rsimp ( ( RALTS ( (map (\<lambda>s1. rsimp (RSEQ (rders r0 s1) (RNTIMES r0 n)) ) Ss )))) = 
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2053
          rsimp ( ( RALTS ( (map (\<lambda>s1.  (RSEQ (rsimp (rders r0 s1)) (RNTIMES r0 n)) ) Ss ))))"
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2054
  apply(subgoal_tac " map (\<lambda>s1.  (RSEQ (rsimp (rders r0 s1)) (RNTIMES r0 n)) ) Ss  scf\<leadsto>*
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2055
                      map (\<lambda>s1.  rsimp (RSEQ  (rders r0 s1) (RNTIMES r0 n)) ) Ss ")
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2056
  using hrewrites_simpeq srewritescf_alt1 apply fastforce
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2057
  using ntimes_closed_form6_hrewrites by blast
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2058
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2059
abbreviation
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2060
  "optermsimp r SN \<equiv>     case SN of
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2061
                                Some (s, n) \<Rightarrow> RSEQ (rders_simp r s) (RNTIMES r n)
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2062
                            |   None \<Rightarrow> RZERO
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2063
                     
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2064
              
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2065
"
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2066
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2067
abbreviation
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2068
  "optermOsimp r SN \<equiv>     case SN of
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2069
                                Some (s, n) \<Rightarrow> rsimp (RSEQ (rders r s) (RNTIMES r n))
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2070
                            |   None \<Rightarrow> RZERO
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2071
                     
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2072
              
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2073
"
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2074
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2075
abbreviation
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2076
  "optermosimp r SN \<equiv> case SN of
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2077
                              Some (s, n) \<Rightarrow> RSEQ (rsimp (rders r s)) (RNTIMES r n)
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2078
                            | None \<Rightarrow> RZERO
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2079
"
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2080
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2081
lemma ntimes_closed_form51:
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2082
  shows "rsimp (RALTS (map (opterm r) (nupdates s r [Some ([c], n)]))) =
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2083
         rsimp (RALTS (map (rsimp \<circ> (opterm r)) (nupdates s r [Some ([c], n)])))"
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2084
  by (metis map_map simp_flatten_aux0)
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2085
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2086
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2087
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2088
lemma osimp_Osimp:
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2089
  shows " nonempty_string sn \<Longrightarrow> optermosimp r sn = optermsimp r sn"
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2090
  apply(induct rule: nonempty_string.induct)
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2091
  apply force
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2092
   apply auto[1]
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2093
  apply simp
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2094
  by (metis list.distinct(1) rders.simps(2) rders_simp.simps(2) rders_simp_same_simpders)
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2095
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2096
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2097
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2098
lemma osimp_Osimp_list:
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2099
  shows "\<forall>sn \<in> set snlist. nonempty_string sn \<Longrightarrow> map (optermosimp r) snlist = map (optermsimp r) snlist"
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2100
  by (simp add: osimp_Osimp)
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2101
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2102
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2103
lemma ntimes_closed_form8:
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2104
  shows  
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2105
"rsimp (RALTS (map (optermosimp r) (nupdates s r [Some ([c], n)]))) =
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2106
 rsimp (RALTS (map (optermsimp r) (nupdates s r [Some ([c], n)])))"
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2107
  apply(subgoal_tac "\<forall>opt \<in> set (nupdates s r [Some ([c], n)]). nonempty_string opt")
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2108
  using osimp_Osimp_list apply presburger
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2109
  by (metis list.distinct(1) list.set_cases nonempty_string.simps(3) nupdates_nonempty set_ConsD)
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2110
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2111
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2112
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2113
lemma ntimes_closed_form9aux:
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2114
  shows "\<forall>snopt \<in> set (nupdates s r [Some ([c], n)]). nonempty_string snopt"
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2115
  by (metis list.distinct(1) list.set_cases nonempty_string.simps(3) nupdates_nonempty set_ConsD)
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2116
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2117
lemma ntimes_closed_form9aux1:
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2118
  shows  "\<forall>snopt \<in> set snlist. nonempty_string snopt \<Longrightarrow> 
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2119
rsimp (RALTS (map (optermosimp r) snlist)) =
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2120
rsimp (RALTS (map (optermOsimp r) snlist))"
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2121
  apply(induct snlist)
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2122
   apply simp+
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2123
  apply(case_tac "a")
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2124
   apply simp+
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2125
  by (smt (z3) case_prod_conv idem_after_simp1 map_eq_conv nonempty_string.elims(2) o_apply option.simps(4) option.simps(5) rsimp.simps(1) rsimp.simps(7) rsimp_idem)
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2126
  
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2127
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2128
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2129
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2130
lemma ntimes_closed_form9:
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2131
  shows  
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2132
"rsimp (RALTS (map (optermosimp r) (nupdates s r [Some ([c], n)]))) =
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2133
 rsimp (RALTS (map (optermOsimp r) (nupdates s r [Some ([c], n)])))"
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2134
  using ntimes_closed_form9aux ntimes_closed_form9aux1 by presburger
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2135
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2136
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2137
lemma ntimes_closed_form10rewrites_aux:
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2138
  shows "  map (rsimp \<circ> (opterm r)) optlist scf\<leadsto>* 
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2139
           map (optermOsimp r)      optlist"
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2140
  apply(induct optlist)
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2141
   apply simp
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2142
   apply (simp add: ss1)
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2143
  apply simp
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2144
  apply(case_tac a)
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2145
  using ss2 apply fastforce
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2146
  using ss2 by force
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2147
  
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2148
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2149
lemma ntimes_closed_form10rewrites:
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2150
  shows "  map (rsimp \<circ> (opterm r)) (nupdates s r [Some ([c], n)]) scf\<leadsto>* 
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2151
           map (optermOsimp r) (nupdates s r [Some ([c], n)])"
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2152
  using ntimes_closed_form10rewrites_aux by blast
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2153
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2154
lemma ntimes_closed_form10:
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2155
  shows "rsimp (RALTS (map (rsimp \<circ> (opterm r)) (nupdates s r [Some ([c], n)]))) = 
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2156
         rsimp (RALTS (map (optermOsimp r) (nupdates s r [Some ([c], n)])))"
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2157
  by (smt (verit, best) case_prod_conv hpower_rs_elems map_eq_conv nupdates_mono2 o_apply option.case(2) option.simps(4) rsimp.simps(3))
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2158
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2159
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2160
lemma rders_simp_cons:
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2161
  shows "rders_simp r (c # s) = rders_simp (rsimp (rder c r)) s"
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2162
  by simp
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2163
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2164
lemma rder_ntimes:
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2165
  shows "rder c (RNTIMES r (Suc n)) = RSEQ (rder c r) (RNTIMES r n)"
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2166
  by simp
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2167
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2168
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2169
lemma ntimes_closed_form:
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2170
  shows "rders_simp (RNTIMES r0 (Suc n)) (c#s) = 
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2171
rsimp ( RALTS ( (map (optermsimp r0 ) (nupdates s r0 [Some ([c], n)]) ) ))"
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2172
  apply (subst rders_simp_cons)
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2173
  apply(subst rder_ntimes)  
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2174
  using ntimes_closed_form10 ntimes_closed_form4 ntimes_closed_form51 ntimes_closed_form8 ntimes_closed_form9 by force
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2175
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2176
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2177
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2178
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2179
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2180
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2181
(*
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2182
lemma ntimes_closed_form:
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2183
  assumes "s \<noteq> []"
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2184
  shows "rders_simp (RNTIMES r (Suc n)) s = 
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2185
rsimp ( RALTS  (     map 
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2186
                     (\<lambda> optSN. case optSN of
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2187
                                Some (s, n) \<Rightarrow> RSEQ (rders_simp r s) (RNTIMES r n)
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2188
                            |   None \<Rightarrow> RZERO
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2189
                     ) 
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2190
                     (ntset r n s) 
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2191
               )
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2192
      )"
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2193
  
c92a41d9c4da updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents: 496
diff changeset
  2194
*)
495
f9cdc295ccf7 a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
  2195
end