3 *) |
3 *) |
4 |
4 |
5 section \<open>Pi and Function Sets\<close> |
5 section \<open>Pi and Function Sets\<close> |
6 |
6 |
7 theory FuncSet |
7 theory FuncSet |
8 imports Hilbert_Choice Main |
8 imports Hilbert_Choice Main |
|
9 abbrevs PiE = "Pi\<^sub>E" |
|
10 PIE = "\<Pi>\<^sub>E" |
9 begin |
11 begin |
10 |
12 |
11 definition Pi :: "'a set \<Rightarrow> ('a \<Rightarrow> 'b set) \<Rightarrow> ('a \<Rightarrow> 'b) set" |
13 definition Pi :: "'a set \<Rightarrow> ('a \<Rightarrow> 'b set) \<Rightarrow> ('a \<Rightarrow> 'b) set" |
12 where "Pi A B = {f. \<forall>x. x \<in> A \<longrightarrow> f x \<in> B x}" |
14 where "Pi A B = {f. \<forall>x. x \<in> A \<longrightarrow> f x \<in> B x}" |
13 |
15 |
358 where "A \<rightarrow>\<^sub>E B \<equiv> (\<Pi>\<^sub>E i\<in>A. B)" |
360 where "A \<rightarrow>\<^sub>E B \<equiv> (\<Pi>\<^sub>E i\<in>A. B)" |
359 |
361 |
360 lemma extensional_funcset_def: "extensional_funcset S T = (S \<rightarrow> T) \<inter> extensional S" |
362 lemma extensional_funcset_def: "extensional_funcset S T = (S \<rightarrow> T) \<inter> extensional S" |
361 by (simp add: PiE_def) |
363 by (simp add: PiE_def) |
362 |
364 |
363 lemma PiE_empty_domain[simp]: "PiE {} T = {\<lambda>x. undefined}" |
365 lemma PiE_empty_domain[simp]: "Pi\<^sub>E {} T = {\<lambda>x. undefined}" |
364 unfolding PiE_def by simp |
366 unfolding PiE_def by simp |
365 |
367 |
366 lemma PiE_UNIV_domain: "PiE UNIV T = Pi UNIV T" |
368 lemma PiE_UNIV_domain: "Pi\<^sub>E UNIV T = Pi UNIV T" |
367 unfolding PiE_def by simp |
369 unfolding PiE_def by simp |
368 |
370 |
369 lemma PiE_empty_range[simp]: "i \<in> I \<Longrightarrow> F i = {} \<Longrightarrow> (\<Pi>\<^sub>E i\<in>I. F i) = {}" |
371 lemma PiE_empty_range[simp]: "i \<in> I \<Longrightarrow> F i = {} \<Longrightarrow> (\<Pi>\<^sub>E i\<in>I. F i) = {}" |
370 unfolding PiE_def by auto |
372 unfolding PiE_def by auto |
371 |
373 |
384 with \<open>Pi\<^sub>E I F = {}\<close> show False |
386 with \<open>Pi\<^sub>E I F = {}\<close> show False |
385 by auto |
387 by auto |
386 qed |
388 qed |
387 qed (auto simp: PiE_def) |
389 qed (auto simp: PiE_def) |
388 |
390 |
389 lemma PiE_arb: "f \<in> PiE S T \<Longrightarrow> x \<notin> S \<Longrightarrow> f x = undefined" |
391 lemma PiE_arb: "f \<in> Pi\<^sub>E S T \<Longrightarrow> x \<notin> S \<Longrightarrow> f x = undefined" |
390 unfolding PiE_def by auto (auto dest!: extensional_arb) |
392 unfolding PiE_def by auto (auto dest!: extensional_arb) |
391 |
393 |
392 lemma PiE_mem: "f \<in> PiE S T \<Longrightarrow> x \<in> S \<Longrightarrow> f x \<in> T x" |
394 lemma PiE_mem: "f \<in> Pi\<^sub>E S T \<Longrightarrow> x \<in> S \<Longrightarrow> f x \<in> T x" |
393 unfolding PiE_def by auto |
395 unfolding PiE_def by auto |
394 |
396 |
395 lemma PiE_fun_upd: "y \<in> T x \<Longrightarrow> f \<in> PiE S T \<Longrightarrow> f(x := y) \<in> PiE (insert x S) T" |
397 lemma PiE_fun_upd: "y \<in> T x \<Longrightarrow> f \<in> Pi\<^sub>E S T \<Longrightarrow> f(x := y) \<in> Pi\<^sub>E (insert x S) T" |
396 unfolding PiE_def extensional_def by auto |
398 unfolding PiE_def extensional_def by auto |
397 |
399 |
398 lemma fun_upd_in_PiE: "x \<notin> S \<Longrightarrow> f \<in> PiE (insert x S) T \<Longrightarrow> f(x := undefined) \<in> PiE S T" |
400 lemma fun_upd_in_PiE: "x \<notin> S \<Longrightarrow> f \<in> Pi\<^sub>E (insert x S) T \<Longrightarrow> f(x := undefined) \<in> Pi\<^sub>E S T" |
399 unfolding PiE_def extensional_def by auto |
401 unfolding PiE_def extensional_def by auto |
400 |
402 |
401 lemma PiE_insert_eq: "PiE (insert x S) T = (\<lambda>(y, g). g(x := y)) ` (T x \<times> PiE S T)" |
403 lemma PiE_insert_eq: "Pi\<^sub>E (insert x S) T = (\<lambda>(y, g). g(x := y)) ` (T x \<times> Pi\<^sub>E S T)" |
402 proof - |
404 proof - |
403 { |
405 { |
404 fix f assume "f \<in> PiE (insert x S) T" "x \<notin> S" |
406 fix f assume "f \<in> Pi\<^sub>E (insert x S) T" "x \<notin> S" |
405 then have "f \<in> (\<lambda>(y, g). g(x := y)) ` (T x \<times> PiE S T)" |
407 then have "f \<in> (\<lambda>(y, g). g(x := y)) ` (T x \<times> Pi\<^sub>E S T)" |
406 by (auto intro!: image_eqI[where x="(f x, f(x := undefined))"] intro: fun_upd_in_PiE PiE_mem) |
408 by (auto intro!: image_eqI[where x="(f x, f(x := undefined))"] intro: fun_upd_in_PiE PiE_mem) |
407 } |
409 } |
408 moreover |
410 moreover |
409 { |
411 { |
410 fix f assume "f \<in> PiE (insert x S) T" "x \<in> S" |
412 fix f assume "f \<in> Pi\<^sub>E (insert x S) T" "x \<in> S" |
411 then have "f \<in> (\<lambda>(y, g). g(x := y)) ` (T x \<times> PiE S T)" |
413 then have "f \<in> (\<lambda>(y, g). g(x := y)) ` (T x \<times> Pi\<^sub>E S T)" |
412 by (auto intro!: image_eqI[where x="(f x, f)"] intro: fun_upd_in_PiE PiE_mem simp: insert_absorb) |
414 by (auto intro!: image_eqI[where x="(f x, f)"] intro: fun_upd_in_PiE PiE_mem simp: insert_absorb) |
413 } |
415 } |
414 ultimately show ?thesis |
416 ultimately show ?thesis |
415 by (auto intro: PiE_fun_upd) |
417 by (auto intro: PiE_fun_upd) |
416 qed |
418 qed |
420 |
422 |
421 lemma PiE_cong: "(\<And>i. i\<in>I \<Longrightarrow> A i = B i) \<Longrightarrow> Pi\<^sub>E I A = Pi\<^sub>E I B" |
423 lemma PiE_cong: "(\<And>i. i\<in>I \<Longrightarrow> A i = B i) \<Longrightarrow> Pi\<^sub>E I A = Pi\<^sub>E I B" |
422 unfolding PiE_def by (auto simp: Pi_cong) |
424 unfolding PiE_def by (auto simp: Pi_cong) |
423 |
425 |
424 lemma PiE_E [elim]: |
426 lemma PiE_E [elim]: |
425 assumes "f \<in> PiE A B" |
427 assumes "f \<in> Pi\<^sub>E A B" |
426 obtains "x \<in> A" and "f x \<in> B x" |
428 obtains "x \<in> A" and "f x \<in> B x" |
427 | "x \<notin> A" and "f x = undefined" |
429 | "x \<notin> A" and "f x = undefined" |
428 using assms by (auto simp: Pi_def PiE_def extensional_def) |
430 using assms by (auto simp: Pi_def PiE_def extensional_def) |
429 |
431 |
430 lemma PiE_I[intro!]: |
432 lemma PiE_I[intro!]: |
431 "(\<And>x. x \<in> A \<Longrightarrow> f x \<in> B x) \<Longrightarrow> (\<And>x. x \<notin> A \<Longrightarrow> f x = undefined) \<Longrightarrow> f \<in> PiE A B" |
433 "(\<And>x. x \<in> A \<Longrightarrow> f x \<in> B x) \<Longrightarrow> (\<And>x. x \<notin> A \<Longrightarrow> f x = undefined) \<Longrightarrow> f \<in> Pi\<^sub>E A B" |
432 by (simp add: PiE_def extensional_def) |
434 by (simp add: PiE_def extensional_def) |
433 |
435 |
434 lemma PiE_mono: "(\<And>x. x \<in> A \<Longrightarrow> B x \<subseteq> C x) \<Longrightarrow> PiE A B \<subseteq> PiE A C" |
436 lemma PiE_mono: "(\<And>x. x \<in> A \<Longrightarrow> B x \<subseteq> C x) \<Longrightarrow> Pi\<^sub>E A B \<subseteq> Pi\<^sub>E A C" |
435 by auto |
437 by auto |
436 |
438 |
437 lemma PiE_iff: "f \<in> PiE I X \<longleftrightarrow> (\<forall>i\<in>I. f i \<in> X i) \<and> f \<in> extensional I" |
439 lemma PiE_iff: "f \<in> Pi\<^sub>E I X \<longleftrightarrow> (\<forall>i\<in>I. f i \<in> X i) \<and> f \<in> extensional I" |
438 by (simp add: PiE_def Pi_iff) |
440 by (simp add: PiE_def Pi_iff) |
439 |
441 |
440 lemma PiE_restrict[simp]: "f \<in> PiE A B \<Longrightarrow> restrict f A = f" |
442 lemma PiE_restrict[simp]: "f \<in> Pi\<^sub>E A B \<Longrightarrow> restrict f A = f" |
441 by (simp add: extensional_restrict PiE_def) |
443 by (simp add: extensional_restrict PiE_def) |
442 |
444 |
443 lemma restrict_PiE[simp]: "restrict f I \<in> PiE I S \<longleftrightarrow> f \<in> Pi I S" |
445 lemma restrict_PiE[simp]: "restrict f I \<in> Pi\<^sub>E I S \<longleftrightarrow> f \<in> Pi I S" |
444 by (auto simp: PiE_iff) |
446 by (auto simp: PiE_iff) |
445 |
447 |
446 lemma PiE_eq_subset: |
448 lemma PiE_eq_subset: |
447 assumes ne: "\<And>i. i \<in> I \<Longrightarrow> F i \<noteq> {}" "\<And>i. i \<in> I \<Longrightarrow> F' i \<noteq> {}" |
449 assumes ne: "\<And>i. i \<in> I \<Longrightarrow> F i \<noteq> {}" "\<And>i. i \<in> I \<Longrightarrow> F' i \<noteq> {}" |
448 and eq: "Pi\<^sub>E I F = Pi\<^sub>E I F'" |
450 and eq: "Pi\<^sub>E I F = Pi\<^sub>E I F'" |