src/ZF/arith_data.ML
changeset 16973 b2a894562b8f
parent 15965 f422f8283491
child 17877 67d5ab1cb0d8
equal deleted inserted replaced
16972:d3f9abe00712 16973:b2a894562b8f
    12   val nat_cancel: simproc list
    12   val nat_cancel: simproc list
    13   (*tools for use in similar applications*)
    13   (*tools for use in similar applications*)
    14   val gen_trans_tac: thm -> thm option -> tactic
    14   val gen_trans_tac: thm -> thm option -> tactic
    15   val prove_conv: string -> tactic list -> Sign.sg ->
    15   val prove_conv: string -> tactic list -> Sign.sg ->
    16                   thm list -> string list -> term * term -> thm option
    16                   thm list -> string list -> term * term -> thm option
    17   val simplify_meta_eq: thm list -> thm -> thm
    17   val simplify_meta_eq: thm list -> simpset -> thm -> thm
    18   (*debugging*)
    18   (*debugging*)
    19   structure EqCancelNumeralsData   : CANCEL_NUMERALS_DATA
    19   structure EqCancelNumeralsData   : CANCEL_NUMERALS_DATA
    20   structure LessCancelNumeralsData : CANCEL_NUMERALS_DATA
    20   structure LessCancelNumeralsData : CANCEL_NUMERALS_DATA
    21   structure DiffCancelNumeralsData : CANCEL_NUMERALS_DATA
    21   structure DiffCancelNumeralsData : CANCEL_NUMERALS_DATA
    22 end;
    22 end;
   126 val tc_rules = [natify_in_nat, add_type, diff_type, mult_type];
   126 val tc_rules = [natify_in_nat, add_type, diff_type, mult_type];
   127 val natifys = [natify_0, natify_ident, add_natify1, add_natify2,
   127 val natifys = [natify_0, natify_ident, add_natify1, add_natify2,
   128                diff_natify1, diff_natify2];
   128                diff_natify1, diff_natify2];
   129 
   129 
   130 (*Final simplification: cancel + and **)
   130 (*Final simplification: cancel + and **)
   131 fun simplify_meta_eq rules =
   131 fun simplify_meta_eq rules ss =
   132     mk_meta_eq o
   132     mk_meta_eq o
   133     simplify (FOL_ss addeqcongs[eq_cong2,iff_cong2]
   133     simplify (Simplifier.inherit_bounds ss FOL_ss addeqcongs[eq_cong2,iff_cong2]
   134                      delsimps iff_simps (*these could erase the whole rule!*)
   134                      delsimps iff_simps (*these could erase the whole rule!*)
   135                      addsimps rules);
   135                      addsimps rules);
   136 
   136 
   137 val final_rules = add_0s @ mult_1s @ [mult_0, mult_0_right];
   137 val final_rules = add_0s @ mult_1s @ [mult_0, mult_0_right];
   138 
   138 
   141   val mk_sum            = (fn T:typ => mk_sum)
   141   val mk_sum            = (fn T:typ => mk_sum)
   142   val dest_sum          = dest_sum
   142   val dest_sum          = dest_sum
   143   val mk_coeff          = mk_coeff
   143   val mk_coeff          = mk_coeff
   144   val dest_coeff        = dest_coeff
   144   val dest_coeff        = dest_coeff
   145   val find_first_coeff  = find_first_coeff []
   145   val find_first_coeff  = find_first_coeff []
   146   val norm_tac_ss1 = ZF_ss addsimps add_0s@add_succs@mult_1s@add_ac
   146   val norm_tac_ss1      = ZF_ss addsimps add_0s @ add_succs @ mult_1s @ add_ac
   147   val norm_tac_ss2 = ZF_ss addsimps add_0s@mult_1s@
   147   val norm_tac_ss2      = ZF_ss addsimps add_0s @ mult_1s @ add_ac @ mult_ac @ tc_rules @ natifys
   148                                     add_ac@mult_ac@tc_rules@natifys
   148   fun norm_tac ss =
   149   val norm_tac = ALLGOALS (asm_simp_tac norm_tac_ss1)
   149     ALLGOALS (asm_simp_tac (Simplifier.inherit_bounds ss norm_tac_ss1))
   150                  THEN ALLGOALS (asm_simp_tac norm_tac_ss2)
   150     THEN ALLGOALS (asm_simp_tac (Simplifier.inherit_bounds ss norm_tac_ss2))
   151   val numeral_simp_tac_ss = ZF_ss addsimps add_0s@tc_rules@natifys
   151   val numeral_simp_tac_ss = ZF_ss addsimps add_0s @ tc_rules @ natifys
   152   val numeral_simp_tac  = ALLGOALS (asm_simp_tac numeral_simp_tac_ss)
   152   fun numeral_simp_tac ss =
       
   153     ALLGOALS (asm_simp_tac (Simplifier.inherit_bounds ss numeral_simp_tac_ss))
   153   val simplify_meta_eq  = simplify_meta_eq final_rules
   154   val simplify_meta_eq  = simplify_meta_eq final_rules
   154   end;
   155   end;
   155 
   156 
   156 (** The functor argumnets are declared as separate structures
   157 (** The functor argumnets are declared as separate structures
   157     so that they can be exported to ease debugging. **)
   158     so that they can be exported to ease debugging. **)
   162   val prove_conv = prove_conv "nateq_cancel_numerals"
   163   val prove_conv = prove_conv "nateq_cancel_numerals"
   163   val mk_bal   = FOLogic.mk_eq
   164   val mk_bal   = FOLogic.mk_eq
   164   val dest_bal = FOLogic.dest_eq
   165   val dest_bal = FOLogic.dest_eq
   165   val bal_add1 = eq_add_iff RS iff_trans
   166   val bal_add1 = eq_add_iff RS iff_trans
   166   val bal_add2 = eq_add_iff RS iff_trans
   167   val bal_add2 = eq_add_iff RS iff_trans
   167   val trans_tac = gen_trans_tac iff_trans
   168   fun trans_tac _ = gen_trans_tac iff_trans
   168   end;
   169   end;
   169 
   170 
   170 structure EqCancelNumerals = CancelNumeralsFun(EqCancelNumeralsData);
   171 structure EqCancelNumerals = CancelNumeralsFun(EqCancelNumeralsData);
   171 
   172 
   172 structure LessCancelNumeralsData =
   173 structure LessCancelNumeralsData =
   175   val prove_conv = prove_conv "natless_cancel_numerals"
   176   val prove_conv = prove_conv "natless_cancel_numerals"
   176   val mk_bal   = FOLogic.mk_binrel "Ordinal.lt"
   177   val mk_bal   = FOLogic.mk_binrel "Ordinal.lt"
   177   val dest_bal = FOLogic.dest_bin "Ordinal.lt" iT
   178   val dest_bal = FOLogic.dest_bin "Ordinal.lt" iT
   178   val bal_add1 = less_add_iff RS iff_trans
   179   val bal_add1 = less_add_iff RS iff_trans
   179   val bal_add2 = less_add_iff RS iff_trans
   180   val bal_add2 = less_add_iff RS iff_trans
   180   val trans_tac = gen_trans_tac iff_trans
   181   fun trans_tac _ = gen_trans_tac iff_trans
   181   end;
   182   end;
   182 
   183 
   183 structure LessCancelNumerals = CancelNumeralsFun(LessCancelNumeralsData);
   184 structure LessCancelNumerals = CancelNumeralsFun(LessCancelNumeralsData);
   184 
   185 
   185 structure DiffCancelNumeralsData =
   186 structure DiffCancelNumeralsData =
   188   val prove_conv = prove_conv "natdiff_cancel_numerals"
   189   val prove_conv = prove_conv "natdiff_cancel_numerals"
   189   val mk_bal   = FOLogic.mk_binop "Arith.diff"
   190   val mk_bal   = FOLogic.mk_binop "Arith.diff"
   190   val dest_bal = FOLogic.dest_bin "Arith.diff" iT
   191   val dest_bal = FOLogic.dest_bin "Arith.diff" iT
   191   val bal_add1 = diff_add_eq RS trans
   192   val bal_add1 = diff_add_eq RS trans
   192   val bal_add2 = diff_add_eq RS trans
   193   val bal_add2 = diff_add_eq RS trans
   193   val trans_tac = gen_trans_tac trans
   194   fun trans_tac _ = gen_trans_tac trans
   194   end;
   195   end;
   195 
   196 
   196 structure DiffCancelNumerals = CancelNumeralsFun(DiffCancelNumeralsData);
   197 structure DiffCancelNumerals = CancelNumeralsFun(DiffCancelNumeralsData);
   197 
   198 
   198 
   199