Theory Type_Encodings

(*  Title:      HOL/Metis_Examples/Type_Encodings.thy
    Author:     Jasmin Blanchette, TU Muenchen

Example that exercises Metis's (and hence Sledgehammer's) type encodings.

section ‹
Example that Exercises Metis's (and Hence Sledgehammer's) Type Encodings

theory Type_Encodings
imports Main

declare [[metis_new_skolem]]

text ‹Setup for testing Metis exhaustively›

lemma fork: "P  P  P" by assumption

ML val type_encs =

fun metis_exhaust_tac ctxt ths =
    fun tac [] st = all_tac st
      | tac (type_enc :: type_encs) st =
        st |> ((if null type_encs then all_tac else resolve_tac ctxt @{thms fork} 1)
               THEN Metis_Tactic.metis_tac [type_enc]
                    ATP_Problem_Generate.combsN ctxt ths 1
               THEN COND (has_fewer_prems 2) all_tac no_tac
               THEN tac type_encs)
  in tac type_encs end

method_setup metis_exhaust = Attrib.thms >>
    (fn ths => fn ctxt => SIMPLE_METHOD (metis_exhaust_tac ctxt ths)) "exhaustively run Metis with all type encodings"

text ‹Miscellaneous tests›

lemma "x = y  y = x"
by metis_exhaust

lemma "[a] = [Suc 0]  a = 1"
by (metis_exhaust last.simps One_nat_def)

lemma "map Suc [0] = [Suc 0]"
by (metis_exhaust

lemma "map Suc [1 + 1] = [Suc 2]"
by (metis_exhaust nat_1_add_1)

lemma "map Suc [2] = [Suc (1 + 1)]"
by (metis_exhaust nat_1_add_1)

definition "null xs = (xs = [])"

lemma "P (null xs)  null xs  xs = []"
by (metis_exhaust null_def)

lemma "(0::nat) + 0 = 0"
by (metis_exhaust add_0_left)