src/HOL/HOLCF/IMP/HoareEx.thy
author wenzelm
Tue, 07 Oct 2014 23:12:08 +0200
changeset 58622 aa99568f56de
parent 43143 1aeafba76f21
child 58880 0baae4311a9f
permissions -rw-r--r--
more antiquotations;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
42151
4da4fc77664b tuned headers;
wenzelm
parents: 41476
diff changeset
     1
(*  Title:      HOL/HOLCF/IMP/HoareEx.thy
3664
2dced1ac2d8e Example from HOLCF paper.
nipkow
parents:
diff changeset
     2
    Author:     Tobias Nipkow, TUM
2dced1ac2d8e Example from HOLCF paper.
nipkow
parents:
diff changeset
     3
    Copyright   1997 TUM
2dced1ac2d8e Example from HOLCF paper.
nipkow
parents:
diff changeset
     4
*)
2dced1ac2d8e Example from HOLCF paper.
nipkow
parents:
diff changeset
     5
12431
07ec657249e5 converted to Isar
kleing
parents: 10835
diff changeset
     6
header "Correctness of Hoare by Fixpoint Reasoning"
07ec657249e5 converted to Isar
kleing
parents: 10835
diff changeset
     7
16417
9bc16273c2d4 migrated theory headers to new format
haftmann
parents: 12600
diff changeset
     8
theory HoareEx imports Denotational begin
3664
2dced1ac2d8e Example from HOLCF paper.
nipkow
parents:
diff changeset
     9
12431
07ec657249e5 converted to Isar
kleing
parents: 10835
diff changeset
    10
text {*
43143
1aeafba76f21 Fixed denotational semantics
nipkow
parents: 42151
diff changeset
    11
  An example from the HOLCF paper by Mueller, Nipkow, Oheimb, Slotosch
58622
aa99568f56de more antiquotations;
wenzelm
parents: 43143
diff changeset
    12
  @{cite MuellerNvOS99}.  It demonstrates fixpoint reasoning by showing
12546
wenzelm
parents: 12431
diff changeset
    13
  the correctness of the Hoare rule for while-loops.
12431
07ec657249e5 converted to Isar
kleing
parents: 10835
diff changeset
    14
*}
3664
2dced1ac2d8e Example from HOLCF paper.
nipkow
parents:
diff changeset
    15
41476
0fa9629aa399 types -> type_synonym
huffman
parents: 40945
diff changeset
    16
type_synonym assn = "state => bool"
12431
07ec657249e5 converted to Isar
kleing
parents: 10835
diff changeset
    17
19737
wenzelm
parents: 16417
diff changeset
    18
definition
21404
eb85850d3eb7 more robust syntax for definition/abbreviation/notation;
wenzelm
parents: 19737
diff changeset
    19
  hoare_valid :: "[assn, com, assn] => bool"  ("|= {(1_)}/ (_)/ {(1_)}" 50) where
43143
1aeafba76f21 Fixed denotational semantics
nipkow
parents: 42151
diff changeset
    20
  "|= {P} c {Q} = (\<forall>s t. P s \<and> D c $(Discr s) = Def t --> Q t)"
3664
2dced1ac2d8e Example from HOLCF paper.
nipkow
parents:
diff changeset
    21
12431
07ec657249e5 converted to Isar
kleing
parents: 10835
diff changeset
    22
lemma WHILE_rule_sound:
43143
1aeafba76f21 Fixed denotational semantics
nipkow
parents: 42151
diff changeset
    23
    "|= {A} c {A} ==> |= {A} WHILE b DO c {\<lambda>s. A s \<and> \<not> bval b s}"
12431
07ec657249e5 converted to Isar
kleing
parents: 10835
diff changeset
    24
  apply (unfold hoare_valid_def)
07ec657249e5 converted to Isar
kleing
parents: 10835
diff changeset
    25
  apply (simp (no_asm))
07ec657249e5 converted to Isar
kleing
parents: 10835
diff changeset
    26
  apply (rule fix_ind)
12600
wenzelm
parents: 12546
diff changeset
    27
    apply (simp (no_asm)) -- "simplifier with enhanced @{text adm}-tactic"
12431
07ec657249e5 converted to Isar
kleing
parents: 10835
diff changeset
    28
   apply (simp (no_asm))
07ec657249e5 converted to Isar
kleing
parents: 10835
diff changeset
    29
  apply (simp (no_asm))
07ec657249e5 converted to Isar
kleing
parents: 10835
diff changeset
    30
  apply blast
07ec657249e5 converted to Isar
kleing
parents: 10835
diff changeset
    31
  done
07ec657249e5 converted to Isar
kleing
parents: 10835
diff changeset
    32
3664
2dced1ac2d8e Example from HOLCF paper.
nipkow
parents:
diff changeset
    33
end