src/HOL/Integ/Bin.ML
changeset 2988 d38f330e58b3
parent 2224 4fc4b465be5b
child 3919 c036caebfc75
equal deleted inserted replaced
2987:becc227bad4d 2988:d38f330e58b3
    10 open Bin;
    10 open Bin;
    11 
    11 
    12 (** extra rules for bin_succ, bin_pred, bin_add, bin_mult **)
    12 (** extra rules for bin_succ, bin_pred, bin_add, bin_mult **)
    13 
    13 
    14 qed_goal "norm_Bcons_Plus_0" Bin.thy
    14 qed_goal "norm_Bcons_Plus_0" Bin.thy
    15     "norm_Bcons Plus False = Plus"
    15     "norm_Bcons PlusSign False = PlusSign"
    16  (fn _ => [(Simp_tac 1)]);
    16  (fn _ => [(Simp_tac 1)]);
    17 
    17 
    18 qed_goal "norm_Bcons_Plus_1" Bin.thy
    18 qed_goal "norm_Bcons_Plus_1" Bin.thy
    19     "norm_Bcons Plus True = Bcons Plus True"
    19     "norm_Bcons PlusSign True = Bcons PlusSign True"
    20  (fn _ => [(Simp_tac 1)]);
    20  (fn _ => [(Simp_tac 1)]);
    21 
    21 
    22 qed_goal "norm_Bcons_Minus_0" Bin.thy
    22 qed_goal "norm_Bcons_Minus_0" Bin.thy
    23     "norm_Bcons Minus False = Bcons Minus False"
    23     "norm_Bcons MinusSign False = Bcons MinusSign False"
    24  (fn _ => [(Simp_tac 1)]);
    24  (fn _ => [(Simp_tac 1)]);
    25 
    25 
    26 qed_goal "norm_Bcons_Minus_1" Bin.thy
    26 qed_goal "norm_Bcons_Minus_1" Bin.thy
    27     "norm_Bcons Minus True = Minus"
    27     "norm_Bcons MinusSign True = MinusSign"
    28  (fn _ => [(Simp_tac 1)]);
    28  (fn _ => [(Simp_tac 1)]);
    29 
    29 
    30 qed_goal "norm_Bcons_Bcons" Bin.thy
    30 qed_goal "norm_Bcons_Bcons" Bin.thy
    31     "norm_Bcons (Bcons w x) b = Bcons (Bcons w x) b"
    31     "norm_Bcons (Bcons w x) b = Bcons (Bcons w x) b"
    32  (fn _ => [(Simp_tac 1)]);
    32  (fn _ => [(Simp_tac 1)]);
    72 qed_goal "bin_add_Bcons_Bcons0" Bin.thy
    72 qed_goal "bin_add_Bcons_Bcons0" Bin.thy
    73     "bin_add (Bcons v False) (Bcons w y) = norm_Bcons (bin_add v w) y"
    73     "bin_add (Bcons v False) (Bcons w y) = norm_Bcons (bin_add v w) y"
    74  (fn _ => [(simp_tac (!simpset addsimps [lemma]) 1)]);
    74  (fn _ => [(simp_tac (!simpset addsimps [lemma]) 1)]);
    75 
    75 
    76 qed_goal "bin_add_Bcons_Plus" Bin.thy
    76 qed_goal "bin_add_Bcons_Plus" Bin.thy
    77     "bin_add (Bcons v x) Plus = Bcons v x"
    77     "bin_add (Bcons v x) PlusSign = Bcons v x"
    78  (fn _ => [(Simp_tac 1)]);
    78  (fn _ => [(Simp_tac 1)]);
    79 
    79 
    80 qed_goal "bin_add_Bcons_Minus" Bin.thy
    80 qed_goal "bin_add_Bcons_Minus" Bin.thy
    81     "bin_add (Bcons v x) Minus = bin_pred (Bcons v x)"
    81     "bin_add (Bcons v x) MinusSign = bin_pred (Bcons v x)"
    82  (fn _ => [(Simp_tac 1)]);
    82  (fn _ => [(Simp_tac 1)]);
    83 
    83 
    84 qed_goal "bin_add_Bcons_Bcons" Bin.thy
    84 qed_goal "bin_add_Bcons_Bcons" Bin.thy
    85     "bin_add (Bcons v x) (Bcons w y) = \
    85     "bin_add (Bcons v x) (Bcons w y) = \
    86 \    norm_Bcons(bin_add v (if x & y then (bin_succ w) else w)) (x~= y)"
    86 \    norm_Bcons(bin_add v (if x & y then (bin_succ w) else w)) (x~= y)"
   209   by (asm_full_simp_tac 
   209   by (asm_full_simp_tac 
   210       (HOL_ss addsimps[zadd_assoc,zadd_0,zadd_0_right, 
   210       (HOL_ss addsimps[zadd_assoc,zadd_0,zadd_0_right, 
   211                        zadd_zminus_inverse2]) 1); 
   211                        zadd_zminus_inverse2]) 1); 
   212 val iob_eq_eq_diff_0 = result(); 
   212 val iob_eq_eq_diff_0 = result(); 
   213 
   213 
   214 goal Bin.thy "(integ_of_bin Plus = $# 0) = True"; 
   214 goal Bin.thy "(integ_of_bin PlusSign = $# 0) = True"; 
   215   by (stac iob_Plus 1); by (Simp_tac 1); 
   215   by (stac iob_Plus 1); by (Simp_tac 1); 
   216 val iob_Plus_eq_0 = result(); 
   216 val iob_Plus_eq_0 = result(); 
   217 
   217 
   218 goal Bin.thy "(integ_of_bin Minus = $# 0) = False"; 
   218 goal Bin.thy "(integ_of_bin MinusSign = $# 0) = False"; 
   219   by (stac iob_Minus 1); 
   219   by (stac iob_Minus 1); 
   220   by (Simp_tac 1);
   220   by (Simp_tac 1);
   221 val iob_Minus_not_eq_0 = result(); 
   221 val iob_Minus_not_eq_0 = result(); 
   222 
   222 
   223 goal Bin.thy 
   223 goal Bin.thy 
   240     "integ_of_bin x < integ_of_bin y \
   240     "integ_of_bin x < integ_of_bin y \
   241 \    = (integ_of_bin (bin_add x (bin_minus y)) < $# 0)";
   241 \    = (integ_of_bin (bin_add x (bin_minus y)) < $# 0)";
   242   by (Simp_tac 1); 
   242   by (Simp_tac 1); 
   243 val iob_less_eq_diff_lt_0 = result(); 
   243 val iob_less_eq_diff_lt_0 = result(); 
   244 
   244 
   245 goal Bin.thy "(integ_of_bin Plus < $# 0) = False"; 
   245 goal Bin.thy "(integ_of_bin PlusSign < $# 0) = False"; 
   246   by (stac iob_Plus 1); by (Simp_tac 1); 
   246   by (stac iob_Plus 1); by (Simp_tac 1); 
   247 val iob_Plus_not_lt_0 = result(); 
   247 val iob_Plus_not_lt_0 = result(); 
   248 
   248 
   249 goal Bin.thy "(integ_of_bin Minus < $# 0) = True"; 
   249 goal Bin.thy "(integ_of_bin MinusSign < $# 0) = True"; 
   250   by (stac iob_Minus 1); by (Simp_tac 1);
   250   by (stac iob_Minus 1); by (Simp_tac 1);
   251 val iob_Minus_lt_0 = result(); 
   251 val iob_Minus_lt_0 = result(); 
   252 
   252 
   253 goal Bin.thy 
   253 goal Bin.thy 
   254     "(integ_of_bin (Bcons w x) < $# 0) = (integ_of_bin w < $# 0)"; 
   254     "(integ_of_bin (Bcons w x) < $# 0) = (integ_of_bin w < $# 0)";