# HG changeset patch # User paulson # Date 909834154 -3600 # Node ID 7559f116cb100ca0271316782bb0b5fc75ca5f1d # Parent d37380544c398428a2f4ad8e4f22f017fc99ee41 locales now implicitly quantify over free variables diff -r d37380544c39 -r 7559f116cb10 src/HOL/Finite.ML --- a/src/HOL/Finite.ML Fri Oct 30 15:59:51 1998 +0100 +++ b/src/HOL/Finite.ML Sat Oct 31 12:42:34 1998 +0100 @@ -591,8 +591,7 @@ Open_locale "LC"; -(*Strip meta-quantifiers: perhaps the locale should do this?*) -val f_lcomm = forall_elim_vars 0 (thm "lcomm"); +val f_lcomm = thm "lcomm"; Goal "ALL A x. card(A) < n --> (A, x) : foldSet f e --> \ @@ -680,10 +679,9 @@ Open_locale "ACe"; -(*Strip meta-quantifiers: perhaps the locale should do this?*) -val f_ident = forall_elim_vars 0 (thm "ident"); -val f_commute = forall_elim_vars 0 (thm "commute"); -val f_assoc = forall_elim_vars 0 (thm "assoc"); +val f_ident = thm "ident"; +val f_commute = thm "commute"; +val f_assoc = thm "assoc"; Goal "f x (f y z) = f y (f x z)"; diff -r d37380544c39 -r 7559f116cb10 src/HOL/Finite.thy --- a/src/HOL/Finite.thy Fri Oct 30 15:59:51 1998 +0100 +++ b/src/HOL/Finite.thy Sat Oct 31 12:42:34 1998 +0100 @@ -62,7 +62,7 @@ fixes f :: ['b,'a] => 'a assumes - lcomm "!! x y z. f x (f y z) = f y (f x z)" + lcomm "f x (f y z) = f y (f x z)" defines (*nothing*) @@ -71,9 +71,9 @@ f :: ['a,'a] => 'a e :: 'a assumes - ident "!! x. f x e = x" - commute "!! x y. f x y = f y x" - assoc "!! x y z. f (f x y) z = f x (f y z)" + ident "f x e = x" + commute "f x y = f y x" + assoc "f (f x y) z = f x (f y z)" defines end diff -r d37380544c39 -r 7559f116cb10 src/HOL/UNITY/Token.ML --- a/src/HOL/UNITY/Token.ML Fri Oct 30 15:59:51 1998 +0100 +++ b/src/HOL/UNITY/Token.ML Sat Oct 31 12:42:34 1998 +0100 @@ -22,15 +22,14 @@ Open_locale "Token"; -(*Strip meta-quantifiers: perhaps the locale should do this?*) -val TR2 = forall_elim_vars 0 (thm "TR2"); -val TR3 = forall_elim_vars 0 (thm "TR3"); -val TR4 = forall_elim_vars 0 (thm "TR4"); -val TR5 = forall_elim_vars 0 (thm "TR5"); -val TR6 = forall_elim_vars 0 (thm "TR6"); -val TR7 = forall_elim_vars 0 (thm "TR7"); -val nodeOrder_def = (thm "nodeOrder_def"); -val next_def = (thm "next_def"); +val TR2 = thm "TR2"; +val TR3 = thm "TR3"; +val TR4 = thm "TR4"; +val TR5 = thm "TR5"; +val TR6 = thm "TR6"; +val TR7 = thm "TR7"; +val nodeOrder_def = thm "nodeOrder_def"; +val next_def = thm "next_def"; AddIffs [thm "N_positive"]; diff -r d37380544c39 -r 7559f116cb10 src/HOL/UNITY/Token.thy --- a/src/HOL/UNITY/Token.thy Fri Oct 30 15:59:51 1998 +0100 +++ b/src/HOL/UNITY/Token.thy Sat Oct 31 12:42:34 1998 +0100 @@ -43,17 +43,17 @@ assumes N_positive "0 s) diffl; + val defaults' = (#1 defaults, filter (fn x => not((fst x) mem diffl')) (#2 defaults), #3 defaults) + in (defaults', (s, foldl abs_o (term, diffl))) end; (* assume a definition, i.e assume the cterm of a definiton term and then eliminate the binding !!, so that the def can be applied as rewrite. The meta hyp will still contain !! *) -fun prep_def clist sg = forall_elim_vars(0) o assume o (cterm_of sg); +fun prep_hyps clist sg = forall_elim_vars(0) o Thm.assume o (Thm.cterm_of sg); (* concrete syntax *) @@ -379,9 +385,11 @@ val new_loc_consts = (map #1 loc_consts); val all_loc_consts = old_loc_consts @ new_loc_consts; - val loc_defs_terms = map (apsnd (abs_over_free (all_loc_consts))) loc_defs; - val loc_defs_thms = map (apsnd (prep_def (map #1 loc_consts) syntax_sign)) loc_defs_terms; - val loc_thms = (map (apsnd (Thm.assume o Thm.cterm_of syntax_sign)) (loc_rules)) @ loc_defs_thms; + val (defaults, loc_defs_terms) = foldl_map (abs_over_free all_loc_consts) (defaults, loc_defs); + val loc_defs_thms = map (apsnd (prep_hyps (map #1 loc_consts) syntax_sign)) loc_defs_terms; + val (defaults, loc_thms_terms) = foldl_map (abs_over_free all_loc_consts) (defaults, loc_rules); + val loc_thms = (map (apsnd (prep_hyps (map #1 loc_consts) syntax_sign)) (loc_thms_terms)) + @ loc_defs_thms; (* error messages *) (* FIXME improve *) @@ -390,7 +398,7 @@ if is_none (get_locale thy name) then [] else ["Duplicate definition of locale " ^ quote name]; - (* check if definientes are local constants (in the same locale, so no redefining!) *) + (* check if definientes are locale constants (in the same locale, so no redefining!) *) val err_def_head = let fun peal_appl t = case t of @@ -405,14 +413,27 @@ else ["defined item not declared fixed in locale " ^ quote name] end; - val errs = err_dup_locale @ err_def_head; + (* check that variables on rhs of definitions are either fixed or on lhs *) + val err_var_rhs = + let fun compare_var_sides (t, (_, Const ("==", _) $ d1 $ d2)) = + let val varl1 = difflist d1 all_loc_consts; + val varl2 = difflist d2 all_loc_consts + in t andalso (varl2 subset varl1) + end + | compare_var_sides (_,_) = error ("an illegal definition"); + val check = foldl compare_var_sides (true, loc_defs) + in if check then [] + else ["nonfixed variable on right hand side of a locale definition in locale" ^ quote name] + end; + + val errs = err_dup_locale @ err_def_head @ err_var_rhs; in if null errs then () else error (cat_lines errs); syntax_thy |> put_locale (name, - make_locale loc_consts nosyn loc_rules loc_defs_terms + make_locale loc_consts nosyn loc_thms_terms loc_defs_terms loc_thms defaults) end;