src/ZF/int_arith.ML
author wenzelm
Sat Oct 17 00:52:37 2009 +0200 (2009-10-17)
changeset 32957 675c0c7e6a37
parent 32155 e2bf2f73b0c8
child 35020 862a20ffa8e2
permissions -rw-r--r--
explicitly qualify Drule.standard;
wenzelm@23146
     1
(*  Title:      ZF/int_arith.ML
wenzelm@23146
     2
    Author:     Larry Paulson
wenzelm@23146
     3
wenzelm@23146
     4
Simprocs for linear arithmetic.
wenzelm@23146
     5
*)
wenzelm@23146
     6
wenzelm@23146
     7
structure Int_Numeral_Simprocs =
wenzelm@23146
     8
struct
wenzelm@23146
     9
wenzelm@23146
    10
(*Utilities*)
wenzelm@23146
    11
wenzelm@27237
    12
fun mk_numeral n = @{const integ_of} $ NumeralSyntax.mk_bin n;
wenzelm@23146
    13
wenzelm@23146
    14
(*Decodes a binary INTEGER*)
wenzelm@27237
    15
fun dest_numeral (Const(@{const_name integ_of}, _) $ w) =
wenzelm@23146
    16
     (NumeralSyntax.dest_bin w
wenzelm@23146
    17
      handle Match => raise TERM("Int_Numeral_Simprocs.dest_numeral:1", [w]))
wenzelm@23146
    18
  | dest_numeral t =  raise TERM("Int_Numeral_Simprocs.dest_numeral:2", [t]);
wenzelm@23146
    19
wenzelm@23146
    20
fun find_first_numeral past (t::terms) =
wenzelm@23146
    21
        ((dest_numeral t, rev past @ terms)
wenzelm@23146
    22
         handle TERM _ => find_first_numeral (t::past) terms)
wenzelm@23146
    23
  | find_first_numeral past [] = raise TERM("find_first_numeral", []);
wenzelm@23146
    24
wenzelm@23146
    25
val zero = mk_numeral 0;
wenzelm@26059
    26
val mk_plus = FOLogic.mk_binop @{const_name "zadd"};
wenzelm@23146
    27
wenzelm@23146
    28
(*Thus mk_sum[t] yields t+#0; longer sums don't have a trailing zero*)
wenzelm@23146
    29
fun mk_sum []        = zero
wenzelm@23146
    30
  | mk_sum [t,u]     = mk_plus (t, u)
wenzelm@23146
    31
  | mk_sum (t :: ts) = mk_plus (t, mk_sum ts);
wenzelm@23146
    32
wenzelm@23146
    33
(*this version ALWAYS includes a trailing zero*)
wenzelm@23146
    34
fun long_mk_sum []        = zero
wenzelm@23146
    35
  | long_mk_sum (t :: ts) = mk_plus (t, mk_sum ts);
wenzelm@23146
    36
wenzelm@26190
    37
val dest_plus = FOLogic.dest_bin @{const_name "zadd"} @{typ i};
wenzelm@23146
    38
wenzelm@23146
    39
(*decompose additions AND subtractions as a sum*)
wenzelm@26059
    40
fun dest_summing (pos, Const (@{const_name "zadd"}, _) $ t $ u, ts) =
wenzelm@23146
    41
        dest_summing (pos, t, dest_summing (pos, u, ts))
wenzelm@26059
    42
  | dest_summing (pos, Const (@{const_name "zdiff"}, _) $ t $ u, ts) =
wenzelm@23146
    43
        dest_summing (pos, t, dest_summing (not pos, u, ts))
wenzelm@23146
    44
  | dest_summing (pos, t, ts) =
wenzelm@27237
    45
        if pos then t::ts else @{const zminus} $ t :: ts;
wenzelm@23146
    46
wenzelm@23146
    47
fun dest_sum t = dest_summing (true, t, []);
wenzelm@23146
    48
wenzelm@26059
    49
val mk_diff = FOLogic.mk_binop @{const_name "zdiff"};
wenzelm@26190
    50
val dest_diff = FOLogic.dest_bin @{const_name "zdiff"} @{typ i};
wenzelm@23146
    51
wenzelm@23146
    52
val one = mk_numeral 1;
wenzelm@26059
    53
val mk_times = FOLogic.mk_binop @{const_name "zmult"};
wenzelm@23146
    54
wenzelm@23146
    55
fun mk_prod [] = one
wenzelm@23146
    56
  | mk_prod [t] = t
wenzelm@23146
    57
  | mk_prod (t :: ts) = if t = one then mk_prod ts
wenzelm@23146
    58
                        else mk_times (t, mk_prod ts);
wenzelm@23146
    59
wenzelm@26190
    60
val dest_times = FOLogic.dest_bin @{const_name "zmult"} @{typ i};
wenzelm@23146
    61
wenzelm@23146
    62
fun dest_prod t =
wenzelm@23146
    63
      let val (t,u) = dest_times t
wenzelm@23146
    64
      in  dest_prod t @ dest_prod u  end
wenzelm@23146
    65
      handle TERM _ => [t];
wenzelm@23146
    66
wenzelm@23146
    67
(*DON'T do the obvious simplifications; that would create special cases*)
wenzelm@23146
    68
fun mk_coeff (k, t) = mk_times (mk_numeral k, t);
wenzelm@23146
    69
wenzelm@23146
    70
(*Express t as a product of (possibly) a numeral with other sorted terms*)
wenzelm@26059
    71
fun dest_coeff sign (Const (@{const_name "zminus"}, _) $ t) = dest_coeff (~sign) t
wenzelm@23146
    72
  | dest_coeff sign t =
wenzelm@29269
    73
    let val ts = sort TermOrd.term_ord (dest_prod t)
wenzelm@23146
    74
        val (n, ts') = find_first_numeral [] ts
wenzelm@23146
    75
                          handle TERM _ => (1, ts)
wenzelm@23146
    76
    in (sign*n, mk_prod ts') end;
wenzelm@23146
    77
wenzelm@23146
    78
(*Find first coefficient-term THAT MATCHES u*)
wenzelm@23146
    79
fun find_first_coeff past u [] = raise TERM("find_first_coeff", [])
wenzelm@23146
    80
  | find_first_coeff past u (t::terms) =
wenzelm@23146
    81
        let val (n,u') = dest_coeff 1 t
wenzelm@23146
    82
        in  if u aconv u' then (n, rev past @ terms)
wenzelm@23146
    83
                          else find_first_coeff (t::past) u terms
wenzelm@23146
    84
        end
wenzelm@23146
    85
        handle TERM _ => find_first_coeff (t::past) u terms;
wenzelm@23146
    86
wenzelm@23146
    87
wenzelm@23146
    88
(*Simplify #1*n and n*#1 to n*)
wenzelm@24893
    89
val add_0s = [@{thm zadd_0_intify}, @{thm zadd_0_right_intify}];
wenzelm@23146
    90
wenzelm@24893
    91
val mult_1s = [@{thm zmult_1_intify}, @{thm zmult_1_right_intify},
wenzelm@24893
    92
               @{thm zmult_minus1}, @{thm zmult_minus1_right}];
wenzelm@23146
    93
wenzelm@24893
    94
val tc_rules = [@{thm integ_of_type}, @{thm intify_in_int},
wenzelm@24893
    95
                @{thm int_of_type}, @{thm zadd_type}, @{thm zdiff_type}, @{thm zmult_type}] @ 
wenzelm@24893
    96
               @{thms bin.intros};
wenzelm@24893
    97
val intifys = [@{thm intify_ident}, @{thm zadd_intify1}, @{thm zadd_intify2},
wenzelm@24893
    98
               @{thm zdiff_intify1}, @{thm zdiff_intify2}, @{thm zmult_intify1}, @{thm zmult_intify2},
wenzelm@24893
    99
               @{thm zless_intify1}, @{thm zless_intify2}, @{thm zle_intify1}, @{thm zle_intify2}];
wenzelm@23146
   100
wenzelm@23146
   101
(*To perform binary arithmetic*)
wenzelm@24893
   102
val bin_simps = [@{thm add_integ_of_left}] @ @{thms bin_arith_simps} @ @{thms bin_rel_simps};
wenzelm@23146
   103
wenzelm@23146
   104
(*To evaluate binary negations of coefficients*)
wenzelm@24893
   105
val zminus_simps = @{thms NCons_simps} @
wenzelm@24893
   106
                   [@{thm integ_of_minus} RS sym,
wenzelm@24893
   107
                    @{thm bin_minus_1}, @{thm bin_minus_0}, @{thm bin_minus_Pls}, @{thm bin_minus_Min},
wenzelm@24893
   108
                    @{thm bin_pred_1}, @{thm bin_pred_0}, @{thm bin_pred_Pls}, @{thm bin_pred_Min}];
wenzelm@23146
   109
wenzelm@23146
   110
(*To let us treat subtraction as addition*)
wenzelm@24893
   111
val diff_simps = [@{thm zdiff_def}, @{thm zminus_zadd_distrib}, @{thm zminus_zminus}];
wenzelm@23146
   112
wenzelm@23146
   113
(*push the unary minus down: - x * y = x * - y *)
wenzelm@23146
   114
val int_minus_mult_eq_1_to_2 =
wenzelm@32957
   115
    [@{thm zmult_zminus}, @{thm zmult_zminus_right} RS sym] MRS trans |> Drule.standard;
wenzelm@23146
   116
wenzelm@23146
   117
(*to extract again any uncancelled minuses*)
wenzelm@23146
   118
val int_minus_from_mult_simps =
wenzelm@24893
   119
    [@{thm zminus_zminus}, @{thm zmult_zminus}, @{thm zmult_zminus_right}];
wenzelm@23146
   120
wenzelm@23146
   121
(*combine unary minus with numeric literals, however nested within a product*)
wenzelm@23146
   122
val int_mult_minus_simps =
wenzelm@24893
   123
    [@{thm zmult_assoc}, @{thm zmult_zminus} RS sym, int_minus_mult_eq_1_to_2];
wenzelm@23146
   124
wenzelm@32155
   125
fun prep_simproc thy (name, pats, proc) =
wenzelm@32155
   126
  Simplifier.simproc thy name pats proc;
wenzelm@23146
   127
wenzelm@23146
   128
structure CancelNumeralsCommon =
wenzelm@23146
   129
  struct
wenzelm@23146
   130
  val mk_sum            = (fn T:typ => mk_sum)
wenzelm@23146
   131
  val dest_sum          = dest_sum
wenzelm@23146
   132
  val mk_coeff          = mk_coeff
wenzelm@23146
   133
  val dest_coeff        = dest_coeff 1
wenzelm@23146
   134
  val find_first_coeff  = find_first_coeff []
wenzelm@23146
   135
  fun trans_tac _       = ArithData.gen_trans_tac iff_trans
wenzelm@23146
   136
wenzelm@24893
   137
  val norm_ss1 = ZF_ss addsimps add_0s @ mult_1s @ diff_simps @ zminus_simps @ @{thms zadd_ac}
wenzelm@23146
   138
  val norm_ss2 = ZF_ss addsimps bin_simps @ int_mult_minus_simps @ intifys
wenzelm@24893
   139
  val norm_ss3 = ZF_ss addsimps int_minus_from_mult_simps @ @{thms zadd_ac} @ @{thms zmult_ac} @ tc_rules @ intifys
wenzelm@23146
   140
  fun norm_tac ss =
wenzelm@23146
   141
    ALLGOALS (asm_simp_tac (Simplifier.inherit_context ss norm_ss1))
wenzelm@23146
   142
    THEN ALLGOALS (asm_simp_tac (Simplifier.inherit_context ss norm_ss2))
wenzelm@23146
   143
    THEN ALLGOALS (asm_simp_tac (Simplifier.inherit_context ss norm_ss3))
wenzelm@23146
   144
wenzelm@23146
   145
  val numeral_simp_ss = ZF_ss addsimps add_0s @ bin_simps @ tc_rules @ intifys
wenzelm@23146
   146
  fun numeral_simp_tac ss =
wenzelm@23146
   147
    ALLGOALS (simp_tac (Simplifier.inherit_context ss numeral_simp_ss))
wenzelm@32149
   148
    THEN ALLGOALS (asm_simp_tac (simpset_of (Simplifier.the_context ss)))
wenzelm@23146
   149
  val simplify_meta_eq  = ArithData.simplify_meta_eq (add_0s @ mult_1s)
wenzelm@23146
   150
  end;
wenzelm@23146
   151
wenzelm@23146
   152
wenzelm@23146
   153
structure EqCancelNumerals = CancelNumeralsFun
wenzelm@23146
   154
 (open CancelNumeralsCommon
wenzelm@23146
   155
  val prove_conv = ArithData.prove_conv "inteq_cancel_numerals"
wenzelm@23146
   156
  val mk_bal   = FOLogic.mk_eq
wenzelm@23146
   157
  val dest_bal = FOLogic.dest_eq
wenzelm@27237
   158
  val bal_add1 = @{thm eq_add_iff1} RS iff_trans
wenzelm@27237
   159
  val bal_add2 = @{thm eq_add_iff2} RS iff_trans
wenzelm@23146
   160
);
wenzelm@23146
   161
wenzelm@23146
   162
structure LessCancelNumerals = CancelNumeralsFun
wenzelm@23146
   163
 (open CancelNumeralsCommon
wenzelm@23146
   164
  val prove_conv = ArithData.prove_conv "intless_cancel_numerals"
wenzelm@26059
   165
  val mk_bal   = FOLogic.mk_binrel @{const_name "zless"}
wenzelm@26190
   166
  val dest_bal = FOLogic.dest_bin @{const_name "zless"} @{typ i}
wenzelm@27237
   167
  val bal_add1 = @{thm less_add_iff1} RS iff_trans
wenzelm@27237
   168
  val bal_add2 = @{thm less_add_iff2} RS iff_trans
wenzelm@23146
   169
);
wenzelm@23146
   170
wenzelm@23146
   171
structure LeCancelNumerals = CancelNumeralsFun
wenzelm@23146
   172
 (open CancelNumeralsCommon
wenzelm@23146
   173
  val prove_conv = ArithData.prove_conv "intle_cancel_numerals"
wenzelm@26059
   174
  val mk_bal   = FOLogic.mk_binrel @{const_name "zle"}
wenzelm@26190
   175
  val dest_bal = FOLogic.dest_bin @{const_name "zle"} @{typ i}
wenzelm@27237
   176
  val bal_add1 = @{thm le_add_iff1} RS iff_trans
wenzelm@27237
   177
  val bal_add2 = @{thm le_add_iff2} RS iff_trans
wenzelm@23146
   178
);
wenzelm@23146
   179
wenzelm@23146
   180
val cancel_numerals =
wenzelm@32155
   181
  map (prep_simproc @{theory})
wenzelm@23146
   182
   [("inteq_cancel_numerals",
wenzelm@23146
   183
     ["l $+ m = n", "l = m $+ n",
wenzelm@23146
   184
      "l $- m = n", "l = m $- n",
wenzelm@23146
   185
      "l $* m = n", "l = m $* n"],
wenzelm@23146
   186
     K EqCancelNumerals.proc),
wenzelm@23146
   187
    ("intless_cancel_numerals",
wenzelm@23146
   188
     ["l $+ m $< n", "l $< m $+ n",
wenzelm@23146
   189
      "l $- m $< n", "l $< m $- n",
wenzelm@23146
   190
      "l $* m $< n", "l $< m $* n"],
wenzelm@23146
   191
     K LessCancelNumerals.proc),
wenzelm@23146
   192
    ("intle_cancel_numerals",
wenzelm@23146
   193
     ["l $+ m $<= n", "l $<= m $+ n",
wenzelm@23146
   194
      "l $- m $<= n", "l $<= m $- n",
wenzelm@23146
   195
      "l $* m $<= n", "l $<= m $* n"],
wenzelm@23146
   196
     K LeCancelNumerals.proc)];
wenzelm@23146
   197
wenzelm@23146
   198
wenzelm@23146
   199
(*version without the hyps argument*)
wenzelm@23146
   200
fun prove_conv_nohyps name tacs sg = ArithData.prove_conv name tacs sg [];
wenzelm@23146
   201
wenzelm@23146
   202
structure CombineNumeralsData =
wenzelm@23146
   203
  struct
wenzelm@24630
   204
  type coeff            = int
wenzelm@24630
   205
  val iszero            = (fn x => x = 0)
wenzelm@24630
   206
  val add               = op + 
wenzelm@23146
   207
  val mk_sum            = (fn T:typ => long_mk_sum) (*to work for #2*x $+ #3*x *)
wenzelm@23146
   208
  val dest_sum          = dest_sum
wenzelm@23146
   209
  val mk_coeff          = mk_coeff
wenzelm@23146
   210
  val dest_coeff        = dest_coeff 1
wenzelm@27237
   211
  val left_distrib      = @{thm left_zadd_zmult_distrib} RS trans
wenzelm@23146
   212
  val prove_conv        = prove_conv_nohyps "int_combine_numerals"
wenzelm@23146
   213
  fun trans_tac _       = ArithData.gen_trans_tac trans
wenzelm@23146
   214
wenzelm@24893
   215
  val norm_ss1 = ZF_ss addsimps add_0s @ mult_1s @ diff_simps @ zminus_simps @ @{thms zadd_ac} @ intifys
wenzelm@23146
   216
  val norm_ss2 = ZF_ss addsimps bin_simps @ int_mult_minus_simps @ intifys
wenzelm@24893
   217
  val norm_ss3 = ZF_ss addsimps int_minus_from_mult_simps @ @{thms zadd_ac} @ @{thms zmult_ac} @ tc_rules @ intifys
wenzelm@23146
   218
  fun norm_tac ss =
wenzelm@23146
   219
    ALLGOALS (asm_simp_tac (Simplifier.inherit_context ss norm_ss1))
wenzelm@23146
   220
    THEN ALLGOALS (asm_simp_tac (Simplifier.inherit_context ss norm_ss2))
wenzelm@23146
   221
    THEN ALLGOALS (asm_simp_tac (Simplifier.inherit_context ss norm_ss3))
wenzelm@23146
   222
wenzelm@23146
   223
  val numeral_simp_ss = ZF_ss addsimps add_0s @ bin_simps @ tc_rules @ intifys
wenzelm@23146
   224
  fun numeral_simp_tac ss =
wenzelm@23146
   225
    ALLGOALS (simp_tac (Simplifier.inherit_context ss numeral_simp_ss))
wenzelm@23146
   226
  val simplify_meta_eq  = ArithData.simplify_meta_eq (add_0s @ mult_1s)
wenzelm@23146
   227
  end;
wenzelm@23146
   228
wenzelm@23146
   229
structure CombineNumerals = CombineNumeralsFun(CombineNumeralsData);
wenzelm@23146
   230
wenzelm@23146
   231
val combine_numerals =
wenzelm@32155
   232
  prep_simproc @{theory}
wenzelm@32155
   233
    ("int_combine_numerals", ["i $+ j", "i $- j"], K CombineNumerals.proc);
wenzelm@23146
   234
wenzelm@23146
   235
wenzelm@23146
   236
wenzelm@23146
   237
(** Constant folding for integer multiplication **)
wenzelm@23146
   238
wenzelm@23146
   239
(*The trick is to regard products as sums, e.g. #3 $* x $* #4 as
wenzelm@23146
   240
  the "sum" of #3, x, #4; the literals are then multiplied*)
wenzelm@23146
   241
wenzelm@23146
   242
wenzelm@23146
   243
structure CombineNumeralsProdData =
wenzelm@23146
   244
  struct
wenzelm@24630
   245
  type coeff            = int
wenzelm@24630
   246
  val iszero            = (fn x => x = 0)
wenzelm@24630
   247
  val add               = op *
wenzelm@23146
   248
  val mk_sum            = (fn T:typ => mk_prod)
wenzelm@23146
   249
  val dest_sum          = dest_prod
wenzelm@23146
   250
  fun mk_coeff(k,t) = if t=one then mk_numeral k
wenzelm@23146
   251
                      else raise TERM("mk_coeff", [])
wenzelm@23146
   252
  fun dest_coeff t = (dest_numeral t, one)  (*We ONLY want pure numerals.*)
wenzelm@24893
   253
  val left_distrib      = @{thm zmult_assoc} RS sym RS trans
wenzelm@23146
   254
  val prove_conv        = prove_conv_nohyps "int_combine_numerals_prod"
wenzelm@23146
   255
  fun trans_tac _       = ArithData.gen_trans_tac trans
wenzelm@23146
   256
wenzelm@23146
   257
wenzelm@23146
   258
wenzelm@23146
   259
val norm_ss1 = ZF_ss addsimps mult_1s @ diff_simps @ zminus_simps
wenzelm@24893
   260
  val norm_ss2 = ZF_ss addsimps [@{thm zmult_zminus_right} RS sym] @
wenzelm@24893
   261
    bin_simps @ @{thms zmult_ac} @ tc_rules @ intifys
wenzelm@23146
   262
  fun norm_tac ss =
wenzelm@23146
   263
    ALLGOALS (asm_simp_tac (Simplifier.inherit_context ss norm_ss1))
wenzelm@23146
   264
    THEN ALLGOALS (asm_simp_tac (Simplifier.inherit_context ss norm_ss2))
wenzelm@23146
   265
wenzelm@23146
   266
  val numeral_simp_ss = ZF_ss addsimps bin_simps @ tc_rules @ intifys
wenzelm@23146
   267
  fun numeral_simp_tac ss =
wenzelm@23146
   268
    ALLGOALS (simp_tac (Simplifier.inherit_context ss numeral_simp_ss))
wenzelm@23146
   269
  val simplify_meta_eq  = ArithData.simplify_meta_eq (mult_1s);
wenzelm@23146
   270
  end;
wenzelm@23146
   271
wenzelm@23146
   272
wenzelm@23146
   273
structure CombineNumeralsProd = CombineNumeralsFun(CombineNumeralsProdData);
wenzelm@23146
   274
wenzelm@23146
   275
val combine_numerals_prod =
wenzelm@32155
   276
  prep_simproc @{theory}
wenzelm@32155
   277
    ("int_combine_numerals_prod", ["i $* j"], K CombineNumeralsProd.proc);
wenzelm@23146
   278
wenzelm@23146
   279
end;
wenzelm@23146
   280
wenzelm@23146
   281
wenzelm@23146
   282
Addsimprocs Int_Numeral_Simprocs.cancel_numerals;
wenzelm@23146
   283
Addsimprocs [Int_Numeral_Simprocs.combine_numerals,
wenzelm@23146
   284
             Int_Numeral_Simprocs.combine_numerals_prod];
wenzelm@23146
   285
wenzelm@23146
   286
wenzelm@23146
   287
(*examples:*)
wenzelm@23146
   288
(*
wenzelm@23146
   289
print_depth 22;
wenzelm@23146
   290
set timing;
wenzelm@23146
   291
set trace_simp;
wenzelm@23146
   292
fun test s = (Goal s; by (Asm_simp_tac 1));
wenzelm@23146
   293
val sg = #sign (rep_thm (topthm()));
wenzelm@23146
   294
val t = FOLogic.dest_Trueprop (Logic.strip_assums_concl(getgoal 1));
wenzelm@23146
   295
val (t,_) = FOLogic.dest_eq t;
wenzelm@23146
   296
wenzelm@23146
   297
(*combine_numerals_prod (products of separate literals) *)
wenzelm@23146
   298
test "#5 $* x $* #3 = y";
wenzelm@23146
   299
wenzelm@23146
   300
test "y2 $+ ?x42 = y $+ y2";
wenzelm@23146
   301
wenzelm@23146
   302
test "oo : int ==> l $+ (l $+ #2) $+ oo = oo";
wenzelm@23146
   303
wenzelm@23146
   304
test "#9$*x $+ y = x$*#23 $+ z";
wenzelm@23146
   305
test "y $+ x = x $+ z";
wenzelm@23146
   306
wenzelm@23146
   307
test "x : int ==> x $+ y $+ z = x $+ z";
wenzelm@23146
   308
test "x : int ==> y $+ (z $+ x) = z $+ x";
wenzelm@23146
   309
test "z : int ==> x $+ y $+ z = (z $+ y) $+ (x $+ w)";
wenzelm@23146
   310
test "z : int ==> x$*y $+ z = (z $+ y) $+ (y$*x $+ w)";
wenzelm@23146
   311
wenzelm@23146
   312
test "#-3 $* x $+ y $<= x $* #2 $+ z";
wenzelm@23146
   313
test "y $+ x $<= x $+ z";
wenzelm@23146
   314
test "x $+ y $+ z $<= x $+ z";
wenzelm@23146
   315
wenzelm@23146
   316
test "y $+ (z $+ x) $< z $+ x";
wenzelm@23146
   317
test "x $+ y $+ z $< (z $+ y) $+ (x $+ w)";
wenzelm@23146
   318
test "x$*y $+ z $< (z $+ y) $+ (y$*x $+ w)";
wenzelm@23146
   319
wenzelm@23146
   320
test "l $+ #2 $+ #2 $+ #2 $+ (l $+ #2) $+ (oo $+ #2) = uu";
wenzelm@23146
   321
test "u : int ==> #2 $* u = u";
wenzelm@23146
   322
test "(i $+ j $+ #12 $+ k) $- #15 = y";
wenzelm@23146
   323
test "(i $+ j $+ #12 $+ k) $- #5 = y";
wenzelm@23146
   324
wenzelm@23146
   325
test "y $- b $< b";
wenzelm@23146
   326
test "y $- (#3 $* b $+ c) $< b $- #2 $* c";
wenzelm@23146
   327
wenzelm@23146
   328
test "(#2 $* x $- (u $* v) $+ y) $- v $* #3 $* u = w";
wenzelm@23146
   329
test "(#2 $* x $* u $* v $+ (u $* v) $* #4 $+ y) $- v $* u $* #4 = w";
wenzelm@23146
   330
test "(#2 $* x $* u $* v $+ (u $* v) $* #4 $+ y) $- v $* u = w";
wenzelm@23146
   331
test "u $* v $- (x $* u $* v $+ (u $* v) $* #4 $+ y) = w";
wenzelm@23146
   332
wenzelm@23146
   333
test "(i $+ j $+ #12 $+ k) = u $+ #15 $+ y";
wenzelm@23146
   334
test "(i $+ j $* #2 $+ #12 $+ k) = j $+ #5 $+ y";
wenzelm@23146
   335
wenzelm@23146
   336
test "#2 $* y $+ #3 $* z $+ #6 $* w $+ #2 $* y $+ #3 $* z $+ #2 $* u = #2 $* y' $+ #3 $* z' $+ #6 $* w' $+ #2 $* y' $+ #3 $* z' $+ u $+ vv";
wenzelm@23146
   337
wenzelm@23146
   338
test "a $+ $-(b$+c) $+ b = d";
wenzelm@23146
   339
test "a $+ $-(b$+c) $- b = d";
wenzelm@23146
   340
wenzelm@23146
   341
(*negative numerals*)
wenzelm@23146
   342
test "(i $+ j $+ #-2 $+ k) $- (u $+ #5 $+ y) = zz";
wenzelm@23146
   343
test "(i $+ j $+ #-3 $+ k) $< u $+ #5 $+ y";
wenzelm@23146
   344
test "(i $+ j $+ #3 $+ k) $< u $+ #-6 $+ y";
wenzelm@23146
   345
test "(i $+ j $+ #-12 $+ k) $- #15 = y";
wenzelm@23146
   346
test "(i $+ j $+ #12 $+ k) $- #-15 = y";
wenzelm@23146
   347
test "(i $+ j $+ #-12 $+ k) $- #-15 = y";
wenzelm@23146
   348
wenzelm@23146
   349
(*Multiplying separated numerals*)
wenzelm@23146
   350
Goal "#6 $* ($# x $* #2) =  uu";
wenzelm@23146
   351
Goal "#4 $* ($# x $* $# x) $* (#2 $* $# x) =  uu";
wenzelm@23146
   352
*)
wenzelm@23146
   353