src/HOL/Orderings.thy
changeset 24704 9a95634ab135
parent 24641 448edc627ee4
child 24741 a53f5db5acbb
equal deleted inserted replaced
24703:0041117b756c 24704:9a95634ab135
   241 
   241 
   242 signature ORDERS =
   242 signature ORDERS =
   243 sig
   243 sig
   244   val print_structures: Proof.context -> unit
   244   val print_structures: Proof.context -> unit
   245   val setup: theory -> theory
   245   val setup: theory -> theory
   246   val order_tac: Proof.context -> int -> tactic
   246   val order_tac: thm list -> Proof.context -> int -> tactic
   247 end;
   247 end;
   248 
   248 
   249 structure Orders: ORDERS =
   249 structure Orders: ORDERS =
   250 struct
   250 struct
   251 
   251 
   281   end;
   281   end;
   282 
   282 
   283 
   283 
   284 (** Method **)
   284 (** Method **)
   285 
   285 
   286 fun struct_tac ((s, [eq, le, less]), thms) =
   286 fun struct_tac ((s, [eq, le, less]), thms) prems =
   287   let
   287   let
   288     fun decomp thy (Trueprop $ t) =
   288     fun decomp thy (Trueprop $ t) =
   289       let
   289       let
   290         fun excluded t =
   290         fun excluded t =
   291           (* exclude numeric types: linear arithmetic subsumes transitivity *)
   291           (* exclude numeric types: linear arithmetic subsumes transitivity *)
   304               else NONE
   304               else NONE
   305 	  | dec _ = NONE;
   305 	  | dec _ = NONE;
   306       in dec t end;
   306       in dec t end;
   307   in
   307   in
   308     case s of
   308     case s of
   309       "order" => Order_Tac.partial_tac decomp thms
   309       "order" => Order_Tac.partial_tac decomp thms prems
   310     | "linorder" => Order_Tac.linear_tac decomp thms
   310     | "linorder" => Order_Tac.linear_tac decomp thms prems
   311     | _ => error ("Unknown kind of order `" ^ s ^ "' encountered in transitivity reasoner.")
   311     | _ => error ("Unknown kind of order `" ^ s ^ "' encountered in transitivity reasoner.")
   312   end
   312   end
   313 
   313 
   314 fun order_tac ctxt =
   314 fun order_tac prems ctxt =
   315   FIRST' (map (fn s => CHANGED o struct_tac s) (Data.get (Context.Proof ctxt)));
   315   FIRST' (map (fn s => CHANGED o struct_tac s prems) (Data.get (Context.Proof ctxt)));
   316 
   316 
   317 
   317 
   318 (** Attribute **)
   318 (** Attribute **)
   319 
   319 
   320 fun add_struct_thm s tag =
   320 fun add_struct_thm s tag =
   347 
   347 
   348 
   348 
   349 (** Setup **)
   349 (** Setup **)
   350 
   350 
   351 val setup = let val _ = OuterSyntax.add_parsers [printP] in
   351 val setup = let val _ = OuterSyntax.add_parsers [printP] in
   352     Method.add_methods [("order", Method.ctxt_args (Method.SIMPLE_METHOD' o order_tac),
   352     Method.add_methods [("order", Method.ctxt_args (Method.SIMPLE_METHOD' o order_tac []),
   353       "normalisation of algebraic structure")] #>
   353       "normalisation of algebraic structure")] #>
   354     Attrib.add_attributes [("order", attribute, "theorems controlling transitivity reasoner")]
   354     Attrib.add_attributes [("order", attribute, "theorems controlling transitivity reasoner")]
   355   end;
   355   end;
   356 
   356 
   357 end;
   357 end;
   511   (Simplifier.change_simpset_of thy (fn ss => ss
   511   (Simplifier.change_simpset_of thy (fn ss => ss
   512     addsimprocs (map (fn (name, raw_ts, proc) =>
   512     addsimprocs (map (fn (name, raw_ts, proc) =>
   513       Simplifier.simproc thy name raw_ts proc)) procs); thy);
   513       Simplifier.simproc thy name raw_ts proc)) procs); thy);
   514 fun add_solver name tac thy =
   514 fun add_solver name tac thy =
   515   (Simplifier.change_simpset_of thy (fn ss => ss addSolver
   515   (Simplifier.change_simpset_of thy (fn ss => ss addSolver
   516     (mk_solver' name (fn ss => tac (MetaSimplifier.the_context ss)))); thy);
   516     (mk_solver' name (fn ss => tac (MetaSimplifier.prems_of_ss ss) (MetaSimplifier.the_context ss)))); thy);
   517 
   517 
   518 in
   518 in
   519   add_simprocs [
   519   add_simprocs [
   520        ("antisym le", ["(x::'a::order) <= y"], prove_antisym_le),
   520        ("antisym le", ["(x::'a::order) <= y"], prove_antisym_le),
   521        ("antisym less", ["~ (x::'a::linorder) < y"], prove_antisym_less)
   521        ("antisym less", ["~ (x::'a::linorder) < y"], prove_antisym_less)