95 (Term.no_dummy_patterns t); |
95 (Term.no_dummy_patterns t); |
96 |
96 |
97 fun prf_of [] (Bound i) = PBound i |
97 fun prf_of [] (Bound i) = PBound i |
98 | prf_of Ts (Const (s, Type ("proof", _))) = |
98 | prf_of Ts (Const (s, Type ("proof", _))) = |
99 change_type (if ty then SOME Ts else NONE) |
99 change_type (if ty then SOME Ts else NONE) |
100 (case NameSpace.explode s of |
100 (case Long_Name.explode s of |
101 "axm" :: xs => |
101 "axm" :: xs => |
102 let |
102 let |
103 val name = NameSpace.implode xs; |
103 val name = Long_Name.implode xs; |
104 val prop = (case AList.lookup (op =) axms name of |
104 val prop = (case AList.lookup (op =) axms name of |
105 SOME prop => prop |
105 SOME prop => prop |
106 | NONE => error ("Unknown axiom " ^ quote name)) |
106 | NONE => error ("Unknown axiom " ^ quote name)) |
107 in PAxm (name, prop, NONE) end |
107 in PAxm (name, prop, NONE) end |
108 | "thm" :: xs => |
108 | "thm" :: xs => |
109 let val name = NameSpace.implode xs; |
109 let val name = Long_Name.implode xs; |
110 in (case AList.lookup (op =) thms name of |
110 in (case AList.lookup (op =) thms name of |
111 SOME thm => fst (strip_combt (Thm.proof_of thm)) |
111 SOME thm => fst (strip_combt (Thm.proof_of thm)) |
112 | NONE => error ("Unknown theorem " ^ quote name)) |
112 | NONE => error ("Unknown theorem " ^ quote name)) |
113 end |
113 end |
114 | _ => error ("Illegal proof constant name: " ^ quote s)) |
114 | _ => error ("Illegal proof constant name: " ^ quote s)) |
145 |
145 |
146 val mk_tyapp = fold (fn T => fn prf => Const ("Appt", |
146 val mk_tyapp = fold (fn T => fn prf => Const ("Appt", |
147 [proofT, Term.itselfT T] ---> proofT) $ prf $ Logic.mk_type T); |
147 [proofT, Term.itselfT T] ---> proofT) $ prf $ Logic.mk_type T); |
148 |
148 |
149 fun term_of _ (PThm (_, ((name, _, NONE), _))) = |
149 fun term_of _ (PThm (_, ((name, _, NONE), _))) = |
150 Const (NameSpace.append "thm" name, proofT) |
150 Const (Long_Name.append "thm" name, proofT) |
151 | term_of _ (PThm (_, ((name, _, SOME Ts), _))) = |
151 | term_of _ (PThm (_, ((name, _, SOME Ts), _))) = |
152 mk_tyapp Ts (Const (NameSpace.append "thm" name, proofT)) |
152 mk_tyapp Ts (Const (Long_Name.append "thm" name, proofT)) |
153 | term_of _ (PAxm (name, _, NONE)) = Const (NameSpace.append "axm" name, proofT) |
153 | term_of _ (PAxm (name, _, NONE)) = Const (Long_Name.append "axm" name, proofT) |
154 | term_of _ (PAxm (name, _, SOME Ts)) = |
154 | term_of _ (PAxm (name, _, SOME Ts)) = |
155 mk_tyapp Ts (Const (NameSpace.append "axm" name, proofT)) |
155 mk_tyapp Ts (Const (Long_Name.append "axm" name, proofT)) |
156 | term_of _ (PBound i) = Bound i |
156 | term_of _ (PBound i) = Bound i |
157 | term_of Ts (Abst (s, opT, prf)) = |
157 | term_of Ts (Abst (s, opT, prf)) = |
158 let val T = the_default dummyT opT |
158 let val T = the_default dummyT opT |
159 in Const ("Abst", (T --> proofT) --> proofT) $ |
159 in Const ("Abst", (T --> proofT) --> proofT) $ |
160 Abs (s, T, term_of (T::Ts) (incr_pboundvars 1 0 prf)) |
160 Abs (s, T, term_of (T::Ts) (incr_pboundvars 1 0 prf)) |
181 val thm_names = map fst (PureThy.all_thms_of thy); |
181 val thm_names = map fst (PureThy.all_thms_of thy); |
182 val axm_names = map fst (Theory.all_axioms_of thy); |
182 val axm_names = map fst (Theory.all_axioms_of thy); |
183 val thy' = thy |
183 val thy' = thy |
184 |> add_proof_syntax |
184 |> add_proof_syntax |
185 |> add_proof_atom_consts |
185 |> add_proof_atom_consts |
186 (map (NameSpace.append "axm") axm_names @ map (NameSpace.append "thm") thm_names); |
186 (map (Long_Name.append "axm") axm_names @ map (Long_Name.append "thm") thm_names); |
187 in |
187 in |
188 (cterm_of thy' (term_of_proof prf), proof_of_term thy true o Thm.term_of) |
188 (cterm_of thy' (term_of_proof prf), proof_of_term thy true o Thm.term_of) |
189 end; |
189 end; |
190 |
190 |
191 fun read_term thy = |
191 fun read_term thy = |
193 val thm_names = filter_out (fn s => s = "") (map fst (PureThy.all_thms_of thy)); |
193 val thm_names = filter_out (fn s => s = "") (map fst (PureThy.all_thms_of thy)); |
194 val axm_names = map fst (Theory.all_axioms_of thy); |
194 val axm_names = map fst (Theory.all_axioms_of thy); |
195 val ctxt = thy |
195 val ctxt = thy |
196 |> add_proof_syntax |
196 |> add_proof_syntax |
197 |> add_proof_atom_consts |
197 |> add_proof_atom_consts |
198 (map (NameSpace.append "axm") axm_names @ map (NameSpace.append "thm") thm_names) |
198 (map (Long_Name.append "axm") axm_names @ map (Long_Name.append "thm") thm_names) |
199 |> ProofContext.init |
199 |> ProofContext.init |
200 |> ProofContext.allow_dummies |
200 |> ProofContext.allow_dummies |
201 |> ProofContext.set_mode ProofContext.mode_schematic; |
201 |> ProofContext.set_mode ProofContext.mode_schematic; |
202 in |
202 in |
203 fn ty => fn s => |
203 fn ty => fn s => |
217 val axm_names = Symtab.keys (fold_proof_atoms true |
217 val axm_names = Symtab.keys (fold_proof_atoms true |
218 (fn PAxm (name, _, _) => Symtab.update (name, ()) | _ => I) [prf] Symtab.empty); |
218 (fn PAxm (name, _, _) => Symtab.update (name, ()) | _ => I) [prf] Symtab.empty); |
219 in |
219 in |
220 add_proof_syntax #> |
220 add_proof_syntax #> |
221 add_proof_atom_consts |
221 add_proof_atom_consts |
222 (map (NameSpace.append "thm") thm_names @ map (NameSpace.append "axm") axm_names) |
222 (map (Long_Name.append "thm") thm_names @ map (Long_Name.append "axm") axm_names) |
223 end; |
223 end; |
224 |
224 |
225 fun proof_of full thm = |
225 fun proof_of full thm = |
226 let |
226 let |
227 val thy = Thm.theory_of_thm thm; |
227 val thy = Thm.theory_of_thm thm; |