Documentation
Projects
.
Util
.
Data
.
Word
.
Part_001
Search
return to top
source
Imports
Init
Projects.Util.Data.Word.Defs
Imported by
Word
.
coeList
Word
.
coeSeq
Word
.
append_def
Word
.
default_eq_nil
Word
.
get?_ofList
Word
.
get?_ofSeq
Word
.
eq_iff_get?
Word
.
take_ofList
Word
.
take_nil
Word
.
get?_nil
Word
.
finite_ofList
Word
.
infinite_ofSeq
Word
.
length?_ofList
Word
.
length?_ofSeq
Word
.
toList?_ofList
Word
.
toSeq?_ofSeq
Word
.
toList?_nil
Word
.
cycleList_nil
Word
.
cycle_nil
Word
.
ofList_nil
Word
.
ofList_cons
Word
.
toSeq?_ofList
Word
.
toList?_ofSeq
Word
.
cases_ofList
Word
.
cases_ofSeq
Word
.
Finite
.
exi_ofList
Word
.
Infinite
.
exi_ofSeq
Word
.
ofList_ne_ofSeq
Word
.
ofSeq_ne_ofList
Word
.
ofList_eq_ofList_iff
Word
.
ofSeq_eq_ofSeq_iff
Word
.
Finite
.
iff_ofList
Word
.
Infinite
.
iff_ofSeq
Word
.
exi_eq_ofList_or_ofSeq
Word
.
ind
Word
.
ind'
Word
.
append'_zero
Word
.
append'_succ_none
Word
.
append'_succ_some
Word
.
append'_ofList
Word
.
append'_ofSeq
Word
.
Infinite
.
append_left
Word
.
get?_append
Word
.
drop_ofList
Word
.
ofList_append
Word
.
ofList_append_ofList
Word
.
take_ofSeq
Word
.
Infinite
.
nonempty
Word
.
ofList_append_infinite
Word
.
drop_ofSeq
Word
.
not_infinite_ofList
Word
.
not_finite_ofSeq
Word
.
infinite_drop
Word
.
infinite_drop_iff
Word
.
get?_zero_cons
Word
.
get?_succ_cons
Word
.
get?_map
Word
.
map_ofList
Word
.
map_ofSeq
Word
.
map_nil
Word
.
map_cons
Word
.
get?_ofList_append_left
Word
.
get?_ofList_append_right
Word
.
get?_cycleList
Word
.
get?_cycle_ofList
Word
.
get?_append_ofSeq
Word
.
take_zero
Word
.
take_succ_cons
Word
.
length?_nil
Word
.
length?_eq_none_of_ofSeq
Word
.
length?_eq_none_iff_exi_seq
Word
.
length?_cons
Word
.
nil_append
Word
.
append_nil
Word
.
append_of_infinite_left
Word
.
infinite_cons
Word
.
cons_append
Word
.
take_length_ofList_append
Word
.
take_length_add_ofList_append
Word
.
cycle_of_infinite
Word
.
get?_cycle_zero
Word
.
length?_cycleList
Word
.
eq_nil_iff_get?_zero
Word
.
instDecidableEqNil
Word
.
instDecidableEqNil_1
Word
.
ofList_eq_nil_iff
Word
.
nil_eq_ofList_iff
Word
.
ne_nil_of_infinite
Word
.
nil_ne_of_infinite
Word
.
length?_cycle
Word
.
toList?_append_of_finite
Word
.
finite_nil
Word
.
finite_cons
Word
.
toList?_cons_of_finite
Word
.
cycleList_cons
Word
.
cycle_cons
Word
.
cycleList_step
Word
.
cycle_step
Word
.
take_length_cycleList
Word
.
take_length_cycle_ofList
Word
.
take_one_ofList_append_of_ne_nil
Word
.
append_assoc
Word
.
take_ofList_append_left
Word
.
take_ofList_append_right
Word
.
ofSeq_step
Word
.
cases'
Word
.
cons_ne_nil
Word
.
nil_ne_cons
Word
.
take_eq_nil_iff
Word
.
cycle_eq_nil_iff
Word
.
drop_zero
Word
.
length?_eq_some_iff
Word
.
drop_of_length_le'
Word
.
drop_nil
Word
.
tail_nil
Word
.
drop_succ_cons
Word
.
tail_cons
Word
.
length?_tail
Word
.
length?_eq_some_zero_off
Word
.
length?_eq_none_iff
Word
.
length?_ne_none_iff
Word
.
get
Word
.
head
Word
.
length
Word
.
get_zero_cons
Word
.
head_cons
Word
.
head_take
Word
.
length_nil
Word
.
length_cons
Word
.
length_eq_get_length?
Word
.
get_length?
Word
.
get?_isSome_iff_forall_length?
Word
.
get_eq_get_get?
Word
.
get_get?
Word
.
cycle_append
Word
.
length?_cycle_eq_some_iff
Word
.
some_eq_length?_cycle_iff
Word
.
length?_cycle_eq_none_iff
Word
.
none_eq_length?_cycle_iff
Word
.
length_cycle
Word
.
length_ofList
Word
.
get_cycle_of_finite_proof₁
Word
.
get_cycle_of_finite_proof₂
Word
.
get_cycle_of_finite
Word
.
head_cycle_of_finite
Word
.
head_cycle
Word
.
get_ofList
Word
.
head_ofList
Word
.
get?_ofList_append_length_add
Word
.
get?_ofList_append_length
Word
.
cons_inj
Word
.
append_eq_append_iff_right_of_finite
Word
.
append_nil'
Word
.
append_of_infinite_left'
Word
.
init_nil
Word
.
init_cons_nil
Word
.
init_cons_cons
Word
.
init_of_infinite
Word
.
init_append_cons
Word
.
init_ofList
Word
.
ofGet?Alt₁
Word
.
ofGet?_eq_alt₁
Word
.
get?_ofGet?
Word
.
get?_ofGet?_eq_none_iff
Word
.
get?_ofGet?_eq_some_iff
Word
.
flatten_nil
Word
.
flatten_cons_aux₁
Word
.
flatten_cons_aux₂
Word
.
flatten_cons_aux₃
Word
.
flatten_cons
Word
.
cycle_steps
Word
.
flatten_ofList_replicate_ofList
Word
.
eq_iff_step
Word
.
get_ofSeq
Word
.
getElem?_take_of_lt
Word
.
getElem_take_proof₁
Word
.
getElem_take
Word
.
ext_take
Word
.
length_take
Word
.
get?_eq_none_of_le
Word
.
get?_zero_eq_none_iff
Word
.
none_eq_get?_zero_iff
Word
.
take_eq_take_iff
Word
.
eq_of_take_imp_get?
Word
.
wordFun_ofList
Word
.
wordFun_ofSeq
Word
.
mem_def
Word
.
mem_ofList
Word
.
mem_ofSeq
Word
.
get?_eq_some_get_iff
Word
.
some_get_eq_get?_iff
Word
.
mem_iff_get?
Word
.
mem_iff_get
Word
.
not_mem_nil
Word
.
mem_cons_iff
Word
.
get?_append_eq_get?_append_of_right
Word
.
map_append
Word
.
get_succ_cons
Word
.
get?_ofList_append_eq_ite
Word
.
get?_drop
Word
.
get?_tail
Word
.
tail_ofSeq
Word
.
ofGet?_spec
Word
.
drop_add
Word
.
drop_add'
Word
.
take_drop
Word
.
take_add
Word
.
take_add'
Word
.
length_take_le
Word
.
le_length_take_iff_eq
Word
.
self_eq_length_take_iff
Word
.
length_take_eq_self_iff
Word
.
le_length_take_iff
Word
.
wf_batches'
Word
.
get?_batches
Word
.
batches_eq
Word
.
batches_ofList
Word
.
batches_ofSeq
Word
.
batches_zero
Word
.
batches_nil
Word
.
batches_of_length_lt
source
theorem
Word
.
coeList
{
α
:
Type
u_1}
{
xs
:
List
α
}
:
ofList
xs
=
ofList
xs
source
theorem
Word
.
coeSeq
{
α
:
Type
u_1}
{
a
:
ℕ
→
α
}
:
ofSeq
a
=
ofSeq
a
source
theorem
Word
.
append_def
{
α
:
Type
u_1}
{
xs
ys
:
Word
α
}
:
xs
++
ys
=
xs
.
append
ys
source
@[simp]
theorem
Word
.
default_eq_nil
{
α
:
Type
u_1}
:
default
=
nil
source
@[simp]
theorem
Word
.
get?_ofList
{
α
:
Type
u_1}
{
xs
:
List
α
}
{
i
:
ℕ
}
:
(
ofList
xs
)
.
get?
i
=
xs
[
i
]
?
source
@[simp]
theorem
Word
.
get?_ofSeq
{
α
:
Type
u_1}
{
a
:
ℕ
→
α
}
{
i
:
ℕ
}
:
(
ofSeq
a
)
.
get?
i
=
some
(
a
i
)
source
theorem
Word
.
eq_iff_get?
{
α
:
Type
u_1}
{
xs
ys
:
Word
α
}
:
xs
=
ys
↔
∀ (
i
:
ℕ
),
xs
.
get?
i
=
ys
.
get?
i
source
@[simp]
theorem
Word
.
take_ofList
{
α
:
Type
u_1}
{
xs
:
List
α
}
{
n
:
ℕ
}
:
take
n
(
ofList
xs
)
=
List.take
n
xs
source
@[simp]
theorem
Word
.
take_nil
{
α
:
Type
u_1}
{
n
:
ℕ
}
:
take
n
nil
=
[
]
source
@[simp]
theorem
Word
.
get?_nil
{
α
:
Type
u_1}
{
i
:
ℕ
}
:
nil
.
get?
i
=
none
source
@[simp]
instance
Word
.
finite_ofList
{
α
:
Type
u_1}
{
xs
:
List
α
}
:
(
ofList
xs
)
.
Finite
source
@[simp]
instance
Word
.
infinite_ofSeq
{
α
:
Type
u_1}
{
a
:
ℕ
→
α
}
:
(
ofSeq
a
)
.
Infinite
source
@[simp]
theorem
Word
.
length?_ofList
{
α
:
Type
u_1}
{
xs
:
List
α
}
:
(
ofList
xs
)
.
length?
=
some
xs
.
length
source
@[simp]
theorem
Word
.
length?_ofSeq
{
α
:
Type
u_1}
{
a
:
ℕ
→
α
}
:
(
ofSeq
a
)
.
length?
=
none
source
@[simp]
theorem
Word
.
toList?_ofList
{
α
:
Type
u_1}
{
xs
:
List
α
}
:
(
ofList
xs
)
.
toList?
=
some
xs
source
@[simp]
theorem
Word
.
toSeq?_ofSeq
{
α
:
Type
u_1}
{
a
:
ℕ
→
α
}
:
(
ofSeq
a
)
.
toSeq?
=
some
a
source
@[simp]
theorem
Word
.
toList?_nil
{
α
:
Type
u_1}
:
nil
.
toList?
=
some
[
]
source
@[simp]
theorem
Word
.
cycleList_nil
{
α
:
Type
u_1}
:
cycleList
[
]
=
nil
source
@[simp]
theorem
Word
.
cycle_nil
{
α
:
Type
u_1}
:
nil
.
cycle
=
nil
source
@[simp]
theorem
Word
.
ofList_nil
{
α
:
Type
u_1}
:
ofList
[
]
=
nil
source
@[simp]
theorem
Word
.
ofList_cons
{
α
:
Type
u_1}
{
x
:
α
}
{
xs
:
List
α
}
:
ofList
(
x
::
xs
)
=
cons
x
(
ofList
xs
)
source
@[simp]
theorem
Word
.
toSeq?_ofList
{
α
:
Type
u_1}
{
xs
:
List
α
}
:
(
ofList
xs
)
.
toSeq?
=
none
source
@[simp]
theorem
Word
.
toList?_ofSeq
{
α
:
Type
u_1}
{
a
:
ℕ
→
α
}
:
(
ofSeq
a
)
.
toList?
=
none
source
@[simp]
theorem
Word
.
cases_ofList
{
α
:
Type
u_1}
{
xs
:
List
α
}
:
(
ofList
xs
)
.
cases
=
Sum.inl
xs
source
@[simp]
theorem
Word
.
cases_ofSeq
{
α
:
Type
u_1}
{
a
:
ℕ
→
α
}
:
(
ofSeq
a
)
.
cases
=
Sum.inr
a
source
theorem
Word
.
Finite
.
exi_ofList
{
α
:
Type
u_1}
{
xs
:
Word
α
}
[
h
:
xs
.
Finite
]
:
∃ (
ys
:
List
α
),
xs
=
ofList
ys
source
theorem
Word
.
Infinite
.
exi_ofSeq
{
α
:
Type
u_1}
{
xs
:
Word
α
}
[
h
:
xs
.
Infinite
]
:
∃ (
a
:
ℕ
→
α
),
xs
=
ofSeq
a
source
@[simp]
theorem
Word
.
ofList_ne_ofSeq
{
α
:
Type
u_1}
{
xs
:
List
α
}
{
a
:
ℕ
→
α
}
:
ofList
xs
≠
ofSeq
a
source
@[simp]
theorem
Word
.
ofSeq_ne_ofList
{
α
:
Type
u_1}
{
xs
:
List
α
}
{
a
:
ℕ
→
α
}
:
ofSeq
a
≠
ofList
xs
source
@[simp]
theorem
Word
.
ofList_eq_ofList_iff
{
α
:
Type
u_1}
{
xs
ys
:
List
α
}
:
ofList
xs
=
ofList
ys
↔
xs
=
ys
source
@[simp]
theorem
Word
.
ofSeq_eq_ofSeq_iff
{
α
:
Type
u_1}
{
a
b
:
ℕ
→
α
}
:
ofSeq
a
=
ofSeq
b
↔
a
=
b
source
theorem
Word
.
Finite
.
iff_ofList
{
α
:
Type
u_1}
{
xs
:
Word
α
}
:
xs
.
Finite
↔
∃ (
ys
:
List
α
),
xs
=
ofList
ys
source
theorem
Word
.
Infinite
.
iff_ofSeq
{
α
:
Type
u_1}
{
xs
:
Word
α
}
:
xs
.
Infinite
↔
∃ (
a
:
ℕ
→
α
),
xs
=
ofSeq
a
source
theorem
Word
.
exi_eq_ofList_or_ofSeq
{
α
:
Type
u_1}
{
xs
:
Word
α
}
:
(∃ (
ys
:
List
α
),
xs
=
ofList
ys
)
∨
∃ (
a
:
ℕ
→
α
),
xs
=
ofSeq
a
source
theorem
Word
.
ind
{
α
:
Type
u_1}
{
p
:
Word
α
→
Prop
}
(
h₁
:
∀ (
xs
:
List
α
),
p
(
ofList
xs
)
)
(
h₂
:
∀ (
a
:
ℕ
→
α
),
p
(
ofSeq
a
)
)
(
xs
:
Word
α
)
:
p
xs
source
theorem
Word
.
ind'
{
α
:
Type
u_1}
{
p
:
Word
α
→
Prop
}
(
h₁
:
∀ (
a
:
ℕ
→
α
),
p
(
ofSeq
a
)
)
(
h₂
:
∀ (
xs
:
List
α
),
p
(
ofList
xs
)
)
(
xs
:
Word
α
)
:
p
xs
source
@[simp]
theorem
Word
.
append'_zero
{
α
:
Type
u_1}
{
f
g
:
ℕ
→
Option
α
}
:
append'
f
g
0
=
(
f
0
)
.
or
(
g
0
)
source
theorem
Word
.
append'_succ_none
{
α
:
Type
u_1}
{
f
g
:
ℕ
→
Option
α
}
{
i
:
ℕ
}
(
h
:
f
0
=
none
)
:
append'
f
g
(
i
+
1
)
=
g
(
i
+
1
)
source
theorem
Word
.
append'_succ_some
{
α
:
Type
u_1}
{
f
g
:
ℕ
→
Option
α
}
{
i
:
ℕ
}
{
x
:
α
}
(
h
:
f
0
=
some
x
)
:
append'
f
g
(
i
+
1
)
=
append'
(fun (
x
:
ℕ
) =>
f
(
x
+
1
)
)
g
i
source
@[simp]
theorem
Word
.
append'_ofList
{
α
:
Type
u_1}
{
xs
:
List
α
}
{
g
:
ℕ
→
Option
α
}
{
i
:
ℕ
}
:
append'
(
ofList
xs
)
.
get?
g
i
=
if
i
<
xs
.
length
then
xs
[
i
]
?
else
g
(
i
-
xs
.
length
)
source
@[simp]
theorem
Word
.
append'_ofSeq
{
α
:
Type
u_1}
{
a
:
ℕ
→
α
}
{
g
:
ℕ
→
Option
α
}
{
i
:
ℕ
}
:
append'
(
ofSeq
a
)
.
get?
g
i
=
some
(
a
i
)
source
@[simp]
theorem
Word
.
Infinite
.
append_left
{
α
:
Type
u_1}
{
xs
ys
:
Word
α
}
[
h
:
xs
.
Infinite
]
:
xs
++
ys
=
xs
source
theorem
Word
.
get?_append
{
α
:
Type
u_1}
{
xs
ys
:
Word
α
}
{
i
:
ℕ
}
:
(
xs
++
ys
).
get?
i
=
match
xs
.
length?
with |
none
=>
xs
.
get?
i
|
some
n
=>
if
i
<
n
then
xs
.
get?
i
else
ys
.
get?
(
i
-
n
)
source
@[simp]
theorem
Word
.
drop_ofList
{
α
:
Type
u_1}
{
xs
:
List
α
}
{
n
:
ℕ
}
:
drop
n
(
ofList
xs
)
=
ofList
(
List.drop
n
xs
)
source
theorem
Word
.
ofList_append
{
α
:
Type
u_1}
{
xs
ys
:
List
α
}
:
ofList
(
xs
++
ys
)
=
ofList
xs
++
ofList
ys
source
@[simp]
theorem
Word
.
ofList_append_ofList
{
α
:
Type
u_1}
{
xs
ys
:
List
α
}
:
ofList
xs
++
ofList
ys
=
ofList
(
xs
++
ys
)
source
@[simp]
theorem
Word
.
take_ofSeq
{
α
:
Type
u_1}
{
a
:
ℕ
→
α
}
{
n
:
ℕ
}
:
take
n
(
ofSeq
a
)
=
mkList
n
a
source
theorem
Word
.
Infinite
.
nonempty
{
α
:
Type
u_1}
{
xs
:
Word
α
}
[
h
:
xs
.
Infinite
]
:
Nonempty
α
source
theorem
Word
.
ofList_append_infinite
{
α
:
Type
u_1}
{
ys
:
Word
α
}
{
xs
:
List
α
}
[
h
:
ys
.
Infinite
]
{
i
:
ℕ
}
:
(
ofList
xs
++
ys
).
get?
i
=
if
i
<
xs
.
length
then
xs
[
i
]
?
else
ys
.
get?
(
i
-
xs
.
length
)
source
@[simp]
theorem
Word
.
drop_ofSeq
{
α
:
Type
u_1}
{
a
:
ℕ
→
α
}
{
n
:
ℕ
}
:
drop
n
(
ofSeq
a
)
=
ofSeq
fun (
x
:
ℕ
) =>
a
(
x
+
n
)
source
@[simp]
theorem
Word
.
not_infinite_ofList
{
α
:
Type
u_1}
{
xs
:
List
α
}
:
¬
(
ofList
xs
)
.
Infinite
source
@[simp]
theorem
Word
.
not_finite_ofSeq
{
α
:
Type
u_1}
{
a
:
ℕ
→
α
}
:
¬
(
ofSeq
a
)
.
Finite
source
instance
Word
.
infinite_drop
{
α
:
Type
u_1}
{
xs
:
Word
α
}
[
h
:
xs
.
Infinite
]
{
n
:
ℕ
}
:
(
drop
n
xs
)
.
Infinite
source
@[simp]
theorem
Word
.
infinite_drop_iff
{
α
:
Type
u_1}
{
xs
:
Word
α
}
{
n
:
ℕ
}
:
(
drop
n
xs
)
.
Infinite
↔
xs
.
Infinite
source
@[simp]
theorem
Word
.
get?_zero_cons
{
α
:
Type
u_1}
{
xs
:
Word
α
}
{
x
:
α
}
:
(
cons
x
xs
)
.
get?
0
=
some
x
source
@[simp]
theorem
Word
.
get?_succ_cons
{
α
:
Type
u_1}
{
xs
:
Word
α
}
{
x
:
α
}
{
i
:
ℕ
}
:
(
cons
x
xs
)
.
get?
(
i
+
1
)
=
xs
.
get?
i
source
@[simp]
theorem
Word
.
get?_map
{
α
:
Type
u_1}
{
β
:
Type
u_2}
{
xs
:
Word
α
}
{
f
:
α
→
β
}
{
i
:
ℕ
}
:
(
map
f
xs
)
.
get?
i
=
Option.map
f
(
xs
.
get?
i
)
source
@[simp]
theorem
Word
.
map_ofList
{
α
:
Type
u_1}
{
β
:
Type
u_2}
{
xs
:
List
α
}
{
f
:
α
→
β
}
:
map
f
(
ofList
xs
)
=
ofList
(
List.map
f
xs
)
source
@[simp]
theorem
Word
.
map_ofSeq
{
α
:
Type
u_1}
{
β
:
Type
u_2}
{
a
:
ℕ
→
α
}
{
f
:
α
→
β
}
:
map
f
(
ofSeq
a
)
=
ofSeq
fun (
x
:
ℕ
) =>
f
(
a
x
)
source
@[simp]
theorem
Word
.
map_nil
{
α
:
Type
u_1}
{
β
:
Type
u_2}
{
f
:
α
→
β
}
:
map
f
nil
=
nil
source
@[simp]
theorem
Word
.
map_cons
{
α
:
Type
u_1}
{
β
:
Type
u_2}
{
xs
:
Word
α
}
{
f
:
α
→
β
}
{
x
:
α
}
:
map
f
(
cons
x
xs
)
=
cons
(
f
x
)
(
map
f
xs
)
source
theorem
Word
.
get?_ofList_append_left
{
α
:
Type
u_1}
{
ys
:
Word
α
}
{
xs
:
List
α
}
{
i
:
ℕ
}
(
h
:
i
<
xs
.
length
)
:
(
ofList
xs
++
ys
).
get?
i
=
some
xs
[
i
]
source
theorem
Word
.
get?_ofList_append_right
{
α
:
Type
u_1}
{
ys
:
Word
α
}
{
xs
:
List
α
}
{
i
:
ℕ
}
(
h
:
xs
.
length
≤
i
)
:
(
ofList
xs
++
ys
).
get?
i
=
ys
.
get?
(
i
-
xs
.
length
)
source
@[simp]
theorem
Word
.
get?_cycleList
{
α
:
Type
u_1}
{
xs
:
List
α
}
{
i
:
ℕ
}
:
(
cycleList
xs
)
.
get?
i
=
xs
[
i
%
xs
.
length
]
?
source
@[simp]
theorem
Word
.
get?_cycle_ofList
{
α
:
Type
u_1}
{
xs
:
List
α
}
{
i
:
ℕ
}
:
(
ofList
xs
)
.
cycle
.
get?
i
=
xs
[
i
%
xs
.
length
]
?
source
@[simp]
theorem
Word
.
get?_append_ofSeq
{
α
:
Type
u_1}
{
xs
:
Word
α
}
{
a
:
ℕ
→
α
}
{
i
:
ℕ
}
:
(
ofSeq
a
++
xs
).
get?
i
=
some
(
a
i
)
source
@[simp]
theorem
Word
.
take_zero
{
α
:
Type
u_1}
{
xs
:
Word
α
}
:
take
0
xs
=
[
]
source
@[simp]
theorem
Word
.
take_succ_cons
{
α
:
Type
u_1}
{
xs
:
Word
α
}
{
x
:
α
}
{
n
:
ℕ
}
:
take
(
n
+
1
)
(
cons
x
xs
)
=
x
::
take
n
xs
source
@[simp]
theorem
Word
.
length?_nil
{
α
:
Type
u_1}
:
nil
.
length?
=
some
0
source
theorem
Word
.
length?_eq_none_of_ofSeq
{
α
:
Type
u_1}
{
xs
:
Word
α
}
(
a
:
ℕ
→
α
)
(
h
:
ofSeq
a
=
xs
)
:
xs
.
length?
=
none
source
theorem
Word
.
length?_eq_none_iff_exi_seq
{
α
:
Type
u_1}
{
xs
:
Word
α
}
:
xs
.
length?
=
none
↔
∃ (
a
:
ℕ
→
α
),
ofSeq
a
=
xs
source
@[simp]
theorem
Word
.
length?_cons
{
α
:
Type
u_1}
{
xs
:
Word
α
}
{
x
:
α
}
:
(
cons
x
xs
)
.
length?
=
Option.map
(fun (
x
:
ℕ
) =>
x
+
1
)
xs
.
length?
source
@[simp]
theorem
Word
.
nil_append
{
α
:
Type
u_1}
{
xs
:
Word
α
}
:
nil
++
xs
=
xs
source
@[simp]
theorem
Word
.
append_nil
{
α
:
Type
u_1}
{
xs
:
Word
α
}
:
xs
++
nil
=
xs
source
@[simp]
theorem
Word
.
append_of_infinite_left
{
α
:
Type
u_1}
{
xs
ys
:
Word
α
}
[
h
:
xs
.
Infinite
]
:
xs
++
ys
=
xs
source
instance
Word
.
infinite_cons
{
α
:
Type
u_1}
{
xs
:
Word
α
}
[
h
:
xs
.
Infinite
]
{
x
:
α
}
:
(
cons
x
xs
)
.
Infinite
source
@[simp]
theorem
Word
.
cons_append
{
α
:
Type
u_1}
{
xs
ys
:
Word
α
}
{
x
:
α
}
:
cons
x
xs
++
ys
=
cons
x
(
xs
++
ys
)
source
@[simp]
theorem
Word
.
take_length_ofList_append
{
α
:
Type
u_1}
{
ys
:
Word
α
}
{
xs
:
List
α
}
:
take
xs
.
length
(
ofList
xs
++
ys
)
=
xs
source
@[simp]
theorem
Word
.
take_length_add_ofList_append
{
α
:
Type
u_1}
{
ys
:
Word
α
}
{
xs
:
List
α
}
{
n
:
ℕ
}
:
take
(
xs
.
length
+
n
) (
ofList
xs
++
ys
)
=
xs
++
take
n
ys
source
@[simp]
theorem
Word
.
cycle_of_infinite
{
α
:
Type
u_1}
{
xs
:
Word
α
}
[
h
:
xs
.
Infinite
]
:
xs
.
cycle
=
xs
source
@[simp]
theorem
Word
.
get?_cycle_zero
{
α
:
Type
u_1}
{
xs
:
Word
α
}
:
xs
.
cycle
.
get?
0
=
xs
.
get?
0
source
theorem
Word
.
length?_cycleList
{
α
:
Type
u_1}
{
xs
:
List
α
}
:
(
cycleList
xs
)
.
length?
=
if
xs
=
[
]
then
some
0
else
none
source
theorem
Word
.
eq_nil_iff_get?_zero
{
α
:
Type
u_1}
{
xs
:
Word
α
}
:
xs
=
nil
↔
xs
.
get?
0
=
none
source
@[instance_reducible]
instance
Word
.
instDecidableEqNil
{
α
:
Type
u_1}
{
xs
:
Word
α
}
:
Decidable
(
xs
=
nil
)
Equations
Word.instDecidableEqNil
=
⋯
.
mpr
inferInstance
source
@[instance_reducible]
instance
Word
.
instDecidableEqNil_1
{
α
:
Type
u_1}
{
xs
:
Word
α
}
:
Decidable
(
nil
=
xs
)
Equations
Word.instDecidableEqNil_1
=
⋯
.
mpr
inferInstance
source
@[simp]
theorem
Word
.
ofList_eq_nil_iff
{
α
:
Type
u_1}
{
xs
:
List
α
}
:
ofList
xs
=
nil
↔
xs
=
[
]
source
@[simp]
theorem
Word
.
nil_eq_ofList_iff
{
α
:
Type
u_1}
{
xs
:
List
α
}
:
nil
=
ofList
xs
↔
xs
=
[
]
source
@[simp]
theorem
Word
.
ne_nil_of_infinite
{
α
:
Type
u_1}
{
xs
:
Word
α
}
[
h
:
xs
.
Infinite
]
:
xs
≠
nil
source
@[simp]
theorem
Word
.
nil_ne_of_infinite
{
α
:
Type
u_1}
{
xs
:
Word
α
}
[
h
:
xs
.
Infinite
]
:
nil
≠
xs
source
theorem
Word
.
length?_cycle
{
α
:
Type
u_1}
{
xs
:
Word
α
}
:
xs
.
cycle
.
length?
=
if
xs
=
nil
then
some
0
else
none
source
@[simp]
theorem
Word
.
toList?_append_of_finite
{
α
:
Type
u_1}
{
xs
ys
:
Word
α
}
[
h₁
:
xs
.
Finite
]
[
h₂
:
ys
.
Finite
]
:
(
xs
++
ys
).
toList?
=
some
(
xs
.
toList?
.
getd
++
ys
.
toList?
.
getd
)
source
@[simp]
instance
Word
.
finite_nil
{
α
:
Type
u_1}
:
nil
.
Finite
source
instance
Word
.
finite_cons
{
α
:
Type
u_1}
{
xs
:
Word
α
}
{
x
:
α
}
[
h
:
xs
.
Finite
]
:
(
cons
x
xs
)
.
Finite
source
@[simp]
theorem
Word
.
toList?_cons_of_finite
{
α
:
Type
u_1}
{
xs
:
Word
α
}
{
x
:
α
}
[
h
:
xs
.
Finite
]
:
(
cons
x
xs
)
.
toList?
=
some
(
x
::
xs
.
toList?
.
getd
)
source
theorem
Word
.
cycleList_cons
{
α
:
Type
u_1}
{
xs
:
List
α
}
{
x
:
α
}
:
cycleList
(
x
::
xs
)
=
cons
x
(
cycleList
(
xs
++
[
x
]
))
source
theorem
Word
.
cycle_cons
{
α
:
Type
u_1}
{
xs
:
Word
α
}
{
x
:
α
}
:
(
cons
x
xs
)
.
cycle
=
cons
x
(
xs
++
ofList
[
x
]
).
cycle
source
theorem
Word
.
cycleList_step
{
α
:
Type
u_1}
{
xs
:
List
α
}
:
cycleList
xs
=
ofList
xs
++
cycleList
xs
source
theorem
Word
.
cycle_step
{
α
:
Type
u_1}
{
xs
:
Word
α
}
:
xs
.
cycle
=
xs
++
xs
.
cycle
source
@[simp]
theorem
Word
.
take_length_cycleList
{
α
:
Type
u_1}
{
xs
:
List
α
}
:
take
xs
.
length
(
cycleList
xs
)
=
xs
source
@[simp]
theorem
Word
.
take_length_cycle_ofList
{
α
:
Type
u_1}
{
xs
:
List
α
}
:
take
xs
.
length
(
ofList
xs
)
.
cycle
=
xs
source
theorem
Word
.
take_one_ofList_append_of_ne_nil
{
α
:
Type
u_1}
{
ys
:
Word
α
}
{
xs
:
List
α
}
(
h
:
xs
≠
[
]
)
:
take
1
(
ofList
xs
++
ys
)
=
[
xs
.
head
h
]
source
theorem
Word
.
append_assoc
{
α
:
Type
u_1}
{
xs
ys
zs
:
Word
α
}
:
xs
++
ys
++
zs
=
xs
++
(
ys
++
zs
)
source
theorem
Word
.
take_ofList_append_left
{
α
:
Type
u_1}
{
ys
:
Word
α
}
{
xs
:
List
α
}
{
n
:
ℕ
}
(
h
:
n
≤
xs
.
length
)
:
take
n
(
ofList
xs
++
ys
)
=
List.take
n
xs
source
theorem
Word
.
take_ofList_append_right
{
α
:
Type
u_1}
{
ys
:
Word
α
}
{
xs
:
List
α
}
{
n
:
ℕ
}
(
h
:
xs
.
length
≤
n
)
:
take
n
(
ofList
xs
++
ys
)
=
xs
++
take
(
n
-
xs
.
length
)
ys
source
theorem
Word
.
ofSeq_step
{
α
:
Type
u_1}
{
a
:
ℕ
→
α
}
:
ofSeq
a
=
cons
(
a
0
)
(
ofSeq
fun (
x
:
ℕ
) =>
a
(
x
+
1
)
)
source
theorem
Word
.
cases'
{
α
:
Type
u_1}
{
p
:
Word
α
→
Prop
}
(
h₁
:
p
nil
)
(
h₂
:
∀ (
x
:
α
) (
xs
:
Word
α
),
p
(
cons
x
xs
)
)
(
xs
:
Word
α
)
:
p
xs
source
@[simp]
theorem
Word
.
cons_ne_nil
{
α
:
Type
u_1}
{
xs
:
Word
α
}
{
x
:
α
}
:
cons
x
xs
≠
nil
source
@[simp]
theorem
Word
.
nil_ne_cons
{
α
:
Type
u_1}
{
xs
:
Word
α
}
{
x
:
α
}
:
nil
≠
cons
x
xs
source
@[simp]
theorem
Word
.
take_eq_nil_iff
{
α
:
Type
u_1}
{
xs
:
Word
α
}
{
n
:
ℕ
}
:
take
n
xs
=
[
]
↔
xs
=
nil
∨
n
=
0
source
@[simp]
theorem
Word
.
cycle_eq_nil_iff
{
α
:
Type
u_1}
{
xs
:
Word
α
}
:
xs
.
cycle
=
nil
↔
xs
=
nil
source
@[simp]
theorem
Word
.
drop_zero
{
α
:
Type
u_1}
{
xs
:
Word
α
}
:
drop
0
xs
=
xs
source
theorem
Word
.
length?_eq_some_iff
{
α
:
Type
u_1}
{
xs
:
Word
α
}
{
n
:
ℕ
}
:
xs
.
length?
=
some
n
↔
∃ (
ys
:
List
α
),
ys
.
length
=
n
∧
ofList
ys
=
xs
source
theorem
Word
.
drop_of_length_le'
{
α
:
Type
u_1}
{
xs
:
Word
α
}
{
n
:
ℕ
}
(
h
:
∃ (
k
:
ℕ
),
xs
.
length?
=
some
k
∧
k
≤
n
)
:
drop
n
xs
=
nil
source
@[simp]
theorem
Word
.
drop_nil
{
α
:
Type
u_1}
{
n
:
ℕ
}
:
drop
n
nil
=
nil
source
@[simp]
theorem
Word
.
tail_nil
{
α
:
Type
u_1}
:
nil
.
tail
=
nil
source
@[simp]
theorem
Word
.
drop_succ_cons
{
α
:
Type
u_1}
{
xs
:
Word
α
}
{
x
:
α
}
{
n
:
ℕ
}
:
drop
(
n
+
1
)
(
cons
x
xs
)
=
drop
n
xs
source
@[simp]
theorem
Word
.
tail_cons
{
α
:
Type
u_1}
{
xs
:
Word
α
}
{
x
:
α
}
:
(
cons
x
xs
)
.
tail
=
xs
source
theorem
Word
.
length?_tail
{
α
:
Type
u_1}
{
xs
:
Word
α
}
:
xs
.
tail
.
length?
=
Option.map
(fun (
x
:
ℕ
) =>
x
-
1
)
xs
.
length?
source
@[simp]
theorem
Word
.
length?_eq_some_zero_off
{
α
:
Type
u_1}
{
xs
:
Word
α
}
:
xs
.
length?
=
some
0
↔
xs
=
nil
source
theorem
Word
.
length?_eq_none_iff
{
α
:
Type
u_1}
{
xs
:
Word
α
}
:
xs
.
length?
=
none
↔
∃ (
a
:
ℕ
→
α
),
ofSeq
a
=
xs
source
theorem
Word
.
length?_ne_none_iff
{
α
:
Type
u_1}
{
xs
:
Word
α
}
:
xs
.
length?
≠
none
↔
∃ (
ys
:
List
α
),
ofList
ys
=
xs
source
def
Word
.
get
{
α
:
Type
u_1}
(
xs
:
Word
α
)
(
i
:
ℕ
)
(
h
:
∀ (
n
:
ℕ
),
xs
.
length?
=
some
n
→
i
<
n
)
:
α
Equations
xs
.
get
i
h
=
(
xs
.
get?
i
)
.
get
⋯
Instances For
source
def
Word
.
head
{
α
:
Type
u_1}
(
xs
:
Word
α
)
(
h
:
xs
≠
nil
)
:
α
Equations
xs
.
head
h
=
xs
.
get
0
⋯
Instances For
source
@[irreducible]
def
Word
.
length
{
α
:
Type
u_1}
(
xs
:
Word
α
)
(
h
:
xs
.
length?
≠
none
)
:
ℕ
Equations
xs
.
length
h
=
if
xs
=
Word.nil
then
0
else
xs
.
tail
.
length
⋯
+
1
Instances For
source
@[simp]
theorem
Word
.
get_zero_cons
{
α
:
Type
u_1}
{
xs
:
Word
α
}
{
x
:
α
}
{
h
:
∀ (
n
:
ℕ
),
(
cons
x
xs
)
.
length?
=
some
n
→
0
<
n
}
:
(
cons
x
xs
)
.
get
0
h
=
x
source
@[simp]
theorem
Word
.
head_cons
{
α
:
Type
u_1}
{
xs
:
Word
α
}
{
x
:
α
}
{
h
:
cons
x
xs
≠
nil
}
:
(
cons
x
xs
)
.
head
h
=
x
source
@[simp]
theorem
Word
.
head_take
{
α
:
Type
u_1}
{
xs
:
Word
α
}
{
n
:
ℕ
}
{
h
:
take
n
xs
≠
[
]
}
:
(
take
n
xs
)
.
head
h
=
xs
.
head
⋯
source
@[simp]
theorem
Word
.
length_nil
{
α
:
Type
u_1}
{
h
:
nil
.
length?
≠
none
}
:
nil
.
length
h
=
0
source
@[simp]
theorem
Word
.
length_cons
{
α
:
Type
u_1}
{
xs
:
Word
α
}
{
x
:
α
}
{
h
:
(
cons
x
xs
)
.
length?
≠
none
}
:
(
cons
x
xs
)
.
length
h
=
xs
.
length
⋯
+
1
source
theorem
Word
.
length_eq_get_length?
{
α
:
Type
u_1}
{
xs
:
Word
α
}
{
h
:
xs
.
length?
≠
none
}
:
xs
.
length
h
=
xs
.
length?
.
get
⋯
source
theorem
Word
.
get_length?
{
α
:
Type
u_1}
{
xs
:
Word
α
}
{
h
:
xs
.
length?
.
isSome
=
true
}
:
xs
.
length?
.
get
h
=
xs
.
length
⋯
source
theorem
Word
.
get?_isSome_iff_forall_length?
{
α
:
Type
u_1}
{
xs
:
Word
α
}
{
i
:
ℕ
}
:
(
xs
.
get?
i
)
.
isSome
=
true
↔
∀ (
n
:
ℕ
),
xs
.
length?
=
some
n
→
i
<
n
source
theorem
Word
.
get_eq_get_get?
{
α
:
Type
u_1}
{
xs
:
Word
α
}
{
i
:
ℕ
}
{
h
:
∀ (
n
:
ℕ
),
xs
.
length?
=
some
n
→
i
<
n
}
:
xs
.
get
i
h
=
(
xs
.
get?
i
)
.
get
⋯
source
theorem
Word
.
get_get?
{
α
:
Type
u_1}
{
xs
:
Word
α
}
{
i
:
ℕ
}
{
h
:
(
xs
.
get?
i
)
.
isSome
=
true
}
:
(
xs
.
get?
i
)
.
get
h
=
xs
.
get
i
⋯
source
theorem
Word
.
cycle_append
{
α
:
Type
u_1}
{
xs
ys
:
Word
α
}
:
(
xs
++
ys
).
cycle
=
xs
++
(
ys
++
xs
).
cycle
source
@[simp]
theorem
Word
.
length?_cycle_eq_some_iff
{
α
:
Type
u_1}
{
xs
:
Word
α
}
{
n
:
ℕ
}
:
xs
.
cycle
.
length?
=
some
n
↔
xs
=
nil
∧
n
=
0
source
@[simp]
theorem
Word
.
some_eq_length?_cycle_iff
{
α
:
Type
u_1}
{
xs
:
Word
α
}
{
n
:
ℕ
}
:
some
n
=
xs
.
cycle
.
length?
↔
xs
=
nil
∧
n
=
0
source
@[simp]
theorem
Word
.
length?_cycle_eq_none_iff
{
α
:
Type
u_1}
{
xs
:
Word
α
}
:
xs
.
cycle
.
length?
=
none
↔
xs
≠
nil
source
@[simp]
theorem
Word
.
none_eq_length?_cycle_iff
{
α
:
Type
u_1}
{
xs
:
Word
α
}
:
none
=
xs
.
cycle
.
length?
↔
xs
≠
nil
source
@[simp]
theorem
Word
.
length_cycle
{
α
:
Type
u_1}
{
xs
:
Word
α
}
{
h
:
xs
.
cycle
.
length?
≠
none
}
:
xs
.
cycle
.
length
h
=
0
source
@[simp]
theorem
Word
.
length_ofList
{
α
:
Type
u_1}
{
xs
:
List
α
}
{
h
:
(
ofList
xs
)
.
length?
≠
none
}
:
(
ofList
xs
)
.
length
h
=
xs
.
length
source
theorem
Word
.
get_cycle_of_finite_proof₁
{
α
:
Type
u_1}
{
xs
:
Word
α
}
[
H
:
xs
.
Finite
]
{
i
:
ℕ
}
(
h
:
∀ (
n
:
ℕ
),
xs
.
cycle
.
length?
=
some
n
→
i
<
n
)
:
xs
.
length?
≠
none
source
theorem
Word
.
get_cycle_of_finite_proof₂
{
α
:
Type
u_1}
{
xs
:
Word
α
}
[
H
:
xs
.
Finite
]
{
i
:
ℕ
}
(
h
:
∀ (
n
:
ℕ
),
xs
.
cycle
.
length?
=
some
n
→
i
<
n
)
(
n
:
ℕ
)
:
xs
.
length?
=
some
n
→
i
%
xs
.
length
⋯
<
n
source
@[simp]
theorem
Word
.
get_cycle_of_finite
{
α
:
Type
u_1}
{
xs
:
Word
α
}
[
H
:
xs
.
Finite
]
{
i
:
ℕ
}
{
h
:
∀ (
n
:
ℕ
),
xs
.
cycle
.
length?
=
some
n
→
i
<
n
}
:
xs
.
cycle
.
get
i
h
=
xs
.
get
(
i
%
xs
.
length
⋯
)
⋯
source
@[simp]
theorem
Word
.
head_cycle_of_finite
{
α
:
Type
u_1}
{
xs
:
Word
α
}
[
H
:
xs
.
Finite
]
{
h
:
xs
.
cycle
≠
nil
}
:
xs
.
cycle
.
head
h
=
xs
.
head
⋯
source
@[simp]
theorem
Word
.
head_cycle
{
α
:
Type
u_1}
{
xs
:
Word
α
}
{
h
:
xs
.
cycle
≠
nil
}
:
xs
.
cycle
.
head
h
=
xs
.
head
⋯
source
@[simp]
theorem
Word
.
get_ofList
{
α
:
Type
u_1}
{
xs
:
List
α
}
{
i
:
ℕ
}
{
h
:
∀ (
n
:
ℕ
),
(
ofList
xs
)
.
length?
=
some
n
→
i
<
n
}
:
(
ofList
xs
)
.
get
i
h
=
xs
[
i
]
source
@[simp]
theorem
Word
.
head_ofList
{
α
:
Type
u_1}
{
xs
:
List
α
}
{
h
:
ofList
xs
≠
nil
}
:
(
ofList
xs
)
.
head
h
=
xs
.
head
⋯
source
@[simp]
theorem
Word
.
get?_ofList_append_length_add
{
α
:
Type
u_1}
{
ys
:
Word
α
}
{
xs
:
List
α
}
{
i
:
ℕ
}
:
(
ofList
xs
++
ys
).
get?
(
xs
.
length
+
i
)
=
ys
.
get?
i
source
@[simp]
theorem
Word
.
get?_ofList_append_length
{
α
:
Type
u_1}
{
ys
:
Word
α
}
{
xs
:
List
α
}
:
(
ofList
xs
++
ys
).
get?
xs
.
length
=
ys
.
get?
0
source
@[simp]
theorem
Word
.
cons_inj
{
α
:
Type
u_1}
{
xs
ys
:
Word
α
}
{
x
y
:
α
}
:
cons
x
xs
=
cons
y
ys
↔
x
=
y
∧
xs
=
ys
source
@[simp]
theorem
Word
.
append_eq_append_iff_right_of_finite
{
α
:
Type
u_1}
{
xs
ys
zs
:
Word
α
}
[
H
:
xs
.
Finite
]
:
xs
++
ys
=
xs
++
zs
↔
ys
=
zs
source
@[simp]
theorem
Word
.
append_nil'
{
α
:
Type
u_1}
{
xs
:
Word
α
}
:
xs
.
append
nil
=
xs
source
@[simp]
theorem
Word
.
append_of_infinite_left'
{
α
:
Type
u_1}
{
xs
ys
:
Word
α
}
[
h
:
xs
.
Infinite
]
:
xs
.
append
ys
=
xs
source
@[simp]
theorem
Word
.
init_nil
{
α
:
Type
u_1}
:
nil
.
init
=
nil
source
@[simp]
theorem
Word
.
init_cons_nil
{
α
:
Type
u_1}
{
x
:
α
}
:
(
cons
x
nil
)
.
init
=
nil
source
@[simp]
theorem
Word
.
init_cons_cons
{
α
:
Type
u_1}
{
xs
:
Word
α
}
{
x
y
:
α
}
:
(
cons
x
(
cons
y
xs
)
)
.
init
=
cons
x
(
cons
y
xs
)
.
init
source
@[simp]
theorem
Word
.
init_of_infinite
{
α
:
Type
u_1}
{
xs
:
Word
α
}
[
h
:
xs
.
Infinite
]
:
xs
.
init
=
xs
source
@[simp]
theorem
Word
.
init_append_cons
{
α
:
Type
u_1}
{
xs
ys
:
Word
α
}
{
x
:
α
}
:
(
xs
++
cons
x
ys
).
init
=
xs
++
(
cons
x
ys
)
.
init
source
@[simp]
theorem
Word
.
init_ofList
{
α
:
Type
u_1}
{
xs
:
List
α
}
:
(
ofList
xs
)
.
init
=
ofList
xs
.
init
source
noncomputable def
Word
.
ofGet?Alt₁
{
α
:
Type
u_1}
(
f
:
ℕ
→
Option
α
)
:
Word
α
Equations
Word.ofGet?Alt₁
f
=
match h₁ :
Nat.find?
fun (
i
:
ℕ
) =>
f
i
=
none
with |
none
=>
Word.ofSeq
fun (
i
:
ℕ
) =>
(
f
i
)
.
get!
|
some
i
=>
if h₂ :
i
=
0
then
Word.nil
else
Word.ofList
(
mkList
i
fun (
x
:
ℕ
) =>
(
f
x
)
.
get!
)
Instances For
source
theorem
Word
.
ofGet?_eq_alt₁
{
α
:
Type
u_1}
:
ofGet?
=
ofGet?Alt₁
source
theorem
Word
.
get?_ofGet?
{
α
:
Type
u_1}
{
f
:
ℕ
→
Option
α
}
{
i
:
ℕ
}
:
(
ofGet?
f
)
.
get?
i
=
if
∀
k
<
i
,
f
k
≠
none
then
f
i
else
none
source
@[simp]
theorem
Word
.
get?_ofGet?_eq_none_iff
{
α
:
Type
u_1}
{
f
:
ℕ
→
Option
α
}
{
i
:
ℕ
}
:
(
ofGet?
f
)
.
get?
i
=
none
↔
∃
k
≤
i
,
f
k
=
none
source
@[simp]
theorem
Word
.
get?_ofGet?_eq_some_iff
{
α
:
Type
u_1}
{
f
:
ℕ
→
Option
α
}
{
i
:
ℕ
}
{
x
:
α
}
:
(
ofGet?
f
)
.
get?
i
=
some
x
↔
f
i
=
some
x
∧
∀
k
<
i
,
f
k
≠
none
source
@[simp]
theorem
Word
.
flatten_nil
{
α
:
Type
u_1}
:
nil
.
flatten
=
nil
source
theorem
Word
.
flatten_cons_aux₁
{
α
:
Type
u_1}
{
L
:
Word
(
Word
α
)
}
{
a
:
ℕ
→
α
}
{
i
:
ℕ
}
:
(
cons
(
ofSeq
a
)
L
)
.
flatten
.
get?
i
=
(
ofSeq
a
++
L
.
flatten
).
get?
i
source
theorem
Word
.
flatten_cons_aux₂
{
α
:
Type
u_1}
{
L
:
Word
(
Word
α
)
}
{
xs
:
List
α
}
{
i
:
ℕ
}
(
h₁
:
i
<
xs
.
length
)
:
(
cons
(
ofList
xs
)
L
)
.
flatten
.
get?
i
=
(
ofList
xs
++
L
.
flatten
).
get?
i
source
theorem
Word
.
flatten_cons_aux₃
{
α
:
Type
u_1}
{
L
:
Word
(
Word
α
)
}
{
xs
:
List
α
}
{
i
:
ℕ
}
(
h₁
:
xs
.
length
≤
i
)
:
(
cons
(
ofList
xs
)
L
)
.
flatten
.
get?
i
=
(
ofList
xs
++
L
.
flatten
).
get?
i
source
@[simp]
theorem
Word
.
flatten_cons
{
α
:
Type
u_1}
{
xs
:
Word
α
}
{
L
:
Word
(
Word
α
)
}
:
(
cons
xs
L
)
.
flatten
=
xs
++
L
.
flatten
source
theorem
Word
.
cycle_steps
{
α
:
Type
u_1}
{
xs
:
Word
α
}
(
n
:
ℕ
)
:
xs
.
cycle
=
(
ofList
(
List.replicate
n
xs
)
)
.
flatten
++
xs
.
cycle
source
@[simp]
theorem
Word
.
flatten_ofList_replicate_ofList
{
α
:
Type
u_1}
{
xs
:
List
α
}
{
n
:
ℕ
}
:
(
ofList
(
List.replicate
n
(
ofList
xs
)
)
)
.
flatten
=
ofList
(
List.replicate
n
xs
)
.
flatten
source
theorem
Word
.
eq_iff_step
{
α
:
Type
u_1}
{
xs
ys
:
Word
α
}
:
xs
=
ys
↔
xs
.
get?
0
=
ys
.
get?
0
∧
xs
.
tail
=
ys
.
tail
source
@[simp]
theorem
Word
.
get_ofSeq
{
α
:
Type
u_1}
{
a
:
ℕ
→
α
}
{
i
:
ℕ
}
{
h
:
∀ (
n
:
ℕ
),
(
ofSeq
a
)
.
length?
=
some
n
→
i
<
n
}
:
(
ofSeq
a
)
.
get
i
h
=
a
i
source
theorem
Word
.
getElem?_take_of_lt
{
α
:
Type
u_1}
{
xs
:
Word
α
}
{
n
i
:
ℕ
}
(
h
:
i
<
n
)
:
(
take
n
xs
)
[
i
]
?
=
xs
.
get?
i
source
theorem
Word
.
getElem_take_proof₁
{
α
:
Type
u_1}
{
xs
:
Word
α
}
{
n
i
:
ℕ
}
(
h
:
i
<
(
take
n
xs
)
.
length
)
(
n✝
:
ℕ
)
:
xs
.
length?
=
some
n✝
→
i
<
n✝
source
@[simp]
theorem
Word
.
getElem_take
{
α
:
Type
u_1}
{
xs
:
Word
α
}
{
n
i
:
ℕ
}
{
h
:
i
<
(
take
n
xs
)
.
length
}
:
(
take
n
xs
)
[
i
]
=
xs
.
get
i
⋯
source
theorem
Word
.
ext_take
{
α
:
Type
u_1}
{
xs
ys
:
Word
α
}
:
xs
=
ys
↔
∀ (
n
:
ℕ
),
take
n
xs
=
take
n
ys
source
theorem
Word
.
length_take
{
α
:
Type
u_1}
{
xs
:
Word
α
}
{
n
:
ℕ
}
:
(
take
n
xs
)
.
length
=
xs
.
length?
.
elim
n
(
min
n
)
source
theorem
Word
.
get?_eq_none_of_le
{
α
:
Type
u_1}
{
xs
:
Word
α
}
{
n
k
:
ℕ
}
(
h₁
:
xs
.
get?
k
=
none
)
(
h₂
:
k
≤
n
)
:
xs
.
get?
n
=
none
source
@[simp]
theorem
Word
.
get?_zero_eq_none_iff
{
α
:
Type
u_1}
{
xs
:
Word
α
}
:
xs
.
get?
0
=
none
↔
xs
=
nil
source
@[simp]
theorem
Word
.
none_eq_get?_zero_iff
{
α
:
Type
u_1}
{
xs
:
Word
α
}
:
none
=
xs
.
get?
0
↔
xs
=
nil
source
theorem
Word
.
take_eq_take_iff
{
α
:
Type
u_1}
{
xs
ys
:
Word
α
}
{
n
:
ℕ
}
:
take
n
xs
=
take
n
ys
↔
∀
k
<
n
,
xs
.
get?
k
=
ys
.
get?
k
source
theorem
Word
.
eq_of_take_imp_get?
{
α
:
Type
u_1}
{
xs
ys
:
Word
α
}
(
h
:
∀ (
n
:
ℕ
),
take
n
xs
=
take
n
ys
→
xs
.
get?
n
=
ys
.
get?
n
)
:
xs
=
ys
source
@[simp]
theorem
Word
.
wordFun_ofList
{
α
:
Type
u_1}
{
β
:
Type
u_2}
{
p
:
(
ℕ
→
α
)
→
Prop
}
{
f
:
List
α
→
List
β
}
{
xs
:
List
α
}
:
wordFun
p
f
(
ofList
xs
)
=
ofList
(
f
xs
)
source
@[simp]
theorem
Word
.
wordFun_ofSeq
{
α
:
Type
u_1}
{
β
:
Type
u_2}
[
hb
:
Nonempty
β
]
{
p
:
(
ℕ
→
α
)
→
Prop
}
{
f
:
List
α
→
List
β
}
{
a
:
ℕ
→
α
}
:
wordFun
p
f
(
ofSeq
a
)
=
ofSeq
(
seqFun
p
f
a
)
source
theorem
Word
.
mem_def
{
α
:
Type
u_1}
{
xs
:
Word
α
}
{
x
:
α
}
:
x
∈
xs
↔
xs
.
mem
x
source
@[simp]
theorem
Word
.
mem_ofList
{
α
:
Type
u_1}
{
xs
:
List
α
}
{
x
:
α
}
:
x
∈
ofList
xs
↔
x
∈
xs
source
@[simp]
theorem
Word
.
mem_ofSeq
{
α
:
Type
u_1}
{
a
:
ℕ
→
α
}
{
x
:
α
}
:
x
∈
ofSeq
a
↔
∃ (
i
:
ℕ
),
a
i
=
x
source
@[simp]
theorem
Word
.
get?_eq_some_get_iff
{
α
:
Type
u_1}
{
xs
:
Word
α
}
{
n
:
ℕ
}
{
h
:
∀ (
n_1
:
ℕ
),
xs
.
length?
=
some
n_1
→
n
<
n_1
}
:
xs
.
get?
n
=
some
(
xs
.
get
n
h
)
↔
∀ (
h
:
xs
.
length?
≠
none
),
n
<
xs
.
length
h
source
@[simp]
theorem
Word
.
some_get_eq_get?_iff
{
α
:
Type
u_1}
{
xs
:
Word
α
}
{
n
:
ℕ
}
{
h
:
∀ (
n_1
:
ℕ
),
xs
.
length?
=
some
n_1
→
n
<
n_1
}
:
some
(
xs
.
get
n
h
)
=
xs
.
get?
n
↔
∀ (
h
:
xs
.
length?
≠
none
),
n
<
xs
.
length
h
source
theorem
Word
.
mem_iff_get?
{
α
:
Type
u_1}
{
xs
:
Word
α
}
{
x
:
α
}
:
x
∈
xs
↔
∃ (
n
:
ℕ
),
xs
.
get?
n
=
some
x
source
theorem
Word
.
mem_iff_get
{
α
:
Type
u_1}
{
xs
:
Word
α
}
{
x
:
α
}
:
x
∈
xs
↔
∃ (
n
:
ℕ
) (
h
:
∀ (
n_1
:
ℕ
),
xs
.
length?
=
some
n_1
→
n
<
n_1
),
xs
.
get
n
h
=
x
source
@[simp]
theorem
Word
.
not_mem_nil
{
α
:
Type
u_1}
{
x
:
α
}
:
x
∉
nil
source
@[simp]
theorem
Word
.
mem_cons_iff
{
α
:
Type
u_1}
{
xs
:
Word
α
}
{
x
y
:
α
}
:
y
∈
cons
x
xs
↔
y
=
x
∨
y
∈
xs
source
theorem
Word
.
get?_append_eq_get?_append_of_right
{
α
:
Type
u_1}
{
xs
ys
zs
:
Word
α
}
{
n
:
ℕ
}
(
h₁
:
∀ (
k
:
ℕ
) (
h
:
xs
.
length?
≠
none
),
n
=
xs
.
length
h
+
k
→
ys
.
get?
k
=
zs
.
get?
k
)
:
(
xs
++
ys
).
get?
n
=
(
xs
++
zs
).
get?
n
source
@[simp]
theorem
Word
.
map_append
{
α
:
Type
u_1}
{
β
:
Type
u_2}
{
xs
ys
:
Word
α
}
{
f
:
α
→
β
}
:
map
f
(
xs
++
ys
)
=
map
f
xs
++
map
f
ys
source
@[simp]
theorem
Word
.
get_succ_cons
{
α
:
Type
u_1}
{
xs
:
Word
α
}
{
x
:
α
}
{
n
:
ℕ
}
{
h
:
∀ (
n_1
:
ℕ
),
(
cons
x
xs
)
.
length?
=
some
n_1
→
n
+
1
<
n_1
}
:
(
cons
x
xs
)
.
get
(
n
+
1
)
h
=
xs
.
get
n
⋯
source
theorem
Word
.
get?_ofList_append_eq_ite
{
α
:
Type
u_1}
{
ys
:
Word
α
}
{
xs
:
List
α
}
{
n
:
ℕ
}
:
(
ofList
xs
++
ys
).
get?
n
=
if h :
n
<
xs
.
length
then
some
xs
[
n
]
else
ys
.
get?
(
n
-
xs
.
length
)
source
@[simp]
theorem
Word
.
get?_drop
{
α
:
Type
u_1}
{
xs
:
Word
α
}
{
n
k
:
ℕ
}
:
(
drop
n
xs
)
.
get?
k
=
xs
.
get?
(
n
+
k
)
source
@[simp]
theorem
Word
.
get?_tail
{
α
:
Type
u_1}
{
xs
:
Word
α
}
{
n
:
ℕ
}
:
xs
.
tail
.
get?
n
=
xs
.
get?
(
n
+
1
)
source
@[simp]
theorem
Word
.
tail_ofSeq
{
α
:
Type
u_1}
{
a
:
ℕ
→
α
}
:
(
ofSeq
a
)
.
tail
=
ofSeq
fun (
x
:
ℕ
) =>
a
(
x
+
1
)
source
theorem
Word
.
ofGet?_spec
{
α
:
Type
u_1}
{
β
:
Type
u_2}
{
xs
:
Word
α
}
(
f
:
Word
α
→
ℕ
→
Option
β
)
(
h
:
∀ (
N
n
:
ℕ
),
N
<
n
→
f
xs
N
=
none
→
f
xs
n
=
none
)
:
(
ofGet?
(
f
xs
)
)
.
get?
=
f
xs
source
theorem
Word
.
drop_add
{
α
:
Type
u_1}
{
xs
:
Word
α
}
{
n
m
:
ℕ
}
:
drop
(
n
+
m
)
xs
=
drop
m
(
drop
n
xs
)
source
theorem
Word
.
drop_add'
{
α
:
Type
u_1}
{
xs
:
Word
α
}
{
n
m
:
ℕ
}
:
drop
(
n
+
m
)
xs
=
drop
n
(
drop
m
xs
)
source
theorem
Word
.
take_drop
{
α
:
Type
u_1}
{
xs
:
Word
α
}
{
n
k
:
ℕ
}
:
take
k
(
drop
n
xs
)
=
List.drop
n
(
take
(
n
+
k
)
xs
)
source
theorem
Word
.
take_add
{
α
:
Type
u_1}
{
xs
:
Word
α
}
{
n
m
:
ℕ
}
:
take
(
n
+
m
)
xs
=
take
n
xs
++
take
m
(
drop
n
xs
)
source
theorem
Word
.
take_add'
{
α
:
Type
u_1}
{
xs
:
Word
α
}
{
n
m
:
ℕ
}
:
take
(
n
+
m
)
xs
=
take
m
xs
++
take
n
(
drop
m
xs
)
source
@[simp]
theorem
Word
.
length_take_le
{
α
:
Type
u_1}
{
xs
:
Word
α
}
{
n
:
ℕ
}
:
(
take
n
xs
)
.
length
≤
n
source
theorem
Word
.
le_length_take_iff_eq
{
α
:
Type
u_1}
{
xs
:
Word
α
}
{
n
:
ℕ
}
:
n
≤
(
take
n
xs
)
.
length
↔
n
=
(
take
n
xs
)
.
length
source
@[simp]
theorem
Word
.
self_eq_length_take_iff
{
α
:
Type
u_1}
{
xs
:
Word
α
}
{
n
:
ℕ
}
:
n
=
(
take
n
xs
)
.
length
↔
∀ (
h
:
xs
.
length?
≠
none
),
n
≤
xs
.
length
h
source
@[simp]
theorem
Word
.
length_take_eq_self_iff
{
α
:
Type
u_1}
{
xs
:
Word
α
}
{
n
:
ℕ
}
:
(
take
n
xs
)
.
length
=
n
↔
∀ (
h
:
xs
.
length?
≠
none
),
n
≤
xs
.
length
h
source
@[simp]
theorem
Word
.
le_length_take_iff
{
α
:
Type
u_1}
{
xs
:
Word
α
}
{
n
:
ℕ
}
:
n
≤
(
take
n
xs
)
.
length
↔
∀ (
h
:
xs
.
length?
≠
none
),
n
≤
xs
.
length
h
source
theorem
Word
.
wf_batches'
{
α
:
Type
u_1}
{
xs
:
Word
α
}
{
n
:
ℕ
}
(
i
:
ℕ
)
:
xs
.
batches'
n
i
=
none
→
∀ (
j
:
ℕ
),
i
<
j
→
xs
.
batches'
n
j
=
none
source
theorem
Word
.
get?_batches
{
α
:
Type
u_1}
{
xs
:
Word
α
}
{
n
:
ℕ
}
:
(
xs
.
batches
n
)
.
get?
=
xs
.
batches'
n
source
theorem
Word
.
batches_eq
{
α
:
Type
u_1}
{
xs
:
Word
α
}
{
n
:
ℕ
}
:
xs
.
batches
n
=
{
get?
:=
xs
.
batches'
n
,
wf
:=
⋯
}
source
@[simp]
theorem
Word
.
batches_ofList
{
α
:
Type
u_1}
{
xs
:
List
α
}
{
n
:
ℕ
}
:
(
ofList
xs
)
.
batches
n
=
ofList
(
xs
.
batches
n
)
source
theorem
Word
.
batches_ofSeq
{
α
:
Type
u_1}
{
a
:
ℕ
→
α
}
{
n
:
ℕ
}
(
hn
:
n
≠
0
)
:
(
ofSeq
a
)
.
batches
n
=
ofSeq
fun (
k
:
ℕ
) =>
mkList
n
fun (
i
:
ℕ
) =>
a
(
n
*
k
+
i
)
source
@[simp]
theorem
Word
.
batches_zero
{
α
:
Type
u_1}
{
xs
:
Word
α
}
:
xs
.
batches
0
=
nil
source
@[simp]
theorem
Word
.
batches_nil
{
α
:
Type
u_1}
{
n
:
ℕ
}
:
nil
.
batches
n
=
nil
source
theorem
Word
.
batches_of_length_lt
{
α
:
Type
u_1}
{
xs
:
Word
α
}
{
n
:
ℕ
}
(
h
:
∃ (
h₁
:
xs
.
length?
≠
none
),
xs
.
length
h₁
<
n
)
:
xs
.
batches
n
=
nil