src/HOL/Hoare/hoare_syntax.ML
author nipkow
Fri, 04 Dec 2020 15:07:47 +0100
changeset 72806 4fa08e083865
parent 69597 ff784d5a5bfb
child 72987 b1be35908165
permissions -rw-r--r--
Extension of session HOL/Hoare with total correctness proof system by Walter Guttmann
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
42153
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
     1
(*  Title:      HOL/Hoare/hoare_syntax.ML
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
     2
    Author:     Leonor Prensa Nieto & Tobias Nipkow
72806
4fa08e083865 Extension of session HOL/Hoare with total correctness proof system by Walter Guttmann
nipkow
parents: 69597
diff changeset
     3
    Author:     Walter Guttmann (extension to total-correctness proofs)
42153
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
     4
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
     5
Syntax translations for Hoare logic.
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
     6
*)
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
     7
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
     8
signature HOARE_SYNTAX =
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
     9
sig
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
    10
  val hoare_vars_tr: term list -> term
72806
4fa08e083865 Extension of session HOL/Hoare with total correctness proof system by Walter Guttmann
nipkow
parents: 69597
diff changeset
    11
  val hoare_tc_vars_tr: term list -> term
42153
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
    12
  val spec_tr': string -> term list -> term
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
    13
end;
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
    14
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
    15
structure Hoare_Syntax: HOARE_SYNTAX =
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
    16
struct
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
    17
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
    18
(** parse translation **)
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
    19
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
    20
local
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
    21
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
    22
fun idt_name (Free (x, _)) = SOME x
69597
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 61424
diff changeset
    23
  | idt_name (Const (\<^syntax_const>\<open>_constrain\<close>, _) $ t $ _) = idt_name t
42153
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
    24
  | idt_name _ = NONE;
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
    25
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
    26
fun eq_idt tu =
59058
a78612c67ec0 renamed "pairself" to "apply2", in accordance to @{apply 2};
wenzelm
parents: 55659
diff changeset
    27
  (case apply2 idt_name tu of
42153
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
    28
    (SOME x, SOME y) => x = y
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
    29
  | _ => false);
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
    30
42284
326f57825e1a explicit structure Syntax_Trans;
wenzelm
parents: 42153
diff changeset
    31
fun mk_abstuple [x] body = Syntax_Trans.abs_tr [x, body]
42153
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
    32
  | mk_abstuple (x :: xs) body =
69597
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 61424
diff changeset
    33
      Syntax.const \<^const_syntax>\<open>case_prod\<close> $ Syntax_Trans.abs_tr [x, mk_abstuple xs body];
42153
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
    34
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
    35
fun mk_fbody x e [y] = if eq_idt (x, y) then e else y
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
    36
  | mk_fbody x e (y :: xs) =
69597
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 61424
diff changeset
    37
      Syntax.const \<^const_syntax>\<open>Pair\<close> $
42153
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
    38
        (if eq_idt (x, y) then e else y) $ mk_fbody x e xs;
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
    39
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
    40
fun mk_fexp x e xs = mk_abstuple xs (mk_fbody x e xs);
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
    41
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
    42
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
    43
(* bexp_tr & assn_tr *)
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
    44
(*all meta-variables for bexp except for TRUE are translated as if they
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
    45
  were boolean expressions*)
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
    46
55659
4089f6e98ab9 reduced ML warnings;
wenzelm
parents: 55414
diff changeset
    47
fun bexp_tr (Const ("TRUE", _)) _ = Syntax.const "TRUE"   (* FIXME !? *)
69597
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 61424
diff changeset
    48
  | bexp_tr b xs = Syntax.const \<^const_syntax>\<open>Collect\<close> $ mk_abstuple xs b;
42153
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
    49
69597
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 61424
diff changeset
    50
fun assn_tr r xs = Syntax.const \<^const_syntax>\<open>Collect\<close> $ mk_abstuple xs r;
42153
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
    51
72806
4fa08e083865 Extension of session HOL/Hoare with total correctness proof system by Walter Guttmann
nipkow
parents: 69597
diff changeset
    52
fun var_tr v xs = mk_abstuple xs v;
4fa08e083865 Extension of session HOL/Hoare with total correctness proof system by Walter Guttmann
nipkow
parents: 69597
diff changeset
    53
42153
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
    54
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
    55
(* com_tr *)
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
    56
69597
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 61424
diff changeset
    57
fun com_tr (Const (\<^syntax_const>\<open>_assign\<close>, _) $ x $ e) xs =
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 61424
diff changeset
    58
      Syntax.const \<^const_syntax>\<open>Basic\<close> $ mk_fexp x e xs
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 61424
diff changeset
    59
  | com_tr (Const (\<^const_syntax>\<open>Basic\<close>,_) $ f) _ = Syntax.const \<^const_syntax>\<open>Basic\<close> $ f
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 61424
diff changeset
    60
  | com_tr (Const (\<^const_syntax>\<open>Seq\<close>,_) $ c1 $ c2) xs =
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 61424
diff changeset
    61
      Syntax.const \<^const_syntax>\<open>Seq\<close> $ com_tr c1 xs $ com_tr c2 xs
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 61424
diff changeset
    62
  | com_tr (Const (\<^const_syntax>\<open>Cond\<close>,_) $ b $ c1 $ c2) xs =
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 61424
diff changeset
    63
      Syntax.const \<^const_syntax>\<open>Cond\<close> $ bexp_tr b xs $ com_tr c1 xs $ com_tr c2 xs
72806
4fa08e083865 Extension of session HOL/Hoare with total correctness proof system by Walter Guttmann
nipkow
parents: 69597
diff changeset
    64
  | com_tr (Const (\<^const_syntax>\<open>While\<close>,_) $ b $ I $ V $ c) xs =
4fa08e083865 Extension of session HOL/Hoare with total correctness proof system by Walter Guttmann
nipkow
parents: 69597
diff changeset
    65
      Syntax.const \<^const_syntax>\<open>While\<close> $ bexp_tr b xs $ assn_tr I xs $ var_tr V xs $ com_tr c xs
42153
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
    66
  | com_tr t _ = t;
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
    67
69597
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 61424
diff changeset
    68
fun vars_tr (Const (\<^syntax_const>\<open>_idts\<close>, _) $ idt $ vars) = idt :: vars_tr vars
42153
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
    69
  | vars_tr t = [t];
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
    70
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
    71
in
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
    72
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
    73
fun hoare_vars_tr [vars, pre, prg, post] =
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
    74
      let val xs = vars_tr vars
69597
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 61424
diff changeset
    75
      in Syntax.const \<^const_syntax>\<open>Valid\<close> $
42153
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
    76
         assn_tr pre xs $ com_tr prg xs $ assn_tr post xs
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
    77
      end
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
    78
  | hoare_vars_tr ts = raise TERM ("hoare_vars_tr", ts);
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
    79
72806
4fa08e083865 Extension of session HOL/Hoare with total correctness proof system by Walter Guttmann
nipkow
parents: 69597
diff changeset
    80
fun hoare_tc_vars_tr [vars, pre, prg, post] =
4fa08e083865 Extension of session HOL/Hoare with total correctness proof system by Walter Guttmann
nipkow
parents: 69597
diff changeset
    81
      let val xs = vars_tr vars
4fa08e083865 Extension of session HOL/Hoare with total correctness proof system by Walter Guttmann
nipkow
parents: 69597
diff changeset
    82
      in Syntax.const \<^const_syntax>\<open>ValidTC\<close> $
4fa08e083865 Extension of session HOL/Hoare with total correctness proof system by Walter Guttmann
nipkow
parents: 69597
diff changeset
    83
         assn_tr pre xs $ com_tr prg xs $ assn_tr post xs
4fa08e083865 Extension of session HOL/Hoare with total correctness proof system by Walter Guttmann
nipkow
parents: 69597
diff changeset
    84
      end
4fa08e083865 Extension of session HOL/Hoare with total correctness proof system by Walter Guttmann
nipkow
parents: 69597
diff changeset
    85
  | hoare_tc_vars_tr ts = raise TERM ("hoare_tc_vars_tr", ts);
4fa08e083865 Extension of session HOL/Hoare with total correctness proof system by Walter Guttmann
nipkow
parents: 69597
diff changeset
    86
42153
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
    87
end;
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
    88
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
    89
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
    90
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
    91
(** print translation **)
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
    92
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
    93
local
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
    94
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
    95
fun dest_abstuple
69597
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 61424
diff changeset
    96
      (Const (\<^const_syntax>\<open>case_prod\<close>, _) $ Abs (v, _, body)) =
42153
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
    97
        subst_bound (Syntax.free v, dest_abstuple body)
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
    98
  | dest_abstuple (Abs (v,_, body)) = subst_bound (Syntax.free v, body)
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
    99
  | dest_abstuple tm = tm;
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
   100
69597
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 61424
diff changeset
   101
fun abs2list (Const (\<^const_syntax>\<open>case_prod\<close>, _) $ Abs (x, T, t)) = Free (x, T) :: abs2list t
55659
4089f6e98ab9 reduced ML warnings;
wenzelm
parents: 55414
diff changeset
   102
  | abs2list (Abs (x, T, _)) = [Free (x, T)]
42153
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
   103
  | abs2list _ = [];
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
   104
69597
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 61424
diff changeset
   105
fun mk_ts (Const (\<^const_syntax>\<open>case_prod\<close>, _) $ Abs (_, _, t)) = mk_ts t
55659
4089f6e98ab9 reduced ML warnings;
wenzelm
parents: 55414
diff changeset
   106
  | mk_ts (Abs (_, _, t)) = mk_ts t
69597
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 61424
diff changeset
   107
  | mk_ts (Const (\<^const_syntax>\<open>Pair\<close>, _) $ a $ b) = a :: mk_ts b
42153
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
   108
  | mk_ts t = [t];
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
   109
69597
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 61424
diff changeset
   110
fun mk_vts (Const (\<^const_syntax>\<open>case_prod\<close>,_) $ Abs (x, _, t)) =
42153
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
   111
      (Syntax.free x :: abs2list t, mk_ts t)
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
   112
  | mk_vts (Abs (x, _, t)) = ([Syntax.free x], [t])
55659
4089f6e98ab9 reduced ML warnings;
wenzelm
parents: 55414
diff changeset
   113
  | mk_vts _ = raise Match;
42153
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
   114
55659
4089f6e98ab9 reduced ML warnings;
wenzelm
parents: 55414
diff changeset
   115
fun find_ch [] _ _ = (false, (Syntax.free "not_ch", Syntax.free "not_ch"))  (* FIXME no_ch!? *)
42153
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
   116
  | find_ch ((v, t) :: vts) i xs =
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
   117
      if t = Bound i then find_ch vts (i - 1) xs
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
   118
      else (true, (v, subst_bounds (xs, t)));
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
   119
69597
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 61424
diff changeset
   120
fun is_f (Const (\<^const_syntax>\<open>case_prod\<close>, _) $ Abs _) = true
55659
4089f6e98ab9 reduced ML warnings;
wenzelm
parents: 55414
diff changeset
   121
  | is_f (Abs _) = true
4089f6e98ab9 reduced ML warnings;
wenzelm
parents: 55414
diff changeset
   122
  | is_f _ = false;
42153
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
   123
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
   124
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
   125
(* assn_tr' & bexp_tr'*)
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
   126
69597
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 61424
diff changeset
   127
fun assn_tr' (Const (\<^const_syntax>\<open>Collect\<close>, _) $ T) = dest_abstuple T
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 61424
diff changeset
   128
  | assn_tr' (Const (\<^const_syntax>\<open>inter\<close>, _) $
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 61424
diff changeset
   129
        (Const (\<^const_syntax>\<open>Collect\<close>, _) $ T1) $ (Const (\<^const_syntax>\<open>Collect\<close>, _) $ T2)) =
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 61424
diff changeset
   130
      Syntax.const \<^const_syntax>\<open>inter\<close> $ dest_abstuple T1 $ dest_abstuple T2
42153
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
   131
  | assn_tr' t = t;
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
   132
69597
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 61424
diff changeset
   133
fun bexp_tr' (Const (\<^const_syntax>\<open>Collect\<close>, _) $ T) = dest_abstuple T
42153
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
   134
  | bexp_tr' t = t;
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
   135
72806
4fa08e083865 Extension of session HOL/Hoare with total correctness proof system by Walter Guttmann
nipkow
parents: 69597
diff changeset
   136
fun var_tr' (Const (\<^const_syntax>\<open>Collect\<close>, _) $ T) = dest_abstuple T
4fa08e083865 Extension of session HOL/Hoare with total correctness proof system by Walter Guttmann
nipkow
parents: 69597
diff changeset
   137
  | var_tr' t = t;
4fa08e083865 Extension of session HOL/Hoare with total correctness proof system by Walter Guttmann
nipkow
parents: 69597
diff changeset
   138
42153
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
   139
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
   140
(* com_tr' *)
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
   141
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
   142
fun mk_assign f =
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
   143
  let
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
   144
    val (vs, ts) = mk_vts f;
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
   145
    val (ch, which) = find_ch (vs ~~ ts) (length vs - 1) (rev vs);
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
   146
  in
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
   147
    if ch
69597
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 61424
diff changeset
   148
    then Syntax.const \<^syntax_const>\<open>_assign\<close> $ fst which $ snd which
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 61424
diff changeset
   149
    else Syntax.const \<^const_syntax>\<open>annskip\<close>
42153
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
   150
  end;
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
   151
69597
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 61424
diff changeset
   152
fun com_tr' (Const (\<^const_syntax>\<open>Basic\<close>, _) $ f) =
42153
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
   153
      if is_f f then mk_assign f
69597
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 61424
diff changeset
   154
      else Syntax.const \<^const_syntax>\<open>Basic\<close> $ f
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 61424
diff changeset
   155
  | com_tr' (Const (\<^const_syntax>\<open>Seq\<close>,_) $ c1 $ c2) =
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 61424
diff changeset
   156
      Syntax.const \<^const_syntax>\<open>Seq\<close> $ com_tr' c1 $ com_tr' c2
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 61424
diff changeset
   157
  | com_tr' (Const (\<^const_syntax>\<open>Cond\<close>, _) $ b $ c1 $ c2) =
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 61424
diff changeset
   158
      Syntax.const \<^const_syntax>\<open>Cond\<close> $ bexp_tr' b $ com_tr' c1 $ com_tr' c2
72806
4fa08e083865 Extension of session HOL/Hoare with total correctness proof system by Walter Guttmann
nipkow
parents: 69597
diff changeset
   159
  | com_tr' (Const (\<^const_syntax>\<open>While\<close>, _) $ b $ I $ V $ c) =
4fa08e083865 Extension of session HOL/Hoare with total correctness proof system by Walter Guttmann
nipkow
parents: 69597
diff changeset
   160
      Syntax.const \<^const_syntax>\<open>While\<close> $ bexp_tr' b $ assn_tr' I $ var_tr' V $ com_tr' c
42153
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
   161
  | com_tr' t = t;
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
   162
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
   163
in
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
   164
55659
4089f6e98ab9 reduced ML warnings;
wenzelm
parents: 55414
diff changeset
   165
fun spec_tr' syn [p, c, q] = Syntax.const syn $ assn_tr' p $ com_tr' c $ assn_tr' q;
42153
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
   166
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
   167
end;
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
   168
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
   169
end;
fa108629d132 use shared copy of hoare_syntax.ML;
wenzelm
parents:
diff changeset
   170