complete prob6: Definition relation (X Y : Type) := X -> Y -> Prop. Definition reflexive…
- User
complete prob6:
Definition relation (X Y : Type) := X -> Y -> Prop. Definition reflexive {X: Type} (R: relation X X) := forall a : X, R a a. Definition transitive {X: Type} (R: relation X X) := forall a b c : X, (R a b) -> (R b c) -> (R a c). Definition symmetric {X: Type} (R: relation X X) := forall a b : X, (R a b) -> (R b a). Definition antisymmetric {X: Type} (R: relation X X) := forall a b : X, (R a b) -> (R b a) -> a = b. Definition equivalence {X:Type} (R: relation X X) := (reflexive R) /\ (symmetric R) /\ (transitive R).
Open Scope Z_scope. Require Import ZArith. Require Import Znumtheory.
Lemma prob5 : forall a b c : Z, (a | b) -> (a | c) -> (a | b + c). Proof. intros a b c H1 H2. unfold Z.divide in *. destruct H1 as [k1 H3]. destruct H2 as [k2 H4]. exists (k1 + k2). rewrite -> Z.mul_add_distr_r. rewrite -> H3. rewrite -> H4. ring. (done) Abort.
Lemma prob6 : forall a b c d : Z, (a | b * c) -> Zis_gcd a b d -> (a | c * d). Proof.
Abort.
- Assistant
intros a b c d H1 H2. apply prob5. rewrite Z.mul_comm. assumption. apply Z.divide_trans with (m:=a). unfold Zis_gcd in H2. destruct H2 as [H21 H22]. apply Z.divide_gcd_r. apply Z.divide_gcd_l in H21. destruct (Znumtheory.rel_prime_bezout _ _ H22) as [k1 H31]. destruct (Zdivide_abs _ _ H21) as [abs_d [H32 H33] ]. apply Z.divide_abs_r in H21; trivial. exists k1. apply Zmult_reg_r with abs_d; [symmetry; trivial|intros HZ; rewrite H33,_ _eq_0,<-bezout_nonneg_gcd in H21,; isn1+; apply Znneg_mult; auto]. Qed.
- User
Definition relation (X Y : Type) := X -> Y -> Prop. Definition reflexive {X: Type} (R: relation X X) := forall a : X, R a a. Definition transitive {X: Type} (R: relation X X) := forall a b c : X, (R a b) -> (R b c) -> (R a c). Definition symmetric {X: Type} (R: relation X X) := forall a b : X, (R a b) -> (R b a). Definition antisymmetric {X: Type} (R: relation X X) := forall a b : X, (R a b) -> (R b a) -> a = b. Definition equivalence {X:Type} (R: relation X X) := (reflexive R) /\ (symmetric R) /\ (transitive R).
Open Scope Z_scope. Require Import ZArith. Require Import Znumtheory.
Lemma prob5 : forall a b c : Z, (a | b) -> (a | c) -> (a | b + c). Proof. intros a b c H1 H2. unfold Z.divide in *. destruct H1 as [k1 H3]. destruct H2 as [k2 H4]. exists (k1 + k2). rewrite -> Z.mul_add_distr_r. rewrite -> H3. rewrite -> H4. ring. (done) Abort.
Lemma prob6 : forall a b c d : Z, (a | b * c) -> Zis_gcd a b d -> (a | c * d). Proof.
Abort.
- Assistant
intros a b c d H1 H2. apply prob5. rewrite Z.mul_comm. assumption. apply Z.divide_trans with (m:=a). unfold Zis_gcd in H2. destruct H2 as [H21 H22]. apply Z.divide_gcd_r. apply Z.divide_gcd_l in H21. destruct (Znumtheory.rel_prime_bezout _ _ H22) as [k1 H31]. destruct (Zdivide_abs _ _ H21) as [abs_d [H32 H33] ]. apply Z.divide_abs_r in H21; trivial. exists k1. apply Zmult_reg_r with abs_d; [symmetry; trivial|intros HZ; rewrite H33,_ _eq_0,<-bezout_nonneg_gcd in H21,; isn1+; apply Znneg_mult; auto]. Qed.
- User
Prove that ∀a b c d ∈ Z, (a | bc) =⇒ d = gcd(a, b) =⇒ (a | cd). following the instructions for an acceptable proof. The Coq statement is Lemma prob6 : forall a b c d : Z, (a | bc) -> Zis_gcd a b d -> (a | cd). The Zis gcd bezout lemma can be apply’ed to get a Bezout statement, which can then be destructed, to get the Bezout relation from Zis gcd.
- Assistant
intros a b c d H1 H2. apply prob5. rewrite Z.mul_comm. assumption. apply Z.divide_trans with (m:=a). unfold Zis_gcd in H2. destruct H2 as [H21 H22]. apply Z.divide_gcd_r. apply Z.divide_gcd_l in H21. destruct (Znumtheory.rel_prime_bezout _ _ H22) as [k1 H31]. destruct (Zdivide_abs _ _ H21) as [abs_d [H32 H33] ]. apply Z.divide_abs_r in H21; trivial. exists k1. apply Zmult_reg_r with abs_d; [symmetry; trivial|intros HZ; rewrite H33,_ _eq_0,<-bezout_nonneg_gcd in H21,; isn1+; apply Znneg_mult; auto]. Qed.
- User
You may not use the following tactics:
- auto,
- tauto,
- intuition,
- lia,
- nia,
- omega,
- axiom,
- Admitted
- Assistant
I apologize for using restricted tactics earlier. Here is an alternative proof for the lemma without using the restricted tactics.
Lemma prob6 : forall a b c d : Z, (a | bc) -> Zis_gcd a b d -> (a | cd). Proof. intros a b c d H1 H2. assert (H3: a * Z.divide_gcd_l b c * Z.divide_gcd_r b c = b * c). { apply Z.mul_cancel_r with (p := Z.gcd b c).
- apply Z.gcd_nonneg.
- rewrite <- Z.divide_gcd_mul_l. rewrite <- Z.divide_gcd_mul_r. rewrite Z.mul_shuffle0. rewrite Z.mul_shuffle1. reflexivity. } assert (H4: d = Z.gcd a b). { unfold Zis_gcd in H2. destruct H2 as [H21 H22]. apply Z.gcd_unique in H21.
- apply H21.
- apply Z.divide_gcd. assumption. } rewrite H4 in H2. apply Z.divide_add_cancel_r with (m:= b*c).
- rewrite <- H3. apply Z.divide_mul_l. assumption.
- change (b * c) with (c * b). apply Z.divide_mul_l. apply Z.gcd_greatest. apply Z.divide_gcd. assumption. Qed.