I have a sequence of applications in that way (f (f (f x))), being f an arbitrary function and any applications numbers sequences. I want to prove that f (x y) and (x (f y)), x = (f f f ...) and y = any value, it's equal. I need that proof in the code below:
Fixpoint r_nat {A : Type} (a : nat) : A -> (A -> A) -> A :=
match a with
|S n => fun (x0 : A) (a0 : A -> A) => r_nat n (a0 x0) a0
|0 => fun (x0 : A) (_ : A -> A) => x0
end.
Theorem homomo_nat : forall {T} (f : T -> T) (h : T) (x : nat), (r_nat x (f h) f) = f ((r_nat x) h f) .
compute.
??.
Qed.
I try unfolding and refining but doesn't work.
I moved the argument (x:nat)
before (h:T)
. That makes the induction hypothesis stronger - it holds for all h
. Then the proof is simply:
Theorem homomo_nat : forall {T} (f : T -> T) (x:nat) (h : T), (r_nat x (f h) f) = f ((r_nat x) h f) .
Proof.
induction x.
reflexivity.
intros. apply IHx.
Qed.
You can also "move the arguments around" with tactics to keep your original theorem if you prefer that... Start with intros; generalize dependent h.