progtut/progtut.thy
author Xingyuan Zhang <xingyuanzhang@126.com>
Sat, 13 Sep 2014 10:07:14 +0800
changeset 25 a5f5b9336007
permissions -rw-r--r--
thys2 added
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
25
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
     1
theory FistStep
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
     2
imports Main
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
     3
begin
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
     4
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
     5
ML {*
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
     6
val pretty_term = Syntax.pretty_term
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
     7
val pwriteln = Pretty.writeln
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
     8
fun pretty_terms ctxt trms =
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
     9
  Pretty.block (Pretty.commas (map (pretty_term ctxt) trms))
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
    10
val show_type_ctxt = Config.put show_types true @{context}
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
    11
val show_all_types_ctxt = Config.put show_all_types true @{context}
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
    12
fun pretty_cterm ctxt ctrm =
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
    13
  pretty_term ctxt (term_of ctrm)
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
    14
fun pretty_thm ctxt thm =
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
    15
  pretty_term ctxt (prop_of thm)
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
    16
fun pretty_thm_no_vars ctxt thm =
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
    17
let
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
    18
  val ctxt' = Config.put show_question_marks false ctxt
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
    19
in
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
    20
  pretty_term ctxt' (prop_of thm)
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
    21
end
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
    22
fun pretty_thms ctxt thms =
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
    23
  Pretty.block (Pretty.commas (map (pretty_thm ctxt) thms))
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
    24
fun pretty_thms_no_vars ctxt thms =
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
    25
  Pretty.block (Pretty.commas (map (pretty_thm_no_vars ctxt) thms))
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
    26
fun pretty_typ ctxt ty = Syntax.pretty_typ ctxt ty
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
    27
fun pretty_typs ctxt tys =
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
    28
  Pretty.block (Pretty.commas (map (pretty_typ ctxt) tys))
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
    29
fun pretty_ctyp ctxt cty = pretty_typ ctxt (typ_of cty)
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
    30
fun pretty_ctyps ctxt ctys =
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
    31
  Pretty.block (Pretty.commas (map (pretty_ctyp ctxt) ctys))
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
    32
fun `f = fn x => (f x, x)
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
    33
fun (x, y) |>> f = (f x, y)
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
    34
fun (x, y) ||> f = (x, f y)
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
    35
fun (x, y) |-> f = f x y
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
    36
*}
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
    37
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
    38
ML {*
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
    39
  val _ = pretty_term @{context} @{term "x + y + z"} |> pwriteln
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
    40
  val _ = pretty_terms @{context} [@{term "x + y"}, @{term "x + y + z"}] |> pwriteln
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
    41
  val show_type_ctxt = Config.put show_types true @{context}
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
    42
  *}
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
    43
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
    44
ML {*
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
    45
   pwriteln (pretty_term show_type_ctxt @{term "(1::nat, x)"})
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
    46
*}
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
    47
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
    48
ML {*
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
    49
pwriteln (Pretty.str (cat_lines ["foo", "bar"]))
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
    50
*}
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
    51
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
    52
ML {*
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
    53
  fun apply_fresh_args f ctxt =
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
    54
      f |> fastype_of
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
    55
        |> binder_types
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
    56
        |> map (pair "z")
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
    57
        |> Variable.variant_frees ctxt [f]
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
    58
        |> map Free
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
    59
        |> tap (fn x => pwriteln (Pretty.str (@{make_string} x)))
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
    60
        |> curry list_comb f
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
    61
*}
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
    62
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
    63
ML {*
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
    64
let
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
    65
   val trm = @{term "P::nat => int => unit => bool"}
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
    66
   val ctxt = ML_Context.the_local_context ()
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
    67
in
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
    68
   apply_fresh_args trm ctxt
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
    69
    |> pretty_term ctxt
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
    70
    |> pwriteln
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
    71
end
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
    72
*}
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
    73
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
    74
ML {*
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
    75
  fun inc_by_three x =
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
    76
      x |> (fn x => x + 1)
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
    77
        |> tap (fn x => pwriteln (Pretty.str (@{make_string} x)))
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
    78
        |> (fn x => x + 2)
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
    79
*}
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
    80
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
    81
ML {*
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
    82
  fun `f = fn x => (f x, x)
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
    83
*}
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
    84
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
    85
ML {*
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
    86
  fun inc_as_pair x =
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
    87
        x |> `(fn x => x + 1)
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
    88
       |> (fn (x, y) => (x, y + 1))
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
    89
*}
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
    90
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
    91
ML {*
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
    92
  3 |> inc_as_pair
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
    93
*}
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
    94
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
    95
ML {*
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
    96
  fun acc_incs x =
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
    97
      x |> (fn x => (0, x))
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
    98
        ||>> (fn x => (x, x + 1))
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
    99
        ||>> (fn x => (x, x + 1))
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
   100
        ||>> (fn x => (x, x + 1))
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
   101
*}
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
   102
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
   103
ML {*
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
   104
  2 |> acc_incs
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
   105
*}
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
   106
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
   107
ML {*
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
   108
let
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
   109
  val ((names1, names2), _) =
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
   110
    @{context}
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
   111
    |> Variable.variant_fixes (replicate 4 "x")
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
   112
    |> tap (fn x => pwriteln (Pretty.str (@{make_string} x)))
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
   113
    ||>> Variable.variant_fixes (replicate 5 "x")
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
   114
    |> tap (fn x => pwriteln (Pretty.str (@{make_string} x)))
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
   115
in
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
   116
  (names1, names2)
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
   117
end
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
   118
*}
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
   119
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
   120
ML {*
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
   121
  @{context}
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
   122
  |> Local_Defs.add_def ((@{binding "One"}, NoSyn), @{term "1::nat"})
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
   123
  ||>> Local_Defs.add_def ((@{binding "Two"}, NoSyn), @{term "2::nat"})
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
   124
  ||>> Local_Defs.add_def ((@{binding "Three"}, NoSyn), @{term "3::nat"})
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
   125
*}
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
   126
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
   127
ML {*
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
   128
let
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
   129
   val ctxt = @{context}
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
   130
in
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
   131
   Syntax.parse_term ctxt "m + n"
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
   132
   |> singleton (Syntax.check_terms ctxt)
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
   133
   |> pretty_term ctxt
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
   134
   |> pwriteln
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
   135
end
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
   136
*}
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
   137
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
   138
ML {*
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
   139
  val term_pat_setup =
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
   140
  let
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
   141
    val parser = Args.context -- Scan.lift Args.name_source
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
   142
      fun term_pat (ctxt, str) =
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
   143
         str |> Proof_Context.read_term_pattern ctxt
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
   144
             |> ML_Syntax.print_term
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
   145
             |> ML_Syntax.atomic
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
   146
   in
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
   147
      ML_Antiquote.inline @{binding "term_pat"} (parser >> term_pat)
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
   148
   end
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
   149
*}
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
   150
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
   151
setup {* term_pat_setup *}
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
   152
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
   153
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
   154
ML {*
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
   155
val type_pat_setup =
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
   156
let
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
   157
   val parser = Args.context -- Scan.lift Args.name_source
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
   158
   fun typ_pat (ctxt, str) =
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
   159
     let
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
   160
       val ctxt' = Proof_Context.set_mode Proof_Context.mode_schematic ctxt
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
   161
     in
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
   162
       str |> Syntax.read_typ ctxt'
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
   163
           |> ML_Syntax.print_typ
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
   164
           |> ML_Syntax.atomic
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
   165
       end
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
   166
in
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
   167
   ML_Antiquote.inline @{binding "typ_pat"} (parser >> typ_pat)
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
   168
end
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
   169
*}
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
   170
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
   171
setup {* type_pat_setup *}
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
   172
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents:
diff changeset
   173
end