author | Cezary Kaliszyk <kaliszyk@in.tum.de> |
Wed, 28 Oct 2009 16:05:59 +0100 | |
changeset 221 | f219011a5e3c |
parent 218 | df05cd030d2f |
child 254 | 77ff9624cfd6 |
permissions | -rw-r--r-- |
127
b054cf6bd179
the command "quotient" can now define more than one quotient at the same time; quotients need to be separated by and
Christian Urban <urbanc@in.tum.de>
parents:
82
diff
changeset
|
1 |
signature QUOTIENT = |
b054cf6bd179
the command "quotient" can now define more than one quotient at the same time; quotients need to be separated by and
Christian Urban <urbanc@in.tum.de>
parents:
82
diff
changeset
|
2 |
sig |
130
8e8ba210f0f7
moved the map-info and fun-info section to quotient.ML
Christian Urban <urbanc@in.tum.de>
parents:
128
diff
changeset
|
3 |
type maps_info = {mapfun: string, relfun: string} |
203
7384115df9fd
added equiv-thm to the quot_info
Christian Urban <urbanc@in.tum.de>
parents:
185
diff
changeset
|
4 |
type quotient_info = {qtyp: typ, rtyp: typ, rel: term, equiv_thm: thm} |
127
b054cf6bd179
the command "quotient" can now define more than one quotient at the same time; quotients need to be separated by and
Christian Urban <urbanc@in.tum.de>
parents:
82
diff
changeset
|
5 |
val mk_quotient_type: ((binding * mixfix) * (typ * term)) list -> Proof.context -> Proof.state |
b054cf6bd179
the command "quotient" can now define more than one quotient at the same time; quotients need to be separated by and
Christian Urban <urbanc@in.tum.de>
parents:
82
diff
changeset
|
6 |
val mk_quotient_type_cmd: (((bstring * mixfix) * string) * string) list -> Proof.context -> Proof.state |
128 | 7 |
val define: binding * mixfix * term -> local_theory -> (term * thm) * local_theory |
8 |
val note: binding * thm -> local_theory -> thm * local_theory |
|
130
8e8ba210f0f7
moved the map-info and fun-info section to quotient.ML
Christian Urban <urbanc@in.tum.de>
parents:
128
diff
changeset
|
9 |
val maps_lookup: theory -> string -> maps_info option |
185
929bc55efff7
added code for declaring map-functions
Christian Urban <urbanc@in.tum.de>
parents:
182
diff
changeset
|
10 |
val maps_update_thy: string -> maps_info -> theory -> theory |
929bc55efff7
added code for declaring map-functions
Christian Urban <urbanc@in.tum.de>
parents:
182
diff
changeset
|
11 |
val maps_update: string -> maps_info -> Proof.context -> Proof.context |
148
8e24e65f1e9b
tuned and attempted to store data about the quotients (does not work yet)
Christian Urban <urbanc@in.tum.de>
parents:
135
diff
changeset
|
12 |
val print_quotdata: Proof.context -> unit |
218
df05cd030d2f
added infrastructure for defining lifted constants
Christian Urban <urbanc@in.tum.de>
parents:
205
diff
changeset
|
13 |
val quotdata_lookup_thy: theory -> quotient_info list |
df05cd030d2f
added infrastructure for defining lifted constants
Christian Urban <urbanc@in.tum.de>
parents:
205
diff
changeset
|
14 |
val quotdata_lookup: Proof.context -> quotient_info list |
203
7384115df9fd
added equiv-thm to the quot_info
Christian Urban <urbanc@in.tum.de>
parents:
185
diff
changeset
|
15 |
val quotdata_update_thy: (typ * typ * term * thm) -> theory -> theory |
7384115df9fd
added equiv-thm to the quot_info
Christian Urban <urbanc@in.tum.de>
parents:
185
diff
changeset
|
16 |
val quotdata_update: (typ * typ * term * thm) -> Proof.context -> Proof.context |
127
b054cf6bd179
the command "quotient" can now define more than one quotient at the same time; quotients need to be separated by and
Christian Urban <urbanc@in.tum.de>
parents:
82
diff
changeset
|
17 |
end; |
71
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
18 |
|
127
b054cf6bd179
the command "quotient" can now define more than one quotient at the same time; quotients need to be separated by and
Christian Urban <urbanc@in.tum.de>
parents:
82
diff
changeset
|
19 |
structure Quotient: QUOTIENT = |
71
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
20 |
struct |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
21 |
|
130
8e8ba210f0f7
moved the map-info and fun-info section to quotient.ML
Christian Urban <urbanc@in.tum.de>
parents:
128
diff
changeset
|
22 |
(* data containers *) |
8e8ba210f0f7
moved the map-info and fun-info section to quotient.ML
Christian Urban <urbanc@in.tum.de>
parents:
128
diff
changeset
|
23 |
(*******************) |
8e8ba210f0f7
moved the map-info and fun-info section to quotient.ML
Christian Urban <urbanc@in.tum.de>
parents:
128
diff
changeset
|
24 |
|
135
6f0d14ba096c
started to write code for storing data about the quotients
Christian Urban <urbanc@in.tum.de>
parents:
130
diff
changeset
|
25 |
(* info about map- and rel-functions *) |
130
8e8ba210f0f7
moved the map-info and fun-info section to quotient.ML
Christian Urban <urbanc@in.tum.de>
parents:
128
diff
changeset
|
26 |
type maps_info = {mapfun: string, relfun: string} |
8e8ba210f0f7
moved the map-info and fun-info section to quotient.ML
Christian Urban <urbanc@in.tum.de>
parents:
128
diff
changeset
|
27 |
|
135
6f0d14ba096c
started to write code for storing data about the quotients
Christian Urban <urbanc@in.tum.de>
parents:
130
diff
changeset
|
28 |
structure MapsData = TheoryDataFun |
130
8e8ba210f0f7
moved the map-info and fun-info section to quotient.ML
Christian Urban <urbanc@in.tum.de>
parents:
128
diff
changeset
|
29 |
(type T = maps_info Symtab.table |
8e8ba210f0f7
moved the map-info and fun-info section to quotient.ML
Christian Urban <urbanc@in.tum.de>
parents:
128
diff
changeset
|
30 |
val empty = Symtab.empty |
8e8ba210f0f7
moved the map-info and fun-info section to quotient.ML
Christian Urban <urbanc@in.tum.de>
parents:
128
diff
changeset
|
31 |
val copy = I |
8e8ba210f0f7
moved the map-info and fun-info section to quotient.ML
Christian Urban <urbanc@in.tum.de>
parents:
128
diff
changeset
|
32 |
val extend = I |
8e8ba210f0f7
moved the map-info and fun-info section to quotient.ML
Christian Urban <urbanc@in.tum.de>
parents:
128
diff
changeset
|
33 |
fun merge _ = Symtab.merge (K true)) |
135
6f0d14ba096c
started to write code for storing data about the quotients
Christian Urban <urbanc@in.tum.de>
parents:
130
diff
changeset
|
34 |
|
6f0d14ba096c
started to write code for storing data about the quotients
Christian Urban <urbanc@in.tum.de>
parents:
130
diff
changeset
|
35 |
val maps_lookup = Symtab.lookup o MapsData.get |
185
929bc55efff7
added code for declaring map-functions
Christian Urban <urbanc@in.tum.de>
parents:
182
diff
changeset
|
36 |
fun maps_update_thy k minfo = MapsData.map (Symtab.update (k, minfo)) |
929bc55efff7
added code for declaring map-functions
Christian Urban <urbanc@in.tum.de>
parents:
182
diff
changeset
|
37 |
fun maps_update k minfo = ProofContext.theory (maps_update_thy k minfo) |
929bc55efff7
added code for declaring map-functions
Christian Urban <urbanc@in.tum.de>
parents:
182
diff
changeset
|
38 |
|
929bc55efff7
added code for declaring map-functions
Christian Urban <urbanc@in.tum.de>
parents:
182
diff
changeset
|
39 |
fun maps_attribute_aux s minfo = Thm.declaration_attribute |
929bc55efff7
added code for declaring map-functions
Christian Urban <urbanc@in.tum.de>
parents:
182
diff
changeset
|
40 |
(fn thm => Context.mapping (maps_update_thy s minfo) (maps_update s minfo)) |
929bc55efff7
added code for declaring map-functions
Christian Urban <urbanc@in.tum.de>
parents:
182
diff
changeset
|
41 |
|
929bc55efff7
added code for declaring map-functions
Christian Urban <urbanc@in.tum.de>
parents:
182
diff
changeset
|
42 |
(* attribute to be used in declare statements *) |
929bc55efff7
added code for declaring map-functions
Christian Urban <urbanc@in.tum.de>
parents:
182
diff
changeset
|
43 |
fun maps_attribute (ctxt, (tystr, (mapstr, relstr))) = |
929bc55efff7
added code for declaring map-functions
Christian Urban <urbanc@in.tum.de>
parents:
182
diff
changeset
|
44 |
let |
929bc55efff7
added code for declaring map-functions
Christian Urban <urbanc@in.tum.de>
parents:
182
diff
changeset
|
45 |
val thy = ProofContext.theory_of ctxt |
929bc55efff7
added code for declaring map-functions
Christian Urban <urbanc@in.tum.de>
parents:
182
diff
changeset
|
46 |
val tyname = Sign.intern_type thy tystr |
929bc55efff7
added code for declaring map-functions
Christian Urban <urbanc@in.tum.de>
parents:
182
diff
changeset
|
47 |
val mapname = Sign.intern_const thy mapstr |
929bc55efff7
added code for declaring map-functions
Christian Urban <urbanc@in.tum.de>
parents:
182
diff
changeset
|
48 |
val relname = Sign.intern_const thy relstr |
929bc55efff7
added code for declaring map-functions
Christian Urban <urbanc@in.tum.de>
parents:
182
diff
changeset
|
49 |
in |
929bc55efff7
added code for declaring map-functions
Christian Urban <urbanc@in.tum.de>
parents:
182
diff
changeset
|
50 |
maps_attribute_aux tyname {mapfun = mapname, relfun = relname} |
929bc55efff7
added code for declaring map-functions
Christian Urban <urbanc@in.tum.de>
parents:
182
diff
changeset
|
51 |
end |
929bc55efff7
added code for declaring map-functions
Christian Urban <urbanc@in.tum.de>
parents:
182
diff
changeset
|
52 |
|
929bc55efff7
added code for declaring map-functions
Christian Urban <urbanc@in.tum.de>
parents:
182
diff
changeset
|
53 |
val maps_attr_parser = |
929bc55efff7
added code for declaring map-functions
Christian Urban <urbanc@in.tum.de>
parents:
182
diff
changeset
|
54 |
Args.context -- Scan.lift |
929bc55efff7
added code for declaring map-functions
Christian Urban <urbanc@in.tum.de>
parents:
182
diff
changeset
|
55 |
((Args.name --| OuterParse.$$$ "=") -- |
929bc55efff7
added code for declaring map-functions
Christian Urban <urbanc@in.tum.de>
parents:
182
diff
changeset
|
56 |
(OuterParse.$$$ "(" |-- Args.name --| OuterParse.$$$ "," -- |
929bc55efff7
added code for declaring map-functions
Christian Urban <urbanc@in.tum.de>
parents:
182
diff
changeset
|
57 |
Args.name --| OuterParse.$$$ ")")) |
929bc55efff7
added code for declaring map-functions
Christian Urban <urbanc@in.tum.de>
parents:
182
diff
changeset
|
58 |
|
929bc55efff7
added code for declaring map-functions
Christian Urban <urbanc@in.tum.de>
parents:
182
diff
changeset
|
59 |
val _ = Context.>> (Context.map_theory |
929bc55efff7
added code for declaring map-functions
Christian Urban <urbanc@in.tum.de>
parents:
182
diff
changeset
|
60 |
(Attrib.setup @{binding "map"} (maps_attr_parser >> maps_attribute) |
929bc55efff7
added code for declaring map-functions
Christian Urban <urbanc@in.tum.de>
parents:
182
diff
changeset
|
61 |
"declaration of map information")) |
135
6f0d14ba096c
started to write code for storing data about the quotients
Christian Urban <urbanc@in.tum.de>
parents:
130
diff
changeset
|
62 |
|
6f0d14ba096c
started to write code for storing data about the quotients
Christian Urban <urbanc@in.tum.de>
parents:
130
diff
changeset
|
63 |
|
6f0d14ba096c
started to write code for storing data about the quotients
Christian Urban <urbanc@in.tum.de>
parents:
130
diff
changeset
|
64 |
(* info about the quotient types *) |
203
7384115df9fd
added equiv-thm to the quot_info
Christian Urban <urbanc@in.tum.de>
parents:
185
diff
changeset
|
65 |
type quotient_info = {qtyp: typ, rtyp: typ, rel: term, equiv_thm: thm} |
135
6f0d14ba096c
started to write code for storing data about the quotients
Christian Urban <urbanc@in.tum.de>
parents:
130
diff
changeset
|
66 |
|
6f0d14ba096c
started to write code for storing data about the quotients
Christian Urban <urbanc@in.tum.de>
parents:
130
diff
changeset
|
67 |
structure QuotData = TheoryDataFun |
6f0d14ba096c
started to write code for storing data about the quotients
Christian Urban <urbanc@in.tum.de>
parents:
130
diff
changeset
|
68 |
(type T = quotient_info list |
6f0d14ba096c
started to write code for storing data about the quotients
Christian Urban <urbanc@in.tum.de>
parents:
130
diff
changeset
|
69 |
val empty = [] |
6f0d14ba096c
started to write code for storing data about the quotients
Christian Urban <urbanc@in.tum.de>
parents:
130
diff
changeset
|
70 |
val copy = I |
6f0d14ba096c
started to write code for storing data about the quotients
Christian Urban <urbanc@in.tum.de>
parents:
130
diff
changeset
|
71 |
val extend = I |
185
929bc55efff7
added code for declaring map-functions
Christian Urban <urbanc@in.tum.de>
parents:
182
diff
changeset
|
72 |
fun merge _ = (op @)) (* FIXME: is this the correct merging function for the list? *) |
135
6f0d14ba096c
started to write code for storing data about the quotients
Christian Urban <urbanc@in.tum.de>
parents:
130
diff
changeset
|
73 |
|
218
df05cd030d2f
added infrastructure for defining lifted constants
Christian Urban <urbanc@in.tum.de>
parents:
205
diff
changeset
|
74 |
val quotdata_lookup_thy = QuotData.get |
df05cd030d2f
added infrastructure for defining lifted constants
Christian Urban <urbanc@in.tum.de>
parents:
205
diff
changeset
|
75 |
val quotdata_lookup = QuotData.get o ProofContext.theory_of |
182
c7eff9882bd8
added data-storage about the quotients
Christian Urban <urbanc@in.tum.de>
parents:
170
diff
changeset
|
76 |
|
203
7384115df9fd
added equiv-thm to the quot_info
Christian Urban <urbanc@in.tum.de>
parents:
185
diff
changeset
|
77 |
fun quotdata_update_thy (qty, rty, rel, equiv_thm) thy = |
7384115df9fd
added equiv-thm to the quot_info
Christian Urban <urbanc@in.tum.de>
parents:
185
diff
changeset
|
78 |
QuotData.map (fn ls => {qtyp = qty, rtyp = rty, rel = rel, equiv_thm = equiv_thm}::ls) thy |
135
6f0d14ba096c
started to write code for storing data about the quotients
Christian Urban <urbanc@in.tum.de>
parents:
130
diff
changeset
|
79 |
|
203
7384115df9fd
added equiv-thm to the quot_info
Christian Urban <urbanc@in.tum.de>
parents:
185
diff
changeset
|
80 |
fun quotdata_update (qty, rty, rel, equiv_thm) ctxt = |
7384115df9fd
added equiv-thm to the quot_info
Christian Urban <urbanc@in.tum.de>
parents:
185
diff
changeset
|
81 |
ProofContext.theory (quotdata_update_thy (qty, rty, rel, equiv_thm)) ctxt |
170 | 82 |
|
135
6f0d14ba096c
started to write code for storing data about the quotients
Christian Urban <urbanc@in.tum.de>
parents:
130
diff
changeset
|
83 |
fun print_quotdata ctxt = |
6f0d14ba096c
started to write code for storing data about the quotients
Christian Urban <urbanc@in.tum.de>
parents:
130
diff
changeset
|
84 |
let |
203
7384115df9fd
added equiv-thm to the quot_info
Christian Urban <urbanc@in.tum.de>
parents:
185
diff
changeset
|
85 |
fun prt_quot {qtyp, rtyp, rel, equiv_thm} = |
185
929bc55efff7
added code for declaring map-functions
Christian Urban <urbanc@in.tum.de>
parents:
182
diff
changeset
|
86 |
Pretty.block (Library.separate (Pretty.brk 2) |
929bc55efff7
added code for declaring map-functions
Christian Urban <urbanc@in.tum.de>
parents:
182
diff
changeset
|
87 |
[Pretty.str ("quotient type:"), |
929bc55efff7
added code for declaring map-functions
Christian Urban <urbanc@in.tum.de>
parents:
182
diff
changeset
|
88 |
Syntax.pretty_typ ctxt qtyp, |
929bc55efff7
added code for declaring map-functions
Christian Urban <urbanc@in.tum.de>
parents:
182
diff
changeset
|
89 |
Pretty.str ("raw type:"), |
929bc55efff7
added code for declaring map-functions
Christian Urban <urbanc@in.tum.de>
parents:
182
diff
changeset
|
90 |
Syntax.pretty_typ ctxt rtyp, |
929bc55efff7
added code for declaring map-functions
Christian Urban <urbanc@in.tum.de>
parents:
182
diff
changeset
|
91 |
Pretty.str ("relation:"), |
203
7384115df9fd
added equiv-thm to the quot_info
Christian Urban <urbanc@in.tum.de>
parents:
185
diff
changeset
|
92 |
Syntax.pretty_term ctxt rel, |
7384115df9fd
added equiv-thm to the quot_info
Christian Urban <urbanc@in.tum.de>
parents:
185
diff
changeset
|
93 |
Pretty.str ("equiv. thm:"), |
7384115df9fd
added equiv-thm to the quot_info
Christian Urban <urbanc@in.tum.de>
parents:
185
diff
changeset
|
94 |
Syntax.pretty_term ctxt (prop_of equiv_thm)]) |
130
8e8ba210f0f7
moved the map-info and fun-info section to quotient.ML
Christian Urban <urbanc@in.tum.de>
parents:
128
diff
changeset
|
95 |
in |
185
929bc55efff7
added code for declaring map-functions
Christian Urban <urbanc@in.tum.de>
parents:
182
diff
changeset
|
96 |
QuotData.get (ProofContext.theory_of ctxt) |
929bc55efff7
added code for declaring map-functions
Christian Urban <urbanc@in.tum.de>
parents:
182
diff
changeset
|
97 |
|> map prt_quot |
929bc55efff7
added code for declaring map-functions
Christian Urban <urbanc@in.tum.de>
parents:
182
diff
changeset
|
98 |
|> Pretty.big_list "quotients:" |
929bc55efff7
added code for declaring map-functions
Christian Urban <urbanc@in.tum.de>
parents:
182
diff
changeset
|
99 |
|> Pretty.writeln |
130
8e8ba210f0f7
moved the map-info and fun-info section to quotient.ML
Christian Urban <urbanc@in.tum.de>
parents:
128
diff
changeset
|
100 |
end |
8e8ba210f0f7
moved the map-info and fun-info section to quotient.ML
Christian Urban <urbanc@in.tum.de>
parents:
128
diff
changeset
|
101 |
|
135
6f0d14ba096c
started to write code for storing data about the quotients
Christian Urban <urbanc@in.tum.de>
parents:
130
diff
changeset
|
102 |
val _ = |
185
929bc55efff7
added code for declaring map-functions
Christian Urban <urbanc@in.tum.de>
parents:
182
diff
changeset
|
103 |
OuterSyntax.improper_command "print_quotients" "print out all quotients" |
135
6f0d14ba096c
started to write code for storing data about the quotients
Christian Urban <urbanc@in.tum.de>
parents:
130
diff
changeset
|
104 |
OuterKeyword.diag (Scan.succeed (Toplevel.keep (print_quotdata o Toplevel.context_of))) |
6f0d14ba096c
started to write code for storing data about the quotients
Christian Urban <urbanc@in.tum.de>
parents:
130
diff
changeset
|
105 |
|
6f0d14ba096c
started to write code for storing data about the quotients
Christian Urban <urbanc@in.tum.de>
parents:
130
diff
changeset
|
106 |
|
6f0d14ba096c
started to write code for storing data about the quotients
Christian Urban <urbanc@in.tum.de>
parents:
130
diff
changeset
|
107 |
|
205 | 108 |
(* wrappers for define, note and theorem_i *) |
135
6f0d14ba096c
started to write code for storing data about the quotients
Christian Urban <urbanc@in.tum.de>
parents:
130
diff
changeset
|
109 |
fun define (name, mx, rhs) lthy = |
6f0d14ba096c
started to write code for storing data about the quotients
Christian Urban <urbanc@in.tum.de>
parents:
130
diff
changeset
|
110 |
let |
6f0d14ba096c
started to write code for storing data about the quotients
Christian Urban <urbanc@in.tum.de>
parents:
130
diff
changeset
|
111 |
val ((rhs, (_ , thm)), lthy') = |
6f0d14ba096c
started to write code for storing data about the quotients
Christian Urban <urbanc@in.tum.de>
parents:
130
diff
changeset
|
112 |
LocalTheory.define Thm.internalK ((name, mx), (Attrib.empty_binding, rhs)) lthy |
6f0d14ba096c
started to write code for storing data about the quotients
Christian Urban <urbanc@in.tum.de>
parents:
130
diff
changeset
|
113 |
in |
6f0d14ba096c
started to write code for storing data about the quotients
Christian Urban <urbanc@in.tum.de>
parents:
130
diff
changeset
|
114 |
((rhs, thm), lthy') |
6f0d14ba096c
started to write code for storing data about the quotients
Christian Urban <urbanc@in.tum.de>
parents:
130
diff
changeset
|
115 |
end |
6f0d14ba096c
started to write code for storing data about the quotients
Christian Urban <urbanc@in.tum.de>
parents:
130
diff
changeset
|
116 |
|
6f0d14ba096c
started to write code for storing data about the quotients
Christian Urban <urbanc@in.tum.de>
parents:
130
diff
changeset
|
117 |
fun note (name, thm) lthy = |
6f0d14ba096c
started to write code for storing data about the quotients
Christian Urban <urbanc@in.tum.de>
parents:
130
diff
changeset
|
118 |
let |
6f0d14ba096c
started to write code for storing data about the quotients
Christian Urban <urbanc@in.tum.de>
parents:
130
diff
changeset
|
119 |
val ((_,[thm']), lthy') = LocalTheory.note Thm.theoremK ((name, []), [thm]) lthy |
6f0d14ba096c
started to write code for storing data about the quotients
Christian Urban <urbanc@in.tum.de>
parents:
130
diff
changeset
|
120 |
in |
6f0d14ba096c
started to write code for storing data about the quotients
Christian Urban <urbanc@in.tum.de>
parents:
130
diff
changeset
|
121 |
(thm', lthy') |
6f0d14ba096c
started to write code for storing data about the quotients
Christian Urban <urbanc@in.tum.de>
parents:
130
diff
changeset
|
122 |
end |
6f0d14ba096c
started to write code for storing data about the quotients
Christian Urban <urbanc@in.tum.de>
parents:
130
diff
changeset
|
123 |
|
203
7384115df9fd
added equiv-thm to the quot_info
Christian Urban <urbanc@in.tum.de>
parents:
185
diff
changeset
|
124 |
fun theorem after_qed goals ctxt = |
7384115df9fd
added equiv-thm to the quot_info
Christian Urban <urbanc@in.tum.de>
parents:
185
diff
changeset
|
125 |
let |
7384115df9fd
added equiv-thm to the quot_info
Christian Urban <urbanc@in.tum.de>
parents:
185
diff
changeset
|
126 |
val goals' = map (rpair []) goals |
7384115df9fd
added equiv-thm to the quot_info
Christian Urban <urbanc@in.tum.de>
parents:
185
diff
changeset
|
127 |
fun after_qed' thms = after_qed (the_single thms) |
7384115df9fd
added equiv-thm to the quot_info
Christian Urban <urbanc@in.tum.de>
parents:
185
diff
changeset
|
128 |
in |
7384115df9fd
added equiv-thm to the quot_info
Christian Urban <urbanc@in.tum.de>
parents:
185
diff
changeset
|
129 |
Proof.theorem_i NONE after_qed' [goals'] ctxt |
7384115df9fd
added equiv-thm to the quot_info
Christian Urban <urbanc@in.tum.de>
parents:
185
diff
changeset
|
130 |
end |
135
6f0d14ba096c
started to write code for storing data about the quotients
Christian Urban <urbanc@in.tum.de>
parents:
130
diff
changeset
|
131 |
|
130
8e8ba210f0f7
moved the map-info and fun-info section to quotient.ML
Christian Urban <urbanc@in.tum.de>
parents:
128
diff
changeset
|
132 |
|
8e8ba210f0f7
moved the map-info and fun-info section to quotient.ML
Christian Urban <urbanc@in.tum.de>
parents:
128
diff
changeset
|
133 |
(* definition of the quotient type *) |
8e8ba210f0f7
moved the map-info and fun-info section to quotient.ML
Christian Urban <urbanc@in.tum.de>
parents:
128
diff
changeset
|
134 |
(***********************************) |
8e8ba210f0f7
moved the map-info and fun-info section to quotient.ML
Christian Urban <urbanc@in.tum.de>
parents:
128
diff
changeset
|
135 |
|
79
c0c41fefeb06
added quotient command (you need to update isar-keywords-prove.el)
Christian Urban <urbanc@in.tum.de>
parents:
75
diff
changeset
|
136 |
(* constructs the term lambda (c::rty => bool). EX (x::rty). c = rel x *) |
71
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
137 |
fun typedef_term rel rty lthy = |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
138 |
let |
79
c0c41fefeb06
added quotient command (you need to update isar-keywords-prove.el)
Christian Urban <urbanc@in.tum.de>
parents:
75
diff
changeset
|
139 |
val [x, c] = [("x", rty), ("c", HOLogic.mk_setT rty)] |
71
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
140 |
|> Variable.variant_frees lthy [rel] |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
141 |
|> map Free |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
142 |
in |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
143 |
lambda c |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
144 |
(HOLogic.exists_const rty $ |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
145 |
lambda x (HOLogic.mk_eq (c, (rel $ x)))) |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
146 |
end |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
147 |
|
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
148 |
(* makes the new type definitions and proves non-emptyness*) |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
149 |
fun typedef_make (qty_name, mx, rel, rty) lthy = |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
150 |
let |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
151 |
val typedef_tac = |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
152 |
EVERY1 [rewrite_goal_tac @{thms mem_def}, |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
153 |
rtac @{thm exI}, |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
154 |
rtac @{thm exI}, |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
155 |
rtac @{thm refl}] |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
156 |
val tfrees = map fst (Term.add_tfreesT rty []) |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
157 |
in |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
158 |
LocalTheory.theory_result |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
159 |
(Typedef.add_typedef false NONE |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
160 |
(qty_name, tfrees, mx) |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
161 |
(typedef_term rel rty lthy) |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
162 |
NONE typedef_tac) lthy |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
163 |
end |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
164 |
|
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
165 |
(* tactic to prove the QUOT_TYPE theorem for the new type *) |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
166 |
fun typedef_quot_type_tac equiv_thm (typedef_info: Typedef.info) = |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
167 |
let |
205 | 168 |
val unfold_mem = MetaSimplifier.rewrite_rule [@{thm mem_def}] |
71
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
169 |
val rep_thm = #Rep typedef_info |> unfold_mem |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
170 |
val rep_inv = #Rep_inverse typedef_info |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
171 |
val abs_inv = #Abs_inverse typedef_info |> unfold_mem |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
172 |
val rep_inj = #Rep_inject typedef_info |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
173 |
in |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
174 |
EVERY1 [rtac @{thm QUOT_TYPE.intro}, |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
175 |
rtac equiv_thm, |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
176 |
rtac rep_thm, |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
177 |
rtac rep_inv, |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
178 |
rtac abs_inv, |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
179 |
rtac @{thm exI}, |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
180 |
rtac @{thm refl}, |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
181 |
rtac rep_inj] |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
182 |
end |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
183 |
|
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
184 |
(* proves the QUOT_TYPE theorem *) |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
185 |
fun typedef_quot_type_thm (rel, abs, rep, equiv_thm, typedef_info) lthy = |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
186 |
let |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
187 |
val quot_type_const = Const (@{const_name "QUOT_TYPE"}, dummyT) |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
188 |
val goal = HOLogic.mk_Trueprop (quot_type_const $ rel $ abs $ rep) |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
189 |
|> Syntax.check_term lthy |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
190 |
in |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
191 |
Goal.prove lthy [] [] goal |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
192 |
(K (typedef_quot_type_tac equiv_thm typedef_info)) |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
193 |
end |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
194 |
|
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
195 |
(* proves the quotient theorem *) |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
196 |
fun typedef_quotient_thm (rel, abs, rep, abs_def, rep_def, quot_type_thm) lthy = |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
197 |
let |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
198 |
val quotient_const = Const (@{const_name "QUOTIENT"}, dummyT) |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
199 |
val goal = HOLogic.mk_Trueprop (quotient_const $ rel $ abs $ rep) |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
200 |
|> Syntax.check_term lthy |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
201 |
|
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
202 |
val typedef_quotient_thm_tac = |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
203 |
EVERY1 [K (rewrite_goals_tac [abs_def, rep_def]), |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
204 |
rtac @{thm QUOT_TYPE.QUOTIENT}, |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
205 |
rtac quot_type_thm] |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
206 |
in |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
207 |
Goal.prove lthy [] [] goal |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
208 |
(K typedef_quotient_thm_tac) |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
209 |
end |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
210 |
|
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
211 |
(* main function for constructing the quotient type *) |
127
b054cf6bd179
the command "quotient" can now define more than one quotient at the same time; quotients need to be separated by and
Christian Urban <urbanc@in.tum.de>
parents:
82
diff
changeset
|
212 |
fun mk_typedef_main (((qty_name, mx), (rty, rel)), equiv_thm) lthy = |
71
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
213 |
let |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
214 |
(* generates typedef *) |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
215 |
val ((_, typedef_info), lthy1) = typedef_make (qty_name, mx, rel, rty) lthy |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
216 |
|
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
217 |
(* abs and rep functions *) |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
218 |
val abs_ty = #abs_type typedef_info |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
219 |
val rep_ty = #rep_type typedef_info |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
220 |
val abs_name = #Abs_name typedef_info |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
221 |
val rep_name = #Rep_name typedef_info |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
222 |
val abs = Const (abs_name, rep_ty --> abs_ty) |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
223 |
val rep = Const (rep_name, abs_ty --> rep_ty) |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
224 |
|
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
225 |
(* ABS and REP definitions *) |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
226 |
val ABS_const = Const (@{const_name "QUOT_TYPE.ABS"}, dummyT ) |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
227 |
val REP_const = Const (@{const_name "QUOT_TYPE.REP"}, dummyT ) |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
228 |
val ABS_trm = Syntax.check_term lthy1 (ABS_const $ rel $ abs) |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
229 |
val REP_trm = Syntax.check_term lthy1 (REP_const $ rep) |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
230 |
val ABS_name = Binding.prefix_name "ABS_" qty_name |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
231 |
val REP_name = Binding.prefix_name "REP_" qty_name |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
232 |
val (((ABS, ABS_def), (REP, REP_def)), lthy2) = |
79
c0c41fefeb06
added quotient command (you need to update isar-keywords-prove.el)
Christian Urban <urbanc@in.tum.de>
parents:
75
diff
changeset
|
233 |
lthy1 |> define (ABS_name, NoSyn, ABS_trm) |
c0c41fefeb06
added quotient command (you need to update isar-keywords-prove.el)
Christian Urban <urbanc@in.tum.de>
parents:
75
diff
changeset
|
234 |
||>> define (REP_name, NoSyn, REP_trm) |
71
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
235 |
|
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
236 |
(* quot_type theorem *) |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
237 |
val quot_thm = typedef_quot_type_thm (rel, abs, rep, equiv_thm, typedef_info) lthy2 |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
238 |
val quot_thm_name = Binding.prefix_name "QUOT_TYPE_" qty_name |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
239 |
|
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
240 |
(* quotient theorem *) |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
241 |
val quotient_thm = typedef_quotient_thm (rel, ABS, REP, ABS_def, REP_def, quot_thm) lthy2 |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
242 |
val quotient_thm_name = Binding.prefix_name "QUOTIENT_" qty_name |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
243 |
|
182
c7eff9882bd8
added data-storage about the quotients
Christian Urban <urbanc@in.tum.de>
parents:
170
diff
changeset
|
244 |
(* storing the quot-info *) |
203
7384115df9fd
added equiv-thm to the quot_info
Christian Urban <urbanc@in.tum.de>
parents:
185
diff
changeset
|
245 |
val lthy3 = quotdata_update (abs_ty, rty, rel, equiv_thm) lthy2 |
182
c7eff9882bd8
added data-storage about the quotients
Christian Urban <urbanc@in.tum.de>
parents:
170
diff
changeset
|
246 |
|
71
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
247 |
(* interpretation *) |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
248 |
val bindd = ((Binding.make ("", Position.none)), ([]: Attrib.src list)) |
182
c7eff9882bd8
added data-storage about the quotients
Christian Urban <urbanc@in.tum.de>
parents:
170
diff
changeset
|
249 |
val ((_, [eqn1pre]), lthy4) = Variable.import true [ABS_def] lthy3; |
71
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
250 |
val eqn1i = Thm.prop_of (symmetric eqn1pre) |
182
c7eff9882bd8
added data-storage about the quotients
Christian Urban <urbanc@in.tum.de>
parents:
170
diff
changeset
|
251 |
val ((_, [eqn2pre]), lthy5) = Variable.import true [REP_def] lthy4; |
71
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
252 |
val eqn2i = Thm.prop_of (symmetric eqn2pre) |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
253 |
|
182
c7eff9882bd8
added data-storage about the quotients
Christian Urban <urbanc@in.tum.de>
parents:
170
diff
changeset
|
254 |
val exp_morphism = ProofContext.export_morphism lthy5 (ProofContext.init (ProofContext.theory_of lthy5)); |
71
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
255 |
val exp_term = Morphism.term exp_morphism; |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
256 |
val exp = Morphism.thm exp_morphism; |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
257 |
|
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
258 |
val mthd = Method.SIMPLE_METHOD ((rtac quot_thm 1) THEN |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
259 |
ALLGOALS (simp_tac (HOL_basic_ss addsimps [(symmetric (exp ABS_def)), (symmetric (exp REP_def))]))) |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
260 |
val mthdt = Method.Basic (fn _ => mthd) |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
261 |
val bymt = Proof.global_terminal_proof (mthdt, NONE) |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
262 |
val exp_i = [(@{const_name QUOT_TYPE}, ((("QUOT_TYPE_I_" ^ (Binding.name_of qty_name)), true), |
170 | 263 |
Expression.Named [("R", rel), ("Abs", abs), ("Rep", rep) ]))] |
71
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
264 |
in |
182
c7eff9882bd8
added data-storage about the quotients
Christian Urban <urbanc@in.tum.de>
parents:
170
diff
changeset
|
265 |
lthy5 |
79
c0c41fefeb06
added quotient command (you need to update isar-keywords-prove.el)
Christian Urban <urbanc@in.tum.de>
parents:
75
diff
changeset
|
266 |
|> note (quot_thm_name, quot_thm) |
c0c41fefeb06
added quotient command (you need to update isar-keywords-prove.el)
Christian Urban <urbanc@in.tum.de>
parents:
75
diff
changeset
|
267 |
||>> note (quotient_thm_name, quotient_thm) |
71
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
268 |
||> LocalTheory.theory (fn thy => |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
269 |
let |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
270 |
val global_eqns = map exp_term [eqn2i, eqn1i]; |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
271 |
(* Not sure if the following context should not be used *) |
182
c7eff9882bd8
added data-storage about the quotients
Christian Urban <urbanc@in.tum.de>
parents:
170
diff
changeset
|
272 |
val (global_eqns2, lthy6) = Variable.import_terms true global_eqns lthy5; |
71
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
273 |
val global_eqns3 = map (fn t => (bindd, t)) global_eqns2; |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
274 |
in ProofContext.theory_of (bymt (Expression.interpretation (exp_i, []) global_eqns3 thy)) end) |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
275 |
end |
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
276 |
|
130
8e8ba210f0f7
moved the map-info and fun-info section to quotient.ML
Christian Urban <urbanc@in.tum.de>
parents:
128
diff
changeset
|
277 |
|
8e8ba210f0f7
moved the map-info and fun-info section to quotient.ML
Christian Urban <urbanc@in.tum.de>
parents:
128
diff
changeset
|
278 |
|
8e8ba210f0f7
moved the map-info and fun-info section to quotient.ML
Christian Urban <urbanc@in.tum.de>
parents:
128
diff
changeset
|
279 |
|
127
b054cf6bd179
the command "quotient" can now define more than one quotient at the same time; quotients need to be separated by and
Christian Urban <urbanc@in.tum.de>
parents:
82
diff
changeset
|
280 |
(* interface and syntax setup *) |
75
5fe163543bb8
started some strange functions
Christian Urban <urbanc@in.tum.de>
parents:
71
diff
changeset
|
281 |
|
127
b054cf6bd179
the command "quotient" can now define more than one quotient at the same time; quotients need to be separated by and
Christian Urban <urbanc@in.tum.de>
parents:
82
diff
changeset
|
282 |
(* the ML-interface takes a list of 4-tuples consisting of *) |
b054cf6bd179
the command "quotient" can now define more than one quotient at the same time; quotients need to be separated by and
Christian Urban <urbanc@in.tum.de>
parents:
82
diff
changeset
|
283 |
(* *) |
b054cf6bd179
the command "quotient" can now define more than one quotient at the same time; quotients need to be separated by and
Christian Urban <urbanc@in.tum.de>
parents:
82
diff
changeset
|
284 |
(* - the name of the quotient type *) |
b054cf6bd179
the command "quotient" can now define more than one quotient at the same time; quotients need to be separated by and
Christian Urban <urbanc@in.tum.de>
parents:
82
diff
changeset
|
285 |
(* - its mixfix annotation *) |
b054cf6bd179
the command "quotient" can now define more than one quotient at the same time; quotients need to be separated by and
Christian Urban <urbanc@in.tum.de>
parents:
82
diff
changeset
|
286 |
(* - the type to be quotient *) |
b054cf6bd179
the command "quotient" can now define more than one quotient at the same time; quotients need to be separated by and
Christian Urban <urbanc@in.tum.de>
parents:
82
diff
changeset
|
287 |
(* - the relation according to which the type is quotient *) |
130
8e8ba210f0f7
moved the map-info and fun-info section to quotient.ML
Christian Urban <urbanc@in.tum.de>
parents:
128
diff
changeset
|
288 |
|
127
b054cf6bd179
the command "quotient" can now define more than one quotient at the same time; quotients need to be separated by and
Christian Urban <urbanc@in.tum.de>
parents:
82
diff
changeset
|
289 |
fun mk_quotient_type quot_list lthy = |
79
c0c41fefeb06
added quotient command (you need to update isar-keywords-prove.el)
Christian Urban <urbanc@in.tum.de>
parents:
75
diff
changeset
|
290 |
let |
185
929bc55efff7
added code for declaring map-functions
Christian Urban <urbanc@in.tum.de>
parents:
182
diff
changeset
|
291 |
fun mk_goal (rty, rel) = |
127
b054cf6bd179
the command "quotient" can now define more than one quotient at the same time; quotients need to be separated by and
Christian Urban <urbanc@in.tum.de>
parents:
82
diff
changeset
|
292 |
let |
148
8e24e65f1e9b
tuned and attempted to store data about the quotients (does not work yet)
Christian Urban <urbanc@in.tum.de>
parents:
135
diff
changeset
|
293 |
val EQUIV_ty = ([rty, rty] ---> @{typ bool}) --> @{typ bool} |
127
b054cf6bd179
the command "quotient" can now define more than one quotient at the same time; quotients need to be separated by and
Christian Urban <urbanc@in.tum.de>
parents:
82
diff
changeset
|
294 |
in |
203
7384115df9fd
added equiv-thm to the quot_info
Christian Urban <urbanc@in.tum.de>
parents:
185
diff
changeset
|
295 |
HOLogic.mk_Trueprop (Const (@{const_name EQUIV}, EQUIV_ty) $ rel) |
127
b054cf6bd179
the command "quotient" can now define more than one quotient at the same time; quotients need to be separated by and
Christian Urban <urbanc@in.tum.de>
parents:
82
diff
changeset
|
296 |
end |
b054cf6bd179
the command "quotient" can now define more than one quotient at the same time; quotients need to be separated by and
Christian Urban <urbanc@in.tum.de>
parents:
82
diff
changeset
|
297 |
|
185
929bc55efff7
added code for declaring map-functions
Christian Urban <urbanc@in.tum.de>
parents:
182
diff
changeset
|
298 |
val goals = map (mk_goal o snd) quot_list |
127
b054cf6bd179
the command "quotient" can now define more than one quotient at the same time; quotients need to be separated by and
Christian Urban <urbanc@in.tum.de>
parents:
82
diff
changeset
|
299 |
|
79
c0c41fefeb06
added quotient command (you need to update isar-keywords-prove.el)
Christian Urban <urbanc@in.tum.de>
parents:
75
diff
changeset
|
300 |
fun after_qed thms lthy = |
203
7384115df9fd
added equiv-thm to the quot_info
Christian Urban <urbanc@in.tum.de>
parents:
185
diff
changeset
|
301 |
fold_map mk_typedef_main (quot_list ~~ thms) lthy |> snd |
79
c0c41fefeb06
added quotient command (you need to update isar-keywords-prove.el)
Christian Urban <urbanc@in.tum.de>
parents:
75
diff
changeset
|
302 |
in |
203
7384115df9fd
added equiv-thm to the quot_info
Christian Urban <urbanc@in.tum.de>
parents:
185
diff
changeset
|
303 |
theorem after_qed goals lthy |
79
c0c41fefeb06
added quotient command (you need to update isar-keywords-prove.el)
Christian Urban <urbanc@in.tum.de>
parents:
75
diff
changeset
|
304 |
end |
205 | 305 |
|
306 |
fun mk_quotient_type_cmd spec lthy = |
|
307 |
let |
|
308 |
fun parse_spec (((qty_str, mx), rty_str), rel_str) = |
|
309 |
let |
|
310 |
val qty_name = Binding.name qty_str |
|
311 |
val rty = Syntax.parse_typ lthy rty_str |> Syntax.check_typ lthy |
|
312 |
val rel = Syntax.parse_term lthy rel_str |> Syntax.check_term lthy |
|
313 |
in |
|
314 |
((qty_name, mx), (rty, rel)) |
|
315 |
end |
|
316 |
in |
|
317 |
mk_quotient_type (map parse_spec spec) lthy |
|
318 |
end |
|
79
c0c41fefeb06
added quotient command (you need to update isar-keywords-prove.el)
Christian Urban <urbanc@in.tum.de>
parents:
75
diff
changeset
|
319 |
|
127
b054cf6bd179
the command "quotient" can now define more than one quotient at the same time; quotients need to be separated by and
Christian Urban <urbanc@in.tum.de>
parents:
82
diff
changeset
|
320 |
val quotspec_parser = |
b054cf6bd179
the command "quotient" can now define more than one quotient at the same time; quotients need to be separated by and
Christian Urban <urbanc@in.tum.de>
parents:
82
diff
changeset
|
321 |
OuterParse.and_list1 |
b054cf6bd179
the command "quotient" can now define more than one quotient at the same time; quotients need to be separated by and
Christian Urban <urbanc@in.tum.de>
parents:
82
diff
changeset
|
322 |
(OuterParse.short_ident -- OuterParse.opt_infix -- |
b054cf6bd179
the command "quotient" can now define more than one quotient at the same time; quotients need to be separated by and
Christian Urban <urbanc@in.tum.de>
parents:
82
diff
changeset
|
323 |
(OuterParse.$$$ "=" |-- OuterParse.typ) -- |
b054cf6bd179
the command "quotient" can now define more than one quotient at the same time; quotients need to be separated by and
Christian Urban <urbanc@in.tum.de>
parents:
82
diff
changeset
|
324 |
(OuterParse.$$$ "/" |-- OuterParse.term)) |
75
5fe163543bb8
started some strange functions
Christian Urban <urbanc@in.tum.de>
parents:
71
diff
changeset
|
325 |
|
79
c0c41fefeb06
added quotient command (you need to update isar-keywords-prove.el)
Christian Urban <urbanc@in.tum.de>
parents:
75
diff
changeset
|
326 |
val _ = OuterKeyword.keyword "/" |
75
5fe163543bb8
started some strange functions
Christian Urban <urbanc@in.tum.de>
parents:
71
diff
changeset
|
327 |
|
79
c0c41fefeb06
added quotient command (you need to update isar-keywords-prove.el)
Christian Urban <urbanc@in.tum.de>
parents:
75
diff
changeset
|
328 |
val _ = |
c0c41fefeb06
added quotient command (you need to update isar-keywords-prove.el)
Christian Urban <urbanc@in.tum.de>
parents:
75
diff
changeset
|
329 |
OuterSyntax.local_theory_to_proof "quotient" |
82 | 330 |
"quotient type definitions (requires equivalence proofs)" |
127
b054cf6bd179
the command "quotient" can now define more than one quotient at the same time; quotients need to be separated by and
Christian Urban <urbanc@in.tum.de>
parents:
82
diff
changeset
|
331 |
OuterKeyword.thy_goal (quotspec_parser >> mk_quotient_type_cmd) |
79
c0c41fefeb06
added quotient command (you need to update isar-keywords-prove.el)
Christian Urban <urbanc@in.tum.de>
parents:
75
diff
changeset
|
332 |
|
c0c41fefeb06
added quotient command (you need to update isar-keywords-prove.el)
Christian Urban <urbanc@in.tum.de>
parents:
75
diff
changeset
|
333 |
end; (* structure *) |
71
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
334 |
|
35be65791f1d
exported parts of QuotMain into a separate ML-file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
335 |
open Quotient |