# HG changeset patch # User wenzelm # Date 1632080234 -7200 # Node ID 54b2e5f771daf27f1c23c3986b60cd8347e8add6 # Parent 3360ea6b659dbb03eb7dce90b0bd052dc798199a clarified signature -- prefer antiquotations (with subtle change of exception content); diff -r 3360ea6b659d -r 54b2e5f771da src/FOL/fologic.ML --- a/src/FOL/fologic.ML Sun Sep 19 21:35:51 2021 +0200 +++ b/src/FOL/fologic.ML Sun Sep 19 21:37:14 2021 +0200 @@ -6,14 +6,8 @@ signature FOLOGIC = sig - val oT: typ val mk_Trueprop: term -> term val dest_Trueprop: term -> term - val not: term - val conj: term - val disj: term - val imp: term - val iff: term val mk_conj: term * term -> term val mk_disj: term * term -> term val mk_imp: term * term -> term @@ -28,52 +22,32 @@ val eq_const: typ -> term val mk_eq: term * term -> term val dest_eq: term -> term * term - val mk_binop: string -> term * term -> term - val mk_binrel: string -> term * term -> term - val dest_bin: string -> typ -> term -> term * term end; structure FOLogic: FOLOGIC = struct -val oT = \<^Type>\o\; - -val Trueprop = \<^Const>\Trueprop\; - -fun mk_Trueprop P = Trueprop $ P; +fun mk_Trueprop P = \<^Const>\Trueprop for P\; -fun dest_Trueprop \<^Const_>\Trueprop for P\ = P - | dest_Trueprop t = raise TERM ("dest_Trueprop", [t]); - - -(* Logical constants *) +val dest_Trueprop = \<^Const_fn>\Trueprop for P => P\; -val not = \<^Const>\Not\; -val conj = \<^Const>\conj\; -val disj = \<^Const>\disj\; -val imp = \<^Const>\imp\; -val iff = \<^Const>\iff\; +fun mk_conj (t1, t2) = \<^Const>\conj for t1 t2\ +and mk_disj (t1, t2) = \<^Const>\disj for t1 t2\ +and mk_imp (t1, t2) = \<^Const>\imp for t1 t2\ +and mk_iff (t1, t2) = \<^Const>\iff for t1 t2\; -fun mk_conj (t1, t2) = conj $ t1 $ t2 -and mk_disj (t1, t2) = disj $ t1 $ t2 -and mk_imp (t1, t2) = imp $ t1 $ t2 -and mk_iff (t1, t2) = iff $ t1 $ t2; - -fun dest_imp \<^Const_>\imp for A B\ = (A, B) - | dest_imp t = raise TERM ("dest_imp", [t]); +val dest_imp = \<^Const_fn>\imp for A B => \(A, B)\\; fun dest_conj \<^Const_>\conj for t t'\ = t :: dest_conj t' | dest_conj t = [t]; -fun dest_iff \<^Const_>\iff for A B\ = (A, B) - | dest_iff t = raise TERM ("dest_iff", [t]); +val dest_iff = \<^Const_fn>\iff for A B => \(A, B)\\; fun eq_const T = \<^Const>\eq T\; fun mk_eq (t, u) = eq_const (fastype_of t) $ t $ u; -fun dest_eq \<^Const_>\eq _ for lhs rhs\ = (lhs, rhs) - | dest_eq t = raise TERM ("dest_eq", [t]) +val dest_eq = \<^Const_fn>\eq _ for lhs rhs => \(lhs, rhs)\\; fun all_const T = \<^Const>\All T\; fun mk_all (Free (x, T), P) = all_const T $ absfree (x, T) P; @@ -81,22 +55,4 @@ fun exists_const T = \<^Const>\Ex T\; fun mk_exists (Free (x, T), P) = exists_const T $ absfree (x, T) P; - -(* binary operations and relations *) - -fun mk_binop c (t, u) = - let val T = fastype_of t in - Const (c, [T, T] ---> T) $ t $ u - end; - -fun mk_binrel c (t, u) = - let val T = fastype_of t in - Const (c, [T, T] ---> oT) $ t $ u - end; - -fun dest_bin c T (tm as Const (c', Type ("fun", [T', _])) $ t $ u) = - if c = c' andalso T = T' then (t, u) - else raise TERM ("dest_bin " ^ c, [tm]) - | dest_bin c _ tm = raise TERM ("dest_bin " ^ c, [tm]); - end; diff -r 3360ea6b659d -r 54b2e5f771da src/FOL/simpdata.ML --- a/src/FOL/simpdata.ML Sun Sep 19 21:35:51 2021 +0200 +++ b/src/FOL/simpdata.ML Sun Sep 19 21:37:14 2021 +0200 @@ -63,8 +63,8 @@ | dest_conj _ = NONE fun dest_imp \<^Const_>\imp for s t\ = SOME (s, t) | dest_imp _ = NONE - val conj = FOLogic.conj - val imp = FOLogic.imp + val conj = \<^Const>\conj\ + val imp = \<^Const>\imp\ (*rules*) val iff_reflection = @{thm iff_reflection} val iffI = @{thm iffI} diff -r 3360ea6b659d -r 54b2e5f771da src/ZF/Tools/cartprod.ML --- a/src/ZF/Tools/cartprod.ML Sun Sep 19 21:35:51 2021 +0200 +++ b/src/ZF/Tools/cartprod.ML Sun Sep 19 21:37:14 2021 +0200 @@ -70,24 +70,22 @@ fun pseudo_type (t $ A $ Abs(_,_,B)) = if t = Pr.sigma then mk_prod(pseudo_type A, pseudo_type B) - else \<^typ>\i\ - | pseudo_type _ = \<^typ>\i\; + else \<^Type>\i\ + | pseudo_type _ = \<^Type>\i\; (*Maps the type T1*...*Tn to [T1,...,Tn], however nested*) fun factors (Type("*", [T1, T2])) = factors T1 @ factors T2 | factors T = [T]; (*Make a well-typed instance of "split"*) -fun split_const T = Const(Pr.split_name, - [[Ind_Syntax.iT, Ind_Syntax.iT]--->T, - Ind_Syntax.iT] ---> T); +fun split_const T = Const(Pr.split_name, [[\<^Type>\i\, \<^Type>\i\]--->T, \<^Type>\i\] ---> T); (*In ap_split S T u, term u expects separate arguments for the factors of S, with result type T. The call creates a new term expecting one argument of type S.*) fun ap_split (Type("*", [T1,T2])) T3 u = split_const T3 $ - Abs("v", Ind_Syntax.iT, (*Not T1, as it involves pseudo-product types*) + Abs("v", \<^Type>\i\, (*Not T1, as it involves pseudo-product types*) ap_split T2 T3 ((ap_split T1 (factors T2 ---> T3) (incr_boundvars 1 u)) $ Bound 0)) @@ -109,7 +107,7 @@ in remove_split ctxt (Drule.instantiate_normalize (TVars.empty, - Vars.make [((v, Ind_Syntax.iT-->T2), Thm.cterm_of ctxt newt)]) rl) + Vars.make [((v, \<^Type>\i\ --> T2), Thm.cterm_of ctxt newt)]) rl) end | split_rule_var _ (t,T,rl) = rl; diff -r 3360ea6b659d -r 54b2e5f771da src/ZF/Tools/datatype_package.ML --- a/src/ZF/Tools/datatype_package.ML Sun Sep 19 21:35:51 2021 +0200 +++ b/src/ZF/Tools/datatype_package.ML Sun Sep 19 21:37:14 2021 +0200 @@ -115,10 +115,10 @@ (*Combine split terms using case; yields the case operator for one part*) fun call_case case_list = - let fun call_f (free,[]) = Abs("null", \<^typ>\i\, free) + let fun call_f (free,[]) = Abs("null", \<^Type>\i\, free) | call_f (free,args) = CP.ap_split (foldr1 CP.mk_prod (map (#2 o dest_Free) args)) - \<^typ>\i\ + \<^Type>\i\ free in Balanced_Tree.make (fn (t1, t2) => Su.elim $ t1 $ t2) (map call_f case_list) end; @@ -162,7 +162,7 @@ Non-identifiers (e.g. infixes) get a name of the form f_op_nnn. **) (*a recursive call for x is the application rec`x *) - val rec_call = \<^Const>\apply\ $ Free ("rec", \<^typ>\i\); + val rec_call = \<^Const>\apply\ $ Free ("rec", \<^Type>\i\); (*look back down the "case args" (which have been reversed) to determine the de Bruijn index*) @@ -199,7 +199,7 @@ (*Add an argument position for each occurrence of a recursive set. Strictly speaking, the recursive arguments are the LAST of the function variable, but they all have type "i" anyway*) - fun add_rec_args args' T = (map (fn _ => \<^typ>\i\) args') ---> T + fun add_rec_args args' T = (map (fn _ => \<^Type>\i\) args') ---> T (*Plug in the function variable type needed for the recursor as well as the new arguments (recursive calls)*) @@ -232,7 +232,7 @@ Misc_Legacy.mk_defpair (recursor_tm, \<^Const>\Univ.Vrecursor\ $ - absfree ("rec", \<^typ>\i\) (list_comb (case_const, recursor_cases))); + absfree ("rec", \<^Type>\i\) (list_comb (case_const, recursor_cases))); (* Build the new theory *) @@ -412,7 +412,7 @@ let val ctxt = Proof_Context.init_global thy; fun read_is strs = - map (Syntax.parse_term ctxt #> Type.constraint \<^typ>\i\) strs + map (Syntax.parse_term ctxt #> Type.constraint \<^Type>\i\) strs |> Syntax.check_terms ctxt; val rec_tms = read_is srec_tms; diff -r 3360ea6b659d -r 54b2e5f771da src/ZF/Tools/inductive_package.ML --- a/src/ZF/Tools/inductive_package.ML Sun Sep 19 21:35:51 2021 +0200 +++ b/src/ZF/Tools/inductive_package.ML Sun Sep 19 21:37:14 2021 +0200 @@ -108,14 +108,14 @@ let val prems = map dest_tprop (Logic.strip_imp_prems intr) val dummy = List.app (fn rec_hd => List.app (Ind_Syntax.chk_prem rec_hd) prems) rec_hds val exfrees = subtract (op =) rec_params (Misc_Legacy.term_frees intr) - val zeq = FOLogic.mk_eq (Free(z', Ind_Syntax.iT), #1 (Ind_Syntax.rule_concl intr)) + val zeq = FOLogic.mk_eq (Free(z', \<^Type>\i\), #1 (Ind_Syntax.rule_concl intr)) in List.foldr FOLogic.mk_exists (Balanced_Tree.make FOLogic.mk_conj (zeq::prems)) exfrees end; (*The Part(A,h) terms -- compose injections to make h*) - fun mk_Part (Bound 0) = Free(X', Ind_Syntax.iT) (*no mutual rec, no Part needed*) - | mk_Part h = \<^Const>\Part\ $ Free(X', Ind_Syntax.iT) $ Abs (w', Ind_Syntax.iT, h); + fun mk_Part (Bound 0) = Free(X', \<^Type>\i\) (*no mutual rec, no Part needed*) + | mk_Part h = \<^Const>\Part\ $ Free(X', \<^Type>\i\) $ Abs (w', \<^Type>\i\, h); (*Access to balanced disjoint sums via injections*) val parts = map mk_Part @@ -126,7 +126,7 @@ val part_intrs = map (subst_free (rec_tms ~~ parts) o fp_part) intr_tms; val fp_abs = - absfree (X', Ind_Syntax.iT) + absfree (X', \<^Type>\i\) (Ind_Syntax.mk_Collect (z', dom_sum, Balanced_Tree.make FOLogic.mk_disj part_intrs)); @@ -159,7 +159,7 @@ (case parts of [_] => [] (*no mutual recursion*) | _ => rec_tms ~~ (*define the sets as Parts*) - map (subst_atomic [(Free (X', Ind_Syntax.iT), big_rec_tm)]) parts)); + map (subst_atomic [(Free (X', \<^Type>\i\), big_rec_tm)]) parts)); (*tracing: print the fixedpoint definition*) val dummy = if !Ind_Syntax.trace then @@ -323,7 +323,7 @@ | ind_tac ctxt (prem::prems) i = DEPTH_SOLVE_1 (ares_tac ctxt [prem, @{thm refl}] i) THEN ind_tac ctxt prems (i-1); - val pred = Free(pred_name, Ind_Syntax.iT --> FOLogic.oT); + val pred = Free(pred_name, \<^Type>\i\ --> \<^Type>\o\); val ind_prems = map (induct_prem (map (rpair pred) rec_tms)) intr_tms; @@ -387,12 +387,12 @@ fun mk_predpair rec_tm = let val rec_name = (#1 o dest_Const o head_of) rec_tm val pfree = Free(pred_name ^ "_" ^ Long_Name.base_name rec_name, - elem_factors ---> FOLogic.oT) + elem_factors ---> \<^Type>\o\) val qconcl = List.foldr FOLogic.mk_all - (FOLogic.imp $ \<^Const>\mem for elem_tuple rec_tm\ + (\<^Const>\imp\ $ \<^Const>\mem for elem_tuple rec_tm\ $ (list_comb (pfree, elem_frees))) elem_frees - in (CP.ap_split elem_type FOLogic.oT pfree, + in (CP.ap_split elem_type \<^Type>\o\ pfree, qconcl) end; @@ -400,14 +400,14 @@ (*Used to form simultaneous induction lemma*) fun mk_rec_imp (rec_tm,pred) = - FOLogic.imp $ \<^Const>\mem for \Bound 0\ rec_tm\ $ (pred $ Bound 0); + \<^Const>\imp\ $ \<^Const>\mem for \Bound 0\ rec_tm\ $ (pred $ Bound 0); (*To instantiate the main induction rule*) val induct_concl = FOLogic.mk_Trueprop (Ind_Syntax.mk_all_imp (big_rec_tm, - Abs("z", Ind_Syntax.iT, + Abs("z", \<^Type>\i\, Balanced_Tree.make FOLogic.mk_conj (ListPair.map mk_rec_imp (rec_tms, preds))))) and mutual_induct_concl = @@ -515,7 +515,7 @@ val induct0 = CP.split_rule_var ctxt4 - (pred_var, elem_type-->FOLogic.oT, induct0) + (pred_var, elem_type --> \<^Type>\o\, induct0) |> Drule.export_without_context and mutual_induct = CP.remove_split ctxt4 mutual_induct_fsplit @@ -564,7 +564,7 @@ (raw_monos, raw_con_defs, raw_type_intrs, raw_type_elims) thy = let val ctxt = Proof_Context.init_global thy; - val read_terms = map (Syntax.parse_term ctxt #> Type.constraint Ind_Syntax.iT) + val read_terms = map (Syntax.parse_term ctxt #> Type.constraint \<^Type>\i\) #> Syntax.check_terms ctxt; val intr_atts = map (map (Attrib.attribute_cmd ctxt) o snd) intr_srcs; diff -r 3360ea6b659d -r 54b2e5f771da src/ZF/Tools/primrec_package.ML --- a/src/ZF/Tools/primrec_package.ML Sun Sep 19 21:35:51 2021 +0200 +++ b/src/ZF/Tools/primrec_package.ML Sun Sep 19 21:37:14 2021 +0200 @@ -106,7 +106,7 @@ and recursor_pairs = map (dest_eqn o Thm.concl_of) rec_rewrites fun absterm (Free x, body) = absfree x body - | absterm (t, body) = Abs("rec", Ind_Syntax.iT, abstract_over (t, body)) + | absterm (t, body) = Abs("rec", \<^Type>\i\, abstract_over (t, body)) (*Translate rec equations into function arguments suitable for recursor. Missing cases are replaced by 0 and all cases are put into order.*) @@ -140,7 +140,7 @@ (*the recursive argument*) val rec_arg = Free (singleton (Name.variant_list (map #1 (ls@rs))) (Long_Name.base_name big_rec_name), - Ind_Syntax.iT) + \<^Type>\i\) val def_tm = Logic.mk_equals (subst_bound (rec_arg, fabs), diff -r 3360ea6b659d -r 54b2e5f771da src/ZF/arith_data.ML --- a/src/ZF/arith_data.ML Sun Sep 19 21:35:51 2021 +0200 +++ b/src/ZF/arith_data.ML Sun Sep 19 21:37:14 2021 +0200 @@ -22,8 +22,6 @@ structure ArithData: ARITH_DATA = struct -val iT = Ind_Syntax.iT; - val zero = \<^Const>\zero\; val succ = \<^Const>\succ\; fun mk_succ t = succ $ t; @@ -49,8 +47,9 @@ (*Use <-> or = depending on the type of t*) fun mk_eq_iff(t,u) = - if fastype_of t = iT then FOLogic.mk_eq(t,u) - else FOLogic.mk_iff(t,u); + if fastype_of t = \<^Type>\i\ + then \<^Const>\IFOL.eq \\<^Type>\i\\ for t u\ + else \<^Const>\IFOL.iff for t u\; (*We remove equality assumptions because they confuse the simplifier and because only type-checking assumptions are necessary.*) @@ -79,12 +78,10 @@ | mk_prod (t :: ts) = if t = one then mk_prod ts else mk_times (t, mk_prod ts); -val dest_times = FOLogic.dest_bin \<^const_name>\Arith.mult\ iT; - -fun dest_prod t = - let val (t,u) = dest_times t - in dest_prod t @ dest_prod u end - handle TERM _ => [t]; +fun dest_prod tm = + let val (t,u) = \<^Const_fn>\Arith.mult for t u => \(t, u)\\ tm + in dest_prod t @ dest_prod u end + handle TERM _ => [tm]; (*Dummy version: the only arguments are 0 and 1*) fun mk_coeff (0, t) = zero @@ -168,7 +165,7 @@ open CancelNumeralsCommon val prove_conv = prove_conv "natless_cancel_numerals" fun mk_bal (t, u) = \<^Const>\Ordinal.lt for t u\ - val dest_bal = FOLogic.dest_bin \<^const_name>\Ordinal.lt\ iT + val dest_bal = \<^Const_fn>\Ordinal.lt for t u => \(t, u)\\ val bal_add1 = @{thm less_add_iff [THEN iff_trans]} val bal_add2 = @{thm less_add_iff [THEN iff_trans]} fun trans_tac ctxt = gen_trans_tac ctxt @{thm iff_trans} @@ -181,7 +178,7 @@ open CancelNumeralsCommon val prove_conv = prove_conv "natdiff_cancel_numerals" fun mk_bal (t, u) = \<^Const>\Arith.diff for t u\ - val dest_bal = FOLogic.dest_bin \<^const_name>\Arith.diff\ iT + val dest_bal = \<^Const_fn>\Arith.diff for t u => \(t, u)\\ val bal_add1 = @{thm diff_add_eq [THEN trans]} val bal_add2 = @{thm diff_add_eq [THEN trans]} fun trans_tac ctxt = gen_trans_tac ctxt @{thm trans} diff -r 3360ea6b659d -r 54b2e5f771da src/ZF/ind_syntax.ML --- a/src/ZF/ind_syntax.ML Sun Sep 19 21:35:51 2021 +0200 +++ b/src/ZF/ind_syntax.ML Sun Sep 19 21:37:14 2021 +0200 @@ -18,14 +18,12 @@ (** Abstract syntax definitions for ZF **) -val iT = \<^Type>\i\; - (*Creates All(%v.v:A --> P(v)) rather than Ball(A,P) *) fun mk_all_imp (A,P) = - FOLogic.all_const iT $ - Abs("v", iT, FOLogic.imp $ \<^Const>\mem for \Bound 0\ A\ $ Term.betapply(P, Bound 0)); + FOLogic.all_const \<^Type>\i\ $ + Abs("v", \<^Type>\i\, \<^Const>\imp\ $ \<^Const>\mem for \Bound 0\ A\ $ Term.betapply(P, Bound 0)); -fun mk_Collect (a, D, t) = \<^Const>\Collect for D\ $ absfree (a, iT) t; +fun mk_Collect (a, D, t) = \<^Const>\Collect for D\ $ absfree (a, \<^Type>\i\) t; (*simple error-checking in the premises of an inductive definition*) fun chk_prem rec_hd \<^Const_>\conj for _ _\ = @@ -64,10 +62,10 @@ (*read a constructor specification*) fun read_construct ctxt (id: string, sprems, syn: mixfix) = - let val prems = map (Syntax.parse_term ctxt #> Type.constraint FOLogic.oT) sprems + let val prems = map (Syntax.parse_term ctxt #> Type.constraint \<^Type>\o\) sprems |> Syntax.check_terms ctxt val args = map (#1 o dest_mem) prems - val T = (map (#2 o dest_Free) args) ---> iT + val T = (map (#2 o dest_Free) args) ---> \<^Type>\i\ handle TERM _ => error "Bad variable in constructor specification" in ((id,T,syn), id, args, prems) end; @@ -91,7 +89,7 @@ (*Make a datatype's domain: form the union of its set parameters*) fun union_params (rec_tm, cs) = let val (_,args) = strip_comb rec_tm - fun is_ind arg = (type_of arg = iT) + fun is_ind arg = (type_of arg = \<^Type>\i\) in case filter is_ind (args @ cs) of [] => \<^Const>\zero\ | u_args => Balanced_Tree.make mk_Un u_args diff -r 3360ea6b659d -r 54b2e5f771da src/ZF/int_arith.ML --- a/src/ZF/int_arith.ML Sun Sep 19 21:35:51 2021 +0200 +++ b/src/ZF/int_arith.ML Sun Sep 19 21:37:14 2021 +0200 @@ -82,12 +82,10 @@ | mk_prod (t :: ts) = if t = one then mk_prod ts else mk_times (t, mk_prod ts); -val dest_times = FOLogic.dest_bin \<^const_name>\zmult\ \<^typ>\i\; - -fun dest_prod t = - let val (t,u) = dest_times t - in dest_prod t @ dest_prod u end - handle TERM _ => [t]; +fun dest_prod tm = + let val (t,u) = \<^Const_fn>\zmult for t u => \(t, u)\\ tm + in dest_prod t @ dest_prod u end + handle TERM _ => [tm]; (*DON'T do the obvious simplifications; that would create special cases*) fun mk_coeff (k, t) = mk_times (mk_numeral k, t); @@ -192,7 +190,7 @@ (open CancelNumeralsCommon val prove_conv = ArithData.prove_conv "intless_cancel_numerals" fun mk_bal (t, u) = \<^Const>\zless for t u\ - val dest_bal = FOLogic.dest_bin \<^const_name>\zless\ \<^typ>\i\ + val dest_bal = \<^Const_fn>\zless for t u => \(t, u)\\ val bal_add1 = @{thm less_add_iff1} RS @{thm iff_trans} val bal_add2 = @{thm less_add_iff2} RS @{thm iff_trans} ); @@ -201,7 +199,7 @@ (open CancelNumeralsCommon val prove_conv = ArithData.prove_conv "intle_cancel_numerals" fun mk_bal (t, u) = \<^Const>\zle for t u\ - val dest_bal = FOLogic.dest_bin \<^const_name>\zle\ \<^typ>\i\ + val dest_bal = \<^Const_fn>\zle for t u => \(t, u)\\ val bal_add1 = @{thm le_add_iff1} RS @{thm iff_trans} val bal_add2 = @{thm le_add_iff2} RS @{thm iff_trans} );