src/HOL/NSA/NSA.thy
changeset 45541 934866fc776c
parent 45540 7f5050fb8821
child 47108 2a1953f0d20d
equal deleted inserted replaced
45540:7f5050fb8821 45541:934866fc776c
   644 by (blast intro: approx_sym approx_trans)
   644 by (blast intro: approx_sym approx_trans)
   645 
   645 
   646 lemma approx_trans3: "[| x @= r; x @= s|] ==> r @= s"
   646 lemma approx_trans3: "[| x @= r; x @= s|] ==> r @= s"
   647 by (blast intro: approx_sym approx_trans)
   647 by (blast intro: approx_sym approx_trans)
   648 
   648 
   649 lemma number_of_approx_reorient: "(number_of w @= x) = (x @= number_of w)"
   649 lemma approx_reorient: "(x @= y) = (y @= x)"
   650 by (blast intro: approx_sym)
   650 by (blast intro: approx_sym)
   651 
       
   652 lemma zero_approx_reorient: "(0 @= x) = (x @= 0)"
       
   653 by (blast intro: approx_sym)
       
   654 
       
   655 lemma one_approx_reorient: "(1 @= x) = (x @= 1)"
       
   656 by (blast intro: approx_sym)
       
   657 
       
   658 
       
   659 ML {*
       
   660 local
       
   661 (*** re-orientation, following HOL/Integ/Bin.ML
       
   662      We re-orient x @=y where x is 0, 1 or a numeral, unless y is as well!
       
   663  ***)
       
   664 
       
   665 (*reorientation simprules using ==, for the following simproc*)
       
   666 val meta_zero_approx_reorient = @{thm zero_approx_reorient} RS eq_reflection;
       
   667 val meta_one_approx_reorient = @{thm one_approx_reorient} RS eq_reflection;
       
   668 val meta_number_of_approx_reorient = @{thm number_of_approx_reorient} RS eq_reflection
       
   669 
   651 
   670 (*reorientation simplification procedure: reorients (polymorphic)
   652 (*reorientation simplification procedure: reorients (polymorphic)
   671   0 = x, 1 = x, nnn = x provided x isn't 0, 1 or a numeral.*)
   653   0 = x, 1 = x, nnn = x provided x isn't 0, 1 or a numeral.*)
   672 fun reorient_proc sg _ (_ $ t $ u) =
   654 simproc_setup approx_reorient_simproc
   673   case u of
   655   ("0 @= x" | "1 @= y" | "number_of w @= z") =
   674       Const(@{const_name Groups.zero}, _) => NONE
   656 {*
   675     | Const(@{const_name Groups.one}, _) => NONE
   657   let val rule = @{thm approx_reorient} RS eq_reflection
   676     | Const(@{const_name Int.number_of}, _) $ _ => NONE
   658       fun proc phi ss ct = case term_of ct of
   677     | _ => SOME (case t of
   659           _ $ t $ u => if can HOLogic.dest_number u then NONE
   678                 Const(@{const_name Groups.zero}, _) => meta_zero_approx_reorient
   660             else if can HOLogic.dest_number t then SOME rule else NONE
   679               | Const(@{const_name Groups.one}, _) => meta_one_approx_reorient
   661         | _ => NONE
   680               | Const(@{const_name Int.number_of}, _) $ _ =>
   662   in proc end
   681                                  meta_number_of_approx_reorient);
       
   682 
       
   683 in
       
   684 
       
   685 val approx_reorient_simproc = Simplifier.simproc_global @{theory}
       
   686   "reorient_simproc" ["0@=x", "1@=x", "number_of w @= x"] reorient_proc;
       
   687 
       
   688 end;
       
   689 
       
   690 Addsimprocs [approx_reorient_simproc];
       
   691 *}
   663 *}
   692 
   664 
   693 lemma Infinitesimal_approx_minus: "(x-y \<in> Infinitesimal) = (x @= y)"
   665 lemma Infinitesimal_approx_minus: "(x-y \<in> Infinitesimal) = (x @= y)"
   694 by (simp add: approx_minus_iff [symmetric] mem_infmal_iff)
   666 by (simp add: approx_minus_iff [symmetric] mem_infmal_iff)
   695 
   667