Section RSA.
Variable p q : nat.
Variable prime_p : prime p.
Variable prime_q : prime q.
Variable neq_pq : p <> q.
Variable e d : nat.
Variable pq : nat.
Hypothesis pqnot_zero : pq <> 0.
Hypothesis pq_div_p : divides (p - 1) pq.
Hypothesis pq_div_q : divides (q - 1) pq.
Variable ed_inv : congruent pq (e * d) 1.
Definition encrypt (w : nat) : nat := power w e.
Definition decrypt (w : nat) : nat := power w d.
intros r; case r.
intros H'; absurd (prime 0); auto.
intros n; case n.
intros H'; absurd (prime 1); auto.
intros n0; case n0; auto with arith.
Qed.

Theorem rsa_correct :
forall w : nat, congruent (p * q) (decrypt (encrypt w)) w.