# HG changeset patch # User hoelzl # Date 1452509795 -3600 # Node ID df65f5c27c1513ca89a42a62671e5e7ae487dfae # Parent eed7ca453573b773e83997e59e62d987952623bc setup code generation for filters as suggested by Florian diff -r eed7ca453573 -r df65f5c27c15 src/HOL/Filter.thy --- a/src/HOL/Filter.thy Mon Jan 11 07:44:20 2016 +0100 +++ b/src/HOL/Filter.thy Mon Jan 11 11:56:35 2016 +0100 @@ -26,11 +26,6 @@ show "(\x. True) \ ?filter" by (auto intro: is_filter.intro) qed -text \Kill code generation for filters\ - -code_datatype Abs_filter -declare [[code abort: Rep_filter]] - lemma is_filter_Rep_filter: "is_filter (Rep_filter F)" using Rep_filter [of F] by simp @@ -1222,4 +1217,52 @@ end +text \Code generation for filters\ + +definition abstract_filter :: "(unit \ 'a filter) \ 'a filter" + where [simp]: "abstract_filter f = f ()" + +code_datatype principal abstract_filter + +hide_const (open) abstract_filter + +declare [[code drop: filterlim prod_filter filtermap eventually + "inf :: _ filter \ _" "sup :: _ filter \ _" "less_eq :: _ filter \ _" + Abs_filter]] + +declare filterlim_principal [code] +declare principal_prod_principal [code] +declare filtermap_principal [code] +declare eventually_principal [code] +declare inf_principal [code] +declare sup_principal [code] +declare principal_le_iff [code] + +lemma Rep_filter_iff_eventually [simp, code]: + "Rep_filter F P \ eventually P F" + by (simp add: eventually_def) + +lemma bot_eq_principal_empty [code]: + "bot = principal {}" + by simp + +lemma top_eq_principal_UNIV [code]: + "top = principal UNIV" + by simp + +instantiation filter :: (equal) equal +begin + +definition equal_filter :: "'a filter \ 'a filter \ bool" + where "equal_filter F F' \ F = F'" + +lemma equal_filter [code]: + "HOL.equal (principal A) (principal B) \ A = B" + by (simp add: equal_filter_def) + +instance + by standard (simp add: equal_filter_def) + end + +end diff -r eed7ca453573 -r df65f5c27c15 src/HOL/Topological_Spaces.thy --- a/src/HOL/Topological_Spaces.thy Mon Jan 11 07:44:20 2016 +0100 +++ b/src/HOL/Topological_Spaces.thy Mon Jan 11 11:56:35 2016 +0100 @@ -2444,8 +2444,9 @@ end lemma uniformity_Abort: - "uniformity = Abs_filter (\P. Code.abort (STR ''uniformity is not executable'') (\x. Rep_filter uniformity P))" - unfolding Code.abort_def Rep_filter_inverse .. + "uniformity = + Filter.abstract_filter (\u. Code.abort (STR ''uniformity is not executable'') (\u. uniformity))" + by simp class open_uniformity = "open" + uniformity + assumes open_uniformity: "\U. open U \ (\x\U. eventually (\(x', y). x' = x \ y \ U) uniformity)"