16 val lookup_abs_rep: Proof.context -> string -> abs_rep option |
16 val lookup_abs_rep: Proof.context -> string -> abs_rep option |
17 val lookup_abs_rep_global: theory -> string -> abs_rep option |
17 val lookup_abs_rep_global: theory -> string -> abs_rep option |
18 val update_abs_rep: string -> abs_rep -> Context.generic -> Context.generic |
18 val update_abs_rep: string -> abs_rep -> Context.generic -> Context.generic |
19 val print_abs_rep: Proof.context -> unit |
19 val print_abs_rep: Proof.context -> unit |
20 |
20 |
21 type quotients = {qtyp: typ, rtyp: typ, equiv_rel: term, equiv_thm: thm} |
21 type quotients = {qtyp: typ, rtyp: typ, equiv_rel: term, equiv_thm: thm, quot_thm: thm} |
22 val transform_quotients: morphism -> quotients -> quotients |
22 val transform_quotients: morphism -> quotients -> quotients |
23 val lookup_quotients: Proof.context -> string -> quotients option |
23 val lookup_quotients: Proof.context -> string -> quotients option |
24 val lookup_quotients_global: theory -> string -> quotients option |
24 val lookup_quotients_global: theory -> string -> quotients option |
25 val update_quotients: string -> quotients -> Context.generic -> Context.generic |
25 val update_quotients: string -> quotients -> Context.generic -> Context.generic |
26 val dest_quotients: Proof.context -> quotients list |
26 val dest_quotients: Proof.context -> quotients list |
123 |> Pretty.big_list "abs/rep terms:" |
123 |> Pretty.big_list "abs/rep terms:" |
124 |> Pretty.writeln |
124 |> Pretty.writeln |
125 end |
125 end |
126 |
126 |
127 (* info about quotient types *) |
127 (* info about quotient types *) |
128 type quotients = {qtyp: typ, rtyp: typ, equiv_rel: term, equiv_thm: thm} |
128 type quotients = {qtyp: typ, rtyp: typ, equiv_rel: term, equiv_thm: thm, quot_thm: thm} |
129 |
129 |
130 structure Quotients = Generic_Data |
130 structure Quotients = Generic_Data |
131 ( |
131 ( |
132 type T = quotients Symtab.table |
132 type T = quotients Symtab.table |
133 val empty = Symtab.empty |
133 val empty = Symtab.empty |
134 val extend = I |
134 val extend = I |
135 fun merge data = Symtab.merge (K true) data |
135 fun merge data = Symtab.merge (K true) data |
136 ) |
136 ) |
137 |
137 |
138 fun transform_quotients phi {qtyp, rtyp, equiv_rel, equiv_thm} = |
138 fun transform_quotients phi {qtyp, rtyp, equiv_rel, equiv_thm, quot_thm} = |
139 {qtyp = Morphism.typ phi qtyp, |
139 {qtyp = Morphism.typ phi qtyp, |
140 rtyp = Morphism.typ phi rtyp, |
140 rtyp = Morphism.typ phi rtyp, |
141 equiv_rel = Morphism.term phi equiv_rel, |
141 equiv_rel = Morphism.term phi equiv_rel, |
142 equiv_thm = Morphism.thm phi equiv_thm} |
142 equiv_thm = Morphism.thm phi equiv_thm, |
|
143 quot_thm = Morphism.thm phi quot_thm} |
143 |
144 |
144 val lookup_quotients = Symtab.lookup o Quotients.get o Context.Proof |
145 val lookup_quotients = Symtab.lookup o Quotients.get o Context.Proof |
145 val lookup_quotients_global = Symtab.lookup o Quotients.get o Context.Theory |
146 val lookup_quotients_global = Symtab.lookup o Quotients.get o Context.Theory |
146 |
147 |
147 fun update_quotients str qinfo = Quotients.map (Symtab.update (str, qinfo)) |
148 fun update_quotients str qinfo = Quotients.map (Symtab.update (str, qinfo)) |
149 fun dest_quotients ctxt = (* FIXME slightly expensive way to retrieve data *) |
150 fun dest_quotients ctxt = (* FIXME slightly expensive way to retrieve data *) |
150 map snd (Symtab.dest (Quotients.get (Context.Proof ctxt))) |
151 map snd (Symtab.dest (Quotients.get (Context.Proof ctxt))) |
151 |
152 |
152 fun print_quotients ctxt = |
153 fun print_quotients ctxt = |
153 let |
154 let |
154 fun prt_quot {qtyp, rtyp, equiv_rel, equiv_thm} = |
155 fun prt_quot {qtyp, rtyp, equiv_rel, equiv_thm, quot_thm} = |
155 Pretty.block (separate (Pretty.brk 2) |
156 Pretty.block (separate (Pretty.brk 2) |
156 [Pretty.str "quotient type:", |
157 [Pretty.str "quotient type:", |
157 Syntax.pretty_typ ctxt qtyp, |
158 Syntax.pretty_typ ctxt qtyp, |
158 Pretty.str "raw type:", |
159 Pretty.str "raw type:", |
159 Syntax.pretty_typ ctxt rtyp, |
160 Syntax.pretty_typ ctxt rtyp, |
160 Pretty.str "relation:", |
161 Pretty.str "relation:", |
161 Syntax.pretty_term ctxt equiv_rel, |
162 Syntax.pretty_term ctxt equiv_rel, |
162 Pretty.str "equiv. thm:", |
163 Pretty.str "equiv. thm:", |
163 Syntax.pretty_term ctxt (prop_of equiv_thm)]) |
164 Syntax.pretty_term ctxt (prop_of equiv_thm), |
|
165 Pretty.str "quot. thm:", |
|
166 Syntax.pretty_term ctxt (prop_of quot_thm)]) |
164 in |
167 in |
165 map (prt_quot o snd) (Symtab.dest (Quotients.get (Context.Proof ctxt))) |
168 map (prt_quot o snd) (Symtab.dest (Quotients.get (Context.Proof ctxt))) |
166 |> Pretty.big_list "quotients:" |
169 |> Pretty.big_list "quotients:" |
167 |> Pretty.writeln |
170 |> Pretty.writeln |
168 end |
171 end |