theory Scratch imports Main keywords "letfact" :: prf_decl % "proof" begin ML \ fun letfact_cmd (pat,(fact,_)) ctxt = let val t = Proof_Context.get_fact_single ctxt fact |> Thm.prop_of val pat_term = Syntax.read_prop (Proof_Context.set_mode Proof_Context.mode_pattern ctxt) pat val ctxt' = Proof_Context.match_bind true [([pat_term],t)] ctxt |> snd in ctxt' end val _ = Outer_Syntax.command \<^command_keyword>\letfact\ "bind a fact to a schematic variable" ( (Parse.term -- (\<^keyword>\=\ |-- Parse.thm)) >> (Toplevel.proof o Proof.map_context o letfact_cmd)) \ lemma "length l \ 1" proof (cases l) case Nil then show ?thesis sorry next case (Cons a list) letfact "_ = ?rhs" = Cons term ?rhs oops end