src/Pure/pure_thy.ML
changeset 70388 e31271559de8
parent 67721 5348bea4accd
child 70403 468cfd56ee03
equal deleted inserted replaced
70387:35dd9212bf29 70388:e31271559de8
    12 end;
    12 end;
    13 
    13 
    14 structure Pure_Thy: PURE_THY =
    14 structure Pure_Thy: PURE_THY =
    15 struct
    15 struct
    16 
    16 
       
    17 (* auxiliary *)
       
    18 
    17 val typ = Simple_Syntax.read_typ;
    19 val typ = Simple_Syntax.read_typ;
    18 val prop = Simple_Syntax.read_prop;
    20 val prop = Simple_Syntax.read_prop;
    19 
    21 
    20 val tycon = Lexicon.mark_type;
    22 val tycon = Lexicon.mark_type;
    21 val const = Lexicon.mark_const;
    23 val const = Lexicon.mark_const;
    24 
    26 
    25 fun mixfix (sy, ps, p) = Mixfix (Input.string sy, ps, p, Position.no_range);
    27 fun mixfix (sy, ps, p) = Mixfix (Input.string sy, ps, p, Position.no_range);
    26 fun infix_ (sy, p) = Infix (Input.string sy, p, Position.no_range);
    28 fun infix_ (sy, p) = Infix (Input.string sy, p, Position.no_range);
    27 fun infixr_ (sy, p) = Infixr (Input.string sy, p, Position.no_range);
    29 fun infixr_ (sy, p) = Infixr (Input.string sy, p, Position.no_range);
    28 fun binder (sy, p, q) = Binder (Input.string sy, p, q, Position.no_range);
    30 fun binder (sy, p, q) = Binder (Input.string sy, p, q, Position.no_range);
       
    31 
       
    32 fun add_deps_type c thy =
       
    33   let
       
    34     val n = Sign.arity_number thy c;
       
    35     val typargs = map (fn a => TFree (a, [])) (Name.invent Name.context Name.aT n);
       
    36   in thy |> Theory.add_deps_global "" ((Defs.Type, c), typargs) [] end
       
    37 
       
    38 fun add_deps_const c thy =
       
    39   let
       
    40     val T = Logic.unvarifyT_global (Sign.the_const_type thy c);
       
    41     val typargs = Sign.const_typargs thy (c, T);
       
    42   in thy |> Theory.add_deps_global "" ((Defs.Const, c), typargs) [] end;
    29 
    43 
    30 
    44 
    31 (* application syntax variants *)
    45 (* application syntax variants *)
    32 
    46 
    33 val appl_syntax =
    47 val appl_syntax =
    68    Old_Appl_Syntax.put false #>
    82    Old_Appl_Syntax.put false #>
    69    Sign.add_types_global
    83    Sign.add_types_global
    70    [(Binding.make ("fun", \<^here>), 2, NoSyn),
    84    [(Binding.make ("fun", \<^here>), 2, NoSyn),
    71     (Binding.make ("prop", \<^here>), 0, NoSyn),
    85     (Binding.make ("prop", \<^here>), 0, NoSyn),
    72     (Binding.make ("itself", \<^here>), 1, NoSyn),
    86     (Binding.make ("itself", \<^here>), 1, NoSyn),
    73     (Binding.make ("dummy", \<^here>), 0, NoSyn)]
    87     (Binding.make ("dummy", \<^here>), 0, NoSyn),
    74   #> Theory.add_deps_global "fun" ((Defs.Type, "fun"), [typ "'a", typ "'b"]) []
    88     (qualify (Binding.make ("proof", \<^here>)), 0, NoSyn)]
    75   #> Theory.add_deps_global "prop" ((Defs.Type, "prop"), []) []
    89   #> add_deps_type "fun"
    76   #> Theory.add_deps_global "itself" ((Defs.Type, "itself"), [typ "'a"]) []
    90   #> add_deps_type "prop"
    77   #> Theory.add_deps_global "dummy" ((Defs.Type, "dummy"), []) []
    91   #> add_deps_type "itself"
       
    92   #> add_deps_type "dummy"
       
    93   #> add_deps_type "Pure.proof"
    78   #> Sign.add_nonterminals_global
    94   #> Sign.add_nonterminals_global
    79     (map (fn name => Binding.make (name, \<^here>))
    95     (map (fn name => Binding.make (name, \<^here>))
    80       (Lexicon.terminals @ ["logic", "type", "types", "sort", "classes",
    96       (Lexicon.terminals @ ["logic", "type", "types", "sort", "classes",
    81         "args", "cargs", "pttrn", "pttrns", "idt", "idts", "aprop", "asms",
    97         "args", "cargs", "pttrn", "pttrns", "idt", "idts", "aprop", "asms",
    82         "any", "prop'", "num_const", "float_const", "num_position",
    98         "any", "prop'", "num_const", "float_const", "num_position",
   198    [(qualify (Binding.make ("eq", \<^here>)), typ "'a \<Rightarrow> 'a \<Rightarrow> prop", infix_ ("\<equiv>", 2)),
   214    [(qualify (Binding.make ("eq", \<^here>)), typ "'a \<Rightarrow> 'a \<Rightarrow> prop", infix_ ("\<equiv>", 2)),
   199     (qualify (Binding.make ("imp", \<^here>)), typ "prop \<Rightarrow> prop \<Rightarrow> prop", infixr_ ("\<Longrightarrow>", 1)),
   215     (qualify (Binding.make ("imp", \<^here>)), typ "prop \<Rightarrow> prop \<Rightarrow> prop", infixr_ ("\<Longrightarrow>", 1)),
   200     (qualify (Binding.make ("all", \<^here>)), typ "('a \<Rightarrow> prop) \<Rightarrow> prop", binder ("\<And>", 0, 0)),
   216     (qualify (Binding.make ("all", \<^here>)), typ "('a \<Rightarrow> prop) \<Rightarrow> prop", binder ("\<And>", 0, 0)),
   201     (qualify (Binding.make ("prop", \<^here>)), typ "prop \<Rightarrow> prop", NoSyn),
   217     (qualify (Binding.make ("prop", \<^here>)), typ "prop \<Rightarrow> prop", NoSyn),
   202     (qualify (Binding.make ("type", \<^here>)), typ "'a itself", NoSyn),
   218     (qualify (Binding.make ("type", \<^here>)), typ "'a itself", NoSyn),
   203     (qualify (Binding.make ("dummy_pattern", \<^here>)), typ "'a", Mixfix.mixfix "'_")]
   219     (qualify (Binding.make ("dummy_pattern", \<^here>)), typ "'a", Mixfix.mixfix "'_"),
   204   #> Theory.add_deps_global "Pure.eq" ((Defs.Const, "Pure.eq"), [typ "'a"]) []
   220     (qualify (Binding.make ("Appt", \<^here>)), typ "Pure.proof \<Rightarrow> 'a \<Rightarrow> Pure.proof", NoSyn),
   205   #> Theory.add_deps_global "Pure.imp" ((Defs.Const, "Pure.imp"), []) []
   221     (qualify (Binding.make ("AppP", \<^here>)), typ "Pure.proof \<Rightarrow> Pure.proof \<Rightarrow> Pure.proof", NoSyn),
   206   #> Theory.add_deps_global "Pure.all" ((Defs.Const, "Pure.all"), [typ "'a"]) []
   222     (qualify (Binding.make ("Abst", \<^here>)), typ "('a \<Rightarrow> Pure.proof) \<Rightarrow> Pure.proof", NoSyn),
   207   #> Theory.add_deps_global "Pure.type" ((Defs.Const, "Pure.type"), [typ "'a"]) []
   223     (qualify (Binding.make ("AbsP", \<^here>)), typ "prop \<Rightarrow> (Pure.proof \<Rightarrow> Pure.proof) \<Rightarrow> Pure.proof", NoSyn),
   208   #> Theory.add_deps_global "Pure.dummy_pattern" ((Defs.Const, "Pure.dummy_pattern"), [typ "'a"]) []
   224     (qualify (Binding.make ("Hyp", \<^here>)), typ "prop \<Rightarrow> Pure.proof", NoSyn),
       
   225     (qualify (Binding.make ("Oracle", \<^here>)), typ "prop \<Rightarrow> Pure.proof", NoSyn),
       
   226     (qualify (Binding.make ("OfClass", \<^here>)), typ "('a itself \<Rightarrow> prop) \<Rightarrow> Pure.proof", NoSyn),
       
   227     (qualify (Binding.make ("MinProof", \<^here>)), typ "Pure.proof", Mixfix.mixfix "?")]
       
   228   #> add_deps_const "Pure.eq"
       
   229   #> add_deps_const "Pure.imp"
       
   230   #> add_deps_const "Pure.all"
       
   231   #> add_deps_const "Pure.type"
       
   232   #> add_deps_const "Pure.dummy_pattern"
   209   #> Sign.parse_ast_translation Syntax_Trans.pure_parse_ast_translation
   233   #> Sign.parse_ast_translation Syntax_Trans.pure_parse_ast_translation
   210   #> Sign.parse_translation Syntax_Trans.pure_parse_translation
   234   #> Sign.parse_translation Syntax_Trans.pure_parse_translation
   211   #> Sign.print_ast_translation Syntax_Trans.pure_print_ast_translation
   235   #> Sign.print_ast_translation Syntax_Trans.pure_print_ast_translation
   212   #> Sign.add_consts
   236   #> Sign.add_consts
   213    [(qualify (Binding.make ("term", \<^here>)), typ "'a \<Rightarrow> prop", NoSyn),
   237    [(qualify (Binding.make ("term", \<^here>)), typ "'a \<Rightarrow> prop", NoSyn),