26 val bws : thm list -> unit |
26 val bws : thm list -> unit |
27 val by : tactic -> unit |
27 val by : tactic -> unit |
28 val byev : tactic list -> unit |
28 val byev : tactic list -> unit |
29 val chop : unit -> unit |
29 val chop : unit -> unit |
30 val choplev : int -> unit |
30 val choplev : int -> unit |
|
31 val export_thy : theory -> thm -> thm |
31 val export : thm -> thm |
32 val export : thm -> thm |
32 val fa : unit -> unit |
33 val fa : unit -> unit |
33 val fd : thm -> unit |
34 val fd : thm -> unit |
34 val fds : thm list -> unit |
35 val fds : thm list -> unit |
35 val fe : thm -> unit |
36 val fe : thm -> unit |
139 |> Thm.strip_shyps |> Thm.implies_intr_shyps |
140 |> Thm.strip_shyps |> Thm.implies_intr_shyps |
140 |> zero_var_indexes |> Thm.varifyT |> Thm.compress |
141 |> zero_var_indexes |> Thm.varifyT |> Thm.compress |
141 end; |
142 end; |
142 |
143 |
143 (** exporting a theorem out of a locale means turning all meta-hyps into assumptions |
144 (** exporting a theorem out of a locale means turning all meta-hyps into assumptions |
144 and expand and cancel the locale definitions. It's relatively easy, because |
145 and expand and cancel the locale definitions. |
145 a definiendum is a locale const, hence Free, hence Var, after standard **) |
146 export goes through all levels in case of nested locales, whereas |
|
147 export_thy just goes one up. (Here the version with theory parameter, the real export |
|
148 resides in Thy/context.ML **) |
|
149 |
|
150 fun get_top_scope_thms thy = |
|
151 let val sc = (Locale.get_scope_sg (sign_of thy)) |
|
152 in if (null sc) then (warning "No locale in theory"; []) |
|
153 else map (#prop o rep_thm) (map #2 (#thms(snd(hd sc)))) |
|
154 end; |
|
155 |
|
156 fun implies_intr_some_hyps thy A_set th = |
|
157 let |
|
158 val sign = sign_of thy; |
|
159 val used_As = A_set inter #hyps(rep_thm(th)); |
|
160 val ctl = map (cterm_of sign) used_As |
|
161 in foldl (fn (x, y) => Thm.implies_intr y x) (th, ctl) |
|
162 end; |
|
163 |
|
164 fun standard_some thy A_set th = |
|
165 let val {maxidx,...} = rep_thm th |
|
166 in |
|
167 th |> implies_intr_some_hyps thy A_set |
|
168 |> forall_intr_frees |> forall_elim_vars (maxidx + 1) |
|
169 |> Thm.strip_shyps |> Thm.implies_intr_shyps |
|
170 |> zero_var_indexes |> Thm.varifyT |> Thm.compress |
|
171 end; |
|
172 |
|
173 fun export_thy thy th = |
|
174 let val A_set = get_top_scope_thms thy |
|
175 in |
|
176 standard_some thy [] (Seq.hd ((REPEAT (FIRSTGOAL (rtac reflexive_thm))) (standard_some thy A_set th))) |
|
177 end; |
|
178 |
146 val export = standard o Seq.hd o (REPEAT (FIRSTGOAL (rtac reflexive_thm))) o standard; |
179 val export = standard o Seq.hd o (REPEAT (FIRSTGOAL (rtac reflexive_thm))) o standard; |
147 |
180 |
148 (*Common treatment of "goal" and "prove_goal": |
181 (*Common treatment of "goal" and "prove_goal": |
149 Return assumptions, initial proof state, and function to make result. |
182 Return assumptions, initial proof state, and function to make result. |
150 "atomic" indicates if the goal should be wrapped up in the function |
183 "atomic" indicates if the goal should be wrapped up in the function |