src/HOL/Tools/record_package.ML
changeset 17616 f526e2b9fe9e
parent 17600 9ae09014730c
child 17875 d81094515061
equal deleted inserted replaced
17615:3c5b158be33c 17616:f526e2b9fe9e
   847  *   X does not affect the selected subrecord.
   847  *   X does not affect the selected subrecord.
   848  * - If X is a more-selector we have to make sure that S is not in the updated
   848  * - If X is a more-selector we have to make sure that S is not in the updated
   849  *   subrecord.
   849  *   subrecord.
   850  *)
   850  *)
   851 val record_simproc =
   851 val record_simproc =
   852   Simplifier.simproc HOL.thy "record_simp" ["s (u k r)"]   (* FIXME pattern!? *)
   852   Simplifier.simproc HOL.thy "record_simp" ["x"]
   853     (fn sg => fn ss => fn t =>
   853     (fn sg => fn ss => fn t =>
   854       (case t of (sel as Const (s, Type (_,[domS,rangeS])))$
   854       (case t of (sel as Const (s, Type (_,[domS,rangeS])))$
   855                    ((upd as Const (u,Type(_,[_,Type (_,[rT,_])]))) $ k $ r)=>
   855                    ((upd as Const (u,Type(_,[_,Type (_,[rT,_])]))) $ k $ r)=>
   856         if is_selector sg s then
   856         if is_selector sg s then
   857           (case get_updates sg u of SOME u_name =>
   857           (case get_updates sg u of SOME u_name =>
   908  *    r(|more := m; A := A r|)
   908  *    r(|more := m; A := A r|)
   909  * If A is contained in the fields of m we cannot remove the update A := A r!
   909  * If A is contained in the fields of m we cannot remove the update A := A r!
   910  * (But r(|more := r; A := A (r(|more := r|))|) = r(|more := r|)
   910  * (But r(|more := r; A := A (r(|more := r|))|) = r(|more := r|)
   911 *)
   911 *)
   912 val record_upd_simproc =
   912 val record_upd_simproc =
   913   Simplifier.simproc HOL.thy "record_upd_simp" ["u k r"]    (* FIXME pattern *)
   913   Simplifier.simproc HOL.thy "record_upd_simp" ["x"]
   914     (fn sg => fn ss => fn t =>
   914     (fn sg => fn ss => fn t =>
   915       (case t of ((upd as Const (u, Type(_,[_,Type(_,[rT,_])]))) $ k $ r) =>
   915       (case t of ((upd as Const (u, Type(_,[_,Type(_,[rT,_])]))) $ k $ r) =>
   916          let datatype ('a,'b) calc = Init of 'b | Inter of 'a
   916          let datatype ('a,'b) calc = Init of 'b | Inter of 'a
   917              val {sel_upd={selectors,updates,...},extfields,...} = RecordsData.get sg;
   917              val {sel_upd={selectors,updates,...},extfields,...} = RecordsData.get sg;
   918 
   918 
  1039  * P t = 0: do not split
  1039  * P t = 0: do not split
  1040  * P t = ~1: completely split
  1040  * P t = ~1: completely split
  1041  * P t > 0: split up to given bound of record extensions
  1041  * P t > 0: split up to given bound of record extensions
  1042  *)
  1042  *)
  1043 fun record_split_simproc P =
  1043 fun record_split_simproc P =
  1044   Simplifier.simproc HOL.thy "record_split_simp" ["a t"]
  1044   Simplifier.simproc HOL.thy "record_split_simp" ["x"]
  1045     (fn sg => fn _ => fn t =>
  1045     (fn sg => fn _ => fn t =>
  1046       (case t of (Const (quantifier, Type (_, [Type (_, [T, _]), _])))$trm =>
  1046       (case t of (Const (quantifier, Type (_, [Type (_, [T, _]), _])))$trm =>
  1047          if quantifier = "All" orelse quantifier = "all" orelse quantifier = "Ex"
  1047          if quantifier = "All" orelse quantifier = "all" orelse quantifier = "Ex"
  1048          then (case rec_id (~1) T of
  1048          then (case rec_id (~1) T of
  1049                  "" => NONE
  1049                  "" => NONE