# HG changeset patch # User wenzelm # Date 1632130527 -7200 # Node ID 5c452041fe838b91c8cd8f78bf59a9f4f830fda8 # Parent 714e87ce6e9d30094b17782569f9b90bb0337a88 clarified antiquotations; diff -r 714e87ce6e9d -r 5c452041fe83 src/HOL/Tools/Argo/argo_real.ML --- a/src/HOL/Tools/Argo/argo_real.ML Sun Sep 19 21:55:11 2021 +0200 +++ b/src/HOL/Tools/Argo/argo_real.ML Mon Sep 20 11:35:27 2021 +0200 @@ -9,63 +9,62 @@ (* translating input terms *) -fun trans_type _ \<^typ>\Real.real\ tcx = SOME (Argo_Expr.Real, tcx) +fun trans_type _ \<^Type>\real\ tcx = SOME (Argo_Expr.Real, tcx) | trans_type _ _ _ = NONE -fun trans_term f (@{const Groups.uminus_class.uminus (real)} $ t) tcx = +fun trans_term f \<^Const_>\uminus \\<^Type>\real\\ for t\ tcx = tcx |> f t |>> Argo_Expr.mk_neg |> SOME - | trans_term f (@{const Groups.plus_class.plus (real)} $ t1 $ t2) tcx = + | trans_term f \<^Const_>\plus \\<^Type>\real\\ for t1 t2\ tcx = tcx |> f t1 ||>> f t2 |>> uncurry Argo_Expr.mk_add2 |> SOME - | trans_term f (@{const Groups.minus_class.minus (real)} $ t1 $ t2) tcx = + | trans_term f \<^Const_>\minus \\<^Type>\real\\ for t1 t2\ tcx = tcx |> f t1 ||>> f t2 |>> uncurry Argo_Expr.mk_sub |> SOME - | trans_term f (@{const Groups.times_class.times (real)} $ t1 $ t2) tcx = + | trans_term f \<^Const_>\times \\<^Type>\real\\ for t1 t2\ tcx = tcx |> f t1 ||>> f t2 |>> uncurry Argo_Expr.mk_mul |> SOME - | trans_term f (@{const Rings.divide_class.divide (real)} $ t1 $ t2) tcx = + | trans_term f \<^Const_>\divide \\<^Type>\real\\ for t1 t2\ tcx = tcx |> f t1 ||>> f t2 |>> uncurry Argo_Expr.mk_div |> SOME - | trans_term f (@{const Orderings.ord_class.min (real)} $ t1 $ t2) tcx = + | trans_term f \<^Const_>\min \\<^Type>\real\\ for t1 t2\ tcx = tcx |> f t1 ||>> f t2 |>> uncurry Argo_Expr.mk_min |> SOME - | trans_term f (@{const Orderings.ord_class.max (real)} $ t1 $ t2) tcx = + | trans_term f \<^Const_>\max \\<^Type>\real\\ for t1 t2\ tcx = tcx |> f t1 ||>> f t2 |>> uncurry Argo_Expr.mk_max |> SOME - | trans_term f (@{const Groups.abs_class.abs (real)} $ t) tcx = + | trans_term f \<^Const_>\abs \\<^Type>\real\\ for t\ tcx = tcx |> f t |>> Argo_Expr.mk_abs |> SOME - | trans_term f (@{const Orderings.ord_class.less (real)} $ t1 $ t2) tcx = + | trans_term f \<^Const_>\less \\<^Type>\real\\ for t1 t2\ tcx = tcx |> f t1 ||>> f t2 |>> uncurry Argo_Expr.mk_lt |> SOME - | trans_term f (@{const Orderings.ord_class.less_eq (real)} $ t1 $ t2) tcx = + | trans_term f \<^Const_>\less_eq \\<^Type>\real\\ for t1 t2\ tcx = tcx |> f t1 ||>> f t2 |>> uncurry Argo_Expr.mk_le |> SOME | trans_term _ t tcx = (case try HOLogic.dest_number t of - SOME (\<^typ>\Real.real\, n) => SOME (Argo_Expr.mk_num (Rat.of_int n), tcx) + SOME (\<^Type>\real\, n) => SOME (Argo_Expr.mk_num (Rat.of_int n), tcx) | _ => NONE) (* reverse translation *) -fun mk_plus t1 t2 = @{const Groups.plus_class.plus (real)} $ t1 $ t2 +fun mk_plus t1 t2 = \<^Const>\plus \\<^Type>\real\\ for t1 t2\ fun mk_sum ts = uncurry (fold_rev mk_plus) (split_last ts) -fun mk_times t1 t2 = @{const Groups.times_class.times (real)} $ t1 $ t2 -fun mk_divide t1 t2 = @{const Rings.divide_class.divide (real)} $ t1 $ t2 -fun mk_le t1 t2 = @{const Orderings.ord_class.less_eq (real)} $ t1 $ t2 -fun mk_lt t1 t2 = @{const Orderings.ord_class.less (real)} $ t1 $ t2 +fun mk_times t1 t2 = \<^Const>\times \\<^Type>\real\\ for t1 t2\ +fun mk_divide t1 t2 = \<^Const>\divide \\<^Type>\real\\ for t1 t2\ +fun mk_le t1 t2 = \<^Const>\less_eq \\<^Type>\real\\ for t1 t2\ +fun mk_lt t1 t2 = \<^Const>\less \\<^Type>\real\\ for t1 t2\ -fun mk_real_num i = HOLogic.mk_number \<^typ>\Real.real\ i +fun mk_real_num i = HOLogic.mk_number \<^Type>\real\ i fun mk_number n = let val (p, q) = Rat.dest n in if q = 1 then mk_real_num p else mk_divide (mk_real_num p) (mk_real_num q) end fun term_of _ (Argo_Expr.E (Argo_Expr.Num n, _)) = SOME (mk_number n) - | term_of f (Argo_Expr.E (Argo_Expr.Neg, [e])) = - SOME (@{const Groups.uminus_class.uminus (real)} $ f e) + | term_of f (Argo_Expr.E (Argo_Expr.Neg, [e])) = SOME \<^Const>\uminus \\<^Type>\real\\ for \f e\\ | term_of f (Argo_Expr.E (Argo_Expr.Add, es)) = SOME (mk_sum (map f es)) | term_of f (Argo_Expr.E (Argo_Expr.Sub, [e1, e2])) = - SOME (@{const Groups.minus_class.minus (real)} $ f e1 $ f e2) + SOME \<^Const>\minus \\<^Type>\real\\ for \f e1\ \f e2\\ | term_of f (Argo_Expr.E (Argo_Expr.Mul, [e1, e2])) = SOME (mk_times (f e1) (f e2)) | term_of f (Argo_Expr.E (Argo_Expr.Div, [e1, e2])) = SOME (mk_divide (f e1) (f e2)) | term_of f (Argo_Expr.E (Argo_Expr.Min, [e1, e2])) = - SOME (@{const Orderings.ord_class.min (real)} $ f e1 $ f e2) + SOME \<^Const>\min \\<^Type>\real\\ for \f e1\ \f e2\\ | term_of f (Argo_Expr.E (Argo_Expr.Max, [e1, e2])) = - SOME (@{const Orderings.ord_class.max (real)} $ f e1 $ f e2) - | term_of f (Argo_Expr.E (Argo_Expr.Abs, [e])) = SOME (@{const Groups.abs_class.abs (real)} $ f e) + SOME \<^Const>\max \\<^Type>\real\\ for \f e1\ \f e2\\ + | term_of f (Argo_Expr.E (Argo_Expr.Abs, [e])) = SOME \<^Const>\abs \\<^Type>\real\\ for \f e\\ | term_of f (Argo_Expr.E (Argo_Expr.Le, [e1, e2])) = SOME (mk_le (f e1) (f e2)) | term_of f (Argo_Expr.E (Argo_Expr.Lt, [e1, e2])) = SOME (mk_lt (f e1) (f e2)) | term_of _ _ = NONE @@ -93,15 +92,15 @@ fun inv_num_conv ctxt = nums_conv mk_divide (fn (_, n) => Rat.inv n) ctxt @1 fun cmp_nums_conv ctxt b ct = - let val t = if b then \<^const>\HOL.True\ else \<^const>\HOL.False\ + let val t = if b then \<^Const>\True\ else \<^Const>\False\ in simp_conv ctxt (HOLogic.mk_eq (Thm.term_of ct, t)) ct end local -fun is_add2 (@{const Groups.plus_class.plus (real)} $ _ $ _) = true +fun is_add2 \<^Const_>\plus \\<^Type>\real\\ for _ _\ = true | is_add2 _ = false -fun is_add3 (@{const Groups.plus_class.plus (real)} $ _ $ t) = is_add2 t +fun is_add3 \<^Const_>\plus \\<^Type>\real\\ for _ t\ = is_add2 t | is_add3 _ = false val flatten_thm = mk_rewr @{lemma "(a::real) + b + c = a + (b + c)" by simp} diff -r 714e87ce6e9d -r 5c452041fe83 src/HOL/Tools/Argo/argo_tactic.ML --- a/src/HOL/Tools/Argo/argo_tactic.ML Sun Sep 19 21:55:11 2021 +0200 +++ b/src/HOL/Tools/Argo/argo_tactic.ML Mon Sep 20 11:35:27 2021 +0200 @@ -144,8 +144,8 @@ SOME ty => (ty, tcx) | NONE => add_new_type T tcx) -fun trans_type _ \<^typ>\HOL.bool\ = pair Argo_Expr.Bool - | trans_type ctxt (Type (\<^type_name>\fun\, [T1, T2])) = +fun trans_type _ \<^Type>\bool\ = pair Argo_Expr.Bool + | trans_type ctxt \<^Type>\fun T1 T2\ = trans_type ctxt T1 ##>> trans_type ctxt T2 #>> Argo_Expr.Func | trans_type ctxt T = (fn tcx => (case ext_trans_type ctxt (trans_type ctxt) T tcx of @@ -164,23 +164,23 @@ SOME c => (Argo_Expr.mk_con c, tcx) | NONE => add_new_term ctxt t (Term.fastype_of t) tcx) -fun mk_eq \<^typ>\HOL.bool\ = Argo_Expr.mk_iff +fun mk_eq \<^Type>\bool\ = Argo_Expr.mk_iff | mk_eq _ = Argo_Expr.mk_eq -fun trans_term _ \<^const>\HOL.True\ = pair Argo_Expr.true_expr - | trans_term _ \<^const>\HOL.False\ = pair Argo_Expr.false_expr - | trans_term ctxt (\<^const>\HOL.Not\ $ t) = trans_term ctxt t #>> Argo_Expr.mk_not - | trans_term ctxt (\<^const>\HOL.conj\ $ t1 $ t2) = +fun trans_term _ \<^Const_>\True\ = pair Argo_Expr.true_expr + | trans_term _ \<^Const_>\False\ = pair Argo_Expr.false_expr + | trans_term ctxt \<^Const_>\Not for t\ = trans_term ctxt t #>> Argo_Expr.mk_not + | trans_term ctxt \<^Const_>\conj for t1 t2\ = trans_term ctxt t1 ##>> trans_term ctxt t2 #>> uncurry Argo_Expr.mk_and2 - | trans_term ctxt (\<^const>\HOL.disj\ $ t1 $ t2) = + | trans_term ctxt \<^Const_>\disj for t1 t2\ = trans_term ctxt t1 ##>> trans_term ctxt t2 #>> uncurry Argo_Expr.mk_or2 - | trans_term ctxt (\<^const>\HOL.implies\ $ t1 $ t2) = + | trans_term ctxt \<^Const_>\implies for t1 t2\ = trans_term ctxt t1 ##>> trans_term ctxt t2 #>> uncurry Argo_Expr.mk_imp - | trans_term ctxt (Const (\<^const_name>\HOL.If\, _) $ t1 $ t2 $ t3) = + | trans_term ctxt \<^Const_>\If _ for t1 t2 t3\ = trans_term ctxt t1 ##>> trans_term ctxt t2 ##>> trans_term ctxt t3 #>> (fn ((u1, u2), u3) => Argo_Expr.mk_ite u1 u2 u3) - | trans_term ctxt (Const (\<^const_name>\HOL.eq\, T) $ t1 $ t2) = - trans_term ctxt t1 ##>> trans_term ctxt t2 #>> uncurry (mk_eq (Term.domain_type T)) + | trans_term ctxt \<^Const_>\HOL.eq T for t1 t2\ = + trans_term ctxt t1 ##>> trans_term ctxt t2 #>> uncurry (mk_eq T) | trans_term ctxt (t as (t1 $ t2)) = (fn tcx => (case ext_trans_term ctxt (trans_term ctxt) t tcx of SOME result => result @@ -258,18 +258,16 @@ | mk_nary' _ f ts = mk_nary f ts fun mk_ite t1 t2 t3 = - let - val T = Term.fastype_of t2 - val ite = Const (\<^const_name>\HOL.If\, [\<^typ>\HOL.bool\, T, T] ---> T) - in ite $ t1 $ t2 $ t3 end + let val T = Term.fastype_of t2 + in \<^Const>\If T for t1 t2 t3\ end -fun term_of _ (Argo_Expr.E (Argo_Expr.True, _)) = \<^const>\HOL.True\ - | term_of _ (Argo_Expr.E (Argo_Expr.False, _)) = \<^const>\HOL.False\ +fun term_of _ (Argo_Expr.E (Argo_Expr.True, _)) = \<^Const>\True\ + | term_of _ (Argo_Expr.E (Argo_Expr.False, _)) = \<^Const>\False\ | term_of cx (Argo_Expr.E (Argo_Expr.Not, [e])) = HOLogic.mk_not (term_of cx e) | term_of cx (Argo_Expr.E (Argo_Expr.And, es)) = - mk_nary' \<^const>\HOL.True\ HOLogic.mk_conj (map (term_of cx) es) + mk_nary' \<^Const>\True\ HOLogic.mk_conj (map (term_of cx) es) | term_of cx (Argo_Expr.E (Argo_Expr.Or, es)) = - mk_nary' \<^const>\HOL.False\ HOLogic.mk_disj (map (term_of cx) es) + mk_nary' \<^Const>\False\ HOLogic.mk_disj (map (term_of cx) es) | term_of cx (Argo_Expr.E (Argo_Expr.Imp, [e1, e2])) = HOLogic.mk_imp (term_of cx e1, term_of cx e2) | term_of cx (Argo_Expr.E (Argo_Expr.Iff, [e1, e2])) = @@ -289,7 +287,7 @@ SOME t => t | NONE => raise Fail "bad expression") -fun as_prop ct = Thm.apply \<^cterm>\HOL.Trueprop\ ct +fun as_prop ct = Thm.apply \<^cterm>\Trueprop\ ct fun cterm_of ctxt cons e = Thm.cterm_of ctxt (term_of (ctxt, cons) e) fun cprop_of ctxt cons e = as_prop (cterm_of ctxt cons e) @@ -317,7 +315,7 @@ fun with_frees ctxt n mk = let val ns = map (fn i => "P" ^ string_of_int i) (0 upto (n - 1)) - val ts = map (Free o rpair \<^typ>\bool\) ns + val ts = map (Free o rpair \<^Type>\bool\) ns val t = mk_nary HOLogic.mk_disj (mk ts) in prove_taut ctxt ns t end @@ -374,12 +372,12 @@ fun flat_conj_conv ct = (case Thm.term_of ct of - \<^const>\HOL.conj\ $ _ $ _ => flatten_conv flat_conj_conv flatten_and_thm ct + \<^Const_>\conj for _ _\ => flatten_conv flat_conj_conv flatten_and_thm ct | _ => Conv.all_conv ct) fun flat_disj_conv ct = (case Thm.term_of ct of - \<^const>\HOL.disj\ $ _ $ _ => flatten_conv flat_disj_conv flatten_or_thm ct + \<^Const_>\disj for _ _\ => flatten_conv flat_disj_conv flatten_or_thm ct | _ => Conv.all_conv ct) fun explode rule1 rule2 thm = @@ -415,7 +413,7 @@ in mk_rewr (discharge2 lhs rhs rule) end fun with_conj f g ct = iff_intro iff_conj_thm (f o explode_conj) g ct -fun with_ndis f g ct = iff_intro iff_ndis_thm (f o explode_ndis) g (Thm.apply \<^cterm>\HOL.Not\ ct) +fun with_ndis f g ct = iff_intro iff_ndis_thm (f o explode_ndis) g (Thm.apply \<^cterm>\Not\ ct) fun swap_indices n iss = map (fn i => find_index (fn is => member (op =) is i) iss) (0 upto (n - 1)) fun sort_nary w f g (n, iss) = w (f (map hd iss)) (under_assumption (f (swap_indices n iss) o g)) @@ -485,7 +483,7 @@ | replay_args_conv ctxt [c1, c2] ct = binop_conv (replay_conv ctxt c1) (replay_conv ctxt c2) ct | replay_args_conv ctxt (c :: cs) ct = (case Term.head_of (Thm.term_of ct) of - Const (\<^const_name>\HOL.If\, _) => + \<^Const_>\If _\ => let val (cs', c') = split_last cs in Conv.combination_conv (replay_args_conv ctxt (c :: cs')) (replay_conv ctxt c') ct end | _ => binop_conv (replay_conv ctxt c) (replay_args_conv ctxt cs) ct) @@ -521,7 +519,7 @@ val unit_rule = @{lemma "(P \ False) \ (\P \ False) \ False" by fast} val unit_rule_var = Thm.dest_arg (Thm.dest_arg1 (Thm.cprem_of unit_rule 1)) -val bogus_ct = \<^cterm>\HOL.True\ +val bogus_ct = \<^cterm>\True\ fun replay_unit_res lit (pthm, plits) (nthm, nlits) = let @@ -544,7 +542,7 @@ fun replay_hyp i ct = if i < 0 then (Thm.assume ct, [(~i, ct)]) else - let val cu = as_prop (Thm.apply \<^cterm>\HOL.Not\ (Thm.apply \<^cterm>\HOL.Not\ (Thm.dest_arg ct))) + let val cu = as_prop (Thm.apply \<^cterm>\Not\ (Thm.apply \<^cterm>\Not\ (Thm.dest_arg ct))) in (discharge (Thm.assume cu) dneg_rule, [(~i, cu)]) end @@ -602,7 +600,7 @@ fun unclausify (thm, lits) ls = (case (Thm.prop_of thm, lits) of - (\<^const>\HOL.Trueprop\ $ \<^const>\HOL.False\, [(_, ct)]) => + (\<^Const_>\Trueprop for \\<^Const_>\False\\\, [(_, ct)]) => let val thm = Thm.implies_intr ct thm in (discharge thm unclausify_rule1 handle THM _ => discharge thm unclausify_rule2, ls) end | _ => (thm, Ord_List.union lit_ord lits ls)) @@ -669,22 +667,22 @@ let val ct = Drule.strip_imp_concl (Thm.cprop_of thm) in (case Thm.term_of ct of - \<^const>\HOL.Trueprop\ $ Var (_, \<^typ>\HOL.bool\) => - instantiate (Thm.dest_arg ct) \<^cterm>\HOL.False\ thm - | Var _ => instantiate ct \<^cprop>\HOL.False\ thm + \<^Const_>\Trueprop for \Var (_, \<^Type>\bool\)\\ => + instantiate (Thm.dest_arg ct) \<^cterm>\False\ thm + | Var _ => instantiate ct \<^cprop>\False\ thm | _ => thm) end fun atomize_conv ctxt ct = (case Thm.term_of ct of - \<^const>\HOL.Trueprop\ $ _ => Conv.all_conv - | \<^const>\Pure.imp\ $ _ $ _ => + \<^Const_>\Trueprop for _\ => Conv.all_conv + | \<^Const_>\Pure.imp for _ _\ => Conv.binop_conv (atomize_conv ctxt) then_conv Conv.rewr_conv @{thm atomize_imp} - | Const (\<^const_name>\Pure.eq\, _) $ _ $ _ => + | \<^Const>\Pure.eq _ for _ _\ => Conv.binop_conv (atomize_conv ctxt) then_conv Conv.rewr_conv @{thm atomize_eq} - | Const (\<^const_name>\Pure.all\, _) $ Abs _ => + | \<^Const>\Pure.all _ for \Abs _\\ => Conv.binder_conv (atomize_conv o snd) ctxt then_conv Conv.rewr_conv @{thm atomize_all} | _ => Conv.all_conv) ct