markdown
合同式と mod 演算md b0cfb39
lecture/math/abstract-algebra/congruences-and-modular-arithmetic.lecture.n.md
Download PDF

合同式ごうどうしきcongruenceと mod 演算えんざんoperation

date2026-07-14document_iddoc_6a6ca43b1c890d8a2a05b45ec31f9e06description合同式と mod 演算を、剰余類の商構造として定義し、加法・乗法・逆元がいつ正当化されるかを説明する。prerequisites[同値関係/どうちかんけい]と[剰余類/じょうよるい] / ユークリッドの[互除法/ごじょほう]type講義content_typelecturestatusactiverelateddata/lecture/math/abstract-algebra/equivalence-relations-and-cosets.lecture.n.md / data/lecture/math/algebra/euclidean-algorithm-and-linear-diophantine-equations.lecture.n.md / data/lecture/math/number-theory/chinese-remainder-theorem.lecture.n.md / data/exercise/math/abstract-algebra/equivalence-relations-and-congruences.exercise.n.md
mathabstract-algebranumber-theorylecture

合同式ごうどうしきを「余あまりが同おなじ」という計算けいさん規則きそくだけで見みると、何故なぜ足たし算ざんや掛かけ算ざんが正当化せいとうかされるのかが見みえにくい。抽象代数ちゅうしょうだいすうでは、合同式ごうどうしきを剰余類じょうよるいの等号とうごうとして見みる。

a≡b[PARSE ERROR: Undefined("Command(\"pmod\")")]n

とは、

n∣(a-b)

という意味いみであり、同時どうじに a と b が同おなじ剰余類じょうよるいに属ぞくするという意味いみでもある。

data/lecture/math/abstract-algebra/equivalence-relations-and-cosets.lecture.n.md

congruence合同式ごうどうしき and mod operation演算えんざん

If congruences合同式ごうどうしき are viewed only as the calculation rule "the remainders are the same," it is hard to see why addition and multiplication are justified. In abstract algebra抽象代数ちゅうしょうだいすう, a congruence合同式ごうどうしき is viewed as equality of residue classes剰余類じょうよるい.

a≡b[PARSE ERROR: Undefined("Command(\"pmod\")")]n

means

n∣(a-b)

and at the same time means that a and b belong to the same residue class.

data/lecture/math/abstract-algebra/equivalence-relations-and-cosets.lecture.n.md

1剰余類じょうよるい全体ぜんたい

n[PARSE ERROR: Undefined("Command(\"ge\")")]2 とする。整数全体せいすうぜんたいを n で割わった余あまりによって分類ぶんるいすると、商集合しょうしゅうごう

Z/nZ={[0],[1],[PARSE ERROR: Undefined("Command(\"dots\")")],[n-1]}

が得えられる。この集合しゅうごうの元げんは整数せいすうではなく、整数せいすうの同値類どうちるいである。

ここでの商集合しょうしゅうごうとは、同おなじ余あまりを持もつ整数せいすうを一ひとつの類るいにまとめ、その類るいを元げんとして扱あつかう集合しゅうごうである。

1The set of residue classes

Let n[PARSE ERROR: Undefined("Command(\"ge\")")]2. Classifying all integers by their remainders modulo n gives the quotient set商集合しょうしゅうごう

Z/nZ={[0],[1],[PARSE ERROR: Undefined("Command(\"dots\")")],[n-1]}

The elements of this set are not integers themselves, but equivalence classes of integers.

Here the quotient set is the set obtained by grouping integers with the same remainder into one class and then treating those classes as the elements.

この講義こうぎでは法ほう n を固定こていし、[a]n を [a] と略記りゃくきする。法ほうを変かえると剰余類じょうよるいも変かわるので、複数ふくすうの法ほうを同時どうじに扱あつかうときは添字そえじを戻もどす。

Throughout this lecture the modulus n is fixed, and [a] abbreviates [a]n. Because changing the modulus changes the residue class, restore the subscript when several moduli are discussed at once.

2足たし算ざんと掛かけ算ざん

剰余類じょうよるいの加法かほうと乗法じょうほうを

[a]+[b]=[a+b]
[a][b]=[ab]

で定義ていぎする。

ここで重要じゅうようなのは、右辺うへんが代表元だいひょうげんの選えらび方かたによらないことである。もし a≡a′[PARSE ERROR: Undefined("Command(\"pmod\")")]n、b≡b′[PARSE ERROR: Undefined("Command(\"pmod\")")]n なら、

(a+b)-(a′+b′)=(a-a′)+(b-b′)

は n の倍数ばいすうである。また、

ab-a′b′=a(b-b′)+b′(a-a′)

も n の倍数ばいすうである。したがって和わと積せきは代表元だいひょうげんによらず定さだまる(well-defined である)。

2Addition and multiplication

Define addition and multiplication of residue classes by

[a]+[b]=[a+b]
[a][b]=[ab]

The important point is that the right-hand side does not depend on the choice of representatives. If a≡a′[PARSE ERROR: Undefined("Command(\"pmod\")")]n and b≡b′[PARSE ERROR: Undefined("Command(\"pmod\")")]n, then

(a+b)-(a′+b′)=(a-a′)+(b-b′)

is a multiple of n. Also,

ab-a′b′=a(b-b′)+b′(a-a′)

is a multiple of n. Therefore the sum and product are well-defined.

3加法かほうについて群ぐんになること

代表元だいひょうげんによらず和わが定さだまったので、(Z/nZ,+) の群ぐんの条件じょうけんを確認かくにんできる。閉包性へいほうせいは [a]+[b]=[a+b]∈Z/nZ から従したがう。結合法則けつごうほうそくは

([a]+[b])+[c]=[(a+b)+c]=[a+(b+c)]=[a]+([b]+[c])

である。[0] が単位元たんいげんであり、[a] の逆元ぎゃくげんは [-a] である。さらに [a]+[b]=[a+b]=[b+a]=[b]+[a] なので可換かかんである。したがって (Z/nZ,+) は可換群かかんぐんである。

乗法じょうほうについても、整数せいすうの法則ほうそくを剰余類じょうよるいへ移うつせる。たとえば結合法則けつごうほうそくと左分配法則ひだりぶんぱいほうそくは

([a][b])[c]=[(ab)c]=[a(bc)]=[a]([b][c]),
[a]([b]+[c])=[a(b+c)]=[ab+ac]=[a][b]+[a][c]

である。同様どうように乗法じょうほうの可換性かかんせいと右分配法則みぎぶんぱいほうそくも従したがい、[1] は乗法じょうほうの単位元たんいげんである。ただし、すべての元げんが乗法逆元じょうほうぎゃくげんを持もつわけではない。この加法かほうと乗法じょうほうの構造こうぞうは、後あとで環かんの公理こうりとして整理せいりする。

3The additive group structure

Now that addition is independent of representatives, we can verify the group axioms for (Z/nZ,+). Closure follows from [a]+[b]=[a+b]∈Z/nZ. Associativity follows from

([a]+[b])+[c]=[(a+b)+c]=[a+(b+c)]=[a]+([b]+[c]).

The identity is [0], and the inverse of [a] is [-a]. Moreover, [a]+[b]=[a+b]=[b+a]=[b]+[a], so addition is commutative. Therefore (Z/nZ,+) is an abelian group.

The integer laws similarly pass to multiplication of residue classes. For example, associativity and left distributivity are

([a][b])[c]=[(ab)c]=[a(bc)]=[a]([b][c]),
[a]([b]+[c])=[a(b+c)]=[ab+ac]=[a][b]+[a][c].

Commutativity and right distributivity follow in the same way, and [1] is the multiplicative identity. Not every element has a multiplicative inverse. These addition and multiplication laws will later be organized as the ring axioms.

4逆元ぎゃくげんがある条件じょうけん

剰余類じょうよるい [a] が乗法逆元じょうほうぎゃくげんを持もつとは、ある [x] が存在そんざいして

[a][x]=[1]

となることである。これは

ax≡1[PARSE ERROR: Undefined("Command(\"pmod\")")]n

と同おなじである。

この合同式ごうどうしきが解かいを持もつための必要十分条件ひつようじゅうぶんじょうけんは

[PARSE ERROR: Undefined("Command(\"gcd\")")](a,n)=1

である。実際じっさい、ax≡1[PARSE ERROR: Undefined("Command(\"pmod\")")]n なら ax-1=kn となる整数せいすう k がある。a と n の公約数こうやくすうは ax-kn=1 も割わるので、[PARSE ERROR: Undefined("Command(\"gcd\")")](a,n)=1 である。逆ぎゃくに [PARSE ERROR: Undefined("Command(\"gcd\")")](a,n)=1 なら、ベズーの等式とうしきにより整数せいすう x,y が存在そんざいして

ax+ny=1

となる。したがって ax≡1[PARSE ERROR: Undefined("Command(\"pmod\")")]n であり、[x] が [a] の逆元ぎゃくげんになる。

この条件じょうけんは代表元だいひょうげんにもよらない。a′=a+kn なら、a と n の公約数こうやくすうは a′ も割わり、a′ と n の公約数こうやくすうは a=a′-kn も割わる。したがって [PARSE ERROR: Undefined("Command(\"gcd\")")](a,n)=[PARSE ERROR: Undefined("Command(\"gcd\")")](a′,n) である。

data/lecture/math/algebra/euclidean-algorithm-and-linear-diophantine-equations.lecture.n.md

ここでは文字もじで割わり算ざんをするのではなく、最大公約数さいだいこうやくすうが 1 であることから逆元ぎゃくげんの存在そんざいを示しめしている。したがって、割わる操作そうさを行おこなう場面ばめんでは、逆元ぎゃくげんが存在そんざいする条件じょうけんを先さきに確認かくにんする必要ひつようがある。

4The condition for an inverse

A residue class [a] has a multiplicative inverse if there exists a class [x] such that

[a][x]=[1]

This is the same as

ax≡1[PARSE ERROR: Undefined("Command(\"pmod\")")]n

The necessary and sufficient condition for this congruence to have a solution is

[PARSE ERROR: Undefined("Command(\"gcd\")")](a,n)=1

Indeed, if ax≡1[PARSE ERROR: Undefined("Command(\"pmod\")")]n, then ax-1=kn for some integer k. Every common divisor of a and n divides ax-kn=1, so [PARSE ERROR: Undefined("Command(\"gcd\")")](a,n)=1. Conversely, if [PARSE ERROR: Undefined("Command(\"gcd\")")](a,n)=1, Bezout's identity gives integers x,y such that

ax+ny=1

Reducing this equality modulo n gives ax≡1[PARSE ERROR: Undefined("Command(\"pmod\")")]n, so [x] is the inverse of [a].

This condition is also independent of the representative. If a′=a+kn, every common divisor of a and n divides a′, while every common divisor of a′ and n divides a=a′-kn. Hence [PARSE ERROR: Undefined("Command(\"gcd\")")](a,n)=[PARSE ERROR: Undefined("Command(\"gcd\")")](a′,n).

data/lecture/math/algebra/euclidean-algorithm-and-linear-diophantine-equations.lecture.n.md

Here we are not dividing by a symbol; we are proving the existence of an inverse from the fact that the greatest common divisor is 1. Therefore, whenever a division-like operation is used, one must first check the condition that an inverse exists.

5合同式ごうどうしきでは常つねに約分やくぶんできるとは限かぎらない

2·1≡2·4[PARSE ERROR: Undefined("Command(\"pmod\")")]6

は成立せいりつするが、1[PARSE ERROR: Undefined("Command(\"not\")")]≡4[PARSE ERROR: Undefined("Command(\"pmod\")")]6 である。したがって整数せいすうの等式とうしきのように 2 を無条件むじょうけんに約分やくぶんすることはできない。

一般いっぱんに ca≡cb[PARSE ERROR: Undefined("Command(\"pmod\")")]n で [PARSE ERROR: Undefined("Command(\"gcd\")")](c,n)=1 なら、[c] は乗法逆元じょうほうぎゃくげんを持もつ。両辺りょうへんに [c]-1 を掛かければ [a]=[b]、すなわち a≡b[PARSE ERROR: Undefined("Command(\"pmod\")")]n を得える。したがって [PARSE ERROR: Undefined("Command(\"gcd\")")](c,n)=1 は、c による約分やくぶんを正当化せいとうかする十分じゅうぶんな条件じょうけんである。

5Cancellation is not always valid in congruences

The congruence

2·1≡2·4[PARSE ERROR: Undefined("Command(\"pmod\")")]6

holds, but 1[PARSE ERROR: Undefined("Command(\"not\")")]≡4[PARSE ERROR: Undefined("Command(\"pmod\")")]6. Thus the factor 2 cannot be cancelled unconditionally as it could in an equality of integers.

In general, if ca≡cb[PARSE ERROR: Undefined("Command(\"pmod\")")]n and [PARSE ERROR: Undefined("Command(\"gcd\")")](c,n)=1, then [c] has a multiplicative inverse. Multiplying both sides by [c]-1 gives [a]=[b], or a≡b[PARSE ERROR: Undefined("Command(\"pmod\")")]n. Thus [PARSE ERROR: Undefined("Command(\"gcd\")")](c,n)=1 is a sufficient condition for cancellation by c.

6フェルマーの小定理しょうていりへの接続せつぞく

p が素数そすうなら、0 でない剰余類じょうよるいは全すべて逆元ぎゃくげんを持もつ。0 でない剰余類じょうよるい全体ぜんたいを

(Z/pZ)×

と書かく。この集合しゅうごうには [1],…,[p-1] の p-1 個この元げんがある。上うえで示しめしたように、0 でない各元かくげんは逆元ぎゃくげんを持もつ。0 でない [a],[b] の積せきが [0] だとすると、両辺りょうへんに [a]-1 を掛かけて [b]=[0] となり矛盾むじゅんする。したがって乗法じょうほうで閉とじている。結合法則けつごうほうそくは整数せいすうの乗法じょうほうから従したがい、[1] が単位元たんいげんである。よってこれは位数いすう p-1 の群ぐんである。ここに後あとで学まなぶラグランジュの定理ていりを適用てきようすると、p∤a のとき [a]p-1=[1]、すなわち

ap-1≡1[PARSE ERROR: Undefined("Command(\"pmod\")")]p

が導みちびかれる。これがフェルマーの小定理しょうていりである。

この節せつは後あとの群ぐんとラグランジュの定理ていりへの見通みとおしである。このページの本流ほんりゅうでは、剰余類じょうよるいの演算えんざんが well-defined であることと、逆元ぎゃくげんの存在条件そんざいじょうけんだけを使つかう。

6Connection to Fermat's little theorem

If p is prime, every nonzero residue class has an inverse. Write the set of all nonzero residue classes as

(Z/pZ)×

This set has the p-1 elements [1],…,[p-1], and every element has an inverse by the criterion proved above. If the product of nonzero [a] and [b] were [0], multiplication by [a]-1 would give [b]=[0], a contradiction. Thus it is closed under multiplication. Associativity follows from integer multiplication, and [1] is the identity. It is therefore a group of order p-1. Lagrange's theorem, studied later, gives [a]p-1=[1] whenever p∤a, or equivalently

ap-1≡1[PARSE ERROR: Undefined("Command(\"pmod\")")]p

This is Fermat's little theorem.

This section is a preview of later material on groups and Lagrange's theorem. The main thread of this page uses only the well-definedness of residue-class operations and the condition for inverses to exist.

7証明しょうめい補足ほそく:合同式ごうどうしきが加法かほうと乗法じょうほうで保存ほぞんされる理由りゆう

n を正せいの整数せいすうとする。合同式ごうどうしき

a≡b[PARSE ERROR: Undefined("Command(\"pmod\")")]n,c≡d[PARSE ERROR: Undefined("Command(\"pmod\")")]n

が成立せいりつするなら、

a+c≡b+d[PARSE ERROR: Undefined("Command(\"pmod\")")]n,ac≡bd[PARSE ERROR: Undefined("Command(\"pmod\")")]n

である。

加法かほうについて証明しょうめいする。a≡b[PARSE ERROR: Undefined("Command(\"pmod\")")]n は n∣(a-b)、c≡d[PARSE ERROR: Undefined("Command(\"pmod\")")]n は n∣(c-d) という意味いみである。したがって

(a+c)-(b+d)=(a-b)+(c-d)

も n で割わり切きれる。よって a+c≡b+d[PARSE ERROR: Undefined("Command(\"pmod\")")]n である。

乗法じょうほうについては

ac-bd=ac-bc+bc-bd=c(a-b)+b(c-d)

と変形へんけいする。n∣(a-b) かつ n∣(c-d) なので、右辺うへんの二ふたつの項こうはどちらも n で割わり切きれる。したがって n∣(ac-bd) であり、ac≡bd[PARSE ERROR: Undefined("Command(\"pmod\")")]n である。

ここでは n で割わるのではなく、n が差さを割わり切きることを使つかっている。したがって文字式もじしきの除算じょざんに伴ともなう 0 除算じょざんの問題もんだいは生しょうじない。ただし、[PARSE ERROR: Undefined("Command(\"pmod\")")]n の記法きほうでは n を正せいの整数せいすうとして固定こていしている。

7Proof supplement: why congruence合同式ごうどうしき is preserved by addition and multiplication

Let n be a positive integer. If the congruences合同式ごうどうしき

a≡b[PARSE ERROR: Undefined("Command(\"pmod\")")]n,c≡d[PARSE ERROR: Undefined("Command(\"pmod\")")]n

hold, then

a+c≡b+d[PARSE ERROR: Undefined("Command(\"pmod\")")]n,ac≡bd[PARSE ERROR: Undefined("Command(\"pmod\")")]n

also hold.

First prove the statement for addition. The congruence合同式ごうどうしき a≡b[PARSE ERROR: Undefined("Command(\"pmod\")")]n means n∣(a-b), and c≡d[PARSE ERROR: Undefined("Command(\"pmod\")")]n means n∣(c-d). Therefore

(a+c)-(b+d)=(a-b)+(c-d)

is also divisible by n. Hence a+c≡b+d[PARSE ERROR: Undefined("Command(\"pmod\")")]n.

For multiplication, rewrite

ac-bd=ac-bc+bc-bd=c(a-b)+b(c-d)

Since n∣(a-b) and n∣(c-d), both terms on the right are divisible by n. Hence n∣(ac-bd), so ac≡bd[PARSE ERROR: Undefined("Command(\"pmod\")")]n.

This proof証明しょうめい does not divide by n; it uses the fact that n divides a difference. Therefore no issue of division by zero in symbolic division arises. However, in the notation [PARSE ERROR: Undefined("Command(\"pmod\")")]n, the modulus n is fixed as a positive integer.

9まとめ

合同式ごうどうしきは、剰余類じょうよるいの等号とうごうである。mod 演算えんざんが正当化せいとうかされるのは、剰余類じょうよるい上じょうの加法かほうと乗法じょうほうが代表元だいひょうげんによらず定さだまるからである。(Z/nZ,+) は可換群かかんぐんである。乗法逆元じょうほうぎゃくげんは常つねにあるわけではなく、[PARSE ERROR: Undefined("Command(\"gcd\")")](a,n)=1 が必要十分条件ひつようじゅうぶんじょうけんである。

9Summary

A congruence合同式ごうどうしき is equality of residue classes. Mod operations are justified because addition and multiplication on residue classes are determined independently of representatives. The additive structure (Z/nZ,+) is an abelian group. Multiplicative inverses do not always exist; the condition [PARSE ERROR: Undefined("Command(\"gcd\")")](a,n)=1 is necessary and sufficient.

raw .n.md をコピー
loc をコピー (filepath:line ~ line)
copy share link
copy encoded share link
path をコピー
copy share link
copy encoded share link
copy share link
copy encoded share link
タブを全て閉じる