src/HOL/Predicate_Compile_Examples/IMP_4.thy
changeset 39186 475856793715
child 40924 a9be7f26b4e6
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/HOL/Predicate_Compile_Examples/IMP_4.thy	Tue Sep 07 11:51:53 2010 +0200
     1.3 @@ -0,0 +1,37 @@
     1.4 +theory IMP_4
     1.5 +imports Predicate_Compile_Quickcheck
     1.6 +begin
     1.7 +
     1.8 +subsection {* IMP *}
     1.9 +
    1.10 +text {*
    1.11 +  In this example, the state is a list of integers and the commands are Skip, Ass, Seq, IF and While.
    1.12 +*}
    1.13 +
    1.14 +types
    1.15 +  var = nat
    1.16 +  state = "int list"
    1.17 +
    1.18 +datatype com =
    1.19 +  Skip |
    1.20 +  Ass var "int" |
    1.21 +  Seq com com |
    1.22 +  IF "state list" com com |
    1.23 +  While "state list" com
    1.24 +
    1.25 +inductive exec :: "com => state => state => bool" where
    1.26 +  "exec Skip s s" |
    1.27 +  "exec (Ass x e) s (s[x := e])" |
    1.28 +  "exec c1 s1 s2 ==> exec c2 s2 s3 ==> exec (Seq c1 c2) s1 s3" |
    1.29 +  "s \<in> set b ==> exec c1 s t ==> exec (IF b c1 c2) s t" |
    1.30 +  "s \<notin> set b ==> exec c2 s t ==> exec (IF b c1 c2) s t" |
    1.31 +  "s \<notin> set b ==> exec (While b c) s s" |
    1.32 +  "s1 \<in> set b ==> exec c s1 s2 ==> exec (While b c) s2 s3 ==> exec (While b c) s1 s3"
    1.33 +
    1.34 +lemma
    1.35 +  "exec c s s' ==> exec (Seq c c) s s'"
    1.36 +  nitpick (* nitpick fails here! *)
    1.37 +  quickcheck[generator = predicate_compile_wo_ff, size=2, iterations=10, expect=counterexample]
    1.38 +oops
    1.39 +
    1.40 +end
    1.41 \ No newline at end of file