Step-by-step derivation
S001 · implies
Before
source operation=flt-all-integer;original snapshot and mathematics retained
After
explicit ordered source output fields=[p, normalized_base, power_p, comparison_residue, congruent, boundary]
Conditions: none
Keep the historical interface marker in the original snapshot while listing ordered source fields here,without JavaScript or external lookup.Field labels are not mathematical evidence,and No retains the operation's claim scope.
Step identifiers and dependencies
Rule: source_ordered_interface_explicit_without_javascript · Uses: G001
S002 · implies
Before
ACTUAL integer modulus=2;complete trial range2..floor_sqrt=1
After
checked rows[divisor,quotient,remainder]=[];first exact factor=null;prime=Yes
Conditions: none
An exact factor in the trial range witnesses compositeness.If the entire range has no factor,any composite decomposition would require one at most sqrt(n),so all composite cases are excluded.The empty range for2 is valid.This is not a primality inference from a Fermat test.
Step identifiers and dependencies
Rule: flt_primality_complete_trial_or_actual_factor_not_Fermat_test · Uses: G001, S001
S003 · implies
Before
original signed base=2;positive modulus=2;use nonnegative gcd inputs=[2, 2]
After
ALL Euclidean rows[left,right,q,r]=[[2, 2, 1, 0]];terminal nonnegative gcd=2;coprime=No
Conditions: none
Euclidean replacements preserve common divisors and give the terminal gcd,including gcd(0,m)=m.Primality of the modulus and invertibility of the base remain separate flags.
Step identifiers and dependencies
Rule: flt_actual_gcd_coprime_separate_from_primality · Uses: G001, S002
S004 · calculation
Before
Fermat original signed base exact quotient := div(2, 2)
After
Fermat original signed base exact quotient = 1
Conditions: none
Substitute original roles and established intermediates exactly,retaining signs,denominators,indices and the relevant carrier.
Step identifiers and dependencies
Rule: exact_rational_arithmetic · Uses: G001, S003
S005 · calculation
Before
Fermat original signed base floor quotient multiple := mul(1, 2)
After
Fermat original signed base floor quotient multiple = 2
Conditions: none
Substitute original roles and established intermediates exactly,retaining signs,denominators,indices and the relevant carrier.
Step identifiers and dependencies
Rule: exact_rational_arithmetic · Uses: G001, S004
S006 · calculation
Before
Fermat original signed base normalized remainder := sub(2, 2)
After
Fermat original signed base normalized remainder = 0
Conditions: none
Substitute original roles and established intermediates exactly,retaining signs,denominators,indices and the relevant carrier.
Step identifiers and dependencies
Rule: exact_rational_arithmetic · Uses: G001, S005
S007 · implies
Before
Fermat original signed base:signed integer value=2;positive modulus=2;exact quotient=1;floor q=1
After
value=q*modulus+remainder;normalized remainder=0 in[0,2)
Conditions: none
Use a positive modulus and floor quotient to obtain the nonnegative representative even for a negative base.Equal remainders express congruence modulo this modulus,not unrestricted integer equality.
Step identifiers and dependencies
Rule: flt_exact_signed_modulo_not_integer_equality · Uses: G001, S006
S008 · implies
Before
Fermat original modular exponent:original normalized base=0;original exponent=2;modulus=2
After
initialize accumulator1,current_base=base,remaining=exponent;invariant accumulator*current_base^remaining congruent to original power
Conditions: none
The multiplicative identity gives the exponent0 convention.Each step preserves congruence to the same original power without constructing huge ordinary powers or replacing modular relations with real equalities.
Step identifiers and dependencies
Rule: flt_modular_power_initial_invariant · Uses: G001, S007
S009 · calculation
Before
Fermat original modular exponent bit0 current base square := mul(0, 0)
After
Fermat original modular exponent bit0 current base square = 0
Conditions: none
Substitute original roles and established intermediates exactly,retaining signs,denominators,indices and the relevant carrier.
Step identifiers and dependencies
Rule: exact_rational_arithmetic · Uses: G001, S008
S010 · calculation
Before
Fermat original modular exponent bit0 squared base reduction exact quotient := div(0, 2)
After
Fermat original modular exponent bit0 squared base reduction exact quotient = 0
Conditions: none
Substitute original roles and established intermediates exactly,retaining signs,denominators,indices and the relevant carrier.
Step identifiers and dependencies
Rule: exact_rational_arithmetic · Uses: G001, S009
S011 · calculation
Before
Fermat original modular exponent bit0 squared base reduction floor quotient multiple := mul(0, 2)
After
Fermat original modular exponent bit0 squared base reduction floor quotient multiple = 0
Conditions: none
Substitute original roles and established intermediates exactly,retaining signs,denominators,indices and the relevant carrier.
Step identifiers and dependencies
Rule: exact_rational_arithmetic · Uses: G001, S010
S012 · calculation
Before
Fermat original modular exponent bit0 squared base reduction normalized remainder := sub(0, 0)
After
Fermat original modular exponent bit0 squared base reduction normalized remainder = 0
Conditions: none
Substitute original roles and established intermediates exactly,retaining signs,denominators,indices and the relevant carrier.
Step identifiers and dependencies
Rule: exact_rational_arithmetic · Uses: G001, S011
S013 · implies
Before
Fermat original modular exponent bit0 squared base reduction:signed integer value=0;positive modulus=2;exact quotient=0;floor q=0
After
value=q*modulus+remainder;normalized remainder=0 in[0,2)
Conditions: none
Use a positive modulus and floor quotient to obtain the nonnegative representative even for a negative base.Equal remainders express congruence modulo this modulus,not unrestricted integer equality.
Step identifiers and dependencies
Rule: flt_exact_signed_modulo_not_integer_equality · Uses: G001, S012
S014 · implies
Before
Fermat original modular exponent:step=0;previous[accumulator,base,exponent]=[1, 0, 2];low bit=0
After
next[accumulator,base,exponent]=[1, 0, 1];split exponent=2*q+bit preserves original-power invariant
Conditions: none
Replace an even power by a squared base;an odd power also contributes one base factor to the accumulator.Exact reductions preserve congruence and halving the remaining nonnegative exponent guarantees termination.
Step identifiers and dependencies
Rule: flt_each_binary_power_step_exact_invariant · Uses: G001, S013
S015 · calculation
Before
Fermat original modular exponent bit1 accumulator product := mul(1, 0)
After
Fermat original modular exponent bit1 accumulator product = 0
Conditions: none
Substitute original roles and established intermediates exactly,retaining signs,denominators,indices and the relevant carrier.
Step identifiers and dependencies
Rule: exact_rational_arithmetic · Uses: G001, S014
S016 · calculation
Before
Fermat original modular exponent bit1 accumulator reduction exact quotient := div(0, 2)
After
Fermat original modular exponent bit1 accumulator reduction exact quotient = 0
Conditions: none
Substitute original roles and established intermediates exactly,retaining signs,denominators,indices and the relevant carrier.
Step identifiers and dependencies
Rule: exact_rational_arithmetic · Uses: G001, S015
S017 · calculation
Before
Fermat original modular exponent bit1 accumulator reduction floor quotient multiple := mul(0, 2)
After
Fermat original modular exponent bit1 accumulator reduction floor quotient multiple = 0
Conditions: none
Substitute original roles and established intermediates exactly,retaining signs,denominators,indices and the relevant carrier.
Step identifiers and dependencies
Rule: exact_rational_arithmetic · Uses: G001, S016
S018 · calculation
Before
Fermat original modular exponent bit1 accumulator reduction normalized remainder := sub(0, 0)
After
Fermat original modular exponent bit1 accumulator reduction normalized remainder = 0
Conditions: none
Substitute original roles and established intermediates exactly,retaining signs,denominators,indices and the relevant carrier.
Step identifiers and dependencies
Rule: exact_rational_arithmetic · Uses: G001, S017
S019 · implies
Before
Fermat original modular exponent bit1 accumulator reduction:signed integer value=0;positive modulus=2;exact quotient=0;floor q=0
After
value=q*modulus+remainder;normalized remainder=0 in[0,2)
Conditions: none
Use a positive modulus and floor quotient to obtain the nonnegative representative even for a negative base.Equal remainders express congruence modulo this modulus,not unrestricted integer equality.
Step identifiers and dependencies
Rule: flt_exact_signed_modulo_not_integer_equality · Uses: G001, S018
S020 · calculation
Before
Fermat original modular exponent bit1 current base square := mul(0, 0)
After
Fermat original modular exponent bit1 current base square = 0
Conditions: none
Substitute original roles and established intermediates exactly,retaining signs,denominators,indices and the relevant carrier.
Step identifiers and dependencies
Rule: exact_rational_arithmetic · Uses: G001, S019
S021 · calculation
Before
Fermat original modular exponent bit1 squared base reduction exact quotient := div(0, 2)
After
Fermat original modular exponent bit1 squared base reduction exact quotient = 0
Conditions: none
Substitute original roles and established intermediates exactly,retaining signs,denominators,indices and the relevant carrier.
Step identifiers and dependencies
Rule: exact_rational_arithmetic · Uses: G001, S020
S022 · calculation
Before
Fermat original modular exponent bit1 squared base reduction floor quotient multiple := mul(0, 2)
After
Fermat original modular exponent bit1 squared base reduction floor quotient multiple = 0
Conditions: none
Substitute original roles and established intermediates exactly,retaining signs,denominators,indices and the relevant carrier.
Step identifiers and dependencies
Rule: exact_rational_arithmetic · Uses: G001, S021
S023 · calculation
Before
Fermat original modular exponent bit1 squared base reduction normalized remainder := sub(0, 0)
After
Fermat original modular exponent bit1 squared base reduction normalized remainder = 0
Conditions: none
Substitute original roles and established intermediates exactly,retaining signs,denominators,indices and the relevant carrier.
Step identifiers and dependencies
Rule: exact_rational_arithmetic · Uses: G001, S022
S024 · implies
Before
Fermat original modular exponent bit1 squared base reduction:signed integer value=0;positive modulus=2;exact quotient=0;floor q=0
After
value=q*modulus+remainder;normalized remainder=0 in[0,2)
Conditions: none
Use a positive modulus and floor quotient to obtain the nonnegative representative even for a negative base.Equal remainders express congruence modulo this modulus,not unrestricted integer equality.
Step identifiers and dependencies
Rule: flt_exact_signed_modulo_not_integer_equality · Uses: G001, S023
S025 · implies
Before
Fermat original modular exponent:step=1;previous[accumulator,base,exponent]=[1, 0, 1];low bit=1
After
next[accumulator,base,exponent]=[0, 0, 0];split exponent=2*q+bit preserves original-power invariant
Conditions: none
Replace an even power by a squared base;an odd power also contributes one base factor to the accumulator.Exact reductions preserve congruence and halving the remaining nonnegative exponent guarantees termination.
Step identifiers and dependencies
Rule: flt_each_binary_power_step_exact_invariant · Uses: G001, S024
S026 · implies
Before
Fermat original modular exponent:remaining exponent0;final normalized accumulator=0
After
EXACT original base^2 modulo2=0
Conditions: none
At remaining exponent0 the invariant leaves exactly the accumulator,giving the original power's residue.The arithmetic result alone does not certify a prime modulus.
Step identifiers and dependencies
Rule: flt_modular_power_terminal_not_primality_converse · Uses: G001, S025
S027 · implies
Before
ACTUAL prime p=2;original a=2 is divisible by p;normalized residue0;positive exponent p
After
a^p residue=0=0=a residue;NO cancellation of a or0 needed
Conditions: none
When p divides a,it also divides the positive p-th power,so both residues are0.This branch does not cancel0 to derive the coprime form.
Step identifiers and dependencies
Rule: flt_all_integer_zero_residue_case_no_invalid_cancellation · Uses: G001, S026