This commit is contained in:
Thomas Baruchel 2023-01-29 21:16:56 +01:00
parent 08e4884255
commit d741cad63f
2 changed files with 247 additions and 36 deletions

View File

@ -1462,3 +1462,175 @@ Proof.
rewrite <- Nat.negb_odd. rewrite <- Nat.negb_odd.
rewrite H0. rewrite H1. reflexivity.
Qed.
Lemma tm_step_square_prefix_not_nil0 :
forall (n : nat) (hd a tl : list bool),
tm_step n = hd ++ a ++ a ++ tl -> 0 < length a
-> hd <> nil
\/ exists a' tl', tm_step (pred n) = a' ++ a' ++ tl'
/\ 0 < length a'.
Proof.
intros n hd a tl. intros H I.
destruct a. inversion I.
destruct a.
assert (W: {hd=nil} + {~ hd=nil}). apply list_eq_dec. apply bool_dec.
destruct W. rewrite e in H.
assert (1 < 2^n). rewrite <- tm_size_power2. rewrite H. simpl.
rewrite <- Nat.succ_lt_mono. apply Nat.lt_0_succ.
assert (Z : 0 < 2^n). apply Nat.lt_succ_l. assumption.
assert (nth_error (tm_step n) 0 <> nth_error (tm_step (S n)) (S (2*0))).
generalize Z. apply tm_step_succ_double_index.
rewrite tm_step_stable with (k := S (2*0)) (m := n) in H1. rewrite H in H1.
simpl in H1. contradiction H1. reflexivity. rewrite Nat.pow_succ_r.
replace (S (2*0)) with (1*1). apply Nat.mul_lt_mono. apply Nat.lt_1_2.
assumption. reflexivity. apply le_0_n. assumption. left. assumption.
destruct a.
assert (W: {hd=nil} + {~ hd=nil}). apply list_eq_dec. apply bool_dec.
destruct W. rewrite e in H.
assert (2 < 2^n). rewrite <- tm_size_power2. rewrite H. simpl.
rewrite <- Nat.succ_lt_mono. rewrite <- Nat.succ_lt_mono. apply Nat.lt_0_succ.
assert (nth_error (tm_step n) 1 = nth_error (tm_step (S n)) (2*1)).
apply tm_step_double_index.
rewrite tm_step_stable with (k := (2*1)) (m := n) in H1. rewrite H in H1.
simpl in H1. inversion H1. rewrite H3 in H.
replace ([] ++ [b;b] ++ [b;b] ++ tl)
with ([b] ++ [b] ++ [b] ++ [b] ++ tl) in H.
apply tm_step_cubefree in H. contradiction H. reflexivity.
apply Nat.lt_0_1. reflexivity. rewrite Nat.pow_succ_r.
apply Nat.mul_lt_mono_pos_l. apply Nat.lt_0_succ.
apply Nat.lt_succ_l. assumption. apply le_0_n. assumption.
left. assumption.
destruct a.
assert (W: {hd=nil} + {~ hd=nil}). apply list_eq_dec. apply bool_dec.
destruct W. rewrite e in H.
assert (5 < 2^n). rewrite <- tm_size_power2. rewrite H. simpl.
rewrite <- Nat.succ_lt_mono. rewrite <- Nat.succ_lt_mono.
rewrite <- Nat.succ_lt_mono. rewrite <- Nat.succ_lt_mono.
rewrite <- Nat.succ_lt_mono. apply Nat.lt_0_succ.
assert (nth_error (tm_step n) 2 <> nth_error (tm_step (S n)) (S (2*2))).
apply tm_step_succ_double_index.
apply Nat.lt_succ_l. apply Nat.lt_succ_l. apply Nat.lt_succ_l. assumption.
rewrite tm_step_stable with (k := S (2*2)) (m := n) in H1. rewrite H in H1.
simpl in H1. contradiction H1. reflexivity. rewrite Nat.pow_succ_r.
apply Nat.lt_succ_l. replace (S (S (2*2))) with (2*3).
apply Nat.mul_lt_mono_pos_l. apply Nat.lt_0_2.
apply Nat.lt_succ_l. apply Nat.lt_succ_l. assumption. reflexivity.
apply le_0_n. assumption. left. assumption.
pose (a' := b::b0::b1::b2::a). fold a' in H.
assert (J : 4 <= length a'). unfold a'. simpl.
rewrite <- Nat.succ_le_mono. rewrite <- Nat.succ_le_mono.
rewrite <- Nat.succ_le_mono. rewrite <- Nat.succ_le_mono. apply le_0_n.
assert (K: {odd (length a') = true} + {~ odd (length a') = true}).
apply bool_dec. destruct K.
assert (length a' < 4). generalize e. generalize H.
apply tm_step_odd_square.
apply Nat.le_ngt in J. apply J in H0. contradiction H0.
apply not_true_iff_false in n0.
assert (K: even (length a') = true).
rewrite <- Nat.negb_odd. rewrite n0. reflexivity.
(*
assert (L: even (length (hd ++ a')) = true).
rewrite Nat.le_succ_l in J. apply Nat.lt_succ_l in J.
apply Nat.lt_succ_l in J. apply Nat.lt_succ_l in J.
generalize J. generalize H. apply tm_step_square_pos.
assert (M: even (length hd) = true).
rewrite app_length in L. rewrite Nat.even_add_even in L.
assumption.
apply Nat.EvenT_Even. apply Nat.even_EvenT. assumption.
*)
assert (W: {hd=nil} + {~ hd=nil}). apply list_eq_dec. apply bool_dec.
destruct W. rewrite e in H. right.
destruct n. inversion H. rewrite app_nil_l in H.
assert (N: tm_morphism (tm_step n) = tm_morphism
(firstn (Nat.div2 (length a')) (tm_step n) ++
firstn (Nat.div2 (length a'))
(skipn (Nat.div2 (length a')) (tm_step n)) ++
skipn (Nat.div2 (length a' + length a')) (tm_step n))).
generalize K. generalize K. generalize H. apply tm_step_morphism3.
assert (O := N). rewrite tm_step_lemma in N.
rewrite tm_morphism_app in N. rewrite tm_morphism_app in N.
assert (length a' + length a' <= 2 * length (tm_step n)).
rewrite tm_size_power2. rewrite <- Nat.pow_succ_r.
rewrite <- tm_size_power2. rewrite H. rewrite app_assoc.
rewrite app_length. rewrite <- app_length. apply Nat.le_add_r.
apply le_0_n. replace (length a' + length a') with (2 * length a') in H0.
rewrite <- Nat.mul_le_mono_pos_l in H0.
assert (length a' = length
(tm_morphism (firstn (Nat.div2 (length a')) (tm_step n)))).
rewrite tm_morphism_length. rewrite firstn_length_le.
rewrite <- Nat.add_0_r. replace 0 with (Nat.b2n (Nat.odd (length a'))) at 2.
rewrite <- Nat.div2_odd. reflexivity. rewrite n0. reflexivity.
assert (Nat.div2 (length a') < length a').
apply Nat.lt_div2. apply Nat.lt_succ_l in J.
apply Nat.lt_succ_l in J. apply Nat.lt_succ_l in J. assumption.
apply Nat.lt_le_incl. generalize H0. generalize H1.
apply Nat.lt_le_trans.
assert (Nat.div2 (length a') < length a'). apply Nat.lt_div2.
apply Nat.lt_succ_l in J. apply Nat.lt_succ_l in J.
apply Nat.lt_succ_l in J. assumption.
assert (length a' = length
(tm_morphism (firstn (Nat.div2 (length a'))
(skipn (Nat.div2 (length a')) (tm_step n))))).
rewrite tm_morphism_length. rewrite firstn_length_le.
rewrite <- Nat.add_0_r. replace 0 with (Nat.b2n (Nat.odd (length a'))) at 2.
rewrite <- Nat.div2_odd. reflexivity. rewrite n0. reflexivity.
rewrite skipn_length.
rewrite Nat.add_le_mono_r with (p := Nat.div2 (length a')).
rewrite Nat.sub_add. rewrite Nat.div2_div at 2. rewrite <- Nat.div_add_l.
rewrite Nat.mul_comm.
replace (2 * Nat.div2 (length a'))
with (2 * Nat.div2 (length a') + Nat.b2n (Nat.odd (length a'))).
rewrite <- Nat.div2_odd. replace (length a' + length a') with (2 * length a').
replace 2 with (2*1) at 2. rewrite Nat.div_mul_cancel_l.
rewrite Nat.div_1_r. assumption. easy. easy. reflexivity.
simpl. rewrite Nat.add_0_r. reflexivity. rewrite n0.
simpl. rewrite Nat.add_0_r. reflexivity. easy.
apply Nat.lt_le_incl. generalize H0. generalize H2.
apply Nat.lt_le_trans.
assert (a' = tm_morphism (firstn (Nat.div2 (length a')) (tm_step n))).
generalize H1. rewrite H in N. generalize N. apply app_eq_length_head.
rewrite <- H4 in N. rewrite H in N. rewrite app_inv_head_iff in N.
assert (a' =
tm_morphism
(firstn (Nat.div2 (length a'))
(skipn (Nat.div2 (length a')) (tm_step n)))).
generalize H3. generalize N. apply app_eq_length_head.
exists (firstn (Nat.div2 (length a')) (tm_step n)).
exists (skipn (Nat.div2 (length a' + length a')) (tm_step n)).
split.
rewrite tm_morphism_app in O.
rewrite tm_morphism_app in O.
rewrite <- H5 in O. rewrite H4 in O at 2.
rewrite <- tm_morphism_app in O.
rewrite <- tm_morphism_app in O.
rewrite <- tm_morphism_eq in O. rewrite <- pred_Sn.
rewrite O at 1. reflexivity.
rewrite firstn_length_le.
apply Nat.div_le_mono with (c := 2) in J.
rewrite Nat.div2_div. replace (4/2) with 2 in J.
apply Nat.lt_succ_l in J. assumption. reflexivity. easy.
apply Nat.lt_le_incl. generalize H0. generalize H2.
apply Nat.lt_le_trans. apply Nat.lt_0_2.
simpl. rewrite Nat.add_0_r. reflexivity.
left. assumption.
Qed.

View File

@ -1540,12 +1540,6 @@ Proof.
Qed.
Lemma tm_step_palindromic_even_morphism2 :
forall (n : nat) (hd a tl : list bool),
tm_step n = hd ++ a ++ (rev a) ++ tl
@ -1591,18 +1585,6 @@ Proof.
assert (K: even (length (rev a)) = true). rewrite rev_length. assumption.
(*
assert (Q: Nat.div2 (length hd) <= length (tm_step (S n))).
rewrite H. rewrite app_length.
assert (Nat.div2 (length hd) <= length hd).
assert (length hd = 0 \/ 0 < length hd). apply Nat.eq_0_gt_0_cases.
destruct H1. rewrite H1. apply Nat.le_refl.
apply Nat.lt_le_incl. apply Nat.lt_div2. assumption.
assert (length hd <= length hd + length (a ++ rev a ++ tl)).
apply Nat.le_add_r. generalize H2. generalize H1. apply Nat.le_trans.
*)
rewrite app_assoc in H. rewrite <- tm_step_lemma in H.
assert (hd ++ a = tm_morphism (firstn (Nat.div2 (length (hd ++ a)))
@ -1697,9 +1679,6 @@ Proof.
rewrite H. rewrite app_assoc. rewrite app_length.
rewrite <- app_length. apply Nat.le_add_r.
assert (H0': even (length (hd' ++ a')) = true).
rewrite app_length. rewrite Nat.even_add.
rewrite I'. rewrite J'. reflexivity.
@ -1751,13 +1730,6 @@ Proof.
with ((length hd' + length a' * 2) / 2) in H.
rewrite Nat.div_add in H. rewrite <- Nat.div2_div in H.
pose (hd'' := firstn (Nat.div2 (length hd')) (tm_step n)).
pose (a'' := firstn (Nat.div2 (length a')) (skipn (Nat.div2 (length hd'))
(tm_step n))).
@ -1789,8 +1761,6 @@ Proof.
rewrite Nat.div_add. rewrite <- Nat.div2_div. reflexivity. easy.
rewrite Nat.mul_comm. simpl. rewrite Nat.add_0_r. reflexivity.
split.
rewrite <- pred_Sn. rewrite <- pred_Sn.
rewrite H4 at 1. fold hd'. rewrite H4'. unfold hd'.
@ -1832,8 +1802,6 @@ Proof.
rewrite Nat.mul_comm. simpl. rewrite Nat.add_0_r. reflexivity.
apply Nat.le_refl.
rewrite <- Nat.div_add. rewrite Nat.mul_comm.
replace (2 * Nat.div2 (length a'))
with (2 * Nat.div2 (length a') + Nat.b2n (Nat.odd (length a'))).
@ -1904,11 +1872,75 @@ Proof.
pose (tl' := (skipn (length hd / 4 + Nat.div2 (length a)) (tm_step n))).
fold hd' in H. fold a' in H. fold tl' in H.
rewrite Nat.pred_succ in K. rewrite Nat.pred_succ in K.
rewrite Nat.pred_succ in L. rewrite Nat.pred_succ in L.
assert (N: length a = length a). reflexivity.
rewrite L in N at 2. fold a' in N.
fold hd' in K. fold a' in L.
assert (N: length a = length a). reflexivity. rewrite L in N at 2.
rewrite tm_morphism_length in N. rewrite tm_morphism_length in N.
rewrite Nat.mul_assoc in N. replace (2*2) with 4 in N.
assert (O: length hd = length hd). reflexivity. rewrite K in O at 2.
rewrite tm_morphism_length in O. rewrite tm_morphism_length in O.
rewrite Nat.mul_assoc in O. replace (2*2) with 4 in O.
generalize dependent a.
generalize dependent hd.
induction m.
- intros hd hd' K O a a' tl'. intros H I J W L M N.
assert (even (length (hd' ++ a')) = true).
assert (0 < length a'). rewrite J in N.
replace (2 ^ (Nat.double 2)) with (4*4) in N.
rewrite Nat.mul_cancel_l in N. rewrite <- N.
apply Nat.lt_0_succ. easy. reflexivity. generalize H0.
generalize H. apply tm_step_palindromic_even_center.
replace (2^pred (Nat.double 2)) with (4*2).
replace (length (hd ++ a)) with (4 * length (hd' ++ a')).
rewrite Nat.mul_mod_distr_l. rewrite Nat.mul_eq_0. right.
rewrite <- Nat.div_exact. rewrite <- Nat.div2_div.
rewrite <- Nat.add_0_r.
replace 0 with (Nat.b2n (odd (length (hd' ++ a')))) at 2.
rewrite <- Nat.div2_odd. reflexivity. rewrite <- Nat.negb_even.
rewrite H0. reflexivity. easy. easy. easy.
rewrite app_length. rewrite app_length. rewrite N.
rewrite Nat.mul_add_distr_l. rewrite K.
rewrite <- K. rewrite O. reflexivity. reflexivity.
- intros hd hd' K O a a' tl'. intros H I J W L M N.
rewrite Nat.double_S.
replace (pred (S (S (Nat.double (S (S m))))))
with (S (S (pred (Nat.double (S (S m)))))).
rewrite Nat.pow_succ_r. rewrite Nat.pow_succ_r.
rewrite Nat.mul_assoc. replace (2*2) with 4.
rewrite app_length. rewrite N. rewrite O.
rewrite <- Nat.mul_add_distr_l. rewrite Nat.mul_mod_distr_l.
apply Nat.mul_eq_0. right. rewrite <- app_length.
m, n, k : nat
hd, a, tl : list bool
hd' := firstn (length hd / 4) (tm_step n) : list bool
a' := firstn (length a / 4) (skipn (length hd / 4) (tm_step n)) : list bool
tl' := skipn (length hd / 4 + Nat.div2 (length a)) (tm_step n) : list bool
H : tm_step n = hd' ++ a' ++ rev a' ++ tl'
I : 6 < length a
J : length a = 2 ^ Nat.double (S (S m))
W : length a mod 4 = 0
K : hd = tm_morphism (tm_morphism hd')
L : a = tm_morphism (tm_morphism a')
M : tl =
tm_morphism
(tm_morphism
(skipn (length hd / 4 + Nat.div2 (length a))
(tm_step (pred (pred (S (S n)))))))
V : 3 < S (S n)
N : length a = 4 * length a'
O : length hd = 4 * length hd'
induction m.
- assert (even (length (hd' ++ a')) = true).
@ -1922,8 +1954,15 @@ Proof.
replace (length (hd ++ a)) with (4 * length (hd' ++ a')).
rewrite Nat.mul_mod_distr_l. rewrite Nat.mul_eq_0. right.
rewrite <- Nat.div_exact. rewrite <- Nat.div2_div.
rewrite <- Nat.add_0_r.
replace 0 with (Nat.b2n (odd (length (hd' ++ a')))) at 2.
rewrite <- Nat.div2_odd. reflexivity. rewrite <- Nat.negb_even.
rewrite H0. reflexivity. easy. easy. easy.
rewrite app_length. rewrite app_length. rewrite N.
rewrite Nat.mul_add_distr_l. rewrite K.
rewrite <- K. rewrite O. reflexivity. reflexivity.
-