856 |
856 |
857 fun quick_and_dirty_prove stndrd thy asms prop tac = |
857 fun quick_and_dirty_prove stndrd thy asms prop tac = |
858 if !record_quick_and_dirty_sensitive andalso !quick_and_dirty |
858 if !record_quick_and_dirty_sensitive andalso !quick_and_dirty |
859 then Goal.prove (ProofContext.init thy) [] [] |
859 then Goal.prove (ProofContext.init thy) [] [] |
860 (Logic.list_implies (map Logic.varify asms,Logic.varify prop)) |
860 (Logic.list_implies (map Logic.varify asms,Logic.varify prop)) |
861 (K (SkipProof.cheat_tac HOL.thy)) |
861 (K (SkipProof.cheat_tac @{theory HOL})) |
862 (* standard can take quite a while for large records, thats why |
862 (* standard can take quite a while for large records, thats why |
863 * we varify the proposition manually here.*) |
863 * we varify the proposition manually here.*) |
864 else let val prf = Goal.prove (ProofContext.init thy) [] asms prop tac; |
864 else let val prf = Goal.prove (ProofContext.init thy) [] asms prop tac; |
865 in if stndrd then standard prf else prf end; |
865 in if stndrd then standard prf else prf end; |
866 |
866 |
922 * situations like "!!f ... . ... f r ..." where f is an extension update function. |
922 * situations like "!!f ... . ... f r ..." where f is an extension update function. |
923 * In order to split "f r" we transform this to "!!r ... . ... r ..." so that the |
923 * In order to split "f r" we transform this to "!!r ... . ... r ..." so that the |
924 * usual split rules for extensions can apply. |
924 * usual split rules for extensions can apply. |
925 *) |
925 *) |
926 val record_split_f_more_simproc = |
926 val record_split_f_more_simproc = |
927 Simplifier.simproc HOL.thy "record_split_f_more_simp" ["x"] |
927 Simplifier.simproc @{theory HOL} "record_split_f_more_simp" ["x"] |
928 (fn thy => fn _ => fn t => |
928 (fn thy => fn _ => fn t => |
929 (case t of (Const ("all", Type (_, [Type (_, [Type("fun",[T,T']), _]), _])))$ |
929 (case t of (Const ("all", Type (_, [Type (_, [Type("fun",[T,T']), _]), _])))$ |
930 (trm as Abs _) => |
930 (trm as Abs _) => |
931 (case rec_id (~1) T of |
931 (case rec_id (~1) T of |
932 "" => NONE |
932 "" => NONE |
998 * X does not affect the selected subrecord. |
998 * X does not affect the selected subrecord. |
999 * - If X is a more-selector we have to make sure that S is not in the updated |
999 * - If X is a more-selector we have to make sure that S is not in the updated |
1000 * subrecord. |
1000 * subrecord. |
1001 *) |
1001 *) |
1002 val record_simproc = |
1002 val record_simproc = |
1003 Simplifier.simproc HOL.thy "record_simp" ["x"] |
1003 Simplifier.simproc @{theory HOL} "record_simp" ["x"] |
1004 (fn thy => fn ss => fn t => |
1004 (fn thy => fn ss => fn t => |
1005 (case t of (sel as Const (s, Type (_,[domS,rangeS])))$ |
1005 (case t of (sel as Const (s, Type (_,[domS,rangeS])))$ |
1006 ((upd as Const (u,Type(_,[_,Type (_,[rT,_])]))) $ k $ r)=> |
1006 ((upd as Const (u,Type(_,[_,Type (_,[rT,_])]))) $ k $ r)=> |
1007 if is_selector thy s then |
1007 if is_selector thy s then |
1008 (case get_updates thy u of SOME u_name => |
1008 (case get_updates thy u of SOME u_name => |
1061 * r(|more := m; A := A r|) |
1061 * r(|more := m; A := A r|) |
1062 * If A is contained in the fields of m we cannot remove the update A := A r! |
1062 * If A is contained in the fields of m we cannot remove the update A := A r! |
1063 * (But r(|more := r; A := A (r(|more := r|))|) = r(|more := r|) |
1063 * (But r(|more := r; A := A (r(|more := r|))|) = r(|more := r|) |
1064 *) |
1064 *) |
1065 val record_upd_simproc = |
1065 val record_upd_simproc = |
1066 Simplifier.simproc HOL.thy "record_upd_simp" ["x"] |
1066 Simplifier.simproc @{theory HOL} "record_upd_simp" ["x"] |
1067 (fn thy => fn ss => fn t => |
1067 (fn thy => fn ss => fn t => |
1068 (case t of ((upd as Const (u, Type(_,[_,Type(_,[rT,_])]))) $ k $ r) => |
1068 (case t of ((upd as Const (u, Type(_,[_,Type(_,[rT,_])]))) $ k $ r) => |
1069 let datatype ('a,'b) calc = Init of 'b | Inter of 'a |
1069 let datatype ('a,'b) calc = Init of 'b | Inter of 'a |
1070 val {sel_upd={selectors,updates,...},extfields,...} = RecordsData.get thy; |
1070 val {sel_upd={selectors,updates,...},extfields,...} = RecordsData.get thy; |
1071 |
1071 |
1200 * record_eq_simproc record_split_simp_tac |
1200 * record_eq_simproc record_split_simp_tac |
1201 * Complexity: #components * #updates #updates |
1201 * Complexity: #components * #updates #updates |
1202 * |
1202 * |
1203 *) |
1203 *) |
1204 val record_eq_simproc = |
1204 val record_eq_simproc = |
1205 Simplifier.simproc HOL.thy "record_eq_simp" ["r = s"] |
1205 Simplifier.simproc @{theory HOL} "record_eq_simp" ["r = s"] |
1206 (fn thy => fn _ => fn t => |
1206 (fn thy => fn _ => fn t => |
1207 (case t of Const ("op =", Type (_, [T, _])) $ _ $ _ => |
1207 (case t of Const ("op =", Type (_, [T, _])) $ _ $ _ => |
1208 (case rec_id (~1) T of |
1208 (case rec_id (~1) T of |
1209 "" => NONE |
1209 "" => NONE |
1210 | name => (case get_equalities thy name of |
1210 | name => (case get_equalities thy name of |
1218 * P t = 0: do not split |
1218 * P t = 0: do not split |
1219 * P t = ~1: completely split |
1219 * P t = ~1: completely split |
1220 * P t > 0: split up to given bound of record extensions |
1220 * P t > 0: split up to given bound of record extensions |
1221 *) |
1221 *) |
1222 fun record_split_simproc P = |
1222 fun record_split_simproc P = |
1223 Simplifier.simproc HOL.thy "record_split_simp" ["x"] |
1223 Simplifier.simproc @{theory HOL} "record_split_simp" ["x"] |
1224 (fn thy => fn _ => fn t => |
1224 (fn thy => fn _ => fn t => |
1225 (case t of (Const (quantifier, Type (_, [Type (_, [T, _]), _])))$trm => |
1225 (case t of (Const (quantifier, Type (_, [Type (_, [T, _]), _])))$trm => |
1226 if quantifier = "All" orelse quantifier = "all" orelse quantifier = "Ex" |
1226 if quantifier = "All" orelse quantifier = "all" orelse quantifier = "Ex" |
1227 then (case rec_id (~1) T of |
1227 then (case rec_id (~1) T of |
1228 "" => NONE |
1228 "" => NONE |
1241 end) |
1241 end) |
1242 else NONE |
1242 else NONE |
1243 | _ => NONE)) |
1243 | _ => NONE)) |
1244 |
1244 |
1245 val record_ex_sel_eq_simproc = |
1245 val record_ex_sel_eq_simproc = |
1246 Simplifier.simproc HOL.thy "record_ex_sel_eq_simproc" ["Ex t"] |
1246 Simplifier.simproc @{theory HOL} "record_ex_sel_eq_simproc" ["Ex t"] |
1247 (fn thy => fn ss => fn t => |
1247 (fn thy => fn ss => fn t => |
1248 let |
1248 let |
1249 fun prove prop = |
1249 fun prove prop = |
1250 quick_and_dirty_prove true thy [] prop |
1250 quick_and_dirty_prove true thy [] prop |
1251 (fn _ => simp_tac (Simplifier.inherit_context ss (get_simpset thy) |
1251 (fn _ => simp_tac (Simplifier.inherit_context ss (get_simpset thy) |