thys2/GeneralRegexBound.thy
author Chengsong
Wed, 09 Mar 2022 17:33:08 +0000
changeset 444 a7e98deebb5c
child 451 7a016eeb118d
permissions -rw-r--r--
restructured sizebound proof
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
444
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
     1
theory GeneralRegexBound imports 
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
     2
"BasicIdentities"
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
     3
begin
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
     4
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
     5
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
     6
lemma non_zero_size:
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
     7
  shows "rsize r \<ge> Suc 0"
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
     8
  apply(induct r)
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
     9
  apply auto done
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    10
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    11
corollary size_geq1:
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    12
  shows "rsize r \<ge> 1"
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    13
  by (simp add: non_zero_size)
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    14
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    15
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    16
definition SEQ_set where
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    17
  "SEQ_set A n \<equiv> {RSEQ r1 r2 | r1 r2. r1 \<in> A \<and> r2 \<in> A \<and> rsize r1 + rsize r2 \<le> n}"
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    18
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    19
definition SEQ_set_cartesian where
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    20
"SEQ_set_cartesian A n  = {RSEQ r1 r2 | r1 r2. r1 \<in> A \<and> r2 \<in> A}"
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    21
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    22
definition ALT_set where
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    23
"ALT_set A n \<equiv> {RALTS rs | rs. set rs \<subseteq> A \<and> sum_list (map rsize rs) \<le> n}"
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    24
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    25
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    26
definition
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    27
  "sizeNregex N \<equiv> {r. rsize r \<le> N}"
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    28
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    29
lemma sizenregex_induct:
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    30
  shows "sizeNregex (Suc n) = sizeNregex n \<union> {RZERO, RONE, RALTS []} \<union> {RCHAR c| c. True} \<union>
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    31
SEQ_set ( sizeNregex n) n \<union> ALT_set (sizeNregex n) n \<union> (RSTAR ` (sizeNregex n))"
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    32
  sorry
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    33
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    34
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    35
lemma chars_finite:
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    36
  shows "finite (RCHAR ` (UNIV::(char set)))"
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    37
  apply(simp)
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    38
  done
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    39
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    40
thm full_SetCompr_eq 
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    41
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    42
lemma size1finite:
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    43
  shows "finite (sizeNregex (Suc 0))"
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    44
  apply(subst sizenregex_induct)
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    45
  apply(subst finite_Un)+
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    46
  apply(subgoal_tac "sizeNregex 0 = {}")
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    47
  apply(rule conjI)+
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    48
  apply (metis Collect_empty_eq finite.emptyI non_zero_size not_less_eq_eq sizeNregex_def)
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    49
      apply simp
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    50
      apply (simp add: full_SetCompr_eq)
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    51
  apply (simp add: SEQ_set_def)
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    52
    apply (simp add: ALT_set_def)  
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    53
   apply(simp add: full_SetCompr_eq)
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    54
  using non_zero_size not_less_eq_eq sizeNregex_def by fastforce
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    55
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    56
lemma seq_included_in_cart:
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    57
  shows "SEQ_set A n \<subseteq> SEQ_set_cartesian A n"
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    58
  using SEQ_set_cartesian_def SEQ_set_def by fastforce
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    59
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    60
lemma finite_seq:
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    61
  shows " finite (sizeNregex n) \<Longrightarrow> finite (SEQ_set (sizeNregex n) n)"
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    62
  apply(rule finite_subset)
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    63
  sorry
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    64
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    65
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    66
lemma finite_size_n:
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    67
  shows "finite (sizeNregex n)"
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    68
  apply(induct n)
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    69
  apply (metis Collect_empty_eq finite.emptyI non_zero_size not_less_eq_eq sizeNregex_def)
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    70
  apply(subst sizenregex_induct)
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    71
  apply(subst finite_Un)+
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    72
  apply(rule conjI)+
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    73
       apply simp
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    74
      apply simp
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    75
     apply (simp add: full_SetCompr_eq)
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    76
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    77
  sorry
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    78
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    79
lemma three_easy_cases0: shows 
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    80
"rsize (rders_simp RZERO s) \<le> Suc 0"
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    81
  sorry
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    82
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    83
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    84
lemma three_easy_cases1: shows 
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    85
"rsize (rders_simp RONE s) \<le> Suc 0"
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    86
  sorry
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    87
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    88
lemma three_easy_casesC: shows
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    89
"rsize (rders_simp (RCHAR c) s) \<le> Suc 0"
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    90
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    91
  sorry
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    92
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    93
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    94
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    95
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    96
end
a7e98deebb5c restructured sizebound proof
Chengsong
parents:
diff changeset
    97