thys2/Bounds.thy
author Chengsong
Mon, 10 Jul 2023 01:51:46 +0100
changeset 661 71502e4d8691
parent 365 ec5e4fe4cc70
permissions -rw-r--r--
overview of finiteness proof Gerog comment "not helpful", adding more intuitions of "closed forms"
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
365
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
     1
   
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
     2
theory Bounds
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
     3
  imports "Lexer" 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
     4
begin
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
     5
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
     6
definition Size :: "rexp \<Rightarrow> nat"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
     7
where "Size r == Max {size (ders s r) | s. True }"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
     8
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
     9
fun bar :: "rexp \<Rightarrow> string \<Rightarrow> rexp" where
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    10
  "bar r [] = r"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    11
| "bar r (c # s) = ALT (ders (c # s) r) (bar r s)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    12
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    13
lemma size_ALT:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    14
  "size (ders s (ALT r1 r2)) = Suc (size (ders s r1) + size (ders s r2))"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    15
apply(induct s arbitrary: r1 r2)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    16
apply(simp_all)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    17
done
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    18
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    19
lemma size_bar_ALT:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    20
  "size (bar (ALT r1 r2) s) = Suc (size (bar r1 s) + size (bar r2 s))"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    21
apply(induct s)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    22
apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    23
apply(simp add: size_ALT)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    24
done
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    25
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    26
lemma size_SEQ:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    27
  "size (ders s (SEQ r1 r2)) \<le> Suc (size (ders s r1)) + size r2 + size (bar (SEQ r1 r2) s)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    28
apply(induct s arbitrary: r1 r2)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    29
apply(simp_all)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    30
done
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    31
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    32
(*
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    33
lemma size_bar_SEQ:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    34
  "size (bar (SEQ r1 r2) s) \<le> Suc (size (bar r1 s) + size (bar r2 s))"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    35
apply(induct s)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    36
apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    37
apply(auto simp add: size_SEQ size_ALT)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    38
apply(rule le_trans)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    39
apply(rule size_SEQ)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    40
done
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    41
*)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    42
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    43
lemma size_STAR:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    44
  "size (ders s (STAR r)) \<le> Suc (size (bar r s)) + size (STAR r)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    45
apply(induct s arbitrary: r)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    46
apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    47
apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    48
apply(rule le_trans)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    49
apply(rule size_SEQ)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    50
apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    51
oops
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    52
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    53
lemma Size_ALT:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    54
  "Size (ALT r1 r2) \<le> Suc (Size r1 + Size r2)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    55
unfolding Size_def
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    56
apply(auto)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    57
apply(simp add: size_ALT)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    58
apply(subgoal_tac "Max {n. \<exists>s. n = Suc (size (ders s r1) + size (ders s r2))} \<ge>
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    59
  Suc (Max {n. \<exists>s. n = size (ders s r1) + size (ders s r2)})")
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    60
prefer 2
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    61
oops
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    62
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    63
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    64
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    65
end