thys/Bounds.thy
author Christian Urban <urbanc@in.tum.de>
Mon, 11 Feb 2019 14:36:23 +0000
changeset 308 496a37d816e9
parent 194 761793cce563
permissions -rw-r--r--
added partial derivative proof from Antimirov
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
148
702ed601349b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     1
   
194
761793cce563 started a theory file about bounds
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 185
diff changeset
     2
theory Bounds
185
841f7b9c0a6a updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 160
diff changeset
     3
  imports "Lexer" 
148
702ed601349b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     4
begin
702ed601349b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     5
194
761793cce563 started a theory file about bounds
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 185
diff changeset
     6
definition Size :: "rexp \<Rightarrow> nat"
761793cce563 started a theory file about bounds
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 185
diff changeset
     7
where "Size r == Max {size (ders s r) | s. True }"
148
702ed601349b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     8
194
761793cce563 started a theory file about bounds
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 185
diff changeset
     9
fun bar :: "rexp \<Rightarrow> string \<Rightarrow> rexp" where
761793cce563 started a theory file about bounds
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 185
diff changeset
    10
  "bar r [] = r"
761793cce563 started a theory file about bounds
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 185
diff changeset
    11
| "bar r (c # s) = ALT (ders (c # s) r) (bar r s)"
148
702ed601349b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    12
194
761793cce563 started a theory file about bounds
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 185
diff changeset
    13
lemma size_ALT:
761793cce563 started a theory file about bounds
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 185
diff changeset
    14
  "size (ders s (ALT r1 r2)) = Suc (size (ders s r1) + size (ders s r2))"
761793cce563 started a theory file about bounds
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 185
diff changeset
    15
apply(induct s arbitrary: r1 r2)
761793cce563 started a theory file about bounds
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 185
diff changeset
    16
apply(simp_all)
761793cce563 started a theory file about bounds
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 185
diff changeset
    17
done
148
702ed601349b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    18
194
761793cce563 started a theory file about bounds
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 185
diff changeset
    19
lemma size_bar_ALT:
761793cce563 started a theory file about bounds
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 185
diff changeset
    20
  "size (bar (ALT r1 r2) s) = Suc (size (bar r1 s) + size (bar r2 s))"
761793cce563 started a theory file about bounds
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 185
diff changeset
    21
apply(induct s)
761793cce563 started a theory file about bounds
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 185
diff changeset
    22
apply(simp)
761793cce563 started a theory file about bounds
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 185
diff changeset
    23
apply(simp add: size_ALT)
761793cce563 started a theory file about bounds
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 185
diff changeset
    24
done
148
702ed601349b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    25
194
761793cce563 started a theory file about bounds
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 185
diff changeset
    26
lemma size_SEQ:
761793cce563 started a theory file about bounds
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 185
diff changeset
    27
  "size (ders s (SEQ r1 r2)) \<le> Suc (size (ders s r1)) + size r2 + size (bar (SEQ r1 r2) s)"
761793cce563 started a theory file about bounds
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 185
diff changeset
    28
apply(induct s arbitrary: r1 r2)
761793cce563 started a theory file about bounds
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 185
diff changeset
    29
apply(simp_all)
761793cce563 started a theory file about bounds
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 185
diff changeset
    30
done
148
702ed601349b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    31
702ed601349b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    32
(*
194
761793cce563 started a theory file about bounds
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 185
diff changeset
    33
lemma size_bar_SEQ:
761793cce563 started a theory file about bounds
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 185
diff changeset
    34
  "size (bar (SEQ r1 r2) s) \<le> Suc (size (bar r1 s) + size (bar r2 s))"
761793cce563 started a theory file about bounds
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 185
diff changeset
    35
apply(induct s)
761793cce563 started a theory file about bounds
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 185
diff changeset
    36
apply(simp)
761793cce563 started a theory file about bounds
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 185
diff changeset
    37
apply(auto simp add: size_SEQ size_ALT)
761793cce563 started a theory file about bounds
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 185
diff changeset
    38
apply(rule le_trans)
761793cce563 started a theory file about bounds
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 185
diff changeset
    39
apply(rule size_SEQ)
761793cce563 started a theory file about bounds
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 185
diff changeset
    40
done
148
702ed601349b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    41
*)
702ed601349b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    42
194
761793cce563 started a theory file about bounds
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 185
diff changeset
    43
lemma size_STAR:
761793cce563 started a theory file about bounds
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 185
diff changeset
    44
  "size (ders s (STAR r)) \<le> Suc (size (bar r s)) + size (STAR r)"
761793cce563 started a theory file about bounds
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 185
diff changeset
    45
apply(induct s arbitrary: r)
761793cce563 started a theory file about bounds
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 185
diff changeset
    46
apply(simp)
761793cce563 started a theory file about bounds
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 185
diff changeset
    47
apply(simp)
761793cce563 started a theory file about bounds
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 185
diff changeset
    48
apply(rule le_trans)
761793cce563 started a theory file about bounds
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 185
diff changeset
    49
apply(rule size_SEQ)
761793cce563 started a theory file about bounds
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 185
diff changeset
    50
apply(simp)
761793cce563 started a theory file about bounds
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 185
diff changeset
    51
oops
148
702ed601349b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    52
194
761793cce563 started a theory file about bounds
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 185
diff changeset
    53
lemma Size_ALT:
761793cce563 started a theory file about bounds
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 185
diff changeset
    54
  "Size (ALT r1 r2) \<le> Suc (Size r1 + Size r2)"
761793cce563 started a theory file about bounds
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 185
diff changeset
    55
unfolding Size_def
761793cce563 started a theory file about bounds
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 185
diff changeset
    56
apply(auto)
761793cce563 started a theory file about bounds
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 185
diff changeset
    57
apply(simp add: size_ALT)
761793cce563 started a theory file about bounds
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 185
diff changeset
    58
apply(subgoal_tac "Max {n. \<exists>s. n = Suc (size (ders s r1) + size (ders s r2))} \<ge>
761793cce563 started a theory file about bounds
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 185
diff changeset
    59
  Suc (Max {n. \<exists>s. n = size (ders s r1) + size (ders s r2)})")
761793cce563 started a theory file about bounds
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 185
diff changeset
    60
prefer 2
761793cce563 started a theory file about bounds
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 185
diff changeset
    61
oops
154
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
    62
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
    63
159
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
    64
148
702ed601349b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    65
end