src/HOL/Metis_Examples/Type_Encodings.thy
author blanchet
Mon, 06 Jun 2011 20:36:35 +0200
changeset 43205 23b81469499f
parent 43197 c71657bbdbc0
child 43208 acfc370df64b
permissions -rw-r--r--
more preparations towards hijacking Metis
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
43197
c71657bbdbc0 tuned Metis examples
blanchet
parents: 43196
diff changeset
     1
(*  Title:      HOL/Metis_Examples/Type_Encodings.thy
43162
9a8acc5adfa3 added Metis examples to test the new type encodings
blanchet
parents:
diff changeset
     2
    Author:     Jasmin Blanchette, TU Muenchen
9a8acc5adfa3 added Metis examples to test the new type encodings
blanchet
parents:
diff changeset
     3
43197
c71657bbdbc0 tuned Metis examples
blanchet
parents: 43196
diff changeset
     4
Example that exercises Metis's (and hence Sledgehammer's) type encodings.
43162
9a8acc5adfa3 added Metis examples to test the new type encodings
blanchet
parents:
diff changeset
     5
*)
9a8acc5adfa3 added Metis examples to test the new type encodings
blanchet
parents:
diff changeset
     6
43197
c71657bbdbc0 tuned Metis examples
blanchet
parents: 43196
diff changeset
     7
header {*
c71657bbdbc0 tuned Metis examples
blanchet
parents: 43196
diff changeset
     8
Example that Exercises Metis's (and Hence Sledgehammer's) Type Encodings
c71657bbdbc0 tuned Metis examples
blanchet
parents: 43196
diff changeset
     9
*}
c71657bbdbc0 tuned Metis examples
blanchet
parents: 43196
diff changeset
    10
c71657bbdbc0 tuned Metis examples
blanchet
parents: 43196
diff changeset
    11
theory Type_Encodings
43162
9a8acc5adfa3 added Metis examples to test the new type encodings
blanchet
parents:
diff changeset
    12
imports Main
9a8acc5adfa3 added Metis examples to test the new type encodings
blanchet
parents:
diff changeset
    13
begin
9a8acc5adfa3 added Metis examples to test the new type encodings
blanchet
parents:
diff changeset
    14
43197
c71657bbdbc0 tuned Metis examples
blanchet
parents: 43196
diff changeset
    15
declare [[metis_new_skolemizer]]
c71657bbdbc0 tuned Metis examples
blanchet
parents: 43196
diff changeset
    16
c71657bbdbc0 tuned Metis examples
blanchet
parents: 43196
diff changeset
    17
sledgehammer_params [prover = e, blocking, timeout = 10, preplay_timeout = 0]
c71657bbdbc0 tuned Metis examples
blanchet
parents: 43196
diff changeset
    18
c71657bbdbc0 tuned Metis examples
blanchet
parents: 43196
diff changeset
    19
43162
9a8acc5adfa3 added Metis examples to test the new type encodings
blanchet
parents:
diff changeset
    20
text {* Setup for testing Metis exhaustively *}
9a8acc5adfa3 added Metis examples to test the new type encodings
blanchet
parents:
diff changeset
    21
9a8acc5adfa3 added Metis examples to test the new type encodings
blanchet
parents:
diff changeset
    22
lemma fork: "P \<Longrightarrow> P \<Longrightarrow> P" by assumption
9a8acc5adfa3 added Metis examples to test the new type encodings
blanchet
parents:
diff changeset
    23
9a8acc5adfa3 added Metis examples to test the new type encodings
blanchet
parents:
diff changeset
    24
ML {*
9a8acc5adfa3 added Metis examples to test the new type encodings
blanchet
parents:
diff changeset
    25
open ATP_Translate
9a8acc5adfa3 added Metis examples to test the new type encodings
blanchet
parents:
diff changeset
    26
9a8acc5adfa3 added Metis examples to test the new type encodings
blanchet
parents:
diff changeset
    27
val polymorphisms = [Polymorphic, Monomorphic, Mangled_Monomorphic]
9a8acc5adfa3 added Metis examples to test the new type encodings
blanchet
parents:
diff changeset
    28
val levels =
9a8acc5adfa3 added Metis examples to test the new type encodings
blanchet
parents:
diff changeset
    29
  [All_Types, Nonmonotonic_Types, Finite_Types, Const_Arg_Types, No_Types]
9a8acc5adfa3 added Metis examples to test the new type encodings
blanchet
parents:
diff changeset
    30
val heaviness = [Heavyweight, Lightweight]
9a8acc5adfa3 added Metis examples to test the new type encodings
blanchet
parents:
diff changeset
    31
val type_syss =
9a8acc5adfa3 added Metis examples to test the new type encodings
blanchet
parents:
diff changeset
    32
  (levels |> map Simple_Types) @
9a8acc5adfa3 added Metis examples to test the new type encodings
blanchet
parents:
diff changeset
    33
  (map_product pair levels heaviness
43196
c6c6c2bc6fe8 more through tests of new Metis
blanchet
parents: 43172
diff changeset
    34
   (* The following two families of type systems are too incomplete for our
c6c6c2bc6fe8 more through tests of new Metis
blanchet
parents: 43172
diff changeset
    35
      tests. *)
c6c6c2bc6fe8 more through tests of new Metis
blanchet
parents: 43172
diff changeset
    36
   |> remove (op =) (Nonmonotonic_Types, Heavyweight)
c6c6c2bc6fe8 more through tests of new Metis
blanchet
parents: 43172
diff changeset
    37
   |> remove (op =) (Finite_Types, Heavyweight)
43162
9a8acc5adfa3 added Metis examples to test the new type encodings
blanchet
parents:
diff changeset
    38
   |> map_product pair polymorphisms
9a8acc5adfa3 added Metis examples to test the new type encodings
blanchet
parents:
diff changeset
    39
   |> map_product (fn constr => fn (poly, (level, heaviness)) =>
9a8acc5adfa3 added Metis examples to test the new type encodings
blanchet
parents:
diff changeset
    40
                      constr (poly, level, heaviness))
9a8acc5adfa3 added Metis examples to test the new type encodings
blanchet
parents:
diff changeset
    41
                  [Preds, Tags])
9a8acc5adfa3 added Metis examples to test the new type encodings
blanchet
parents:
diff changeset
    42
43205
23b81469499f more preparations towards hijacking Metis
blanchet
parents: 43197
diff changeset
    43
fun new_metis_exhaust_tac ctxt ths =
43162
9a8acc5adfa3 added Metis examples to test the new type encodings
blanchet
parents:
diff changeset
    44
  let
43172
blanchet
parents: 43162
diff changeset
    45
    fun tac [] st = all_tac st
blanchet
parents: 43162
diff changeset
    46
      | tac (type_sys :: type_syss) st =
blanchet
parents: 43162
diff changeset
    47
        st (* |> tap (fn _ => tracing (PolyML.makestring type_sys)) *)
blanchet
parents: 43162
diff changeset
    48
           |> ((if null type_syss then all_tac else rtac @{thm fork} 1)
43205
23b81469499f more preparations towards hijacking Metis
blanchet
parents: 43197
diff changeset
    49
               THEN Metis_Tactics.new_metis_tac [type_sys] ctxt ths 1
43172
blanchet
parents: 43162
diff changeset
    50
               THEN COND (has_fewer_prems 2) all_tac no_tac
blanchet
parents: 43162
diff changeset
    51
               THEN tac type_syss)
43162
9a8acc5adfa3 added Metis examples to test the new type encodings
blanchet
parents:
diff changeset
    52
  in tac end
9a8acc5adfa3 added Metis examples to test the new type encodings
blanchet
parents:
diff changeset
    53
*}
9a8acc5adfa3 added Metis examples to test the new type encodings
blanchet
parents:
diff changeset
    54
43205
23b81469499f more preparations towards hijacking Metis
blanchet
parents: 43197
diff changeset
    55
method_setup new_metis_exhaust = {*
43162
9a8acc5adfa3 added Metis examples to test the new type encodings
blanchet
parents:
diff changeset
    56
  Attrib.thms >>
43205
23b81469499f more preparations towards hijacking Metis
blanchet
parents: 43197
diff changeset
    57
    (fn ths => fn ctxt => SIMPLE_METHOD (new_metis_exhaust_tac ctxt ths type_syss))
43162
9a8acc5adfa3 added Metis examples to test the new type encodings
blanchet
parents:
diff changeset
    58
*} "exhaustively run the new Metis with all type encodings"
9a8acc5adfa3 added Metis examples to test the new type encodings
blanchet
parents:
diff changeset
    59
9a8acc5adfa3 added Metis examples to test the new type encodings
blanchet
parents:
diff changeset
    60
43197
c71657bbdbc0 tuned Metis examples
blanchet
parents: 43196
diff changeset
    61
text {* Miscellaneous tests *}
43162
9a8acc5adfa3 added Metis examples to test the new type encodings
blanchet
parents:
diff changeset
    62
9a8acc5adfa3 added Metis examples to test the new type encodings
blanchet
parents:
diff changeset
    63
lemma "x = y \<Longrightarrow> y = x"
43205
23b81469499f more preparations towards hijacking Metis
blanchet
parents: 43197
diff changeset
    64
by new_metis_exhaust
43162
9a8acc5adfa3 added Metis examples to test the new type encodings
blanchet
parents:
diff changeset
    65
9a8acc5adfa3 added Metis examples to test the new type encodings
blanchet
parents:
diff changeset
    66
lemma "[a] = [1 + 1] \<Longrightarrow> a = 1 + (1::int)"
43205
23b81469499f more preparations towards hijacking Metis
blanchet
parents: 43197
diff changeset
    67
by (new_metis_exhaust last.simps)
43162
9a8acc5adfa3 added Metis examples to test the new type encodings
blanchet
parents:
diff changeset
    68
9a8acc5adfa3 added Metis examples to test the new type encodings
blanchet
parents:
diff changeset
    69
lemma "map Suc [0] = [Suc 0]"
43205
23b81469499f more preparations towards hijacking Metis
blanchet
parents: 43197
diff changeset
    70
by (new_metis_exhaust map.simps)
43162
9a8acc5adfa3 added Metis examples to test the new type encodings
blanchet
parents:
diff changeset
    71
9a8acc5adfa3 added Metis examples to test the new type encodings
blanchet
parents:
diff changeset
    72
lemma "map Suc [1 + 1] = [Suc 2]"
43205
23b81469499f more preparations towards hijacking Metis
blanchet
parents: 43197
diff changeset
    73
by (new_metis_exhaust map.simps nat_1_add_1)
43162
9a8acc5adfa3 added Metis examples to test the new type encodings
blanchet
parents:
diff changeset
    74
9a8acc5adfa3 added Metis examples to test the new type encodings
blanchet
parents:
diff changeset
    75
lemma "map Suc [2] = [Suc (1 + 1)]"
43205
23b81469499f more preparations towards hijacking Metis
blanchet
parents: 43197
diff changeset
    76
by (new_metis_exhaust map.simps nat_1_add_1)
43162
9a8acc5adfa3 added Metis examples to test the new type encodings
blanchet
parents:
diff changeset
    77
9a8acc5adfa3 added Metis examples to test the new type encodings
blanchet
parents:
diff changeset
    78
definition "null xs = (xs = [])"
9a8acc5adfa3 added Metis examples to test the new type encodings
blanchet
parents:
diff changeset
    79
9a8acc5adfa3 added Metis examples to test the new type encodings
blanchet
parents:
diff changeset
    80
lemma "P (null xs) \<Longrightarrow> null xs \<Longrightarrow> xs = []"
43205
23b81469499f more preparations towards hijacking Metis
blanchet
parents: 43197
diff changeset
    81
by (new_metis_exhaust null_def)
43162
9a8acc5adfa3 added Metis examples to test the new type encodings
blanchet
parents:
diff changeset
    82
9a8acc5adfa3 added Metis examples to test the new type encodings
blanchet
parents:
diff changeset
    83
lemma "(0::nat) + 0 = 0"
43205
23b81469499f more preparations towards hijacking Metis
blanchet
parents: 43197
diff changeset
    84
by (new_metis_exhaust arithmetic_simps(38))
43162
9a8acc5adfa3 added Metis examples to test the new type encodings
blanchet
parents:
diff changeset
    85
9a8acc5adfa3 added Metis examples to test the new type encodings
blanchet
parents:
diff changeset
    86
end