# HG changeset patch # User wenzelm # Date 1635358033 -7200 # Node ID eceb93181ad9c303ce39e60e9151184e431cdfb7 # Parent 5d91897a8e5420fdd824b6b64cd2fde2d469e7bc more antiquotations; diff -r 5d91897a8e54 -r eceb93181ad9 src/HOL/Tools/record.ML --- a/src/HOL/Tools/record.ML Wed Oct 27 11:47:42 2021 +0100 +++ b/src/HOL/Tools/record.ML Wed Oct 27 20:07:13 2021 +0200 @@ -107,17 +107,11 @@ |-> (fn (tyco, info) => get_typedef_info tyco vs info) end; -fun mk_cons_tuple (left, right) = - let - val (leftT, rightT) = (fastype_of left, fastype_of right); - val prodT = HOLogic.mk_prodT (leftT, rightT); - val isomT = Type (\<^type_name>\tuple_isomorphism\, [prodT, leftT, rightT]); - in - Const (\<^const_name>\Record.iso_tuple_cons\, isomT --> leftT --> rightT --> prodT) $ - Const (fst tuple_iso_tuple, isomT) $ left $ right - end; - -fun dest_cons_tuple (Const (\<^const_name>\Record.iso_tuple_cons\, _) $ Const _ $ t $ u) = (t, u) +fun mk_cons_tuple (t, u) = + let val (A, B) = apply2 fastype_of (t, u) + in \<^Const>\iso_tuple_cons \<^Type>\prod A B\ A B for \<^Const>\tuple_iso_tuple A B\ t u\ end; + +fun dest_cons_tuple \<^Const_>\iso_tuple_cons _ _ _ for \Const _\ t u\ = (t, u) | dest_cons_tuple t = raise TERM ("dest_cons_tuple", [t]); fun add_iso_tuple_type overloaded (b, alphas) (leftT, rightT) thy = @@ -149,7 +143,7 @@ [((Binding.concealed (Thm.def_binding isom_binding), Logic.mk_equals (isom, body)), [])]; val iso_tuple = isom_def RS (abs_inverse RS (rep_inject RS iso_tuple_intro)); - val cons = Const (\<^const_name>\Record.iso_tuple_cons\, isomT --> leftT --> rightT --> absT); + val cons = \<^Const>\iso_tuple_cons absT leftT rightT\; val thm_thy = cdef_thy @@ -171,8 +165,7 @@ val goal' = Envir.beta_eta_contract goal; val is = (case goal' of - Const (\<^const_name>\Trueprop\, _) $ - (Const (\<^const_name>\isomorphic_tuple\, _) $ Const is) => is + \<^Const_>\Trueprop for \<^Const>\isomorphic_tuple _ _ _ for \Const is\\\ => is | _ => err "unexpected goal format" goal'); val isthm = (case Symtab.lookup isthms (#1 is) of @@ -937,7 +930,7 @@ fun mk_comp_id f = let val T = range_type (fastype_of f) - in HOLogic.mk_comp (Const (\<^const_name>\Fun.id\, T --> T), f) end; + in HOLogic.mk_comp (\<^Const>\id T\, f) end; fun get_upd_funs (upd $ _ $ t) = upd :: get_upd_funs t | get_upd_funs _ = []; @@ -1272,7 +1265,7 @@ {lhss = [\<^term>\r = s\], proc = fn _ => fn ctxt => fn ct => (case Thm.term_of ct of - Const (\<^const_name>\HOL.eq\, Type (_, [T, _])) $ _ $ _ => + \<^Const_>\HOL.eq T for _ _\ => (case rec_id ~1 T of "" => NONE | name => @@ -1325,7 +1318,7 @@ let val thy = Proof_Context.theory_of ctxt; val t = Thm.term_of ct; - fun mkeq (lr, Teq, (sel, Tsel), x) i = + fun mkeq (lr, T, (sel, Tsel), x) i = if is_selector thy sel then let val x' = @@ -1334,23 +1327,22 @@ else raise TERM ("", [x]); val sel' = Const (sel, Tsel) $ Bound 0; val (l, r) = if lr then (sel', x') else (x', sel'); - in Const (\<^const_name>\HOL.eq\, Teq) $ l $ r end + in \<^Const>\HOL.eq T for l r\ end else raise TERM ("", [Const (sel, Tsel)]); - fun dest_sel_eq (Const (\<^const_name>\HOL.eq\, Teq) $ (Const (sel, Tsel) $ Bound 0) $ X) = - (true, Teq, (sel, Tsel), X) - | dest_sel_eq (Const (\<^const_name>\HOL.eq\, Teq) $ X $ (Const (sel, Tsel) $ Bound 0)) = - (false, Teq, (sel, Tsel), X) + fun dest_sel_eq (\<^Const_>\HOL.eq T\ $ (Const (sel, Tsel) $ Bound 0) $ X) = + (true, T, (sel, Tsel), X) + | dest_sel_eq (\<^Const_>\HOL.eq T\ $ X $ (Const (sel, Tsel) $ Bound 0)) = + (false, T, (sel, Tsel), X) | dest_sel_eq _ = raise TERM ("", []); in (case t of - Const (\<^const_name>\Ex\, Tex) $ Abs (s, T, t) => + \<^Const_>\Ex T for \Abs (s, _, t)\\ => (let val eq = mkeq (dest_sel_eq t) 0; val prop = Logic.list_all ([("r", T)], - Logic.mk_equals - (Const (\<^const_name>\Ex\, Tex) $ Abs (s, T, eq), \<^term>\True\)); + Logic.mk_equals (\<^Const>\Ex T for \Abs (s, T, eq)\\, \<^Const>\True\)); in SOME (Goal.prove_sorry_global thy [] [] prop (fn {context = ctxt', ...} => @@ -1713,16 +1705,11 @@ val T = Type (tyco, map TFree vs); val test_function = Free ("f", termifyT T --> \<^typ>\(bool \ term list) option\); val params = Name.invent_names Name.context "x" Ts; - fun full_exhaustiveT T = - (termifyT T --> \<^typ>\(bool \ Code_Evaluation.term list) option\) --> - \<^typ>\natural\ --> \<^typ>\(bool \ Code_Evaluation.term list) option\; - fun mk_full_exhaustive T = - Const (\<^const_name>\Quickcheck_Exhaustive.full_exhaustive_class.full_exhaustive\, - full_exhaustiveT T); + fun mk_full_exhaustive U = \<^Const>\full_exhaustive_class.full_exhaustive U\; val lhs = mk_full_exhaustive T $ test_function $ size; val tc = test_function $ (HOLogic.mk_valtermify_app extN params T); - val rhs = fold_rev (fn (v, T) => fn cont => - mk_full_exhaustive T $ (lambda (Free (v, termifyT T)) cont) $ size) params tc; + val rhs = fold_rev (fn (v, U) => fn cont => + mk_full_exhaustive U $ (lambda (Free (v, termifyT U)) cont) $ size) params tc; in (lhs, rhs) end; @@ -1756,10 +1743,7 @@ fun add_code ext_tyco vs extT ext simps inject thy = if Config.get_global thy codegen then let - val eq = - HOLogic.mk_Trueprop (HOLogic.mk_eq - (Const (\<^const_name>\HOL.equal\, extT --> extT --> HOLogic.boolT), - Const (\<^const_name>\HOL.eq\, extT --> extT --> HOLogic.boolT))); + val eq = HOLogic.mk_Trueprop (HOLogic.mk_eq (\<^Const>\HOL.equal extT\, \<^Const>\HOL.eq extT\)); fun tac ctxt eq_def = Class.intro_classes_tac ctxt [] THEN rewrite_goals_tac ctxt [Simpdata.mk_eq eq_def]