src/HOL/Library/Omega_Words_Fun.thy
changeset 81142 6ad2c917dd2e
parent 76231 8a48e18f081e
equal deleted inserted replaced
81141:3e3e7a68cd80 81142:6ad2c917dd2e
    46 definition
    46 definition
    47   conc :: "['a list, 'a word] \<Rightarrow> 'a word"  (infixr \<open>\<frown>\<close> 65)
    47   conc :: "['a list, 'a word] \<Rightarrow> 'a word"  (infixr \<open>\<frown>\<close> 65)
    48   where "w \<frown> x == \<lambda>n. if n < length w then w!n else x (n - length w)"
    48   where "w \<frown> x == \<lambda>n. if n < length w then w!n else x (n - length w)"
    49 
    49 
    50 definition
    50 definition
    51   iter :: "'a list \<Rightarrow> 'a word"  (\<open>(_\<^sup>\<omega>)\<close> [1000])
    51   iter :: "'a list \<Rightarrow> 'a word"  (\<open>(\<open>notation=\<open>postfix \<omega>\<close>\<close>_\<^sup>\<omega>)\<close> [1000])
    52   where "iter w == if w = [] then undefined else (\<lambda>n. w!(n mod (length w)))"
    52   where "iter w == if w = [] then undefined else (\<lambda>n. w!(n mod (length w)))"
    53 
    53 
    54 lemma conc_empty[simp]: "[] \<frown> w = w"
    54 lemma conc_empty[simp]: "[] \<frown> w = w"
    55   unfolding conc_def by auto
    55   unfolding conc_def by auto
    56 
    56 
   114 subsection \<open>Subsequence, Prefix, and Suffix\<close>
   114 subsection \<open>Subsequence, Prefix, and Suffix\<close>
   115 
   115 
   116 definition suffix :: "[nat, 'a word] \<Rightarrow> 'a word"
   116 definition suffix :: "[nat, 'a word] \<Rightarrow> 'a word"
   117   where "suffix k x \<equiv> \<lambda>n. x (k+n)"
   117   where "suffix k x \<equiv> \<lambda>n. x (k+n)"
   118 
   118 
   119 definition subsequence :: "'a word \<Rightarrow> nat \<Rightarrow> nat \<Rightarrow> 'a list"  (\<open>_ [_ \<rightarrow> _]\<close> 900)
   119 definition subsequence :: "'a word \<Rightarrow> nat \<Rightarrow> nat \<Rightarrow> 'a list"
       
   120     (\<open>(\<open>open_block notation=\<open>mixfix subsequence\<close>\<close>_ [_ \<rightarrow> _])\<close> 900)
   120   where "subsequence w i j \<equiv> map w [i..<j]"
   121   where "subsequence w i j \<equiv> map w [i..<j]"
   121 
   122 
   122 abbreviation prefix :: "nat \<Rightarrow> 'a word \<Rightarrow> 'a list"
   123 abbreviation prefix :: "nat \<Rightarrow> 'a word \<Rightarrow> 'a list"
   123   where "prefix n w \<equiv> subsequence w 0 n"
   124   where "prefix n w \<equiv> subsequence w 0 n"
   124 
   125