src/HOL/Predicate_Compile_Examples/IMP_4.thy
author bulwahn
Tue Sep 07 11:51:53 2010 +0200 (2010-09-07)
changeset 39186 475856793715
child 40924 a9be7f26b4e6
permissions -rw-r--r--
adding IMP quickcheck examples
bulwahn@39186
     1
theory IMP_4
bulwahn@39186
     2
imports Predicate_Compile_Quickcheck
bulwahn@39186
     3
begin
bulwahn@39186
     4
bulwahn@39186
     5
subsection {* IMP *}
bulwahn@39186
     6
bulwahn@39186
     7
text {*
bulwahn@39186
     8
  In this example, the state is a list of integers and the commands are Skip, Ass, Seq, IF and While.
bulwahn@39186
     9
*}
bulwahn@39186
    10
bulwahn@39186
    11
types
bulwahn@39186
    12
  var = nat
bulwahn@39186
    13
  state = "int list"
bulwahn@39186
    14
bulwahn@39186
    15
datatype com =
bulwahn@39186
    16
  Skip |
bulwahn@39186
    17
  Ass var "int" |
bulwahn@39186
    18
  Seq com com |
bulwahn@39186
    19
  IF "state list" com com |
bulwahn@39186
    20
  While "state list" com
bulwahn@39186
    21
bulwahn@39186
    22
inductive exec :: "com => state => state => bool" where
bulwahn@39186
    23
  "exec Skip s s" |
bulwahn@39186
    24
  "exec (Ass x e) s (s[x := e])" |
bulwahn@39186
    25
  "exec c1 s1 s2 ==> exec c2 s2 s3 ==> exec (Seq c1 c2) s1 s3" |
bulwahn@39186
    26
  "s \<in> set b ==> exec c1 s t ==> exec (IF b c1 c2) s t" |
bulwahn@39186
    27
  "s \<notin> set b ==> exec c2 s t ==> exec (IF b c1 c2) s t" |
bulwahn@39186
    28
  "s \<notin> set b ==> exec (While b c) s s" |
bulwahn@39186
    29
  "s1 \<in> set b ==> exec c s1 s2 ==> exec (While b c) s2 s3 ==> exec (While b c) s1 s3"
bulwahn@39186
    30
bulwahn@39186
    31
lemma
bulwahn@39186
    32
  "exec c s s' ==> exec (Seq c c) s s'"
bulwahn@39186
    33
  nitpick (* nitpick fails here! *)
bulwahn@39186
    34
  quickcheck[generator = predicate_compile_wo_ff, size=2, iterations=10, expect=counterexample]
bulwahn@39186
    35
oops
bulwahn@39186
    36
bulwahn@39186
    37
end