author paulson Thu Sep 26 10:51:58 2002 +0200 (2002-09-26) changeset 13586 0f339348df0e parent 13585 db4005b40cc6 child 13587 659813a3f879
new theory for Pi-sets, restrict, etc.
```     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/src/HOL/Library/FuncSet.thy	Thu Sep 26 10:51:58 2002 +0200
1.3 @@ -0,0 +1,177 @@
1.4 +(*  Title:      HOL/Library/FuncSet.thy
1.5 +    ID:         \$Id\$
1.6 +    Author:     Florian Kammueller and Lawrence C Paulson
1.7 +*)
1.8 +
1.10 +  \title{Pi and Function Sets}
1.11 +  \author{Florian Kammueller and Lawrence C Paulson}
1.12 +*}
1.13 +
1.14 +theory FuncSet = Main:
1.15 +
1.16 +constdefs
1.17 +  Pi      :: "['a set, 'a => 'b set] => ('a => 'b) set"
1.18 +    "Pi A B == {f. \<forall>x. x \<in> A --> f(x) \<in> B(x)}"
1.19 +
1.20 +  extensional :: "'a set => ('a => 'b) set"
1.21 +    "extensional A == {f. \<forall>x. x~:A --> f(x) = arbitrary}"
1.22 +
1.23 +  restrict :: "['a => 'b, 'a set] => ('a => 'b)"
1.24 +    "restrict f A == (%x. if x \<in> A then f x else arbitrary)"
1.25 +
1.26 +syntax
1.27 +  "@Pi"  :: "[pttrn, 'a set, 'b set] => ('a => 'b) set"  ("(3PI _:_./ _)" 10)
1.28 +  funcset :: "['a set, 'b set] => ('a => 'b) set"      (infixr "->" 60)
1.29 +  "@lam" :: "[pttrn, 'a set, 'a => 'b] => ('a=>'b)"  ("(3%_:_./ _)" [0,0,3] 3)
1.30 +
1.31 +syntax (xsymbols)
1.32 +  "@Pi" :: "[pttrn, 'a set, 'b set] => ('a => 'b) set"  ("(3\<Pi> _\<in>_./ _)"   10)
1.33 +  funcset :: "['a set, 'b set] => ('a => 'b) set"  (infixr "\<rightarrow>" 60)
1.34 +  "@lam" :: "[pttrn, 'a set, 'a => 'b] => ('a=>'b)"  ("(3\<lambda>_\<in>_./ _)" [0,0,3] 3)
1.35 +
1.36 +translations
1.37 +  "PI x:A. B" => "Pi A (%x. B)"
1.38 +  "A -> B"    => "Pi A (_K B)"
1.39 +  "%x:A. f"  == "restrict (%x. f) A"
1.40 +
1.41 +constdefs
1.42 +  compose :: "['a set, 'b => 'c, 'a => 'b] => ('a => 'c)"
1.43 +  "compose A g f == \<lambda>x\<in>A. g (f x)"
1.44 +
1.45 +
1.46 +
1.47 +subsection{*Basic Properties of @{term Pi}*}
1.48 +
1.49 +lemma Pi_I: "(!!x. x \<in> A ==> f x \<in> B x) ==> f \<in> Pi A B"
1.51 +
1.52 +lemma funcsetI: "(!!x. x \<in> A ==> f x \<in> B) ==> f \<in> A -> B"
1.54 +
1.55 +lemma Pi_mem: "[|f: Pi A B; x \<in> A|] ==> f x \<in> B x"
1.57 +done
1.58 +
1.59 +lemma funcset_mem: "[|f \<in> A -> B; x \<in> A|] ==> f x \<in> B"
1.61 +
1.62 +lemma Pi_eq_empty: "((PI x: A. B x) = {}) = (\<exists>x\<in>A. B(x) = {})"
1.64 +apply auto
1.65 +txt{*Converse direction requires Axiom of Choice to exhibit a function
1.66 +picking an element from each non-empty @{term "B x"}*}
1.67 +apply (drule_tac x = "%u. SOME y. y \<in> B u" in spec)
1.68 +apply (auto );
1.69 +apply (cut_tac P= "%y. y \<in> B x" in some_eq_ex)
1.70 +apply (auto );
1.71 +done
1.72 +
1.73 +lemma Pi_empty: "Pi {} B = UNIV"
1.75 +done
1.76 +
1.77 +text{*Covariance of Pi-sets in their second argument*}
1.78 +lemma Pi_mono: "(!!x. x \<in> A ==> B x <= C x) ==> Pi A B <= Pi A C"
1.79 +by (simp add: Pi_def, blast)
1.80 +
1.81 +text{*Contravariance of Pi-sets in their first argument*}
1.82 +lemma Pi_anti_mono: "A' <= A ==> Pi A B <= Pi A' B"
1.83 +by (simp add: Pi_def, blast)
1.84 +
1.85 +
1.86 +subsection{*Composition With a Restricted Domain: @{term compose}*}
1.87 +
1.88 +lemma funcset_compose:
1.89 +     "[| f \<in> A -> B; g \<in> B -> C |]==> compose A g f \<in> A -> C"
1.90 +by (simp add: Pi_def compose_def restrict_def)
1.91 +
1.92 +lemma compose_assoc:
1.93 +     "[| f \<in> A -> B; g \<in> B -> C; h \<in> C -> D |]
1.94 +      ==> compose A h (compose A g f) = compose A (compose B h g) f"
1.95 +by (simp add: expand_fun_eq Pi_def compose_def restrict_def)
1.96 +
1.97 +lemma compose_eq: "x \<in> A ==> compose A g f x = g(f(x))"
1.98 +apply (simp add: compose_def restrict_def)
1.99 +done
1.100 +
1.101 +lemma surj_compose: "[| f ` A = B; g ` B = C |] ==> compose A g f ` A = C"
1.102 +apply (auto simp add: image_def compose_eq)
1.103 +done
1.104 +
1.105 +lemma inj_on_compose:
1.106 +     "[| f ` A = B; inj_on f A; inj_on g B |] ==> inj_on (compose A g f) A"
1.107 +by (auto simp add: inj_on_def compose_eq)
1.108 +
1.109 +
1.110 +subsection{*Bounded Abstraction: @{term restrict}*}
1.111 +
1.112 +lemma restrict_in_funcset: "(!!x. x \<in> A ==> f x \<in> B) ==> (\<lambda>x\<in>A. f x) \<in> A -> B"
1.113 +by (simp add: Pi_def restrict_def)
1.114 +
1.115 +
1.116 +lemma restrictI: "(!!x. x \<in> A ==> f x \<in> B x) ==> (\<lambda>x\<in>A. f x) \<in> Pi A B"
1.117 +by (simp add: Pi_def restrict_def)
1.118 +
1.119 +lemma restrict_apply [simp]:
1.120 +     "(\<lambda>y\<in>A. f y) x = (if x \<in> A then f x else arbitrary)"
1.122 +
1.123 +lemma restrict_ext:
1.124 +    "(!!x. x \<in> A ==> f x = g x) ==> (\<lambda>x\<in>A. f x) = (\<lambda>x\<in>A. g x)"
1.125 +by (simp add: expand_fun_eq Pi_def Pi_def restrict_def)
1.126 +
1.127 +lemma inj_on_restrict_eq: "inj_on (restrict f A) A = inj_on f A"
1.128 +apply (simp add: inj_on_def restrict_def)
1.129 +done
1.130 +
1.131 +
1.132 +lemma Id_compose:
1.133 +     "[|f \<in> A -> B;  f \<in> extensional A|] ==> compose A (\<lambda>y\<in>B. y) f = f"
1.134 +by (auto simp add: expand_fun_eq compose_def extensional_def Pi_def)
1.135 +
1.136 +lemma compose_Id:
1.137 +     "[|g \<in> A -> B;  g \<in> extensional A|] ==> compose A g (\<lambda>x\<in>A. x) = g"
1.138 +by (auto simp add: expand_fun_eq compose_def extensional_def Pi_def)
1.139 +
1.140 +
1.141 +subsection{*Extensionality*}
1.142 +
1.143 +lemma extensional_arb: "[|f \<in> extensional A; x\<notin> A|] ==> f x = arbitrary"
1.145 +done
1.146 +
1.147 +lemma restrict_extensional [simp]: "restrict f A \<in> extensional A"
1.148 +by (simp add: restrict_def extensional_def)
1.149 +
1.150 +lemma compose_extensional [simp]: "compose A f g \<in> extensional A"
1.152 +
1.153 +lemma extensionalityI:
1.154 +     "[| f \<in> extensional A; g \<in> extensional A;
1.155 +         !!x. x\<in>A ==> f x = g x |] ==> f = g"
1.156 +by (force simp add: expand_fun_eq extensional_def)
1.157 +
1.158 +lemma Inv_funcset: "f ` A = B ==> (\<lambda>x\<in>B. Inv A f x) : B -> A"
1.159 +apply (unfold Inv_def)
1.160 +apply (fast intro: restrict_in_funcset someI2)
1.161 +done
1.162 +
1.163 +lemma compose_Inv_id:
1.164 +     "[| inj_on f A;  f ` A = B |]
1.165 +      ==> compose A (\<lambda>y\<in>B. Inv A f y) f = (\<lambda>x\<in>A. x)"
1.167 +apply (rule restrict_ext)
1.168 +apply auto
1.169 +apply (erule subst)