src/HOL/Predicate_Compile_Examples/IMP_3.thy
author wenzelm
Wed Dec 29 17:34:41 2010 +0100 (2010-12-29)
changeset 41413 64cd30d6b0b8
parent 40924 a9be7f26b4e6
child 42031 2de57cda5b24
permissions -rw-r--r--
explicit file specifications -- avoid secondary load path;
bulwahn@39186
     1
theory IMP_3
wenzelm@41413
     2
imports "~~/src/HOL/Library/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 one integer variable and the commands are Skip, Ass, Seq, IF, and While.
bulwahn@39186
     9
*}
bulwahn@39186
    10
bulwahn@39186
    11
types
bulwahn@39186
    12
  var = unit
bulwahn@39186
    13
  state = int
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 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@40924
    33
  quickcheck[tester = predicate_compile_ff_nofs, size=2, iterations=10, quiet = false, expect = counterexample]
bulwahn@39186
    34
oops
bulwahn@39186
    35
bulwahn@39186
    36
bulwahn@39186
    37
end