I am trying to solve the equation of form
A * B * C * D * E = F
where is *some complicated left associative operation.
Currently, all opaque (including *and Aafter F), and it can be made transparent using autounfold with M_db.
The problem is that if I globally spread the definition in a formula, simplification will take forever. Instead, I want to deploy first A * B, apply some tactics to reduce it to normal form X, and then do the same with X * C, etc.
Any idea how I accomplished this? Here is my current approach, but in Aeither at Adoes not work. In addition, it is not clear to me whether this is the correct structure, or whether it reduce_mshould return something.
Ltac reduce_m M :=
match M with
| ?A × ?B => reduce_m A;
reduce_m B;
simpl;
autorewrite with C_db
| ?A => autounfold with M_db (* in A *);
simpl;
autorewrite with C_db
end.
Ltac simpl_m :=
match goal with
| [|- ?M = _ ] => reduce_m M
end.
Minimal example:
Require Import Arith.
Definition add_f (f g : nat -> nat) := fun x => f x + g x.
Infix "+" := add_f.
Definition f := fun x => if x =? 4 then 1 else 0.
Definition g := fun x => if x <=? 4 then 3 else 0.
Definition h := fun x => if x =? 2 then 2 else 0.
Lemma ex : f + g + h = fun x => match x with
| 0 => 3
| 1 => 3
| 2 => 5
| 3 => 3
| 4 => 4
| _ => 0
end.