64551
|
1 |
(* Title: HOL/Types_To_Sets/Examples/Prerequisites.thy
|
|
2 |
Author: Ondřej Kunčar, TU München
|
|
3 |
*)
|
|
4 |
|
|
5 |
theory Prerequisites
|
|
6 |
imports Main
|
|
7 |
begin
|
|
8 |
|
|
9 |
context
|
|
10 |
fixes Rep Abs A T
|
|
11 |
assumes type: "type_definition Rep Abs A"
|
|
12 |
assumes T_def: "T \<equiv> (\<lambda>(x::'a) (y::'b). x = Rep y)"
|
|
13 |
begin
|
|
14 |
|
|
15 |
lemma type_definition_Domainp: "Domainp T = (\<lambda>x. x \<in> A)"
|
|
16 |
proof -
|
|
17 |
interpret type_definition Rep Abs A by(rule type)
|
|
18 |
show ?thesis
|
|
19 |
unfolding Domainp_iff[abs_def] T_def fun_eq_iff
|
|
20 |
by (metis Abs_inverse Rep)
|
|
21 |
qed
|
|
22 |
|
|
23 |
end
|
|
24 |
|
69295
|
25 |
subsection \<open>setting up transfer for local typedef\<close>
|
|
26 |
|
|
27 |
lemmas [transfer_rule] = \<comment> \<open>prefer right-total rules\<close>
|
|
28 |
right_total_All_transfer
|
|
29 |
right_total_UNIV_transfer
|
|
30 |
right_total_Ex_transfer
|
|
31 |
|
|
32 |
locale local_typedef = fixes S ::"'b set" and s::"'s itself"
|
|
33 |
assumes Ex_type_definition_S: "\<exists>(Rep::'s \<Rightarrow> 'b) (Abs::'b \<Rightarrow> 's). type_definition Rep Abs S"
|
|
34 |
begin
|
|
35 |
|
|
36 |
definition "rep = fst (SOME (Rep::'s \<Rightarrow> 'b, Abs). type_definition Rep Abs S)"
|
|
37 |
definition "Abs = snd (SOME (Rep::'s \<Rightarrow> 'b, Abs). type_definition Rep Abs S)"
|
|
38 |
|
|
39 |
lemma type_definition_S: "type_definition rep Abs S"
|
|
40 |
unfolding Abs_def rep_def split_beta'
|
|
41 |
by (rule someI_ex) (use Ex_type_definition_S in auto)
|
|
42 |
|
|
43 |
lemma rep_in_S[simp]: "rep x \<in> S"
|
|
44 |
and rep_inverse[simp]: "Abs (rep x) = x"
|
|
45 |
and Abs_inverse[simp]: "y \<in> S \<Longrightarrow> rep (Abs y) = y"
|
|
46 |
using type_definition_S
|
|
47 |
unfolding type_definition_def by auto
|
|
48 |
|
|
49 |
definition cr_S where "cr_S \<equiv> \<lambda>s b. s = rep b"
|
|
50 |
lemmas Domainp_cr_S = type_definition_Domainp[OF type_definition_S cr_S_def, transfer_domain_rule]
|
|
51 |
lemmas right_total_cr_S = typedef_right_total[OF type_definition_S cr_S_def, transfer_rule]
|
|
52 |
and bi_unique_cr_S = typedef_bi_unique[OF type_definition_S cr_S_def, transfer_rule]
|
|
53 |
and left_unique_cr_S = typedef_left_unique[OF type_definition_S cr_S_def, transfer_rule]
|
|
54 |
and right_unique_cr_S = typedef_right_unique[OF type_definition_S cr_S_def, transfer_rule]
|
|
55 |
|
|
56 |
lemma cr_S_rep[intro, simp]: "cr_S (rep a) a" by (simp add: cr_S_def)
|
|
57 |
lemma cr_S_Abs[intro, simp]: "a\<in>S \<Longrightarrow> cr_S a (Abs a)" by (simp add: cr_S_def)
|
|
58 |
|
64551
|
59 |
end
|
69295
|
60 |
|
|
61 |
end
|