Prove the Existence of Modular Multiplicative Inverse Using Coq












1















I'm trying to prove the Chinese Remainder Theorem using Coq.
currently, I'm trying to prove the existence of modular multiplicative inverse, this is what I've done so far:



Theorem modulo_inv : forall m n : Z, rel_prime m n -> exists x : Z, (m * x == 1 [ n ]) .
Proof .
intros m0 n0 co_prime0 .
destruct (rel_prime_bezout _ _ co_prime0) as [u v Eq].
cut (u * m0 = 1 - v * n0); auto with zarith .
intros Eq0 .
exists u.
(* the subgoal is Eq0 *)
Abort.


and all there's left now is one subgoal, which means the same as Eq0 as shown below:



1 subgoal
m, n : Z
co_prime : rel_prime m n
m0, n0 : Z
co_prime0 : rel_prime m0 n0
u, v : Z
Eq : u * m0 + v * n0 = 1
Eq0 : u * m0 = 1 - v * n0
______________________________________(1/1)
(m0 * u == 1 [n0])


Does anyone know how to show that the subgoal equals to Eq0?



P.S. The definition of Modulo is given below:



Definition modulo (a b n : Z) : Prop := (n | (a - b)) .
Notation "( a == b [ n ])" := (modulo a b n) .









share|improve this question




















  • 2





    Are you already familiar with an informal proof (i.e., not in Coq) of this theorem? Because if you do it is easier to then try to map each step of that proof to a statement in Coq.

    – Li-yao Xia
    Nov 27 '18 at 12:37











  • How would you prove the theorem on paper?

    – gallais
    Nov 27 '18 at 12:39











  • You can also checkout the proof of this theorem in mathcomp library.

    – Anton Trunov
    Nov 27 '18 at 12:49











  • @Li-yaoXia I have updated my informal proof, but how do you convert that to formal proof?

    – Ang.
    Nov 27 '18 at 13:08











  • @AntonTrunov Thank you, I'll check it out.

    – Ang.
    Nov 27 '18 at 13:09
















1















I'm trying to prove the Chinese Remainder Theorem using Coq.
currently, I'm trying to prove the existence of modular multiplicative inverse, this is what I've done so far:



Theorem modulo_inv : forall m n : Z, rel_prime m n -> exists x : Z, (m * x == 1 [ n ]) .
Proof .
intros m0 n0 co_prime0 .
destruct (rel_prime_bezout _ _ co_prime0) as [u v Eq].
cut (u * m0 = 1 - v * n0); auto with zarith .
intros Eq0 .
exists u.
(* the subgoal is Eq0 *)
Abort.


and all there's left now is one subgoal, which means the same as Eq0 as shown below:



1 subgoal
m, n : Z
co_prime : rel_prime m n
m0, n0 : Z
co_prime0 : rel_prime m0 n0
u, v : Z
Eq : u * m0 + v * n0 = 1
Eq0 : u * m0 = 1 - v * n0
______________________________________(1/1)
(m0 * u == 1 [n0])


Does anyone know how to show that the subgoal equals to Eq0?



P.S. The definition of Modulo is given below:



Definition modulo (a b n : Z) : Prop := (n | (a - b)) .
Notation "( a == b [ n ])" := (modulo a b n) .









share|improve this question




















  • 2





    Are you already familiar with an informal proof (i.e., not in Coq) of this theorem? Because if you do it is easier to then try to map each step of that proof to a statement in Coq.

    – Li-yao Xia
    Nov 27 '18 at 12:37











  • How would you prove the theorem on paper?

    – gallais
    Nov 27 '18 at 12:39











  • You can also checkout the proof of this theorem in mathcomp library.

    – Anton Trunov
    Nov 27 '18 at 12:49











  • @Li-yaoXia I have updated my informal proof, but how do you convert that to formal proof?

    – Ang.
    Nov 27 '18 at 13:08











  • @AntonTrunov Thank you, I'll check it out.

    – Ang.
    Nov 27 '18 at 13:09














1












1








1








I'm trying to prove the Chinese Remainder Theorem using Coq.
currently, I'm trying to prove the existence of modular multiplicative inverse, this is what I've done so far:



Theorem modulo_inv : forall m n : Z, rel_prime m n -> exists x : Z, (m * x == 1 [ n ]) .
Proof .
intros m0 n0 co_prime0 .
destruct (rel_prime_bezout _ _ co_prime0) as [u v Eq].
cut (u * m0 = 1 - v * n0); auto with zarith .
intros Eq0 .
exists u.
(* the subgoal is Eq0 *)
Abort.


and all there's left now is one subgoal, which means the same as Eq0 as shown below:



1 subgoal
m, n : Z
co_prime : rel_prime m n
m0, n0 : Z
co_prime0 : rel_prime m0 n0
u, v : Z
Eq : u * m0 + v * n0 = 1
Eq0 : u * m0 = 1 - v * n0
______________________________________(1/1)
(m0 * u == 1 [n0])


Does anyone know how to show that the subgoal equals to Eq0?



P.S. The definition of Modulo is given below:



Definition modulo (a b n : Z) : Prop := (n | (a - b)) .
Notation "( a == b [ n ])" := (modulo a b n) .









share|improve this question
















I'm trying to prove the Chinese Remainder Theorem using Coq.
currently, I'm trying to prove the existence of modular multiplicative inverse, this is what I've done so far:



Theorem modulo_inv : forall m n : Z, rel_prime m n -> exists x : Z, (m * x == 1 [ n ]) .
Proof .
intros m0 n0 co_prime0 .
destruct (rel_prime_bezout _ _ co_prime0) as [u v Eq].
cut (u * m0 = 1 - v * n0); auto with zarith .
intros Eq0 .
exists u.
(* the subgoal is Eq0 *)
Abort.


and all there's left now is one subgoal, which means the same as Eq0 as shown below:



1 subgoal
m, n : Z
co_prime : rel_prime m n
m0, n0 : Z
co_prime0 : rel_prime m0 n0
u, v : Z
Eq : u * m0 + v * n0 = 1
Eq0 : u * m0 = 1 - v * n0
______________________________________(1/1)
(m0 * u == 1 [n0])


Does anyone know how to show that the subgoal equals to Eq0?



P.S. The definition of Modulo is given below:



Definition modulo (a b n : Z) : Prop := (n | (a - b)) .
Notation "( a == b [ n ])" := (modulo a b n) .






coq






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 10 at 11:17







Ang.

















asked Nov 27 '18 at 12:21









Ang.Ang.

62




62








  • 2





    Are you already familiar with an informal proof (i.e., not in Coq) of this theorem? Because if you do it is easier to then try to map each step of that proof to a statement in Coq.

    – Li-yao Xia
    Nov 27 '18 at 12:37











  • How would you prove the theorem on paper?

    – gallais
    Nov 27 '18 at 12:39











  • You can also checkout the proof of this theorem in mathcomp library.

    – Anton Trunov
    Nov 27 '18 at 12:49











  • @Li-yaoXia I have updated my informal proof, but how do you convert that to formal proof?

    – Ang.
    Nov 27 '18 at 13:08











  • @AntonTrunov Thank you, I'll check it out.

    – Ang.
    Nov 27 '18 at 13:09














  • 2





    Are you already familiar with an informal proof (i.e., not in Coq) of this theorem? Because if you do it is easier to then try to map each step of that proof to a statement in Coq.

    – Li-yao Xia
    Nov 27 '18 at 12:37











  • How would you prove the theorem on paper?

    – gallais
    Nov 27 '18 at 12:39











  • You can also checkout the proof of this theorem in mathcomp library.

    – Anton Trunov
    Nov 27 '18 at 12:49











  • @Li-yaoXia I have updated my informal proof, but how do you convert that to formal proof?

    – Ang.
    Nov 27 '18 at 13:08











  • @AntonTrunov Thank you, I'll check it out.

    – Ang.
    Nov 27 '18 at 13:09








2




2





Are you already familiar with an informal proof (i.e., not in Coq) of this theorem? Because if you do it is easier to then try to map each step of that proof to a statement in Coq.

– Li-yao Xia
Nov 27 '18 at 12:37





Are you already familiar with an informal proof (i.e., not in Coq) of this theorem? Because if you do it is easier to then try to map each step of that proof to a statement in Coq.

– Li-yao Xia
Nov 27 '18 at 12:37













How would you prove the theorem on paper?

– gallais
Nov 27 '18 at 12:39





How would you prove the theorem on paper?

– gallais
Nov 27 '18 at 12:39













You can also checkout the proof of this theorem in mathcomp library.

– Anton Trunov
Nov 27 '18 at 12:49





You can also checkout the proof of this theorem in mathcomp library.

– Anton Trunov
Nov 27 '18 at 12:49













@Li-yaoXia I have updated my informal proof, but how do you convert that to formal proof?

– Ang.
Nov 27 '18 at 13:08





@Li-yaoXia I have updated my informal proof, but how do you convert that to formal proof?

– Ang.
Nov 27 '18 at 13:08













@AntonTrunov Thank you, I'll check it out.

– Ang.
Nov 27 '18 at 13:09





@AntonTrunov Thank you, I'll check it out.

– Ang.
Nov 27 '18 at 13:09












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53499594%2fprove-the-existence-of-modular-multiplicative-inverse-using-coq%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53499594%2fprove-the-existence-of-modular-multiplicative-inverse-using-coq%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Contact image not getting when fetch all contact list from iPhone by CNContact

count number of partitions of a set with n elements into k subsets

A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks