506 hide (open) const swap |
506 hide (open) const swap |
507 |
507 |
508 |
508 |
509 subsection {* Inversion of injective functions *} |
509 subsection {* Inversion of injective functions *} |
510 |
510 |
511 definition the_inv_onto :: "'a set => ('a => 'b) => ('b => 'a)" where |
511 definition the_inv_into :: "'a set => ('a => 'b) => ('b => 'a)" where |
512 "the_inv_onto A f == %x. THE y. y : A & f y = x" |
512 "the_inv_into A f == %x. THE y. y : A & f y = x" |
513 |
513 |
514 lemma the_inv_onto_f_f: |
514 lemma the_inv_into_f_f: |
515 "[| inj_on f A; x : A |] ==> the_inv_onto A f (f x) = x" |
515 "[| inj_on f A; x : A |] ==> the_inv_into A f (f x) = x" |
516 apply (simp add: the_inv_onto_def inj_on_def) |
516 apply (simp add: the_inv_into_def inj_on_def) |
517 apply (blast intro: the_equality) |
517 apply (blast intro: the_equality) |
518 done |
518 done |
519 |
519 |
520 lemma f_the_inv_onto_f: |
520 lemma f_the_inv_into_f: |
521 "inj_on f A ==> y : f`A ==> f (the_inv_onto A f y) = y" |
521 "inj_on f A ==> y : f`A ==> f (the_inv_into A f y) = y" |
522 apply (simp add: the_inv_onto_def) |
522 apply (simp add: the_inv_into_def) |
523 apply (rule the1I2) |
523 apply (rule the1I2) |
524 apply(blast dest: inj_onD) |
524 apply(blast dest: inj_onD) |
525 apply blast |
525 apply blast |
526 done |
526 done |
527 |
527 |
528 lemma the_inv_onto_into: |
528 lemma the_inv_into_into: |
529 "[| inj_on f A; x : f ` A; A <= B |] ==> the_inv_onto A f x : B" |
529 "[| inj_on f A; x : f ` A; A <= B |] ==> the_inv_into A f x : B" |
530 apply (simp add: the_inv_onto_def) |
530 apply (simp add: the_inv_into_def) |
531 apply (rule the1I2) |
531 apply (rule the1I2) |
532 apply(blast dest: inj_onD) |
532 apply(blast dest: inj_onD) |
533 apply blast |
533 apply blast |
534 done |
534 done |
535 |
535 |
536 lemma the_inv_onto_onto[simp]: |
536 lemma the_inv_into_onto[simp]: |
537 "inj_on f A ==> the_inv_onto A f ` (f ` A) = A" |
537 "inj_on f A ==> the_inv_into A f ` (f ` A) = A" |
538 by (fast intro:the_inv_onto_into the_inv_onto_f_f[symmetric]) |
538 by (fast intro:the_inv_into_into the_inv_into_f_f[symmetric]) |
539 |
539 |
540 lemma the_inv_onto_f_eq: |
540 lemma the_inv_into_f_eq: |
541 "[| inj_on f A; f x = y; x : A |] ==> the_inv_onto A f y = x" |
541 "[| inj_on f A; f x = y; x : A |] ==> the_inv_into A f y = x" |
542 apply (erule subst) |
542 apply (erule subst) |
543 apply (erule the_inv_onto_f_f, assumption) |
543 apply (erule the_inv_into_f_f, assumption) |
544 done |
544 done |
545 |
545 |
546 lemma the_inv_onto_comp: |
546 lemma the_inv_into_comp: |
547 "[| inj_on f (g ` A); inj_on g A; x : f ` g ` A |] ==> |
547 "[| inj_on f (g ` A); inj_on g A; x : f ` g ` A |] ==> |
548 the_inv_onto A (f o g) x = (the_inv_onto A g o the_inv_onto (g ` A) f) x" |
548 the_inv_into A (f o g) x = (the_inv_into A g o the_inv_into (g ` A) f) x" |
549 apply (rule the_inv_onto_f_eq) |
549 apply (rule the_inv_into_f_eq) |
550 apply (fast intro: comp_inj_on) |
550 apply (fast intro: comp_inj_on) |
551 apply (simp add: f_the_inv_onto_f the_inv_onto_into) |
551 apply (simp add: f_the_inv_into_f the_inv_into_into) |
552 apply (simp add: the_inv_onto_into) |
552 apply (simp add: the_inv_into_into) |
553 done |
553 done |
554 |
554 |
555 lemma inj_on_the_inv_onto: |
555 lemma inj_on_the_inv_into: |
556 "inj_on f A \<Longrightarrow> inj_on (the_inv_onto A f) (f ` A)" |
556 "inj_on f A \<Longrightarrow> inj_on (the_inv_into A f) (f ` A)" |
557 by (auto intro: inj_onI simp: image_def the_inv_onto_f_f) |
557 by (auto intro: inj_onI simp: image_def the_inv_into_f_f) |
558 |
558 |
559 lemma bij_betw_the_inv_onto: |
559 lemma bij_betw_the_inv_into: |
560 "bij_betw f A B \<Longrightarrow> bij_betw (the_inv_onto A f) B A" |
560 "bij_betw f A B \<Longrightarrow> bij_betw (the_inv_into A f) B A" |
561 by (auto simp add: bij_betw_def inj_on_the_inv_onto the_inv_onto_into) |
561 by (auto simp add: bij_betw_def inj_on_the_inv_into the_inv_into_into) |
562 |
562 |
563 abbreviation the_inv :: "('a \<Rightarrow> 'b) \<Rightarrow> ('b \<Rightarrow> 'a)" where |
563 abbreviation the_inv :: "('a \<Rightarrow> 'b) \<Rightarrow> ('b \<Rightarrow> 'a)" where |
564 "the_inv f \<equiv> the_inv_onto UNIV f" |
564 "the_inv f \<equiv> the_inv_into UNIV f" |
565 |
565 |
566 lemma the_inv_f_f: |
566 lemma the_inv_f_f: |
567 assumes "inj f" |
567 assumes "inj f" |
568 shows "the_inv f (f x) = x" using assms UNIV_I |
568 shows "the_inv f (f x) = x" using assms UNIV_I |
569 by (rule the_inv_onto_f_f) |
569 by (rule the_inv_into_f_f) |
570 |
570 |
571 |
571 |
572 subsection {* Proof tool setup *} |
572 subsection {* Proof tool setup *} |
573 |
573 |
574 text {* simplifies terms of the form |
574 text {* simplifies terms of the form |