src/HOL/Predicate_Compile_Examples/IMP_2.thy
author bulwahn
Tue, 07 Sep 2010 11:51:53 +0200
changeset 39188 cd6558ed65d7
parent 39186 475856793715
child 39249 9c866b248cb1
permissions -rw-r--r--
adding the Reg_Exp example
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
39186
475856793715 adding IMP quickcheck examples
bulwahn
parents:
diff changeset
     1
theory IMP_2
475856793715 adding IMP quickcheck examples
bulwahn
parents:
diff changeset
     2
imports "Predicate_Compile_Quickcheck"
475856793715 adding IMP quickcheck examples
bulwahn
parents:
diff changeset
     3
begin
475856793715 adding IMP quickcheck examples
bulwahn
parents:
diff changeset
     4
475856793715 adding IMP quickcheck examples
bulwahn
parents:
diff changeset
     5
subsection {* IMP *}
475856793715 adding IMP quickcheck examples
bulwahn
parents:
diff changeset
     6
475856793715 adding IMP quickcheck examples
bulwahn
parents:
diff changeset
     7
text {*
475856793715 adding IMP quickcheck examples
bulwahn
parents:
diff changeset
     8
  In this example, the state is one boolean variable and the commands are Skip, Ass, Seq, IF and While.
475856793715 adding IMP quickcheck examples
bulwahn
parents:
diff changeset
     9
*}
475856793715 adding IMP quickcheck examples
bulwahn
parents:
diff changeset
    10
475856793715 adding IMP quickcheck examples
bulwahn
parents:
diff changeset
    11
types
475856793715 adding IMP quickcheck examples
bulwahn
parents:
diff changeset
    12
  var = unit
475856793715 adding IMP quickcheck examples
bulwahn
parents:
diff changeset
    13
  state = bool
475856793715 adding IMP quickcheck examples
bulwahn
parents:
diff changeset
    14
475856793715 adding IMP quickcheck examples
bulwahn
parents:
diff changeset
    15
datatype com =
475856793715 adding IMP quickcheck examples
bulwahn
parents:
diff changeset
    16
  Skip |
475856793715 adding IMP quickcheck examples
bulwahn
parents:
diff changeset
    17
  Ass bool |
475856793715 adding IMP quickcheck examples
bulwahn
parents:
diff changeset
    18
  Seq com com |
475856793715 adding IMP quickcheck examples
bulwahn
parents:
diff changeset
    19
  IF com com |
475856793715 adding IMP quickcheck examples
bulwahn
parents:
diff changeset
    20
  While com
475856793715 adding IMP quickcheck examples
bulwahn
parents:
diff changeset
    21
475856793715 adding IMP quickcheck examples
bulwahn
parents:
diff changeset
    22
inductive exec :: "com => state => state => bool" where
475856793715 adding IMP quickcheck examples
bulwahn
parents:
diff changeset
    23
  "exec Skip s s" |
475856793715 adding IMP quickcheck examples
bulwahn
parents:
diff changeset
    24
  "exec (Ass e) s e" |
475856793715 adding IMP quickcheck examples
bulwahn
parents:
diff changeset
    25
  "exec c1 s1 s2 ==> exec c2 s2 s3 ==> exec (Seq c1 c2) s1 s3" |
475856793715 adding IMP quickcheck examples
bulwahn
parents:
diff changeset
    26
  "s ==> exec c1 s t ==> exec (IF c1 c2) s t" |
475856793715 adding IMP quickcheck examples
bulwahn
parents:
diff changeset
    27
  "\<not> s ==> exec c2 s t ==> exec (IF c1 c2) s t" |
475856793715 adding IMP quickcheck examples
bulwahn
parents:
diff changeset
    28
  "\<not> s ==> exec (While c) s s" |
475856793715 adding IMP quickcheck examples
bulwahn
parents:
diff changeset
    29
  "s ==> exec c s s' ==> exec (While c) s' s'' ==> exec (While c) s s''"
475856793715 adding IMP quickcheck examples
bulwahn
parents:
diff changeset
    30
475856793715 adding IMP quickcheck examples
bulwahn
parents:
diff changeset
    31
lemma
475856793715 adding IMP quickcheck examples
bulwahn
parents:
diff changeset
    32
  "exec c s s' ==> exec (Seq c c) s s'"
475856793715 adding IMP quickcheck examples
bulwahn
parents:
diff changeset
    33
quickcheck[generator = predicate_compile_wo_ff, size = 2, iterations = 1]
475856793715 adding IMP quickcheck examples
bulwahn
parents:
diff changeset
    34
oops
475856793715 adding IMP quickcheck examples
bulwahn
parents:
diff changeset
    35
475856793715 adding IMP quickcheck examples
bulwahn
parents:
diff changeset
    36
475856793715 adding IMP quickcheck examples
bulwahn
parents:
diff changeset
    37
end