(* Paraphernalia: *) Ltac fold_unfold_tactic name := intros; unfold name; fold name; reflexivity. Require Import Arith Bool. (* ********** *) Check Bool.eqb. (* : bool -> bool -> bool *) Check eqb. (* : bool -> bool -> bool *) Search (eqb _ _ = true -> _ = _). (* eqb_prop: forall a b : bool, eqb a b = true -> a = b *) Search (eqb _ _ = true). (* eqb_reflx: forall b : bool, eqb b b = true *) Search (_ * _). (* Definition is_even (n: nat) := *) (* Proposition product_of_n_and_even_is_even : *) (* forall n : nat, *) Proposition product_of_2_consecutive_natural_numbers_is_even: forall n: nat, exists a: nat, n * (S n) = 2 * a. Proof. intro n. induction n as [ | n' IHn']. - exists 0. rewrite -> (Nat.mul_0_l 1). rewrite -> (Nat.mul_0_r 2). reflexivity. - rewrite -> (Nat.mul_succ_r (S n') (S n')). rewrite -> (Nat.mul_succ_r (S n') n'). rewrite -> (Nat.mul_comm (S n') n'). destruct IHn' as [k IHn']. rewrite -> IHn'. rewrite <- (Nat.add_assoc (2 * k) (S n') (S n')). remember (S n' + S n') as x eqn:H_x. rewrite <- (Nat.mul_1_l (S n')) in H_x at 1. rewrite -> H_x. rewrite <- (Nat.mul_succ_l 1 (S n')). Search (_ * _ + _ * _). rewrite <- (Nat.mul_add_distr_l 2 k (S n')). exists (k + S n'). reflexivity. Qed. Proposition product_of_3_consecutive_natural_numbers_is_divisible_by_2: forall n : nat, exists a : nat, n * (S n) * (S (S n)) = 2 * a. Proof. intro n. induction n as [ | n' IHn' ]. - exists 0. rewrite -> (Nat.mul_0_l 1). rewrite -> (Nat.mul_0_l 2). rewrite -> (Nat.mul_0_r 2). reflexivity. - destruct IHn' as [k IHn']. destruct (product_of_2_consecutive_natural_numbers_is_even (S n')) as [x H_product_of_2_consecutive_natural_numbers_is_even]. rewrite -> H_product_of_2_consecutive_natural_numbers_is_even. exists (x * S (S (S n'))). Check (Nat.mul_assoc 2 x (S (S (S n')))). rewrite -> (Nat.mul_assoc 2 x (S (S (S n')))). reflexivity. Qed.