114 fun xml_of_criterion (Name name) = XML.Elem (("Name", [("val", name)]), []) |
114 fun xml_of_criterion (Name name) = XML.Elem (("Name", [("val", name)]), []) |
115 | xml_of_criterion Intro = XML.Elem (("Intro", []) , []) |
115 | xml_of_criterion Intro = XML.Elem (("Intro", []) , []) |
116 | xml_of_criterion Elim = XML.Elem (("Elim", []) , []) |
116 | xml_of_criterion Elim = XML.Elem (("Elim", []) , []) |
117 | xml_of_criterion Dest = XML.Elem (("Dest", []) , []) |
117 | xml_of_criterion Dest = XML.Elem (("Dest", []) , []) |
118 | xml_of_criterion Solves = XML.Elem (("Solves", []) , []) |
118 | xml_of_criterion Solves = XML.Elem (("Solves", []) , []) |
119 | xml_of_criterion (Simp pat) = XML.Elem (("Simp", []) , [XML_Syntax.xml_of_term pat]) |
119 | xml_of_criterion (Simp pat) = XML.Elem (("Simp", []), [Legacy_XML_Syntax.xml_of_term pat]) |
120 | xml_of_criterion (Pattern pat) = XML.Elem (("Pattern", []) , [XML_Syntax.xml_of_term pat]); |
120 | xml_of_criterion (Pattern pat) = XML.Elem (("Pattern", []), [Legacy_XML_Syntax.xml_of_term pat]); |
121 |
121 |
122 fun criterion_of_xml (XML.Elem (("Name", [("val", name)]), [])) = Name name |
122 fun criterion_of_xml (XML.Elem (("Name", [("val", name)]), [])) = Name name |
123 | criterion_of_xml (XML.Elem (("Intro", []) , [])) = Intro |
123 | criterion_of_xml (XML.Elem (("Intro", []) , [])) = Intro |
124 | criterion_of_xml (XML.Elem (("Elim", []) , [])) = Elim |
124 | criterion_of_xml (XML.Elem (("Elim", []) , [])) = Elim |
125 | criterion_of_xml (XML.Elem (("Dest", []) , [])) = Dest |
125 | criterion_of_xml (XML.Elem (("Dest", []) , [])) = Dest |
126 | criterion_of_xml (XML.Elem (("Solves", []) , [])) = Solves |
126 | criterion_of_xml (XML.Elem (("Solves", []) , [])) = Solves |
127 | criterion_of_xml (XML.Elem (("Simp", []) , [tree])) = Simp (XML_Syntax.term_of_xml tree) |
127 | criterion_of_xml (XML.Elem (("Simp", []), [tree])) = Simp (Legacy_XML_Syntax.term_of_xml tree) |
128 | criterion_of_xml (XML.Elem (("Pattern", []) , [tree])) = Pattern (XML_Syntax.term_of_xml tree) |
128 | criterion_of_xml (XML.Elem (("Pattern", []), [tree])) = Pattern (Legacy_XML_Syntax.term_of_xml tree) |
129 | criterion_of_xml tree = raise XML_Syntax.XML ("criterion_of_xml: bad tree", tree); |
129 | criterion_of_xml tree = raise Legacy_XML_Syntax.XML ("criterion_of_xml: bad tree", tree); |
130 |
130 |
131 fun xml_of_query {goal = NONE, limit, rem_dups, criteria} = |
131 fun xml_of_query {goal = NONE, limit, rem_dups, criteria} = |
132 let |
132 let |
133 val properties = [] |
133 val properties = [] |
134 |> (if rem_dups then cons ("rem_dups", "") else I) |
134 |> (if rem_dups then cons ("rem_dups", "") else I) |
147 XML.Decode.list (XML.Decode.pair XML.Decode.bool |
147 XML.Decode.list (XML.Decode.pair XML.Decode.bool |
148 (criterion_of_xml o the_single)) body; |
148 (criterion_of_xml o the_single)) body; |
149 in |
149 in |
150 {goal = NONE, limit = limit, rem_dups = rem_dups, criteria = criteria} |
150 {goal = NONE, limit = limit, rem_dups = rem_dups, criteria = criteria} |
151 end |
151 end |
152 | query_of_xml tree = raise XML_Syntax.XML ("query_of_xml: bad tree", tree); |
152 | query_of_xml tree = raise Legacy_XML_Syntax.XML ("query_of_xml: bad tree", tree); |
153 |
153 |
154 |
154 |
155 |
155 |
156 (** theorems, either internal or external (without proof) **) |
156 (** theorems, either internal or external (without proof) **) |
157 |
157 |
165 Position.markup pos o Markup.properties [("name", name)] |
165 Position.markup pos o Markup.properties [("name", name)] |
166 | fact_ref_markup fact_ref = raise Fail "bad fact ref"; |
166 | fact_ref_markup fact_ref = raise Fail "bad fact ref"; |
167 |
167 |
168 fun xml_of_theorem (Internal _) = raise Fail "xml_of_theorem: Internal" |
168 fun xml_of_theorem (Internal _) = raise Fail "xml_of_theorem: Internal" |
169 | xml_of_theorem (External (fact_ref, prop)) = |
169 | xml_of_theorem (External (fact_ref, prop)) = |
170 XML.Elem (fact_ref_markup fact_ref ("External", []), [XML_Syntax.xml_of_term prop]); |
170 XML.Elem (fact_ref_markup fact_ref ("External", []), [Legacy_XML_Syntax.xml_of_term prop]); |
171 |
171 |
172 fun theorem_of_xml (XML.Elem (("External", properties), [tree])) = |
172 fun theorem_of_xml (XML.Elem (("External", properties), [tree])) = |
173 let |
173 let |
174 val name = the (Properties.get properties "name"); |
174 val name = the (Properties.get properties "name"); |
175 val pos = Position.of_properties properties; |
175 val pos = Position.of_properties properties; |
176 val intvs_opt = |
176 val intvs_opt = |
177 Option.map (single o Facts.Single o Markup.parse_int) |
177 Option.map (single o Facts.Single o Markup.parse_int) |
178 (Properties.get properties "index"); |
178 (Properties.get properties "index"); |
179 in |
179 in |
180 External (Facts.Named ((name, pos), intvs_opt), XML_Syntax.term_of_xml tree) |
180 External (Facts.Named ((name, pos), intvs_opt), Legacy_XML_Syntax.term_of_xml tree) |
181 end |
181 end |
182 | theorem_of_xml tree = raise XML_Syntax.XML ("theorem_of_xml: bad tree", tree); |
182 | theorem_of_xml tree = raise Legacy_XML_Syntax.XML ("theorem_of_xml: bad tree", tree); |
183 |
183 |
184 fun xml_of_result (opt_found, theorems) = |
184 fun xml_of_result (opt_found, theorems) = |
185 let |
185 let |
186 val properties = |
186 val properties = |
187 if is_some opt_found then [("found", Markup.print_int (the opt_found))] else []; |
187 if is_some opt_found then [("found", Markup.print_int (the opt_found))] else []; |
190 end; |
190 end; |
191 |
191 |
192 fun result_of_xml (XML.Elem (("Result", properties), body)) = |
192 fun result_of_xml (XML.Elem (("Result", properties), body)) = |
193 (Properties.get properties "found" |> Option.map Markup.parse_int, |
193 (Properties.get properties "found" |> Option.map Markup.parse_int, |
194 XML.Decode.list (theorem_of_xml o the_single) body) |
194 XML.Decode.list (theorem_of_xml o the_single) body) |
195 | result_of_xml tree = raise XML_Syntax.XML ("result_of_xml: bad tree", tree); |
195 | result_of_xml tree = raise Legacy_XML_Syntax.XML ("result_of_xml: bad tree", tree); |
196 |
196 |
197 fun prop_of (Internal (_, thm)) = Thm.full_prop_of thm |
197 fun prop_of (Internal (_, thm)) = Thm.full_prop_of thm |
198 | prop_of (External (_, prop)) = prop; |
198 | prop_of (External (_, prop)) = prop; |
199 |
199 |
200 fun nprems_of (Internal (_, thm)) = Thm.nprems_of thm |
200 fun nprems_of (Internal (_, thm)) = Thm.nprems_of thm |