I am confused. Coq gives the following error:
No subterm matching Hab * a.
What is causing the problem, and how can I solve it?
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 modelus : forall a b c d : Z, (a | b * c) -> Zis_gcd a b d -> (a | c * d).
Proof.
intros a b c d [Hab Hac] [H1 H2].
unfold Z.divide in *.
destruct H1 as [H3 H1].
destruct H2 as [H4 H2].
exists (c * H3 + b * H4).
rewrite Z.mul_add_distr_r.
rewrite <- Hac.
rewrite Z.mul_assoc.
rewrite <- H1.
rewrite <- H2.
reflexivity.
rewrite<- Hac.
, you're asking to replace all occurrences ofHab * a
in the goal byb * c
. But there are no occurrences ofHab * a
in the goal. $\endgroup$*
in Coq. The termc * x * a
is read(c * x) * a
and notc * (x * a)
. You may use the associativity of multiplication before your rewrite. P.S. Why callingHab
an integer ? $\endgroup$