thys3/HarderProps.thy
author Chengsong
Mon, 03 Oct 2022 02:08:49 +0100
changeset 609 61139fdddae0
parent 556 c27f04bb2262
permissions -rw-r--r--
chap1 totally done
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
556
Chengsong
parents:
diff changeset
     1
theory HarderProps imports BasicIdentities
Chengsong
parents:
diff changeset
     2
begin
Chengsong
parents:
diff changeset
     3
Chengsong
parents:
diff changeset
     4
Chengsong
parents:
diff changeset
     5
Chengsong
parents:
diff changeset
     6
Chengsong
parents:
diff changeset
     7
lemma spawn_simp_rsimpalts:
Chengsong
parents:
diff changeset
     8
  shows "rsimp (rsimp_ALTs rs) = rsimp (rsimp_ALTs (map rsimp rs))"
Chengsong
parents:
diff changeset
     9
  apply(cases rs)
Chengsong
parents:
diff changeset
    10
   apply simp
Chengsong
parents:
diff changeset
    11
  apply(case_tac list)
Chengsong
parents:
diff changeset
    12
   apply simp
Chengsong
parents:
diff changeset
    13
   apply(subst rsimp_idem[symmetric])
Chengsong
parents:
diff changeset
    14
   apply simp
Chengsong
parents:
diff changeset
    15
  apply(subgoal_tac "rsimp_ALTs rs = RALTS rs")
Chengsong
parents:
diff changeset
    16
   apply(simp only:)
Chengsong
parents:
diff changeset
    17
   apply(subgoal_tac "rsimp_ALTs (map rsimp rs) = RALTS (map rsimp rs)")
Chengsong
parents:
diff changeset
    18
    apply(simp only:)
Chengsong
parents:
diff changeset
    19
  prefer 2
Chengsong
parents:
diff changeset
    20
  apply simp
Chengsong
parents:
diff changeset
    21
   prefer 2
Chengsong
parents:
diff changeset
    22
  using rsimp_ALTs.simps(3) apply presburger
Chengsong
parents:
diff changeset
    23
  apply auto
Chengsong
parents:
diff changeset
    24
  apply(subst rsimp_idem)+
Chengsong
parents:
diff changeset
    25
  by (metis comp_apply rsimp_idem)
Chengsong
parents:
diff changeset
    26
Chengsong
parents:
diff changeset
    27
Chengsong
parents:
diff changeset
    28
Chengsong
parents:
diff changeset
    29
Chengsong
parents:
diff changeset
    30
lemma good1_rsimpalts:
Chengsong
parents:
diff changeset
    31
  shows "rsimp r = RALTS rs \<Longrightarrow> rsimp_ALTs rs = RALTS rs"
Chengsong
parents:
diff changeset
    32
  by (metis no_alt_short_list_after_simp) 
Chengsong
parents:
diff changeset
    33
  
Chengsong
parents:
diff changeset
    34
Chengsong
parents:
diff changeset
    35
Chengsong
parents:
diff changeset
    36
Chengsong
parents:
diff changeset
    37
lemma good1_flatten:
Chengsong
parents:
diff changeset
    38
  shows "\<lbrakk> rsimp r =  (RALTS rs1)\<rbrakk>
Chengsong
parents:
diff changeset
    39
       \<Longrightarrow> rflts (rsimp_ALTs rs1 # map rsimp rsb) = rflts (rs1 @ map rsimp rsb)"
Chengsong
parents:
diff changeset
    40
  apply(subst good1_rsimpalts)
Chengsong
parents:
diff changeset
    41
   apply simp+
Chengsong
parents:
diff changeset
    42
  apply(subgoal_tac "rflts (rs1 @ map rsimp rsb) = rs1 @ rflts (map rsimp rsb)")
Chengsong
parents:
diff changeset
    43
   apply simp
Chengsong
parents:
diff changeset
    44
  using flts_append rsimp_inner_idem4 by presburger
Chengsong
parents:
diff changeset
    45
Chengsong
parents:
diff changeset
    46
  
Chengsong
parents:
diff changeset
    47
lemma flatten_rsimpalts:
Chengsong
parents:
diff changeset
    48
  shows "rflts (rsimp_ALTs (rdistinct (rflts (map rsimp rsa)) {}) # map rsimp rsb) = 
Chengsong
parents:
diff changeset
    49
         rflts ( (rdistinct (rflts (map rsimp rsa)) {}) @ map rsimp rsb)"
Chengsong
parents:
diff changeset
    50
  apply(case_tac "map rsimp rsa")
Chengsong
parents:
diff changeset
    51
   apply simp
Chengsong
parents:
diff changeset
    52
  apply(case_tac "list")
Chengsong
parents:
diff changeset
    53
   apply simp
Chengsong
parents:
diff changeset
    54
   apply(case_tac a)
Chengsong
parents:
diff changeset
    55
        apply simp+
Chengsong
parents:
diff changeset
    56
    apply(rename_tac rs1)
Chengsong
parents:
diff changeset
    57
    apply (metis good1_flatten map_eq_Cons_D no_further_dB_after_simp)
Chengsong
parents:
diff changeset
    58
  
Chengsong
parents:
diff changeset
    59
  apply simp
Chengsong
parents:
diff changeset
    60
  
Chengsong
parents:
diff changeset
    61
  apply(subgoal_tac "\<forall>r \<in> set( rflts (map rsimp rsa)). good r")
Chengsong
parents:
diff changeset
    62
   apply(case_tac "rdistinct (rflts (map rsimp rsa)) {}")
Chengsong
parents:
diff changeset
    63
    apply simp
Chengsong
parents:
diff changeset
    64
   apply(case_tac "listb")
Chengsong
parents:
diff changeset
    65
    apply simp+
Chengsong
parents:
diff changeset
    66
  apply (metis Cons_eq_appendI good1_flatten rflts.simps(3) rsimp.simps(2) rsimp_ALTs.simps(3))
Chengsong
parents:
diff changeset
    67
  by (metis (mono_tags, lifting) flts3 good1 image_iff list.set_map)
Chengsong
parents:
diff changeset
    68
Chengsong
parents:
diff changeset
    69
Chengsong
parents:
diff changeset
    70
Chengsong
parents:
diff changeset
    71
Chengsong
parents:
diff changeset
    72
Chengsong
parents:
diff changeset
    73
Chengsong
parents:
diff changeset
    74
lemma simp_flatten:
Chengsong
parents:
diff changeset
    75
  shows "rsimp (RALTS ((RALTS rsa) # rsb)) = rsimp (RALTS (rsa @ rsb))"
Chengsong
parents:
diff changeset
    76
  apply simp
Chengsong
parents:
diff changeset
    77
  apply(subst flatten_rsimpalts)
Chengsong
parents:
diff changeset
    78
  apply(simp add: flts_append)
Chengsong
parents:
diff changeset
    79
  by (metis Diff_empty distinct_once_enough flts_append nonalt0_fltseq nonalt_flts_rd qqq1 rdistinct_set_equality1)
Chengsong
parents:
diff changeset
    80
Chengsong
parents:
diff changeset
    81
Chengsong
parents:
diff changeset
    82
Chengsong
parents:
diff changeset
    83
Chengsong
parents:
diff changeset
    84
Chengsong
parents:
diff changeset
    85
lemma simp_flatten_aux0:
Chengsong
parents:
diff changeset
    86
  shows "rsimp (RALTS rs) = rsimp (RALTS (map rsimp rs))"
Chengsong
parents:
diff changeset
    87
  apply(induct rs)
Chengsong
parents:
diff changeset
    88
   apply simp+
Chengsong
parents:
diff changeset
    89
  by (metis (mono_tags, opaque_lifting) comp_eq_dest_lhs map_eq_conv rsimp_idem)
Chengsong
parents:
diff changeset
    90
  
Chengsong
parents:
diff changeset
    91
Chengsong
parents:
diff changeset
    92
Chengsong
parents:
diff changeset
    93
Chengsong
parents:
diff changeset
    94
Chengsong
parents:
diff changeset
    95
Chengsong
parents:
diff changeset
    96
lemma good_singleton:
Chengsong
parents:
diff changeset
    97
  shows "good a \<and> nonalt a  \<Longrightarrow> rflts [a] = [a]"
Chengsong
parents:
diff changeset
    98
  using good.simps(1) k0b by blast
Chengsong
parents:
diff changeset
    99
Chengsong
parents:
diff changeset
   100
Chengsong
parents:
diff changeset
   101
Chengsong
parents:
diff changeset
   102
Chengsong
parents:
diff changeset
   103
Chengsong
parents:
diff changeset
   104
lemma good_flatten_aux_aux1:
Chengsong
parents:
diff changeset
   105
  shows "\<lbrakk> size rs \<ge>2; 
Chengsong
parents:
diff changeset
   106
\<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>
Chengsong
parents:
diff changeset
   107
       \<Longrightarrow> rdistinct (rs @ rsb) rset =
Chengsong
parents:
diff changeset
   108
           rdistinct (rflts [rsimp_ALTs (rdistinct rs {})] @ rsb) rset"
Chengsong
parents:
diff changeset
   109
  apply(induct rs arbitrary: rset)
Chengsong
parents:
diff changeset
   110
   apply simp
Chengsong
parents:
diff changeset
   111
  apply(case_tac "a \<in> rset")
Chengsong
parents:
diff changeset
   112
   apply simp
Chengsong
parents:
diff changeset
   113
   apply(case_tac "rdistinct rs {a}")
Chengsong
parents:
diff changeset
   114
    apply simp
Chengsong
parents:
diff changeset
   115
    apply(subst good_singleton)
Chengsong
parents:
diff changeset
   116
     apply force
Chengsong
parents:
diff changeset
   117
  apply simp
Chengsong
parents:
diff changeset
   118
    apply (meson all_that_same_elem)
Chengsong
parents:
diff changeset
   119
   apply(subgoal_tac "rflts [rsimp_ALTs (a # rdistinct rs {a})] = a # rdistinct rs {a} ")
Chengsong
parents:
diff changeset
   120
  prefer 2
Chengsong
parents:
diff changeset
   121
  using k0a rsimp_ALTs.simps(3) apply presburger
Chengsong
parents:
diff changeset
   122
  apply(simp only:)
Chengsong
parents:
diff changeset
   123
  apply(subgoal_tac "rdistinct (rs @ rsb) rset = rdistinct ((rdistinct (a # rs) {}) @ rsb) rset ")
Chengsong
parents:
diff changeset
   124
    apply (metis insert_absorb insert_is_Un insert_not_empty rdistinct.simps(2))
Chengsong
parents:
diff changeset
   125
   apply (meson distinct_eq_interesting1)
Chengsong
parents:
diff changeset
   126
  apply simp
Chengsong
parents:
diff changeset
   127
  apply(case_tac "rdistinct rs {a}")
Chengsong
parents:
diff changeset
   128
  prefer 2
Chengsong
parents:
diff changeset
   129
   apply(subgoal_tac "rsimp_ALTs (a # rdistinct rs {a}) = RALTS (a # rdistinct rs {a})")
Chengsong
parents:
diff changeset
   130
  apply(simp only:)
Chengsong
parents:
diff changeset
   131
  apply(subgoal_tac "a # rdistinct (rs @ rsb) (insert a rset) =
Chengsong
parents:
diff changeset
   132
           rdistinct (rflts [RALTS (a # rdistinct rs {a})] @ rsb) rset")
Chengsong
parents:
diff changeset
   133
   apply simp
Chengsong
parents:
diff changeset
   134
  apply (metis append_Cons distinct_early_app empty_iff insert_is_Un k0a rdistinct.simps(2))
Chengsong
parents:
diff changeset
   135
  using rsimp_ALTs.simps(3) apply presburger
Chengsong
parents:
diff changeset
   136
  by (metis Un_insert_left append_Cons distinct_early_app empty_iff good_singleton rdistinct.simps(2) rsimp_ALTs.simps(2) sup_bot_left)
Chengsong
parents:
diff changeset
   137
Chengsong
parents:
diff changeset
   138
Chengsong
parents:
diff changeset
   139
Chengsong
parents:
diff changeset
   140
  
Chengsong
parents:
diff changeset
   141
Chengsong
parents:
diff changeset
   142
lemma good_flatten_aux_aux:
Chengsong
parents:
diff changeset
   143
  shows "\<lbrakk>\<exists>a aa lista list. rs = a # list \<and> list = aa # lista; 
Chengsong
parents:
diff changeset
   144
\<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>
Chengsong
parents:
diff changeset
   145
       \<Longrightarrow> rdistinct (rs @ rsb) rset =
Chengsong
parents:
diff changeset
   146
           rdistinct (rflts [rsimp_ALTs (rdistinct rs {})] @ rsb) rset"
Chengsong
parents:
diff changeset
   147
  apply(erule exE)+
Chengsong
parents:
diff changeset
   148
  apply(subgoal_tac "size rs \<ge> 2")
Chengsong
parents:
diff changeset
   149
   apply (metis good_flatten_aux_aux1)
Chengsong
parents:
diff changeset
   150
  by (simp add: Suc_leI length_Cons less_add_Suc1)
Chengsong
parents:
diff changeset
   151
Chengsong
parents:
diff changeset
   152
Chengsong
parents:
diff changeset
   153
Chengsong
parents:
diff changeset
   154
lemma good_flatten_aux:
Chengsong
parents:
diff changeset
   155
  shows " \<lbrakk>\<forall>r\<in>set rs. good r \<or> r = RZERO; \<forall>r\<in>set rsa . good r \<or> r = RZERO; 
Chengsong
parents:
diff changeset
   156
           \<forall>r\<in>set rsb. good r \<or> r = RZERO;
Chengsong
parents:
diff changeset
   157
     rsimp (RALTS (rsa @ rs @ rsb)) = rsimp_ALTs (rdistinct (rflts (rsa @ rs @ rsb)) {});
Chengsong
parents:
diff changeset
   158
     rsimp (RALTS (rsa @ [RALTS rs] @ rsb)) =
Chengsong
parents:
diff changeset
   159
     rsimp_ALTs (rdistinct (rflts (rsa @ [rsimp (RALTS rs)] @ rsb)) {});
Chengsong
parents:
diff changeset
   160
     map rsimp rsa = rsa; 
Chengsong
parents:
diff changeset
   161
     map rsimp rsb = rsb; 
Chengsong
parents:
diff changeset
   162
     map rsimp rs = rs;
Chengsong
parents:
diff changeset
   163
     rdistinct (rflts rsa @ rflts rs @ rflts rsb) {} =
Chengsong
parents:
diff changeset
   164
     rdistinct (rflts rsa) {} @ rdistinct (rflts rs @ rflts rsb) (set (rflts rsa));
Chengsong
parents:
diff changeset
   165
     rdistinct (rflts rsa @ rflts [rsimp (RALTS rs)] @ rflts rsb) {} =
Chengsong
parents:
diff changeset
   166
     rdistinct (rflts rsa) {} @ rdistinct (rflts [rsimp (RALTS rs)] @ rflts rsb) (set (rflts rsa))\<rbrakk>
Chengsong
parents:
diff changeset
   167
    \<Longrightarrow>    rdistinct (rflts rs @ rflts rsb) rset =
Chengsong
parents:
diff changeset
   168
           rdistinct (rflts [rsimp (RALTS rs)] @ rflts rsb) rset"
Chengsong
parents:
diff changeset
   169
  apply simp
Chengsong
parents:
diff changeset
   170
  apply(case_tac "rflts rs ")
Chengsong
parents:
diff changeset
   171
   apply simp
Chengsong
parents:
diff changeset
   172
  apply(case_tac "list")
Chengsong
parents:
diff changeset
   173
   apply simp
Chengsong
parents:
diff changeset
   174
   apply(case_tac "a \<in> rset")
Chengsong
parents:
diff changeset
   175
    apply simp
Chengsong
parents:
diff changeset
   176
  apply (metis append.left_neutral append_Cons equals0D k0b list.set_intros(1) nonalt_flts_rd qqq1 rdistinct.simps(2))
Chengsong
parents:
diff changeset
   177
   apply simp
Chengsong
parents:
diff changeset
   178
  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)
Chengsong
parents:
diff changeset
   179
  apply(subgoal_tac "\<forall>r \<in> set (rflts rs). good r \<and> r \<noteq> RZERO \<and> nonalt r")
Chengsong
parents:
diff changeset
   180
   prefer 2
Chengsong
parents:
diff changeset
   181
  apply (metis Diff_empty flts3 nonalt_flts_rd qqq1 rdistinct_set_equality1)  
Chengsong
parents:
diff changeset
   182
  apply(subgoal_tac "\<forall>r \<in> set (rflts rsb). good r \<and> r \<noteq> RZERO \<and> nonalt r")
Chengsong
parents:
diff changeset
   183
   prefer 2
Chengsong
parents:
diff changeset
   184
  apply (metis Diff_empty flts3 good.simps(1) nonalt_flts_rd rdistinct_set_equality1)  
Chengsong
parents:
diff changeset
   185
  by (smt (verit, ccfv_threshold) good_flatten_aux_aux)
Chengsong
parents:
diff changeset
   186
Chengsong
parents:
diff changeset
   187
  
Chengsong
parents:
diff changeset
   188
Chengsong
parents:
diff changeset
   189
Chengsong
parents:
diff changeset
   190
lemma good_flatten_middle:
Chengsong
parents:
diff changeset
   191
  shows "\<lbrakk>\<forall>r \<in> set rs. good r \<or> r = RZERO; 
Chengsong
parents:
diff changeset
   192
          \<forall>r \<in> set rsa. good r \<or> r = RZERO; 
Chengsong
parents:
diff changeset
   193
          \<forall>r \<in> set rsb. good r \<or> r = RZERO\<rbrakk> \<Longrightarrow>
Chengsong
parents:
diff changeset
   194
rsimp (RALTS (rsa @ rs @ rsb)) = 
Chengsong
parents:
diff changeset
   195
rsimp (RALTS (rsa @ [RALTS rs] @ rsb))"
Chengsong
parents:
diff changeset
   196
  apply(subgoal_tac "rsimp (RALTS (rsa @ rs @ rsb)) = rsimp_ALTs (rdistinct (rflts (map rsimp rsa @ 
Chengsong
parents:
diff changeset
   197
map rsimp rs @ map rsimp rsb)) {})")
Chengsong
parents:
diff changeset
   198
  prefer 2
Chengsong
parents:
diff changeset
   199
  apply simp
Chengsong
parents:
diff changeset
   200
  apply(simp only:)
Chengsong
parents:
diff changeset
   201
    apply(subgoal_tac "rsimp (RALTS (rsa @ [RALTS rs] @ rsb)) = rsimp_ALTs (rdistinct (rflts (map rsimp rsa @ 
Chengsong
parents:
diff changeset
   202
[rsimp (RALTS rs)] @ map rsimp rsb)) {})")
Chengsong
parents:
diff changeset
   203
  prefer 2
Chengsong
parents:
diff changeset
   204
   apply simp
Chengsong
parents:
diff changeset
   205
  apply(simp only:)
Chengsong
parents:
diff changeset
   206
  apply(subgoal_tac "map rsimp rsa = rsa")
Chengsong
parents:
diff changeset
   207
  prefer 2
Chengsong
parents:
diff changeset
   208
  apply (metis map_idI rsimp.simps(3) test)
Chengsong
parents:
diff changeset
   209
  apply(simp only:)
Chengsong
parents:
diff changeset
   210
  apply(subgoal_tac "map rsimp rsb = rsb")
Chengsong
parents:
diff changeset
   211
   prefer 2
Chengsong
parents:
diff changeset
   212
  apply (metis map_idI rsimp.simps(3) test)
Chengsong
parents:
diff changeset
   213
  apply(simp only:)
Chengsong
parents:
diff changeset
   214
  apply(subst flts_append)+
Chengsong
parents:
diff changeset
   215
  apply(subgoal_tac "map rsimp rs = rs")
Chengsong
parents:
diff changeset
   216
   apply(simp only:)
Chengsong
parents:
diff changeset
   217
   prefer 2
Chengsong
parents:
diff changeset
   218
  apply (metis map_idI rsimp.simps(3) test)
Chengsong
parents:
diff changeset
   219
  apply(subgoal_tac "rdistinct (rflts rsa @ rflts rs @ rflts rsb) {} = 
Chengsong
parents:
diff changeset
   220
rdistinct (rflts rsa) {} @ rdistinct  (rflts rs @ rflts rsb) (set (rflts rsa))")
Chengsong
parents:
diff changeset
   221
   apply(simp only:)
Chengsong
parents:
diff changeset
   222
  prefer 2
Chengsong
parents:
diff changeset
   223
  using rdistinct_concat_general apply blast
Chengsong
parents:
diff changeset
   224
  apply(subgoal_tac "rdistinct (rflts rsa @ rflts [rsimp (RALTS rs)] @ rflts rsb) {} = 
Chengsong
parents:
diff changeset
   225
rdistinct (rflts rsa) {} @ rdistinct  (rflts [rsimp (RALTS rs)] @ rflts rsb) (set (rflts rsa))")
Chengsong
parents:
diff changeset
   226
   apply(simp only:)
Chengsong
parents:
diff changeset
   227
  prefer 2
Chengsong
parents:
diff changeset
   228
  using rdistinct_concat_general apply blast
Chengsong
parents:
diff changeset
   229
  apply(subgoal_tac "rdistinct (rflts rs @ rflts rsb) (set (rflts rsa)) = 
Chengsong
parents:
diff changeset
   230
                     rdistinct  (rflts [rsimp (RALTS rs)] @ rflts rsb) (set (rflts rsa))")
Chengsong
parents:
diff changeset
   231
   apply presburger
Chengsong
parents:
diff changeset
   232
  using good_flatten_aux by blast
Chengsong
parents:
diff changeset
   233
Chengsong
parents:
diff changeset
   234
Chengsong
parents:
diff changeset
   235
Chengsong
parents:
diff changeset
   236
lemma simp_flatten3:
Chengsong
parents:
diff changeset
   237
  shows "rsimp (RALTS (rsa @ [RALTS rs ] @ rsb)) = rsimp (RALTS (rsa @ rs @ rsb))"
Chengsong
parents:
diff changeset
   238
  apply(subgoal_tac "rsimp (RALTS (rsa @ [RALTS rs] @ rsb)) = 
Chengsong
parents:
diff changeset
   239
                     rsimp (RALTS (map rsimp rsa @ [rsimp (RALTS rs)] @ map rsimp rsb)) ")
Chengsong
parents:
diff changeset
   240
  prefer 2
Chengsong
parents:
diff changeset
   241
   apply (metis append.left_neutral append_Cons list.simps(9) map_append simp_flatten_aux0)
Chengsong
parents:
diff changeset
   242
  apply (simp only:)
Chengsong
parents:
diff changeset
   243
  apply(subgoal_tac "rsimp (RALTS (rsa @ rs @ rsb)) = 
Chengsong
parents:
diff changeset
   244
rsimp (RALTS (map rsimp rsa @ map rsimp rs @ map rsimp rsb))")
Chengsong
parents:
diff changeset
   245
  prefer 2
Chengsong
parents:
diff changeset
   246
   apply (metis map_append simp_flatten_aux0)
Chengsong
parents:
diff changeset
   247
  apply(simp only:)
Chengsong
parents:
diff changeset
   248
  apply(subgoal_tac "rsimp  (RALTS (map rsimp rsa @ map rsimp rs @ map rsimp rsb)) =
Chengsong
parents:
diff changeset
   249
 rsimp (RALTS (map rsimp rsa @ [RALTS (map rsimp rs)] @ map rsimp rsb))")
Chengsong
parents:
diff changeset
   250
  
Chengsong
parents:
diff changeset
   251
   apply (metis (no_types, lifting) head_one_more_simp map_append simp_flatten_aux0)
Chengsong
parents:
diff changeset
   252
  apply(subgoal_tac "\<forall>r \<in> set (map rsimp rsa). good r \<or> r = RZERO")
Chengsong
parents:
diff changeset
   253
   apply(subgoal_tac "\<forall>r \<in> set (map rsimp rs). good r \<or> r = RZERO")
Chengsong
parents:
diff changeset
   254
    apply(subgoal_tac "\<forall>r \<in> set (map rsimp rsb). good r \<or> r = RZERO")
Chengsong
parents:
diff changeset
   255
  
Chengsong
parents:
diff changeset
   256
  using good_flatten_middle apply presburger
Chengsong
parents:
diff changeset
   257
  apply (simp add: good1)
Chengsong
parents:
diff changeset
   258
  apply (simp add: good1)
Chengsong
parents:
diff changeset
   259
  apply (simp add: good1)
Chengsong
parents:
diff changeset
   260
  done
Chengsong
parents:
diff changeset
   261
Chengsong
parents:
diff changeset
   262
Chengsong
parents:
diff changeset
   263
lemma simp_removes_duplicate1:
Chengsong
parents:
diff changeset
   264
  shows  " a \<in> set rsa \<Longrightarrow> rsimp (RALTS (rsa @ [a])) =  rsimp (RALTS (rsa))"
Chengsong
parents:
diff changeset
   265
and " rsimp (RALTS (a1 # rsa @ [a1])) = rsimp (RALTS (a1 # rsa))"
Chengsong
parents:
diff changeset
   266
  apply(induct rsa arbitrary: a1)
Chengsong
parents:
diff changeset
   267
     apply simp
Chengsong
parents:
diff changeset
   268
    apply simp
Chengsong
parents:
diff changeset
   269
  prefer 2
Chengsong
parents:
diff changeset
   270
  apply(case_tac "a = aa")
Chengsong
parents:
diff changeset
   271
     apply simp
Chengsong
parents:
diff changeset
   272
    apply simp
Chengsong
parents:
diff changeset
   273
  apply (metis Cons_eq_appendI Cons_eq_map_conv distinct_removes_duplicate_flts list.set_intros(2))
Chengsong
parents:
diff changeset
   274
  apply (metis append_Cons append_Nil distinct_removes_duplicate_flts list.set_intros(1) list.simps(8) list.simps(9))
Chengsong
parents:
diff changeset
   275
  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))
Chengsong
parents:
diff changeset
   276
Chengsong
parents:
diff changeset
   277
lemma simp_removes_duplicate2:
Chengsong
parents:
diff changeset
   278
  shows "a \<in> set rsa \<Longrightarrow> rsimp (RALTS (rsa @ [a] @ rsb)) = rsimp (RALTS (rsa @ rsb))"
Chengsong
parents:
diff changeset
   279
  apply(induct rsb arbitrary: rsa)
Chengsong
parents:
diff changeset
   280
   apply simp
Chengsong
parents:
diff changeset
   281
  using distinct_removes_duplicate_flts apply auto[1]
Chengsong
parents:
diff changeset
   282
  by (metis append.assoc head_one_more_simp rsimp.simps(2) simp_flatten simp_removes_duplicate1(1))
Chengsong
parents:
diff changeset
   283
Chengsong
parents:
diff changeset
   284
lemma simp_removes_duplicate3:
Chengsong
parents:
diff changeset
   285
  shows "a \<in> set rsa \<Longrightarrow> rsimp (RALTS (rsa @ a # rsb)) = rsimp (RALTS (rsa @ rsb))"
Chengsong
parents:
diff changeset
   286
  using simp_removes_duplicate2 by auto
Chengsong
parents:
diff changeset
   287
Chengsong
parents:
diff changeset
   288
Chengsong
parents:
diff changeset
   289
end