src/HOL/Predicate_Compile_Examples/IMP_3.thy
author huffman
Thu, 27 Oct 2011 07:46:57 +0200
changeset 45270 d5b5c9259afd
parent 43686 bc7d63c7fd6f
child 45451 74515e8e6046
permissions -rw-r--r--
fix bug in cancel_factor simprocs so they will work on goals like 'x * y < x * z' where the common term is already on the left
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
39186
475856793715 adding IMP quickcheck examples
bulwahn
parents:
diff changeset
     1
theory IMP_3
41413
64cd30d6b0b8 explicit file specifications -- avoid secondary load path;
wenzelm
parents: 40924
diff changeset
     2
imports "~~/src/HOL/Library/Predicate_Compile_Quickcheck"
39186
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 integer 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
42031
2de57cda5b24 adapting predicate_compile_quickcheck; tuned
bulwahn
parents: 41413
diff changeset
    11
type_synonym var = unit
2de57cda5b24 adapting predicate_compile_quickcheck; tuned
bulwahn
parents: 41413
diff changeset
    12
type_synonym state = int
39186
475856793715 adding IMP quickcheck examples
bulwahn
parents:
diff changeset
    13
475856793715 adding IMP quickcheck examples
bulwahn
parents:
diff changeset
    14
datatype com =
475856793715 adding IMP quickcheck examples
bulwahn
parents:
diff changeset
    15
  Skip |
475856793715 adding IMP quickcheck examples
bulwahn
parents:
diff changeset
    16
  Ass var "int" |
475856793715 adding IMP quickcheck examples
bulwahn
parents:
diff changeset
    17
  Seq com com |
475856793715 adding IMP quickcheck examples
bulwahn
parents:
diff changeset
    18
  IF "state list" com com |
475856793715 adding IMP quickcheck examples
bulwahn
parents:
diff changeset
    19
  While "state list" com
475856793715 adding IMP quickcheck examples
bulwahn
parents:
diff changeset
    20
475856793715 adding IMP quickcheck examples
bulwahn
parents:
diff changeset
    21
inductive exec :: "com => state => state => bool" where
475856793715 adding IMP quickcheck examples
bulwahn
parents:
diff changeset
    22
  "exec Skip s s" |
475856793715 adding IMP quickcheck examples
bulwahn
parents:
diff changeset
    23
  "exec (Ass x e) s e" |
475856793715 adding IMP quickcheck examples
bulwahn
parents:
diff changeset
    24
  "exec c1 s1 s2 ==> exec c2 s2 s3 ==> exec (Seq c1 c2) s1 s3" |
475856793715 adding IMP quickcheck examples
bulwahn
parents:
diff changeset
    25
  "s \<in> set b ==> exec c1 s t ==> exec (IF b c1 c2) s t" |
475856793715 adding IMP quickcheck examples
bulwahn
parents:
diff changeset
    26
  "s \<notin> set b ==> exec c2 s t ==> exec (IF b c1 c2) s t" |
475856793715 adding IMP quickcheck examples
bulwahn
parents:
diff changeset
    27
  "s \<notin> set b ==> exec (While b c) s s" |
475856793715 adding IMP quickcheck examples
bulwahn
parents:
diff changeset
    28
  "s1 \<in> set b ==> exec c s1 s2 ==> exec (While b c) s2 s3 ==> exec (While b c) s1 s3"
475856793715 adding IMP quickcheck examples
bulwahn
parents:
diff changeset
    29
475856793715 adding IMP quickcheck examples
bulwahn
parents:
diff changeset
    30
lemma
475856793715 adding IMP quickcheck examples
bulwahn
parents:
diff changeset
    31
  "exec c s s' ==> exec (Seq c c) s s'"
43686
bc7d63c7fd6f tuning options to avoid spurious isabelle test failures
bulwahn
parents: 42031
diff changeset
    32
  quickcheck[tester = predicate_compile_ff_nofs, size=2, iterations=100, quiet = false, expect = counterexample]
39186
475856793715 adding IMP quickcheck examples
bulwahn
parents:
diff changeset
    33
oops
475856793715 adding IMP quickcheck examples
bulwahn
parents:
diff changeset
    34
475856793715 adding IMP quickcheck examples
bulwahn
parents:
diff changeset
    35
43686
bc7d63c7fd6f tuning options to avoid spurious isabelle test failures
bulwahn
parents: 42031
diff changeset
    36
end