Skip to main content
IoT
PSUT Engineering StudioPrincess Sumaya University for Technology
V21.6.5 · Student / connected
Cyber Defense StudioIoT Security and PrivacyExperimentsWorkspaces
Home / IoT Security and Privacy / EC03
IoTPSUT IoT Engineering StudioPrincess Sumaya University for Technology · Dr. Mohammad Alja’afreh
ESSENTIAL LABORATORY · EC03 · IoT SECURITY AND PRIVACY
IoT Security and Privacy

Modular arithmetic I — Congruences and residues

Use modular arithmetic to model clocks, normalize residues, solve congruences and reason about divisibility.

Design experiment & verify evidence →
EC03 · Laboratory mentorAsk about the current experiment, its algorithms or Python notebook.
Ask Dr. MohammadAdaptive practice
EC03 · Academic orientation

Scope and objectives

Scope of the experiment

Use modular arithmetic to model clocks, normalize residues, solve congruences and reason about divisibility.

The focus of this experiment is to identify residue classes and canonical modular representatives. Students then calculate positive and negative reductions and congruence checks, and verify equivalence through divisibility rather than ordinary equality. The Concepts view explains the operation before the practical work; the Simulation view is used to examine reference and changed inputs, not to substitute for actual measurements.

Learning objectives

  • Identify residue classes and canonical modular representatives.
  • Calculate positive and negative reductions and congruence checks.
  • Verify equivalence through divisibility rather than ordinary equality.
  • Record the relevant inputs, intermediate states and final verification result before changing the reference configuration.
  • Compare the reference calculation or decision with an independent implementation or authorized observation; state any discrepancy and the applicable model boundary.

Expected learning outcomes

On completion, students can identify residue classes and canonical modular representatives, calculate positive and negative reductions and congruence checks, and verify equivalence through divisibility rather than ordinary equality.

Required deliverables

Submit the derivation or state trace for the named operation, the exact reference and changed configurations, the associated simulator or practical evidence, and a short validation statement addressing verify equivalence through divisibility rather than ordinary equality. Separate predicted values from observations.

Prerequisite knowledge and related learning

Review the foundational terminology in Concepts and confirm readiness using the existing setup instructions. After completion, continue to Modular arithmetic II — Euclid, totient, Affine and Hill.

Environment and experimental methodology

The included teaching workstation and the listed Python/Colab or WSL implementation. Historical and small-number constructions are instructional, not deployment recommendations.

Begin with a manual prediction, record the baseline, change one independent condition at a time, and compare the resulting trace or measurements with the original prediction. Record observations and uncertainty separately from reference values. Follow the experiment’s specific procedure, safety limits, and acceptance checks.

How to investigate Modular arithmetic I — Congruences and residues

Use modular arithmetic to model clocks, normalize residues, solve congruences and reason about divisibility.

Analytical investigation means collecting an observation, identifying the mechanism, using a calculation or state trace to explain it, and checking your conclusion against evidence. Controlled comparison means changing one independent variable, holding the remaining relevant conditions constant, and measuring a dependent variable against a baseline. Experimental validation means comparing a predicted result to a reproducible observation or assertion; agreement inside a model does not certify hardware. Evidence-based reasoning connects a specific observation to a theoretical rule and states uncertainty, not merely an opinion. Performance characterization records a named metric and its units across conditions; sensitivity analysis changes one parameter across several values. A threat assessment links an asset, threat, consequence and evidence to a mitigation.

Experiment-specific guided practice

Objective: Use modular arithmetic to model clocks, normalize residues, solve congruences and reason about divisibility.

  1. Complete the analytical preparation below before programming. Show the intermediate mathematical calculations.
  2. 12-hour clock — complete its numbered steps and record the requested evidence.
  3. Congruence substitution and signed residues — complete its numbered steps and record the requested evidence.
  4. Divisibility, proof and counterexample — complete its numbered steps and record the requested evidence.

Reference check: Clock 10 + 80 displays 6:00. Each remainder is nonnegative and less than the modulus. The congruence class is generated by −1+25k.

Model boundary: Fictional educational inputs. Browser algorithms and reference programs; no hardware or live-network measurements. Supplied starter notebooks may be incomplete; trace playback is recorded execution, not arbitrary Python running in browser.

Independent task and submission evidence

2. 12-hour clock — complete its numbered steps and record the requested evidence. Record the named input, prediction, actual output and one limitation; restore the original condition and repeat.

Before execution write the independent variable and its levels, dependent observation with units where applicable, baseline, controlled variables, measurement method and expected result. For a state machine use state/event/output rather than inventing a numeric metric. Record failures and repeat the baseline. A weak conclusion is “it works”; a supported conclusion names the changed setting, observed value/state, corresponding rule and one limitation.

TrialChanged settingFixed settingsPredicted resultActual observation / unitsEvidence / uncertainty
A: baselineReferenceRecordPredictRecordRecord
B: one changeRecordSame as APredictRecordRecord
A: repeatRestoreSame as APredictRecordRecord

Completion: submit the filled table, relevant simulator screenshot or terminal/notebook output, reasoning with units/assumptions, and one limitation. Preserve the independent assessment questions; this guide does not fill their answers.

Scientific concepts and engineering principles

Scientific architecture · EC03 · Modular arithmetic I — Congruences and residues

Euclidean residues and congruence — Integer / −17; Modulus / 5; Euclidean division / −17 = (−4)·5 + 3; Residue / r=3; Congruence / −17 ≡ 3 (mod 5)
Scientific concept map: Integer a — Signed value; Modulus m — Positive integer; Division — a=q·m+r; Residue — 0≤r<m; Congruence — Compare same residue.

Euclidean division

For a positive modulus m, write a=mq+r with 0≤r<m. Congruence a≡b (mod m) means m divides a−b. Negative operands still have a nonnegative canonical remainder.

Congruence under operations

Replacing an operand by a congruent representative preserves sums, differences, products and nonnegative integer powers. A modular clock is a useful visualization of this equivalence class. For a twelve-hour clock, display residue 0 as 12.

Proof and counterexample

A numerical example can disprove a universal claim but cannot by itself prove it. To establish divisibility, introduce an integer multiplier. For a square modulo 4, enumerate the four possible residues and use the resulting set to rule out impossible sums of squares.

Prerequisites: EC02 and earlier foundations as applicable.

EC03 engineering diagram
Algorithm structure and data flow. Use the simulation to inspect the corresponding numerical transformations.

Engineering diagrams

Residue and quotient distinguish equivalent integers.
Residue and quotient distinguish equivalent integers.

Scientific foundations and worked examples

Clock arithmetic and signed residues

A clock is the quotient of integer hours by multiples of 12. Starting from 10, 80 hours later gives 90 mod 12=6. Starting at 4 and moving back 40 hours gives −36 mod 12=0, displayed as 12. The quotient can be negative; the canonical residue is always in [0,m−1]. For example −101=−8×13+3.

Algebra of congruences

If a≡7 and b≡3 modulo 11, addition and multiplication may be performed on the representatives: 7a+3b≡49+9≡3; 2a²+3b²≡98+27≡4; \(a^{3}\)+4b³≡343+108≡0. The class of −1 modulo 25 is {25k−1:k∈Z}; restricting k gives all members in a finite interval. Congruence is reflexive, symmetric and transitive because divisibility of differences has these properties.

Divisibility and proof construction

The relation a|b means b=ak for an integer k. Mutual divisibility of nonzero integers gives |a|=|b|, not necessarily a=b. If ac|bc and c≠0, cancel c from bc=ack to obtain b=ak. If a|bc, it does not follow that a divides either factor: 6|2×3 but neither 2 nor 3 is divisible by 6. If a divides b and a+b is odd, a must be odd because an even a would make both terms even. Integer squares are 0 or 1 modulo 4, hence a sum of two squares cannot be 3 modulo 4.

Engineering principles · additional worked teaching example

For modulus m>0, a=q m+r with 0≤r<m. Example −19=−3×7+2, so −19≡2 mod7. Congruence compares residues rather than ordinary equality; addition and multiplication preserve congruence.

From theory to experiment

Predict the reference result before operating the workbench; check the actual intermediate state, units and constraints. The existing simulation, implementation and procedure below are distinct sources of evidence.

Worked engineering reasoning and boundary conditions

Euclidean division writes a=qn+r with 0≤r<n. For −23 mod 7, q=−4 and r=5. Congruence preserves addition and multiplication.

Use the diagram to follow the calculation or state progression. Keep the teaching configuration separate from the independent exercise values; compare observations with the actual model and implementation.

Mathematical representation and interpretation

Euclidean remainder and congruence

n is a positive modulus, q the quotient, r the canonical nonnegative residue. Equality of residues does not mean equality of integers.

\[a=qn+r,\quad 0\le r<n,\qquad a\equiv b\pmod n\iff n\mid(a-b)\]

For a=−8 and n=5, choose q=−2 and r=2: −8=−10+2.

Concept animation · operation pathway

Explore the teaching example independently of the simulator. Each step reveals an operation, data relationship or calculated state. The Simulation view has separate editable inputs.

Modular arithmetic I — Congruences and residues: operation pathwayDividend−23, modulus 7Quotientfloor(−23/7)=−4Remainder−23−(−4×7)=5Verify−23=−28+5Read the active operation, then inspect the accumulated state.

Step 1 of 4 · Dividend

Dividend

Dividend
−23, modulus 7

Teaching example only; inspect live calculations or real practical evidence separately.

Interactive flashcards

Self-rated study progress is stored locally, not used for official grades.

Browse all explanations
What is a residue?

The remainder in the chosen modulus range.

When are integers congruent?

Their difference is divisible by the modulus.

Why use modular clocks?

They visualize cyclic arithmetic.

What is 29 mod 7?

1.

What is the canonical residue of −3 modulo 7?

4.

What is 17 modulo 5?

2.

When are a and b congruent modulo n?

When n divides a−b.

What is a congruence class?

All integers with the same remainder modulo n.

What happens after moving n positions around a modular clock?

The initial residue is restored.

Is congruence preserved by addition?

Yes, when both congruences use the same modulus.

Is congruence preserved by multiplication?

Yes, under the same modulus.

Can ordinary division always be used in modular arithmetic?

No. Modular division requires an invertible divisor.

What are the possible square residues modulo 4?

0 and 1.

How do you check a claimed residue?

Verify its difference from the integer is divisible by the modulus.

Evaluate −17 mod 5 as a least nonnegative residue.

−17=−4×5+3, so the residue is 3.

Are 17 and −3 congruent modulo 5?

Yes. Their difference is 20, which is divisible by 5.

If a≡b mod n, is a²≡b² mod n? Explain.

Yes: \(a^{2}\)−\(b^{2}\)=(a−b)(a+b), so divisibility by n follows.

Shared research workbenches · network designer & advanced studies
Concurrent-device simulation & Monte Carlo research
Distributed digital twin · topology, protocol & battery research