src/Pure/Isar/attrib.ML
changeset 63019 80ef19b51493
parent 62898 fdc290b68ecd
child 63068 8b9401bfd9fd
equal deleted inserted replaced
63017:00f4461fa99f 63019:80ef19b51493
    76   val option_string: string * Position.T -> string Config.T * (theory -> theory)
    76   val option_string: string * Position.T -> string Config.T * (theory -> theory)
    77   val setup_option_bool: string * Position.T -> bool Config.T
    77   val setup_option_bool: string * Position.T -> bool Config.T
    78   val setup_option_int: string * Position.T -> int Config.T
    78   val setup_option_int: string * Position.T -> int Config.T
    79   val setup_option_real: string * Position.T -> real Config.T
    79   val setup_option_real: string * Position.T -> real Config.T
    80   val setup_option_string: string * Position.T -> string Config.T
    80   val setup_option_string: string * Position.T -> string Config.T
       
    81   val consumes: int -> Token.src
       
    82   val constraints: int -> Token.src
       
    83   val cases_open: Token.src
       
    84   val case_names: string list -> Token.src
       
    85   val case_conclusion: string * string list -> Token.src
    81 end;
    86 end;
    82 
    87 
    83 structure Attrib: ATTRIB =
    88 structure Attrib: ATTRIB =
    84 struct
    89 struct
    85 
    90 
   233   |> Context.proof_map;
   238   |> Context.proof_map;
   234 
   239 
   235 
   240 
   236 (* internal attribute *)
   241 (* internal attribute *)
   237 
   242 
   238 fun internal att =
       
   239   Token.make_src ("Pure.attribute", Position.none)
       
   240     [Token.make_string ("<attribute>", Position.none) |> Token.assign (SOME (Token.Attribute att))];
       
   241 
       
   242 val _ = Theory.setup
   243 val _ = Theory.setup
   243   (setup (Binding.make ("attribute", @{here}))
   244   (setup (Binding.make ("attribute", @{here}))
   244     (Scan.lift Args.internal_attribute >> Morphism.form)
   245     (Scan.lift Args.internal_attribute >> Morphism.form)
   245     "internal attribute");
   246     "internal attribute");
       
   247 
       
   248 fun internal_name ctxt name =
       
   249   Token.make_src (name, Position.none) [] |> check_src ctxt |> hd;
       
   250 
       
   251 val internal_attribute_name =
       
   252   internal_name (Context.the_local_context ()) "attribute";
       
   253 
       
   254 fun internal att =
       
   255   internal_attribute_name ::
       
   256     [Token.make_string ("<attribute>", Position.none) |> Token.assign (SOME (Token.Attribute att))];
   246 
   257 
   247 
   258 
   248 (* add/del syntax *)
   259 (* add/del syntax *)
   249 
   260 
   250 fun add_del add del = Scan.lift (Args.add >> K add || Args.del >> K del || Scan.succeed add);
   261 fun add_del add del = Scan.lift (Args.add >> K add || Args.del >> K del || Scan.succeed add);
   526     (Scan.lift (Scan.optional Parse.int 1) >> Rule_Cases.consumes)
   537     (Scan.lift (Scan.optional Parse.int 1) >> Rule_Cases.consumes)
   527     "number of consumed facts" #>
   538     "number of consumed facts" #>
   528   setup @{binding constraints}
   539   setup @{binding constraints}
   529     (Scan.lift Parse.nat >> Rule_Cases.constraints)
   540     (Scan.lift Parse.nat >> Rule_Cases.constraints)
   530     "number of equality constraints" #>
   541     "number of equality constraints" #>
       
   542   setup @{binding cases_open}
       
   543     (Scan.succeed Rule_Cases.cases_open)
       
   544     "rule with open parameters" #>
   531   setup @{binding case_names}
   545   setup @{binding case_names}
   532     (Scan.lift (Scan.repeat1 (Args.name --
   546     (Scan.lift (Scan.repeat (Args.name --
   533       Scan.optional (Parse.$$$ "[" |-- Scan.repeat1 (Args.maybe Args.name) --| Parse.$$$ "]") []))
   547       Scan.optional (Parse.$$$ "[" |-- Scan.repeat1 (Args.maybe Args.name) --| Parse.$$$ "]") []))
   534       >> (fn cs =>
   548       >> (fn cs =>
   535         Rule_Cases.cases_hyp_names
   549         Rule_Cases.cases_hyp_names
   536           (map #1 cs)
   550           (map #1 cs)
   537           (map (map (the_default Rule_Cases.case_hypsN) o #2) cs)))
   551           (map (map (the_default Rule_Cases.case_hypsN) o #2) cs)))
   605   register_config Raw_Simplifier.simp_depth_limit_raw #>
   619   register_config Raw_Simplifier.simp_depth_limit_raw #>
   606   register_config Raw_Simplifier.simp_trace_depth_limit_raw #>
   620   register_config Raw_Simplifier.simp_trace_depth_limit_raw #>
   607   register_config Raw_Simplifier.simp_debug_raw #>
   621   register_config Raw_Simplifier.simp_debug_raw #>
   608   register_config Raw_Simplifier.simp_trace_raw);
   622   register_config Raw_Simplifier.simp_trace_raw);
   609 
   623 
   610 end;
   624 
       
   625 (* internal source *)
       
   626 
       
   627 local
       
   628 
       
   629 val internal = internal_name (Context.the_local_context ());
       
   630 
       
   631 val consumes_name = internal "consumes";
       
   632 val constraints_name = internal "constraints";
       
   633 val cases_open_name = internal "cases_open";
       
   634 val case_names_name = internal "case_names";
       
   635 val case_conclusion_name = internal "case_conclusion";
       
   636 
       
   637 fun make_string s = Token.make_string (s, Position.none);
       
   638 
       
   639 in
       
   640 
       
   641 fun consumes i = consumes_name :: Token.make_int i;
       
   642 fun constraints i = constraints_name :: Token.make_int i;
       
   643 val cases_open = [cases_open_name];
       
   644 fun case_names names = case_names_name :: map make_string names;
       
   645 fun case_conclusion (name, names) = case_conclusion_name :: map make_string (name :: names);
       
   646 
       
   647 end;
       
   648 
       
   649 end;