diff --git a/thys/Binary_Code_Imprimitive/Binary_Code_Imprimitive.thy b/thys/Binary_Code_Imprimitive/Binary_Code_Imprimitive.thy new file mode 100644 --- /dev/null +++ b/thys/Binary_Code_Imprimitive/Binary_Code_Imprimitive.thy @@ -0,0 +1,1168 @@ +(* Title: Binary Code Imprimitive + File: Combinatorics_Words_Interpretations.Binary_Code_Imprimitive + Author: Štěpán Holub, Charles University + Author: Martin Raška, Charles University + +Part of Combinatorics on Words Formalized. See https://gitlab.com/formalcow/combinatorics-on-words-formalized/ +*) + +chapter "Binary codes that do not preserve primitivity" + +theory Binary_Code_Imprimitive + imports + Combinatorics_Words_Graph_Lemma.Glued_Codes + Binary_Square_Interpretation +begin + +text \This theory focuses on the characterization of imprimitive words which are concatenations +of copies of two words (forming a binary code). +We follow the article @{cite lerest} (mainly Th\'eor\`eme 2.1 and Lemme 3.1), +while substantially optimizing the proof. See also @{cite spehner} for an earlier result on this question, +and @{cite Manuch} for another proof.\ + +section \General primitivity not preserving codes\ + +context code + +begin + +text \ +Two nontrivially conjugate elements generated by a code induce a disjoint interpretation.\ + +lemma shift_disjoint: + assumes "ws \ lists \" and "ws' \ lists \" and "z \ \\\" and "z \ concat ws = concat ws' \ z" + "us \p ws\<^sup>@n" and "vs \p ws'\<^sup>@n" + shows "z \ concat us \ concat vs" + using \z \ \\\\ +proof (elim contrapos_nn) + assume "z \ concat us = concat vs" + have "z \ \" + using \z \ \\\\ by blast + obtain us' where "ws\<^sup>@n = us \ us'" + using prefixE[OF \us \p ws\<^sup>@n\]. + obtain vs' where "ws'\<^sup>@n = vs \ vs'" + using prefixE[OF \vs \p ws'\<^sup>@n\]. + from conjug_pow[OF \z \ concat ws = concat ws' \ z\[symmetric], symmetric] + have "z \ concat (ws\<^sup>@n) = concat (ws'\<^sup>@n) \ z" + unfolding concat_pow. + from this[ unfolded \ws\<^sup>@n = us \ us'\ \ws'\<^sup>@n = vs \ vs'\ concat_morph rassoc + \z \ concat us = concat vs\[symmetric] cancel] + have "concat vs' \ z = concat us'".. + show "z \ \\\" + proof (rule stability) + have "us \ lists \" and "us' \ lists \" and "vs \ lists \" and "vs' \ lists \" + using \ws \ lists \\ \ws' \ lists \\ \ws'\<^sup>@n = vs \ vs'\ \ws\<^sup>@n = us \ us'\ + by inlists + thus "z \ concat us \ \\\" and "concat vs' \ \\\" and "concat us \ \\\" and "concat vs' \ z \ \\\" + unfolding \concat vs' \ z = concat us'\ \z \ concat us = concat vs\ + by (simp_all add: concat_in_hull') + qed +qed + +text\This in particular yields a disjoint extendable interpretation of any prefix\ + +lemma shift_interpret: + assumes "ws \ lists \" and "ws' \ lists \" and "z \ \\\" and + conjug: "z \ concat ws = concat ws' \ z" and "\<^bold>|z\<^bold>| < \<^bold>|concat ws'\<^bold>|" + and "us \p ws" and "us \ \" + obtains p s vs ps ss where "p (concat us) s \\<^sub>\ vs" and "ps \ vs \p ws' \ ws'" + and "us \ ss = ws \ ws" and + "concat ps \ p = z" and "s \p concat ss" and "p \s concat ws" and "vs \ lists \" + "\ us' vs'. us' \p us \ vs' \p vs \ p \ concat us' \ concat vs'" and "p \ \" and "s \ \" +proof- + have "ws' \ ws' \ lists \" + using \ws' \ lists \\ by inlists + have "concat us \ \" + using \us \ \\ unfolding code_concat_eq_emp_iff[OF pref_in_lists[OF \us \p ws\ \ws \ lists \\]]. + have "\<^bold>|concat ws'\<^bold>| = \<^bold>|concat ws\<^bold>|" + using lenarg[OF conjug, unfolded lenmorph] by linarith + have "z \ concat(ws \ ws) = concat (ws' \ ws') \ z" + unfolding rassoc concat_morph conjug[symmetric] unfolding lassoc cancel_right + using conjug. + hence "concat (ws' \ ws') \p z \ concat (ws \ ws)" + by blast + have "z \ concat ws \p concat (ws' \ ws')" + unfolding concat_morph conjug pref_cancel_conv using eq_le_pref[OF conjug less_imp_le[OF \\<^bold>|z\<^bold>| < \<^bold>|concat ws'\<^bold>|\]]. + from prefixE[OF pref_shorten[OF pref_concat_pref[OF \us \p ws\] this], unfolded rassoc] + obtain su where fac_u[symmetric]: "concat (ws' \ ws') = z \ concat us \ su". + + from obtain_fac_interpret[OF fac_u \concat us \ \\] + obtain ps ss' p s vs where "p (concat us) s \\<^sub>\ vs" and + "ps \ vs \ ss' = ws' \ ws'" and "concat ps \ p = z" and "s \ concat ss' = su". + note fac_interpretE[OF \p (concat us) s \\<^sub>\ vs\] + + from prefixE[OF pref_ext[OF \us \p ws\]] + obtain ss where [symmetric]:"ws \ ws = us \ ss". + + have "ps \ vs \p ws' \ ws'" + unfolding \ps \ vs \ ss' = ws' \ ws'\[symmetric] lassoc using triv_pref. + + hence "vs \ lists \" + using \ws'\ lists \\ + by inlists + + from \concat (ws' \ ws') \p z \ concat (ws \ ws)\[folded arg_cong[OF \ps \ vs \ ss' = ws' \ ws'\, of concat] \us \ ss = ws \ ws\, + unfolded concat_morph, folded \p \ concat us \ s = concat vs\ \concat ps \ p = z\, + unfolded rassoc pref_cancel_conv] + have "s \p concat ss" + using append_prefixD by blast + + have "\<^bold>|p\<^bold>| \ \<^bold>|concat ws\<^bold>|" + using \\<^bold>|z\<^bold>| < \<^bold>|concat ws'\<^bold>|\[folded lenarg[OF \concat ps \ p = z\], unfolded \\<^bold>|concat ws'\<^bold>| = \<^bold>|concat ws\<^bold>|\] + by simp + + with eqd[reversed, OF conjug[folded \concat ps \ p = z\, unfolded lassoc, symmetric] this] + have "p \s concat ws" + by blast + + have disjoint: "p \ concat us' \ concat vs'" if "us' \p us" "vs' \p vs" for us' vs' + proof + have "us' \p ws \ ws" + using \us \p ws\ \us' \p us\ by auto + have "ps \ vs' \p ws' \ ws'" + using \vs' \p vs\ \ps \ vs \p ws' \ ws'\ pref_trans same_prefix_prefix by metis + assume "p \ concat us' = concat vs'" + hence "z \ concat us' = concat (ps \ vs')" + unfolding concat_morph \concat ps \ p = z\[symmetric] rassoc cancel. + thus False + using shift_disjoint[OF \ws \ lists \\ \ws' \ lists \\ \z \ \\\\ + \z \ concat ws = concat ws' \ z\ \us' \p ws \ ws\[folded pow_two] \ps \ vs' \p ws' \ ws'\[folded pow_two]] by fast + qed + from disjoint[of \ \] + have "p \ \" by blast + have "s \ \" + using \p \ concat us \ s = concat vs\ disjoint by auto + + from that[OF \p (concat us) s \\<^sub>\ vs\ \ps \ vs \p ws' \ ws'\ \us \ ss = ws \ ws\ \concat ps \ p = z\ \s \p concat ss\ \p \s concat ws\ \vs \ lists \\ + disjoint \p \ \\ \ s \ \\] + show thesis. +qed + +text\The conditions are in particular met by imprimitivity witnesses\ + +lemma imprim_witness_shift: + assumes "ws \ lists \" and "primitive ws" and "\ primitive (concat ws)" + obtains z n where "concat ws = z\<^sup>@Suc(Suc n)" "z \ \\\" and "z \ concat ws = concat ws \ z" and "\<^bold>|z\<^bold>| < \<^bold>|concat ws\<^bold>|" +proof- + have "concat ws \ \" + using \primitive ws\ emp_concat_emp'[OF \ws \ lists \\] emp_not_prim by blast + obtain z n where [symmetric]: "z\<^sup>@Suc(Suc n) = concat ws" + using not_prim_primroot_expE[OF \\ primitive (concat ws)\ \concat ws \ \\, of thesis] by force + + hence "z \ \" + using \concat ws \ \\ by force + + have "z \ \\\" + proof + assume "z \ \\\" + then obtain zs where "zs \ lists \" and "concat zs = z" + using hull_concat_lists0 by blast + from is_code[OF \ws \ lists \\ pow_in_lists[OF \zs \ lists \\], + unfolded concat_pow \concat ws = z\<^sup>@Suc(Suc n)\ \concat zs = z\] + show False + using \primitive ws\ pow_not_prim by blast + qed + + have "\<^bold>|z\<^bold>| < \<^bold>|concat ws\<^bold>|" + unfolding lenarg[OF \concat ws = z\<^sup>@Suc(Suc n)\, unfolded lenmorph pow_len] + using nemp_len[OF \z \ \\] by simp + + from that[OF \concat ws = z\<^sup>@Suc(Suc n)\ \z \ \\\\ _ this] + show thesis + unfolding \concat ws = z\<^sup>@Suc(Suc n)\ pow_comm by blast + +qed + +end + +section \Covered uniform square\ + +\ \Showing that two noncommuting words of the same length do not admit a non-trivial interpretation\ + +lemma cover_xy_xxx: assumes "\<^bold>|x\<^bold>| = \<^bold>|y\<^bold>|" and "p \ x \ y \ s = x \ x \ x" + shows "x = y" + using append_assoc assms(1) assms(2) eq_le_pref le_refl long_pref lq_triv prefI pref_comm_eq' by metis + +lemma cover_xy_yyy: assumes "\<^bold>|x\<^bold>| = \<^bold>|y\<^bold>|" and eq: "p \ x \ y \ s = y \ y \ y" + shows "x = y" + using cover_xy_xxx[reversed, unfolded rassoc, OF \\<^bold>|x\<^bold>| = \<^bold>|y\<^bold>|\[symmetric] eq, symmetric]. + +lemma cover_xy_xxy: assumes "\<^bold>|x\<^bold>| = \<^bold>|y\<^bold>|" and "s \ \" and eq: "p \ x \ y \ s = x \ x \ y" + shows "x = y" +proof- + have "\<^bold>|p\<^bold>| < \<^bold>|x\<^bold>|" + using lenarg[OF eq] nemp_pos_len[OF \s \ \\] unfolding lenmorph by linarith + then obtain t where x: "x = p \ t" and "t \ \" + using eqd[OF eq] by force + from eq[unfolded this rassoc cancel] + have "p \ t = t \ p" + by mismatch + hence "x \p t \ x" + unfolding x by auto + from eq[unfolded x] + have "y \p t \ y" + using \p \ t = t \ p\ \p \ t \ y \ s = t \ p \ t \ y\ pref_cancel' suf_marker_per_root triv_pref by metis + show "x = y" + using same_len_nemp_root_eq[OF \x \p t \ x\ \y \p t \ y\ \t \ \\ \\<^bold>|x\<^bold>| = \<^bold>|y\<^bold>|\]. +qed + +lemma cover_xy_xyy: assumes "\<^bold>|x\<^bold>| = \<^bold>|y\<^bold>|" and "p \ \" and eq: "p \ x \ y \ s = x \ y \ y" + shows "x = y" + using cover_xy_xxy[reversed, unfolded rassoc, OF assms(1)[symmetric] assms(2) eq].. + +lemma cover_xy_yyx: assumes "\<^bold>|x\<^bold>| = \<^bold>|y\<^bold>|" and eq: "p \ x \ y \ s = y \ y \ x" + shows "x = y" +proof- + have "\<^bold>|p\<^bold>| \ \<^bold>|y\<^bold>|" + using lenarg[OF eq] unfolding lenmorph by linarith + then obtain t where y: "y = p \ t" + using eqd[OF eq] by force + from eqd_eq[OF _ \\<^bold>|x\<^bold>| = \<^bold>|y\<^bold>|\[unfolded y swap_len[of p]], unfolded rassoc, + OF eq[unfolded this rassoc cancel]] + have x: "x = t \ p" by blast + from eq[unfolded x y rassoc cancel] + have "p \ t = t \ p" + by mismatch + thus "x = y" + unfolding x y.. +qed + +lemma cover_xy_yxx: assumes "\<^bold>|x\<^bold>| = \<^bold>|y\<^bold>|" and eq: "p \ x \ y \ s = y \ x \ x" + shows "x = y" + using cover_xy_yyx[reversed, unfolded rassoc, OF assms(1)[symmetric] eq].. + +lemma cover_xy_xyx: assumes "\<^bold>|x\<^bold>| = \<^bold>|y\<^bold>|" and "p \ \" and "s \ \" and eq: "p \ x \ y \ s = x \ y \ x" + shows "\ primitive (x \ y)" +proof + assume "primitive (x \ y)" + have "p \ (x \ y) \ (s \ y) = (x \ y) \ (x \ y)" + unfolding lassoc eq[unfolded lassoc].. + from prim_overlap_sqE[OF \primitive (x \ y)\ this] + show False + using \p \ \\ \s \ \\ by blast +qed + +lemma cover_xy_yxy: assumes "\<^bold>|x\<^bold>| = \<^bold>|y\<^bold>|" and "p \ \" and \s \ \\ and eq: "p \ x \ y \ s = y \ x \ y" + shows "\ primitive (x \ y)" + using cover_xy_xyx[reversed, unfolded rassoc, OF assms(1)[symmetric] assms(3) assms(2) eq]. + +lemma eq_append_not_prim: "x = y \ \ primitive (x \ y)" + by (metis append_Nil2 comm_not_prim prim_nemp) + +theorem uniform_square_interp: assumes "x\y \ y\x" and "\<^bold>|x\<^bold>| = \<^bold>|y\<^bold>|" and "vs \ lists {x,y}" + and "p (x \ y) s \\<^sub>\ vs" and "p \ \" +shows "\ primitive (x\y)" and "vs = [x,y,x] \ vs = [y,x,y]" +proof- + note fac_interpretE[OF \p (x \ y) s \\<^sub>\ vs\] + + have "vs \ \" + using \p \ (x \ y) \ s = concat vs\ assms(5) by force + have "\<^bold>|p\<^bold>| < \<^bold>|x\<^bold>|" + using prefix_length_less[OF \p

] lists_hd_in_set[OF \vs \ \\ \vs \ lists {x,y}\] + \\<^bold>|x\<^bold>| = \<^bold>|y\<^bold>|\ + by fastforce + have "\<^bold>|s\<^bold>| < \<^bold>|x\<^bold>|" + using suffix_length_less[OF \s ] \\<^bold>|x\<^bold>| = \<^bold>|y\<^bold>|\ lists_hd_in_set[reversed, OF \vs \ \\ \vs \ lists {x,y}\] + by fastforce + have "\<^bold>|concat vs\<^bold>| = \<^bold>|x\<^bold>| * \<^bold>|vs\<^bold>|" + using assms(2-3) + proof (induction vs, force) + case (Cons a vs) + have "\<^bold>|a\<^bold>| = \<^bold>|x\<^bold>|" and "\<^bold>|a # vs\<^bold>| = Suc \<^bold>|vs\<^bold>|" and + "\<^bold>|concat (a # vs)\<^bold>| = \<^bold>|a\<^bold>| + \<^bold>|concat vs\<^bold>|" and "\<^bold>|concat vs\<^bold>| = \<^bold>|x\<^bold>| * \<^bold>|vs\<^bold>|" + using \a#vs \ lists {x,y}\ \\<^bold>|x\<^bold>| = \<^bold>|y\<^bold>|\ Cons.IH Cons.prems by auto + then show ?case by force + qed + note leneq = lenarg[OF \p \ (x \ y) \ s = concat vs\, unfolded this lenmorph \\<^bold>|x\<^bold>| = \<^bold>|y\<^bold>|\[symmetric]] + hence "\<^bold>|x\<^bold>| * \<^bold>|vs\<^bold>| < \<^bold>|x\<^bold>| * 4" and "2 * \<^bold>|x\<^bold>| < \<^bold>|x\<^bold>| * \<^bold>|vs\<^bold>| " + using \\<^bold>|p\<^bold>| < \<^bold>|x\<^bold>|\ \\<^bold>|s\<^bold>| < \<^bold>|x\<^bold>|\ nemp_pos_len[OF \p \ \\] by linarith+ + hence "\<^bold>|vs\<^bold>| = 3" + by force + hence "s \ \" + using leneq \\<^bold>|p\<^bold>| < \<^bold>|x\<^bold>|\ by force + + have "x \ y" + using assms(1) by blast + with \\<^bold>|vs\<^bold>| = 3\ \vs \ lists {x,y}\ \p \ (x \ y) \ s = concat vs\ + have "(\ primitive (x\y)) \ (vs = [x,y,x] \ vs = [y,x,y])" + proof(list_inspection, simp_all) + assume "p \ x \ y \ s = x \ x \ x" + from cover_xy_xxx[OF \\<^bold>|x\<^bold>| = \<^bold>|y\<^bold>|\ this] + show False + using \x \ y\ by blast + next + assume "p \ x \ y \ s = x \ x \ y" + from cover_xy_xxy[OF \\<^bold>|x\<^bold>| = \<^bold>|y\<^bold>|\ \s \ \\ this] + show False + using \x \ y\ by blast + next + assume "p \ x \ y \ s = x \ y \ x" + from cover_xy_xyx[OF \\<^bold>|x\<^bold>| = \<^bold>|y\<^bold>|\ \p \ \\ \s \ \\ this] + show "\ primitive (x \ y)" + by blast + next + assume "p \ x \ y \ s = x \ y \ y" + from cover_xy_xyy[OF \\<^bold>|x\<^bold>| = \<^bold>|y\<^bold>|\ \p \ \\ this] + show False + using \x \ y\ by blast + next + assume "p \ x \ y \ s = y \ x \ x" + from cover_xy_yxx[OF \\<^bold>|x\<^bold>| = \<^bold>|y\<^bold>|\ this] + show False + using \x \ y\ by blast + next + assume "p \ x \ y \ s = y \ x \ y" + from cover_xy_yxy[OF \\<^bold>|x\<^bold>| = \<^bold>|y\<^bold>|\ \p \ \\ \s \ \\ this] + show "\ primitive (x \ y)" + by blast + next + assume "p \ x \ y \ s = y \ y \ x" + from cover_xy_yyx[OF \\<^bold>|x\<^bold>| = \<^bold>|y\<^bold>|\ this] + show False + using \x \ y\ by blast + next + assume "p \ x \ y \ s = y \ y \ y" + from cover_xy_yyy[OF \\<^bold>|x\<^bold>| = \<^bold>|y\<^bold>|\ this] + show False + using \x \ y\ by blast + qed + thus "\ primitive (x\y)" "vs = [x,y,x] \ vs = [y,x,y]" + by blast+ +qed + +subsection \Primitivity (non)preserving uniform binary codes\ + +\ \This in particular implies the following characterization of uniform binary primitive codes. Cf. V. Mitrana, Primitive morphisms, Information Processing Letters 64 (1997), 277--281\ + +theorem bin_uniform_prim_morph: + assumes "x \ y \ y \ x" and "\<^bold>|x\<^bold>| = \<^bold>|y\<^bold>|" and "primitive (x \ y)" + and "ws \ lists {x,y}" and "2 \ \<^bold>|ws\<^bold>|" + shows "primitive ws \ primitive (concat ws)" +proof (standard, rule ccontr) + assume \primitive ws\ and \\ primitive (concat ws)\ + from bin_prim_long_pref[OF \ws \ lists {x,y}\ \primitive ws\ \2 \ \<^bold>|ws\<^bold>|\] + obtain ws' where "ws \ ws'" "[x, y] \p ws'". + have "ws' \ lists {x,y}" + using conjug_in_lists'[OF \ws \ ws'\ \ws \ lists {x,y}\]. + have "primitive ws'" + using prim_conjug[OF \primitive ws\ \ws \ ws'\]. + have "\ primitive (concat ws')" + using conjug_concat_prim_iff \\ primitive (concat ws)\ \ws \ ws'\ by auto + interpret code "{x,y}" + using bin_code_code[OF \x \ y \ y \ x\]. + + have "[x,y] \ \" by blast + from imprim_witness_shift[OF \ws' \ lists {x,y}\ \primitive ws'\ \\ primitive (concat ws')\] + obtain z n where "concat ws' = z \<^sup>@ Suc (Suc n)" "z \ \{x, y}\" "z \ concat ws' = concat ws' \ z" "\<^bold>|z\<^bold>| < \<^bold>|concat ws'\<^bold>|". + from shift_interpret[OF \ws' \ lists {x,y}\ \ws' \ lists {x,y}\ this(2-4) \[x,y] \p ws'\ \[x,y] \ \\] + obtain vs p s where "vs \ lists {x,y}" "p (concat [x, y]) s \\<^sub>\ vs" "p \ \" by metis + from uniform_square_interp(1)[OF \x \ y \ y \ x\ \\<^bold>|x\<^bold>| = \<^bold>|y\<^bold>|\ \vs \ lists {x,y}\ _ \p \ \\] + \primitive (x \ y)\ \p (concat [x, y]) s \\<^sub>\ vs\ + show False by force +qed (simp add: prim_concat_prim) + +\ \A stronger version is implied by the following lemma.\ + +lemma bin_uniform_imprim: assumes "x \ y \ y \ x" and "\<^bold>|x\<^bold>| = \<^bold>|y\<^bold>|" and "\ primitive x" + shows "primitive (x \ y)" +proof (rule ccontr) + obtain s n where "s\<^sup>@n = x" and "2 \ n" + using not_prim_pow[OF \\ primitive x\]. + assume "\ primitive (x \ y)" + have "x \ y \ \" + using \x \ y \ y \ x\ by blast + from not_prim_expE[OF \\ primitive (x \ y)\ this] + obtain z k where "primitive z" and "2 \ k" and "z\<^sup>@k = x \ y". + from split_pow[OF \x \ y \ y \ x\ \z\<^sup>@k = x \ y\[symmetric]] + obtain l m u v where "z \<^sup>@ l \ u = x" "v \ z \<^sup>@ m = y" "u \ v = z" "u \ v \ v \ u" "k = Suc (l + m)". + have "u \ \" and "v \ \" + using \u \ v \ v \ u\ by blast+ + have "m = l" and "\<^bold>|u\<^bold>| = \<^bold>|v\<^bold>|" + using almost_equal_equal[OF nemp_len[OF \u \ \\] nemp_len[OF \v \ \\], of l m] lenarg[OF \z\<^sup>@l \ u = x\[symmetric], unfolded \\<^bold>|x\<^bold>| =\<^bold>|y\<^bold>|\, folded lenarg[OF \v \ z\<^sup>@m = y\]] unfolding lenmorph pow_len + lenarg[OF \u \ v = z\, symmetric] by presburger+ + have "x \p z \ x" + using pref_prod_root[OF pref_ext[of x, OF self_pref, of y, folded \z\<^sup>@k = x \ y\]]. + have "x \p s \ x" + unfolding \s\<^sup>@n = x\[symmetric] using pref_prod_root by blast + have "z \ s \ s \ z" + using \x \ y \ y \ x\ comm_add_exps[of s z n k, unfolded \s \<^sup>@ n = x\ \z \<^sup>@ k = x \ y\ rassoc cancel] + by force + with two_pers[OF \x \p z \ x\ \x \p s \ x\] + have "\<^bold>|x\<^bold>| < \<^bold>|z\<^bold>| + \<^bold>|s\<^bold>|" by linarith + have "l = 1" + proof (rule ccontr) + assume "l \ 1" hence "2 \ l" + using \k = Suc (l + m)\ \2 \ k\ unfolding \m = l\ by force + from trans_le_add1[OF mult_le_mono1[OF this]] + have "2*\<^bold>|z\<^bold>| \ \<^bold>|x\<^bold>|" + unfolding lenarg[OF \z\<^sup>@l \ u = x\, unfolded pow_len lenmorph, symmetric]. + from mult_le_mono1[OF \2 \ n\] + have "2*\<^bold>|s\<^bold>| \ \<^bold>|x\<^bold>|" + unfolding lenarg[OF \s\<^sup>@n = x\, unfolded pow_len lenmorph, symmetric]. + hence "2*\<^bold>|z\<^bold>| + 2*\<^bold>|s\<^bold>| \ 2*\<^bold>|x\<^bold>|" + using \2*\<^bold>|z\<^bold>| \ \<^bold>|x\<^bold>|\ by force + thus False + using mult_less_mono1[OF \\<^bold>|x\<^bold>| < \<^bold>|z\<^bold>| + \<^bold>|s\<^bold>|\, of 2] by force + qed + hence "x = u \ v \ u" + using \u \ v = z\ \z \<^sup>@ l \ u = x\ by fastforce + have "u \ v" + using \u \ v \ v \ u\ by blast + hence "primitive [u,v,u]" + by primitivity_inspection + hence "primitive [u,v,u] \ primitive (concat [u, v, u])" + using \x = u \ v \ u\ \\ primitive x\ by auto + with bin_uniform_prim_morph[OF \u \ v \ v \ u\ \\<^bold>|u\<^bold>| = \<^bold>|v\<^bold>|\ \primitive z\[folded \u \ v = z\], of "[u,v,u]"] + show False by simp +qed + +theorem bin_uniform_prim_morph': + assumes "x \ y \ y \ x" and "\<^bold>|x\<^bold>| = \<^bold>|y\<^bold>|" and "primitive (x \ y) \ \ primitive x" + and "ws \ lists {x,y}" and "2 \ \<^bold>|ws\<^bold>|" + shows "primitive ws \ primitive (concat ws)" + using bin_uniform_prim_morph[OF assms(1-2) _ assms(4-5)] bin_uniform_imprim[OF assms(1-2)] assms(3) by fast + +section \The main theorem\ + +subsection \Imprimitive words with single y\ + +text \If the shorter word occurs only once, the result is straightforward from the parametric solution of the Lyndon-Schutzenberger + equation.\ + +lemma bin_imprim_single_y: + assumes non_comm: "x \ y \ y \ x" and + "ws \ lists {x,y}" and + "\<^bold>|y\<^bold>| \ \<^bold>|x\<^bold>|" and + "2 \ count_list ws x" and + "count_list ws y < 2" and + "primitive ws" and + "\ primitive (concat ws)" + shows "ws \ [x,x,y]" and "primitive x" and "primitive y" +proof- + have "x \ y" + using non_comm by blast + have "count_list ws y \ 0" + proof + assume "count_list ws y = 0" + from bin_lists_count_zero'[OF \ws \ lists {x,y}\ this] + have "ws \ lists {x}". + from prim_exp_one[OF \primitive ws\ sing_lists_exp_count[OF this]] + show False + using \2 \ count_list ws x\ by simp + qed + hence "count_list ws y = 1" + using \count_list ws y < 2\ by linarith + + from this bin_count_one_conjug[OF \ws \ lists {x,y}\ _ this] + have "ws \ [x]\<^sup>@count_list ws x \ [y]" + using non_comm (1) by metis + from conjug_concat_prim_iff[OF this] + have "\ primitive (x\<^sup>@(count_list ws x) \ y)" + using \\ primitive (concat ws)\ by (auto simp add: concat_pow) + + from not_prim_pow[OF this] + obtain z l where [symmetric]: "z\<^sup>@l = x\<^sup>@(count_list ws x) \ y\<^sup>@1" and "2 \ l" + unfolding pow_one'. + + interpret LS_len_le x y "count_list ws x" 1 l z + apply (unfold_locales; fact?) + using \2 \ count_list ws x\ by auto + + from case_j2k1[OF \2 \ count_list ws x\ refl] + have "primitive x" and "primitive y" and "count_list ws x = 2" by blast+ + + with \ws \ [x]\<^sup>@count_list ws x \ [y]\[unfolded this(3) pow_two append_Cons append_Nil] + show "primitive x" and "primitive y" and "ws \ [x,x,y]" + by simp_all + +qed + +subsection \Conjugate words\ + + +lemma bin_imprim_not_conjug: + assumes "ws \ lists {x,y}" and + "x \ y \ y \ x" and + "2 \ \<^bold>|ws\<^bold>|" and + "primitive ws" and + "\ primitive (concat ws)" + shows "\ x \ y" +proof + assume "x \ y" + hence "\<^bold>|x\<^bold>| = \<^bold>|y\<^bold>|" by force + from bin_uniform_prim_morph[OF \x \ y \ y \ x\ this _ \ws \ lists {x,y}\ \2 \ \<^bold>|ws\<^bold>|\] + have "\ primitive (x\y)" + using \primitive ws\ \\ primitive (concat ws)\ by blast + + (* have "[x,y] \ \" and "\<^bold>|[x,y]\<^bold>| \ \<^bold>|ws\<^bold>|" and "concat[x,y] = x \ y" *) + (* using \2 \ \<^bold>|ws\<^bold>|\ by auto *) + + (* interpret binary_code x y *) + (* using \x \ y \ y \ x\ by unfold_locales *) + (* from switch_fac[OF bin_code_neq bin_prim_long_set[OF \ws \ lists {x,y}\ \primitive ws\ \2 \ \<^bold>|ws\<^bold>|\]] *) + (* have "[x,y] \f ws \ ws". *) + (* from rotate_into_pref_sq[OF this] *) + (* obtain ws' where "ws \ ws'" and "[x,y] \p ws'" *) + (* using \2 \ \<^bold>|ws\<^bold>|\ by auto *) + + (* have "ws' \ lists {x,y}" and "primitive ws'" and "\ primitive (concat ws')" *) + (* using \ws \ lists {x,y}\[unfolded conjug_in_lists_iff [OF \ws \ ws'\]] *) + (* prim_conjug[OF \primitive ws\ \ws \ ws'\] *) + (* \\ primitive (concat ws)\[unfolded conjug_concat_prim_iff[OF \ws \ ws'\]]. *) + + (* from imprim_witness_shift[OF \ws' \ lists {x,y}\ \primitive ws'\ \\ primitive (concat ws')\] *) + (* obtain z where "z \ \{x, y}\" and "z \ concat ws' = concat ws' \ z" and "\<^bold>|z\<^bold>| < \<^bold>|concat ws'\<^bold>|". *) + + (* from shift_interpret[OF \ws' \ lists {x,y}\ \ws' \ lists {x,y}\ this \[x,y] \p ws'\ \[x,y] \ \\] *) + (* obtain p s vs where "p (x \ y) s \\<^sub>\ vs" and \vs \ lists {x, y}\ and *) + (* disjoint: "(\us' vs'. us' \p [x, y] \ vs' \p vs \ p \ concat us' \ concat vs')" *) + (* unfolding \concat [x,y] = x \ y\ by metis *) + (* from disjoint[of \ \] have "p \ \" by simp *) + + (* from uniform_square_interp(1)[OF \x\y \ y\x\ conjug_len[OF \x \ y\] \vs \ lists {x, y}\ *) + (* \p (x \ y) s \\<^sub>\ vs\ \p \ \\] *) + (* have "\ primitive (x \ y)". *) + + from Lyndon_Schutzenberger_conjug[OF \x \ y\ this] + show False + using \x \ y \ y \ x\ by blast +qed + +subsection \Square prefix of the longer word and both words primitive (was all\_assms\ + +text\The main idea of the proof is as follows: Imprimitivity of the concatenation yields +(at least) two overlapping factorizations into @{term "{x,y}"}. +Due to the presence of the square @{term "x \ x"}, these two can be synchronized, which yields that the +situation coincides with the canonical form. +\ + +lemma bin_imprim_primitive: + assumes "x \ y \ y \ x" + and "primitive x" and "primitive y" + and "\<^bold>|y\<^bold>| \ \<^bold>|x\<^bold>|" + and "ws \ lists {x, y}" + and "primitive ws" and "\ primitive (concat ws)" + and "[x, x] \f ws \ ws" + shows "ws \ [x, x, y]" +proof- + have "x \ y" + using assms(1) by blast + hence "2 \ \<^bold>|ws\<^bold>|" + by (metis Cons_in_lists_iff Suc_1 Suc_leI assms(2) assms(3) assms(5) assms(6) assms(7) nemp_le_len order_le_less prim_nemp sing_word_concat two_elem_cases) + have "\<^bold>|[x, x]\<^bold>| \ \<^bold>|ws\<^bold>|" + using \2 \ \<^bold>|ws\<^bold>|\ by force + obtain ws' where "ws \ ws'" "[x,x] \p ws'" + using rotate_into_pos_sq[of \ "[x,x]", unfolded clean_emp, OF \[x, x] \f ws \ ws\ + _ \\<^bold>|[x, x]\<^bold>| \ \<^bold>|ws\<^bold>|\] + by auto + + have "ws' \ lists {x,y}" + by (meson \ws \ ws'\ assms(5) conjug_in_lists') + have "primitive ws'" + by (meson \ws \ ws'\ assms(6) prim_conjug) + have "\ primitive (concat ws')" + using \ws \ ws'\ assms(7) conjug_concat_prim_iff by blast + + have "ws' = [x,x,y]" + proof(rule ccontr) + assume "ws' \ [x,x,y]" + + have "2 \ \<^bold>|ws'\<^bold>|" and "[x,x] \ \" + using \[x,x] \p ws'\ unfolding prefix_def by auto + have "x \ y" + using prim_exp_eq[OF \primitive ws'\ sing_lists_exp_len] \ws' \ lists {x,y}\ \[x,x] \p ws'\ by force + hence "x \ y \ y \ x" + using comm_prim[OF \primitive x\ \primitive y\] by blast + from bin_imprim_not_conjug[OF \ws' \ lists {x,y}\ this \2 \ \<^bold>|ws'\<^bold>|\ \primitive ws'\ \\ primitive (concat ws')\] + have "\ x \ y". + have "[x,x] \np ws'" + using npI[OF _ \[x,x] \p ws'\] by blast + have "concat ws' \ \" + using \primitive x\ \[x,x] \p ws'\ by (fastforce simp add: prefix_def) + have "ws' \ \" + using \concat ws' \ \\ by auto + have "ws' \ ws' \ ws' \ lists {x, y}" and "ws' \ ws' \ lists {x, y}" + using \ws' \ lists {x,y}\ by inlists + have "concat [x,x] = x \ x" by simp + + have "primitive [x,x,y]" + using \x \ y\ by primitivity_inspection + + interpret xy: binary_code x y + using \x \ y \ y \ x\ by (unfold_locales) + + from xy.imprim_witness_shift[OF \ws' \ lists {x,y}\ \primitive ws'\ \\ primitive (concat ws')\] + obtain z n where con_ws: "concat ws' = z \<^sup>@ Suc (Suc n)" and "z \ \{x, y}\" and "z \ concat ws' = concat ws' \ z" and "\<^bold>|z\<^bold>| < \<^bold>|concat ws'\<^bold>|". + + obtain vs p s ps ss where "p (x \ x) s \\<^sub>\ vs" and "ps \ vs \p ws' \ ws'" and + "[x, x] \ ss = ws' \ ws'" and \concat ps \ p = z\ and "s \p concat ss" and "p \s concat ws'" and \vs \ lists {x, y}\ and + disjoint: "(\us' vs'. us' \p [x, x] \ vs' \p vs \ p \ concat us' \ concat vs')" and "p \ \" and "s \ \" + using xy.shift_interpret[OF \ws' \ lists {x,y}\ \ws' \ lists {x,y}\ \z \ \{x, y}\\ \z \ concat ws' = concat ws' \ z\ + \\<^bold>|z\<^bold>| < \<^bold>|concat ws'\<^bold>|\ \[x,x] \p ws'\ \[x,x] \ \\, of thesis] + unfolding \concat [x,x] = x \ x\ by fast + from disjoint[of \ \] have "p \ \" by simp + + have triv: "2 \ Suc(Suc n)" "Suc 0 < Suc (Suc n)" by simp_all + + have "ps \ lists {x,y}" + using \ps \ vs \p ws' \ ws'\ \ws' \ lists {x,y}\ \ws' \ ws' \ lists {x, y}\ append_prefixD pref_in_lists by metis + have "vs \ lists {x,y}" + using \ws' \ lists {x,y}\ pref_in_lists[OF \ps \ vs \p ws' \ ws'\] by inlists + have "ss \ lists {x,y}" + using \ws' \ lists {x,y}\ \[x,x] \ ss = ws' \ ws'\ append_in_lists_conv by metis + + interpret square_interp_ext x y p s vs + by (rule square_interp_ext.intro[OF square_interp.intro, unfolded square_interp_ext_axioms_def, + OF \primitive x\ \primitive y\ \\<^bold>|y\<^bold>| \ \<^bold>|x\<^bold>|\ \vs \ lists {x,y}\ \\ x \ y\ disjoint], simp_all only: \p x \ x s \\<^sub>\ vs\) + (meson \p \s concat ws'\ \s \p concat ss\ \ss \ lists {x, y}\ \ws' \ lists {x, y}\ concat_in_hull') + +\ \Establishing the connection between ws' = [x,x,y] and z = xp.\ + + define xp where "xp = x \ p" + + have "concat [x,x,y] = xp \ xp" + by (simp add: xxy_root xp_def) + + hence "ws' \ [x,x,y] \ [x,x,y] \ ws'" + using comm_prim[OF \primitive ws'\ \primitive [x,x,y]\] \ws' \ [x,x,y] \by force + + have "z \ xp \ xp \ z" + proof + assume "z \ xp = xp \ z" + from power_commuting_commutes[symmetric, OF this[symmetric], of 2, + THEN power_commuting_commutes, of "Suc (Suc n)", unfolded pow_two] + have "z\<^sup>@Suc(Suc n) \ xp \ xp = xp \ xp \ z\<^sup>@Suc(Suc n)" + unfolding rassoc. + hence "concat ws' \ concat [x,x,y] = concat [x,x,y] \ concat ws'" + unfolding con_ws \concat [x,x,y] = xp \ xp\ rassoc by simp + from xy.is_code[OF _ _ this[folded concat_morph]] + have "ws' \ [x, x, y] = [x,x,y] \ ws'" + using append_in_lists \ws' \ lists {x,y}\ by simp + thus False + using \ws' \ [x, x, y] \ [x,x,y] \ ws'\ by fastforce + qed + + then interpret binary_code z xp + by (unfold_locales) + + have "\ concat (ws' \ [x, x, y]) \ concat ([x, x, y] \ ws')" + proof (rule notI) + assume "concat (ws' \ [x, x, y]) \ concat ([x, x, y] \ ws')" + from comm_comp_eq[OF this[unfolded concat_morph], unfolded \concat [x,x,y] = xp \ xp\ con_ws] + have "z \<^sup>@ Suc (Suc n) \ xp\<^sup>@Suc(Suc 0) = xp\<^sup>@Suc(Suc 0) \ z \<^sup>@ Suc (Suc n)" + unfolding pow_Suc pow_zero clean_emp rassoc. + from comm_drop_exps[OF this] + show False + using \z \ xp \ xp \ z\ by blast + qed + +\ \How the xp/z mismatch is reflected by mismatch in lists {x,y}?\ +\ \Looking at the first occurrence of z:\ + + define lcp_ws where "lcp_ws = ws' \ [x,x,y] \\<^sub>p [x,x,y] \ ws'" + + have "lcp_ws \ lists {x,y}" + unfolding lcp_ws_def by inlists + + have lcp_xp_z: "concat (ws' \ [x,x,y]) \\<^sub>p concat ([x,x,y] \ ws') = bin_lcp z (x \ p)" + unfolding concat_morph con_ws \concat [x,x,y] = xp \ xp\ add_exps[symmetric] + using bin_lcp_pows[of "Suc n" "(x\p)\<^sup>@Suc 0" "Suc 0" "z\<^sup>@(Suc n)"] + unfolding xp_def pow_Suc pow_zero clean_emp rassoc. + + have "(concat lcp_ws) \ bin_lcp x y = bin_lcp z (x \ p)" + proof (rule xy.bin_code_lcp_concat'[OF _ _ \\ concat (ws' \ [x, x, y]) \ concat ([x, x, y] \ ws')\, folded lcp_ws_def, unfolded lcp_xp_z, symmetric]) + show "ws' \ [x, x, y] \ lists {x, y}" and "[x, x, y] \ ws' \ lists {x, y}" + by inlists + qed + +\ \Looking at the second occurrence of z:\ + + define ws'' where "ws'' = ps \ [x,y]" + define lcp_ws' where "lcp_ws' = ws' \ ws'' \\<^sub>p ws'' \ ws'" + + have "lcp_ws' \ lists {x,y}" + unfolding lcp_ws'_def + using \ps \ lists {x, y}\ \ws' \ lists {x, y}\ ws''_def by inlists + + have "concat ws'' = z \ xp" + unfolding ws''_def xp_def using \concat ps \ p = z\ xxy_root by fastforce + + have "ws' \ ws'' \ ws'' \ ws'" + proof + assume "ws' \ ws'' = ws'' \ ws'" + from arg_cong[OF this, of concat, unfolded concat_morph con_ws + \concat ws'' = z \ xp\, + unfolded lassoc pow_comm, unfolded rassoc cancel] + show False + using \z \ xp \ xp \ z\ comm_drop_exp' by blast + qed + + have + lcp_xp_z': "concat (ws' \ ws'') \\<^sub>p concat (ws'' \ ws') = z \ bin_lcp z (x \ p)" + unfolding concat_morph con_ws \concat ws'' = z \ xp\ pow_Suc + unfolding lassoc cancel + unfolding rassoc lcp_ext_left cancel + using bin_lcp_pows[of "(Suc n)" \ 0 "z \ z\<^sup>@n", unfolded pow_one rassoc clean_emp] + unfolding lassoc pow_Suc[symmetric] pow_Suc2[symmetric] + using xp_def by auto + + have "z \ bin_lcp z (x \ p) = concat (lcp_ws') \ bin_lcp x y" + unfolding lcp_xp_z'[symmetric] lcp_ws'_def + proof (rule xy.bin_code_lcp_concat') + show "ws' \ ws'' \ lists {x, y}" + unfolding ws''_def using \ws' \ ws' \ ws' \ lists {x, y}\ \ps \ lists {x,y}\ by inlists + thus "ws'' \ ws' \ lists {x, y}" + by inlists + show "\ concat (ws' \ ws'') \ concat (ws'' \ ws')" + unfolding concat_morph con_ws \concat ws'' = z \ xp\ pow_Suc rassoc comp_cancel + unfolding lassoc pow_Suc[symmetric] pow_Suc2[symmetric] comm_comp_eq_conv + comm_drop_exps_conv[of _ _ _ 0, unfolded pow_one] + using non_comm. + qed + + have "concat lcp_ws' = z \ concat lcp_ws" + unfolding cancel_right[of "concat lcp_ws'" "bin_lcp x y" "z \ concat lcp_ws", symmetric] + unfolding rassoc[of z] \concat (lcp_ws) \ bin_lcp x y = bin_lcp z (x \ p)\ \z \ bin_lcp z (x \ p) = concat (lcp_ws') \ bin_lcp x y\.. + + have "lcp_ws \p ws' \ [x,x,y]" + unfolding lcp_ws_def using longest_common_prefix_prefix1. + have "lcp_ws \ ws' \ [x,x,y]" + unfolding lcp_ws_def lcp_pref_conv + using \ws' \ [x, x, y] \ [x, x, y] \ ws'\ pref_comm_eq by blast + have "lcp_ws \p ws' \ [x,x]" + using spref_butlast_pref[OF \lcp_ws \p ws' \ [x,x,y]\ \lcp_ws \ ws' \ [x,x,y]\] + unfolding butlast_append by simp + from prefixE[OF pref_prolong[OF this \[x,x] \p ws'\]] + obtain ws''\<^sub>1 where "ws' \ ws' \ ws' = lcp_ws \ ws''\<^sub>1" using rassoc by metis + + have "ws' \ ps \ [x,y] \p ws' \ ps \ [x,y,x]" + by simp + from pref_trans[OF pref_trans[OF longest_common_prefix_prefix1 this]] + have "lcp_ws' \p ws' \ ws' \ ws'" + unfolding lcp_ws'_def ws''_def using \ps \ vs \p ws' \ ws'\[unfolded cover_xyx, unfolded pref_cancel_conv] + unfolding pref_cancel_conv[symmetric, of "ps \ [x,y,x]" "ws' \ ws'" ws'] by blast + from prefixE[OF this] + obtain ws''\<^sub>2 where "ws' \ ws' \ ws' = lcp_ws' \ ws''\<^sub>2". + + have "concat lcp_ws'\ concat ws''\<^sub>1 = z \ concat(lcp_ws) \ concat ws''\<^sub>1" + unfolding lassoc \concat lcp_ws' = z \ concat lcp_ws\.. + also have "... = z \ concat (ws' \ ws' \ ws')" + unfolding rassoc \ws' \ ws' \ ws' = lcp_ws \ ws''\<^sub>1\ concat_morph.. + also have "... = concat (ws' \ ws' \ ws') \ z" + unfolding concat_morph con_ws add_exps[symmetric] + pow_Suc[symmetric] pow_Suc2[symmetric].. + also have "... = concat lcp_ws'\ concat ws''\<^sub>2 \ z" + unfolding \ws' \ ws' \ ws' = lcp_ws' \ ws''\<^sub>2\ concat_morph rassoc.. + finally have "concat ws''\<^sub>1 = concat ws''\<^sub>2 \ z" + unfolding cancel. + + from xy.stability[of "concat ws''\<^sub>2" "concat lcp_ws" z, + folded \concat ws''\<^sub>1 = concat ws''\<^sub>2 \ z\ \concat lcp_ws' = z \ concat lcp_ws\] + have "z \ \{x, y}\" + using \ws' \ ws' \ ws' = lcp_ws \ ws''\<^sub>1\ \ws' \ ws' \ ws' = lcp_ws' \ ws''\<^sub>2\ \ws' \ ws' \ ws' \ lists {x, y}\ + append_in_lists_dest append_in_lists_dest' concat_in_hull' by metis + thus False + using \z \ \{x,y}\\ by blast + qed + thus ?thesis + using \ws \ ws'\ by blast +qed + +subsection \Obtaining primitivity with two squares (refining)\ + +lemma bin_imprim_both_squares_prim: + assumes "x \ y \ y \ x" + and "ws \ lists {x, y}" + and "primitive ws" and "\ primitive (concat ws)" + and "[x, x] \f ws \ ws" + and "[y, y] \f ws \ ws" + and "primitive x" and "primitive y" + shows False +proof- + have "x \ y" using \x \ y \ y \ x\ + by blast + from bin_imprim_primitive[OF \x \ y \ y \ x\ \primitive x\ \primitive y\ + _ \ws \ lists {x,y}\ \primitive ws\ \\ primitive (concat ws)\ \[x, x] \f ws \ ws\] + bin_imprim_primitive[OF \x \ y \ y \ x\[symmetric] \primitive y\ \primitive x\ + _ \ws \ lists {x,y}\[unfolded insert_commute[of x]] \primitive ws\ \\ primitive (concat ws)\ + \[y, y] \f ws \ ws\] + have "ws \ [x, x, y] \ ws \ [y, y, x]" + using \x \ y \ y \ x\ + by force + hence "\<^bold>|ws\<^bold>| = 3" + using conjug_len by force + note[simp] = sublist_code(3) + from \\<^bold>|ws\<^bold>| = 3\ \ws \ lists {x,y}\ \x \ y\ + \[x, x] \f ws \ ws\ \[y, y] \f ws \ ws\ + show False + by list_inspection simp_all +qed + +lemma bin_imprim_both_squares: + assumes "x \ y \ y \ x" + and "ws \ lists {x, y}" + and "primitive ws" and "\ primitive (concat ws)" + and "[x, x] \f ws \ ws" + and "[y, y] \f ws \ ws" + shows False +proof (rule bin_imprim_both_squares_prim) + have "x \ \" and "y \ \" and "x \ y" + using \x \ y \ y \ x\ by blast+ + let ?R = "\ x. [\ x]\<^sup>@(e\<^sub>\ x)" + define ws' where "ws' = concat (map ?R ws)" + show "\ x \ \ y \ \ y \ \ x" + using \x \ y \ y \ x\[unfolded comp_primroot_conv'[OF \x \ \\ \y \ \\]]. + have [simp]: "a = x \ a = y \ [\ a] \<^sup>@ e\<^sub>\ a \ lists {\ x, \ y}" for a + using insert_iff sing_pow_lists[of _ "{\ x, \ y}"] by metis + show "ws' \ lists {\ x, \ y}" + unfolding ws'_def using \ws \ lists {x,y}\ + by (induction ws, simp_all) + +\ \The primitivity of ws' is obtained from the fact that the decompositions into + roots is a primitive morphism\ + interpret binary_code x y + using \x \ y \ y \ x\ by unfold_locales + note[simp] = sublist_code(3) + have "\<^bold>|ws\<^bold>| \ 3 \ ws \ lists {x,y} \ x \ y \ [x, x] \f ws \ ws \ [y, y] \f ws \ ws \ False" + by list_inspection simp_all + from this[OF _ \ ws \ lists {x,y}\ \x \ y\ \[x, x] \f ws \ ws\ \[y, y] \f ws \ ws\] + roots_prim_morph[OF \ws \ lists {x,y}\ _ \primitive ws\] + show "primitive ws'" + unfolding ws'_def by fastforce + + show "\ primitive (concat ws')" + unfolding ws'_def concat_root_dec_eq_concat[OF \ws \ lists{x,y}\] by fact + + have "concat(map ?R [x,x]) \f ws' \ ws'" and "concat(map ?R [y,y]) \f ws' \ ws'" + unfolding ws'_def + using concat_mono_fac[OF map_mono_sublist[OF \[x,x] \f ws \ ws\]] + concat_mono_fac[OF map_mono_sublist[OF \[y,y] \f ws \ ws\]] + unfolding concat_morph map_append. + + have "Suc (Suc (e\<^sub>\ x + e\<^sub>\ x - 2)) = e\<^sub>\ x + e\<^sub>\ x" + using Suc_minus2 primroot_exp_nemp[OF \x \ \\] by simp + have "concat (map ?R [x,x]) = [\ x] \<^sup>@ (Suc (e\<^sub>\ x -1) + Suc (e\<^sub>\ x - 1))" + unfolding Suc_minus[OF primroot_exp_nemp[OF \x \ \\]] by (simp add: add_exps) + hence "[\ x, \ x] \f concat (map ?R [x,x])" + by auto + thus "[\ x, \ x] \f ws' \ ws'" + using fac_trans[OF _ \concat(map ?R [x,x]) \f ws' \ ws'\] by blast + + have "Suc (Suc (e\<^sub>\ y + e\<^sub>\ y - 2)) = e\<^sub>\ y + e\<^sub>\ y" + using Suc_minus2 primroot_exp_nemp[OF \y \ \\] by simp + have "concat (map ?R [y,y]) = [\ y] \<^sup>@ (Suc (e\<^sub>\ y -1) + Suc (e\<^sub>\ y - 1))" + unfolding Suc_minus[OF primroot_exp_nemp[OF \y \ \\]] by (simp add: add_exps) + hence "[\ y, \ y] \f concat (map ?R [y,y])" + by auto + thus "[\ y, \ y] \f ws' \ ws'" + using fac_trans[OF _ \concat(map ?R [y,y]) \f ws' \ ws'\] by blast + + show "primitive (\ x)" and "primitive (\ y)" + using primroot_prim \x \ \\ \y \ \\ by blast+ +qed + +subsection \Obtaining the square of the longer word (gluing)\ + +lemma bin_imprim_longer_twice: + \ \ +1. If there are both squares, then contradiction; +2. If a square is missing: + a) if y appears once: the positive conclusion + b) if y appears twice, then gluing preserves presence of the longer word at least twice (because both appear twice) + and induction yields [x',x',y'] where y' is a suffix of x', + a contradiction with primitivity of words of the form xyxyy; +\ + assumes "x \ y \ y \ x" + and "ws \ lists {x, y}" + and "\<^bold>|y\<^bold>| \ \<^bold>|x\<^bold>|" + and "count_list ws x \ 2" + and "primitive ws" and "\ primitive (concat ws)" + shows "ws \ [x,x,y] \ primitive x \ primitive y" + using assms proof (induction "\<^bold>|ws\<^bold>|" arbitrary: x y ws rule: less_induct) + case less + then show ?case + proof (cases) + assume "[x, x] \f ws \ ws \ [y, y] \f ws \ ws" + with bin_imprim_both_squares[OF \x \ y \ y \ x\ \ws \ lists {x,y}\ \primitive ws\ \ \ primitive (concat ws)\] + have False by blast + thus ?case by blast + next + assume missing_sq: "\ ([x, x] \f ws \ ws \ [y, y] \f ws \ ws)" + then show ?case + proof (cases) + assume "count_list ws y < 2" + with bin_imprim_single_y[OF less.prems(1-4) this less.prems(5-6)] + show "ws \ [x,x,y] \ primitive x \ primitive y" + by blast + next + assume "\ count_list ws y < 2" hence "2 \ count_list ws y" by simp + +\ \Missing square and two y's allow gluing\ + define x' where "x' = (if \ [x, x] \f ws \ ws then x else y)" + define y' where "y' = (if \ [x, x] \f ws \ ws then y else x)" + + have "{x', y'} = {x, y}" + by (simp add: doubleton_eq_iff x'_def y'_def) + note cases = disjE[OF this[unfolded doubleton_eq_iff]] + have "\ [x', x'] \f ws \ ws" + using missing_sq x'_def by presburger + have "count_list ws x' \ 2" and "count_list ws y' \ 2" + unfolding x'_def y'_def using \2 \ count_list ws x\ \2 \ count_list ws y\ by presburger+ + have "x' \ y' \ y' \ x'" + by (rule cases, simp_all add: \x \ y \ y \ x\ \x \ y \ y \ x\[symmetric]) + have "x' \ \" and "x' \ y'" and "x' \ y' \ y'" + using \x' \ y' \ y' \ x'\ by auto + +\ \rotating last if necessary for successful gluing\ + note prim_nemp[OF \primitive ws\] + hence rot: "last ws = x' \ hd ws = x' \ butlast ws \ [x',x'] \ tl ws = ws \ ws" + using append_butlast_last_id hd_tl hd_word mult_assoc by metis + from this[THEN facI'] + have "last ws = x' \ hd ws \ x'" + using \\ [x', x'] \f ws \ ws\ by blast + define ws' where "ws' = (if last ws \ x' then ws else tl ws \ [hd ws])" + have cond: "ws' = \ \ last ws' \ x'" \ \gluing condition\ + unfolding ws'_def using \last ws = x' \ hd ws \ x'\ by simp + have "ws' \ ws" + unfolding ws'_def using \ws \ \\ by fastforce + hence counts': "count_list ws' x' \ 2" "count_list ws' y' \ 2" + by (simp_all add: \2 \ count_list ws x'\ \2 \ count_list ws y'\ count_list_conjug) + +\ \verify induction assumptions of the glued word\ + let ?ws = "glue x' ws'" + have c1: "\<^bold>|?ws\<^bold>| < \<^bold>|ws\<^bold>|" + using len_glue[OF cond] conjug_len[OF \ws' \ ws\] \count_list ws' x' \ 2\ by linarith + hence c2: "(x' \ y') \ y' \ y' \ x' \ y'" + using \x' \ y' \ y' \ x'\ by force + + have "ws' \f ws \ ws" + using conjugE[OF \ws' \ ws\] rassoc sublist_appendI by metis + hence "\ [x', x'] \f ws'" + using \\ [x',x'] \f ws \ ws\ by blast + have "ws' \ lists {x',y'}" + using conjug_in_lists[OF \ws' \ ws\ \ws \ lists {x,y}\[folded \{x',y'} = {x,y}\]]. + have c3: "?ws \ lists {x' \ y', y'}" + using single_bin_glue_in_lists[OF cond \\ [x', x'] \f ws'\ \ws' \ lists {x',y'}\]. + + have c4: "2 \ count_list (glue x' ws') (x' \ y')" + using \2 \ count_list ws' x'\ + unfolding count_list_single_bin_glue(1)[OF \x' \ \\ \x' \ y'\ cond \ws' \ lists {x',y'}\ \\ [x',x'] \f ws'\]. + + from \primitive ws\[folded conjug_prim_iff[OF \ws' \ ws\]] + have c5: "primitive (glue x' ws')" + using prim_bin_glue [OF \ws' \ lists {x',y'}\ \x' \ \\ cond] by blast + + have "count_list ws' x' \ 2" + using \count_list ws x \ 2\ \count_list ws y \ 2\ \{x', y'} = {x, y}\ + count_list_conjug[OF \ws' \ ws\] x'_def by metis + + have "concat (glue x' ws') = concat ws'" + by (simp add: cond) + have c6: "\ primitive (concat (glue x' ws'))" + unfolding \concat (glue x' ws') = concat ws'\ using \\ primitive (concat ws)\ \ws' \ ws\ + conjug_concat_conjug prim_conjug by metis + \ \The claim holds by induction\ + from less.hyps[OF c1 c2 c3 _ c4 c5 c6] + have "glue x' ws' \ [x' \ y', x' \ y', y']" by simp + \ \Which is impossible after gluing\ + from prim_xyxyy[OF \x' \ y' \ y' \ x'\] conjug_prim_iff[OF conjug_concat_conjug[OF this]] + have False + using \\ primitive (concat (glue x' ws'))\ by simp + thus ?case by blast + qed + qed +qed + +lemma bin_imprim_both_twice: + assumes "x \ y \ y \ x" + and "ws \ lists {x, y}" + and "count_list ws x \ 2" + and "count_list ws y \ 2" + and "primitive ws" and "\ primitive (concat ws)" + shows False +proof- + have "x \ y" + using \x \ y \ y \ x\ by blast + from bin_imprim_longer_twice[OF assms(1-2) _ assms(3) assms(5-6)] + bin_imprim_longer_twice[OF assms(1)[symmetric] assms(2)[unfolded insert_commute[of x]] _ assms(4) assms(5-6)] + have or: "ws \ [x, x, y] \ ws \ [y, y, x]" by linarith + thus False + proof (rule disjE) + assume "ws \ [x, x, y]" + from \count_list ws y \ 2\[unfolded count_list_conjug[OF this]] + show False + using \x \ y\ by force + next + assume "ws \ [y, y, x]" + from \count_list ws x \ 2\[unfolded count_list_conjug[OF this]] + show False + using \x \ y\ by force + qed +qed + +section \Examples\ + +lemma "x \ \ \ \ (x\x) \ \\<^sub>\ [x,x]" + unfolding factor_interpretation_def + by simp + +lemma assumes "x = [(0::nat),1,0,1,0]" and "y = [1,0,0,1]" + shows "[0,1] (x\x) [1,0] \\<^sub>\ [x,y,x]" + unfolding factor_interpretation_def assms by (simp add: suf_def) + +section "Primitivity non-preserving binary code" + +text\In this section, we give the final form of imprimitive words over a given +binary code @{term "{x,y}"}. +We start with a lemma, then we show that the only possibility is that such +word is conjugate with @{term "x\<^sup>@j \ y\<^sup>@k"}.\ + +lemma bin_imprim_expsE_y: assumes "x \ y \ y \ x" and + "ws \ lists {x,y}" and + "2 \ \<^bold>|ws\<^bold>|" and + "primitive ws" and + "\ primitive (concat ws)" and + "count_list ws y = 1" +obtains j k where "1 \ j" "1 \ k" "j = 1 \ k = 1" + "ws \ [x]\<^sup>@j \ [y]\<^sup>@k" +proof- + have "x \ y" using \x \ y \ y \ x\ by blast + obtain j1 j2 where "[x]\<^sup>@j1\[y]\[x]\<^sup>@j2 = ws" + using bin_count_one_decompose[OF \ws \ lists {x,y}\ \x \ y\ \count_list ws y = 1\]. + have "1 \ j2 + j1" + using \[x] \<^sup>@ j1 \ [y] \ [x] \<^sup>@ j2 = ws\ \2 \ \<^bold>|ws\<^bold>|\ not_less_eq_eq by fastforce + have "ws \ [x]\<^sup>@(j2+j1)\[y]\<^sup>@1" + using conjugI'[of "[x] \<^sup>@ j1 \ [y]" "[x] \<^sup>@ j2"] + unfolding \[x] \<^sup>@ j1 \ [y] \ [x] \<^sup>@ j2 = ws\[symmetric] power_add rassoc pow_one'. + from that[OF \1 \ j2 + j1\ _ _ this] + show ?thesis + by blast +qed + +lemma bin_imprim_expsE: assumes "x \ y \ y \ x" and + "ws \ lists {x,y}" and + "2 \ \<^bold>|ws\<^bold>|" and + "primitive ws" and + "\ primitive (concat ws)" +obtains j k where "1 \ j" "1 \ k" "j = 1 \ k = 1" + "ws \ [x]\<^sup>@j \ [y]\<^sup>@k" +proof- + note \ws \ lists {x,y}\[unfolded insert_commute[of x]] + + from bin_lists_count_zero[OF \ws \ lists {x,y}\] + sing_lists_exp_len[of ws y] + prim_exp_one[OF \primitive ws\, of "[y]" "\<^bold>|ws\<^bold>|"] + have "count_list ws x \ 0" + using \2 \ \<^bold>|ws\<^bold>|\ by fastforce + + from bin_lists_count_zero[OF \ws \ lists {y,x}\] + sing_lists_exp_len[of ws x] + prim_exp_one[OF \primitive ws\, of "[x]" "\<^bold>|ws\<^bold>|"] + have "count_list ws y \ 0" + using \2 \ \<^bold>|ws\<^bold>|\ by fastforce + + consider "count_list ws x = 1" | "count_list ws y = 1" + using bin_imprim_both_twice[OF \x \ y \ y \ x\ \ws \ lists {x,y}\ _ _ + \primitive ws\ \\ primitive (concat ws)\] + \count_list ws x \ 0\ \count_list ws y \ 0\ + unfolding One_less_Two_le_iff[symmetric] less_one[symmetric] by fastforce + thus thesis + proof(cases) + assume \count_list ws x = 1\ + from bin_imprim_expsE_y[reversed, OF \x \ y \ y \ x\ \ws \ lists {y, x}\ \2 \ \<^bold>|ws\<^bold>|\ + \primitive ws\ \\ primitive (concat ws)\ \count_list ws x = 1\] + show thesis + using that by metis + next + assume \count_list ws y = 1\ + from bin_imprim_expsE_y[OF \x \ y \ y \ x\ \ws \ lists {x, y}\ \2 \ \<^bold>|ws\<^bold>|\ + \primitive ws\ \\ primitive (concat ws)\ \count_list ws y = 1\] + show ?thesis + using that. + qed +qed + +subsection \The target theorem\ + +text\Given a binary code @{term "{x,y}"} such that there is a primitive factorisation +@{term ws} over it whose concatenation is imprimitive, we finally show that there are +integers @{term j} and @{term k} (depending only on @{term "{x,y}"}) such that +any other such factorisation @{term ws'} is conjugate to @{term "[x]\<^sup>@j \ [y]\<^sup>@k"}.\ + +theorem bin_imprim_code: assumes "x \ y \ y \ x" and "ws \ lists {x,y}" and + "2 \ \<^bold>|ws\<^bold>|" and "primitive ws" and "\ primitive (concat ws)" +obtains j k where "1 \ j" and "1 \ k" and "j = 1 \ k = 1" + "\ws. ws \ lists {x,y} \ 2 \ \<^bold>|ws\<^bold>| \ + (primitive ws \ \ primitive (concat ws) \ ws \ [x]\<^sup>@j \ [y]\<^sup>@k)" and + "\<^bold>|y\<^bold>| \ \<^bold>|x\<^bold>| \ 2 \ j \ j = 2 \ primitive x \ primitive y" and + "\<^bold>|y\<^bold>| \ \<^bold>|x\<^bold>| \ 2 \ k \ j = 1 \ primitive x" +proof- + obtain j k where "1 \ j" "1 \ k" "j = 1 \ k = 1" + "ws \ [x]\<^sup>@j \ [y]\<^sup>@k" + using bin_imprim_expsE[OF \x \ y \ y \ x\] + using assms by metis + + have "\ primitive (x\<^sup>@j \ y\<^sup>@k)" + using \\ primitive (concat ws)\ + unfolding concat_morph concat_sing_pow + conjug_prim_iff[OF conjug_concat_conjug[OF \ws \ [x] \<^sup>@ j \ [y] \<^sup>@ k\]]. + + from not_prim_pow[OF this] + obtain z l where [symmetric]: "z\<^sup>@l = x\<^sup>@j \ y\<^sup>@k" and "2 \ l". + + show thesis + proof (rule that[of j k ]) + show "1 \ j" "1 \ k" "j = 1 \ k = 1" by fact+ + + fix ws' + assume hyps: "ws' \ lists {x,y}" "2 \ \<^bold>|ws'\<^bold>|" + show "primitive ws' \ \ primitive (concat ws') \ ws' \ [x]\<^sup>@j \ [y]\<^sup>@k" + proof + assume " primitive ws' \ \ primitive (concat ws')" + hence prems: "primitive ws'" "\ primitive (concat ws')" by blast+ + obtain j' k' where "1 \ j'" "1 \ k'" "j' = 1 \ k' = 1" + "ws' \ [x]\<^sup>@j' \ [y]\<^sup>@k'" + using bin_imprim_expsE[OF \x \ y \ y \ x\ hyps prems]. + + have "\ primitive (x \<^sup>@ j'\ y \<^sup>@ k')" + using \\ primitive (concat ws')\ + unfolding concat_morph concat_sing_pow + conjug_prim_iff[OF conjug_concat_conjug[OF \ws' \ [x] \<^sup>@ j' \ [y] \<^sup>@ k'\]]. + + have "j = j'" "k = k'" + using LS_unique[OF \x \ y \ y \ x\ + \1 \ j\ \1 \ k\ \\ primitive (x \<^sup>@ j \ y \<^sup>@ k)\ + \1 \ j'\ \1 \ k'\ \\ primitive (x \<^sup>@ j'\ y \<^sup>@ k')\]. + + show "ws' \ [x] \<^sup>@ j \ [y] \<^sup>@ k" + unfolding \j = j'\ \k = k'\ by fact + next + assume "ws' \ [x]\<^sup>@j \ [y]\<^sup>@k" + note conjug_trans[OF \ws \ [x]\<^sup>@j \ [y]\<^sup>@k\ conjug_sym[OF this]] + from prim_conjug[OF \primitive ws\ this] + \\ primitive (concat ws)\[unfolded conjug_concat_prim_iff[OF \ws \ ws'\]] + show "primitive ws' \ \ primitive (concat ws')" by blast + qed + next + assume "\<^bold>|y\<^bold>| \ \<^bold>|x\<^bold>|" + interpret LS_len_le x y j k l z + by unfold_locales fact+ + + assume "2 \ j" + with jk_small + have "k = 1" by fastforce + from case_j2k1[OF \2 \ j\ this] + show "j = 2 \ primitive x \ primitive y" + by blast + next + assume "\<^bold>|y\<^bold>| \ \<^bold>|x\<^bold>|" + interpret LS_len_le x y j k l z + by unfold_locales fact+ + + assume "2 \ k" + show "j = 1 \ primitive x" + using \2 \ k\ \j = 1 \ k = 1\ case_j1k2_primitive by auto + qed +qed + +end \ No newline at end of file diff --git a/thys/Binary_Code_Imprimitive/Binary_Square_Interpretation.thy b/thys/Binary_Code_Imprimitive/Binary_Square_Interpretation.thy new file mode 100644 --- /dev/null +++ b/thys/Binary_Code_Imprimitive/Binary_Square_Interpretation.thy @@ -0,0 +1,1063 @@ +(* Title: Binary Square Interpretation + File: Combinatorics_Words_Interpretations.Binary_Square_Interpretation + Author: Štěpán Holub, Charles University + Author: Martin Raška, Charles University + +Part of Combinatorics on Words Formalized. See https://gitlab.com/formalcow/combinatorics-on-words-formalized/ +*) + +theory Binary_Square_Interpretation + +imports + Combinatorics_Words.Equations_Basic +begin + +section \Lemmas for covered x square\ + +text \This section explores various variants of the situation when @{term "x \ x"} is covered with + @{term "x\y\<^sup>@k\u \ v\y\<^sup>@l\x"}, with @{term "y = u\v"}, and the displayed dots being synchronized. +\ + +subsection \Two particular cases\ + +\ \Very short and very large overlap\ + +lemma pref_suf_pers_short: assumes "x \p v \ x" and "\<^bold>|v \ u\<^bold>| < \<^bold>|x\<^bold>|" and "x \s p \ u \ v \ u" and "p \ \{u,v}\" + \ \@{term "x \ x"} is covered by @{term "(p\u\v\u) \ (v\x)"}, the displayed dots being synchronized\ + \ \That is, the condition on the first @{term x} in @{term "x\y\<^sup>@k\u \ v\y\<^sup>@l\x"} is relaxed\ + shows "u\v = v\u" +proof (rule nemp_comm) + have "v \ u \<^bold>|v \ u\<^bold>| < \<^bold>|x\<^bold>|\, of "p \ u", unfolded rassoc, OF \x \s p \ u \ v \ u\]. + assume "u \ \" and "v \ \" + obtain q where "x = q \ v \ u" and "q \ \" + using \v \ u by (auto simp add: suf_def) + hence "q \s p \ u" + using \x \s p \ u \ v \ u\ by (auto simp add: suf_def) + have "q \ v = v \ q" + using pref_marker[OF \x \p v\x\, of q ] \x = q \ v \ u\ by simp + from suf_marker_per_root[OF \x \p v \ x\, of q u, unfolded rassoc \x = q \ v \ u\] + have "u \p v \ u" + by blast + from root_comm_root[OF this \q\v = v\q\ \v \ \\] + have "u \p q \ u" by simp + + consider "u \s q" | "q \s u" + using \q \s p \ u\ suffix_same_cases by blast + thus "u\v = v\u" + proof (cases) + assume "u \s q" + from two_elem_root_suf_comm'[OF \u \p v \ u\ _ _ \p \ \{u,v}\\, of "q\<^sup><\u", unfolded rq_suf[OF this] lassoc, OF _ \q \ v = v \ q\] + show ?thesis + using \q \s p \ u\ rq_suf[OF \u \s q\] same_suffix_suffix by metis + next + assume "q \s u" + from root_suf_comm[OF \u \p q \ u\ suffix_appendI[OF this]] + have "q\u = u\q". + from comm_trans[OF \q \ u = u \ q\[symmetric] \q \ v = v \ q\[symmetric] \q \ \\] + show "u\v = v\u". + qed +qed + +lemma pref_suf_pers_large_overlap: + assumes + "p \p x" and "s \s x" and "p \p r \ p" and "s \s s \ r" and "\<^bold>|x\<^bold>| + \<^bold>|r\<^bold>| \ \<^bold>|p\<^bold>| + \<^bold>|s\<^bold>|" + shows "x \ r = r \ x" + using assms +proof (cases "r = \", force) + assume "r \ \" hence "r \ \" by blast + have "\<^bold>|s\<^bold>| \ \<^bold>|x\<^bold>|" + using \s \s x\ unfolding suf_def by force + have "\<^bold>|p\<^bold>| \ \<^bold>|x\<^bold>|" + using \p \p x\ by (force simp add: prefix_def) + have "\<^bold>|r\<^bold>| \ \<^bold>|p\<^bold>|" + using \\<^bold>|x\<^bold>| + \<^bold>|r\<^bold>| \ \<^bold>|p\<^bold>| + \<^bold>|s\<^bold>|\ \\<^bold>|s\<^bold>| \ \<^bold>|x\<^bold>|\ unfolding lenmorph by linarith + have "\<^bold>|r\<^bold>| \ \<^bold>|s\<^bold>|" + using \\<^bold>|x\<^bold>| + \<^bold>|r\<^bold>| \ \<^bold>|p\<^bold>| + \<^bold>|s\<^bold>|\ \\<^bold>|p\<^bold>| \ \<^bold>|x\<^bold>|\ unfolding lenmorph by linarith + obtain p1 ov s1 where "p1 \ ov \ s1 = x" and "p1 \ ov = p" and "ov \ s1 = s" + using pref_suf_overlapE[OF \p \p x\ \s \s x\] using \\<^bold>|x\<^bold>| + \<^bold>|r\<^bold>| \ \<^bold>|p\<^bold>| + \<^bold>|s\<^bold>|\ by auto + have "\<^bold>|r\<^bold>| \ \<^bold>|ov\<^bold>|" + using \\<^bold>|x\<^bold>| + \<^bold>|r\<^bold>| \ \<^bold>|p\<^bold>| + \<^bold>|s\<^bold>|\[folded \p1 \ ov \ s1 = x\ \p1 \ ov = p\ \ov \ s1 = s\] + unfolding lenmorph by force + have "r \p p" + using \\<^bold>|r\<^bold>| \ \<^bold>|p\<^bold>|\[unfolded swap_len] pref_prod_long[OF \p \p r \ p\] by blast + hence "r \p x" + using \p \p x\ by auto + have "r \s s" + using \\<^bold>|r\<^bold>| \ \<^bold>|s\<^bold>|\[unfolded swap_len] pref_prod_long[reversed, OF \s \s s \ r\] by blast + hence "r \s x" + using \s \s x\ by auto + obtain k where "p \p r\<^sup>@k" + using per_prefE[OF \p \p r \ p\ \r \ \\]. + hence "p1 \ ov \f r\<^sup>@k" + unfolding \p1 \ ov = p\ by blast + obtain l where "s \s r\<^sup>@l" + using per_prefE[reversed, OF \s \s s \ r\ \r \ \\]. + hence "ov \ s1 \f r\<^sup>@l" + unfolding \ov \ s1 = s\ by blast + from per_glue_facs[OF \p1 \ ov \f r\<^sup>@k\ \ov \ s1 \f r\<^sup>@l\ \\<^bold>|r\<^bold>| \ \<^bold>|ov\<^bold>|\, unfolded \p1 \ ov \ s1 = x\] + obtain m where "x \f r \<^sup>@ m". + show "x \ r = r \ x" + using root_suf_comm[OF + pref_prod_root[OF marker_fac_pref[OF \x \f r \<^sup>@ m\ \r \p x\]] + suffix_appendI[OF \r \s x\]].. +qed + +subsection \Main cases\ + +locale pref_suf_pers = + fixes x u v k m + assumes + x_pref: "x \p (v \ (u \ v)\<^sup>@(Suc k)) \ x" \ \@{term "x \p p \ x"} and @{term "p \p q \ p"} where @{term "q \p v \ u"}\ + and + x_suf: "x \s x \ (u \ v)\<^sup>@(Suc m) \ u" \ \@{term "x \s s \ x"} and @{term "s \s q' \ s"} where @{term "q' \p u \ v"}\ +begin + +lemma pref_suf_commute_all_commutes: + assumes "\<^bold>|u \ v\<^bold>| \ \<^bold>|x\<^bold>|" and "u \ v = v \ u" + shows "commutes {u,v,x}" + using assms +proof (cases "u \ v = \", force) + let ?p = "(v \ (u \ v)\<^sup>@(Suc k))" + let ?s = "(u \ v)\<^sup>@(Suc m) \ u" + note x_pref x_suf + + assume "u \ v \ \" + have "?p \ \" and "?s \ \" and "v \ u \ \" + using \u \ v \ \\ by force+ + obtain r where "u \ r*" and "v \ r*" and "primitive r" + using \u \ v = v \ u\ comm_primrootE by metis + hence "r \ \" + by force + + have "?p \ r*" and "?s \ r*" and "v \ u \ r*" and "u \ v \ r*" + using \u \ r*\ \v \ r*\ by fast+ + + have "x \p r \ x" + using \?p \ r*\ \x \p ?p \ x\ \?p \ \\ by blast + have "v \ u \s x" + using ruler_le[reversed, OF _ _ \\<^bold>|u \ v\<^bold>| \ \<^bold>|x\<^bold>|\[unfolded swap_len[of u]], + of "(x \ (u \ v) \<^sup>@ m \ u) \ v \ u", OF triv_suf, unfolded rassoc, OF \x \s x \ ?s\[unfolded pow_Suc2 rassoc]]. + have "r \s v \ u" + using \v \ u \ \\ \v \ u \ r*\ by blast + have "r \s r \ x" + using suf_trans[OF \r \s v \ u\ \v \ u \s x\, THEN suffix_appendI] by blast + have "x \ r = r \ x" + using root_suf_comm[OF \x \p r \ x\ \r \s r \ x\, symmetric]. + hence "x \ r*" + by (simp add: \primitive r\ prim_comm_root) + thus "commutes {u,v,x}" + using \u \ r*\ \v \ r*\ commutesI_root[of "{u,v,x}"] by blast +qed + +lemma no_overlap: + assumes + len: "\<^bold>|v \ (u \ v)\<^sup>@(Suc k)\<^bold>| + \<^bold>|(u \ v)\<^sup>@(Suc m) \ u\<^bold>| \ \<^bold>|x\<^bold>|" (is "\<^bold>|?p\<^bold>| + \<^bold>|?s\<^bold>| \ \<^bold>|x\<^bold>|") + shows "commutes {u,v,x}" + using assms +proof (cases "u \ v = \", force) + note x_pref x_suf + assume "u \ v \ \" + have "?p \ \" and "?s \ \" + using \u \ v \ \\ by force+ + from \\<^bold>|?p\<^bold>| + \<^bold>|?s\<^bold>| \ \<^bold>|x\<^bold>|\ + have "\<^bold>|?p\<^bold>| + \<^bold>|?s\<^bold>| - (gcd \<^bold>|?p\<^bold>| \<^bold>|?s\<^bold>|) \ \<^bold>|x\<^bold>|" + by linarith + from per_lemma_pref_suf[OF \x \p ?p \ x\ \x \s x \ ?s\ \?p \ \\ \?s \ \\ this] + obtain r s kp ks mw where "?p = (r \ s)\<^sup>@kp" and "?s = (s \ r)\<^sup>@ks" and "x = (r \ s)\<^sup>@mw \ r" and "primitive (r \ s)". + hence "\ ?p = r \ s" + using \v \ (u \ v) \<^sup>@ Suc k \ \\ comm_primroots nemp_pow_nemp pow_comm prim_self_root by metis + moreover have "\ ?s = s \ r" + using pow_prim_primroot[OF \?s \ \\ _ \?s = (s \ r)\<^sup>@ks\] prim_conjug[OF \primitive (r \ s)\] by blast + ultimately have "\ ?p \ \ ?s" + by force + from conj_pers_conj_comm[OF this] + have "u \ v = v \ u". + + from pref_suf_commute_all_commutes[OF _ this] + show "commutes {u,v,x}" + using len by auto +qed + +lemma no_overlap': + assumes + len: "\<^bold>|v \ (u \ v)\<^sup>@(Suc k)\<^bold>| + \<^bold>|(u \ v)\<^sup>@(Suc m) \ u\<^bold>| \ \<^bold>|x\<^bold>|" (is "\<^bold>|?p\<^bold>| + \<^bold>|?s\<^bold>| \ \<^bold>|x\<^bold>|") + shows "u \ v = v \ u" + by (rule commutesE[of "{u,v,x}"], simp_all add: no_overlap[OF len]) + +lemma short_overlap: + assumes + len1: "\<^bold>|x\<^bold>| < \<^bold>|v \ (u \ v)\<^sup>@(Suc k)\<^bold>| + \<^bold>|(u \ v)\<^sup>@(Suc m) \ u\<^bold>|" (is "\<^bold>|x\<^bold>| < \<^bold>|?p\<^bold>| + \<^bold>|?s\<^bold>|") and + len2: "\<^bold>|v \ (u \ v)\<^sup>@(Suc k)\<^bold>| + \<^bold>|(u \ v)\<^sup>@(Suc m) \ u\<^bold>| \ \<^bold>|x\<^bold>| + \<^bold>|u\<^bold>|" (is "\<^bold>|?p\<^bold>| + \<^bold>|?s\<^bold>| \ \<^bold>|x\<^bold>| + \<^bold>|u\<^bold>|") + shows "commutes {u,v,x}" +proof (rule pref_suf_commute_all_commutes) + show "\<^bold>|u \ v\<^bold>| \ \<^bold>|x\<^bold>|" + using len2 by force +next + note x_pref x_suf + \ \obtain the overlap\ + + have "\<^bold>|?p\<^bold>| \ \<^bold>|x\<^bold>|" + using len2 unfolding lenmorph by linarith + hence "?p \p x" + using \x \p ?p \ x\ pref_prod_long by blast + + have "\<^bold>|?s\<^bold>| \ \<^bold>|x\<^bold>|" + using len2 unfolding pow_len lenmorph by auto + hence "?s \s x" + using suf_prod_long[OF \x \s x \ ?s\] by blast + + from pref_suf_overlapE[OF \?p \p x\ \?s \s x\ less_imp_le[OF len1]] + obtain p1 ov s1 where "p1 \ ov \ s1 = x" and "p1 \ ov = ?p" and "ov \ s1 = ?s". + + from len1[folded this] + have "ov \ \" + by fastforce + + have "\<^bold>|ov\<^bold>| \ \<^bold>|u\<^bold>|" + using len2[folded \p1 \ ov \ s1 = x\ \p1 \ ov = ?p\ \ov \ s1 = ?s\] unfolding lenmorph by auto + + then obtain s' where "ov \ s' = u" and "s' \ v \ (u \ v) \<^sup>@ m \ u = s1" + using eqdE[OF \ov \ s1 = ?s\[unfolded pow_Suc rassoc]] by auto + +\ \obtain the left complement\ + + from eqdE[reversed, of p1 ov "v \ (u \ v)\<^sup>@k" "u \ v", unfolded rassoc, + OF \p1 \ ov = ?p\[unfolded pow_Suc2]] \\<^bold>|ov\<^bold>| \ \<^bold>|u\<^bold>|\ + have "v \ (u \ v) \<^sup>@ k \p p1" by (auto simp add: prefix_def) + + then obtain q where "v \ (u \ v)\<^sup>@k \ q = p1" + by (force simp add: prefix_def) + +\ \main proof using the lemma @{thm uvu_suf_uvvu}\ + + show "u \ v = v \ u" + proof (rule sym, rule uvu_suf_uvvu) + show "s' ov \ s' = u\ \ov \ \\ by blast + show "u \ v \ v \ u \ s' = q \ u \ v \ u" \ \the main fact: the overlap situation\ + proof- + have "u \ v \ u \p ?s" + unfolding pow_Suc rassoc pref_cancel_conv shift_pow by blast + hence "p1 \ u \ v \ u \p x" + unfolding \p1 \ ov \ s1 = x\[symmetric] \ov \ s1 = ?s\ pref_cancel_conv. + hence "v \ (u \ v)\<^sup>@k \ q \ u \ v \ ov \p x" + using \v \ (u \ v)\<^sup>@k \ q = p1\ \ov \ s' = u\ by (force simp add: prefix_def) + + have "v \ u \p x" + using \?p \p x\[unfolded pow_Suc] by (auto simp add: prefix_def) + have "\<^bold>|?p \ v \ u\<^bold>| \ \<^bold>|x\<^bold>|" + using len2 unfolding lenmorph by force + hence "?p \ v \ u \p x" + using \x \p ?p \ x\ \v \ u \p x\ pref_prod_longer by blast + hence "v \ (u \ v)\<^sup>@k \ u \ v \ v \ u \p x" + unfolding pow_Suc2 rassoc. + + have "\<^bold>|v \ (u \ v)\<^sup>@k \ u \ v \ v \ u\<^bold>| = \<^bold>|v \ (u \ v)\<^sup>@k \ q \ u \ v \ ov\<^bold>|" + using lenarg[OF \p1 \ ov = ?p\[folded \v \ (u \ v)\<^sup>@k \ q = p1\, unfolded pow_Suc2 rassoc cancel]] + by force + + from ruler_eq_len[OF \v \ (u \ v)\<^sup>@k \ u \ v \ v \ u \p x\ \v \ (u \ v)\<^sup>@k \ q \ u \ v \ ov \p x\ this, unfolded cancel] + have "u \ v \ v \ u = q \ u \ v \ ov". + + thus "u \ v \ v \ u \ s' = q \ u \ v \ u" + using \ov \ s' = u\ by auto + qed + show "q \s v \ u" + proof (rule ruler_le[reversed]) + show "q \s x" + proof (rule suf_trans) + show "p1 \s x" + using \p1 \ ov \ s1 = x\[unfolded \ov \ s1 = ?s\] \x \s x \ ?s\ same_suffix_suffix by blast + show "q \s p1" + using \v \ (u \ v) \<^sup>@ k \ q = p1\ by auto + qed + show "v \ u \s x" + using \?s \s x\[unfolded pow_Suc2 rassoc] suffix_appendD by metis + show "\<^bold>|q\<^bold>| \ \<^bold>|v \ u\<^bold>|" + using lenarg[OF \u \ v \ v \ u \ s' = q \ u \ v \ u\] lenarg[OF \ov \ s' = u\] by force + qed + qed auto +qed + +lemma medium_overlap: + assumes + len1: "\<^bold>|x\<^bold>| + \<^bold>|u\<^bold>| < \<^bold>|v \ (u \ v)\<^sup>@(Suc k)\<^bold>| + \<^bold>|(u \ v)\<^sup>@(Suc m) \ u\<^bold>|" (is "\<^bold>|x\<^bold>| + \<^bold>|u\<^bold>| < \<^bold>|?p\<^bold>| + \<^bold>|?s\<^bold>|") and + len2: "\<^bold>|v \ (u \ v)\<^sup>@(Suc k)\<^bold>| + \<^bold>|(u \ v)\<^sup>@(Suc m) \ u\<^bold>| < \<^bold>|x\<^bold>| + \<^bold>|u \ v\<^bold>|" (is "\<^bold>|?p\<^bold>| + \<^bold>|?s\<^bold>| < \<^bold>|x\<^bold>| + \<^bold>|u \ v\<^bold>|") + shows "commutes {u,v,x}" +proof (rule pref_suf_commute_all_commutes) + show "\<^bold>|u \ v\<^bold>| \ \<^bold>|x\<^bold>|" + using len2 by force +next + note x_pref x_suf + have "\<^bold>|?p\<^bold>| \ \<^bold>|x\<^bold>|" + using len2 by auto + hence "?p \p x" + using \x \p ?p \ x\ pref_prod_long by blast + hence "v \ (u \ v)\<^sup>@k \ u \ v \ v \p ?p \ x" + using \x \p ?p \ x\ unfolding pow_Suc2 rassoc by (auto simp add: prefix_def) + + have "\<^bold>|?s\<^bold>| \ \<^bold>|x\<^bold>|" + using len2 unfolding pow_len lenmorph by auto + hence "?s \s x" + using suf_prod_long[OF \x \s x \ ?s\] by blast + then obtain p' where "p' \ u \ v \p x" and "p' \ ?s = x" + by (auto simp add: suf_def) + + have "\<^bold>|p' \ u \ v\<^bold>| \ \<^bold>|?p \ v\<^bold>|" + using len1[folded \p' \ ?s = x\] by force + + have "\<^bold>|v \ (u \ v)\<^sup>@k\<^bold>| < \<^bold>|p'\<^bold>|" + using len2[folded \p' \ ?s = x\] by force + + from less_imp_le[OF this] + obtain p where "v \ (u \ v)\<^sup>@k \ p = p'" + using ruler_le[OF \?p \p x\ \p' \ u \ v \p x\, unfolded pow_Suc2 lassoc, THEN pref_cancel_right, THEN pref_cancel_right] + by (auto simp add: prefix_def) + + have "\<^bold>|p\<^bold>| \ \<^bold>|v\<^bold>|" + using \v \ (u \ v)\<^sup>@k \ p = p'\ \\<^bold>|p' \ u \ v\<^bold>| \ \<^bold>|?p \ v\<^bold>|\ by force + + show "u \ v = v \ u" + proof (rule uv_fac_uvv) + show "p \ u \ v \p u \ v \ v" + proof (rule pref_cancel[of "v \ (u \ v)\<^sup>@k"], rule ruler_le) + show "(v \ (u \ v) \<^sup>@ k) \ p \ u \ v \p ?p \ x" + unfolding lassoc \v \ (u \ v)\<^sup>@k \ p = p'\[unfolded lassoc] + using \p' \ u \ v \p x\ \x \p ?p \ x\ by force + show "(v \ (u \ v) \<^sup>@ k) \ u \ v \ v \p (v \ (u \ v) \<^sup>@ Suc k) \ x" + unfolding pow_Suc2 rassoc + using \v \ (u \ v) \<^sup>@ Suc k \p x\ by (auto simp add: prefix_def) + show "\<^bold>|(v \ (u \ v) \<^sup>@ k) \ p \ u \ v\<^bold>| \ \<^bold>|(v \ (u \ v) \<^sup>@ k) \ u \ v \ v\<^bold>|" + using \v \ (u \ v)\<^sup>@k \ p = p'\ \\<^bold>|p' \ u \ v\<^bold>| \ \<^bold>|?p \ v\<^bold>|\ by force + qed + + have "p \s x" + using \p' \ ?s = x\[folded \v \ (u \ v)\<^sup>@k \ p = p'\] \x \s x \ ?s\ suf_cancel suffix_appendD by metis + + from ruler_le[reversed, OF this \?s \s x\, unfolded pow_Suc2 rassoc] + show "p \s (u \ v) \<^sup>@ m \ u \ v \ u" + using \\<^bold>|p\<^bold>| \ \<^bold>|v\<^bold>|\ unfolding lenmorph by auto + + show "(u \ v) \<^sup>@ m \ u \ v \ u \ \{u, v}\" + by (simp add: gen_in hull_closed power_in) + + show "p \ \" + using \\<^bold>|v \ (u \ v)\<^sup>@k\<^bold>| < \<^bold>|p'\<^bold>|\ \v \ (u \ v)\<^sup>@k \ p = p'\ by force + qed +qed + +thm + no_overlap + short_overlap + medium_overlap + +end + +thm + pref_suf_pers.no_overlap + pref_suf_pers.short_overlap + pref_suf_pers.medium_overlap + pref_suf_pers_large_overlap + +section \Square interpretation\ + +text \In this section fundamental description is given of (the only) +possible @{term "{x,y}"}-interpretation of the square @{term "x\x"}, where @{term "\<^bold>|y\<^bold>| \ \<^bold>|x\<^bold>|"}. +The proof is divided into several locales. +\ + +\ \An example motivating disjointness: an interpretation which is not disjoint.\ +lemma cover_not_disjoint: + shows "primitive [0::nat,1,0,1,0,1,0]" (is "primitive ?x") and + "primitive[0::nat, 1]" (is "primitive ?y") and + "[0::nat,1,0,1,0,1,0] \ [0,1] \ [0,1] \ [0,1,0,1,0,1,0]" + (is "?x \ ?y \ ?y \ ?x") and + "\ [0::nat,1,0,1,0,1,0] \ [0,1,0,1,0,1,0] [1,0,1,0] \\<^sub>\ [[0,1,0,1,0,1,0],[0,1],[0,1],[0,1,0,1,0,1,0]]" + (is "\ ?x \ ?x ?s \\<^sub>\ [?x,?y,?y,?x]") + unfolding factor_interpretation_def + by (primitivity_inspection+) force + +subsection \Locale: interpretation\ + +locale square_interp = + \ \The basic set of assumptions\ + \ \The goal is to arrive at @{term "ws = [x] \ [y]\<^sup>@k \ [x]"} including the description + of the interpretation in terms of the first and the second occurrence of x in the interpreted square.\ + fixes x y p s ws + assumes + prim_x: "primitive x" and prim_y: "primitive y" and + y_le_x: "\<^bold>|y\<^bold>| \ \<^bold>|x\<^bold>|" and + ws_lists: "ws \ lists {x,y}" and + nconjug: "\ x \ y" and + disjoint: "\ p1 p2. p1 \p [x,x] \ p2 \p ws \ p \ concat p1 \ concat p2" and + interp: "p (x\x) s \\<^sub>\ ws" + +begin + +interpretation binary_code x y + using binary_code_def comm_prim nconjug nconjug_neq prim_x prim_y by metis + +lemmas interpret_concat = fac_interpretE(3)[OF interp] + +lemma p_nemp: "p \ \" + using disjoint[of \ \] by auto + +lemma s_nemp: "s \ \" + using disjoint[of "[x,x]" ws] interpret_concat by force + +lemma x_root: "\ x = x" + using prim_x by blast + +lemma y_root: "\ y = y" + using prim_y by blast + +lemma ws_nemp: "ws \ \" + using bin_fst_nemp fac_interpret_nemp interp by blast + +lemma hd_ws_lists: "hd ws \ {x, y}" + using lists_hd_in_set ws_lists ws_nemp by auto + +lemma last_ws_lists: "last ws \ {x, y}" + using lists_hd_in_set[reversed, OF ws_nemp ws_lists]. + +lemma kE: obtains k where "[hd ws] \ [y]\<^sup>@k \ [last ws] = ws" +proof- + from list.collapse[OF ws_nemp] hd_word + obtain ws' where "ws = [hd ws] \ ws'" + by metis + hence "\<^bold>|hd ws\<^bold>| \ \<^bold>|x\<^bold>|" + using two_elem_cases[OF lists_hd_in_set[OF ws_nemp ws_lists]] y_le_x by blast + hence "\<^bold>|x\<^bold>| \ \<^bold>|concat ws'\<^bold>|" + using lenarg[OF interpret_concat, unfolded lenmorph] + unfolding concat.simps clean_emp arg_cong[OF \ws = [hd ws] \ ws'\, of "\ x. \<^bold>|concat x\<^bold>|", unfolded concat_morph lenmorph] + by linarith + hence "ws' \ \" + using nemp_len[OF bin_fst_nemp] by fastforce + then obtain mid_ws where "ws' = mid_ws \ [last ws]" + using \ws = [hd ws] \ ws'\ append_butlast_last_id last_appendR by metis + note \ws = [hd ws] \ ws'\[unfolded this] + fac_interpretE[OF interp] + obtain p' where [symmetric]:"p \ p' = hd ws" and "p' \ \" + using sprefE[OF \p

]. + obtain s' where [symmetric]: "s'\ s = last ws" and "s' \ \" + using sprefE[reversed, OF \s ]. + have "p' \ concat mid_ws \ s' = x \ x" + using \ws = [hd ws] \ mid_ws \ [last ws]\[unfolded \hd ws = p \ p'\ \last ws = s'\ s\] + \p \ (x \ x) \ s = concat ws\ by simp + note over = prim_overlap_sqE[OF prim_x, folded this] + have "mid_ws \ lists {x,y}" + using \ws = [hd ws] \ ws'\ \ws' = mid_ws \ [last ws]\ append_in_lists_conv ws_lists by metis + have "x \ set mid_ws" + proof + assume "x \ set mid_ws" + then obtain r q where "concat mid_ws = r \ x \ q" + using concat.simps(2) concat_morph in_set_conv_decomp_first by metis + have "(p' \ r) \ x \ (q \ s') = x \ x" + using \p' \ concat mid_ws \ s' = x \ x\[unfolded \concat mid_ws = r \ x \ q\] + unfolding rassoc. + from prim_overlap_sqE[OF prim_x this] + show False + using \p' \ \\ \s' \ \\ by blast + qed + hence "mid_ws \ lists {y}" + using \mid_ws \ lists {x,y}\ by force + from that sing_lists_exp[OF this] + show thesis + using \ws = [hd ws] \ mid_ws \ [last ws]\ by metis +qed + +lemma l_mE: obtains m u v l where "(hd ws)\y\<^sup>@m\u = p\x" and "v \ y\<^sup>@l \ (last ws) = x \ s" and + "u\v = y" and "u \ v \ v \ u" +proof- + note fac_interpretE[OF interp] + obtain k where "[hd ws] \ [y]\<^sup>@k \ [last ws] = ws" + using kE. + from arg_cong[OF this, of concat, folded interpret_concat, unfolded concat_morph rassoc concat_sing' concat_sing_pow] + have "hd ws \ y\<^sup>@k \ last ws = p \ x \ x \ s". + have "\<^bold>|hd ws\<^bold>| \ \<^bold>|p \ x\<^bold>|" + unfolding lenmorph using y_le_x two_elem_cases[OF hd_ws_lists] using dual_order.trans by fastforce + from eqd[OF _ this] + obtain ya where "hd ws \ ya = p \ x" + using \hd ws \ y\<^sup>@k \ last ws = p \ x \ x \ s\ by auto + have "\<^bold>|last ws\<^bold>| \ \<^bold>|x\<^bold>|" + unfolding lenmorph using dual_order.trans last_ws_lists y_le_x by auto + hence "\<^bold>|last ws\<^bold>| < \<^bold>|x \ s\<^bold>|" + unfolding lenmorph using nemp_len[OF s_nemp] by linarith + from eqd[reversed, OF _ less_imp_le[OF this]] + obtain yb where "yb \ (last ws) = x \ s" + using \(hd ws) \ y\<^sup>@k \ (last ws) = p \ x \ x \ s\ rassoc by metis + hence "yb \ \" + using s_nemp \\<^bold>|last ws\<^bold>| < \<^bold>|x \ s\<^bold>|\ by force + have "ya \ yb = y\<^sup>@k" + using \(hd ws) \ y\<^sup>@k \ (last ws) = p \ x \ x \ s\[folded \yb \ (last ws) = x \ s\, unfolded lassoc cancel_right, folded \(hd ws) \ ya = p \ x\, unfolded rassoc cancel, symmetric]. + then obtain m u where "m < k" and "u

@m \ u = ya" + using pref_mod_power[of ya y k] \yb \ \\ by blast + have "y\<^sup>@m \ u \ (u\\<^sup>>y) \ y\<^sup>@(k - m - 1) = y\<^sup>@m \ y \ y\<^sup>@(k - m - 1)" + using \u

by (auto simp add: prefix_def) + also have "... = y\<^sup>@(m + 1 + (k-m-1))" + using mult_assoc add_exps pow_one' by metis + also have "... = y\<^sup>@k" + using \m < k\ by auto + then obtain l v where "u\v = y" and "y\<^sup>@m \ u \ v \ y\<^sup>@l = y\<^sup>@k" + using \y \<^sup>@ m \ u \ u\\<^sup>>y \ y \<^sup>@ (k - m - 1) = y \<^sup>@ m \ y \ y \<^sup>@ (k - m - 1)\ calculation by auto + have "concat ([hd ws]\[y] \<^sup>@ m) = hd ws \ y \<^sup>@ m" + by simp + + have "v \ \" + using \u

\u\v = y\ by fast + + have "[hd ws] \ [y] \<^sup>@ m \p ws" + using \[hd ws] \ [y]\<^sup>@k \ [last ws] = ws\[folded pop_pow[OF less_imp_le[OF \m < k\]]] by fastforce + from disjoint[OF _ this, of "[x]", unfolded \concat ([hd ws] \ [y] \<^sup>@ m) = hd ws \ y \<^sup>@ m\] + have "u \ \" + using \(hd ws) \ ya = p \ x\[folded \y\<^sup>@m \ u = ya\] s_nemp by force + have "u\v \ v\u" + using comm_not_prim[OF \u \ \\ \v \ \\] prim_y \u\v = y\ by blast + + from that[of m u "u\\<^sup>>y" l, OF \hd ws \ ya = p \ x\[folded \y \<^sup>@ m \ u = ya\], folded \yb \ last ws = x \ s\ \u \ v = y\, + unfolded lq_triv lassoc cancel_right, OF _ _ this] + show thesis + using \y \<^sup>@ m \ u \ v \ y \<^sup>@ l = y \<^sup>@ k\[folded \ya \ yb = y \<^sup>@ k\ \y \<^sup>@ m \ u = ya\, unfolded rassoc cancel, folded \u \ v = y\] by blast +qed + +lemma last_ws: "last ws = x" +proof(rule ccontr) + assume "last ws \ x" + hence "last ws = y" + using last_ws_lists by blast + obtain l m u v where "(hd ws)\y\<^sup>@m\u = p\x" and "v \ y\<^sup>@l \ (last ws) = x \ s" and + "u\v = y" and "u \ v \ v \ u" + using l_mE by metis + note y_le_x[folded \u \ v = y\,unfolded swap_len[of u]] + + from \v \ y\<^sup>@l \ (last ws) = x \ s\[unfolded \last ws = y\, folded \u \ v = y\] + have "x \p (v \ u)\<^sup>@Suc l \ v" + unfolding pow_Suc2 rassoc using append_eq_appendI prefix_def shift_pow by metis + moreover have "(v \ u) \<^sup>@ Suc l \ v \p (v \ u) \ (v \ u) \<^sup>@ Suc l \ v" + unfolding lassoc pow_comm[symmetric] using rassoc by blast + ultimately have "x \p (v \ u) \ x" + using pref_keeps_root by blast + + thus False + proof (cases "m = 0") + assume "m \ 0" + then obtain m' where "m = Suc m'" + using not0_implies_Suc by blast + have "v \ u \s x" + using \(hd ws)\y\<^sup>@m\u = p\x\[folded \u \ v = y\, unfolded \m = Suc m'\ pow_Suc2 rassoc] + suffix_appendD[THEN suf_prod_long[OF _ \\<^bold>|v \ u\<^bold>| \ \<^bold>|x\<^bold>|\], of p "hd ws \ (u \ v) \<^sup>@ m' \ u", unfolded rassoc] by simp + have "(v \ u) \ x = x \ (v \ u)" + using root_suf_comm'[OF \x \p (v \ u) \ x\ \(v \ u) \s x\]. + thus False + using \u \ v = y\ comm_prim conjugI nconjug prim_conjug prim_x prim_y by metis + next + assume "m = 0" + thus False + proof (cases "hd ws = y") + assume "hd ws = y" + have "p \ (x \ x) \ s = y\<^sup>@Suc (Suc (Suc (m+l)))" + unfolding rassoc \v \ y\<^sup>@l \ (last ws) = x \ s\[unfolded \last ws = y\, symmetric] power_Suc2 + unfolding lassoc \(hd ws)\y\<^sup>@m\u = p\x\[unfolded \hd ws = y\, symmetric] + \u \ v = y\[symmetric] + by comparison + have "\ x \ \ y" + proof (rule fac_two_conjug_primroot) + show "x \ \" and "y \ \" using bin_fst_nemp bin_snd_nemp. + show "x \ x \f y\<^sup>@Suc (Suc (Suc (m+l)))" + using facI[of "x\x" p s,unfolded \p \ (x \ x) \ s = y\<^sup>@Suc (Suc (Suc (m+l)))\]. + show "x \ x \f x\<^sup>@2" + unfolding pow_two by blast + show "\<^bold>|x\<^bold>| + \<^bold>|y\<^bold>| - (gcd \<^bold>|x\<^bold>| \<^bold>|y\<^bold>|) \ \<^bold>|x \ x\<^bold>|" + using y_le_x unfolding lenmorph by auto + qed + thus False + unfolding x_root y_root using nconjug by blast + next + assume "hd ws \ y" + hence "hd ws = x" + using hd_ws_lists by auto + + have "u \ v = v \ u" + proof (rule pref_suf_pers_short[reversed]) + show "x \s x \ u" + using \(hd ws)\y\<^sup>@m\u = p\x\[unfolded \m = 0\ \hd ws = x\ pow_zero clean_emp] + by (simp add: suf_def) + have "v \ u \p x" + using \x \p (v \ u) \ x\ y_le_x[folded \u \ v = y\,unfolded swap_len[of u]] + pref_prod_long by blast + thus "\<^bold>|v \ u\<^bold>| < \<^bold>|x\<^bold>|" + using nconjug conjugI[OF _ \u \ v = y\, of x] \\<^bold>|v \ u\<^bold>| \ \<^bold>|x\<^bold>|\ + le_neq_implies_less pref_same_len by blast + from \x \p (v \ u)\<^sup>@Suc l \ v\ + show "x \p ((v \ u) \ v) \ (u \ v)\<^sup>@l" + by comparison + show "(u \ v) \<^sup>@ l \ \{v, u}\" + by blast + qed + thus False + using prim_y \u \ v \ v \ u\ by simp + qed + qed +qed + +lemma rev_square_interp: + "square_interp (rev x) (rev y) (rev s) (rev p) (rev (map rev ws))" +proof (unfold_locales) + show "rev (map rev ws) \ lists {rev x, rev y}" + using ws_lists by force + show "(rev s) (rev x \ rev x) (rev p) \\<^sub>\ rev (map rev ws)" + using interp rev_fac_interp by fastforce + show "\<^bold>|rev y\<^bold>| \ \<^bold>|rev x\<^bold>|" + using y_le_x by simp + show "\ (rev x) \ (rev y)" + by (simp add: conjug_rev_conv nconjug) + show "primitive (rev x)" and "primitive (rev y)" + using prim_x prim_y by (simp_all add: prim_rev_iff) + show "\p1 p2. p1 \p [rev x, rev x] \ p2 \p rev (map rev ws) \ rev s \ concat p1 \ concat p2" + proof + fix p1' p2' assume "p1' \p [rev x, rev x]" and "p2' \p rev (map rev ws)" and "rev s \ concat p1' = concat p2'" + obtain p1 p2 where "p1' \ p1 = [rev x, rev x]" and "p2'\p2 = rev (map rev ws)" + using \p1' \p [rev x, rev x]\ \p2' \p rev (map rev ws)\ by (auto simp add: prefix_def) + hence "rev s \ (concat p1' \ concat p1) \ rev p = concat p2' \ concat p2" + unfolding concat_morph[symmetric] using \(rev s) (rev x \ rev x) (rev p) \\<^sub>\ rev (map rev ws)\ fac_interpretE(3) by force + from this[unfolded lassoc, folded \rev s \ concat p1' = concat p2'\, unfolded rassoc cancel] + have "concat p1 \ rev p = concat p2". + hence "p \ (concat (rev (map rev p1))) = concat (rev (map rev p2))" + using rev_append rev_concat rev_map rev_rev_ident by metis + have "rev (map rev p1) \p [x,x]" + using arg_cong[OF \p1' \ p1 = [rev x, rev x]\, of "\ x. rev (map rev x)", unfolded map_append rev_append] + by fastforce + have "rev (map rev p2) \p ws" + using arg_cong[OF \p2'\p2 = rev (map rev ws)\, of "\ x. rev (map rev x)", unfolded map_append rev_append rev_map + rev_rev_ident map_rev_involution, folded rev_map] by blast + from disjoint[OF \rev (map rev p1) \p [x,x]\ \rev (map rev p2) \p ws\] + show False + using \p \ (concat (rev (map rev p1))) = concat (rev (map rev p2))\ by blast + qed +qed + +lemma hd_ws: "hd ws = x" +using square_interp.last_ws[reversed, OF rev_square_interp] +unfolding hd_map[OF ws_nemp] + by simp + +lemma p_pref: "p

Locale with additional parameters\ + \ \Obtained parameters added into the context, we show that there is just one @{term y} in @{term ws}, + that is, that @{term "m = 0"} and @{term "l = 0"}. + The proof harvests results obtained in the section "Lemmas for covered x square" +\ + +locale square_interp_plus = square_interp + + fixes l m u v + assumes fst_x: "x \ y\<^sup>@m \ u = p \ x" and + snd_x: "v \ y\<^sup>@l \ x = x \ s" and + uv_y: "u \ v = y" and + uv_code: "u \ v \ v \ u" +begin + +interpretation binary_code x y + using binary_code.intro comm_prim nconjug nconjug_neq prim_x prim_y by metis + +interpretation uv: binary_code u v + using uv_code by (simp add: binary_code.intro) + +lemma rev_square_interpret_plus: "square_interp_plus (rev x) (rev y) (rev s) (rev p) (rev (map rev ws)) m l (rev v) (rev u)" +proof- + note fac_interpretE[OF interp, unfolded hd_ws last_ws] + note \s [unfolded strict_suffix_to_prefix] + note \p

[unfolded spref_rev_suf_iff] + + interpret i: square_interp "(rev x)" "(rev y)" "(rev s)" "(rev p)" "(rev (map rev ws))" + using rev_square_interp. + show ?thesis + apply standard + apply (simp_all del: rev_append add: rev_pow[symmetric] rev_append[symmetric]) + by (simp_all only: uv_code, simp_all add: fst_x snd_x uv_y) +qed + +subsubsection \Exactly one of the exponents is zero: impossible.\ + +text \Uses lemma @{thm pref_suf_pers_short} and exploits the symmetric interpretation.\ + +lemma fst_exp_zero: assumes "m = 0" and "l \ 0" shows "False" +proof (rule notE[OF uv_code]) + note y_le_x[folded uv_y, unfolded swap_len[of u]] + have "x \p (v \ (u \ v) \<^sup>@ l) \ x" + unfolding rassoc using snd_x[folded uv_y] by fast + moreover have "v \ (u \ v) \<^sup>@ l \ \" + using uv_code by force + ultimately obtain exp where "x \p (v \ (u \ v) \<^sup>@ l)\<^sup>@exp" + using per_prefE by blast + hence "exp \ 0" + using pow_zero bin_fst_nemp[folded prefix_Nil] by metis + + show "u \ v = v \ u" + proof (rule pref_suf_pers_short[reversed]) + show "x \s x \ u" + using fst_x[unfolded \m = 0\ pow_zero clean_emp] by (simp add: suf_def) + have "((v \ u) \ v) \ ((u \ v)\<^sup>@(l-1)) \ (v \ (u \ v) \<^sup>@ l)\<^sup>@(exp -1) = (v \ (u \ v) \<^sup>@ l)\<^sup>@exp" + (is "((v \ u) \ v) \ ?suf = (v \ (u \ v) \<^sup>@ l)\<^sup>@exp") + by (simp add: \exp \ 0\ \l \ 0\ pop_pow_one) + show "((u \ v)\<^sup>@(l-1)) \ (v \ (u \ v) \<^sup>@ l)\<^sup>@(exp -1) \ \{v,u}\" + by (simp add: gen_in hull_closed power_in) + have "v \ u \p x" + using pref_prod_longer[OF \x \p (v \ (u \ v) \<^sup>@ l) \ x\[unfolded rassoc] _ \\<^bold>|v \ u\<^bold>| \ \<^bold>|x\<^bold>|\] + unfolding pop_pow_one[OF \l \ 0\] rassoc by blast + thus "\<^bold>|v \ u\<^bold>| < \<^bold>|x\<^bold>|" + using nconjug conjugI[OF _ uv_y, of x] \\<^bold>|v \ u\<^bold>| \ \<^bold>|x\<^bold>|\ + le_neq_implies_less pref_same_len by blast + show "x \p ((v \ u) \ v) \ ?suf" + unfolding \((v \ u) \ v) \ ?suf = (v \ (u \ v) \<^sup>@ l)\<^sup>@exp\ by fact + qed +qed + +lemma snd_exp_zero: assumes "m \ 0" and "l = 0" shows "False" +using square_interp_plus.fst_exp_zero[OF rev_square_interpret_plus, reversed, + rotated, OF assms]. + +subsubsection \Both exponents positive: impossible\ + +lemma both_exps_pos: assumes "m \ 0" and "l \ 0" shows "False" +proof- + note fac_interpretE[OF interp, unfolded hd_ws last_ws] + have "\<^bold>|p\<^bold>| \ \<^bold>|x\<^bold>|" and "\<^bold>|s\<^bold>| \ \<^bold>|x\<^bold>|" + using pref_len[OF sprefD1[OF \p

]] suf_len[OF ssufD1[OF \s ]]. + + obtain m' l' where "Suc m' = m" and "Suc l' = l" + using assms predE by metis + have "x \p (v \ (u \ v)\<^sup>@Suc l') \ x" + (is "x \p ?pref \ x") + using snd_x[folded uv_y \Suc l' = l\] by force + moreover have "x \s x \ ((u \ v)\<^sup>@Suc m' \ u)" + (is "x \s x \ ?suf") + using fst_x[folded uv_y \Suc m' = m\] by force + + ultimately interpret pref_suf_pers x u v l' m' + by (unfold_locales) + + have "?pref \p x" + using snd_x[folded uv_y \Suc l' = l\ rassoc, symmetric] eqd[reversed, OF _ \\<^bold>|s\<^bold>| \ \<^bold>|x\<^bold>|\] by blast + have "?suf \s x" + using fst_x[folded uv_y \Suc m' = m\, symmetric] eqd[OF _ \\<^bold>|p\<^bold>| \ \<^bold>|x\<^bold>|\] by blast + + have in_particular: "commutes {u,v,x} \ u \ v = v \ u" + using commutes_def insertCI by metis + have in_particular': "x \ v \ u = (v \ u) \ x \ x \ y" + using comm_prim conjugI' prim_conjug prim_x prim_y uv_y by metis + +\ \Case analysis based on (slightly modified) lemmas for covered x square.\ + + note no_overlap_comm = no_overlap[THEN in_particular] and + short_overlap_comm = short_overlap[THEN in_particular] and + medium_overlap_comm = medium_overlap[THEN in_particular] and + large_overlap_conjug = pref_suf_pers_large_overlap[OF \?pref \p x\ \?suf \s x\,THEN in_particular'] + + consider + (no_overlap) "\<^bold>|?pref\<^bold>| + \<^bold>|?suf\<^bold>| \ \<^bold>|x\<^bold>|" | + (short_overlap) "\<^bold>|x\<^bold>| < \<^bold>|?pref\<^bold>| + \<^bold>|?suf\<^bold>| \ \<^bold>|?pref\<^bold>| + \<^bold>|?suf\<^bold>| \ \<^bold>|x\<^bold>| + \<^bold>|u\<^bold>|" | + (medium_overlap) "\<^bold>|x\<^bold>| + \<^bold>|u\<^bold>| < \<^bold>|?pref\<^bold>| + \<^bold>|?suf\<^bold>| \ \<^bold>|?pref\<^bold>| + \<^bold>|?suf\<^bold>| < \<^bold>|x\<^bold>| + \<^bold>|u \ v\<^bold>|" | + (large_overlap) "\<^bold>|x\<^bold>| + \<^bold>|v \ u\<^bold>| \ \<^bold>|?pref\<^bold>| + \<^bold>|?suf\<^bold>|" + unfolding swap_len[of v] by linarith + thus False + proof (cases) + case no_overlap + then show False + using no_overlap_comm uv_code by blast + next + case short_overlap + then show False + using short_overlap_comm uv_code by blast + next + case medium_overlap + then show False + using medium_overlap_comm uv_code by blast + next + case large_overlap + show False + thm large_overlap_conjug nconjug + proof (rule notE[OF nconjug], rule large_overlap_conjug[OF _ _ large_overlap]) + have "(u \ v) \<^sup>@ l' \p (u \ v) \<^sup>@ Suc l'" + using pref_pow_ext by blast + thus "v \ (u \ v) \<^sup>@ Suc l' \p (v \ u) \ v \ (u \ v) \<^sup>@ Suc l'" + unfolding pow_Suc rassoc pref_cancel_conv. + show "(u \ v) \<^sup>@ Suc m' \ u \s ((u \ v) \<^sup>@ Suc m' \ u) \ v \ u" + by comparison + qed + qed +qed + +thm suf_cancel_conv + +end + +subsection \Back to the main locale\ + +context square_interp + +begin + +definition u where "u = x\\<^sup>>(p \ x)" +definition v where "v = (x \ s)\<^sup><\x" + +lemma cover_xyx: "ws = [x,y,x]" and uv_code: "u \ v \ v \ u" and uv_y: "u \ v = y" and + px_xu: "p \ x = x \ u" and vx_xs: "v \ x = x \ s" +proof- + note prim_nemp[OF prim_y] + obtain k where ws: "[x] \ [y]\<^sup>@k \ [x] = ws" + using kE[unfolded hd_ws last_ws]. + obtain m u' v' l where "x \ y \<^sup>@ m \ u' = p \ x" and "v' \ y \<^sup>@ l \ x = x \ s" and "u' \ v' = y" and "u' \ v' \ v' \ u'" + using l_mE[unfolded hd_ws last_ws]. + then interpret square_interp_plus x y p s ws l m u' v' + by (unfold_locales) + have "m = 0" and "l = 0" + using both_exps_pos snd_exp_zero fst_exp_zero by blast+ + have "u' = u" + unfolding u_def + using conjug_lq[OF fst_x[unfolded \m = 0\ pow_zero clean_emp, symmetric]]. + have "v' = v" + unfolding v_def + using conjug_lq[reversed, OF snd_x[unfolded \l = 0\ pow_zero clean_emp, symmetric]]. + have "x \ y \<^sup>@ m \ (u' \ v') \ y\<^sup>@l \ x = concat ws" + unfolding interpret_concat[symmetric] using fst_x snd_x by force + from this[folded ws, unfolded \u' \ v' = y\ \m = 0\ \l = 0\ pow_zero clean_emp] + have "k = 1" + unfolding eq_pow_exp[OF \y \ \\, of k 1, symmetric] pow_one' concat_morph concat_pow + by simp + from ws[unfolded this pow_one'] + show "ws = [x,y,x]" by simp + show "u \ v = y" and "u \ v \ v \ u" + unfolding \u' = u\[symmetric] \v' = v\[symmetric] by fact+ + show "p \ x = x \ u" + using \x \ y \<^sup>@ m \ u' = p \ x\[unfolded \m = 0\ \u' = u\ pow_zero clean_emp, symmetric]. + show " v \ x = x \ s" + using \v' \ y \<^sup>@ l \ x = x \ s\[unfolded \l = 0\ \v' = v\ pow_zero clean_emp]. +qed + +lemma u_nemp: "u \ \" and v_nemp: "v \ \" + using uv_code by force+ + +lemma cover: "x \ y \ x = p \ x \ x \ s" + using interpret_concat cover_xyx by auto + +lemma conjug_facs: "\ u \ \ v" +proof- + note sufI[OF px_xu] + have "u \ \" + using p_nemp px_xu by force + obtain expu where "x \f u\<^sup>@expu" + using per_prefE[reversed, OF \ x \s x \ u\ \u \ \\ pref_fac[reversed,elim_format]]. + + note prefI[OF vx_xs[symmetric]] + have "v \ \" + using s_nemp vx_xs by force + obtain expv where "x \f v\<^sup>@expv" + using per_prefE[OF \x \p v \ x\ \v \ \\ pref_fac[elim_format]]. + + show "\ u \ \ v" + proof(rule fac_two_conjug_primroot[OF \x \f u\<^sup>@expu\ \x \f v\<^sup>@expv\ \u \ \\ \v \ \\]) + show "\<^bold>|u\<^bold>| + \<^bold>|v\<^bold>| - (gcd \<^bold>|u\<^bold>| \<^bold>|v\<^bold>|) \ \<^bold>|x\<^bold>|" + using y_le_x[folded uv_y, unfolded lenmorph] by fastforce + qed +qed + +term square_interp.v + +\ \We have a detailed information about all words\ +lemma bin_sq_interpE: obtains r t m k l + where "(t \ r)\<^sup>@Suc k = u" and "(r \ t)\<^sup>@Suc l = v" and + "(r \ t)\<^sup>@Suc m \ r = x" and "(t \ r)\<^sup>@Suc k \ (r \ t)\<^sup>@Suc l = y" + and "(r \ t)\<^sup>@Suc k = p" and "(t \ r)\<^sup>@Suc l = s" and "r \ t \ t \ r" +proof- + + obtain r t k m where "(r \ t)\<^sup>@Suc k = p" and "(t \ r)\<^sup>@Suc k = u" and "(r \ t)\<^sup>@m \ r = x" and + "t \ \" and "primitive (r \ t)" + using conjug_eq_primrootE[OF px_xu p_nemp]. + have "t \ r = \ u" + using prim_conjug[OF \primitive (r \ t)\, THEN pow_prim_primroot[OF u_nemp], OF conjugI' \(t \ r)\<^sup>@Suc k = u\[symmetric]].. + + have "m \ 0" + proof + assume "m = 0" + hence "x = r" using \(r \ t)\<^sup>@m \ r = x\ by simp + from y_le_x[folded uv_y, folded \(t \ r)\<^sup>@Suc k = u\, unfolded lenmorph pow_len this] + show False + using nemp_len[OF \t \ \\] by force + qed + + then obtain pred_m where "m = Suc pred_m" + using not0_implies_Suc by auto + + from \(r \ t)\<^sup>@m \ r = x\[unfolded this] + have "r \ t \p x" + by auto + + have "r \ t = \ v" + proof (rule ruler_eq_len[of "\ v" "x" "r \ t", symmetric]) + have "\<^bold>|\ v\<^bold>| \ \<^bold>|x\<^bold>|" + unfolding conjug_len[OF conjug_facs, symmetric] \t \ r = \ u\[symmetric] + unfolding \(r \ t)\<^sup>@m \ r = x\[symmetric] + lenmorph pow_len + using \m = Suc pred_m\ by auto + from ruler_le[OF _ _ this, of "v \ x"] + show "\ v \p x" + using vx_xs prefI prefix_prefix primroot_pref v_nemp by metis + show "r \ t \p x" by fact + show "\<^bold>|\ v\<^bold>| = \<^bold>|r \ t\<^bold>|" + unfolding conjug_len[OF conjug_facs, symmetric, folded \t \ r = \ u\] lenmorph by simp + qed + + then obtain l where "(r \ t)\<^sup>@Suc l = v" + using primroot_expE v_nemp by metis + + have "(t \ r)\<^sup>@Suc l = s" + using vx_xs[folded \(r \ t)\<^sup>@m \ r = x\ \(r \ t)\<^sup>@Suc l = v\, unfolded lassoc pows_comm[of _ _ m], + unfolded rassoc cancel, unfolded shift_pow cancel]. + + have "r \ t \ t \ r" + using \(t \ r) \<^sup>@ Suc k = u\ \(r \ t) \<^sup>@ Suc l = v\ pows_comm[of "t \ r" "Suc k" "Suc l"] uv_code by force + + show thesis + using that[OF \(t \r)\<^sup>@Suc k = u\ \(r \ t) \<^sup>@ Suc l = v\ \(r \ t)\<^sup>@m \ r = x\[unfolded \m = Suc pred_m\] + uv_y[folded \(t \r)\<^sup>@Suc k = u\ \(r \ t) \<^sup>@ Suc l = v\] \(r \ t) \<^sup>@ Suc k = p\ \(t \ r) \<^sup>@ Suc l = s\ \r \ t \ t \ r\]. +qed + +end + +subsection \Locale: Extendable interpretation\ +text \Further specification follows from the assumption that the interpretation is extendable, + that is, the covered @{term "x\x"} is a factor of a word composed of @{term "{x,y}"}. Namely, @{term u} and @{term v} are then conjugate by @{term x}.\ + +locale square_interp_ext = square_interp + + assumes p_extend: "\ pe. pe \ \{x,y}\ \ p \s pe" and + s_extend: "\ se. se \ \{x,y}\ \ s \p se" + +begin + +lemma s_pref_y: "s \p y" +proof- + obtain sy ry eu ev ex + where "(ry \ sy)\<^sup>@Suc eu = u" and "(sy \ ry)\<^sup>@Suc ev = v" and + "(sy \ ry)\<^sup>@Suc eu = p" and "(ry \ sy)\<^sup>@Suc ev = s" and + "(sy \ ry)\<^sup>@Suc ex \ sy = x" and "sy \ ry \ ry \ sy" + using bin_sq_interpE. + + obtain se where "se \ \{x,y}\" and "s \p se" + using s_extend by blast + hence "se \ \" using s_nemp by force + + from \(sy \ ry)\<^sup>@Suc ex \ sy = x\ + have "sy \ ry \p x" + unfolding pow_Suc rassoc by force + + have "x \p se \ y \p se" + using \se \ \\ hull.cases[OF \se \ \{x,y}\\, of "x \p se \ y \p se"] + prefix_append triv_pref two_elem_cases by blast + moreover have "\ x \p se" + proof + assume "x \p se" + from ruler_eq_len[of "sy \ ry" se "ry \ sy", OF pref_trans[OF \sy \ ry \p x\ this]] + show False + using \s \p se\[folded \(ry \ sy)\<^sup>@Suc ev = s\[unfolded pow_Suc]] \sy \ ry \ ry \ sy\ by (force simp add: prefix_def) + qed + ultimately have y_pref_se: "y \p se" by blast + + from ruler_le[OF \s \p se\ this] + show "s \p y" + using lenarg[OF vx_xs] unfolding uv_y[symmetric] lenmorph by linarith +qed + +lemma rev_square_interpret_ext: "square_interp_ext (rev x) (rev y) (rev s) (rev p) (rev (map rev ws))" +proof- + interpret i: square_interp "(rev x)" "(rev y)" "(rev s)" "(rev p)" "(rev (map rev ws))" + using rev_square_interp. + show ?thesis + proof + show "\pe. pe \ \{rev x, rev y}\ \ rev s \s pe" + using pref_rev_suf_iff s_pref_y by blast + obtain pe where "pe \ \{x, y}\" and "p \s pe" + using p_extend by blast + hence "rev pe \ \{rev x, rev y}\" + by (simp add: rev_hull rev_in_conv) + thus "\se. se \ \{rev x, rev y}\ \ rev p \p se" + using \p \s pe\[unfolded suf_rev_pref_iff prefix_def] rev_rev_ident by blast + qed +qed + +lemma p_suf_y: "p \s y" +proof- + interpret i: square_interp_ext "(rev x)" "(rev y)" "(rev s)" "(rev p)" "(rev (map rev ws))" + using rev_square_interpret_ext. + + from i.s_pref_y[reversed] + show "p \s y". +qed + +theorem bin_sq_interpret_extE: obtains r t k m where "(r \ t)\<^sup>@Suc m \ r = x" and "(t \ r)\<^sup>@Suc k \ (r \ t)\<^sup>@ Suc k = y" + "(r \ t)\<^sup>@Suc k = p" and "(t \ r)\<^sup>@ Suc k = s" and "r \ t \ t \ r" and "u = s" and "v = p" and "\<^bold>|p\<^bold>| = \<^bold>|s\<^bold>|" +proof- + obtain r t k k' m + where u: "(t \ r)\<^sup>@Suc k = u" and v: "(r \ t)\<^sup>@Suc k' = v" and + p: "(r \ t)\<^sup>@Suc k = p" and s: "(t \ r)\<^sup>@Suc k' = s" and + x: "(r \ t)\<^sup>@Suc m \ r = x" and code: "r \ t \ t \ r" + using bin_sq_interpE. + have "\<^bold>|u \ v\<^bold>| = \<^bold>|s \ p\<^bold>|" + using lenarg[OF px_xu, unfolded lenmorph] lenarg[OF vx_xs, unfolded lenmorph] by simp + hence "u \ v = s \ p" + unfolding uv_y using s_pref_y p_suf_y by (auto simp add: prefix_def suf_def) + note eq = \u \ v = s \ p\[unfolded \(t \ r)\<^sup>@Suc k = u\[symmetric] \(r \ t)\<^sup>@Suc k' = v\[symmetric], + unfolded \(t \ r)\<^sup>@Suc k' = s\[symmetric] \(r \ t)\<^sup>@Suc k = p\[symmetric]] + from pows_eq_comm[OF this, THEN comm_add_exps, of "Suc k" "Suc k'"] + have "k = k'" + unfolding \(t \ r) \<^sup>@ Suc k = u\ \(r \ t) \<^sup>@ Suc k' = v\ using uv_code by blast + have "\<^bold>|p\<^bold>| = \<^bold>|s\<^bold>|" + using lenarg[OF p] lenarg[OF s] unfolding \k = k'\ pow_len lenmorph add.commute[of "\<^bold>|r\<^bold>|"] by fastforce + thus thesis + using that[OF x uv_y[folded u v \k = k'\] p s[folded \k = k'\] code] u v p s unfolding \k = k'\ by argo +qed + +lemma ps_len: "\<^bold>|p\<^bold>| = \<^bold>|s\<^bold>|" and p_eq_v: "p = v" and s_eq_u: "s = u" + using bin_sq_interpret_extE by blast+ + +lemma v_x_x_u: "v \ x = x \ u" + using vx_xs unfolding s_eq_u. + +lemma sp_y: "s \ p = y" + using p_eq_v s_eq_u uv_y by auto + +lemma p_x_x_s: "p \ x = x \ s" + by (simp add: px_xu s_eq_u) + +lemma xxy_root: "x \ x \ y = (x \ p) \ (x \ p)" + using p_x_x_s sp_y by force + +theorem sq_ext_interp: "ws = [x, y, x]" "s \ p = y" "p \ x = x \ s" + using cover_xyx sp_y p_x_x_s. + +end + +theorem bin_sq_interpE: + assumes "primitive x" and "primitive y" and "\<^bold>|y\<^bold>| \ \<^bold>|x\<^bold>|" and "ws \ lists {x, y}" and "\ x \ y" and + "\ p1 p2. p1 \p [x, x] \ p2 \p ws \ p \ concat p1 \ concat p2" and "p x \ x s \\<^sub>\ ws" + obtains r t m k l where "(r \ t)\<^sup>@Suc m \ r = x" and "(t \ r)\<^sup>@Suc k \ (r \ t)\<^sup>@ Suc l = y" + "(r \ t)\<^sup>@Suc k = p" and "(t \ r)\<^sup>@ Suc l = s" and "r \ t \ t \ r" + using square_interp.bin_sq_interpE[OF square_interp.intro, OF assms, of thesis]. + +theorem bin_sq_interpret_extE: + assumes "primitive x" and "primitive y" and "\<^bold>|y\<^bold>| \ \<^bold>|x\<^bold>|" and "ws \ lists {x, y}" and "\ x \ y" and + "\ p1 p2. p1 \p [x, x] \ p2 \p ws \ p \ concat p1 \ concat p2" and "p x \ x s \\<^sub>\ ws" and + p_extend: "\ pe. pe \ \{x,y}\ \ p \s pe" and + s_extend: "\ se. se \ \{x,y}\ \ s \p se" + obtains r t m k where "(r \ t)\<^sup>@Suc m \ r = x" and "(t \ r)\<^sup>@Suc k \ (r \ t)\<^sup>@ Suc k = y" + "(r \ t)\<^sup>@Suc k = p" and "(t \ r)\<^sup>@ Suc k = s" and "r \ t \ t \ r" + using square_interp_ext.bin_sq_interpret_extE[OF square_interp_ext.intro, OF square_interp.intro square_interp_ext_axioms.intro, OF assms, of thesis]. + +end \ No newline at end of file diff --git a/thys/Binary_Code_Imprimitive/ROOT b/thys/Binary_Code_Imprimitive/ROOT new file mode 100644 --- /dev/null +++ b/thys/Binary_Code_Imprimitive/ROOT @@ -0,0 +1,12 @@ +chapter AFP + +session Binary_Code_Imprimitive (AFP) = Combinatorics_Words + + options [timeout = 600] + sessions + Combinatorics_Words_Graph_Lemma + theories + Binary_Square_Interpretation + Binary_Code_Imprimitive + document_files + root.tex + root.bib diff --git a/thys/Binary_Code_Imprimitive/document/root.bib b/thys/Binary_Code_Imprimitive/document/root.bib new file mode 100644 --- /dev/null +++ b/thys/Binary_Code_Imprimitive/document/root.bib @@ -0,0 +1,37 @@ +@PhdThesis{spehner, + title = "{Quelques probl\`{e}mes d'extension, de conjugaison et de présentation des sous-mono\"{i}des d'un mono\"{i}de libre.}", + author = "Spehner, J.-C.", + school = "Universit\'{e} Paris VII, Paris", + year = "1976", +} + +@Article{lerest, + author = {Barbin-Le Rest, Evelyne and Le Rest, Michel}, + title = {Sur la Combinatoire des Codes \`{a} Deux Mots.}, + journal = {Theor. Comput. Sci.}, + year = {1985}, + volume = {41}, + pages = {61--80}, + added-at = {2011-09-07T00:00:00.000+0200}, + biburl = {http://www.bibsonomy.org/bibtex/253c7e2761f4ea85902779bcf0c728123/dblp}, + ee = {http://dx.doi.org/10.1016/0304-3975(85)90060-X}, + interhash = {f84dac1c875cca36656e0d06f0f35127}, + intrahash = {53c7e2761f4ea85902779bcf0c728123}, + keywords = {dblp}, + timestamp = {2011-09-07T00:00:00.000+0200}, +} + +@article{Manuch, + author = {J{\'{a}}n Ma{\v n}uch}, + title = {Defect Effect of Bi-infinite Words in the Two-element Case}, + journal = {Discret. Math. Theor. Comput. Sci.}, + volume = {4}, + number = {2}, + pages = {273--290}, + year = {2001}, + url = {http://dmtcs.episciences.org/279}, + timestamp = {Fri, 13 Mar 2020 14:37:54 +0100}, + biburl = {https://dblp.org/rec/journals/dmtcs/Manuch01.bib}, + bibsource = {dblp computer science bibliography, https://dblp.org}, + doi = {10.46298/dmtcs.279} +} \ No newline at end of file diff --git a/thys/Binary_Code_Imprimitive/document/root.tex b/thys/Binary_Code_Imprimitive/document/root.tex new file mode 100644 --- /dev/null +++ b/thys/Binary_Code_Imprimitive/document/root.tex @@ -0,0 +1,76 @@ +\documentclass[11pt,a4paper]{report} +\usepackage[utf8]{inputenc} +\usepackage{isabelle,isabellesym} +\usepackage{fontspec} + +% further packages required for unusual symbols (see also +% isabellesym.sty), use only when needed + +\usepackage{amssymb} + %for \, \, \, \, \, \, + %\, \, \, \, \, + %\, \, \ + +%\usepackage{eurosym} + %for \ + +%\usepackage[only,bigsqcap]{stmaryrd} + %for \ + +%\usepackage{eufrak} + %for \ ... \, \ ... \ (also included in amssymb) + +%\usepackage{textcomp} + %for \, \, \, \, \, + %\ + +% this should be the last package used +\usepackage{pdfsetup} + +% urls in roman style, theory text in math-similar italics +\urlstyle{rm} +\isabellestyle{it} + +% for uniform font size +%\renewcommand{\isastyle}{\isastyleminor} + + +\begin{document} + +\title{Combinatorics on Words formalized \\ Binary codes that do not preserve primitivity} +\author{Štěpán Holub \\ Martin Raška } + + + \date{ \today + \vfill + Funded by the Czech Science Foundation grant GA\v CR 20-20621S.} + +\maketitle + +%\begin{abstract} +%Lecture notes +%\end{abstract} + +\tableofcontents +\vspace{\baselineskip} + +% sane default for proof documents +\parindent 0pt\parskip 0.5ex + +% generated text of all theories +\input{session} + +% optional bibliography +\cleardoublepage +\phantomsection +\addcontentsline{toc}{chapter}{References} +\renewcommand{\bibname}{References} +\bibliographystyle{abbrv} +\bibliography{root} + +\end{document} + +%%% Local Variables: +%%% mode: latex +%%% TeX-master: t +%%% End: diff --git a/thys/ROOTS b/thys/ROOTS --- a/thys/ROOTS +++ b/thys/ROOTS @@ -1,734 +1,735 @@ ABY3_Protocols ADS_Functor AI_Planning_Languages_Semantics AODV AOT AVL-Trees AWN Abortable_Linearizable_Modules Abs_Int_ITP2012 Abstract-Hoare-Logics Abstract-Rewriting Abstract_Completeness Abstract_Soundness Ackermanns_not_PR Actuarial_Mathematics Adaptive_State_Counting Affine_Arithmetic Aggregation_Algebras Akra_Bazzi Algebraic_Numbers Algebraic_VCs Allen_Calculus Amicable_Numbers Amortized_Complexity AnselmGod Applicative_Lifting Approximation_Algorithms Architectural_Design_Patterns Aristotles_Assertoric_Syllogistic Arith_Prog_Rel_Primes ArrowImpossibilityGS Attack_Trees Auto2_HOL Auto2_Imperative_HOL AutoFocus-Stream Automated_Stateful_Protocol_Verification Automatic_Refinement AxiomaticCategoryTheory BDD BD_Security_Compositional BNF_CC BNF_Operations BTree Balog_Szemeredi_Gowers Banach_Steinhaus Belief_Revision Bell_Numbers_Spivey BenOr_Kozen_Reif Berlekamp_Zassenhaus Bernoulli Bertrands_Postulate Bicategory BinarySearchTree +Binary_Code_Imprimitive Binding_Syntax_Theory Binomial-Heaps Binomial-Queues BirdKMP Birkhoff_Finite_Distributive_Lattices Blue_Eyes Bondy Boolean_Expression_Checkers Boolos_Curious_Inference Boolos_Curious_Inference_Automated Bounded_Deducibility_Security Buchi_Complementation Budan_Fourier Buffons_Needle Buildings BytecodeLogicJmlTypes C2KA_DistributedSystems CAVA_Automata CAVA_LTL_Modelchecker CCS CHERI-C_Memory_Model CISC-Kernel CRDT CRYSTALS-Kyber CSP_RefTK CVP_Hardness CYK CZH_Elementary_Categories CZH_Foundations CZH_Universal_Constructions CakeML CakeML_Codegen Call_Arity Card_Equiv_Relations Card_Multisets Card_Number_Partitions Card_Partitions Cartan_FP Case_Labeling Catalan_Numbers Category Category2 Category3 Cauchy Cayley_Hamilton Certification_Monads Chandy_Lamport Chord_Segments Circus Clean Clique_and_Monotone_Circuits ClockSynchInst Closest_Pair_Points CoCon CoSMeDis CoSMed CofGroups Coinductive Coinductive_Languages Collections Combinable_Wands Combinatorial_Enumeration_Algorithms Combinatorics_Words Combinatorics_Words_Graph_Lemma Combinatorics_Words_Lyndon Commuting_Hermitian Comparison_Sort_Lower_Bound Compiling-Exceptions-Correctly Complete_Non_Orders Completeness Complex_Bounded_Operators Complex_Geometry Complx ComponentDependencies ConcurrentGC ConcurrentIMP Concurrent_Ref_Alg Concurrent_Revisions Conditional_Simplification Conditional_Transfer_Rule Consensus_Refined Constructive_Cryptography Constructive_Cryptography_CM Constructor_Funs Containers Cook_Levin CoreC++ Core_DOM Core_SC_DOM Correctness_Algebras Cotangent_PFD_Formula Count_Complex_Roots CryptHOL CryptoBasedCompositionalProperties Cubic_Quartic_Equations DFS_Framework DOM_Components DPRM_Theorem DPT-SAT-Solver DataRefinementIBP Datatype_Order_Generator Decl_Sem_Fun_PL Decreasing-Diagrams Decreasing-Diagrams-II Dedekind_Real Deep_Learning Delta_System_Lemma Density_Compiler Dependent_SIFUM_Refinement Dependent_SIFUM_Type_Systems Depth-First-Search Derangements Deriving Descartes_Sign_Rule Design_Theory Dict_Construction Differential_Dynamic_Logic Differential_Game_Logic Digit_Expansions Dijkstra_Shortest_Path Diophantine_Eqns_Lin_Hom Dirichlet_L Dirichlet_Series DiscretePricing Discrete_Summation DiskPaxos Dominance_CHK DynamicArchitectures Dynamic_Tables E_Transcendental Echelon_Form EdmondsKarp_Maxflow Edwards_Elliptic_Curves_Group Efficient-Mergesort Elliptic_Curves_Group_Law Encodability_Process_Calculi Epistemic_Logic Equivalence_Relation_Enumeration Ergodic_Theory Error_Function Euler_MacLaurin Euler_Partition Eval_FO Example-Submission Extended_Finite_State_Machine_Inference Extended_Finite_State_Machines FFT FLP FOL-Fitting FOL_Axiomatic FOL_Harrison FOL_Seq_Calc1 FOL_Seq_Calc2 FOL_Seq_Calc3 FO_Theory_Rewriting FSM_Tests Factor_Algebraic_Polynomial Factored_Transition_System_Bounding Falling_Factorial_Sum Farkas FeatherweightJava Featherweight_OCL Fermat3_4 FileRefinement FinFun Finger-Trees Finite-Map-Extras Finite_Automata_HF Finite_Fields Finitely_Generated_Abelian_Groups First_Order_Terms First_Welfare_Theorem Fishburn_Impossibility Fisher_Yates Fishers_Inequality Flow_Networks Floyd_Warshall Flyspeck-Tame FocusStreamsCaseStudies Forcing Formal_Puiseux_Series Formal_SSA Formula_Derivatives Foundation_of_geometry Fourier Free-Boolean-Algebra Free-Groups Frequency_Moments Fresh_Identifiers FunWithFunctions FunWithTilings Functional-Automata Functional_Ordered_Resolution_Prover Furstenberg_Topology GPU_Kernel_PL Gabow_SCC GaleStewart_Games Gale_Shapley Game_Based_Crypto Gauss-Jordan-Elim-Fun Gauss_Jordan Gauss_Sums Gaussian_Integers GenClock General-Triangle Generalized_Counting_Sort Generic_Deriving Generic_Join GewirthPGCProof Girth_Chromatic Given_Clause_Loops GoedelGod Goedel_HFSet_Semantic Goedel_HFSet_Semanticless Goedel_Incompleteness Goodstein_Lambda GraphMarkingIBP Graph_Saturation Graph_Theory Green Groebner_Bases Groebner_Macaulay Gromov_Hyperbolicity Grothendieck_Schemes Group-Ring-Module HOL-CSP HOLCF-Prelude HRB-Slicing Hahn_Jordan_Decomposition Hales_Jewett Heard_Of Hello_World HereditarilyFinite Hermite Hermite_Lindemann Hidden_Markov_Models Higher_Order_Terms HoareForDivergence Hoare_Time Hood_Melville_Queue HotelKeyCards Huffman Hybrid_Logic Hybrid_Multi_Lane_Spatial_Logic Hybrid_Systems_VCs HyperCTL Hyperdual IEEE_Floating_Point IFC_Tracking IMAP-CRDT IMO2019 IMP2 IMP2_Binary_Heap IMP_Compiler IMP_Compiler_Reuse IP_Addresses Imperative_Insertion_Sort Implicational_Logic Impossible_Geometry Incompleteness Incredible_Proof_Machine Independence_CH Inductive_Confidentiality Inductive_Inference InfPathElimination InformationFlowSlicing InformationFlowSlicing_Inter Integration Interpolation_Polynomials_HOL_Algebra Interpreter_Optimizations Interval_Arithmetic_Word32 Intro_Dest_Elim Involutions2Squares Iptables_Semantics Irrational_Series_Erdos_Straus Irrationality_J_Hancl Irrationals_From_THEBOOK IsaGeoCoq IsaNet Isabelle_C Isabelle_Marries_Dirac Isabelle_Meta_Model Jacobson_Basic_Algebra Jinja JinjaDCI JinjaThreads JiveDataStoreModel Jordan_Hoelder Jordan_Normal_Form KAD KAT_and_DRA KBPs KD_Tree Key_Agreement_Strong_Adversaries Khovanskii_Theorem Kleene_Algebra Kneser_Cauchy_Davenport Knights_Tour Knot_Theory Knuth_Bendix_Order Knuth_Morris_Pratt Koenigsberg_Friendship Kruskal Kuratowski_Closure_Complement LLL_Basis_Reduction LLL_Factorization LOFT LP_Duality LTL LTL_Master_Theorem LTL_Normal_Form LTL_to_DRA LTL_to_GBA Lam-ml-Normalization LambdaAuth LambdaMu Lambda_Free_EPO Lambda_Free_KBOs Lambda_Free_RPOs Lambert_W Landau_Symbols Laplace_Transform Latin_Square LatticeProperties Launchbury Laws_of_Large_Numbers Lazy-Lists-II Lazy_Case Lehmer Lifting_Definition_Option Lifting_the_Exponent LightweightJava LinearQuantifierElim Linear_Inequalities Linear_Programming Linear_Recurrences Liouville_Numbers List-Index List-Infinite List_Interleaving List_Inversions List_Update LocalLexing Localization_Ring Locally-Nameless-Sigma Logging_Independent_Anonymity Lowe_Ontological_Argument Lower_Semicontinuous Lp Lucas_Theorem MDP-Algorithms MDP-Rewards MFMC_Countable MFODL_Monitor_Optimized MFOTL_Monitor MSO_Regex_Equivalence Markov_Models Marriage Mason_Stothers Matrices_for_ODEs Matrix Matrix_Tensor Matroids Max-Card-Matching Maximum_Segment_Sum Median_Method Median_Of_Medians_Selection Menger Mereology Mersenne_Primes Metalogic_ProofChecker MiniML MiniSail Minimal_SSA Minkowskis_Theorem Minsky_Machines Modal_Logics_for_NTS Modular_Assembly_Kit_Security Modular_arithmetic_LLL_and_HNF_algorithms Monad_Memo_DP Monad_Normalisation MonoBoolTranAlgebra MonoidalCategory Monomorphic_Monad MuchAdoAboutTwo Multi_Party_Computation Multirelations Multiset_Ordering_NPC Multitape_To_Singletape_TM Myhill-Nerode Name_Carrying_Type_Inference Nano_JSON Nash_Williams Nat-Interval-Logic Native_Word Nested_Multisets_Ordinals Network_Security_Policy_Verification Neumann_Morgenstern_Utility No_FTL_observers Nominal2 Noninterference_CSP Noninterference_Concurrent_Composition Noninterference_Generic_Unwinding Noninterference_Inductive_Unwinding Noninterference_Ipurge_Unwinding Noninterference_Sequential_Composition NormByEval Nullstellensatz Number_Theoretic_Transform Octonions OpSets Open_Induction Optics Optimal_BST Orbit_Stabiliser Order_Lattice_Props Ordered_Resolution_Prover Ordinal Ordinal_Partitions Ordinals_and_Cardinals Ordinary_Differential_Equations PAC_Checker PAL PAPP_Impossibility PCF PLM POPLmark-deBruijn PSemigroupsConvolution Package_logic Padic_Field Padic_Ints Pairing_Heap Paraconsistency Parity_Game Partial_Function_MR Partial_Order_Reduction Password_Authentication_Protocol Pell Perfect-Number-Thm Perron_Frobenius Physical_Quantities Pi_Calculus Pi_Transcendental Planarity_Certificates Pluennecke_Ruzsa_Inequality Poincare_Bendixson Poincare_Disc Polynomial_Factorization Polynomial_Interpolation Polynomials Pop_Refinement Posix-Lexing Possibilistic_Noninterference Power_Sum_Polynomials Pratt_Certificate Prefix_Free_Code_Combinators Presburger-Automata Prim_Dijkstra_Simple Prime_Distribution_Elementary Prime_Harmonic_Series Prime_Number_Theorem Priority_Queue_Braun Priority_Search_Trees Probabilistic_Noninterference Probabilistic_Prime_Tests Probabilistic_System_Zoo Probabilistic_Timed_Automata Probabilistic_While Probability_Inequality_Completeness Program-Conflict-Analysis Progress_Tracking Projective_Geometry Projective_Measurements Promela Proof_Strategy_Language PropResPI Propositional_Logic_Class Propositional_Proof_Systems Prpu_Maxflow PseudoHoops Psi_Calculi Ptolemys_Theorem Public_Announcement_Logic QHLProver QR_Decomposition Quantales Quantifier_Elimination_Hybrid Quasi_Borel_Spaces Quaternions Query_Optimization Quick_Sort_Cost RIPEMD-160-SPARK ROBDD RSAPSS Ramsey-Infinite Random_BSTs Random_Graph_Subgraph_Threshold Randomised_BSTs Randomised_Social_Choice Rank_Nullity_Theorem Real_Impl Real_Power Real_Time_Deque Recursion-Addition Recursion-Theory-I Refine_Imperative_HOL Refine_Monadic RefinementReactive Regex_Equivalence Registers Regression_Test_Selection Regular-Sets Regular_Algebras Regular_Tree_Relations Relation_Algebra Relational-Incorrectness-Logic Relational_Disjoint_Set_Forests Relational_Forests Relational_Method Relational_Minimum_Spanning_Trees Relational_Paths Rensets Rep_Fin_Groups ResiduatedTransitionSystem Residuated_Lattices Resolution_FOL Rewrite_Properties_Reduction Rewriting_Z Ribbon_Proofs Risk_Free_Lending Robbins-Conjecture Robinson_Arithmetic Root_Balanced_Tree Roth_Arithmetic_Progressions Routing Roy_Floyd_Warshall SATSolverVerification SCC_Bloemen_Sequential SC_DOM_Components SDS_Impossibility SIFPL SIFUM_Type_Systems SPARCv8 Safe_Distance Safe_OCL Safe_Range_RC Saturation_Framework Saturation_Framework_Extensions Sauer_Shelah_Lemma Schutz_Spacetime Secondary_Sylow Security_Protocol_Refinement Selection_Heap_Sort SenSocialChoice Separata Separation_Algebra Separation_Logic_Imperative_HOL Separation_Logic_Unbounded SequentInvertibility Shadow_DOM Shadow_SC_DOM Shivers-CFA ShortestPath Show Sigma_Commit_Crypto Signature_Groebner Simpl Simple_Firewall Simplex Simplicial_complexes_and_boolean_functions SimplifiedOntologicalArgument Skew_Heap Skip_Lists Slicing Sliding_Window_Algorithm Smith_Normal_Form Smooth_Manifolds Solidity Sophomores_Dream Sort_Encodings Source_Coding_Theorem SpecCheck Special_Function_Bounds Splay_Tree Sqrt_Babylonian Stable_Matching Stalnaker_Logic Statecharts Stateful_Protocol_Composition_and_Typing Stellar_Quorums Stern_Brocot Stewart_Apollonius Stirling_Formula Stochastic_Matrices Stone_Algebras Stone_Kleene_Relation_Algebras Stone_Relation_Algebras Store_Buffer_Reduction Stream-Fusion Stream_Fusion_Code StrictOmegaCategories Strong_Security Sturm_Sequences Sturm_Tarski Stuttering_Equivalence Subresultants Subset_Boolean_Algebras SumSquares Sunflowers SuperCalc Suppes_Theorem Surprise_Paradox Symmetric_Polynomials Syntax_Independent_Logic Synthetic_Completeness Szemeredi_Regularity Szpilrajn TESL_Language TLA Tail_Recursive_Functions Tarskis_Geometry Taylor_Models Three_Circles Timed_Automata Topological_Semantics Topology TortoiseHare Transcendence_Series_Hancl_Rucki Transformer_Semantics Transition_Systems_and_Automata Transitive-Closure Transitive-Closure-II Transitive_Models Treaps Tree-Automata Tree_Decomposition Triangle Trie Turans_Graph_Theorem Twelvefold_Way Tycon Types_Tableaus_and_Goedels_God Types_To_Sets_Extension UPF UPF_Firewall UTP Undirected_Graph_Theory Universal_Hash_Families Universal_Turing_Machine UpDown_Scheme VYDRA_MDL Valuation Van_Emde_Boas_Trees Van_der_Waerden VectorSpace VeriComp Verified-Prover Verified_SAT_Based_AI_Planning VerifyThis2018 VerifyThis2019 Vickrey_Clarke_Groves Virtual_Substitution VolpanoSmith WHATandWHERE_Security WOOT_Strong_Eventual_Consistency WebAssembly Weight_Balanced_Trees Weighted_Arithmetic_Geometric_Mean Weighted_Path_Order Well_Quasi_Orders Wetzels_Problem Winding_Number_Eval Word_Lib WorkerWrapper X86_Semantics XML Youngs_Inequality ZFC_in_HOL Zeta_3_Irrational Zeta_Function pGCL