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

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

ab[PARSE ERROR: Undefined("Command(\"pmod\")")]n

とは、

n(a-b)

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

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剰余類じょうよるい.

ab[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]

定義ていぎする。

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

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

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

ab-ab=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 aa[PARSE ERROR: Undefined("Command(\"pmod\")")]n and bb[PARSE ERROR: Undefined("Command(\"pmod\")")]n, then

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

is a multiple of n. Also,

ab-ab=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]

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

ax1[PARSE ERROR: Undefined("Command(\"pmod\")")]n

おなじである。

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

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

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

ax+ny=1

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

この条件じょうけん代表元だいひょうげんにもよらない。a=a+kn なら、an公約数こうやくすうaり、an公約数こうやくすう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

ax1[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 ax1[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 ax1[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·12·4[PARSE ERROR: Undefined("Command(\"pmod\")")]6

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

一般いっぱんcacb[PARSE ERROR: Undefined("Command(\"pmod\")")]n[PARSE ERROR: Undefined("Command(\"gcd\")")](c,n)=1 なら、[c]乗法逆元じょうほうぎゃくげんつ。両辺りょうへん[c]-1ければ [a]=[b]、すなわち ab[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·12·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 cacb[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 ab[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ぐんである。ここにあとまなぶラグランジュの定理ていり適用てきようすると、pa のとき [a]p-1=[1]、すなわち

ap-11[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 pa, or equivalently

ap-11[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せい整数せいすうとする。合同式ごうどうしき

ab[PARSE ERROR: Undefined("Command(\"pmod\")")]n,cd[PARSE ERROR: Undefined("Command(\"pmod\")")]n

成立せいりつするなら、

a+cb+d[PARSE ERROR: Undefined("Command(\"pmod\")")]n,acbd[PARSE ERROR: Undefined("Command(\"pmod\")")]n

である。

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

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

nれる。よって a+cb+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) であり、acbd[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合同式ごうどうしき

ab[PARSE ERROR: Undefined("Command(\"pmod\")")]n,cd[PARSE ERROR: Undefined("Command(\"pmod\")")]n

hold, then

a+cb+d[PARSE ERROR: Undefined("Command(\"pmod\")")]n,acbd[PARSE ERROR: Undefined("Command(\"pmod\")")]n

also hold.

First prove the statement for addition. The congruence合同式ごうどうしき ab[PARSE ERROR: Undefined("Command(\"pmod\")")]n means n(a-b), and cd[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+cb+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 acbd[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
タブを全て閉じる