Documentation
Projects
.
Util
.
Data
.
Word
.
Part_002
Search
return to top
source
Imports
Init
Projects.Util.Data.Word.Part_001
Imported by
Word
.
limit_spec
Word
.
limit_eq_none_iff
Word
.
limit_eq_some_iff
Word
.
limit_const
Word
.
limit_eq_seqFun
Word
.
finite_ne_infinite
Word
.
infinite_ne_finite
Word
.
infinite_append_left
Word
.
infinite_append_right
Word
.
ofList_prefix_ofList_iff
Word
.
ofList_infix_ofList_iff
Word
.
get?_ofGet?_ext
Word
.
get?_append_left
Word
.
get?_of_prefix
Word
.
exi_get?_Of_le
Word
.
limit_spec_of_prefix
Word
.
limit_spec_of_prefix_list
Word
.
zipWith_cons
Word
.
get_eq_of_get?_eq_some_proof₁
Word
.
get_eq_of_get?_eq_some
Word
.
get_eq_getElem_take_proof₁
Word
.
get_eq_getElem_take
Word
.
zipWith_nil_left
Word
.
zipWith_nil_right
Word
.
take_zipWith
Word
.
zipWith_comm
Word
.
getElem?_take
Word
.
zipWith_ofList_left
Word
.
zipWith_ofList_right
Word
.
take_cycleList_proof₁
Word
.
length?_cycleList_eq_none_iff
Word
.
length?_cycleList_eq_some_iff
Word
.
get_cycleList_proof₁
Word
.
get_cycleList
Word
.
take_cycleList
Word
.
take_cycle_proof₁
Word
.
cycle_ofList
Word
.
take_cycle
Word
.
get_cons_proof₁
Word
.
get_cons
Word
.
dite_get_nil_left
Word
.
dite_get_nil_right
Word
.
ext_get
Word
.
list_foldr_append_replicate_nil
Word
.
list_foldr_append_replicate_nil'
Word
.
ofGet?_const_none
Word
.
flatten_ofSeq_const_nil
Word
.
cntrex₁
Word
.
flatten_append
Word
.
Infinite
.
length?_eq
Word
.
length?_append
Word
.
length?_append'
Word
.
length?_append_comm
Word
.
length?_flatten_ofList_proof₁
Word
.
length?_flatten_ofList
Word
.
get_append_left
Word
.
get_ofList_append_left
Word
.
get_ofList_append_right_proof₁
Word
.
get_ofList_append_right
Word
.
flatten_ofList_zipWith_ofList
Word
.
ext_toList?
Word
.
ofSeq_steps
Word
.
cons_prefix_cons_iff
Word
.
drop_ofList_append_left
Word
.
drop_ofList_append_right
Word
.
drop_length_ofList_append
Word
.
drop_length_add_ofList_append
Word
.
drop_add_length_ofList_append
Word
.
prefix_drop
Word
.
prefix_refl
Word
.
infix_refl
Word
.
nil_prefix
Word
.
nil_infix
Word
.
zipWith_prefix_append_left
Word
.
zipWith_prefix_append_right
Word
.
prefix_append
Word
.
prefix_flatten
Word
.
get?_cons
Word
.
mem_of_get?_eq_some
Word
.
mem_ofList_iff
Word
.
mem_append_iff
Word
.
mem_append_iff'
Word
.
mem_foldr_append_iff_of_finite
Word
.
mem_of_mem_take
Word
.
mem_iff_append
Word
.
finite_append_of
Word
.
infinite_append_of_left
Word
.
infinite_append_of_right
Word
.
finite_append_iff
Word
.
infinite_append_iff
Word
.
finite_flatten_ofList_iff
Word
.
mem_flatten_iff_of_finite
Word
.
mem_of_mem_drop
Word
.
mem_iff_mem_take
Word
.
mem_zipWith_iff
Word
.
get_mem
Word
.
mem_of_get_eq
Word
.
flatMap_eq_flatten_map
Word
.
flatten_ofList_of_finite
Word
.
map_map
Word
.
flatMap_map
Word
.
flatMap_ofList_fun_ofList
Word
.
ofList_prefix_ofSeq_iff
Word
.
not_ofSeq_prefix_ofList
Word
.
ofSeq_prefix_ofSeq_iff
Word
.
ofList_infix_ofSeq_iff
Word
.
not_ofSeq_infix_ofList
Word
.
ofSeq_infix_ofSeq_iff
Word
.
batches_step
Word
.
flatMap_nil
Word
.
flatMap_cons
Word
.
mk_eq_ofGet?_self_simp
Word
.
append_eq_ofGet?
Word
.
zipWith_eq_ofGet?
source
theorem
Word
.
limit_spec
{
α
:
Type
u_1}
{
w
:
Word
α
}
{
a
:
ℕ
→
Word
α
}
(
h
:
∀ (
i
:
ℕ
),
∃ (
N
:
ℕ
),
∀ (
n
:
ℕ
),
N
≤
n
→
(
a
n
)
.
get?
i
=
w
.
get?
i
)
:
limit
a
=
some
w
source
@[simp]
theorem
Word
.
limit_eq_none_iff
{
α
:
Type
u_1}
{
a
:
ℕ
→
Word
α
}
:
limit
a
=
none
↔
∀ (
w
:
Word
α
),
∃ (
i
:
ℕ
),
∀ (
N
:
ℕ
),
∃ (
n
:
ℕ
),
N
≤
n
∧
(
a
n
)
.
get?
i
≠
w
.
get?
i
source
@[simp]
theorem
Word
.
limit_eq_some_iff
{
α
:
Type
u_1}
{
w
:
Word
α
}
{
a
:
ℕ
→
Word
α
}
:
limit
a
=
some
w
↔
∀ (
i
:
ℕ
),
∃ (
N
:
ℕ
),
∀ (
n
:
ℕ
),
N
≤
n
→
(
a
n
)
.
get?
i
=
w
.
get?
i
source
@[simp]
theorem
Word
.
limit_const
{
α
:
Type
u_1}
{
w
:
Word
α
}
:
(
limit
fun (
x
:
ℕ
) =>
w
)
=
some
w
source
theorem
Word
.
limit_eq_seqFun
{
α
:
Type
u_1}
{
β
:
Type
u_2}
[
hb
:
Nonempty
β
]
{
p
:
(
ℕ
→
α
)
→
Prop
}
{
f
:
List
α
→
List
β
}
{
g
:
(
ℕ
→
α
)
→
ℕ
→
β
}
{
a
:
ℕ
→
α
}
(
ha
:
p
a
)
(
h
:
SeqFunCnd
p
f
g
)
:
(
limit
fun (
n
:
ℕ
) =>
ofList
(
f
(
mkList
n
a
)
)
)
=
some
(
ofSeq
(
seqFun
p
f
a
)
)
source
@[simp]
theorem
Word
.
finite_ne_infinite
{
α
:
Type
u_1}
{
w₁
w₂
:
Word
α
}
[
h₁
:
w₁
.
Finite
]
[
h₂
:
w₂
.
Infinite
]
:
w₁
≠
w₂
source
@[simp]
theorem
Word
.
infinite_ne_finite
{
α
:
Type
u_1}
{
w₁
w₂
:
Word
α
}
[
h₁
:
w₁
.
Infinite
]
[
h₂
:
w₂
.
Finite
]
:
w₁
≠
w₂
source
instance
Word
.
infinite_append_left
{
α
:
Type
u_1}
{
w
w₁
:
Word
α
}
[
h
:
w
.
Infinite
]
:
(
w₁
++
w
).
Infinite
source
instance
Word
.
infinite_append_right
{
α
:
Type
u_1}
{
w
w₁
:
Word
α
}
[
h
:
w
.
Infinite
]
:
(
w
++
w₁
).
Infinite
source
@[simp]
theorem
Word
.
ofList_prefix_ofList_iff
{
α
:
Type
u_1}
{
xs
ys
:
List
α
}
:
(
ofList
xs
)
.
IsPrefix
(
ofList
ys
)
↔
xs
<+:
ys
source
@[simp]
theorem
Word
.
ofList_infix_ofList_iff
{
α
:
Type
u_1}
{
xs
ys
:
List
α
}
:
(
ofList
xs
)
.
IsInfix
(
ofList
ys
)
↔
xs
<:+:
ys
source
theorem
Word
.
get?_ofGet?_ext
{
α
:
Type
u_1}
{
f
:
ℕ
→
Option
α
}
:
(
ofGet?
f
)
.
get?
=
fun (
i
:
ℕ
) =>
if
∀
k
<
i
,
f
k
≠
none
then
f
i
else
none
source
theorem
Word
.
get?_append_left
{
α
:
Type
u_1}
{
w₁
w₂
:
Word
α
}
{
n
:
ℕ
}
{
x
:
α
}
(
h
:
w₁
.
get?
n
=
some
x
)
:
(
w₁
++
w₂
).
get?
n
=
some
x
source
theorem
Word
.
get?_of_prefix
{
α
:
Type
u_1}
{
w₁
w₂
:
Word
α
}
{
n
:
ℕ
}
{
x
:
α
}
(
h₁
:
w₁
.
IsPrefix
w₂
)
(
h₂
:
w₁
.
get?
n
=
some
x
)
:
w₂
.
get?
n
=
some
x
source
theorem
Word
.
exi_get?_Of_le
{
α
:
Type
u_1}
{
w
:
Word
α
}
{
k
n
:
ℕ
}
{
x
:
α
}
(
h₁
:
w
.
get?
n
=
some
x
)
(
h₂
:
k
≤
n
)
:
∃ (
y
:
α
),
w
.
get?
k
=
some
y
source
theorem
Word
.
limit_spec_of_prefix
{
α
:
Type
u_1}
{
a
:
ℕ
→
Word
α
}
(
h
:
∀ (
k
n
:
ℕ
),
k
≤
n
→
(
a
k
)
.
IsPrefix
(
a
n
)
)
:
∃ (
w
:
Word
α
),
limit
a
=
some
w
∧
∀ (
n
:
ℕ
) (
x
:
α
),
(∃ (
k
:
ℕ
),
(
a
k
)
.
get?
n
=
some
x
)
→
w
.
get?
n
=
some
x
source
theorem
Word
.
limit_spec_of_prefix_list
{
α
:
Type
u_1}
{
a
:
ℕ
→
List
α
}
(
h
:
∀ (
k
n
:
ℕ
),
k
≤
n
→
a
k
<+:
a
n
)
:
∃ (
w
:
Word
α
),
(
limit
fun (
x
:
ℕ
) =>
ofList
(
a
x
)
)
=
some
w
∧
∀ (
n
:
ℕ
) (
x
:
α
),
(∃ (
k
:
ℕ
) (
h
:
n
<
(
a
k
)
.
length
),
(
a
k
)
[
n
]
=
x
)
→
w
.
get?
n
=
some
x
source
@[simp]
theorem
Word
.
zipWith_cons
{
α
:
Type
u_1}
{
β
:
Type
u_2}
{
γ
:
Type
u_3}
{
x
:
α
}
{
y
:
β
}
{
xs
:
Word
α
}
{
ys
:
Word
β
}
{
f
:
α
→
β
→
γ
}
:
zipWith
f
(
cons
x
xs
)
(
cons
y
ys
)
=
cons
(
f
x
y
)
(
zipWith
f
xs
ys
)
source
theorem
Word
.
get_eq_of_get?_eq_some_proof₁
{
α
:
Type
u_1}
{
w
:
Word
α
}
{
i
:
ℕ
}
{
x
:
α
}
(
h
:
w
.
get?
i
=
some
x
)
(
n
:
ℕ
)
:
w
.
length?
=
some
n
→
i
<
n
source
theorem
Word
.
get_eq_of_get?_eq_some
{
α
:
Type
u_1}
{
w
:
Word
α
}
{
i
:
ℕ
}
{
x
:
α
}
(
h
:
w
.
get?
i
=
some
x
)
:
w
.
get
i
⋯
=
x
source
theorem
Word
.
get_eq_getElem_take_proof₁
{
α
:
Type
u_1}
{
w
:
Word
α
}
{
i
:
ℕ
}
(
h
:
∀ (
n
:
ℕ
),
w
.
length?
=
some
n
→
i
<
n
)
:
i
<
(
take
(
i
+
1
)
w
)
.
length
source
theorem
Word
.
get_eq_getElem_take
{
α
:
Type
u_1}
{
w
:
Word
α
}
{
n
:
ℕ
}
{
h
:
∀ (
n_1
:
ℕ
),
w
.
length?
=
some
n_1
→
n
<
n_1
}
:
w
.
get
n
h
=
(
take
(
n
+
1
)
w
)
[
n
]
source
@[simp]
theorem
Word
.
zipWith_nil_left
{
α
:
Type
u_1}
{
β
:
Type
u_2}
{
γ
:
Type
u_3}
{
f
:
α
→
β
→
γ
}
{
w
:
Word
β
}
:
zipWith
f
nil
w
=
nil
source
@[simp]
theorem
Word
.
zipWith_nil_right
{
α
:
Type
u_1}
{
β
:
Type
u_2}
{
γ
:
Type
u_3}
{
f
:
α
→
β
→
γ
}
{
w
:
Word
α
}
:
zipWith
f
w
nil
=
nil
source
@[simp]
theorem
Word
.
take_zipWith
{
α
:
Type
u_1}
{
β
:
Type
u_2}
{
γ
:
Type
u_3}
{
f
:
α
→
β
→
γ
}
{
w₁
:
Word
α
}
{
w₂
:
Word
β
}
{
n
:
ℕ
}
:
take
n
(
zipWith
f
w₁
w₂
)
=
List.zipWith
f
(
take
n
w₁
)
(
take
n
w₂
)
source
theorem
Word
.
zipWith_comm
{
α
:
Type
u_1}
{
β
:
Type
u_2}
{
γ
:
Type
u_3}
{
f
:
α
→
β
→
γ
}
{
w₁
:
Word
α
}
{
w₂
:
Word
β
}
:
zipWith
f
w₁
w₂
=
zipWith
(fun (
y
:
β
) (
x
:
α
) =>
f
x
y
)
w₂
w₁
source
theorem
Word
.
getElem?_take
{
α
:
Type
u_1}
{
w
:
Word
α
}
{
n
i
:
ℕ
}
:
(
take
n
w
)
[
i
]
?
=
if
i
<
n
then
w
.
get?
i
else
none
source
@[simp]
theorem
Word
.
zipWith_ofList_left
{
α
:
Type
u_1}
{
β
:
Type
u_2}
{
γ
:
Type
u_3}
{
f
:
α
→
β
→
γ
}
{
xs
:
List
α
}
{
w
:
Word
β
}
:
zipWith
f
(
ofList
xs
)
w
=
ofList
(
List.zipWith
f
xs
(
take
xs
.
length
w
)
)
source
@[simp]
theorem
Word
.
zipWith_ofList_right
{
α
:
Type
u_1}
{
β
:
Type
u_2}
{
γ
:
Type
u_3}
{
f
:
α
→
β
→
γ
}
{
w
:
Word
α
}
{
xs
:
List
β
}
:
zipWith
f
w
(
ofList
xs
)
=
ofList
(
List.zipWith
f
(
take
xs
.
length
w
)
xs
)
source
theorem
Word
.
take_cycleList_proof₁
{
α
:
Type
u_1}
{
xs
:
List
α
}
{
i
:
ℕ
}
(
h₁
:
xs
≠
[
]
)
:
i
%
xs
.
length
<
xs
.
length
source
@[simp]
theorem
Word
.
length?_cycleList_eq_none_iff
{
α
:
Type
u_1}
{
xs
:
List
α
}
:
(
cycleList
xs
)
.
length?
=
none
↔
xs
≠
[
]
source
@[simp]
theorem
Word
.
length?_cycleList_eq_some_iff
{
α
:
Type
u_1}
{
xs
:
List
α
}
{
n
:
ℕ
}
:
(
cycleList
xs
)
.
length?
=
some
n
↔
xs
=
[
]
∧
n
=
0
source
theorem
Word
.
get_cycleList_proof₁
{
α
:
Type
u_1}
{
xs
:
List
α
}
{
n
:
ℕ
}
(
h
:
∀ (
k
:
ℕ
),
(
cycleList
xs
)
.
length?
=
some
k
→
n
<
k
)
:
n
%
xs
.
length
<
xs
.
length
source
@[simp]
theorem
Word
.
get_cycleList
{
α
:
Type
u_1}
{
xs
:
List
α
}
{
n
:
ℕ
}
{
h
:
∀ (
n_1
:
ℕ
),
(
cycleList
xs
)
.
length?
=
some
n_1
→
n
<
n_1
}
:
(
cycleList
xs
)
.
get
n
h
=
xs
[
n
%
xs
.
length
]
source
theorem
Word
.
take_cycleList
{
α
:
Type
u_1}
{
xs
:
List
α
}
{
n
:
ℕ
}
(
h
:
xs
≠
[
]
)
:
take
n
(
cycleList
xs
)
=
mkList
n
fun (
i
:
ℕ
) =>
xs
[
i
%
xs
.
length
]
source
theorem
Word
.
take_cycle_proof₁
{
α
:
Type
u_1}
{
w
:
Word
α
}
{
n
i
:
ℕ
}
(
h₁
:
w
≠
nil
)
(
h₂
:
w
.
length?
=
some
n
)
:
i
%
w
.
length?
.
getD
(
i
+
1
)
<
n
source
@[simp]
theorem
Word
.
cycle_ofList
{
α
:
Type
u_1}
{
xs
:
List
α
}
:
(
ofList
xs
)
.
cycle
=
cycleList
xs
source
theorem
Word
.
take_cycle
{
α
:
Type
u_1}
{
w
:
Word
α
}
{
n
:
ℕ
}
(
h
:
w
≠
nil
)
:
take
n
w
.
cycle
=
mkList
n
fun (
i
:
ℕ
) =>
w
.
get
(
i
%
w
.
length?
.
getD
(
i
+
1
)
)
⋯
source
theorem
Word
.
get_cons_proof₁
{
α
:
Type
u_1}
{
w
:
Word
α
}
{
x
:
α
}
{
i
:
ℕ
}
(
h₁
:
∀ (
n
:
ℕ
),
(
cons
x
w
)
.
length?
=
some
n
→
i
<
n
)
(
h₂
:
i
≠
0
)
(
n
:
ℕ
)
:
w
.
length?
=
some
n
→
i
-
1
<
n
source
theorem
Word
.
get_cons
{
α
:
Type
u_1}
{
w
:
Word
α
}
{
x
:
α
}
{
i
:
ℕ
}
{
h
:
∀ (
n
:
ℕ
),
(
cons
x
w
)
.
length?
=
some
n
→
i
<
n
}
:
(
cons
x
w
)
.
get
i
h
=
if h₁ :
i
=
0
then
x
else
w
.
get
(
i
-
1
)
⋯
source
@[simp]
theorem
Word
.
dite_get_nil_left
{
α
:
Type
u_1}
{
p
:
Prop
}
[
hp
:
Decidable
p
]
{
i
:
ℕ
}
{
f
:
¬
p
→
α
}
(
h
:
p
→
∀ (
n
:
ℕ
),
nil
.
length?
=
some
n
→
i
<
n
)
:
(if h₁ :
p
then
nil
.
get
i
⋯
else
f
h₁
)
=
f
⋯
source
@[simp]
theorem
Word
.
dite_get_nil_right
{
α
:
Type
u_1}
{
p
:
Prop
}
[
hp
:
Decidable
p
]
{
i
:
ℕ
}
{
f
:
p
→
α
}
(
h
:
¬
p
→
∀ (
n
:
ℕ
),
nil
.
length?
=
some
n
→
i
<
n
)
:
(if h₁ :
p
then
f
h₁
else
nil
.
get
i
⋯
)
=
f
⋯
source
theorem
Word
.
ext_get
{
α
:
Type
u_1}
{
w₁
w₂
:
Word
α
}
:
w₁
=
w₂
↔
w₁
.
length?
=
w₂
.
length?
∧
∀ (
i
:
ℕ
) (
h₁
:
∀ (
n
:
ℕ
),
w₁
.
length?
=
some
n
→
i
<
n
) (
h₂
:
∀ (
n
:
ℕ
),
w₂
.
length?
=
some
n
→
i
<
n
),
w₁
.
get
i
h₁
=
w₂
.
get
i
h₂
source
@[simp]
theorem
Word
.
list_foldr_append_replicate_nil
{
α
:
Type
u_1}
{
w
:
Word
α
}
{
n
:
ℕ
}
:
List.foldr
(fun (
x1
x2
:
Word
α
) =>
x1
++
x2
)
w
(
List.replicate
n
nil
)
=
w
source
@[simp]
theorem
Word
.
list_foldr_append_replicate_nil'
{
α
:
Type
u_1}
{
w
:
Word
α
}
{
n
:
ℕ
}
:
List.foldr
append
w
(
List.replicate
n
nil
)
=
w
source
@[simp]
theorem
Word
.
ofGet?_const_none
{
α
:
Type
u_1}
:
(
ofGet?
fun (
x
:
ℕ
) =>
none
)
=
nil
source
@[simp]
theorem
Word
.
flatten_ofSeq_const_nil
{
α
:
Type
u_1}
:
(
ofSeq
fun (
x
:
ℕ
) =>
nil
)
.
flatten
=
nil
source
theorem
Word
.
cntrex₁
:
¬
∀ (
α
:
Type
) (
W₁
W₂
:
Word
(
Word
α
)
),
(
W₁
++
W₂
).
flatten
=
W₁
.
flatten
++
W₂
.
flatten
source
@[simp]
theorem
Word
.
flatten_append
{
α
:
Type
u_1}
{
W₁
W₂
:
Word
(
Word
α
)
}
[
h
:
W₁
.
Finite
]
:
(
W₁
++
W₂
).
flatten
=
W₁
.
flatten
++
W₂
.
flatten
source
@[simp]
theorem
Word
.
Infinite
.
length?_eq
{
α
:
Type
u_1}
{
w
:
Word
α
}
[
h
:
w
.
Infinite
]
:
w
.
length?
=
none
source
theorem
Word
.
length?_append
{
α
:
Type
u_1}
{
w₁
w₂
:
Word
α
}
:
(
w₁
++
w₂
).
length?
=
w₁
.
length?
.
bind
fun (
n
:
ℕ
) =>
Option.map
(fun (
x
:
ℕ
) =>
n
+
x
)
w₂
.
length?
source
theorem
Word
.
length?_append'
{
α
:
Type
u_1}
{
w₁
w₂
:
Word
α
}
:
(
w₁
++
w₂
).
length?
=
w₂
.
length?
.
bind
fun (
n
:
ℕ
) =>
Option.map
(fun (
x
:
ℕ
) =>
n
+
x
)
w₁
.
length?
source
theorem
Word
.
length?_append_comm
{
α
:
Type
u_1}
{
w₁
w₂
:
Word
α
}
:
(
w₁
++
w₂
).
length?
=
(
w₂
++
w₁
).
length?
source
theorem
Word
.
length?_flatten_ofList_proof₁
{
α
:
Type
u_1}
{
ws
:
List
(
Word
α
)
}
{
w
:
{
w
:
Word
α
//
w
∈
ws
}
}
(
h
:
¬
∃
w
∈
ws
,
w
.
Infinite
)
:
(↑
w
)
.
length?
≠
none
source
theorem
Word
.
length?_flatten_ofList
{
α
:
Type
u_1}
{
ws
:
List
(
Word
α
)
}
:
(
ofList
ws
)
.
flatten
.
length?
=
if h :
∃
w
∈
ws
,
w
.
Infinite
then
none
else
some
(
List.map
(fun (
w
:
{
x
:
Word
α
//
x
∈
ws
}
) =>
(↑
w
)
.
length
⋯
)
ws
.
attach
)
.
sum
source
theorem
Word
.
get_append_left
{
α
:
Type
u_1}
{
w₁
w₂
:
Word
α
}
{
i
:
ℕ
}
{
h
:
∀ (
n
:
ℕ
),
(
w₁
++
w₂
).
length?
=
some
n
→
i
<
n
}
(
h₁
:
∀ (
n
:
ℕ
),
w₁
.
length?
=
some
n
→
i
<
n
)
:
(
w₁
++
w₂
).
get
i
h
=
w₁
.
get
i
h₁
source
theorem
Word
.
get_ofList_append_left
{
α
:
Type
u_1}
{
w
:
Word
α
}
{
xs
:
List
α
}
{
i
:
ℕ
}
{
h
:
∀ (
n
:
ℕ
),
(
ofList
xs
++
w
).
length?
=
some
n
→
i
<
n
}
(
h₁
:
i
<
xs
.
length
)
:
(
ofList
xs
++
w
).
get
i
h
=
xs
[
i
]
source
theorem
Word
.
get_ofList_append_right_proof₁
{
α
:
Type
u_1}
{
w
:
Word
α
}
{
xs
:
List
α
}
{
i
:
ℕ
}
(
h₁
:
∀ (
n
:
ℕ
),
(
ofList
xs
++
w
).
length?
=
some
n
→
i
<
n
)
(
h₂
:
xs
.
length
≤
i
)
(
n
:
ℕ
)
:
w
.
length?
=
some
n
→
i
-
xs
.
length
<
n
source
theorem
Word
.
get_ofList_append_right
{
α
:
Type
u_1}
{
w
:
Word
α
}
{
xs
:
List
α
}
{
i
:
ℕ
}
{
h
:
∀ (
n
:
ℕ
),
(
ofList
xs
++
w
).
length?
=
some
n
→
i
<
n
}
(
h₁
:
xs
.
length
≤
i
)
:
(
ofList
xs
++
w
).
get
i
h
=
w
.
get
(
i
-
xs
.
length
)
⋯
source
@[simp]
theorem
Word
.
flatten_ofList_zipWith_ofList
{
α
:
Type
u_1}
{
β
:
Type
u_2}
{
γ
:
Type
u_3}
{
xs
:
List
α
}
{
ys
:
List
β
}
{
f
:
α
→
β
→
List
γ
}
:
(
ofList
(
List.zipWith
(fun (
x1
:
α
) (
x2
:
β
) =>
ofList
(
f
x1
x2
)
)
xs
ys
)
)
.
flatten
=
ofList
(
List.zipWith
f
xs
ys
)
.
flatten
source
theorem
Word
.
ext_toList?
{
α
:
Type
u_1}
{
w₁
w₂
:
Word
α
}
[
h₁
:
w₁
.
Finite
]
[
h₂
:
w₂
.
Finite
]
:
w₁
=
w₂
↔
w₁
.
toList?
=
w₂
.
toList?
source
theorem
Word
.
ofSeq_steps
{
α
:
Type
u_1}
{
a
:
ℕ
→
α
}
(
n
:
ℕ
)
:
ofSeq
a
=
ofList
(
mkList
n
a
)
++
ofSeq
fun (
x
:
ℕ
) =>
a
(
x
+
n
)
source
@[simp]
theorem
Word
.
cons_prefix_cons_iff
{
α
:
Type
u_1}
{
w₁
w₂
:
Word
α
}
{
x
y
:
α
}
:
(
cons
x
w₁
)
.
IsPrefix
(
cons
y
w₂
)
↔
x
=
y
∧
w₁
.
IsPrefix
w₂
source
theorem
Word
.
drop_ofList_append_left
{
α
:
Type
u_1}
{
w
:
Word
α
}
{
xs
:
List
α
}
{
n
:
ℕ
}
(
h
:
n
≤
xs
.
length
)
:
drop
n
(
ofList
xs
++
w
)
=
ofList
(
List.drop
n
xs
)
++
w
source
theorem
Word
.
drop_ofList_append_right
{
α
:
Type
u_1}
{
w
:
Word
α
}
{
xs
:
List
α
}
{
n
:
ℕ
}
(
h
:
xs
.
length
≤
n
)
:
drop
n
(
ofList
xs
++
w
)
=
drop
(
n
-
xs
.
length
)
w
source
@[simp]
theorem
Word
.
drop_length_ofList_append
{
α
:
Type
u_1}
{
w
:
Word
α
}
{
xs
:
List
α
}
:
drop
xs
.
length
(
ofList
xs
++
w
)
=
w
source
@[simp]
theorem
Word
.
drop_length_add_ofList_append
{
α
:
Type
u_1}
{
w
:
Word
α
}
{
xs
:
List
α
}
{
n
:
ℕ
}
:
drop
(
xs
.
length
+
n
) (
ofList
xs
++
w
)
=
drop
n
w
source
@[simp]
theorem
Word
.
drop_add_length_ofList_append
{
α
:
Type
u_1}
{
w
:
Word
α
}
{
xs
:
List
α
}
{
n
:
ℕ
}
:
drop
(
n
+
xs
.
length
) (
ofList
xs
++
w
)
=
drop
n
w
source
theorem
Word
.
prefix_drop
{
α
:
Type
u_1}
{
w₁
w₂
:
Word
α
}
{
n
:
ℕ
}
(
h
:
w₁
.
IsPrefix
w₂
)
:
(
drop
n
w₁
)
.
IsPrefix
(
drop
n
w₂
)
source
@[simp]
theorem
Word
.
prefix_refl
{
α
:
Type
u_1}
{
w
:
Word
α
}
:
w
.
IsPrefix
w
source
@[simp]
theorem
Word
.
infix_refl
{
α
:
Type
u_1}
{
w
:
Word
α
}
:
w
.
IsInfix
w
source
@[simp]
theorem
Word
.
nil_prefix
{
α
:
Type
u_1}
{
w
:
Word
α
}
:
nil
.
IsPrefix
w
source
@[simp]
theorem
Word
.
nil_infix
{
α
:
Type
u_1}
{
w
:
Word
α
}
:
nil
.
IsInfix
w
source
@[simp]
theorem
Word
.
zipWith_prefix_append_left
{
α
:
Type
u_1}
{
β
:
Type
u_2}
{
γ
:
Type
u_3}
{
w₁
w₂
:
Word
α
}
{
w₃
:
Word
β
}
{
f
:
α
→
β
→
γ
}
:
(
zipWith
f
w₁
w₃
)
.
IsPrefix
(
zipWith
f
(
w₁
++
w₂
)
w₃
)
source
@[simp]
theorem
Word
.
zipWith_prefix_append_right
{
α
:
Type
u_1}
{
β
:
Type
u_2}
{
γ
:
Type
u_3}
{
w₁
:
Word
α
}
{
w₂
w₃
:
Word
β
}
{
f
:
α
→
β
→
γ
}
:
(
zipWith
f
w₁
w₂
)
.
IsPrefix
(
zipWith
f
w₁
(
w₂
++
w₃
))
source
@[simp]
theorem
Word
.
prefix_append
{
α
:
Type
u_1}
{
w₁
w₂
:
Word
α
}
:
w₁
.
IsPrefix
(
w₁
++
w₂
)
source
theorem
Word
.
prefix_flatten
{
α
:
Type
u_1}
{
W₁
W₂
:
Word
(
Word
α
)
}
(
h
:
W₁
.
IsPrefix
W₂
)
:
W₁
.
flatten
.
IsPrefix
W₂
.
flatten
source
theorem
Word
.
get?_cons
{
α
:
Type
u_1}
{
w
:
Word
α
}
{
x
:
α
}
{
i
:
ℕ
}
:
(
cons
x
w
)
.
get?
i
=
if
i
=
0
then
some
x
else
w
.
get?
(
i
-
1
)
source
theorem
Word
.
mem_of_get?_eq_some
{
α
:
Type
u_1}
{
w
:
Word
α
}
{
i
:
ℕ
}
{
x
:
α
}
(
h
:
w
.
get?
i
=
some
x
)
:
x
∈
w
source
@[simp]
theorem
Word
.
mem_ofList_iff
{
α
:
Type
u_1}
{
xs
:
List
α
}
{
x
:
α
}
:
x
∈
ofList
xs
↔
x
∈
xs
source
@[simp]
theorem
Word
.
mem_append_iff
{
α
:
Type
u_1}
{
w₁
w₂
:
Word
α
}
{
x
:
α
}
:
x
∈
w₁
++
w₂
↔
x
∈
w₁
∨
w₁
.
Finite
∧
x
∈
w₂
source
@[simp]
theorem
Word
.
mem_append_iff'
{
α
:
Type
u_1}
{
w₁
w₂
:
Word
α
}
{
x
:
α
}
:
x
∈
w₁
.
append
w₂
↔
x
∈
w₁
∨
w₁
.
Finite
∧
x
∈
w₂
source
theorem
Word
.
mem_foldr_append_iff_of_finite
{
α
:
Type
u_1}
{
L
:
List
(
Word
α
)
}
{
x
:
α
}
(
h
:
∀
w
∈
L
,
w
.
Finite
)
:
x
∈
List.foldr
append
nil
L
↔
∃
w
∈
L
,
x
∈
w
source
theorem
Word
.
mem_of_mem_take
{
α
:
Type
u_1}
{
w
:
Word
α
}
{
x
:
α
}
{
n
:
ℕ
}
(
h
:
x
∈
take
n
w
)
:
x
∈
w
source
theorem
Word
.
mem_iff_append
{
α
:
Type
u_1}
{
w
:
Word
α
}
{
x
:
α
}
:
x
∈
w
↔
∃ (
xs
:
List
α
) (
w₁
:
Word
α
),
ofList
xs
++
cons
x
w₁
=
w
source
@[simp]
instance
Word
.
finite_append_of
{
α
:
Type
u_1}
{
w₁
w₂
:
Word
α
}
[
h₁
:
w₁
.
Finite
]
[
h₂
:
w₂
.
Finite
]
:
(
w₁
++
w₂
).
Finite
source
@[simp]
instance
Word
.
infinite_append_of_left
{
α
:
Type
u_1}
{
w₁
w₂
:
Word
α
}
[
h
:
w₁
.
Infinite
]
:
(
w₁
++
w₂
).
Infinite
source
@[simp]
instance
Word
.
infinite_append_of_right
{
α
:
Type
u_1}
{
w₁
w₂
:
Word
α
}
[
h
:
w₂
.
Infinite
]
:
(
w₁
++
w₂
).
Infinite
source
@[simp]
theorem
Word
.
finite_append_iff
{
α
:
Type
u_1}
{
w₁
w₂
:
Word
α
}
:
(
w₁
++
w₂
).
Finite
↔
w₁
.
Finite
∧
w₂
.
Finite
source
@[simp]
theorem
Word
.
infinite_append_iff
{
α
:
Type
u_1}
{
w₁
w₂
:
Word
α
}
:
(
w₁
++
w₂
).
Infinite
↔
w₁
.
Infinite
∨
w₂
.
Infinite
source
@[simp]
theorem
Word
.
finite_flatten_ofList_iff
{
α
:
Type
u_1}
{
L
:
List
(
Word
α
)
}
:
(
ofList
L
)
.
flatten
.
Finite
↔
∀
w
∈
L
,
w
.
Finite
source
theorem
Word
.
mem_flatten_iff_of_finite
{
α
:
Type
u_1}
{
W
:
Word
(
Word
α
)
}
{
x
:
α
}
(
h
:
∀
w
∈
W
,
w
.
Finite
)
:
x
∈
W
.
flatten
↔
∃
w
∈
W
,
x
∈
w
source
theorem
Word
.
mem_of_mem_drop
{
α
:
Type
u_1}
{
w
:
Word
α
}
{
x
:
α
}
{
n
:
ℕ
}
(
h
:
x
∈
drop
n
w
)
:
x
∈
w
source
theorem
Word
.
mem_iff_mem_take
{
α
:
Type
u_1}
{
w
:
Word
α
}
{
x
:
α
}
:
x
∈
w
↔
∃ (
n
:
ℕ
),
x
∈
take
n
w
source
@[simp]
theorem
Word
.
mem_zipWith_iff
{
α
:
Type
u_1}
{
β
:
Type
u_2}
{
γ
:
Type
u_3}
{
f
:
α
→
β
→
γ
}
{
w₁
:
Word
α
}
{
w₂
:
Word
β
}
{
x
:
γ
}
:
x
∈
zipWith
f
w₁
w₂
↔
∃ (
i
:
ℕ
) (
h₁
:
∀ (
n
:
ℕ
),
w₁
.
length?
=
some
n
→
i
<
n
) (
h₂
:
∀ (
n
:
ℕ
),
w₂
.
length?
=
some
n
→
i
<
n
),
f
(
w₁
.
get
i
h₁
)
(
w₂
.
get
i
h₂
)
=
x
source
@[simp]
theorem
Word
.
get_mem
{
α
:
Type
u_1}
{
w
:
Word
α
}
{
i
:
ℕ
}
{
h
:
∀ (
n
:
ℕ
),
w
.
length?
=
some
n
→
i
<
n
}
:
w
.
get
i
h
∈
w
source
theorem
Word
.
mem_of_get_eq
{
α
:
Type
u_1}
{
w
:
Word
α
}
{
i
:
ℕ
}
{
x
:
α
}
{
h₁
:
∀ (
n
:
ℕ
),
w
.
length?
=
some
n
→
i
<
n
}
(
h
:
w
.
get
i
h₁
=
x
)
:
x
∈
w
source
theorem
Word
.
flatMap_eq_flatten_map
{
α
:
Type
u_1}
{
β
:
Type
u_2}
{
w
:
Word
α
}
{
f
:
α
→
Word
β
}
:
w
.
flatMap
f
=
(
map
f
w
)
.
flatten
source
theorem
Word
.
flatten_ofList_of_finite
{
α
:
Type
u_1}
{
xs
:
List
(
Word
α
)
}
(
h
:
∀
w
∈
xs
,
w
.
Finite
)
:
(
ofList
xs
)
.
flatten
=
ofList
(
List.flatMap
(fun (
x
:
Word
α
) =>
x
.
toList?
.
get!
)
xs
)
source
@[simp]
theorem
Word
.
map_map
{
α
:
Type
u_1}
{
β
:
Type
u_2}
{
γ
:
Type
u_3}
{
w
:
Word
α
}
{
f
:
α
→
β
}
{
g
:
β
→
γ
}
:
map
g
(
map
f
w
)
=
map
(fun (
x
:
α
) =>
g
(
f
x
)
)
w
source
@[simp]
theorem
Word
.
flatMap_map
{
α
:
Type
u_1}
{
β
:
Type
u_2}
{
γ
:
Type
u_3}
{
w
:
Word
α
}
{
f
:
α
→
β
}
{
g
:
β
→
Word
γ
}
:
(
map
f
w
)
.
flatMap
g
=
w
.
flatMap
fun (
x
:
α
) =>
g
(
f
x
)
source
@[simp]
theorem
Word
.
flatMap_ofList_fun_ofList
{
α
:
Type
u_1}
{
β
:
Type
u_2}
{
xs
:
List
α
}
{
f
:
α
→
List
β
}
:
(
(
ofList
xs
)
.
flatMap
fun (
x
:
α
) =>
ofList
(
f
x
)
)
=
ofList
(
List.flatMap
f
xs
)
source
@[simp]
theorem
Word
.
ofList_prefix_ofSeq_iff
{
α
:
Type
u_1}
{
xs
:
List
α
}
{
a
:
ℕ
→
α
}
:
(
ofList
xs
)
.
IsPrefix
(
ofSeq
a
)
↔
SeqPrefix
xs
a
source
@[simp]
theorem
Word
.
not_ofSeq_prefix_ofList
{
α
:
Type
u_1}
{
xs
:
List
α
}
{
a
:
ℕ
→
α
}
:
¬
(
ofSeq
a
)
.
IsPrefix
(
ofList
xs
)
source
@[simp]
theorem
Word
.
ofSeq_prefix_ofSeq_iff
{
α
:
Type
u_1}
{
a
b
:
ℕ
→
α
}
:
(
ofSeq
a
)
.
IsPrefix
(
ofSeq
b
)
↔
a
=
b
source
@[simp]
theorem
Word
.
ofList_infix_ofSeq_iff
{
α
:
Type
u_1}
{
xs
:
List
α
}
{
a
:
ℕ
→
α
}
:
(
ofList
xs
)
.
IsInfix
(
ofSeq
a
)
↔
SeqInfix
xs
a
source
@[simp]
theorem
Word
.
not_ofSeq_infix_ofList
{
α
:
Type
u_1}
{
xs
:
List
α
}
{
a
:
ℕ
→
α
}
:
¬
(
ofSeq
a
)
.
IsInfix
(
ofList
xs
)
source
@[simp]
theorem
Word
.
ofSeq_infix_ofSeq_iff
{
α
:
Type
u_1}
{
a
b
:
ℕ
→
α
}
:
(
ofSeq
a
)
.
IsInfix
(
ofSeq
b
)
↔
∃ (
n
:
ℕ
),
a
=
fun (
x
:
ℕ
) =>
b
(
x
+
n
)
source
theorem
Word
.
batches_step
{
α
:
Type
u_1}
{
w
:
Word
α
}
{
n
:
ℕ
}
:
w
.
batches
n
=
if
n
=
0
∨
∃ (
k
:
ℕ
),
w
.
length?
=
some
k
∧
k
<
n
then
nil
else
cons
(
take
n
w
)
(
(
drop
n
w
)
.
batches
n
)
source
@[simp]
theorem
Word
.
flatMap_nil
{
α
:
Type
u_1}
{
β
:
Type
u_2}
{
f
:
α
→
Word
β
}
:
nil
.
flatMap
f
=
nil
source
@[simp]
theorem
Word
.
flatMap_cons
{
α
:
Type
u_1}
{
β
:
Type
u_2}
{
w
:
Word
α
}
{
f
:
α
→
Word
β
}
{
x
:
α
}
:
(
cons
x
w
)
.
flatMap
f
=
f
x
++
w
.
flatMap
f
source
@[simp]
theorem
Word
.
mk_eq_ofGet?_self_simp
{
α
:
Type
u_1}
{
f
:
ℕ
→
Option
α
}
{
wf
:
∀ (
i
:
ℕ
),
f
i
=
none
→
∀ (
n
:
ℕ
),
i
<
n
→
f
n
=
none
}
:
{
get?
:=
f
,
wf
:=
wf
}
=
ofGet?
f
↔
True
source
theorem
Word
.
append_eq_ofGet?
{
α
:
Type
u_1}
{
w₁
w₂
:
Word
α
}
:
w₁
.
append
w₂
=
ofGet?
(
append'
w₁
.
get?
w₂
.
get?
)
source
theorem
Word
.
zipWith_eq_ofGet?
{
α
:
Type
u_1}
{
β
:
Type
u_2}
{
γ
:
Type
u_3}
{
f
:
α
→
β
→
γ
}
{
w₁
:
Word
α
}
{
w₂
:
Word
β
}
:
zipWith
f
w₁
w₂
=
ofGet?
fun (
i
:
ℕ
) =>
match
w₁
.
get?
i
,
w₂
.
get?
i
with |
some
x
,
some
y
=>
some
(
f
x
y
)
|
x
,
x_1
=>
none