Created
December 31, 2022 08:11
-
-
Save kino6052/c8cd21a8b7f7b38fd31f98fdf646d9a2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Require Import Arith. | |
(* define the function that calculates t1 and t2 *) | |
Fixpoint calc_t1 (m: nat) (l: list nat) : nat := | |
match l with | |
| [] => 1 | |
| h :: t => h * calc_t1 m t | |
end * m - 1. | |
Fixpoint calc_t2 (m: nat) (l: list nat) : nat := | |
match l with | |
| [] => 1 | |
| h :: t => h * calc_t2 m t | |
end * m + 1. | |
(* prove that a number is prime *) | |
Fixpoint is_prime (p: nat) : bool := | |
match p with | |
| 0 => false | |
| 1 => false | |
| 2 => true | |
| S (S n as p') => | |
negb (existsb (fun x => p' mod x =? 0) (seq 2 p')) | |
&& is_prime p' | |
end. | |
(* prove that t1 and t2 are not divisible by any element in the list *) | |
Theorem non_divisible (m: nat) (l: list nat) : | |
(forall p, In p l -> is_prime p = true -> (calc_t1 m l) mod p <> 0) | |
/\ (forall p, In p l -> is_prime p = true -> (calc_t2 m l) mod p <> 0). | |
Proof. | |
split. | |
- induction l. | |
+ intros p H H0. inversion H. | |
+ intros p H H0. inversion H. | |
* subst. simpl. | |
destruct (Nat.eq_dec m 0). | |
{ rewrite Nat.mul_0_l. rewrite Nat.sub_0_r. | |
apply Nat.mod_1_r. } | |
{ apply Nat.mod_1_r. } | |
* apply IHl. assumption. assumption. | |
- induction l. | |
+ intros p H H0. inversion H. | |
+ intros p H H0. inversion H. | |
* subst. simpl. | |
destruct (Nat.eq_dec m 0). | |
{ rewrite Nat.mul_0_l. rewrite Nat.sub_0_r. | |
apply Nat.mod_1_r. } | |
{ apply Nat.mod_1_r. } | |
* apply IHl. assumption. assumption. | |
Qed |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment