thys2/ClosedForms.thy
author Chengsong
Fri, 01 Apr 2022 23:17:40 +0100
changeset 476 56837303ce61
parent 475 10fd25fba2ba
child 478 51af5f882350
permissions -rw-r--r--
hello
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
444
a7e98deebb5c restructured sizebound proof
Chengsong
parents: 443
diff changeset
     1
theory ClosedForms imports
a7e98deebb5c restructured sizebound proof
Chengsong
parents: 443
diff changeset
     2
"BasicIdentities"
443
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
     3
begin
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
     4
453
Chengsong
parents: 451
diff changeset
     5
465
Chengsong
parents: 456
diff changeset
     6
lemma idem_after_simp1:
Chengsong
parents: 456
diff changeset
     7
  shows "rsimp_ALTs (rdistinct (rflts [rsimp aa]) {}) = rsimp aa"
Chengsong
parents: 456
diff changeset
     8
  apply(case_tac "rsimp aa")
Chengsong
parents: 456
diff changeset
     9
  apply simp+
Chengsong
parents: 456
diff changeset
    10
  apply (metis no_alt_short_list_after_simp no_further_dB_after_simp)
Chengsong
parents: 456
diff changeset
    11
  by simp
456
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
    12
476
Chengsong
parents: 475
diff changeset
    13
lemma identity_wwo0:
Chengsong
parents: 475
diff changeset
    14
  shows "rsimp (rsimp_ALTs (RZERO # rs)) = rsimp (rsimp_ALTs rs)"
Chengsong
parents: 475
diff changeset
    15
  by (metis idem_after_simp1 list.exhaust list.simps(8) list.simps(9) rflts.simps(2) rsimp.simps(2) rsimp.simps(3) rsimp_ALTs.simps(1) rsimp_ALTs.simps(2) rsimp_ALTs.simps(3))
Chengsong
parents: 475
diff changeset
    16
456
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
    17
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
    18
lemma distinct_removes_last:
465
Chengsong
parents: 456
diff changeset
    19
  shows "\<lbrakk>a \<in> set as\<rbrakk>
456
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
    20
    \<Longrightarrow> rdistinct as rset = rdistinct (as @ [a]) rset"
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
    21
and "rdistinct (ab # as @ [ab]) rset1 = rdistinct (ab # as) rset1"
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
    22
  apply(induct as arbitrary: rset ab rset1 a)
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
    23
     apply simp
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
    24
    apply simp
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
    25
  apply(case_tac "aa \<in> rset")
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
    26
   apply(case_tac "a = aa")
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
    27
  apply (metis append_Cons)
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
    28
    apply simp
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
    29
   apply(case_tac "a \<in> set as")
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
    30
  apply (metis append_Cons rdistinct.simps(2) set_ConsD)
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
    31
   apply(case_tac "a = aa")
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
    32
    prefer 2
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
    33
    apply simp
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
    34
   apply (metis append_Cons)
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
    35
  apply(case_tac "ab \<in> rset1")
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
    36
  prefer 2
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
    37
   apply(subgoal_tac "rdistinct (ab # (a # as) @ [ab]) rset1 = 
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
    38
               ab # (rdistinct ((a # as) @ [ab]) (insert ab rset1))")
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
    39
  prefer 2
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
    40
  apply force
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
    41
  apply(simp only:)
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
    42
     apply(subgoal_tac "rdistinct (ab # a # as) rset1 = ab # (rdistinct (a # as) (insert ab rset1))")
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
    43
    apply(simp only:)
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
    44
    apply(subgoal_tac "rdistinct ((a # as) @ [ab]) (insert ab rset1) = rdistinct (a # as) (insert ab rset1)")
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
    45
     apply blast
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
    46
    apply(case_tac "a \<in> insert ab rset1")
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
    47
     apply simp
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
    48
     apply (metis insertI1)
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
    49
    apply simp
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
    50
    apply (meson insertI1)
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
    51
   apply simp
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
    52
  apply(subgoal_tac "rdistinct ((a # as) @ [ab]) rset1 = rdistinct (a # as) rset1")
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
    53
   apply simp
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
    54
  by (metis append_Cons insert_iff insert_is_Un rdistinct.simps(2))
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
    55
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
    56
465
Chengsong
parents: 456
diff changeset
    57
lemma distinct_removes_middle:
Chengsong
parents: 456
diff changeset
    58
  shows  "\<lbrakk>a \<in> set as\<rbrakk>
Chengsong
parents: 456
diff changeset
    59
    \<Longrightarrow> rdistinct (as @ as2) rset = rdistinct (as @ [a] @ as2) rset"
Chengsong
parents: 456
diff changeset
    60
and "rdistinct (ab # as @ [ab] @ as3) rset1 = rdistinct (ab # as @ as3) rset1"
Chengsong
parents: 456
diff changeset
    61
   apply(induct as arbitrary: rset rset1 ab as2 as3 a)
Chengsong
parents: 456
diff changeset
    62
     apply simp
Chengsong
parents: 456
diff changeset
    63
    apply simp
Chengsong
parents: 456
diff changeset
    64
   apply(case_tac "a \<in> rset")
Chengsong
parents: 456
diff changeset
    65
    apply simp
Chengsong
parents: 456
diff changeset
    66
    apply metis
453
Chengsong
parents: 451
diff changeset
    67
   apply simp
465
Chengsong
parents: 456
diff changeset
    68
   apply (metis insertI1)
Chengsong
parents: 456
diff changeset
    69
  apply(case_tac "a = ab")
453
Chengsong
parents: 451
diff changeset
    70
   apply simp
465
Chengsong
parents: 456
diff changeset
    71
   apply(case_tac "ab \<in> rset")
453
Chengsong
parents: 451
diff changeset
    72
    apply simp
465
Chengsong
parents: 456
diff changeset
    73
    apply presburger
Chengsong
parents: 456
diff changeset
    74
   apply (meson insertI1)
Chengsong
parents: 456
diff changeset
    75
  apply(case_tac "a \<in> rset")
Chengsong
parents: 456
diff changeset
    76
  apply (metis (no_types, opaque_lifting) Un_insert_left append_Cons insert_iff rdistinct.simps(2) sup_bot_left)
Chengsong
parents: 456
diff changeset
    77
  apply(case_tac "ab \<in> rset")
Chengsong
parents: 456
diff changeset
    78
  apply simp
Chengsong
parents: 456
diff changeset
    79
   apply (meson insert_iff)
Chengsong
parents: 456
diff changeset
    80
  apply simp
Chengsong
parents: 456
diff changeset
    81
  by (metis insertI1)
453
Chengsong
parents: 451
diff changeset
    82
Chengsong
parents: 451
diff changeset
    83
465
Chengsong
parents: 456
diff changeset
    84
lemma distinct_removes_middle3:
Chengsong
parents: 456
diff changeset
    85
  shows  "\<lbrakk>a \<in> set as\<rbrakk>
Chengsong
parents: 456
diff changeset
    86
    \<Longrightarrow> rdistinct (as @ a #as2) rset = rdistinct (as @ as2) rset"
Chengsong
parents: 456
diff changeset
    87
  using distinct_removes_middle(1) by fastforce
Chengsong
parents: 456
diff changeset
    88
Chengsong
parents: 456
diff changeset
    89
lemma distinct_removes_last2:
Chengsong
parents: 456
diff changeset
    90
  shows "\<lbrakk>a \<in> set as\<rbrakk>
Chengsong
parents: 456
diff changeset
    91
    \<Longrightarrow> rdistinct as rset = rdistinct (as @ [a]) rset"
Chengsong
parents: 456
diff changeset
    92
  by (simp add: distinct_removes_last(1))
Chengsong
parents: 456
diff changeset
    93
Chengsong
parents: 456
diff changeset
    94
lemma distinct_removes_middle2:
Chengsong
parents: 456
diff changeset
    95
  shows "a \<in> set as \<Longrightarrow> rdistinct (as @ [a] @ rs) {} = rdistinct (as @ rs) {}"
Chengsong
parents: 456
diff changeset
    96
  by (metis distinct_removes_middle(1))
Chengsong
parents: 456
diff changeset
    97
Chengsong
parents: 456
diff changeset
    98
lemma distinct_removes_list:
476
Chengsong
parents: 475
diff changeset
    99
  shows "\<lbrakk> \<forall>r \<in> set rs. r \<in> set as\<rbrakk> \<Longrightarrow> rdistinct (as @ rs) {} = rdistinct as {}"
465
Chengsong
parents: 456
diff changeset
   100
  apply(induct rs)
Chengsong
parents: 456
diff changeset
   101
   apply simp+
476
Chengsong
parents: 475
diff changeset
   102
  apply(subgoal_tac "rdistinct (as @ a # rs) {} = rdistinct (as @ rs) {}")
465
Chengsong
parents: 456
diff changeset
   103
   prefer 2
Chengsong
parents: 456
diff changeset
   104
  apply (metis append_Cons append_Nil distinct_removes_middle(1))
Chengsong
parents: 456
diff changeset
   105
  by presburger
453
Chengsong
parents: 451
diff changeset
   106
451
7a016eeb118d finiteness
Chengsong
parents: 445
diff changeset
   107
453
Chengsong
parents: 451
diff changeset
   108
lemma spawn_simp_rsimpalts:
Chengsong
parents: 451
diff changeset
   109
  shows "rsimp (rsimp_ALTs rs) = rsimp (rsimp_ALTs (map rsimp rs))"
Chengsong
parents: 451
diff changeset
   110
  apply(cases rs)
Chengsong
parents: 451
diff changeset
   111
   apply simp
Chengsong
parents: 451
diff changeset
   112
  apply(case_tac list)
Chengsong
parents: 451
diff changeset
   113
   apply simp
Chengsong
parents: 451
diff changeset
   114
   apply(subst rsimp_idem[symmetric])
Chengsong
parents: 451
diff changeset
   115
   apply simp
Chengsong
parents: 451
diff changeset
   116
  apply(subgoal_tac "rsimp_ALTs rs = RALTS rs")
Chengsong
parents: 451
diff changeset
   117
   apply(simp only:)
Chengsong
parents: 451
diff changeset
   118
   apply(subgoal_tac "rsimp_ALTs (map rsimp rs) = RALTS (map rsimp rs)")
Chengsong
parents: 451
diff changeset
   119
    apply(simp only:)
Chengsong
parents: 451
diff changeset
   120
  prefer 2
Chengsong
parents: 451
diff changeset
   121
  apply simp
Chengsong
parents: 451
diff changeset
   122
   prefer 2
Chengsong
parents: 451
diff changeset
   123
  using rsimp_ALTs.simps(3) apply presburger
Chengsong
parents: 451
diff changeset
   124
  apply auto
Chengsong
parents: 451
diff changeset
   125
  apply(subst rsimp_idem)+
Chengsong
parents: 451
diff changeset
   126
  by (metis comp_apply rsimp_idem)
Chengsong
parents: 451
diff changeset
   127
Chengsong
parents: 451
diff changeset
   128
lemma map_concat_cons:
Chengsong
parents: 451
diff changeset
   129
  shows "map f rsa @ f a # rs = map f (rsa @ [a]) @ rs"
Chengsong
parents: 451
diff changeset
   130
  by simp
Chengsong
parents: 451
diff changeset
   131
Chengsong
parents: 451
diff changeset
   132
lemma neg_removal_element_of:
Chengsong
parents: 451
diff changeset
   133
  shows " \<not> a \<notin> aset \<Longrightarrow> a \<in> aset"
Chengsong
parents: 451
diff changeset
   134
  by simp
Chengsong
parents: 451
diff changeset
   135
465
Chengsong
parents: 456
diff changeset
   136
lemma flts_removes0:
Chengsong
parents: 456
diff changeset
   137
  shows "  rflts (rs @ [RZERO])  =
Chengsong
parents: 456
diff changeset
   138
           rflts rs"
Chengsong
parents: 456
diff changeset
   139
  apply(induct rs)
Chengsong
parents: 456
diff changeset
   140
   apply simp
Chengsong
parents: 456
diff changeset
   141
  by (metis append_Cons rflts.simps(2) rflts.simps(3) rflts_def_idiot)
Chengsong
parents: 456
diff changeset
   142
  
Chengsong
parents: 456
diff changeset
   143
lemma flts_keeps1:
Chengsong
parents: 456
diff changeset
   144
  shows " rflts (rs @ [RONE]) = 
Chengsong
parents: 456
diff changeset
   145
          rflts  rs @ [RONE] "
Chengsong
parents: 456
diff changeset
   146
  apply (induct rs)
Chengsong
parents: 456
diff changeset
   147
   apply simp
Chengsong
parents: 456
diff changeset
   148
  by (metis append.assoc append_Cons rflts.simps(2) rflts.simps(3) rflts_def_idiot)
Chengsong
parents: 456
diff changeset
   149
Chengsong
parents: 456
diff changeset
   150
lemma flts_keeps_others:
Chengsong
parents: 456
diff changeset
   151
  shows "\<lbrakk>a \<noteq> RZERO; \<nexists>rs1. a = RALTS rs1\<rbrakk> \<Longrightarrow>rflts (rs @ [a]) = rflts rs @ [a]"
Chengsong
parents: 456
diff changeset
   152
  apply(induct rs)
Chengsong
parents: 456
diff changeset
   153
   apply simp
Chengsong
parents: 456
diff changeset
   154
  apply (simp add: rflts_def_idiot)
Chengsong
parents: 456
diff changeset
   155
  apply(case_tac a)
Chengsong
parents: 456
diff changeset
   156
       apply simp
Chengsong
parents: 456
diff changeset
   157
  using flts_keeps1 apply blast
Chengsong
parents: 456
diff changeset
   158
     apply (metis append.assoc append_Cons rflts.simps(2) rflts.simps(3) rflts_def_idiot)
Chengsong
parents: 456
diff changeset
   159
  apply (metis append.assoc append_Cons rflts.simps(2) rflts.simps(3) rflts_def_idiot)
Chengsong
parents: 456
diff changeset
   160
  apply blast
Chengsong
parents: 456
diff changeset
   161
  by (metis append.assoc append_Cons rflts.simps(2) rflts.simps(3) rflts_def_idiot)
Chengsong
parents: 456
diff changeset
   162
Chengsong
parents: 456
diff changeset
   163
Chengsong
parents: 456
diff changeset
   164
lemma rflts_def_idiot2:
Chengsong
parents: 456
diff changeset
   165
  shows "\<lbrakk>a \<noteq> RZERO; \<nexists>rs1. a = RALTS rs1; a \<in> set rs\<rbrakk> \<Longrightarrow> a \<in> set (rflts rs)"
Chengsong
parents: 456
diff changeset
   166
  apply(induct rs)
Chengsong
parents: 456
diff changeset
   167
   apply simp
Chengsong
parents: 456
diff changeset
   168
  by (metis append.assoc in_set_conv_decomp insert_iff list.simps(15) rflts.simps(2) rflts.simps(3) rflts_def_idiot)
Chengsong
parents: 456
diff changeset
   169
Chengsong
parents: 456
diff changeset
   170
lemma rflts_spills_last:
Chengsong
parents: 456
diff changeset
   171
  shows "a = RALTS rs \<Longrightarrow> rflts (rs1 @ [a]) = rflts rs1 @ rs"
Chengsong
parents: 456
diff changeset
   172
  apply (induct rs1)
Chengsong
parents: 456
diff changeset
   173
  apply simp
Chengsong
parents: 456
diff changeset
   174
  by (metis append.assoc append_Cons rflts.simps(2) rflts.simps(3) rflts_def_idiot)
Chengsong
parents: 456
diff changeset
   175
Chengsong
parents: 456
diff changeset
   176
Chengsong
parents: 456
diff changeset
   177
lemma spilled_alts_contained:
Chengsong
parents: 456
diff changeset
   178
  shows "\<lbrakk>a = RALTS rs ; a \<in> set rs1\<rbrakk> \<Longrightarrow> \<forall>r \<in> set rs. r \<in> set (rflts rs1)"
Chengsong
parents: 456
diff changeset
   179
  apply(induct rs1)
Chengsong
parents: 456
diff changeset
   180
   apply simp 
Chengsong
parents: 456
diff changeset
   181
  apply(case_tac "a = aa")
Chengsong
parents: 456
diff changeset
   182
   apply simp
Chengsong
parents: 456
diff changeset
   183
  apply(subgoal_tac " a \<in> set rs1")
Chengsong
parents: 456
diff changeset
   184
  prefer 2
Chengsong
parents: 456
diff changeset
   185
   apply (meson set_ConsD)
Chengsong
parents: 456
diff changeset
   186
  apply(case_tac aa)
Chengsong
parents: 456
diff changeset
   187
  using rflts.simps(2) apply presburger
Chengsong
parents: 456
diff changeset
   188
      apply fastforce
Chengsong
parents: 456
diff changeset
   189
  apply fastforce
Chengsong
parents: 456
diff changeset
   190
  apply fastforce
Chengsong
parents: 456
diff changeset
   191
  apply fastforce
Chengsong
parents: 456
diff changeset
   192
  by fastforce
Chengsong
parents: 456
diff changeset
   193
Chengsong
parents: 456
diff changeset
   194
lemma distinct_removes_duplicate_flts:
Chengsong
parents: 456
diff changeset
   195
  shows " a \<in> set rsa
Chengsong
parents: 456
diff changeset
   196
       \<Longrightarrow> rdistinct (rflts (map rsimp rsa @ [rsimp a])) {} =
Chengsong
parents: 456
diff changeset
   197
           rdistinct (rflts (map rsimp rsa)) {}"
Chengsong
parents: 456
diff changeset
   198
  apply(subgoal_tac "rsimp a \<in> set (map rsimp rsa)")
Chengsong
parents: 456
diff changeset
   199
  prefer 2
Chengsong
parents: 456
diff changeset
   200
  apply simp
Chengsong
parents: 456
diff changeset
   201
  apply(induct "rsimp a")
Chengsong
parents: 456
diff changeset
   202
       apply simp
Chengsong
parents: 456
diff changeset
   203
  using flts_removes0 apply presburger
Chengsong
parents: 456
diff changeset
   204
      apply(subgoal_tac " rdistinct (rflts (map rsimp rsa @ [rsimp a])) {} =  
Chengsong
parents: 456
diff changeset
   205
                          rdistinct (rflts (map rsimp rsa @ [RONE])) {}")
Chengsong
parents: 456
diff changeset
   206
      apply (simp only:)
Chengsong
parents: 456
diff changeset
   207
       apply(subst flts_keeps1)
Chengsong
parents: 456
diff changeset
   208
  apply (metis distinct_removes_last2 rflts_def_idiot2 rrexp.simps(20) rrexp.simps(6))
Chengsong
parents: 456
diff changeset
   209
      apply presburger
Chengsong
parents: 456
diff changeset
   210
        apply(subgoal_tac " rdistinct (rflts (map rsimp rsa @ [rsimp a]))    {} =  
Chengsong
parents: 456
diff changeset
   211
                            rdistinct ((rflts (map rsimp rsa)) @ [RCHAR x]) {}")
Chengsong
parents: 456
diff changeset
   212
      apply (simp only:)
Chengsong
parents: 456
diff changeset
   213
      prefer 2
Chengsong
parents: 456
diff changeset
   214
      apply (metis flts_keeps_others rrexp.distinct(21) rrexp.distinct(3))
Chengsong
parents: 456
diff changeset
   215
  apply (metis distinct_removes_last2 rflts_def_idiot2 rrexp.distinct(21) rrexp.distinct(3))
Chengsong
parents: 456
diff changeset
   216
Chengsong
parents: 456
diff changeset
   217
    apply (metis distinct_removes_last2 flts_keeps_others rflts_def_idiot2 rrexp.distinct(25) rrexp.distinct(5))
Chengsong
parents: 456
diff changeset
   218
   prefer 2
Chengsong
parents: 456
diff changeset
   219
   apply (metis distinct_removes_last2 flts_keeps_others flts_removes0 rflts_def_idiot2 rrexp.distinct(29))
Chengsong
parents: 456
diff changeset
   220
  apply(subgoal_tac "rflts (map rsimp rsa @ [rsimp a]) = rflts (map rsimp rsa) @ x")
Chengsong
parents: 456
diff changeset
   221
  prefer 2
Chengsong
parents: 456
diff changeset
   222
  apply (simp add: rflts_spills_last)
Chengsong
parents: 456
diff changeset
   223
  apply(simp only:)
Chengsong
parents: 456
diff changeset
   224
  apply(subgoal_tac "\<forall> r \<in> set x. r \<in> set (rflts (map rsimp rsa))")
Chengsong
parents: 456
diff changeset
   225
  prefer 2
Chengsong
parents: 456
diff changeset
   226
  using spilled_alts_contained apply presburger
Chengsong
parents: 456
diff changeset
   227
  by (metis append_self_conv distinct_removes_list in_set_conv_decomp rev_exhaust)
Chengsong
parents: 456
diff changeset
   228
Chengsong
parents: 456
diff changeset
   229
lemma flts_middle0:
Chengsong
parents: 456
diff changeset
   230
  shows "rflts (rsa @ RZERO # rsb) = rflts (rsa @ rsb)"
Chengsong
parents: 456
diff changeset
   231
  apply(induct rsa)
Chengsong
parents: 456
diff changeset
   232
  apply simp
Chengsong
parents: 456
diff changeset
   233
  by (metis append_Cons rflts.simps(2) rflts.simps(3) rflts_def_idiot)
Chengsong
parents: 456
diff changeset
   234
Chengsong
parents: 456
diff changeset
   235
lemma flts_middle01:
Chengsong
parents: 456
diff changeset
   236
  shows "rflts (rsa @ [RZERO] @ rsb) = rflts (rsa @ rsb)"
Chengsong
parents: 456
diff changeset
   237
  by (simp add: flts_middle0)
Chengsong
parents: 456
diff changeset
   238
Chengsong
parents: 456
diff changeset
   239
lemma flts_append1:
Chengsong
parents: 456
diff changeset
   240
  shows "\<lbrakk>a \<noteq> RZERO; \<nexists>rs1. a = RALTS rs1; a \<in> set rs\<rbrakk>  \<Longrightarrow>
Chengsong
parents: 456
diff changeset
   241
         rflts (rsa @ [a] @ rsb) = rflts rsa @ [a] @ (rflts rsb)"
Chengsong
parents: 456
diff changeset
   242
  apply(induct rsa arbitrary: rsb)
Chengsong
parents: 456
diff changeset
   243
   apply simp
Chengsong
parents: 456
diff changeset
   244
  using rflts_def_idiot apply presburger
Chengsong
parents: 456
diff changeset
   245
  apply(case_tac aa)  
Chengsong
parents: 456
diff changeset
   246
       apply simp+
Chengsong
parents: 456
diff changeset
   247
  done
Chengsong
parents: 456
diff changeset
   248
Chengsong
parents: 456
diff changeset
   249
lemma flts_append:
Chengsong
parents: 456
diff changeset
   250
  shows "rflts (rs1 @ rs2) = rflts rs1 @ rflts rs2"
Chengsong
parents: 456
diff changeset
   251
  apply(induct rs1)
Chengsong
parents: 456
diff changeset
   252
   apply simp
Chengsong
parents: 456
diff changeset
   253
  apply(case_tac a)
Chengsong
parents: 456
diff changeset
   254
       apply simp+
Chengsong
parents: 456
diff changeset
   255
  done
Chengsong
parents: 456
diff changeset
   256
Chengsong
parents: 456
diff changeset
   257
lemma simp_removes_duplicate1:
Chengsong
parents: 456
diff changeset
   258
  shows  " a \<in> set rsa \<Longrightarrow> rsimp (RALTS (rsa @ [a])) =  rsimp (RALTS (rsa))"
Chengsong
parents: 456
diff changeset
   259
and " rsimp (RALTS (a1 # rsa @ [a1])) = rsimp (RALTS (a1 # rsa))"
Chengsong
parents: 456
diff changeset
   260
  apply(induct rsa arbitrary: a1)
Chengsong
parents: 456
diff changeset
   261
     apply simp
Chengsong
parents: 456
diff changeset
   262
    apply simp
Chengsong
parents: 456
diff changeset
   263
  prefer 2
Chengsong
parents: 456
diff changeset
   264
  apply(case_tac "a = aa")
Chengsong
parents: 456
diff changeset
   265
     apply simp
Chengsong
parents: 456
diff changeset
   266
    apply simp
Chengsong
parents: 456
diff changeset
   267
  apply (metis Cons_eq_appendI Cons_eq_map_conv distinct_removes_duplicate_flts list.set_intros(2))
Chengsong
parents: 456
diff changeset
   268
  apply (metis append_Cons append_Nil distinct_removes_duplicate_flts list.set_intros(1) list.simps(8) list.simps(9))
Chengsong
parents: 456
diff changeset
   269
  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: 456
diff changeset
   270
  
Chengsong
parents: 456
diff changeset
   271
lemma simp_removes_duplicate2:
Chengsong
parents: 456
diff changeset
   272
  shows "a \<in> set rsa \<Longrightarrow> rsimp (RALTS (rsa @ [a] @ rsb)) = rsimp (RALTS (rsa @ rsb))"
Chengsong
parents: 456
diff changeset
   273
  apply(induct rsb arbitrary: rsa)
Chengsong
parents: 456
diff changeset
   274
   apply simp
Chengsong
parents: 456
diff changeset
   275
  using distinct_removes_duplicate_flts apply auto[1]
Chengsong
parents: 456
diff changeset
   276
  by (metis append.assoc head_one_more_simp rsimp.simps(2) simp_flatten simp_removes_duplicate1(1))
Chengsong
parents: 456
diff changeset
   277
Chengsong
parents: 456
diff changeset
   278
lemma simp_removes_duplicate3:
Chengsong
parents: 456
diff changeset
   279
  shows "a \<in> set rsa \<Longrightarrow> rsimp (RALTS (rsa @ a # rsb)) = rsimp (RALTS (rsa @ rsb))"
Chengsong
parents: 456
diff changeset
   280
  using simp_removes_duplicate2 by auto
Chengsong
parents: 456
diff changeset
   281
Chengsong
parents: 456
diff changeset
   282
lemma distinct_removes_middle4:
Chengsong
parents: 456
diff changeset
   283
  shows "a \<in> set rsa \<Longrightarrow> rdistinct (rsa @ [a] @ rsb) rset = rdistinct (rsa @ rsb) rset"
Chengsong
parents: 456
diff changeset
   284
  using distinct_removes_middle(1) by fastforce
Chengsong
parents: 456
diff changeset
   285
Chengsong
parents: 456
diff changeset
   286
lemma distinct_removes_middle_list:
Chengsong
parents: 456
diff changeset
   287
  shows "\<forall>a \<in> set x. a \<in> set rsa \<Longrightarrow> rdistinct (rsa @ x @ rsb) rset = rdistinct (rsa @ rsb) rset"
Chengsong
parents: 456
diff changeset
   288
  apply(induct x)
Chengsong
parents: 456
diff changeset
   289
   apply simp
Chengsong
parents: 456
diff changeset
   290
  by (simp add: distinct_removes_middle3)
Chengsong
parents: 456
diff changeset
   291
Chengsong
parents: 456
diff changeset
   292
Chengsong
parents: 456
diff changeset
   293
lemma distinct_removes_duplicate_flts2:
Chengsong
parents: 456
diff changeset
   294
  shows " a \<in> set rsa
Chengsong
parents: 456
diff changeset
   295
       \<Longrightarrow> rdistinct (rflts (rsa @ [a] @ rsb)) {} =
Chengsong
parents: 456
diff changeset
   296
           rdistinct (rflts (rsa @ rsb)) {}"
Chengsong
parents: 456
diff changeset
   297
  apply(induct a arbitrary: rsb)
Chengsong
parents: 456
diff changeset
   298
  using flts_middle01 apply presburger
Chengsong
parents: 456
diff changeset
   299
      apply(subgoal_tac "rflts (rsa @ [RONE] @ rsb) = rflts rsa @ [RONE] @ rflts rsb")
Chengsong
parents: 456
diff changeset
   300
  prefer 2
Chengsong
parents: 456
diff changeset
   301
  using flts_append1 apply blast
Chengsong
parents: 456
diff changeset
   302
      apply simp
Chengsong
parents: 456
diff changeset
   303
      apply(subgoal_tac "RONE \<in> set (rflts rsa)")
Chengsong
parents: 456
diff changeset
   304
  prefer 2
Chengsong
parents: 456
diff changeset
   305
  using rflts_def_idiot2 apply blast
Chengsong
parents: 456
diff changeset
   306
      apply(subst distinct_removes_middle3)
Chengsong
parents: 456
diff changeset
   307
       apply simp
Chengsong
parents: 456
diff changeset
   308
  using flts_append apply presburger
Chengsong
parents: 456
diff changeset
   309
     apply simp
Chengsong
parents: 456
diff changeset
   310
  apply (metis distinct_removes_middle3 flts_append in_set_conv_decomp rflts.simps(5))
Chengsong
parents: 456
diff changeset
   311
  apply (metis distinct_removes_middle(1) flts_append flts_append1 rflts_def_idiot2 rrexp.distinct(25) rrexp.distinct(5))
Chengsong
parents: 456
diff changeset
   312
   apply(subgoal_tac "rflts (rsa @ [RALTS x] @ rsb) = rflts rsa @ x @ rflts rsb")
Chengsong
parents: 456
diff changeset
   313
    prefer 2
Chengsong
parents: 456
diff changeset
   314
  apply (simp add: flts_append)
Chengsong
parents: 456
diff changeset
   315
   apply (simp only:)
Chengsong
parents: 456
diff changeset
   316
Chengsong
parents: 456
diff changeset
   317
   apply(subgoal_tac "\<forall>r1 \<in> set x. r1 \<in> set (rflts rsa)")
Chengsong
parents: 456
diff changeset
   318
    prefer 2
Chengsong
parents: 456
diff changeset
   319
  using spilled_alts_contained apply blast
Chengsong
parents: 456
diff changeset
   320
  apply(subst flts_append)
Chengsong
parents: 456
diff changeset
   321
  using distinct_removes_middle_list apply blast
Chengsong
parents: 456
diff changeset
   322
  using distinct_removes_middle2 flts_append rflts_def_idiot2 by fastforce
Chengsong
parents: 456
diff changeset
   323
Chengsong
parents: 456
diff changeset
   324
Chengsong
parents: 456
diff changeset
   325
lemma simp_removes_duplicate:
Chengsong
parents: 456
diff changeset
   326
  shows "a \<in> set rsa \<Longrightarrow> rsimp (rsimp_ALTs (rsa @ a # rs)) =  rsimp (rsimp_ALTs (rsa @ rs))"
Chengsong
parents: 456
diff changeset
   327
  apply(subgoal_tac "rsimp (rsimp_ALTs (rsa @ a # rs)) = rsimp (RALTS (rsa @ a # rs))")
Chengsong
parents: 456
diff changeset
   328
   prefer 2
Chengsong
parents: 456
diff changeset
   329
  apply (smt (verit, best) Cons_eq_append_conv append_is_Nil_conv empty_set equals0D list.distinct(1) rsimp_ALTs.elims)
Chengsong
parents: 456
diff changeset
   330
  apply(simp only:)
Chengsong
parents: 456
diff changeset
   331
  apply simp
Chengsong
parents: 456
diff changeset
   332
  apply(subgoal_tac "(rdistinct (rflts (map rsimp rsa @ rsimp a # map rsimp rs)) {}) = (rdistinct (rflts (map rsimp rsa @  map rsimp rs)) {})")
Chengsong
parents: 456
diff changeset
   333
   apply(simp only:)
Chengsong
parents: 456
diff changeset
   334
  prefer 2
Chengsong
parents: 456
diff changeset
   335
   apply(subgoal_tac "rsimp a \<in> set (map rsimp rsa)")
Chengsong
parents: 456
diff changeset
   336
    prefer 2
Chengsong
parents: 456
diff changeset
   337
  apply simp
Chengsong
parents: 456
diff changeset
   338
  using distinct_removes_duplicate_flts2 apply force
Chengsong
parents: 456
diff changeset
   339
  apply(case_tac rsa)
Chengsong
parents: 456
diff changeset
   340
   apply simp
Chengsong
parents: 456
diff changeset
   341
  apply(case_tac rs)
Chengsong
parents: 456
diff changeset
   342
   apply simp
Chengsong
parents: 456
diff changeset
   343
   apply(case_tac list)
Chengsong
parents: 456
diff changeset
   344
    apply simp
Chengsong
parents: 456
diff changeset
   345
  using idem_after_simp1 apply presburger
Chengsong
parents: 456
diff changeset
   346
   apply simp+
Chengsong
parents: 456
diff changeset
   347
  apply(subgoal_tac "rsimp_ALTs (aa # list @ aaa # lista) = RALTS (aa # list @ aaa # lista)")
Chengsong
parents: 456
diff changeset
   348
   apply simp
Chengsong
parents: 456
diff changeset
   349
  using rsimpalts_conscons by presburger
467
Chengsong
parents: 465
diff changeset
   350
Chengsong
parents: 465
diff changeset
   351
Chengsong
parents: 465
diff changeset
   352
Chengsong
parents: 465
diff changeset
   353
Chengsong
parents: 465
diff changeset
   354
lemma distinct_flts_no0:
468
a0f27e21b42c all texrelated
Chengsong
parents: 467
diff changeset
   355
  shows "  rflts (map rsimp (rdistinct rs (insert RZERO rset)))  =
a0f27e21b42c all texrelated
Chengsong
parents: 467
diff changeset
   356
           rflts (map rsimp (rdistinct rs rset))  "
a0f27e21b42c all texrelated
Chengsong
parents: 467
diff changeset
   357
  
a0f27e21b42c all texrelated
Chengsong
parents: 467
diff changeset
   358
  apply(induct rs arbitrary: rset)
467
Chengsong
parents: 465
diff changeset
   359
   apply simp
Chengsong
parents: 465
diff changeset
   360
  apply(case_tac a)
468
a0f27e21b42c all texrelated
Chengsong
parents: 467
diff changeset
   361
  apply simp+
a0f27e21b42c all texrelated
Chengsong
parents: 467
diff changeset
   362
    apply (smt (verit, ccfv_SIG) rflts.simps(2) rflts.simps(3) rflts_def_idiot)
a0f27e21b42c all texrelated
Chengsong
parents: 467
diff changeset
   363
  prefer 2
a0f27e21b42c all texrelated
Chengsong
parents: 467
diff changeset
   364
  apply simp  
a0f27e21b42c all texrelated
Chengsong
parents: 467
diff changeset
   365
  by (smt (verit, ccfv_threshold) Un_insert_right insert_iff list.simps(9) rdistinct.simps(2) rflts.simps(2) rflts.simps(3) rflts_def_idiot rrexp.distinct(7))
a0f27e21b42c all texrelated
Chengsong
parents: 467
diff changeset
   366
467
Chengsong
parents: 465
diff changeset
   367
Chengsong
parents: 465
diff changeset
   368
471
Chengsong
parents: 469
diff changeset
   369
Chengsong
parents: 469
diff changeset
   370
inductive frewrite:: "rrexp list \<Rightarrow> rrexp list \<Rightarrow> bool" ("_ \<leadsto>f _" [10, 10] 10)
Chengsong
parents: 469
diff changeset
   371
  where
Chengsong
parents: 469
diff changeset
   372
  "(RZERO # rs) \<leadsto>f rs"
Chengsong
parents: 469
diff changeset
   373
| "((RALTS rs) # rsa) \<leadsto>f (rs @ rsa)"
Chengsong
parents: 469
diff changeset
   374
| "rs1 \<leadsto>f rs2 \<Longrightarrow> (r # rs1) \<leadsto>f (r # rs2)"
Chengsong
parents: 469
diff changeset
   375
Chengsong
parents: 469
diff changeset
   376
Chengsong
parents: 469
diff changeset
   377
inductive 
Chengsong
parents: 469
diff changeset
   378
  frewrites:: "rrexp list \<Rightarrow> rrexp list \<Rightarrow> bool" ("_ \<leadsto>f* _" [10, 10] 10)
Chengsong
parents: 469
diff changeset
   379
where 
473
Chengsong
parents: 472
diff changeset
   380
  [intro, simp]:"rs \<leadsto>f* rs"
Chengsong
parents: 472
diff changeset
   381
| [intro]: "\<lbrakk>rs1 \<leadsto>f* rs2; rs2 \<leadsto>f rs3\<rbrakk> \<Longrightarrow> rs1 \<leadsto>f* rs3"
Chengsong
parents: 472
diff changeset
   382
Chengsong
parents: 472
diff changeset
   383
inductive grewrite:: "rrexp list \<Rightarrow> rrexp list \<Rightarrow> bool" ("_ \<leadsto>g _" [10, 10] 10)
Chengsong
parents: 472
diff changeset
   384
  where
Chengsong
parents: 472
diff changeset
   385
  "(RZERO # rs) \<leadsto>g rs"
Chengsong
parents: 472
diff changeset
   386
| "((RALTS rs) # rsa) \<leadsto>g (rs @ rsa)"
Chengsong
parents: 472
diff changeset
   387
| "rs1 \<leadsto>g rs2 \<Longrightarrow> (r # rs1) \<leadsto>g (r # rs2)"
Chengsong
parents: 472
diff changeset
   388
| "rsa @ [a] @ rsb @ [a] @ rsc \<leadsto>g rsa @ [a] @ rsb @ rsc" 
Chengsong
parents: 472
diff changeset
   389
Chengsong
parents: 472
diff changeset
   390
Chengsong
parents: 472
diff changeset
   391
inductive 
Chengsong
parents: 472
diff changeset
   392
  grewrites:: "rrexp list \<Rightarrow> rrexp list \<Rightarrow> bool" ("_ \<leadsto>g* _" [10, 10] 10)
Chengsong
parents: 472
diff changeset
   393
where 
Chengsong
parents: 472
diff changeset
   394
  [intro, simp]:"rs \<leadsto>g* rs"
Chengsong
parents: 472
diff changeset
   395
| [intro]: "\<lbrakk>rs1 \<leadsto>g* rs2; rs2 \<leadsto>g rs3\<rbrakk> \<Longrightarrow> rs1 \<leadsto>g* rs3"
Chengsong
parents: 472
diff changeset
   396
(*
Chengsong
parents: 472
diff changeset
   397
inductive 
Chengsong
parents: 472
diff changeset
   398
  frewrites2:: "rrexp list \<Rightarrow> rrexp list \<Rightarrow> bool" ("_ <\<leadsto>f* _" [10, 10] 10)
Chengsong
parents: 472
diff changeset
   399
where 
Chengsong
parents: 472
diff changeset
   400
 [intro]: "\<lbrakk>rs1 \<leadsto>f* rs2; rs2 \<leadsto>f* rs1\<rbrakk> \<Longrightarrow> rs1 <\<leadsto>f* rs2"
Chengsong
parents: 472
diff changeset
   401
*)
471
Chengsong
parents: 469
diff changeset
   402
Chengsong
parents: 469
diff changeset
   403
lemma fr_in_rstar : "r1 \<leadsto>f r2 \<Longrightarrow> r1 \<leadsto>f* r2"
Chengsong
parents: 469
diff changeset
   404
  using frewrites.intros(1) frewrites.intros(2) by blast
Chengsong
parents: 469
diff changeset
   405
 
Chengsong
parents: 469
diff changeset
   406
lemma freal_trans[trans]: 
Chengsong
parents: 469
diff changeset
   407
  assumes a1: "r1 \<leadsto>f* r2"  and a2: "r2 \<leadsto>f* r3"
Chengsong
parents: 469
diff changeset
   408
  shows "r1 \<leadsto>f* r3"
Chengsong
parents: 469
diff changeset
   409
  using a2 a1
Chengsong
parents: 469
diff changeset
   410
  apply(induct r2 r3 arbitrary: r1 rule: frewrites.induct) 
Chengsong
parents: 469
diff changeset
   411
  apply(auto)
Chengsong
parents: 469
diff changeset
   412
  done
Chengsong
parents: 469
diff changeset
   413
Chengsong
parents: 469
diff changeset
   414
Chengsong
parents: 469
diff changeset
   415
lemma  many_steps_later: "\<lbrakk>r1 \<leadsto>f r2; r2 \<leadsto>f* r3 \<rbrakk> \<Longrightarrow> r1 \<leadsto>f* r3"
Chengsong
parents: 469
diff changeset
   416
  by (meson fr_in_rstar freal_trans)
Chengsong
parents: 469
diff changeset
   417
Chengsong
parents: 469
diff changeset
   418
475
10fd25fba2ba identities
Chengsong
parents: 473
diff changeset
   419
lemma gr_in_rstar : "r1 \<leadsto>g r2 \<Longrightarrow> r1 \<leadsto>g* r2"
10fd25fba2ba identities
Chengsong
parents: 473
diff changeset
   420
  using grewrites.intros(1) grewrites.intros(2) by blast
10fd25fba2ba identities
Chengsong
parents: 473
diff changeset
   421
 
10fd25fba2ba identities
Chengsong
parents: 473
diff changeset
   422
lemma greal_trans[trans]: 
10fd25fba2ba identities
Chengsong
parents: 473
diff changeset
   423
  assumes a1: "r1 \<leadsto>g* r2"  and a2: "r2 \<leadsto>g* r3"
10fd25fba2ba identities
Chengsong
parents: 473
diff changeset
   424
  shows "r1 \<leadsto>g* r3"
10fd25fba2ba identities
Chengsong
parents: 473
diff changeset
   425
  using a2 a1
10fd25fba2ba identities
Chengsong
parents: 473
diff changeset
   426
  apply(induct r2 r3 arbitrary: r1 rule: grewrites.induct) 
10fd25fba2ba identities
Chengsong
parents: 473
diff changeset
   427
  apply(auto)
10fd25fba2ba identities
Chengsong
parents: 473
diff changeset
   428
  done
10fd25fba2ba identities
Chengsong
parents: 473
diff changeset
   429
10fd25fba2ba identities
Chengsong
parents: 473
diff changeset
   430
10fd25fba2ba identities
Chengsong
parents: 473
diff changeset
   431
lemma  gmany_steps_later: "\<lbrakk>r1 \<leadsto>g r2; r2 \<leadsto>g* r3 \<rbrakk> \<Longrightarrow> r1 \<leadsto>g* r3"
10fd25fba2ba identities
Chengsong
parents: 473
diff changeset
   432
  by (meson gr_in_rstar greal_trans)
10fd25fba2ba identities
Chengsong
parents: 473
diff changeset
   433
10fd25fba2ba identities
Chengsong
parents: 473
diff changeset
   434
10fd25fba2ba identities
Chengsong
parents: 473
diff changeset
   435
471
Chengsong
parents: 469
diff changeset
   436
lemma frewrite_append:
Chengsong
parents: 469
diff changeset
   437
  shows "\<lbrakk> rsa \<leadsto>f rsb \<rbrakk> \<Longrightarrow> rs @ rsa \<leadsto>f rs @ rsb"
Chengsong
parents: 469
diff changeset
   438
  apply(induct rs)
472
Chengsong
parents: 471
diff changeset
   439
   apply simp+
Chengsong
parents: 471
diff changeset
   440
  using frewrite.intros(3) by blast
475
10fd25fba2ba identities
Chengsong
parents: 473
diff changeset
   441
10fd25fba2ba identities
Chengsong
parents: 473
diff changeset
   442
lemma grewrite_append:
10fd25fba2ba identities
Chengsong
parents: 473
diff changeset
   443
  shows "\<lbrakk> rsa \<leadsto>g rsb \<rbrakk> \<Longrightarrow> rs @ rsa \<leadsto>g rs @ rsb"
10fd25fba2ba identities
Chengsong
parents: 473
diff changeset
   444
  apply(induct rs)
10fd25fba2ba identities
Chengsong
parents: 473
diff changeset
   445
   apply simp+
10fd25fba2ba identities
Chengsong
parents: 473
diff changeset
   446
  using grewrite.intros(3) by blast
472
Chengsong
parents: 471
diff changeset
   447
  
471
Chengsong
parents: 469
diff changeset
   448
Chengsong
parents: 469
diff changeset
   449
Chengsong
parents: 469
diff changeset
   450
lemma frewrites_cons:
Chengsong
parents: 469
diff changeset
   451
  shows "\<lbrakk> rsa \<leadsto>f* rsb \<rbrakk> \<Longrightarrow> r # rsa \<leadsto>f* r # rsb"
472
Chengsong
parents: 471
diff changeset
   452
  apply(induct rsa rsb rule: frewrites.induct)
Chengsong
parents: 471
diff changeset
   453
   apply simp
Chengsong
parents: 471
diff changeset
   454
  using frewrite.intros(3) by blast
471
Chengsong
parents: 469
diff changeset
   455
Chengsong
parents: 469
diff changeset
   456
475
10fd25fba2ba identities
Chengsong
parents: 473
diff changeset
   457
lemma grewrites_cons:
10fd25fba2ba identities
Chengsong
parents: 473
diff changeset
   458
  shows "\<lbrakk> rsa \<leadsto>g* rsb \<rbrakk> \<Longrightarrow> r # rsa \<leadsto>g* r # rsb"
10fd25fba2ba identities
Chengsong
parents: 473
diff changeset
   459
  apply(induct rsa rsb rule: grewrites.induct)
10fd25fba2ba identities
Chengsong
parents: 473
diff changeset
   460
   apply simp
10fd25fba2ba identities
Chengsong
parents: 473
diff changeset
   461
  using grewrite.intros(3) by blast
10fd25fba2ba identities
Chengsong
parents: 473
diff changeset
   462
10fd25fba2ba identities
Chengsong
parents: 473
diff changeset
   463
471
Chengsong
parents: 469
diff changeset
   464
lemma frewrites_append:
Chengsong
parents: 469
diff changeset
   465
  shows " \<lbrakk>rsa \<leadsto>f* rsb\<rbrakk> \<Longrightarrow> (rs @ rsa) \<leadsto>f* (rs @ rsb)"
472
Chengsong
parents: 471
diff changeset
   466
  apply(induct rs)
471
Chengsong
parents: 469
diff changeset
   467
   apply simp
472
Chengsong
parents: 471
diff changeset
   468
  by (simp add: frewrites_cons)
471
Chengsong
parents: 469
diff changeset
   469
475
10fd25fba2ba identities
Chengsong
parents: 473
diff changeset
   470
lemma grewrites_append:
10fd25fba2ba identities
Chengsong
parents: 473
diff changeset
   471
  shows " \<lbrakk>rsa \<leadsto>g* rsb\<rbrakk> \<Longrightarrow> (rs @ rsa) \<leadsto>g* (rs @ rsb)"
10fd25fba2ba identities
Chengsong
parents: 473
diff changeset
   472
  apply(induct rs)
10fd25fba2ba identities
Chengsong
parents: 473
diff changeset
   473
   apply simp
10fd25fba2ba identities
Chengsong
parents: 473
diff changeset
   474
  by (simp add: grewrites_cons)
10fd25fba2ba identities
Chengsong
parents: 473
diff changeset
   475
471
Chengsong
parents: 469
diff changeset
   476
Chengsong
parents: 469
diff changeset
   477
Chengsong
parents: 469
diff changeset
   478
lemma frewrites_concat:
Chengsong
parents: 469
diff changeset
   479
  shows "\<lbrakk>rs1 \<leadsto>f rs2; rsa \<leadsto>f* rsb \<rbrakk> \<Longrightarrow> (rs1 @ rsa) \<leadsto>f* (rs2 @ rsb)"
Chengsong
parents: 469
diff changeset
   480
  apply(induct rs1 rs2 rule: frewrite.induct)
Chengsong
parents: 469
diff changeset
   481
    apply(simp)
Chengsong
parents: 469
diff changeset
   482
  apply(subgoal_tac "(RZERO # rs @ rsa) \<leadsto>f (rs @ rsa)")
Chengsong
parents: 469
diff changeset
   483
  prefer 2
Chengsong
parents: 469
diff changeset
   484
  using frewrite.intros(1) apply blast
Chengsong
parents: 469
diff changeset
   485
    apply(subgoal_tac "(rs @ rsa) \<leadsto>f* (rs @ rsb)")
Chengsong
parents: 469
diff changeset
   486
  using many_steps_later apply blast
472
Chengsong
parents: 471
diff changeset
   487
  apply (simp add: frewrites_append)
Chengsong
parents: 471
diff changeset
   488
  apply (metis append.assoc append_Cons frewrite.intros(2) frewrites_append many_steps_later)
Chengsong
parents: 471
diff changeset
   489
  using frewrites_cons by auto
471
Chengsong
parents: 469
diff changeset
   490
475
10fd25fba2ba identities
Chengsong
parents: 473
diff changeset
   491
lemma grewrites_concat:
10fd25fba2ba identities
Chengsong
parents: 473
diff changeset
   492
  shows "\<lbrakk>rs1 \<leadsto>g rs2; rsa \<leadsto>g* rsb \<rbrakk> \<Longrightarrow> (rs1 @ rsa) \<leadsto>g* (rs2 @ rsb)"
10fd25fba2ba identities
Chengsong
parents: 473
diff changeset
   493
  apply(induct rs1 rs2 rule: grewrite.induct)
10fd25fba2ba identities
Chengsong
parents: 473
diff changeset
   494
    apply(simp)
10fd25fba2ba identities
Chengsong
parents: 473
diff changeset
   495
  apply(subgoal_tac "(RZERO # rs @ rsa) \<leadsto>g (rs @ rsa)")
10fd25fba2ba identities
Chengsong
parents: 473
diff changeset
   496
  prefer 2
10fd25fba2ba identities
Chengsong
parents: 473
diff changeset
   497
  using grewrite.intros(1) apply blast
10fd25fba2ba identities
Chengsong
parents: 473
diff changeset
   498
    apply(subgoal_tac "(rs @ rsa) \<leadsto>g* (rs @ rsb)")
10fd25fba2ba identities
Chengsong
parents: 473
diff changeset
   499
  using gmany_steps_later apply blast
10fd25fba2ba identities
Chengsong
parents: 473
diff changeset
   500
  apply (simp add: grewrites_append)
10fd25fba2ba identities
Chengsong
parents: 473
diff changeset
   501
  apply (metis append.assoc append_Cons grewrite.intros(2) grewrites_append gmany_steps_later)
10fd25fba2ba identities
Chengsong
parents: 473
diff changeset
   502
  using grewrites_cons apply auto
10fd25fba2ba identities
Chengsong
parents: 473
diff changeset
   503
  apply(subgoal_tac "rsaa @ a # rsba @ a # rsc @ rsa \<leadsto>g* rsaa @ a # rsba @ a # rsc @ rsb")
10fd25fba2ba identities
Chengsong
parents: 473
diff changeset
   504
  using grewrite.intros(4) grewrites.intros(2) apply force
10fd25fba2ba identities
Chengsong
parents: 473
diff changeset
   505
  using grewrites_append by auto
10fd25fba2ba identities
Chengsong
parents: 473
diff changeset
   506
10fd25fba2ba identities
Chengsong
parents: 473
diff changeset
   507
10fd25fba2ba identities
Chengsong
parents: 473
diff changeset
   508
lemma grewritess_concat:
10fd25fba2ba identities
Chengsong
parents: 473
diff changeset
   509
  shows "\<lbrakk>rsa \<leadsto>g* rsb; rsc \<leadsto>g* rsd \<rbrakk> \<Longrightarrow> (rsa @ rsc) \<leadsto>g* (rsb @ rsd)"
10fd25fba2ba identities
Chengsong
parents: 473
diff changeset
   510
  apply(induct rsa rsb rule: grewrites.induct)
10fd25fba2ba identities
Chengsong
parents: 473
diff changeset
   511
   apply(case_tac rs)
10fd25fba2ba identities
Chengsong
parents: 473
diff changeset
   512
    apply simp
10fd25fba2ba identities
Chengsong
parents: 473
diff changeset
   513
  using grewrites_append apply blast   
10fd25fba2ba identities
Chengsong
parents: 473
diff changeset
   514
  by (meson greal_trans grewrites.simps grewrites_concat)
10fd25fba2ba identities
Chengsong
parents: 473
diff changeset
   515
476
Chengsong
parents: 475
diff changeset
   516
fun alt_set:: "rrexp \<Rightarrow> rrexp set"
Chengsong
parents: 475
diff changeset
   517
  where
Chengsong
parents: 475
diff changeset
   518
  "alt_set (RALTS rs) = set rs \<union> \<Union> (alt_set ` (set rs))"
Chengsong
parents: 475
diff changeset
   519
| "alt_set r = {r}"
Chengsong
parents: 475
diff changeset
   520
Chengsong
parents: 475
diff changeset
   521
lemma alt_set_has_all:
Chengsong
parents: 475
diff changeset
   522
  shows "RALTS rs \<in> alt_set rx \<Longrightarrow> set rs \<subseteq> alt_set rx"
Chengsong
parents: 475
diff changeset
   523
  apply(induct rx arbitrary: rs)
Chengsong
parents: 475
diff changeset
   524
       apply simp_all
Chengsong
parents: 475
diff changeset
   525
  apply(rename_tac rSS rss)
Chengsong
parents: 475
diff changeset
   526
  using in_mono by fastforce
Chengsong
parents: 475
diff changeset
   527
Chengsong
parents: 475
diff changeset
   528
Chengsong
parents: 475
diff changeset
   529
Chengsong
parents: 475
diff changeset
   530
Chengsong
parents: 475
diff changeset
   531
lemma grewrite_equal_rsimp:
Chengsong
parents: 475
diff changeset
   532
  shows "\<lbrakk>rs1 \<leadsto>g rs2; rsimp_ALTs (rdistinct (rflts (map rsimp rs1)) (rset \<union> \<Union>(alt_set ` rset))) =
Chengsong
parents: 475
diff changeset
   533
          rsimp_ALTs (rdistinct (rflts (map rsimp rs2)) (rset \<union> \<Union>(alt_set ` rset)))\<rbrakk>
Chengsong
parents: 475
diff changeset
   534
       \<Longrightarrow> rsimp_ALTs (rdistinct (rflts (rsimp r # map rsimp rs1))  (rset \<union> \<Union>(alt_set ` rset))) =
Chengsong
parents: 475
diff changeset
   535
           rsimp_ALTs (rdistinct (rflts (rsimp r # map rsimp rs2))  (rset \<union> \<Union>(alt_set ` rset)))"
Chengsong
parents: 475
diff changeset
   536
  apply(induct rs1 rs2 arbitrary:rset rule: grewrite.induct)
Chengsong
parents: 475
diff changeset
   537
     apply simp
Chengsong
parents: 475
diff changeset
   538
  apply (metis append_Cons append_Nil flts_middle0)
Chengsong
parents: 475
diff changeset
   539
    apply(case_tac "rsimp r \<in> rset")
Chengsong
parents: 475
diff changeset
   540
     apply simp
Chengsong
parents: 475
diff changeset
   541
  oops
Chengsong
parents: 475
diff changeset
   542
Chengsong
parents: 475
diff changeset
   543
Chengsong
parents: 475
diff changeset
   544
Chengsong
parents: 475
diff changeset
   545
lemma grewrite_equal_rsimp:
Chengsong
parents: 475
diff changeset
   546
  shows "rs1 \<leadsto>g rs2 \<Longrightarrow> rsimp (RALTS rs1) = rsimp (RALTS rs2)"
Chengsong
parents: 475
diff changeset
   547
  apply(induct rs1 rs2 rule: grewrite.induct)
Chengsong
parents: 475
diff changeset
   548
  apply simp
Chengsong
parents: 475
diff changeset
   549
  using simp_flatten apply blast
Chengsong
parents: 475
diff changeset
   550
   prefer 2
Chengsong
parents: 475
diff changeset
   551
   apply (smt (verit) append.assoc append_Cons in_set_conv_decomp simp_removes_duplicate2)
Chengsong
parents: 475
diff changeset
   552
  apply simp
Chengsong
parents: 475
diff changeset
   553
  apply(case_tac "rdistinct (rflts (map rsimp rs1)) {}")
Chengsong
parents: 475
diff changeset
   554
  apply(case_tac "rsimp r = RZERO")
Chengsong
parents: 475
diff changeset
   555
    apply simp
Chengsong
parents: 475
diff changeset
   556
   apply(case_tac "\<exists>rs. rsimp r = RALTS rs")
Chengsong
parents: 475
diff changeset
   557
    prefer 2
Chengsong
parents: 475
diff changeset
   558
   
Chengsong
parents: 475
diff changeset
   559
    apply(subgoal_tac "rdistinct (rflts (rsimp r # map rsimp rs1)) {} = 
Chengsong
parents: 475
diff changeset
   560
                    rsimp r # rdistinct (rflts (map rsimp rs1)) {rsimp r}")
Chengsong
parents: 475
diff changeset
   561
  prefer 2
Chengsong
parents: 475
diff changeset
   562
  apply (simp add: list.inject rflts_def_idiot)
Chengsong
parents: 475
diff changeset
   563
    apply(simp only:)
Chengsong
parents: 475
diff changeset
   564
Chengsong
parents: 475
diff changeset
   565
  sorry
Chengsong
parents: 475
diff changeset
   566
Chengsong
parents: 475
diff changeset
   567
475
10fd25fba2ba identities
Chengsong
parents: 473
diff changeset
   568
lemma grewrites_equal_rsimp:
10fd25fba2ba identities
Chengsong
parents: 473
diff changeset
   569
  shows "rs1 \<leadsto>g* rs2 \<Longrightarrow> rsimp (RALTS rs1) = rsimp (RALTS rs2)"
476
Chengsong
parents: 475
diff changeset
   570
  apply (induct rs1 rs2 rule: grewrites.induct)
475
10fd25fba2ba identities
Chengsong
parents: 473
diff changeset
   571
  apply simp
476
Chengsong
parents: 475
diff changeset
   572
  using grewrite_equal_rsimp by presburger
Chengsong
parents: 475
diff changeset
   573
  
Chengsong
parents: 475
diff changeset
   574
Chengsong
parents: 475
diff changeset
   575
Chengsong
parents: 475
diff changeset
   576
Chengsong
parents: 475
diff changeset
   577
lemma grewrites_equal_simp_2:
Chengsong
parents: 475
diff changeset
   578
  shows "rsimp (RALTS rs1) = rsimp (RALTS rs2) \<Longrightarrow> rs1 \<leadsto>g* rs2"
475
10fd25fba2ba identities
Chengsong
parents: 473
diff changeset
   579
  sorry
10fd25fba2ba identities
Chengsong
parents: 473
diff changeset
   580
476
Chengsong
parents: 475
diff changeset
   581
lemma grewrites_last:
Chengsong
parents: 475
diff changeset
   582
  shows "r # [RALTS rs] \<leadsto>g*  r # rs"
Chengsong
parents: 475
diff changeset
   583
  by (metis gr_in_rstar grewrite.intros(2) grewrite.intros(3) self_append_conv)
Chengsong
parents: 475
diff changeset
   584
Chengsong
parents: 475
diff changeset
   585
lemma simp_flatten2:
Chengsong
parents: 475
diff changeset
   586
  shows "rsimp (RALTS (r # [RALTS rs])) = rsimp (RALTS (r # rs))"
Chengsong
parents: 475
diff changeset
   587
  using grewrites_equal_rsimp grewrites_last by blast
475
10fd25fba2ba identities
Chengsong
parents: 473
diff changeset
   588
473
Chengsong
parents: 472
diff changeset
   589
lemma frewrites_middle:
Chengsong
parents: 472
diff changeset
   590
  shows "rs1 \<leadsto>f* rs2 \<Longrightarrow> r # (RALTS rs # rs1) \<leadsto>f* r # (rs @ rs1)"
Chengsong
parents: 472
diff changeset
   591
  by (simp add: fr_in_rstar frewrite.intros(2) frewrite.intros(3))
471
Chengsong
parents: 469
diff changeset
   592
473
Chengsong
parents: 472
diff changeset
   593
lemma frewrites_alt:
Chengsong
parents: 472
diff changeset
   594
  shows "rs1 \<leadsto>f* rs2 \<Longrightarrow> (RALT r1 r2) # rs1 \<leadsto>f* r1 # r2 # rs2"  
Chengsong
parents: 472
diff changeset
   595
  by (metis Cons_eq_appendI append_self_conv2 frewrite.intros(2) frewrites_cons many_steps_later)
471
Chengsong
parents: 469
diff changeset
   596
Chengsong
parents: 469
diff changeset
   597
lemma early_late_der_frewrites:
Chengsong
parents: 469
diff changeset
   598
  shows "map (rder x) (rflts rs) \<leadsto>f* rflts (map (rder x) rs)"
Chengsong
parents: 469
diff changeset
   599
  apply(induct rs)
Chengsong
parents: 469
diff changeset
   600
   apply simp
Chengsong
parents: 469
diff changeset
   601
  apply(case_tac a)
Chengsong
parents: 469
diff changeset
   602
       apply simp+
Chengsong
parents: 469
diff changeset
   603
  using frewrite.intros(1) many_steps_later apply blast
Chengsong
parents: 469
diff changeset
   604
     apply(case_tac "x = x3")
472
Chengsong
parents: 471
diff changeset
   605
      apply simp
Chengsong
parents: 471
diff changeset
   606
  using frewrites_cons apply presburger
Chengsong
parents: 471
diff changeset
   607
  using frewrite.intros(1) many_steps_later apply fastforce
Chengsong
parents: 471
diff changeset
   608
  apply(case_tac "rnullable x41")
473
Chengsong
parents: 472
diff changeset
   609
     apply simp+
Chengsong
parents: 472
diff changeset
   610
     apply (simp add: frewrites_alt)
Chengsong
parents: 472
diff changeset
   611
  apply (simp add: frewrites_cons)
Chengsong
parents: 472
diff changeset
   612
   apply (simp add: frewrites_append)
Chengsong
parents: 472
diff changeset
   613
  by (simp add: frewrites_cons)
471
Chengsong
parents: 469
diff changeset
   614
Chengsong
parents: 469
diff changeset
   615
Chengsong
parents: 469
diff changeset
   616
Chengsong
parents: 469
diff changeset
   617
Chengsong
parents: 469
diff changeset
   618
473
Chengsong
parents: 472
diff changeset
   619
lemma with_wo0_distinct:
Chengsong
parents: 472
diff changeset
   620
  shows "rdistinct rs rset \<leadsto>f* rdistinct rs (insert RZERO rset)"
Chengsong
parents: 472
diff changeset
   621
  apply(induct rs arbitrary: rset)
Chengsong
parents: 472
diff changeset
   622
   apply simp
Chengsong
parents: 472
diff changeset
   623
  apply(case_tac a)
Chengsong
parents: 472
diff changeset
   624
  apply(case_tac "RZERO \<in> rset")
Chengsong
parents: 472
diff changeset
   625
        apply simp+
Chengsong
parents: 472
diff changeset
   626
  using fr_in_rstar frewrite.intros(1) apply presburger
Chengsong
parents: 472
diff changeset
   627
  apply (case_tac "RONE \<in> rset")
Chengsong
parents: 472
diff changeset
   628
       apply simp+
Chengsong
parents: 472
diff changeset
   629
  using frewrites_cons apply presburger
Chengsong
parents: 472
diff changeset
   630
     apply(case_tac "a \<in> rset")
Chengsong
parents: 472
diff changeset
   631
  apply simp
Chengsong
parents: 472
diff changeset
   632
  apply (simp add: frewrites_cons)
Chengsong
parents: 472
diff changeset
   633
     apply(case_tac "a \<in> rset")
Chengsong
parents: 472
diff changeset
   634
  apply simp
Chengsong
parents: 472
diff changeset
   635
  apply (simp add: frewrites_cons)
Chengsong
parents: 472
diff changeset
   636
       apply(case_tac "a \<in> rset")
Chengsong
parents: 472
diff changeset
   637
  apply simp
Chengsong
parents: 472
diff changeset
   638
  apply (simp add: frewrites_cons)
Chengsong
parents: 472
diff changeset
   639
       apply(case_tac "a \<in> rset")
Chengsong
parents: 472
diff changeset
   640
  apply simp
Chengsong
parents: 472
diff changeset
   641
  apply (simp add: frewrites_cons)
Chengsong
parents: 472
diff changeset
   642
  done
Chengsong
parents: 472
diff changeset
   643
476
Chengsong
parents: 475
diff changeset
   644
(*Interesting lemma: not obvious but easily proven by sledgehammer*)
473
Chengsong
parents: 472
diff changeset
   645
476
Chengsong
parents: 475
diff changeset
   646
  
Chengsong
parents: 475
diff changeset
   647
Chengsong
parents: 475
diff changeset
   648
Chengsong
parents: 475
diff changeset
   649
(*lemma induction last rule not go through
Chengsong
parents: 475
diff changeset
   650
 example:
Chengsong
parents: 475
diff changeset
   651
r #
Chengsong
parents: 475
diff changeset
   652
           rdistinct rs1
Chengsong
parents: 475
diff changeset
   653
            (insert RZERO
Chengsong
parents: 475
diff changeset
   654
              (insert r
Chengsong
parents: 475
diff changeset
   655
                (rset \<union>
Chengsong
parents: 475
diff changeset
   656
                 \<Union> (alt_set `
Chengsong
parents: 475
diff changeset
   657
                     rset)))) \<leadsto>g* r #
Chengsong
parents: 475
diff changeset
   658
                                   rdistinct rs2
Chengsong
parents: 475
diff changeset
   659
                                    (insert RZERO (insert r (rset \<union> \<Union> (alt_set ` rset))))
Chengsong
parents: 475
diff changeset
   660
 rs2 = [+rs] rs3 = rs,
Chengsong
parents: 475
diff changeset
   661
r = +rs
Chengsong
parents: 475
diff changeset
   662
[] \<leadsto>g* rs which is wrong
Chengsong
parents: 475
diff changeset
   663
*)
473
Chengsong
parents: 472
diff changeset
   664
lemma frewrite_with_distinct:
Chengsong
parents: 472
diff changeset
   665
  shows " \<lbrakk>rs2 \<leadsto>f rs3\<rbrakk>
Chengsong
parents: 472
diff changeset
   666
       \<Longrightarrow> rdistinct rs2
476
Chengsong
parents: 475
diff changeset
   667
            (insert RZERO (rset \<union> \<Union> (alt_set ` rset))) \<leadsto>g* 
473
Chengsong
parents: 472
diff changeset
   668
           rdistinct rs3 
Chengsong
parents: 472
diff changeset
   669
            (insert RZERO (rset \<union> \<Union> (alt_set ` rset)))"
476
Chengsong
parents: 475
diff changeset
   670
  apply(induct rs2 rs3  arbitrary: rset rule: frewrite.induct)
473
Chengsong
parents: 472
diff changeset
   671
    apply(case_tac "RZERO \<in>  (rset \<union> \<Union> (alt_set ` rset))")
Chengsong
parents: 472
diff changeset
   672
  apply simp
Chengsong
parents: 472
diff changeset
   673
    apply simp
476
Chengsong
parents: 475
diff changeset
   674
473
Chengsong
parents: 472
diff changeset
   675
476
Chengsong
parents: 475
diff changeset
   676
  oops
Chengsong
parents: 475
diff changeset
   677
469
e5dd8cc0aa82 all electron pics removed
Chengsong
parents: 468
diff changeset
   678
e5dd8cc0aa82 all electron pics removed
Chengsong
parents: 468
diff changeset
   679
473
Chengsong
parents: 472
diff changeset
   680
lemma frewrites_with_distinct:
476
Chengsong
parents: 475
diff changeset
   681
  shows "\<lbrakk>rsa \<leadsto>f rsb \<rbrakk> \<Longrightarrow>
Chengsong
parents: 475
diff changeset
   682
( (rs1 @ (rdistinct rsa (insert RZERO (set rs1 \<union> \<Union>(alt_set ` (set rs1) )))) \<leadsto>g* 
Chengsong
parents: 475
diff changeset
   683
 rs1 @ (rdistinct rsb (insert RZERO (set rs1 \<union> \<Union>(alt_set ` (set rs1) )))))
Chengsong
parents: 475
diff changeset
   684
\<or> ( rs1 @ (rdistinct rsb (insert RZERO (set rs1 \<union> \<Union>(alt_set ` (set rs1) )))) \<leadsto>g*
Chengsong
parents: 475
diff changeset
   685
    rs1 @ (rdistinct rsa (insert RZERO (set rs1 \<union> \<Union>(alt_set ` (set rs1) )))))  
Chengsong
parents: 475
diff changeset
   686
 )
Chengsong
parents: 475
diff changeset
   687
"
Chengsong
parents: 475
diff changeset
   688
  apply(induct rsa rsb arbitrary: rs1 rule: frewrite.induct)
Chengsong
parents: 475
diff changeset
   689
    apply simp
Chengsong
parents: 475
diff changeset
   690
   apply(case_tac "RALTS rs \<in> set rs1")
Chengsong
parents: 475
diff changeset
   691
    apply(subgoal_tac "set rs \<subseteq> \<Union> (alt_set `set rs1)")
Chengsong
parents: 475
diff changeset
   692
     apply (metis (full_types) Un_iff Un_insert_left 
Chengsong
parents: 475
diff changeset
   693
Un_insert_right grewrites.intros(1) le_supI2 rdistinct.simps(2) rdistinct_concat)
Chengsong
parents: 475
diff changeset
   694
  apply (metis Un_subset_iff Union_upper alt_set.simps(1) imageI)
Chengsong
parents: 475
diff changeset
   695
Chengsong
parents: 475
diff changeset
   696
   apply(case_tac "RALTS rs \<in> \<Union> (alt_set ` set rs1)")
Chengsong
parents: 475
diff changeset
   697
  apply simp
Chengsong
parents: 475
diff changeset
   698
  apply (smt (z3) UN_insert Un_iff alt_set.simps(1) alt_set_has_all dual_order.trans grewrites.intros(1) insert_absorb rdistinct_concat subset_insertI)
Chengsong
parents: 475
diff changeset
   699
  
Chengsong
parents: 475
diff changeset
   700
Chengsong
parents: 475
diff changeset
   701
  oops
Chengsong
parents: 475
diff changeset
   702
Chengsong
parents: 475
diff changeset
   703
Chengsong
parents: 475
diff changeset
   704
Chengsong
parents: 475
diff changeset
   705
lemma rd_flts_set:
Chengsong
parents: 475
diff changeset
   706
  shows "rs1 \<leadsto>f* rs2 \<Longrightarrow> rdistinct rs1 ({RZERO} \<union>  (rset \<union>  \<Union>(alt_set ` rset))) \<leadsto>g* 
Chengsong
parents: 475
diff changeset
   707
                          rdistinct rs2 ({RZERO} \<union>  (rset \<union>  \<Union>(alt_set ` rset)))"
473
Chengsong
parents: 472
diff changeset
   708
  apply(induct rs1 rs2 rule: frewrites.induct)
Chengsong
parents: 472
diff changeset
   709
   apply simp
476
Chengsong
parents: 475
diff changeset
   710
  oops
Chengsong
parents: 475
diff changeset
   711
Chengsong
parents: 475
diff changeset
   712
lemma frewrite_simpeq:
Chengsong
parents: 475
diff changeset
   713
  shows "rs1 \<leadsto>f rs2 \<Longrightarrow> rsimp (RALTS rs1) = rsimp (RALTS rs2)"
Chengsong
parents: 475
diff changeset
   714
  apply(induct rs1 rs2 rule: frewrite.induct)
Chengsong
parents: 475
diff changeset
   715
    apply simp
Chengsong
parents: 475
diff changeset
   716
  using simp_flatten apply presburger
Chengsong
parents: 475
diff changeset
   717
  by (meson grewrites_cons grewrites_equal_rsimp grewrites_equal_simp_2)
Chengsong
parents: 475
diff changeset
   718
Chengsong
parents: 475
diff changeset
   719
lemma frewrite_rd_grewrites:
Chengsong
parents: 475
diff changeset
   720
  shows "rs1 \<leadsto>f rs2 \<Longrightarrow> 
Chengsong
parents: 475
diff changeset
   721
\<exists>rs3. (rs1 \<leadsto>g* rs3) \<and> (rs2 \<leadsto>g* rs3) "
Chengsong
parents: 475
diff changeset
   722
  apply(induct rs1 rs2 rule: frewrite.induct)
Chengsong
parents: 475
diff changeset
   723
    apply(rule_tac x = "rs" in exI)
Chengsong
parents: 475
diff changeset
   724
    apply(rule conjI)
Chengsong
parents: 475
diff changeset
   725
     apply(rule gr_in_rstar)
Chengsong
parents: 475
diff changeset
   726
  apply(rule grewrite.intros)
Chengsong
parents: 475
diff changeset
   727
    apply(rule grewrites.intros)
Chengsong
parents: 475
diff changeset
   728
  using grewrite.intros(2) apply blast
Chengsong
parents: 475
diff changeset
   729
  by (meson grewrites_cons)
473
Chengsong
parents: 472
diff changeset
   730
476
Chengsong
parents: 475
diff changeset
   731
Chengsong
parents: 475
diff changeset
   732
lemma frewrites_rd_grewrites:
Chengsong
parents: 475
diff changeset
   733
  shows "rs1 \<leadsto>f* rs2 \<Longrightarrow>
Chengsong
parents: 475
diff changeset
   734
\<exists>rs3. (rs1 \<leadsto>g* rs3) \<and> (rs2 \<leadsto>g* rs3)"
Chengsong
parents: 475
diff changeset
   735
  apply(induct rs1 rs2 rule: frewrites.induct)
Chengsong
parents: 475
diff changeset
   736
   apply simp
Chengsong
parents: 475
diff changeset
   737
  apply(rule exI)
Chengsong
parents: 475
diff changeset
   738
  apply(rule grewrites.intros)
Chengsong
parents: 475
diff changeset
   739
  by (metis frewrite_simpeq grewrites_equal_rsimp grewrites_equal_simp_2)
473
Chengsong
parents: 472
diff changeset
   740
476
Chengsong
parents: 475
diff changeset
   741
Chengsong
parents: 475
diff changeset
   742
Chengsong
parents: 475
diff changeset
   743
Chengsong
parents: 475
diff changeset
   744
Chengsong
parents: 475
diff changeset
   745
lemma frewrite_simpeq2:
Chengsong
parents: 475
diff changeset
   746
  shows "rs1 \<leadsto>f rs2 \<Longrightarrow> rsimp (RALTS (rdistinct rs1 {})) = rsimp (RALTS (rdistinct rs2 {}))"
Chengsong
parents: 475
diff changeset
   747
  apply(induct rs1 rs2 rule: frewrite.induct)
Chengsong
parents: 475
diff changeset
   748
    apply simp  
Chengsong
parents: 475
diff changeset
   749
    apply (simp add: distinct_flts_no0)
Chengsong
parents: 475
diff changeset
   750
  apply simp
473
Chengsong
parents: 472
diff changeset
   751
(*a more refined notion of \<leadsto>* is needed,
Chengsong
parents: 472
diff changeset
   752
this lemma fails when rs1 contains some RALTS rs where elements
Chengsong
parents: 472
diff changeset
   753
of rs appear in later parts of rs1, which will be picked up by rs2
Chengsong
parents: 472
diff changeset
   754
and deduplicated*)
476
Chengsong
parents: 475
diff changeset
   755
lemma frewrites_simpeq:
473
Chengsong
parents: 472
diff changeset
   756
  shows "rs1 \<leadsto>f* rs2 \<Longrightarrow>
476
Chengsong
parents: 475
diff changeset
   757
 rsimp (RALTS (rdistinct rs1 {})) = rsimp (RALTS ( rdistinct rs2 {})) "
Chengsong
parents: 475
diff changeset
   758
  apply(induct rs1 rs2 rule: frewrites.induct)
Chengsong
parents: 475
diff changeset
   759
   apply simp
Chengsong
parents: 475
diff changeset
   760
  
Chengsong
parents: 475
diff changeset
   761
  sorry
Chengsong
parents: 475
diff changeset
   762
Chengsong
parents: 475
diff changeset
   763
473
Chengsong
parents: 472
diff changeset
   764
Chengsong
parents: 472
diff changeset
   765
lemma frewrite_single_step:
Chengsong
parents: 472
diff changeset
   766
  shows " rs2 \<leadsto>f rs3 \<Longrightarrow> rsimp (RALTS rs2) = rsimp (RALTS rs3)"
Chengsong
parents: 472
diff changeset
   767
  apply(induct rs2 rs3 rule: frewrite.induct)
Chengsong
parents: 472
diff changeset
   768
    apply simp
Chengsong
parents: 472
diff changeset
   769
  using simp_flatten apply blast
Chengsong
parents: 472
diff changeset
   770
  by (metis (no_types, opaque_lifting) list.simps(9) rsimp.simps(2) simp_flatten2)
Chengsong
parents: 472
diff changeset
   771
Chengsong
parents: 472
diff changeset
   772
lemma frewrites_equivalent_simp:
Chengsong
parents: 472
diff changeset
   773
  shows "rs1 \<leadsto>f* rs2 \<Longrightarrow> rsimp (RALTS rs1) = rsimp (RALTS rs2)"
Chengsong
parents: 472
diff changeset
   774
  apply(induct rs1 rs2 rule: frewrites.induct)
Chengsong
parents: 472
diff changeset
   775
   apply simp
Chengsong
parents: 472
diff changeset
   776
  using frewrite_single_step by presburger
Chengsong
parents: 472
diff changeset
   777
476
Chengsong
parents: 475
diff changeset
   778
lemma grewrite_simpalts:
Chengsong
parents: 475
diff changeset
   779
  shows " rs2 \<leadsto>g rs3 \<Longrightarrow> rsimp (rsimp_ALTs rs2) = rsimp (rsimp_ALTs rs3)"
Chengsong
parents: 475
diff changeset
   780
  apply(induct rs2 rs3 rule : grewrite.induct)
Chengsong
parents: 475
diff changeset
   781
  using identity_wwo0 apply presburger
Chengsong
parents: 475
diff changeset
   782
  apply (metis frewrite.intros(1) frewrite_single_step identity_wwo0 rsimp_ALTs.simps(3) simp_flatten)
Chengsong
parents: 475
diff changeset
   783
  apply (smt (verit, ccfv_SIG) gmany_steps_later grewrites.intros(1) grewrites_cons grewrites_equal_rsimp identity_wwo0 rsimp_ALTs.simps(3))
Chengsong
parents: 475
diff changeset
   784
  apply simp
Chengsong
parents: 475
diff changeset
   785
  apply(subst rsimp_alts_equal)
Chengsong
parents: 475
diff changeset
   786
  apply(case_tac "rsa = [] \<and> rsb = [] \<and> rsc = []")
Chengsong
parents: 475
diff changeset
   787
   apply(subgoal_tac "rsa @ a # rsb @ rsc = [a]")
Chengsong
parents: 475
diff changeset
   788
  apply (simp only:)
Chengsong
parents: 475
diff changeset
   789
  apply (metis append_Nil frewrite.intros(1) frewrite_single_step identity_wwo0 rsimp_ALTs.simps(3) simp_removes_duplicate1(2))
Chengsong
parents: 475
diff changeset
   790
   apply simp
Chengsong
parents: 475
diff changeset
   791
  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)
Chengsong
parents: 475
diff changeset
   792
Chengsong
parents: 475
diff changeset
   793
Chengsong
parents: 475
diff changeset
   794
lemma grewrites_simpalts:
Chengsong
parents: 475
diff changeset
   795
  shows " rs2 \<leadsto>g* rs3 \<Longrightarrow> rsimp (rsimp_ALTs rs2) = rsimp (rsimp_ALTs rs3)"
Chengsong
parents: 475
diff changeset
   796
  apply(induct rs2 rs3 rule: grewrites.induct)
Chengsong
parents: 475
diff changeset
   797
   apply simp
Chengsong
parents: 475
diff changeset
   798
  using grewrite_simpalts by presburger
Chengsong
parents: 475
diff changeset
   799
(*
473
Chengsong
parents: 472
diff changeset
   800
lemma frewrites_dB_wwo0_simp:
Chengsong
parents: 472
diff changeset
   801
  shows "rdistinct rs1 {RZERO} \<leadsto>f* rdistinct rs2 {RZERO} 
Chengsong
parents: 472
diff changeset
   802
         \<Longrightarrow> rsimp (RALTS (rdistinct rs1 {})) = rsimp (RALTS (rdistinct rs2 {}))"
Chengsong
parents: 472
diff changeset
   803
Chengsong
parents: 472
diff changeset
   804
  sorry
476
Chengsong
parents: 475
diff changeset
   805
*)
Chengsong
parents: 475
diff changeset
   806
lemma "rsimp (rsimp_ALTs (RZERO # rdistinct (map (rder x) (rflts rs)) {RZERO})) =
Chengsong
parents: 475
diff changeset
   807
       rsimp (rsimp_ALTs (rdistinct (map (rder x) (rflts rs)) {})) "
Chengsong
parents: 475
diff changeset
   808
Chengsong
parents: 475
diff changeset
   809
  sorry
473
Chengsong
parents: 472
diff changeset
   810
Chengsong
parents: 472
diff changeset
   811
Chengsong
parents: 472
diff changeset
   812
467
Chengsong
parents: 465
diff changeset
   813
lemma simp_der_flts:
471
Chengsong
parents: 469
diff changeset
   814
  shows "rsimp (RALTS (rdistinct (map (rder x) (rflts rs)) {})) = 
Chengsong
parents: 469
diff changeset
   815
         rsimp (RALTS (rdistinct (rflts (map (rder x) rs)) {}))"
473
Chengsong
parents: 472
diff changeset
   816
  apply(subgoal_tac "map (rder x) (rflts rs) \<leadsto>f* rflts (map (rder x) rs)")
Chengsong
parents: 472
diff changeset
   817
   apply(subgoal_tac "rdistinct (map (rder x) (rflts rs)) {RZERO} 
476
Chengsong
parents: 475
diff changeset
   818
                    \<leadsto>g* rdistinct ( rflts (map (rder x) rs)) {RZERO}")
473
Chengsong
parents: 472
diff changeset
   819
  apply(subgoal_tac "rsimp (RALTS (rdistinct (map (rder x) (rflts rs)) {})) 
Chengsong
parents: 472
diff changeset
   820
                   = rsimp (RALTS ( rdistinct ( rflts (map (rder x) rs)) {}))")
Chengsong
parents: 472
diff changeset
   821
  apply meson
476
Chengsong
parents: 475
diff changeset
   822
  apply (metis distinct_flts_no0 grewrites_equal_rsimp rsimp.simps(2))
Chengsong
parents: 475
diff changeset
   823
  sorry
Chengsong
parents: 475
diff changeset
   824
Chengsong
parents: 475
diff changeset
   825
Chengsong
parents: 475
diff changeset
   826
Chengsong
parents: 475
diff changeset
   827
Chengsong
parents: 475
diff changeset
   828
 
Chengsong
parents: 475
diff changeset
   829
Chengsong
parents: 475
diff changeset
   830
Chengsong
parents: 475
diff changeset
   831
Chengsong
parents: 475
diff changeset
   832
lemma simp_der_pierce_flts_prelim:
Chengsong
parents: 475
diff changeset
   833
  shows "rsimp (rsimp_ALTs (rdistinct (map (rder x) (rflts rs)) {})) 
Chengsong
parents: 475
diff changeset
   834
       = rsimp (rsimp_ALTs (rdistinct (rflts (map (rder x) rs)) {}))"
Chengsong
parents: 475
diff changeset
   835
  apply(subgoal_tac "map (rder x) (rflts rs) \<leadsto>g* rflts (map (rder x) rs)")
Chengsong
parents: 475
diff changeset
   836
  apply(subgoal_tac "rdistinct (map (rder x) (rflts rs)) {RZERO} \<leadsto>g* rdistinct (rflts (map (rder x) rs)) {RZERO}")
Chengsong
parents: 475
diff changeset
   837
  using grewrites_equal_simp_2 grewrites_simpalts simp_der_flts apply blast
Chengsong
parents: 475
diff changeset
   838
  apply (simp add: early_late_der_frewrites frewrites_with_distinct2_grewrites)
Chengsong
parents: 475
diff changeset
   839
  using early_late_der_frewrites frewrites_equivalent_simp grewrites_equal_simp_2 by blast
467
Chengsong
parents: 465
diff changeset
   840
Chengsong
parents: 465
diff changeset
   841
465
Chengsong
parents: 456
diff changeset
   842
lemma simp_der_pierce_flts:
471
Chengsong
parents: 469
diff changeset
   843
  shows " rsimp (
Chengsong
parents: 469
diff changeset
   844
rsimp_ALTs (rdistinct (map (rder x) (rflts (map (rsimp \<circ> (\<lambda>r. rders_simp r xs)) rs))) {})
Chengsong
parents: 469
diff changeset
   845
) =
Chengsong
parents: 469
diff changeset
   846
          rsimp (
Chengsong
parents: 469
diff changeset
   847
rsimp_ALTs (rdistinct (rflts (map (rder x) (map (rsimp \<circ> (\<lambda>r. rders_simp r xs)) rs))) {})
Chengsong
parents: 469
diff changeset
   848
)"
476
Chengsong
parents: 475
diff changeset
   849
  using simp_der_pierce_flts_prelim by presburger
465
Chengsong
parents: 456
diff changeset
   850
453
Chengsong
parents: 451
diff changeset
   851
Chengsong
parents: 451
diff changeset
   852
Chengsong
parents: 451
diff changeset
   853
lemma simp_more_distinct:
465
Chengsong
parents: 456
diff changeset
   854
  shows "rsimp  (rsimp_ALTs (rsa @ rs)) = rsimp (rsimp_ALTs (rsa @ (rdistinct rs (set rsa)))) "
467
Chengsong
parents: 465
diff changeset
   855
  
Chengsong
parents: 465
diff changeset
   856
465
Chengsong
parents: 456
diff changeset
   857
453
Chengsong
parents: 451
diff changeset
   858
Chengsong
parents: 451
diff changeset
   859
  sorry
Chengsong
parents: 451
diff changeset
   860
Chengsong
parents: 451
diff changeset
   861
lemma non_empty_list:
Chengsong
parents: 451
diff changeset
   862
  shows "a \<in> set as \<Longrightarrow> as \<noteq> []"
Chengsong
parents: 451
diff changeset
   863
  by (metis empty_iff empty_set)
Chengsong
parents: 451
diff changeset
   864
456
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
   865
lemma distinct_comp:
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
   866
  shows "rdistinct (rs1@rs2) {} = (rdistinct rs1 {}) @ (rdistinct rs2 (set rs1))"
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
   867
  apply(induct rs2 arbitrary: rs1)
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
   868
   apply simp
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
   869
  apply(subgoal_tac "rs1 @ a # rs2 = (rs1 @ [a]) @ rs2")
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
   870
   apply(simp only:)
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
   871
   apply(case_tac "a \<in> set rs1")
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
   872
    apply simp
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
   873
  oops
453
Chengsong
parents: 451
diff changeset
   874
456
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
   875
lemma instantiate1:
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
   876
  shows "\<lbrakk>\<And>ab rset1.  rdistinct (ab # as) rset1 = rdistinct (ab # as @ [ab]) rset1\<rbrakk> \<Longrightarrow>  
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
   877
rdistinct (aa # as) rset = rdistinct (aa # as @ [aa]) rset"
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
   878
  apply(drule_tac x = "aa" in meta_spec)
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
   879
  apply(drule_tac x = "rset" in meta_spec)
453
Chengsong
parents: 451
diff changeset
   880
  apply simp
456
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
   881
  done
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
   882
  
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
   883
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
   884
lemma not_head_elem:
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
   885
  shows " \<lbrakk>aa \<in> set (a # as); aa \<notin> (set as)\<rbrakk> \<Longrightarrow> a = aa"
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
   886
  
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
   887
  by fastforce
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
   888
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
   889
(*
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
   890
  apply simp
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
   891
  apply (metis append_Cons)
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
   892
  apply(case_tac "ab \<in> rset1")
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
   893
  apply (metis (no_types, opaque_lifting) Un_insert_left append_Cons insert_iff rdistinct.simps(2) sup_bot_left)
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
   894
  apply(subgoal_tac "rdistinct (ab # (aa # as) @ [ab]) rset1 = 
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
   895
               ab # (rdistinct ((aa # as) @ [ab]) (insert ab rset1))")
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
   896
   apply(simp only:)
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
   897
   apply(subgoal_tac "rdistinct (ab # aa # as) rset1 = ab # (rdistinct (aa # as) (insert ab rset1))")
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
   898
  apply(simp only:)
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
   899
    apply(subgoal_tac "rdistinct ((aa # as) @ [ab]) (insert ab rset1) = rdistinct (aa # as) (insert ab rset1)")
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
   900
  apply blast
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
   901
*)
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
   902
  
453
Chengsong
parents: 451
diff changeset
   903
Chengsong
parents: 451
diff changeset
   904
lemma flts_identity1:
Chengsong
parents: 451
diff changeset
   905
  shows  "rflts (rs @ [RONE]) = rflts rs @ [RONE] "
Chengsong
parents: 451
diff changeset
   906
  apply(induct rs)
Chengsong
parents: 451
diff changeset
   907
   apply simp+
Chengsong
parents: 451
diff changeset
   908
  apply(case_tac a)
Chengsong
parents: 451
diff changeset
   909
       apply simp
Chengsong
parents: 451
diff changeset
   910
      apply simp+
Chengsong
parents: 451
diff changeset
   911
  done
Chengsong
parents: 451
diff changeset
   912
Chengsong
parents: 451
diff changeset
   913
lemma flts_identity10:
Chengsong
parents: 451
diff changeset
   914
  shows " rflts (rs @ [RCHAR c]) = rflts rs @ [RCHAR c]"
Chengsong
parents: 451
diff changeset
   915
  apply(induct rs)
Chengsong
parents: 451
diff changeset
   916
   apply simp+
Chengsong
parents: 451
diff changeset
   917
  apply(case_tac a)
Chengsong
parents: 451
diff changeset
   918
       apply simp+
Chengsong
parents: 451
diff changeset
   919
  done
Chengsong
parents: 451
diff changeset
   920
Chengsong
parents: 451
diff changeset
   921
lemma flts_identity11:
Chengsong
parents: 451
diff changeset
   922
  shows " rflts (rs @ [RSEQ r1 r2]) = rflts rs @ [RSEQ r1 r2]"
Chengsong
parents: 451
diff changeset
   923
  apply(induct rs)
Chengsong
parents: 451
diff changeset
   924
   apply simp+
Chengsong
parents: 451
diff changeset
   925
  apply(case_tac a)
Chengsong
parents: 451
diff changeset
   926
       apply simp+
Chengsong
parents: 451
diff changeset
   927
  done
Chengsong
parents: 451
diff changeset
   928
Chengsong
parents: 451
diff changeset
   929
lemma flts_identity12:
Chengsong
parents: 451
diff changeset
   930
  shows " rflts (rs @ [RSTAR r0]) = rflts rs @ [RSTAR r0]"
Chengsong
parents: 451
diff changeset
   931
  apply(induct rs)
Chengsong
parents: 451
diff changeset
   932
   apply simp+
Chengsong
parents: 451
diff changeset
   933
  apply(case_tac a)
Chengsong
parents: 451
diff changeset
   934
       apply simp+
Chengsong
parents: 451
diff changeset
   935
  done
Chengsong
parents: 451
diff changeset
   936
Chengsong
parents: 451
diff changeset
   937
lemma flts_identity2:
Chengsong
parents: 451
diff changeset
   938
  shows "a \<noteq> RZERO \<and> (\<forall>rs. a \<noteq> RALTS rs) \<Longrightarrow>  rflts (rs @ [a]) = rflts rs @ [a]"
Chengsong
parents: 451
diff changeset
   939
  apply(case_tac a)
Chengsong
parents: 451
diff changeset
   940
       apply simp
Chengsong
parents: 451
diff changeset
   941
  using flts_identity1 apply auto[1]
Chengsong
parents: 451
diff changeset
   942
  using flts_identity10 apply blast
Chengsong
parents: 451
diff changeset
   943
  using flts_identity11 apply auto[1]
Chengsong
parents: 451
diff changeset
   944
   apply blast
Chengsong
parents: 451
diff changeset
   945
  using flts_identity12 by presburger
456
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
   946
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
   947
lemma flts_identity3:
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
   948
  shows "a = RZERO  \<Longrightarrow> rflts (rs @ [a]) = rflts rs"
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
   949
  apply simp
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
   950
  apply(induct rs)
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
   951
   apply simp+
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
   952
  apply(case_tac aa)
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
   953
       apply simp+
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
   954
  done
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
   955
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
   956
lemma distinct_removes_last3:
465
Chengsong
parents: 456
diff changeset
   957
  shows "\<lbrakk>a \<in> set as\<rbrakk>
456
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
   958
    \<Longrightarrow> rdistinct as {} = rdistinct (as @ [a]) {}"
465
Chengsong
parents: 456
diff changeset
   959
  by (simp add: distinct_removes_last2)
456
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
   960
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
   961
lemma set_inclusion_with_flts1:
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
   962
  shows " \<lbrakk>RONE \<in> set rs\<rbrakk> \<Longrightarrow> RONE  \<in> set (rflts rs)"
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
   963
  apply(induct rs)
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
   964
   apply simp
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
   965
  apply(case_tac " RONE \<in> set rs")
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
   966
   apply simp
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
   967
  apply (metis Un_upper2 insert_absorb insert_subset list.set_intros(2) rflts.simps(2) rflts.simps(3) rflts_def_idiot set_append)
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
   968
  apply(case_tac "RONE = a")
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
   969
   apply simp
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
   970
  apply simp
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
   971
  done
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
   972
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
   973
lemma set_inclusion_with_flts10:
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
   974
  shows " \<lbrakk>RCHAR x \<in> set rs\<rbrakk> \<Longrightarrow> RCHAR x  \<in> set (rflts rs)"
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
   975
  apply(induct rs)
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
   976
   apply simp
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
   977
  apply(case_tac " RCHAR x \<in> set rs")
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
   978
   apply simp
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
   979
  apply (metis Un_upper2 insert_absorb insert_subset rflts.simps(2) rflts.simps(3) rflts_def_idiot set_append set_subset_Cons)
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
   980
  apply(case_tac "RCHAR x = a")
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
   981
   apply simp
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
   982
  apply fastforce
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
   983
  apply simp
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
   984
  done
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
   985
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
   986
lemma set_inclusion_with_flts11:
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
   987
  shows " \<lbrakk>RSEQ r1 r2 \<in> set rs\<rbrakk> \<Longrightarrow> RSEQ r1 r2  \<in> set (rflts rs)"
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
   988
  apply(induct rs)
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
   989
   apply simp
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
   990
  apply(case_tac " RSEQ r1 r2 \<in> set rs")
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
   991
   apply simp
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
   992
  apply (metis Un_upper2 insert_absorb insert_subset rflts.simps(2) rflts.simps(3) rflts_def_idiot set_append set_subset_Cons)
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
   993
  apply(case_tac "RSEQ r1 r2 = a")
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
   994
   apply simp
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
   995
  apply fastforce
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
   996
  apply simp
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
   997
  done
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
   998
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
   999
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
  1000
lemma set_inclusion_with_flts:
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
  1001
  shows " \<lbrakk>a \<in> set as; rsimp a \<in> set (map rsimp as); rsimp a = RONE\<rbrakk> \<Longrightarrow> rsimp a \<in> set (rflts (map rsimp as))"
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
  1002
  by (simp add: set_inclusion_with_flts1)
453
Chengsong
parents: 451
diff changeset
  1003
  
456
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
  1004
lemma "\<And>x5. \<lbrakk>a \<in> set as; rsimp a \<in> set (map rsimp as); rsimp a = RALTS x5\<rbrakk>
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
  1005
          \<Longrightarrow> rsimp_ALTs (rdistinct (rflts (map rsimp as @ [rsimp a])) {}) = 
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
  1006
rsimp_ALTs (rdistinct (rflts (map rsimp as @ x5)) {})"
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
  1007
465
Chengsong
parents: 456
diff changeset
  1008
  sorry
Chengsong
parents: 456
diff changeset
  1009
453
Chengsong
parents: 451
diff changeset
  1010
Chengsong
parents: 451
diff changeset
  1011
lemma last_elem_dup1:
Chengsong
parents: 451
diff changeset
  1012
  shows " a \<in> set as \<Longrightarrow> rsimp (RALTS (as @ [a] )) = rsimp (RALTS (as ))"
Chengsong
parents: 451
diff changeset
  1013
  apply simp
Chengsong
parents: 451
diff changeset
  1014
  apply(subgoal_tac "rsimp a \<in> set (map rsimp as)")
Chengsong
parents: 451
diff changeset
  1015
  prefer 2
Chengsong
parents: 451
diff changeset
  1016
   apply simp
456
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
  1017
  apply(case_tac "rsimp a")
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
  1018
       apply simp
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
  1019
  
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
  1020
  using flts_identity3 apply presburger
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
  1021
      apply(subst flts_identity2)
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
  1022
  using rrexp.distinct(1) rrexp.distinct(15) apply presburger
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
  1023
      apply(subst distinct_removes_last3[symmetric])
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
  1024
  using set_inclusion_with_flts apply blast
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
  1025
  apply simp
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
  1026
  apply (metis distinct_removes_last3 flts_identity10 set_inclusion_with_flts10)
26a5e640cdd7 realPhdThesis
Chengsong
parents: 453
diff changeset
  1027
  apply (metis distinct_removes_last3 flts_identity11 set_inclusion_with_flts11)
453
Chengsong
parents: 451
diff changeset
  1028
  sorry
Chengsong
parents: 451
diff changeset
  1029
Chengsong
parents: 451
diff changeset
  1030
lemma last_elem_dup:
Chengsong
parents: 451
diff changeset
  1031
  shows " a \<in> set as \<Longrightarrow> rsimp (rsimp_ALTs (as @ [a] )) = rsimp (rsimp_ALTs (as ))"
Chengsong
parents: 451
diff changeset
  1032
  apply(induct as rule: rev_induct)
Chengsong
parents: 451
diff changeset
  1033
   apply simp
Chengsong
parents: 451
diff changeset
  1034
  apply simp
Chengsong
parents: 451
diff changeset
  1035
  apply(subgoal_tac "xs \<noteq> []")
Chengsong
parents: 451
diff changeset
  1036
  prefer 2
Chengsong
parents: 451
diff changeset
  1037
  
Chengsong
parents: 451
diff changeset
  1038
Chengsong
parents: 451
diff changeset
  1039
  
Chengsong
parents: 451
diff changeset
  1040
Chengsong
parents: 451
diff changeset
  1041
  sorry
Chengsong
parents: 451
diff changeset
  1042
Chengsong
parents: 451
diff changeset
  1043
lemma appeared_before_remove_later:
Chengsong
parents: 451
diff changeset
  1044
  shows "a \<in>  set as \<Longrightarrow> rsimp (rsimp_ALTs ( as @ a # rs)) = rsimp (rsimp_ALTs (as @ rs))"
Chengsong
parents: 451
diff changeset
  1045
and "a \<in> set as \<Longrightarrow> rsimp (rsimp_ALTs as ) = rsimp (rsimp_ALTs (as @ [a]))"
Chengsong
parents: 451
diff changeset
  1046
  apply(induct rs arbitrary: as)
Chengsong
parents: 451
diff changeset
  1047
   apply simp
Chengsong
parents: 451
diff changeset
  1048
  
Chengsong
parents: 451
diff changeset
  1049
Chengsong
parents: 451
diff changeset
  1050
  sorry
Chengsong
parents: 451
diff changeset
  1051
Chengsong
parents: 451
diff changeset
  1052
lemma distinct_remove_later:
Chengsong
parents: 451
diff changeset
  1053
  shows "\<lbrakk>rder x a \<in> rder x ` set rsa\<rbrakk>
Chengsong
parents: 451
diff changeset
  1054
       \<Longrightarrow> rsimp (rsimp_ALTs (map (rder x) rsa @ rder x a # map (rder x) (rdistinct rs (insert a (set rsa))))) =
Chengsong
parents: 451
diff changeset
  1055
           rsimp (rsimp_ALTs (map (rder x) rsa @ map (rder x) (rdistinct rs (set rsa))))"
451
7a016eeb118d finiteness
Chengsong
parents: 445
diff changeset
  1056
  
7a016eeb118d finiteness
Chengsong
parents: 445
diff changeset
  1057
  sorry
7a016eeb118d finiteness
Chengsong
parents: 445
diff changeset
  1058
7a016eeb118d finiteness
Chengsong
parents: 445
diff changeset
  1059
453
Chengsong
parents: 451
diff changeset
  1060
lemma distinct_der_general:
Chengsong
parents: 451
diff changeset
  1061
  shows "rsimp (rsimp_ALTs (map (rder x) (rsa @ (rdistinct rs (set rsa))))) =
Chengsong
parents: 451
diff changeset
  1062
 rsimp ( rsimp_ALTs ((map (rder x) rsa)@(rdistinct (map (rder x) rs) (set (map (rder x) rsa)))) )"
Chengsong
parents: 451
diff changeset
  1063
  apply(induct rs arbitrary: rsa)
Chengsong
parents: 451
diff changeset
  1064
   apply simp
Chengsong
parents: 451
diff changeset
  1065
  apply(case_tac "a \<in> set rsa")
Chengsong
parents: 451
diff changeset
  1066
   apply(subgoal_tac "rder x a \<in> set (map (rder x) rsa)")
Chengsong
parents: 451
diff changeset
  1067
  apply simp
Chengsong
parents: 451
diff changeset
  1068
   apply simp
Chengsong
parents: 451
diff changeset
  1069
  apply(case_tac "rder x a \<notin> set (map (rder x) rsa)")
Chengsong
parents: 451
diff changeset
  1070
   apply(simp)
Chengsong
parents: 451
diff changeset
  1071
  apply(subst map_concat_cons)+
Chengsong
parents: 451
diff changeset
  1072
  apply(drule_tac x = "rsa @ [a]" in meta_spec)
Chengsong
parents: 451
diff changeset
  1073
   apply simp
Chengsong
parents: 451
diff changeset
  1074
  apply(drule neg_removal_element_of)
Chengsong
parents: 451
diff changeset
  1075
  apply simp
Chengsong
parents: 451
diff changeset
  1076
  apply(subst distinct_remove_later)
Chengsong
parents: 451
diff changeset
  1077
   apply simp
Chengsong
parents: 451
diff changeset
  1078
  apply(drule_tac x = "rsa" in meta_spec)
Chengsong
parents: 451
diff changeset
  1079
  by blast
Chengsong
parents: 451
diff changeset
  1080
Chengsong
parents: 451
diff changeset
  1081
  
Chengsong
parents: 451
diff changeset
  1082
Chengsong
parents: 451
diff changeset
  1083
451
7a016eeb118d finiteness
Chengsong
parents: 445
diff changeset
  1084
lemma distinct_der:
7a016eeb118d finiteness
Chengsong
parents: 445
diff changeset
  1085
  shows "rsimp (rsimp_ALTs (map (rder x) (rdistinct rs {}))) = rsimp ( rsimp_ALTs (rdistinct (map (rder x) rs) {}))"
453
Chengsong
parents: 451
diff changeset
  1086
  by (metis distinct_der_general list.simps(8) self_append_conv2 set_empty)
451
7a016eeb118d finiteness
Chengsong
parents: 445
diff changeset
  1087
453
Chengsong
parents: 451
diff changeset
  1088
  
Chengsong
parents: 451
diff changeset
  1089
Chengsong
parents: 451
diff changeset
  1090
Chengsong
parents: 451
diff changeset
  1091
lemma rders_simp_lambda:
Chengsong
parents: 451
diff changeset
  1092
  shows " rsimp \<circ> rder x \<circ> (\<lambda>r. rders_simp r xs) = (\<lambda>r. rders_simp r (xs @ [x]))"
Chengsong
parents: 451
diff changeset
  1093
  using rders_simp_append by auto
451
7a016eeb118d finiteness
Chengsong
parents: 445
diff changeset
  1094
453
Chengsong
parents: 451
diff changeset
  1095
lemma rders_simp_nonempty_simped:
Chengsong
parents: 451
diff changeset
  1096
  shows "xs \<noteq> [] \<Longrightarrow> rsimp \<circ> (\<lambda>r. rders_simp r xs) = (\<lambda>r. rders_simp r xs)"
Chengsong
parents: 451
diff changeset
  1097
  using rders_simp_same_simpders rsimp_idem by auto
Chengsong
parents: 451
diff changeset
  1098
Chengsong
parents: 451
diff changeset
  1099
lemma repeated_altssimp:
Chengsong
parents: 451
diff changeset
  1100
  shows "\<forall>r \<in> set rs. rsimp r = r \<Longrightarrow> rsimp (rsimp_ALTs (rdistinct (rflts rs) {})) =
Chengsong
parents: 451
diff changeset
  1101
           rsimp_ALTs (rdistinct (rflts rs) {})"
Chengsong
parents: 451
diff changeset
  1102
  by (metis map_idI rsimp.simps(2) rsimp_idem)
451
7a016eeb118d finiteness
Chengsong
parents: 445
diff changeset
  1103
465
Chengsong
parents: 456
diff changeset
  1104
Chengsong
parents: 456
diff changeset
  1105
lemma add0_isomorphic:
Chengsong
parents: 456
diff changeset
  1106
  shows "rsimp_ALTs (rdistinct (rflts [rsimp r, RZERO]) {}) = rsimp r"
Chengsong
parents: 456
diff changeset
  1107
  sorry
Chengsong
parents: 456
diff changeset
  1108
Chengsong
parents: 456
diff changeset
  1109
Chengsong
parents: 456
diff changeset
  1110
lemma distinct_append_simp:
Chengsong
parents: 456
diff changeset
  1111
  shows " rsimp (rsimp_ALTs rs1) = rsimp (rsimp_ALTs rs2) \<Longrightarrow>
Chengsong
parents: 456
diff changeset
  1112
           rsimp (rsimp_ALTs (f a # rs1)) =
Chengsong
parents: 456
diff changeset
  1113
           rsimp (rsimp_ALTs (f a # rs2))"
Chengsong
parents: 456
diff changeset
  1114
  apply(case_tac rs1)
Chengsong
parents: 456
diff changeset
  1115
   apply simp
Chengsong
parents: 456
diff changeset
  1116
   apply(case_tac rs2)
Chengsong
parents: 456
diff changeset
  1117
    apply simp
Chengsong
parents: 456
diff changeset
  1118
   apply simp
Chengsong
parents: 456
diff changeset
  1119
   prefer 2
Chengsong
parents: 456
diff changeset
  1120
   apply(case_tac list)
Chengsong
parents: 456
diff changeset
  1121
    apply(case_tac rs2)
Chengsong
parents: 456
diff changeset
  1122
     apply simp
Chengsong
parents: 456
diff changeset
  1123
  using add0_isomorphic apply blast 
Chengsong
parents: 456
diff changeset
  1124
    apply simp
467
Chengsong
parents: 465
diff changeset
  1125
  oops
465
Chengsong
parents: 456
diff changeset
  1126
444
a7e98deebb5c restructured sizebound proof
Chengsong
parents: 443
diff changeset
  1127
lemma alts_closed_form: shows 
a7e98deebb5c restructured sizebound proof
Chengsong
parents: 443
diff changeset
  1128
"rsimp (rders_simp (RALTS rs) s) = 
a7e98deebb5c restructured sizebound proof
Chengsong
parents: 443
diff changeset
  1129
rsimp (RALTS (map (\<lambda>r. rders_simp r s) rs))"
a7e98deebb5c restructured sizebound proof
Chengsong
parents: 443
diff changeset
  1130
  apply(induct s rule: rev_induct)
a7e98deebb5c restructured sizebound proof
Chengsong
parents: 443
diff changeset
  1131
   apply simp
a7e98deebb5c restructured sizebound proof
Chengsong
parents: 443
diff changeset
  1132
  apply simp
a7e98deebb5c restructured sizebound proof
Chengsong
parents: 443
diff changeset
  1133
  apply(subst rders_simp_append)
a7e98deebb5c restructured sizebound proof
Chengsong
parents: 443
diff changeset
  1134
  apply(subgoal_tac " rsimp (rders_simp (rders_simp (RALTS rs) xs) [x]) = 
a7e98deebb5c restructured sizebound proof
Chengsong
parents: 443
diff changeset
  1135
 rsimp(rders_simp (rsimp_ALTs (rdistinct (rflts (map (rsimp \<circ> (\<lambda>r. rders_simp r xs)) rs)) {})) [x])")
a7e98deebb5c restructured sizebound proof
Chengsong
parents: 443
diff changeset
  1136
   prefer 2
a7e98deebb5c restructured sizebound proof
Chengsong
parents: 443
diff changeset
  1137
  apply (metis inside_simp_removal rders_simp_one_char)
a7e98deebb5c restructured sizebound proof
Chengsong
parents: 443
diff changeset
  1138
  apply(simp only: )
451
7a016eeb118d finiteness
Chengsong
parents: 445
diff changeset
  1139
  apply(subst rders_simp_one_char)
7a016eeb118d finiteness
Chengsong
parents: 445
diff changeset
  1140
  apply(subst rsimp_idem)
7a016eeb118d finiteness
Chengsong
parents: 445
diff changeset
  1141
  apply(subgoal_tac "rsimp (rder x (rsimp_ALTs (rdistinct (rflts (map (rsimp \<circ> (\<lambda>r. rders_simp r xs)) rs)) {}))) =
7a016eeb118d finiteness
Chengsong
parents: 445
diff changeset
  1142
                     rsimp ((rsimp_ALTs (map (rder x) (rdistinct (rflts (map (rsimp \<circ> (\<lambda>r. rders_simp r xs)) rs)) {})))) ")
7a016eeb118d finiteness
Chengsong
parents: 445
diff changeset
  1143
  prefer 2
7a016eeb118d finiteness
Chengsong
parents: 445
diff changeset
  1144
  using rder_rsimp_ALTs_commute apply presburger
7a016eeb118d finiteness
Chengsong
parents: 445
diff changeset
  1145
  apply(simp only:)
7a016eeb118d finiteness
Chengsong
parents: 445
diff changeset
  1146
  apply(subgoal_tac "rsimp (rsimp_ALTs (map (rder x) (rdistinct (rflts (map (rsimp \<circ> (\<lambda>r. rders_simp r xs)) rs)) {})))
7a016eeb118d finiteness
Chengsong
parents: 445
diff changeset
  1147
= rsimp (rsimp_ALTs (rdistinct (map (rder x) (rflts (map (rsimp \<circ> (\<lambda>r. rders_simp r xs)) rs))) {}))")
7a016eeb118d finiteness
Chengsong
parents: 445
diff changeset
  1148
   prefer 2
7a016eeb118d finiteness
Chengsong
parents: 445
diff changeset
  1149
  
7a016eeb118d finiteness
Chengsong
parents: 445
diff changeset
  1150
  using distinct_der apply presburger
7a016eeb118d finiteness
Chengsong
parents: 445
diff changeset
  1151
  apply(simp only:)
453
Chengsong
parents: 451
diff changeset
  1152
  apply(subgoal_tac " rsimp (rsimp_ALTs (rdistinct (map (rder x) (rflts (map (rsimp \<circ> (\<lambda>r. rders_simp r xs)) rs))) {})) =
Chengsong
parents: 451
diff changeset
  1153
                      rsimp (rsimp_ALTs (rdistinct ( (rflts (map (rder x) (map (rsimp \<circ> (\<lambda>r. rders_simp r xs)) rs)))) {}))")
Chengsong
parents: 451
diff changeset
  1154
   apply(simp only:)
Chengsong
parents: 451
diff changeset
  1155
  apply(subgoal_tac " rsimp (rsimp_ALTs (rdistinct (rflts (map (rder x) (map (rsimp \<circ> (\<lambda>r. rders_simp r xs)) rs))) {})) = 
Chengsong
parents: 451
diff changeset
  1156
                      rsimp (rsimp_ALTs (rdistinct (rflts ( (map (rsimp \<circ> (rder x) \<circ> (\<lambda>r. rders_simp r xs)) rs))) {}))")
Chengsong
parents: 451
diff changeset
  1157
    apply(simp only:)
Chengsong
parents: 451
diff changeset
  1158
  apply(subst rders_simp_lambda)
Chengsong
parents: 451
diff changeset
  1159
    apply(subst rders_simp_nonempty_simped)
Chengsong
parents: 451
diff changeset
  1160
     apply simp
Chengsong
parents: 451
diff changeset
  1161
    apply(subgoal_tac "\<forall>r \<in> set  (map (\<lambda>r. rders_simp r (xs @ [x])) rs). rsimp r = r")
Chengsong
parents: 451
diff changeset
  1162
  prefer 2
Chengsong
parents: 451
diff changeset
  1163
     apply (simp add: rders_simp_same_simpders rsimp_idem)
Chengsong
parents: 451
diff changeset
  1164
    apply(subst repeated_altssimp)
Chengsong
parents: 451
diff changeset
  1165
     apply simp
Chengsong
parents: 451
diff changeset
  1166
  apply fastforce
465
Chengsong
parents: 456
diff changeset
  1167
   apply (metis inside_simp_removal list.map_comp rder.simps(4) rsimp.simps(2) rsimp_idem)
476
Chengsong
parents: 475
diff changeset
  1168
  using simp_der_pierce_flts by blast
443
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
  1169
444
a7e98deebb5c restructured sizebound proof
Chengsong
parents: 443
diff changeset
  1170
lemma alts_closed_form_variant: shows 
a7e98deebb5c restructured sizebound proof
Chengsong
parents: 443
diff changeset
  1171
"s \<noteq> [] \<Longrightarrow> rders_simp (RALTS rs) s = 
a7e98deebb5c restructured sizebound proof
Chengsong
parents: 443
diff changeset
  1172
rsimp (RALTS (map (\<lambda>r. rders_simp r s) rs))"
a7e98deebb5c restructured sizebound proof
Chengsong
parents: 443
diff changeset
  1173
  sorry
443
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
  1174
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
  1175
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
  1176
444
a7e98deebb5c restructured sizebound proof
Chengsong
parents: 443
diff changeset
  1177
lemma star_closed_form:
a7e98deebb5c restructured sizebound proof
Chengsong
parents: 443
diff changeset
  1178
  shows "rders_simp (RSTAR r0) (c#s) = 
a7e98deebb5c restructured sizebound proof
Chengsong
parents: 443
diff changeset
  1179
rsimp ( RALTS ( (map (\<lambda>s1. RSEQ (rders_simp r0 s1) (RSTAR r0) ) (star_updates s r0 [[c]]) ) ))"
a7e98deebb5c restructured sizebound proof
Chengsong
parents: 443
diff changeset
  1180
  apply(induct s)
a7e98deebb5c restructured sizebound proof
Chengsong
parents: 443
diff changeset
  1181
   apply simp
a7e98deebb5c restructured sizebound proof
Chengsong
parents: 443
diff changeset
  1182
  sorry
443
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
  1183
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
  1184
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
  1185
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
  1186
lemma seq_closed_form: shows 
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
  1187
"rsimp (rders_simp (RSEQ r1 r2) s) = 
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
  1188
rsimp ( RALTS ( (RSEQ (rders_simp r1 s) r2) # 
445
e072cfc2f2ee closedforms
Chengsong
parents: 444
diff changeset
  1189
                (map (rders_simp r2) (vsuf s r1)) 
443
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
  1190
              )  
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
  1191
      )"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
  1192
  apply(induct s)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
  1193
  apply simp
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
  1194
  sorry
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
  1195
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
  1196
444
a7e98deebb5c restructured sizebound proof
Chengsong
parents: 443
diff changeset
  1197
lemma seq_closed_form_variant: shows
a7e98deebb5c restructured sizebound proof
Chengsong
parents: 443
diff changeset
  1198
"s \<noteq> [] \<Longrightarrow> (rders_simp (RSEQ r1 r2) s) = 
a7e98deebb5c restructured sizebound proof
Chengsong
parents: 443
diff changeset
  1199
rsimp (RALTS ((RSEQ (rders_simp r1 s) r2) # (map (rders_simp r2) (vsuf s r1))))"
445
e072cfc2f2ee closedforms
Chengsong
parents: 444
diff changeset
  1200
  apply(induct s rule: rev_induct)
e072cfc2f2ee closedforms
Chengsong
parents: 444
diff changeset
  1201
   apply simp
e072cfc2f2ee closedforms
Chengsong
parents: 444
diff changeset
  1202
  apply(subst rders_simp_append)
e072cfc2f2ee closedforms
Chengsong
parents: 444
diff changeset
  1203
  apply(subst rders_simp_one_char)
e072cfc2f2ee closedforms
Chengsong
parents: 444
diff changeset
  1204
  apply(subst rsimp_idem[symmetric])
e072cfc2f2ee closedforms
Chengsong
parents: 444
diff changeset
  1205
  apply(subst rders_simp_one_char[symmetric])
e072cfc2f2ee closedforms
Chengsong
parents: 444
diff changeset
  1206
  apply(subst rders_simp_append[symmetric])
e072cfc2f2ee closedforms
Chengsong
parents: 444
diff changeset
  1207
  apply(insert seq_closed_form)
e072cfc2f2ee closedforms
Chengsong
parents: 444
diff changeset
  1208
  apply(subgoal_tac "rsimp (rders_simp (RSEQ r1 r2) (xs @ [x]))
e072cfc2f2ee closedforms
Chengsong
parents: 444
diff changeset
  1209
 = rsimp (RALTS (RSEQ (rders_simp r1 (xs @ [x])) r2 # map (rders_simp r2) (vsuf (xs @ [x]) r1)))")
e072cfc2f2ee closedforms
Chengsong
parents: 444
diff changeset
  1210
   apply force
e072cfc2f2ee closedforms
Chengsong
parents: 444
diff changeset
  1211
  by presburger
443
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
  1212
476
Chengsong
parents: 475
diff changeset
  1213
lemma simp_helps_der_pierce:
Chengsong
parents: 475
diff changeset
  1214
  shows " rsimp
Chengsong
parents: 475
diff changeset
  1215
            (rder x
Chengsong
parents: 475
diff changeset
  1216
              (rsimp_ALTs rs)) = 
Chengsong
parents: 475
diff changeset
  1217
          rsimp 
Chengsong
parents: 475
diff changeset
  1218
            (rsimp_ALTs 
Chengsong
parents: 475
diff changeset
  1219
              (map (rder x )
Chengsong
parents: 475
diff changeset
  1220
                rs
Chengsong
parents: 475
diff changeset
  1221
              )
Chengsong
parents: 475
diff changeset
  1222
            )"
Chengsong
parents: 475
diff changeset
  1223
  sorry
Chengsong
parents: 475
diff changeset
  1224
444
a7e98deebb5c restructured sizebound proof
Chengsong
parents: 443
diff changeset
  1225
end