(***************************************************************************)
(* Formalization of the Chou, Gao and Zhang's decision procedure.          *)
(* Julien Narboux (Julien@narboux.fr)                                      *)
(* LIX/INRIA FUTURS 2004-2006                                              *)
(* University of Strasbourg 2008                                           *)
(***************************************************************************)
Require Export field_general_properties.
(** We define our own field tactic based on the new ring *)
(** This tactic is geared toward automation because it does not generate non nullity conditions but it assumes that we know that the denominators of the input are not zero (syntactically !) *)
(** This tactic is also used to reduce a term to a unique fraction *)
(** This tactic is not reflexive, it is basically a reduction to the same denominators but even using the legacy ring it is quicker than the legacy field tactic on our examples *)
Ltac assumption_or_ax := assumption || apply chara_not_2.
Ltac solve_conds :=
repeat split;
repeat (assumption_or_ax ||
apply nonzeromult ||
apply nonzerodiv ||
apply nonzeroinv).
Ltac smart_field := field; solve_conds.
Ltac smart_field_simplify_eq := field_simplify_eq;solve_conds.

(* Specifications: *)
Lemma same_denom_add_1 : forall a b c d : F,
b<>0 ->
d<>0 ->
a/b + c/d = (a*d+c*b) / (b*d).
Lemma same_denom_add_2 : forall a b c : F,
b<>0 ->
a/b + c = (a+c*b) / b.
Lemma same_denom_add_3 : forall a c d : F,
d<>0 ->
a + c/d = (a*d+c) / d.
Lemma same_denom_min_1 : forall a b c d : F,
b<>0 ->
d<>0 ->
a/b - c/d = (a*d-c*b) / (b*d).
Lemma same_denom_min_2 : forall a b c : F,
b<>0 ->
a/b - c = (a-c*b) / b.
Lemma same_denom_min_3 : forall a  c d : F,
d<>0 ->
a - (c/d) = (a*d-c) / d.
Lemma same_denom_mul_1 : forall a b c d : F,
b<>0 ->
d<>0 ->
a/b * c/d = (a*c) / (b*d).
Lemma same_denom_mul_2 : forall a b c : F,
b<>0 ->
a/b * c = (a*c) / b.
Lemma same_denom_mul_3 : forall a c d : F,
d<>0 ->
a * (c/d) = (a*c) / d.
Lemma same_denom_div_1 : forall a b c d : F,
b<>0 ->
c/d<>0 ->
d<>0 ->
(a/b) / (c/d) = (a*d) / (b*c).
Lemma invariant_div_1 : forall b c d,
b<>0 ->
c/d<>0 ->
d<>0 ->
b*c <> 0.
Lemma same_denom_div_3 : forall a c d : F,
c/d<>0 ->
d<>0 ->
a / (c/d) = (a*d) / c.
Lemma invariant_div_3 : forall c d,
c/d<>0 ->
d<>0 ->
c <> 0.
Lemma same_denom_div_2 : forall a b c : F,
b<>0 ->
c<>0 ->
(a/b) / c = a / (b*c).
Lemma remove_inv : forall a : F,
Finv a = 1/a.
Lemma remove_opp : forall a : F,
-a = 0-a.
Lemma simp_1 : forall a : F,
a*0 = 0.
Lemma simp_2 : forall a : F,
0*a = 0.
Lemma simp_3 : forall a : F,
1*a = a.
Lemma simp_4 : forall a : F,
a*1 = a.
Lemma simp_5 : forall a : F,
0+a = a.
Lemma simp_6: forall a : F,
a+0 = a.
Lemma simp_7: forall a : F,
a-0 = a.
Lemma simp_8: forall a : F,
a-a = 0.
Lemma simp_9: forall a : F,
-a+a = 0.
Lemma simp_10: forall a b : F,
a+ -(b)= a-b.
Lemma simp_11 : -0=0.
Lemma simp_12 : forall a, - - a=a.
Lemma simp_13 : forall a b, - a * -b=a*b.
Lemma simp_14 : forall a b, (- a) * b=-(a*b).
Lemma simp_15 : forall a b, a * (- b)=-(a*b).
Hint Rewrite
simp_1 simp_2 simp_3 simp_4 simp_5
simp_6 simp_7 simp_8 simp_9 simp_10
simp_11 simp_12 simp_13 simp_14 simp_15
: ring_simplification.