2014-07-14 19:32:44 +00:00
|
|
|
(*
|
|
|
|
* Copyright 2014, NICTA
|
|
|
|
*
|
|
|
|
* This software may be distributed and modified according to the terms of
|
|
|
|
* the BSD 2-Clause license. Note that NO WARRANTY is provided.
|
|
|
|
* See "LICENSE_BSD2.txt" for details.
|
|
|
|
*
|
|
|
|
* @TAG(NICTA_BSD)
|
|
|
|
*)
|
|
|
|
|
|
|
|
(*Alternate apply command which displays "used" theorems in refinement step*)
|
|
|
|
|
|
|
|
theory Apply_Trace_Cmd
|
|
|
|
imports Apply_Trace
|
|
|
|
keywords "apply_trace" :: prf_script
|
|
|
|
begin
|
|
|
|
|
2019-06-05 10:18:48 +00:00
|
|
|
ML\<open>
|
2014-07-14 19:32:44 +00:00
|
|
|
|
|
|
|
val _ =
|
2015-04-17 15:19:32 +00:00
|
|
|
Outer_Syntax.command @{command_keyword "apply_trace"} "initial refinement step (unstructured)"
|
2017-07-12 05:13:51 +00:00
|
|
|
|
|
|
|
(Args.mode "only_names" -- (Scan.option (Parse.position Parse.cartouche)) -- Method.parse >>
|
2016-12-15 06:07:23 +00:00
|
|
|
(fn ((on,query),text) => Toplevel.proofs (Apply_Trace.apply_results {silent_fail = false}
|
|
|
|
(Pretty.writeln ooo (Apply_Trace.pretty_deps on query)) text)));
|
2014-07-14 19:32:44 +00:00
|
|
|
|
2019-06-05 10:18:48 +00:00
|
|
|
\<close>
|
2014-07-14 19:32:44 +00:00
|
|
|
|
|
|
|
lemmas [no_trace] = protectI protectD TrueI Eq_TrueI eq_reflection
|
|
|
|
|
2014-10-08 04:18:29 +00:00
|
|
|
(* Test. *)
|
|
|
|
lemma "(a \<and> b) = (b \<and> a)"
|
|
|
|
apply_trace auto
|
|
|
|
oops
|
|
|
|
|
2015-09-17 04:02:46 +00:00
|
|
|
(* Test. *)
|
2017-07-12 05:13:51 +00:00
|
|
|
lemma "(a \<and> b) = (b \<and> a)"
|
2015-09-17 04:02:46 +00:00
|
|
|
apply_trace \<open>intro\<close> auto
|
|
|
|
oops
|
|
|
|
|
2015-09-16 07:01:09 +00:00
|
|
|
(* Local assumptions might mask real facts (or each other). Probably not an issue in practice.*)
|
|
|
|
lemma
|
|
|
|
assumes X: "b = a"
|
|
|
|
assumes Y: "b = a"
|
|
|
|
shows
|
|
|
|
"b = a"
|
|
|
|
apply_trace (rule Y)
|
|
|
|
oops
|
|
|
|
|
2016-12-15 05:16:27 +00:00
|
|
|
(* If any locale facts are accessible their local variant is assumed to the one that is used. *)
|
2017-02-10 04:18:46 +00:00
|
|
|
|
|
|
|
locale Apply_Trace_foo = fixes b a
|
2016-12-15 05:16:27 +00:00
|
|
|
assumes X: "b = a"
|
|
|
|
begin
|
|
|
|
|
|
|
|
lemma shows "b = a" "b = a"
|
|
|
|
apply -
|
2017-02-15 23:03:56 +00:00
|
|
|
apply_trace (rule Apply_Trace_foo.X)
|
2016-12-15 05:16:27 +00:00
|
|
|
prefer 2
|
|
|
|
apply_trace (rule X)
|
|
|
|
oops
|
|
|
|
end
|
|
|
|
|
2017-07-03 05:03:07 +00:00
|
|
|
experiment begin
|
2015-09-17 04:02:46 +00:00
|
|
|
|
2017-07-03 05:03:07 +00:00
|
|
|
text \<open>Example of trace for grouped lemmas\<close>
|
|
|
|
definition ex :: "nat set" where
|
|
|
|
"ex = {1,2,3,4}"
|
|
|
|
|
|
|
|
lemma v1: "1 \<in> ex" by (simp add: ex_def)
|
|
|
|
lemma v2: "2 \<in> ex" by (simp add: ex_def)
|
|
|
|
lemma v3: "3 \<in> ex" by (simp add: ex_def)
|
|
|
|
|
|
|
|
text \<open>Group several lemmas in a single one\<close>
|
|
|
|
lemmas vs = v1 v2 v3
|
|
|
|
|
|
|
|
lemma "2 \<in> ex"
|
|
|
|
apply_trace (simp add: vs)
|
|
|
|
oops
|
|
|
|
|
|
|
|
end
|
2014-07-14 19:32:44 +00:00
|
|
|
end
|