I want to assert some lemmas at the top of the proof and re-use them for every future goal. I did:
Theorem add_comm_eauto_using:
forall n m: nat,
n + m = m + n.
Proof.
intros. induction n.
assert (H: forall n, n + 0 = n) by eauto using n_plus_zero_eq_n.
assert (H': forall n m, S (n + m) = n + S m) by eauto using Sn_plus_m_eq_n_plus_Sm.
- eauto with *.
but after I prove the base case the hypothesis dispear from the local context!
Why does that happen and how to I stop coq removing my local lemmas and keeping them in the local context in this proof forever? Ideally inside the Proof. body Qed.
body.
script:
Theorem n_plus_zero_eq_n:
forall n:nat,
n + 0 = n.
Proof.
intros.
induction n as [| n' IH].
- simpl. reflexivity.
- simpl. rewrite -> IH. reflexivity.
Qed.
Theorem Sn_plus_m_eq_n_plus_Sm:
forall n m : nat,
S (n + m) = n + (S m).
Proof.
intros n m.
induction n as [| n' IH].
- auto.
- simpl. rewrite <- IH. reflexivity.
Qed.
Theorem add_comm :
forall n m : nat,
n + m = m + n.
Proof.
intros.
induction n as [| n' IH].
- simpl. rewrite -> n_plus_zero_eq_n. reflexivity.
- simpl. rewrite -> IH. rewrite -> Sn_plus_m_eq_n_plus_Sm. reflexivity.
Qed.
(* auto using proof *)
Theorem add_comm_eauto_using_auto_with_start:
forall n m: nat,
n + m = m + n.
Proof.
intros. induction n.
Print Hint.
- auto with *.
- auto with *.
Qed.
Theorem add_comm_eauto_using:
forall n m: nat,
n + m = m + n.
Proof.
intros. induction n.
assert (H: forall n, n + 0 = n) by eauto using n_plus_zero_eq_n.
assert (H': forall n m, S (n + m) = n + S m) by eauto using Sn_plus_m_eq_n_plus_Sm.
- eauto with *.
- eauto using IHn, H, H'.