src/HOL/arith_data.ML
changeset 15195 197e00ce3f20
parent 15185 8c43ffe2bb32
child 15197 19e735596e51
equal deleted inserted replaced
15194:ddbbab501213 15195:197e00ce3f20
   479 fun arith_method prems =
   479 fun arith_method prems =
   480   Method.METHOD (fn facts => HEADGOAL (Method.insert_tac (prems @ facts) THEN' arith_tac));
   480   Method.METHOD (fn facts => HEADGOAL (Method.insert_tac (prems @ facts) THEN' arith_tac));
   481 
   481 
   482 end;
   482 end;
   483 
   483 
       
   484 (* antisymmetry:
       
   485    combines x <= y (or ~(y < x)) and y <= x (or ~(x < y)) into x = y *)
       
   486 
       
   487 local
       
   488 val antisym = mk_meta_eq order_antisym
       
   489 val not_lessD = linorder_not_less RS iffD1
       
   490 fun prp t thm = (#prop(rep_thm thm) = t)
       
   491 in
       
   492 fun antisym_eq prems thm =
       
   493   let
       
   494     val r = #prop(rep_thm thm);
       
   495   in
       
   496     case r of
       
   497       Tr $ ((c as Const("op <=",T)) $ s $ t) =>
       
   498         let val r' = Tr $ (c $ t $ s)
       
   499         in
       
   500           case Library.find_first (prp r') prems of
       
   501             None =>
       
   502               let val r' = Tr $ (HOLogic.not_const $ (Const("op <",T) $ s $ t))
       
   503               in case Library.find_first (prp r') prems of
       
   504                    None => []
       
   505                  | Some thm' => [(thm' RS not_lessD) RS (thm RS antisym)]
       
   506               end
       
   507           | Some thm' => [thm' RS (thm RS antisym)]
       
   508         end
       
   509     | Tr $ (Const("Not",_) $ (Const("op <",T) $ s $ t)) =>
       
   510         let val r' = Tr $ (Const("op <=",T) $ s $ t)
       
   511         in
       
   512           case Library.find_first (prp r') prems of
       
   513             None =>
       
   514               let val r' = Tr $ (HOLogic.not_const $ (Const("op <",T) $ t $ s))
       
   515               in case Library.find_first (prp r') prems of
       
   516                    None => []
       
   517                  | Some thm' =>
       
   518                      [(thm' RS not_lessD) RS ((thm RS not_lessD) RS antisym)]
       
   519               end
       
   520           | Some thm' => [thm' RS ((thm RS not_lessD) RS antisym)]
       
   521         end
       
   522     | _ => []
       
   523   end
       
   524   handle THM _ => []
       
   525 end;
       
   526 
   484 
   527 
   485 (* theory setup *)
   528 (* theory setup *)
   486 
   529 
   487 val arith_setup =
   530 val arith_setup =
   488  [Simplifier.change_simpset_of (op addsimprocs) nat_cancel_sums] @
   531  [Simplifier.change_simpset_of (op setmksimps2) antisym_eq,
       
   532   Simplifier.change_simpset_of (op addsimprocs) nat_cancel_sums] @
   489   init_lin_arith_data @
   533   init_lin_arith_data @
   490   [Simplifier.change_simpset_of (op addSolver)
   534   [Simplifier.change_simpset_of (op addSolver)
   491    (mk_solver "lin. arith." Fast_Arith.cut_lin_arith_tac),
   535    (mk_solver "lin. arith." Fast_Arith.cut_lin_arith_tac),
   492   Simplifier.change_simpset_of (op addsimprocs) [fast_nat_arith_simproc],
   536   Simplifier.change_simpset_of (op addsimprocs) [fast_nat_arith_simproc],
   493   Method.add_methods [("arith", (arith_method o #2) oo Method.syntax Args.bang_facts,
   537   Method.add_methods [("arith", (arith_method o #2) oo Method.syntax Args.bang_facts,