4. Data Structures
-
LaPToP.DataStructures.Str[complete] -
LaPToP.DataStructures.Str.nil[complete] -
LaPToP.DataStructures.Str.item[complete] -
LaPToP.DataStructures.Str.len[complete]
Hehner treats finite sequences uniformly (often called strings or lists). Concatenation, length, and indexing are the primitive operations; many program specifications are expressed directly in this theory.
"Bunches are uncontained collections and sets are contained collections.
Similarly, strings are uncontained sequences and lists are contained
sequences." A string of items of type \alpha is modelled as a Lean
List α (Str α): \mathit{nil} is [], a one-item string i is [i],
join S; T is S ++ T, and the length \leftrightarrow S is
Str.len S, valued in the extended naturals like the book's. Only finite
strings are modelled, so the book's provisos \leftrightarrow S < \infty
hold automatically.
Lean code for Definition4.1●4 definitions
Associated Lean declarations
-
LaPToP.DataStructures.Str[complete]
-
LaPToP.DataStructures.Str.nil[complete]
-
LaPToP.DataStructures.Str.item[complete]
-
LaPToP.DataStructures.Str.len[complete]
-
LaPToP.DataStructures.Str[complete] -
LaPToP.DataStructures.Str.nil[complete] -
LaPToP.DataStructures.Str.item[complete] -
LaPToP.DataStructures.Str.len[complete]
-
abbrevdefined in LaPToP/DataStructures/Strings.leancomplete
abbrev LaPToP.DataStructures.Str.{u} (α : Type u) : Type u
abbrev LaPToP.DataStructures.Str.{u} (α : Type u) : Type u
A *string* of items of type `α` (aPToP §2.2), modelled as a list.
-
abbrevdefined in LaPToP/DataStructures/Strings.leancomplete
abbrev LaPToP.DataStructures.Str.nil.{u} {α : Type u} : LaPToP.DataStructures.Str α
abbrev LaPToP.DataStructures.Str.nil.{u} {α : Type u} : LaPToP.DataStructures.Str α
`nil`, the empty string.
-
abbrevdefined in LaPToP/DataStructures/Strings.leancomplete
abbrev LaPToP.DataStructures.Str.item.{u} {α : Type u} (i : α) : LaPToP.DataStructures.Str α
abbrev LaPToP.DataStructures.Str.item.{u} {α : Type u} (i : α) : LaPToP.DataStructures.Str α
The one-item string consisting of the item `i`; the book writes it just `i`.
-
defdefined in LaPToP/DataStructures/Strings.leancomplete
def LaPToP.DataStructures.Str.len.{u} {α : Type u} (S : LaPToP.DataStructures.Str α) : ℕ∞
def LaPToP.DataStructures.Str.len.{u} {α : Type u} (S : LaPToP.DataStructures.Str α) : ℕ∞
`↔S`, the length of a string, as an extended natural number (the book's lengths live in `xnat`).
-
list_append_nil[complete] -
LaPToP.DataStructures.Str.append_nil[complete]
Appending the empty list on the right is an identity:
xs \mathbin{+\hspace{-0.4em}+} [\,] = xs.
This is the first identity for Definition 4.1.
Lean code for Theorem4.2●1 theorem
Associated Lean declarations
-
LaPToP.DataStructures.Str.append_nil[complete]
-
LaPToP.DataStructures.Str.append_nil[complete]
-
theoremdefined in LaPToP/DataStructures/Strings.leancomplete
theorem LaPToP.DataStructures.Str.append_nil.{u} {α : Type u} (S : LaPToP.DataStructures.Str α) : S ++ LaPToP.DataStructures.Str.nil = S
theorem LaPToP.DataStructures.Str.append_nil.{u} {α : Type u} (S : LaPToP.DataStructures.Str α) : S ++ LaPToP.DataStructures.Str.nil = S
`S; nil = S` (identity, left equation).
By the definition of list append / List.concat.
Lean code for Theorem4.2
Associated Lean declarations
-
list_append_nil[complete]
-
list_append_nil[complete]
theorem list_append_nil (xs : List α) :
xs ++ ([] : List α) = xs := α:Type u_1xs:List α⊢ xs ++ [] = xs
All goals completed! 🐙
-
LaPToP.DataStructures.Str.at[complete] -
LaPToP.DataStructures.Str.sub[complete] -
LaPToP.DataStructures.Str.copies[complete] -
LaPToP.DataStructures.Str.star[complete] -
LaPToP.DataStructures.Str.update[complete] -
LaPToP.DataStructures.Str.interval[complete]
The syntax of strings beyond join and length: S\,n is item n of S
(indexing from 0: "the index of an item is the number of items that precede
it"); S\,T for a string of indexes T selects a whole string of items, as in
(3; 5; 7; 9)\,(2; 1; 2) = 7; 5; 7; n*S is n copies of S joined
together; *S is the bunch of all such copies; S \triangleleft n \triangleright i
("S but at n is i") replaces the item at index n; and x;..y is the
string x; x+1; \ldots; y-1. The book leaves S\,n unspecified for an index
out of range; the Lean model returns default there. Extends
Definition 4.1.
Lean code for Definition4.3●6 definitions
Associated Lean declarations
-
LaPToP.DataStructures.Str.at[complete]
-
LaPToP.DataStructures.Str.sub[complete]
-
LaPToP.DataStructures.Str.copies[complete]
-
LaPToP.DataStructures.Str.star[complete]
-
LaPToP.DataStructures.Str.update[complete]
-
LaPToP.DataStructures.Str.interval[complete]
-
LaPToP.DataStructures.Str.at[complete] -
LaPToP.DataStructures.Str.sub[complete] -
LaPToP.DataStructures.Str.copies[complete] -
LaPToP.DataStructures.Str.star[complete] -
LaPToP.DataStructures.Str.update[complete] -
LaPToP.DataStructures.Str.interval[complete]
-
defdefined in LaPToP/DataStructures/Strings.leancomplete
def LaPToP.DataStructures.Str.at.{u} {α : Type u} [Inhabited α] (S : LaPToP.DataStructures.Str α) (n : ℕ) : α
def LaPToP.DataStructures.Str.at.{u} {α : Type u} [Inhabited α] (S : LaPToP.DataStructures.Str α) (n : ℕ) : α
`S n`, item `n` of `S`; indexes count the items that precede an item, so they start at `0`. Out of range the book leaves the value unspecified; we return `default`.
-
defdefined in LaPToP/DataStructures/Strings.leancomplete
def LaPToP.DataStructures.Str.sub.{u} {α : Type u} [Inhabited α] (S : LaPToP.DataStructures.Str α) (T : LaPToP.DataStructures.Str ℕ) : LaPToP.DataStructures.Str α
def LaPToP.DataStructures.Str.sub.{u} {α : Type u} [Inhabited α] (S : LaPToP.DataStructures.Str α) (T : LaPToP.DataStructures.Str ℕ) : LaPToP.DataStructures.Str α
`S T` for a string of indexes `T`: the string of the items of `S` at those indexes, e.g. `(3; 5; 7; 9) (2; 1; 2) = 7; 5; 7`.
-
defdefined in LaPToP/DataStructures/Strings.leancomplete
def LaPToP.DataStructures.Str.copies.{u} {α : Type u} (n : ℕ) (S : LaPToP.DataStructures.Str α) : LaPToP.DataStructures.Str α
def LaPToP.DataStructures.Str.copies.{u} {α : Type u} (n : ℕ) (S : LaPToP.DataStructures.Str α) : LaPToP.DataStructures.Str α
`n*S`, `n` copies of `S` joined together, e.g. `3*(0; 1) = 0; 1; 0; 1; 0; 1`.
-
defdefined in LaPToP/DataStructures/Strings.leancomplete
def LaPToP.DataStructures.Str.star.{u} {α : Type u} (S : LaPToP.DataStructures.Str α) : Set (LaPToP.DataStructures.Str α)
def LaPToP.DataStructures.Str.star.{u} {α : Type u} (S : LaPToP.DataStructures.Str α) : Set (LaPToP.DataStructures.Str α)
`*S`, the bunch of all strings formed by joining any number of copies of `S`: `*(0; 1) = nil, 0;1, 0;1;0;1, ...`.
-
defdefined in LaPToP/DataStructures/Strings.leancomplete
def LaPToP.DataStructures.Str.update.{u} {α : Type u} (S : LaPToP.DataStructures.Str α) (n : ℕ) (i : α) : LaPToP.DataStructures.Str α
def LaPToP.DataStructures.Str.update.{u} {α : Type u} (S : LaPToP.DataStructures.Str α) (n : ℕ) (i : α) : LaPToP.DataStructures.Str α
`S⊲n⊳i`, "`S` but at `n` is `i`": the string like `S` except that the item at index `n` is `i`.
-
defdefined in LaPToP/DataStructures/Strings.leancomplete
def LaPToP.DataStructures.Str.interval (x y : ℤ) : LaPToP.DataStructures.Str ℤ
def LaPToP.DataStructures.Str.interval (x y : ℤ) : LaPToP.DataStructures.Str ℤ
`x;..y`, "`x` to `y`": the string `x; x+1; ...; y-1` (empty unless `x < y`).
-
LaPToP.DataStructures.Str.append_nil[complete] -
LaPToP.DataStructures.Str.nil_append[complete] -
LaPToP.DataStructures.Str.append_assoc[complete] -
LaPToP.DataStructures.Str.len_nil[complete] -
LaPToP.DataStructures.Str.len_item[complete] -
LaPToP.DataStructures.Str.len_append[complete] -
LaPToP.DataStructures.Str.append_item_append_inj[complete]
The join and length axioms of String Theory:
S; \mathit{nil} = S = \mathit{nil}; S (identity),
S; (T; U) = (S; T); U (associativity),
\leftrightarrow\mathit{nil} = 0 and \leftrightarrow i = 1 (base),
\leftrightarrow(S; T) = \leftrightarrow S + \leftrightarrow T, and
(i = j) = (S; i; T = S; j; T).
Uses Definition 4.1; the first identity is Theorem 4.2.
Lean code for Theorem4.4●7 theorems
Associated Lean declarations
-
LaPToP.DataStructures.Str.append_nil[complete]
-
LaPToP.DataStructures.Str.nil_append[complete]
-
LaPToP.DataStructures.Str.append_assoc[complete]
-
LaPToP.DataStructures.Str.len_nil[complete]
-
LaPToP.DataStructures.Str.len_item[complete]
-
LaPToP.DataStructures.Str.len_append[complete]
-
LaPToP.DataStructures.Str.append_item_append_inj[complete]
-
LaPToP.DataStructures.Str.append_nil[complete] -
LaPToP.DataStructures.Str.nil_append[complete] -
LaPToP.DataStructures.Str.append_assoc[complete] -
LaPToP.DataStructures.Str.len_nil[complete] -
LaPToP.DataStructures.Str.len_item[complete] -
LaPToP.DataStructures.Str.len_append[complete] -
LaPToP.DataStructures.Str.append_item_append_inj[complete]
-
theoremdefined in LaPToP/DataStructures/Strings.leancomplete
theorem LaPToP.DataStructures.Str.append_nil.{u} {α : Type u} (S : LaPToP.DataStructures.Str α) : S ++ LaPToP.DataStructures.Str.nil = S
theorem LaPToP.DataStructures.Str.append_nil.{u} {α : Type u} (S : LaPToP.DataStructures.Str α) : S ++ LaPToP.DataStructures.Str.nil = S
`S; nil = S` (identity, left equation).
-
theoremdefined in LaPToP/DataStructures/Strings.leancomplete
theorem LaPToP.DataStructures.Str.nil_append.{u} {α : Type u} (S : LaPToP.DataStructures.Str α) : LaPToP.DataStructures.Str.nil ++ S = S
theorem LaPToP.DataStructures.Str.nil_append.{u} {α : Type u} (S : LaPToP.DataStructures.Str α) : LaPToP.DataStructures.Str.nil ++ S = S
`S = nil; S` (identity, right equation).
-
theoremdefined in LaPToP/DataStructures/Strings.leancomplete
theorem LaPToP.DataStructures.Str.append_assoc.{u} {α : Type u} (S T U : LaPToP.DataStructures.Str α) : S ++ (T ++ U) = S ++ T ++ U
theorem LaPToP.DataStructures.Str.append_assoc.{u} {α : Type u} (S T U : LaPToP.DataStructures.Str α) : S ++ (T ++ U) = S ++ T ++ U
`S; (T; U) = (S; T); U` (associativity).
-
theoremdefined in LaPToP/DataStructures/Strings.leancomplete
theorem LaPToP.DataStructures.Str.len_nil.{u} {α : Type u} : LaPToP.DataStructures.Str.nil.len = 0
theorem LaPToP.DataStructures.Str.len_nil.{u} {α : Type u} : LaPToP.DataStructures.Str.nil.len = 0
`↔nil = 0` (base).
-
theoremdefined in LaPToP/DataStructures/Strings.leancomplete
theorem LaPToP.DataStructures.Str.len_item.{u} {α : Type u} (i : α) : (LaPToP.DataStructures.Str.item i).len = 1
theorem LaPToP.DataStructures.Str.len_item.{u} {α : Type u} (i : α) : (LaPToP.DataStructures.Str.item i).len = 1
`↔i = 1` (base).
-
theoremdefined in LaPToP/DataStructures/Strings.leancomplete
theorem LaPToP.DataStructures.Str.len_append.{u} {α : Type u} (S T : LaPToP.DataStructures.Str α) : (S ++ T).len = S.len + T.len
theorem LaPToP.DataStructures.Str.len_append.{u} {α : Type u} (S T : LaPToP.DataStructures.Str α) : (S ++ T).len = S.len + T.len
`↔(S; T) = ↔S + ↔T`.
-
theoremdefined in LaPToP/DataStructures/Strings.leancomplete
theorem LaPToP.DataStructures.Str.append_item_append_inj.{u} {α : Type u} (S T : LaPToP.DataStructures.Str α) (i j : α) : i = j ↔ S ++ LaPToP.DataStructures.Str.item i ++ T = S ++ LaPToP.DataStructures.Str.item j ++ T
theorem LaPToP.DataStructures.Str.append_item_append_inj.{u} {α : Type u} (S T : LaPToP.DataStructures.Str α) (i j : α) : i = j ↔ S ++ LaPToP.DataStructures.Str.item i ++ T = S ++ LaPToP.DataStructures.Str.item j ++ T
`i = j = (S; i; T = S; j; T)`: equal strings have equal items at each index. (Listed with the order axioms in the book; it needs no order.)
List.append_nil, List.nil_append, List.append_assoc, List.length_append,
and cancellation of a common prefix and suffix.
-
LaPToP.DataStructures.Str.sub_nil[complete] -
LaPToP.DataStructures.Str.at_append_item_append[complete] -
LaPToP.DataStructures.Str.sub_append[complete] -
LaPToP.DataStructures.Str.sub_sub[complete] -
LaPToP.DataStructures.Str.at_map_of_lt[complete]
The indexing axioms:
S\,\mathit{nil} = \mathit{nil},
(S; i; T)\,(\leftrightarrow S) = i,
S\,(T; U) = S\,T; S\,U, and
S\,(T\,U) = (S\,T)\,U.
The last law is stated for U a string of indexes of T, since out-of-range
indexes are unspecified in the book. Uses Definition 4.3.
Lean code for Theorem4.5●5 theorems
Associated Lean declarations
-
LaPToP.DataStructures.Str.sub_nil[complete]
-
LaPToP.DataStructures.Str.at_append_item_append[complete]
-
LaPToP.DataStructures.Str.sub_append[complete]
-
LaPToP.DataStructures.Str.sub_sub[complete]
-
LaPToP.DataStructures.Str.at_map_of_lt[complete]
-
LaPToP.DataStructures.Str.sub_nil[complete] -
LaPToP.DataStructures.Str.at_append_item_append[complete] -
LaPToP.DataStructures.Str.sub_append[complete] -
LaPToP.DataStructures.Str.sub_sub[complete] -
LaPToP.DataStructures.Str.at_map_of_lt[complete]
-
theoremdefined in LaPToP/DataStructures/Strings.leancomplete
theorem LaPToP.DataStructures.Str.sub_nil.{u} {α : Type u} [Inhabited α] (S : LaPToP.DataStructures.Str α) : S.sub LaPToP.DataStructures.Str.nil = LaPToP.DataStructures.Str.nil
theorem LaPToP.DataStructures.Str.sub_nil.{u} {α : Type u} [Inhabited α] (S : LaPToP.DataStructures.Str α) : S.sub LaPToP.DataStructures.Str.nil = LaPToP.DataStructures.Str.nil
`S nil = nil`.
-
theoremdefined in LaPToP/DataStructures/Strings.leancomplete
theorem LaPToP.DataStructures.Str.at_append_item_append.{u} {α : Type u} [Inhabited α] (S T : LaPToP.DataStructures.Str α) (i : α) : (S ++ LaPToP.DataStructures.Str.item i ++ T).at (List.length S) = i
theorem LaPToP.DataStructures.Str.at_append_item_append.{u} {α : Type u} [Inhabited α] (S T : LaPToP.DataStructures.Str α) (i : α) : (S ++ LaPToP.DataStructures.Str.item i ++ T).at (List.length S) = i
`(S; i; T) ↔S = i`: the item at index `↔S` of `S; i; T` is `i`. (The book's proviso `↔S < ∞` holds automatically for finite strings.)
-
theoremdefined in LaPToP/DataStructures/Strings.leancomplete
theorem LaPToP.DataStructures.Str.sub_append.{u} {α : Type u} [Inhabited α] (S : LaPToP.DataStructures.Str α) (T U : LaPToP.DataStructures.Str ℕ) : S.sub (T ++ U) = S.sub T ++ S.sub U
theorem LaPToP.DataStructures.Str.sub_append.{u} {α : Type u} [Inhabited α] (S : LaPToP.DataStructures.Str α) (T U : LaPToP.DataStructures.Str ℕ) : S.sub (T ++ U) = S.sub T ++ S.sub U
`S (T; U) = S T; S U`: indexing distributes over join of index strings.
-
theoremdefined in LaPToP/DataStructures/Strings.leancomplete
theorem LaPToP.DataStructures.Str.sub_sub.{u} {α : Type u} [Inhabited α] (S : LaPToP.DataStructures.Str α) (T U : LaPToP.DataStructures.Str ℕ) (hU : ∀ k ∈ U, k < List.length T) : S.sub (T.sub U) = (S.sub T).sub U
theorem LaPToP.DataStructures.Str.sub_sub.{u} {α : Type u} [Inhabited α] (S : LaPToP.DataStructures.Str α) (T U : LaPToP.DataStructures.Str ℕ) (hU : ∀ k ∈ U, k < List.length T) : S.sub (T.sub U) = (S.sub T).sub U
`S (T U) = (S T) U`, for `U` a string of indexes of `T`.
-
theoremdefined in LaPToP/DataStructures/Strings.leancomplete
theorem LaPToP.DataStructures.Str.at_map_of_lt.{u, v} {α : Type u} [Inhabited α] {β : Type v} [Inhabited β] (f : α → β) (T : LaPToP.DataStructures.Str α) {k : ℕ} (hk : k < List.length T) : LaPToP.DataStructures.Str.at (List.map f T) k = f (T.at k)
theorem LaPToP.DataStructures.Str.at_map_of_lt.{u, v} {α : Type u} [Inhabited α] {β : Type v} [Inhabited β] (f : α → β) (T : LaPToP.DataStructures.Str α) {k : ℕ} (hk : k < List.length T) : LaPToP.DataStructures.Str.at (List.map f T) k = f (T.at k)
Indexing a mapped string at an in-range index.
Indexing is List.getD; the laws are List.map_append, List.map_map, and
the getElem? lemmas for appending and mapping.
-
LaPToP.DataStructures.Str.copies_zero[complete] -
LaPToP.DataStructures.Str.copies_succ[complete] -
LaPToP.DataStructures.Str.copies_three_example[complete] -
LaPToP.DataStructures.Str.mem_star[complete] -
LaPToP.DataStructures.Str.update_append_item_append[complete] -
LaPToP.DataStructures.Str.update_example[complete]
Copies and update:
0*S = \mathit{nil}, (n+1)*S = n*S; S, and
(S; i; T) \triangleleft \leftrightarrow S \triangleright j = S; j; T,
together with the book's examples 3*(0; 1) = 0; 1; 0; 1; 0; 1 and
3; 5; 9 \triangleleft 2 \triangleright 8 = 3; 5; 8, and the membership
condition for *S. The copy count is a natural number here (the book allows
\infty). Uses Definition 4.3.
Lean code for Theorem4.6●6 theorems
Associated Lean declarations
-
LaPToP.DataStructures.Str.copies_zero[complete]
-
LaPToP.DataStructures.Str.copies_succ[complete]
-
LaPToP.DataStructures.Str.copies_three_example[complete]
-
LaPToP.DataStructures.Str.mem_star[complete]
-
LaPToP.DataStructures.Str.update_append_item_append[complete]
-
LaPToP.DataStructures.Str.update_example[complete]
-
LaPToP.DataStructures.Str.copies_zero[complete] -
LaPToP.DataStructures.Str.copies_succ[complete] -
LaPToP.DataStructures.Str.copies_three_example[complete] -
LaPToP.DataStructures.Str.mem_star[complete] -
LaPToP.DataStructures.Str.update_append_item_append[complete] -
LaPToP.DataStructures.Str.update_example[complete]
-
theoremdefined in LaPToP/DataStructures/Strings.leancomplete
theorem LaPToP.DataStructures.Str.copies_zero.{u} {α : Type u} (S : LaPToP.DataStructures.Str α) : LaPToP.DataStructures.Str.copies 0 S = LaPToP.DataStructures.Str.nil
theorem LaPToP.DataStructures.Str.copies_zero.{u} {α : Type u} (S : LaPToP.DataStructures.Str α) : LaPToP.DataStructures.Str.copies 0 S = LaPToP.DataStructures.Str.nil
`0*S = nil`.
-
theoremdefined in LaPToP/DataStructures/Strings.leancomplete
theorem LaPToP.DataStructures.Str.copies_succ.{u} {α : Type u} (S : LaPToP.DataStructures.Str α) (n : ℕ) : LaPToP.DataStructures.Str.copies (n + 1) S = LaPToP.DataStructures.Str.copies n S ++ S
theorem LaPToP.DataStructures.Str.copies_succ.{u} {α : Type u} (S : LaPToP.DataStructures.Str α) (n : ℕ) : LaPToP.DataStructures.Str.copies (n + 1) S = LaPToP.DataStructures.Str.copies n S ++ S
`(n+1)*S = n*S; S`.
-
theoremdefined in LaPToP/DataStructures/Strings.leancomplete
theorem LaPToP.DataStructures.Str.copies_three_example : LaPToP.DataStructures.Str.copies 3 [0, 1] = [0, 1, 0, 1, 0, 1]
theorem LaPToP.DataStructures.Str.copies_three_example : LaPToP.DataStructures.Str.copies 3 [0, 1] = [0, 1, 0, 1, 0, 1]
`3*(0; 1) = 0; 1; 0; 1; 0; 1`, the book's example.
-
theoremdefined in LaPToP/DataStructures/Strings.leancomplete
theorem LaPToP.DataStructures.Str.mem_star.{u} {α : Type u} (S T : LaPToP.DataStructures.Str α) : T ∈ S.star ↔ ∃ n, LaPToP.DataStructures.Str.copies n S = T
theorem LaPToP.DataStructures.Str.mem_star.{u} {α : Type u} (S T : LaPToP.DataStructures.Str α) : T ∈ S.star ↔ ∃ n, LaPToP.DataStructures.Str.copies n S = T
Membership in `*S`: the strings `n*S`.
-
theoremdefined in LaPToP/DataStructures/Strings.leancomplete
theorem LaPToP.DataStructures.Str.update_append_item_append.{u} {α : Type u} (S T : LaPToP.DataStructures.Str α) (i j : α) : (S ++ LaPToP.DataStructures.Str.item i ++ T).update (List.length S) j = S ++ LaPToP.DataStructures.Str.item j ++ T
theorem LaPToP.DataStructures.Str.update_append_item_append.{u} {α : Type u} (S T : LaPToP.DataStructures.Str α) (i j : α) : (S ++ LaPToP.DataStructures.Str.item i ++ T).update (List.length S) j = S ++ LaPToP.DataStructures.Str.item j ++ T
`(S; i; T)⊲↔S⊳j = S; j; T`: updating at index `↔S` replaces `i` by `j`.
-
theoremdefined in LaPToP/DataStructures/Strings.leancomplete
theorem LaPToP.DataStructures.Str.update_example : LaPToP.DataStructures.Str.update [3, 5, 9] 2 8 = [3, 5, 8]
theorem LaPToP.DataStructures.Str.update_example : LaPToP.DataStructures.Str.update [3, 5, 9] 2 8 = [3, 5, 8]
`3; 5; 9⊲2⊳8 = 3; 5; 8`, the book's example.
List.replicate_succ' with List.flatten_append; List.set_append_right for
the update law; the examples are by evaluation.
-
LaPToP.DataStructures.Str.nil_le[complete] -
LaPToP.DataStructures.Str.lt_append_item_append[complete] -
LaPToP.DataStructures.Str.append_lt_append_of_lt[complete]
"The order of two strings is determined by the items at the first index where
they differ. ... If there is no index where they differ, the shorter string
comes before the longer one." The axioms:
\mathit{nil} \le S < S; i; T and
i < j \Rightarrow S; i; T < S; j; U.
Lean's lexicographic order on lists is exactly this ordering. Uses
Definition 4.1.
Lean code for Theorem4.7●3 theorems
Associated Lean declarations
-
LaPToP.DataStructures.Str.nil_le[complete]
-
LaPToP.DataStructures.Str.lt_append_item_append[complete]
-
LaPToP.DataStructures.Str.append_lt_append_of_lt[complete]
-
LaPToP.DataStructures.Str.nil_le[complete] -
LaPToP.DataStructures.Str.lt_append_item_append[complete] -
LaPToP.DataStructures.Str.append_lt_append_of_lt[complete]
-
theoremdefined in LaPToP/DataStructures/Strings.leancomplete
theorem LaPToP.DataStructures.Str.nil_le.{u} {α : Type u} [LT α] (S : LaPToP.DataStructures.Str α) : LaPToP.DataStructures.Str.nil ≤ S
theorem LaPToP.DataStructures.Str.nil_le.{u} {α : Type u} [LT α] (S : LaPToP.DataStructures.Str α) : LaPToP.DataStructures.Str.nil ≤ S
`nil ≤ S`.
-
theoremdefined in LaPToP/DataStructures/Strings.leancomplete
theorem LaPToP.DataStructures.Str.lt_append_item_append.{u} {α : Type u} [LT α] (S T : LaPToP.DataStructures.Str α) (i : α) : S < S ++ LaPToP.DataStructures.Str.item i ++ T
theorem LaPToP.DataStructures.Str.lt_append_item_append.{u} {α : Type u} [LT α] (S T : LaPToP.DataStructures.Str α) (i : α) : S < S ++ LaPToP.DataStructures.Str.item i ++ T
`S < S; i; T`: a proper prefix comes first.
-
theoremdefined in LaPToP/DataStructures/Strings.leancomplete
theorem LaPToP.DataStructures.Str.append_lt_append_of_lt.{u} {α : Type u} [LT α] (S T U : LaPToP.DataStructures.Str α) (i j : α) (h : i < j) : S ++ LaPToP.DataStructures.Str.item i ++ T < S ++ LaPToP.DataStructures.Str.item j ++ U
theorem LaPToP.DataStructures.Str.append_lt_append_of_lt.{u} {α : Type u} [LT α] (S T U : LaPToP.DataStructures.Str α) (i j : α) (h : i < j) : S ++ LaPToP.DataStructures.Str.item i ++ T < S ++ LaPToP.DataStructures.Str.item j ++ U
`i < j ⇒ S; i; T < S; j; U`: strings are ordered by the first differing item.
Induction on the common prefix S, using List.nil_lt_cons and
List.cons_lt_cons_iff.
-
LaPToP.DataStructures.Str.len_interval[complete] -
LaPToP.DataStructures.Str.interval_self[complete] -
LaPToP.DataStructures.Str.interval_succ[complete] -
LaPToP.DataStructures.Str.interval_append_interval[complete] -
LaPToP.DataStructures.Str.mem_interval[complete]
The string interval x;..y ("x to y", same pronunciation as the bunch
x,..y; x included, y excluded):
\leftrightarrow(x;..y) = y - x,
x;..x = \mathit{nil}, x;..x+1 = x, and
(x;..y); (y;..z) = x;..z for x \le y \le z;
its items are exactly the integers i with x \le i < y. As for the bunch
interval, the length law uses the difference truncated at 0. Uses
Definition 4.3 and Definition 2.12.
Lean code for Theorem4.8●5 theorems
Associated Lean declarations
-
LaPToP.DataStructures.Str.len_interval[complete]
-
LaPToP.DataStructures.Str.interval_self[complete]
-
LaPToP.DataStructures.Str.interval_succ[complete]
-
LaPToP.DataStructures.Str.interval_append_interval[complete]
-
LaPToP.DataStructures.Str.mem_interval[complete]
-
LaPToP.DataStructures.Str.len_interval[complete] -
LaPToP.DataStructures.Str.interval_self[complete] -
LaPToP.DataStructures.Str.interval_succ[complete] -
LaPToP.DataStructures.Str.interval_append_interval[complete] -
LaPToP.DataStructures.Str.mem_interval[complete]
-
theoremdefined in LaPToP/DataStructures/Strings.leancomplete
theorem LaPToP.DataStructures.Str.len_interval (x y : ℤ) : (LaPToP.DataStructures.Str.interval x y).len = ↑(y - x).toNat
theorem LaPToP.DataStructures.Str.len_interval (x y : ℤ) : (LaPToP.DataStructures.Str.interval x y).len = ↑(y - x).toNat
`↔(x;..y) = y – x` (with the difference truncated at `0`; for `x ≤ y` it is exactly `y – x`).
-
theoremdefined in LaPToP/DataStructures/Strings.leancomplete
theorem LaPToP.DataStructures.Str.interval_self (x : ℤ) : LaPToP.DataStructures.Str.interval x x = LaPToP.DataStructures.Str.nil
theorem LaPToP.DataStructures.Str.interval_self (x : ℤ) : LaPToP.DataStructures.Str.interval x x = LaPToP.DataStructures.Str.nil
`x;..x = nil`.
-
theoremdefined in LaPToP/DataStructures/Strings.leancomplete
theorem LaPToP.DataStructures.Str.interval_succ (x : ℤ) : LaPToP.DataStructures.Str.interval x (x + 1) = LaPToP.DataStructures.Str.item x
theorem LaPToP.DataStructures.Str.interval_succ (x : ℤ) : LaPToP.DataStructures.Str.interval x (x + 1) = LaPToP.DataStructures.Str.item x
`x;..x+1 = x`.
-
theoremdefined in LaPToP/DataStructures/Strings.leancomplete
theorem LaPToP.DataStructures.Str.interval_append_interval {x y z : ℤ} (hxy : x ≤ y) (hyz : y ≤ z) : LaPToP.DataStructures.Str.interval x y ++ LaPToP.DataStructures.Str.interval y z = LaPToP.DataStructures.Str.interval x z
theorem LaPToP.DataStructures.Str.interval_append_interval {x y z : ℤ} (hxy : x ≤ y) (hyz : y ≤ z) : LaPToP.DataStructures.Str.interval x y ++ LaPToP.DataStructures.Str.interval y z = LaPToP.DataStructures.Str.interval x z
`(x;..y); (y;..z) = x;..z` for `x ≤ y ≤ z`.
-
theoremdefined in LaPToP/DataStructures/Strings.leancomplete
theorem LaPToP.DataStructures.Str.mem_interval (i x y : ℤ) : i ∈ LaPToP.DataStructures.Str.interval x y ↔ x ≤ i ∧ i < y
theorem LaPToP.DataStructures.Str.mem_interval (i x y : ℤ) : i ∈ LaPToP.DataStructures.Str.interval x y ↔ x ≤ i ∧ i < y
The items of `x;..y` are exactly the integers `i` with `x ≤ i < y`.
The interval is List.range shifted by x; the join law is List.range_add
after splitting z - x = (y - x) + (z - y).
-
LaPToP.DataStructures.HList[complete] -
LaPToP.DataStructures.Str.pack[complete] -
LaPToP.DataStructures.HList.contents[complete] -
LaPToP.DataStructures.HList.length[complete] -
LaPToP.DataStructures.HList.domain[complete] -
LaPToP.DataStructures.HList.at[complete] -
LaPToP.DataStructures.HList.comp[complete] -
LaPToP.DataStructures.HList.join[complete] -
LaPToP.DataStructures.HList.modify[complete]
"A list is a contained string." Although the string 0; 1; 2 is not a single
item, the list [0; 1; 2] is. List formation [S] packages a string
(Str.pack); contents \sim L unpackages it (HList.contents); \# L is the
length, \square L = 0,..\# L the domain (a bunch of naturals), L\,n the item
at index n, L\,M composition ("L composed with M": the items of L
at the indexes listed in M), L ;; M join, and n \to i \mid L ("n maps
to i otherwise L") the list like L except that item n is i. Lists
are ordered lexicographically, like strings. In Lean HList α is a one-field
structure around a Str α, exactly as HSet packages a bunch in
Definition 2.1; the operations act on contents via
Definition 4.3.
Lean code for Definition4.9●9 definitions
Associated Lean declarations
-
LaPToP.DataStructures.HList[complete]
-
LaPToP.DataStructures.Str.pack[complete]
-
LaPToP.DataStructures.HList.contents[complete]
-
LaPToP.DataStructures.HList.length[complete]
-
LaPToP.DataStructures.HList.domain[complete]
-
LaPToP.DataStructures.HList.at[complete]
-
LaPToP.DataStructures.HList.comp[complete]
-
LaPToP.DataStructures.HList.join[complete]
-
LaPToP.DataStructures.HList.modify[complete]
-
LaPToP.DataStructures.HList[complete] -
LaPToP.DataStructures.Str.pack[complete] -
LaPToP.DataStructures.HList.contents[complete] -
LaPToP.DataStructures.HList.length[complete] -
LaPToP.DataStructures.HList.domain[complete] -
LaPToP.DataStructures.HList.at[complete] -
LaPToP.DataStructures.HList.comp[complete] -
LaPToP.DataStructures.HList.join[complete] -
LaPToP.DataStructures.HList.modify[complete]
-
structuredefined in LaPToP/DataStructures/Lists.leancomplete
structure LaPToP.DataStructures.HList.{u} (α : Type u) : Type u
structure LaPToP.DataStructures.HList.{u} (α : Type u) : Type u
A Hehner *list* (aPToP §2.3): a string packaged as a single item. The book writes `[S]` for the list containing the string `S` (see `Str.pack`) and `~L` for the contents of the list `L` (see `HList.contents`).
Fields
contents : LaPToP.DataStructures.Str α
`~L`, the contents of the list `L`, a string.
-
defdefined in LaPToP/DataStructures/Lists.leancomplete
def LaPToP.DataStructures.Str.pack.{u} {α : Type u} (S : LaPToP.DataStructures.Str α) : LaPToP.DataStructures.HList α
def LaPToP.DataStructures.Str.pack.{u} {α : Type u} (S : LaPToP.DataStructures.Str α) : LaPToP.DataStructures.HList α
`[S]`, the list containing the string `S` (aPToP §2.3).
-
abbrevdefined in LaPToP/DataStructures/Lists.leancomplete
abbrev LaPToP.DataStructures.HList.contents.{u} {α : Type u} (self : LaPToP.DataStructures.HList α) : LaPToP.DataStructures.Str α
abbrev LaPToP.DataStructures.HList.contents.{u} {α : Type u} (self : LaPToP.DataStructures.HList α) : LaPToP.DataStructures.Str α
`~L`, the contents of the list `L`, a string.
-
defdefined in LaPToP/DataStructures/Lists.leancomplete
def LaPToP.DataStructures.HList.length.{u} {α : Type u} (L : LaPToP.DataStructures.HList α) : ℕ∞
def LaPToP.DataStructures.HList.length.{u} {α : Type u} (L : LaPToP.DataStructures.HList α) : ℕ∞
`#L`, the length of a list: the number of items it contains.
-
defdefined in LaPToP/DataStructures/Lists.leancomplete
def LaPToP.DataStructures.HList.domain.{u} {α : Type u} (L : LaPToP.DataStructures.HList α) : LaPToP.BasicTheories.Bunch ℕ
def LaPToP.DataStructures.HList.domain.{u} {α : Type u} (L : LaPToP.DataStructures.HList α) : LaPToP.BasicTheories.Bunch ℕ
`☐L`, the domain of a list: the bunch of its indexes `0,..#L`.
-
defdefined in LaPToP/DataStructures/Lists.leancomplete
def LaPToP.DataStructures.HList.at.{u} {α : Type u} [Inhabited α] (L : LaPToP.DataStructures.HList α) (n : ℕ) : α
def LaPToP.DataStructures.HList.at.{u} {α : Type u} [Inhabited α] (L : LaPToP.DataStructures.HList α) (n : ℕ) : α
`L n`, the item of `L` at index `n` (indexing from `0`).
-
defdefined in LaPToP/DataStructures/Lists.leancomplete
def LaPToP.DataStructures.HList.comp.{u} {α : Type u} [Inhabited α] (L : LaPToP.DataStructures.HList α) (M : LaPToP.DataStructures.HList ℕ) : LaPToP.DataStructures.HList α
def LaPToP.DataStructures.HList.comp.{u} {α : Type u} [Inhabited α] (L : LaPToP.DataStructures.HList α) (M : LaPToP.DataStructures.HList ℕ) : LaPToP.DataStructures.HList α
`L M`, list composition: the list of items of `L` at the indexes listed in `M`, e.g. `[3; 5; 7; 4] [2; 1; 2] = [7; 5; 7]`.
-
defdefined in LaPToP/DataStructures/Lists.leancomplete
def LaPToP.DataStructures.HList.join.{u} {α : Type u} (L M : LaPToP.DataStructures.HList α) : LaPToP.DataStructures.HList α
def LaPToP.DataStructures.HList.join.{u} {α : Type u} (L M : LaPToP.DataStructures.HList α) : LaPToP.DataStructures.HList α
`L ;; M`, list join.
-
defdefined in LaPToP/DataStructures/Lists.leancomplete
def LaPToP.DataStructures.HList.modify.{u} {α : Type u} (n : ℕ) (i : α) (L : LaPToP.DataStructures.HList α) : LaPToP.DataStructures.HList α
def LaPToP.DataStructures.HList.modify.{u} {α : Type u} (n : ℕ) (i : α) (L : LaPToP.DataStructures.HList α) : LaPToP.DataStructures.HList α
`n→i | L`, "`n` maps to `i` otherwise `L`": the list like `L` except that item `n` is `i`.
-
LaPToP.DataStructures.HList.pack_contents[complete] -
LaPToP.DataStructures.HList.contents_pack[complete] -
LaPToP.DataStructures.HList.length_pack[complete] -
LaPToP.DataStructures.HList.domain_eq[complete] -
LaPToP.DataStructures.HList.image_domain[complete] -
LaPToP.DataStructures.HList.pack_join_pack[complete] -
LaPToP.DataStructures.HList.at_pack[complete] -
LaPToP.DataStructures.HList.pack_comp_pack[complete] -
LaPToP.DataStructures.HList.modify_pack[complete] -
LaPToP.DataStructures.HList.pack_inj[complete] -
LaPToP.DataStructures.HList.pack_lt_pack[complete] -
LaPToP.DataStructures.HList.image_pack_subset_image_pack[complete] -
LaPToP.DataStructures.Str.pack_injective[complete] -
LaPToP.DataStructures.HList.contents_example[complete] -
LaPToP.DataStructures.HList.length_example[complete] -
LaPToP.DataStructures.HList.at_example[complete] -
LaPToP.DataStructures.HList.comp_example[complete] -
LaPToP.DataStructures.HList.join_example[complete] -
LaPToP.DataStructures.HList.modify_example[complete] -
LaPToP.DataStructures.HList.modify_modify_example[complete] -
LaPToP.DataStructures.HList.modify_swap_example[complete]
Hehner's List Theory axioms, for lists L, strings S, T, an index n of
S, an item i, and bunches of strings A, B:
[\sim L] = L (list formation), \sim[S] = S (contents),
\#[S] = \leftrightarrow S (length), \square L = 0,..\# L (domain),
[S] ;; [T] = [S; T] (join), [S]\,n = S\,n (indexing),
[S]\,[T] = [S\,T] (composition), n \to i \mid [S] = [S \triangleleft n \triangleright i]
(modification), [S] = [T] = (S = T) (equation), [S] < [T] = (S < T) (order),
and [A] : [B] = A : B (inclusion, with [A] the bunch of lists [S] for
S : A). The domain law is stated on the naturals, with a companion reading it
in the integers as the bunch interval Definition 2.12. The remaining
axiom [S] \neq S (structure) is not an equation in the typed model: a list and
its contents have different Lean types, which is exactly the distinction it
records. The book's worked examples (\sim[3;5;7;4], \#[3;5;7;4],
[3;5;7;4]\,2, [3;5;7;4]\,[2;1;2], [3;5;7;4];;[2;1;2],
2 \to 22 \mid [10;..15], and the item swap) are checked by evaluation.
Uses Definition 4.9 and Theorem 4.5.
Lean code for Theorem4.10●21 theorems
Associated Lean declarations
-
LaPToP.DataStructures.HList.pack_contents[complete]
-
LaPToP.DataStructures.HList.contents_pack[complete]
-
LaPToP.DataStructures.HList.length_pack[complete]
-
LaPToP.DataStructures.HList.domain_eq[complete]
-
LaPToP.DataStructures.HList.image_domain[complete]
-
LaPToP.DataStructures.HList.pack_join_pack[complete]
-
LaPToP.DataStructures.HList.at_pack[complete]
-
LaPToP.DataStructures.HList.pack_comp_pack[complete]
-
LaPToP.DataStructures.HList.modify_pack[complete]
-
LaPToP.DataStructures.HList.pack_inj[complete]
-
LaPToP.DataStructures.HList.pack_lt_pack[complete]
-
LaPToP.DataStructures.HList.image_pack_subset_image_pack[complete]
-
LaPToP.DataStructures.Str.pack_injective[complete]
-
LaPToP.DataStructures.HList.contents_example[complete]
-
LaPToP.DataStructures.HList.length_example[complete]
-
LaPToP.DataStructures.HList.at_example[complete]
-
LaPToP.DataStructures.HList.comp_example[complete]
-
LaPToP.DataStructures.HList.join_example[complete]
-
LaPToP.DataStructures.HList.modify_example[complete]
-
LaPToP.DataStructures.HList.modify_modify_example[complete]
-
LaPToP.DataStructures.HList.modify_swap_example[complete]
-
LaPToP.DataStructures.HList.pack_contents[complete] -
LaPToP.DataStructures.HList.contents_pack[complete] -
LaPToP.DataStructures.HList.length_pack[complete] -
LaPToP.DataStructures.HList.domain_eq[complete] -
LaPToP.DataStructures.HList.image_domain[complete] -
LaPToP.DataStructures.HList.pack_join_pack[complete] -
LaPToP.DataStructures.HList.at_pack[complete] -
LaPToP.DataStructures.HList.pack_comp_pack[complete] -
LaPToP.DataStructures.HList.modify_pack[complete] -
LaPToP.DataStructures.HList.pack_inj[complete] -
LaPToP.DataStructures.HList.pack_lt_pack[complete] -
LaPToP.DataStructures.HList.image_pack_subset_image_pack[complete] -
LaPToP.DataStructures.Str.pack_injective[complete] -
LaPToP.DataStructures.HList.contents_example[complete] -
LaPToP.DataStructures.HList.length_example[complete] -
LaPToP.DataStructures.HList.at_example[complete] -
LaPToP.DataStructures.HList.comp_example[complete] -
LaPToP.DataStructures.HList.join_example[complete] -
LaPToP.DataStructures.HList.modify_example[complete] -
LaPToP.DataStructures.HList.modify_modify_example[complete] -
LaPToP.DataStructures.HList.modify_swap_example[complete]
-
theoremdefined in LaPToP/DataStructures/Lists.leancomplete
theorem LaPToP.DataStructures.HList.pack_contents.{u} {α : Type u} (L : LaPToP.DataStructures.HList α) : L.contents.pack = L
theorem LaPToP.DataStructures.HList.pack_contents.{u} {α : Type u} (L : LaPToP.DataStructures.HList α) : L.contents.pack = L
`[~L] = L` (list formation).
-
theoremdefined in LaPToP/DataStructures/Lists.leancomplete
theorem LaPToP.DataStructures.HList.contents_pack.{u} {α : Type u} (S : LaPToP.DataStructures.Str α) : S.pack.contents = S
theorem LaPToP.DataStructures.HList.contents_pack.{u} {α : Type u} (S : LaPToP.DataStructures.Str α) : S.pack.contents = S
`~[S] = S` (contents).
-
theoremdefined in LaPToP/DataStructures/Lists.leancomplete
theorem LaPToP.DataStructures.HList.length_pack.{u} {α : Type u} (S : LaPToP.DataStructures.Str α) : S.pack.length = S.len
theorem LaPToP.DataStructures.HList.length_pack.{u} {α : Type u} (S : LaPToP.DataStructures.Str α) : S.pack.length = S.len
`#[S] = ↔S` (length).
-
theoremdefined in LaPToP/DataStructures/Lists.leancomplete
theorem LaPToP.DataStructures.HList.domain_eq.{u} {α : Type u} (L : LaPToP.DataStructures.HList α) : L.domain = {n | n < List.length L.contents}
theorem LaPToP.DataStructures.HList.domain_eq.{u} {α : Type u} (L : LaPToP.DataStructures.HList α) : L.domain = {n | n < List.length L.contents}
`☐L = 0,..#L` (domain): the indexes of `L` are the naturals below its length.
-
theoremdefined in LaPToP/DataStructures/Lists.leancomplete
theorem LaPToP.DataStructures.HList.image_domain.{u} {α : Type u} (L : LaPToP.DataStructures.HList α) : Nat.cast '' L.domain = LaPToP.BasicTheories.Bunch.interval 0 ↑(List.length L.contents)
theorem LaPToP.DataStructures.HList.image_domain.{u} {α : Type u} (L : LaPToP.DataStructures.HList α) : Nat.cast '' L.domain = LaPToP.BasicTheories.Bunch.interval 0 ↑(List.length L.contents)
The domain, read in the integers, is the bunch interval `0,..#L`.
-
theoremdefined in LaPToP/DataStructures/Lists.leancomplete
theorem LaPToP.DataStructures.HList.pack_join_pack.{u} {α : Type u} (S T : LaPToP.DataStructures.Str α) : S.pack.join T.pack = (S ++ T).pack
theorem LaPToP.DataStructures.HList.pack_join_pack.{u} {α : Type u} (S T : LaPToP.DataStructures.Str α) : S.pack.join T.pack = (S ++ T).pack
`[S];;[T] = [S; T]` (join).
-
theoremdefined in LaPToP/DataStructures/Lists.leancomplete
theorem LaPToP.DataStructures.HList.at_pack.{u} {α : Type u} (S : LaPToP.DataStructures.Str α) (n : ℕ) [Inhabited α] : S.pack.at n = S.at n
theorem LaPToP.DataStructures.HList.at_pack.{u} {α : Type u} (S : LaPToP.DataStructures.Str α) (n : ℕ) [Inhabited α] : S.pack.at n = S.at n
`[S] n = S n` (indexing).
-
theoremdefined in LaPToP/DataStructures/Lists.leancomplete
theorem LaPToP.DataStructures.HList.pack_comp_pack.{u} {α : Type u} (S : LaPToP.DataStructures.Str α) [Inhabited α] (T : LaPToP.DataStructures.Str ℕ) : S.pack.comp T.pack = (S.sub T).pack
theorem LaPToP.DataStructures.HList.pack_comp_pack.{u} {α : Type u} (S : LaPToP.DataStructures.Str α) [Inhabited α] (T : LaPToP.DataStructures.Str ℕ) : S.pack.comp T.pack = (S.sub T).pack
`[S] [T] = [S T]` (composition).
-
theoremdefined in LaPToP/DataStructures/Lists.leancomplete
theorem LaPToP.DataStructures.HList.modify_pack.{u} {α : Type u} (S : LaPToP.DataStructures.Str α) (n : ℕ) (i : α) : LaPToP.DataStructures.HList.modify n i S.pack = (S.update n i).pack
theorem LaPToP.DataStructures.HList.modify_pack.{u} {α : Type u} (S : LaPToP.DataStructures.Str α) (n : ℕ) (i : α) : LaPToP.DataStructures.HList.modify n i S.pack = (S.update n i).pack
`n→i | [S] = [S⊲n⊳i]` (modification).
-
theoremdefined in LaPToP/DataStructures/Lists.leancomplete
theorem LaPToP.DataStructures.HList.pack_inj.{u} {α : Type u} (S T : LaPToP.DataStructures.Str α) : S.pack = T.pack ↔ S = T
theorem LaPToP.DataStructures.HList.pack_inj.{u} {α : Type u} (S T : LaPToP.DataStructures.Str α) : S.pack = T.pack ↔ S = T
`[S] = [T] = (S = T)` (equation).
-
theoremdefined in LaPToP/DataStructures/Lists.leancomplete
theorem LaPToP.DataStructures.HList.pack_lt_pack.{u} {α : Type u} (S T : LaPToP.DataStructures.Str α) [LT α] : S.pack < T.pack ↔ S < T
theorem LaPToP.DataStructures.HList.pack_lt_pack.{u} {α : Type u} (S T : LaPToP.DataStructures.Str α) [LT α] : S.pack < T.pack ↔ S < T
`[S] < [T] = (S < T)` (order).
-
theoremdefined in LaPToP/DataStructures/Lists.leancomplete
theorem LaPToP.DataStructures.HList.image_pack_subset_image_pack.{u} {α : Type u} (A B : LaPToP.BasicTheories.Bunch (LaPToP.DataStructures.Str α)) : LaPToP.DataStructures.Str.pack '' A ⊆ LaPToP.DataStructures.Str.pack '' B ↔ A ⊆ B
theorem LaPToP.DataStructures.HList.image_pack_subset_image_pack.{u} {α : Type u} (A B : LaPToP.BasicTheories.Bunch (LaPToP.DataStructures.Str α)) : LaPToP.DataStructures.Str.pack '' A ⊆ LaPToP.DataStructures.Str.pack '' B ↔ A ⊆ B
`[A]: [B] = A: B` (inclusion), for bunches of strings `A`, `B`; list brackets distribute over bunch union, so `[A]` is the bunch of lists `[S]` for `S : A`.
-
theoremdefined in LaPToP/DataStructures/Lists.leancomplete
theorem LaPToP.DataStructures.Str.pack_injective.{u} {α : Type u} : Function.Injective LaPToP.DataStructures.Str.pack
theorem LaPToP.DataStructures.Str.pack_injective.{u} {α : Type u} : Function.Injective LaPToP.DataStructures.Str.pack
Packaging is injective; `[S] = [T] = (S = T)` is `HList.pack_inj`.
-
theoremdefined in LaPToP/DataStructures/Lists.leancomplete
theorem LaPToP.DataStructures.HList.contents_example : (LaPToP.DataStructures.Str.pack [3, 5, 7, 4]).contents = [3, 5, 7, 4]
theorem LaPToP.DataStructures.HList.contents_example : (LaPToP.DataStructures.Str.pack [3, 5, 7, 4]).contents = [3, 5, 7, 4]
`~[3; 5; 7; 4] = 3; 5; 7; 4`.
-
theoremdefined in LaPToP/DataStructures/Lists.leancomplete
theorem LaPToP.DataStructures.HList.length_example : (LaPToP.DataStructures.Str.pack [3, 5, 7, 4]).length = 4
theorem LaPToP.DataStructures.HList.length_example : (LaPToP.DataStructures.Str.pack [3, 5, 7, 4]).length = 4
`#[3; 5; 7; 4] = 4`.
-
theoremdefined in LaPToP/DataStructures/Lists.leancomplete
theorem LaPToP.DataStructures.HList.at_example : (LaPToP.DataStructures.Str.pack [3, 5, 7, 4]).at 2 = 7
theorem LaPToP.DataStructures.HList.at_example : (LaPToP.DataStructures.Str.pack [3, 5, 7, 4]).at 2 = 7
`[3; 5; 7; 4] 2 = 7`.
-
theoremdefined in LaPToP/DataStructures/Lists.leancomplete
theorem LaPToP.DataStructures.HList.comp_example : (LaPToP.DataStructures.Str.pack [3, 5, 7, 4]).comp (LaPToP.DataStructures.Str.pack [2, 1, 2]) = LaPToP.DataStructures.Str.pack [7, 5, 7]
theorem LaPToP.DataStructures.HList.comp_example : (LaPToP.DataStructures.Str.pack [3, 5, 7, 4]).comp (LaPToP.DataStructures.Str.pack [2, 1, 2]) = LaPToP.DataStructures.Str.pack [7, 5, 7]
`[3; 5; 7; 4] [2; 1; 2] = [7; 5; 7]`.
-
theoremdefined in LaPToP/DataStructures/Lists.leancomplete
theorem LaPToP.DataStructures.HList.join_example : (LaPToP.DataStructures.Str.pack [3, 5, 7, 4]).join (LaPToP.DataStructures.Str.pack [2, 1, 2]) = LaPToP.DataStructures.Str.pack [3, 5, 7, 4, 2, 1, 2]
theorem LaPToP.DataStructures.HList.join_example : (LaPToP.DataStructures.Str.pack [3, 5, 7, 4]).join (LaPToP.DataStructures.Str.pack [2, 1, 2]) = LaPToP.DataStructures.Str.pack [3, 5, 7, 4, 2, 1, 2]
`[3; 5; 7; 4];;[2; 1; 2] = [3; 5; 7; 4; 2; 1; 2]`.
-
theoremdefined in LaPToP/DataStructures/Lists.leancomplete
theorem LaPToP.DataStructures.HList.modify_example : LaPToP.DataStructures.HList.modify 2 22 (LaPToP.DataStructures.Str.interval 10 15).pack = LaPToP.DataStructures.Str.pack [10, 11, 22, 13, 14]
theorem LaPToP.DataStructures.HList.modify_example : LaPToP.DataStructures.HList.modify 2 22 (LaPToP.DataStructures.Str.interval 10 15).pack = LaPToP.DataStructures.Str.pack [10, 11, 22, 13, 14]
`2→22 | [10;..15] = [10; 11; 22; 13; 14]`.
-
theoremdefined in LaPToP/DataStructures/Lists.leancomplete
theorem LaPToP.DataStructures.HList.modify_modify_example : LaPToP.DataStructures.HList.modify 2 22 (LaPToP.DataStructures.HList.modify 3 33 (LaPToP.DataStructures.Str.interval 10 15).pack) = LaPToP.DataStructures.Str.pack [10, 11, 22, 33, 14]
theorem LaPToP.DataStructures.HList.modify_modify_example : LaPToP.DataStructures.HList.modify 2 22 (LaPToP.DataStructures.HList.modify 3 33 (LaPToP.DataStructures.Str.interval 10 15).pack) = LaPToP.DataStructures.Str.pack [10, 11, 22, 33, 14]
`2→22 | 3→33 | [10;..15] = [10; 11; 22; 33; 14]`.
-
theoremdefined in LaPToP/DataStructures/Lists.leancomplete
theorem LaPToP.DataStructures.HList.modify_swap_example : have L := (LaPToP.DataStructures.Str.interval 10 15).pack; LaPToP.DataStructures.HList.modify 2 (L.at 3) (LaPToP.DataStructures.HList.modify 3 (L.at 2) L) = LaPToP.DataStructures.Str.pack [10, 11, 13, 12, 14]
theorem LaPToP.DataStructures.HList.modify_swap_example : have L := (LaPToP.DataStructures.Str.interval 10 15).pack; LaPToP.DataStructures.HList.modify 2 (L.at 3) (LaPToP.DataStructures.HList.modify 3 (L.at 2) L) = LaPToP.DataStructures.Str.pack [10, 11, 13, 12, 14]
With `L = [10;..15]`, `2→L 3 | 3→L 2 | L = [10; 11; 13; 12; 14]`: swapping two items.
Every law is definitional (rfl / Iff.rfl) once the list operators are
defined on contents; equation and inclusion follow from injectivity of
packaging (Set.image_subset_image_iff).
-
LaPToP.DataStructures.HList.comp_at[complete] -
LaPToP.DataStructures.HList.comp_assoc[complete] -
LaPToP.DataStructures.HList.comp_join[complete]
Theorems Hehner derives from the axioms, for lists L, M, N and natural n:
(L\,M)\,n = L\,(M\,n) (composition), (L\,M)\,N = L\,(M\,N) (associativity),
and L\,(M ;; N) = L\,M ;; L\,N (distributivity). The first two are stated for
n an index of M, respectively N a list of indexes of M, because the
book leaves out-of-range indexing unspecified. Uses Theorem 4.10 and
Theorem 4.5.
Lean code for Theorem4.11●3 theorems
Associated Lean declarations
-
LaPToP.DataStructures.HList.comp_at[complete]
-
LaPToP.DataStructures.HList.comp_assoc[complete]
-
LaPToP.DataStructures.HList.comp_join[complete]
-
LaPToP.DataStructures.HList.comp_at[complete] -
LaPToP.DataStructures.HList.comp_assoc[complete] -
LaPToP.DataStructures.HList.comp_join[complete]
-
theoremdefined in LaPToP/DataStructures/Lists.leancomplete
theorem LaPToP.DataStructures.HList.comp_at.{u} {α : Type u} [Inhabited α] (L : LaPToP.DataStructures.HList α) (M : LaPToP.DataStructures.HList ℕ) {n : ℕ} (hn : n < List.length M.contents) : (L.comp M).at n = L.at (M.at n)
theorem LaPToP.DataStructures.HList.comp_at.{u} {α : Type u} [Inhabited α] (L : LaPToP.DataStructures.HList α) (M : LaPToP.DataStructures.HList ℕ) {n : ℕ} (hn : n < List.length M.contents) : (L.comp M).at n = L.at (M.at n)
`(L M) n = L (M n)` (composition), for `n` an index of `M`.
-
theoremdefined in LaPToP/DataStructures/Lists.leancomplete
theorem LaPToP.DataStructures.HList.comp_assoc.{u} {α : Type u} [Inhabited α] (L : LaPToP.DataStructures.HList α) (M N : LaPToP.DataStructures.HList ℕ) (hN : ∀ k ∈ N.contents, k < List.length M.contents) : (L.comp M).comp N = L.comp (M.comp N)
theorem LaPToP.DataStructures.HList.comp_assoc.{u} {α : Type u} [Inhabited α] (L : LaPToP.DataStructures.HList α) (M N : LaPToP.DataStructures.HList ℕ) (hN : ∀ k ∈ N.contents, k < List.length M.contents) : (L.comp M).comp N = L.comp (M.comp N)
`(L M) N = L (M N)` (associativity), for `N` a list of indexes of `M`.
-
theoremdefined in LaPToP/DataStructures/Lists.leancomplete
theorem LaPToP.DataStructures.HList.comp_join.{u} {α : Type u} [Inhabited α] (L : LaPToP.DataStructures.HList α) (M N : LaPToP.DataStructures.HList ℕ) : L.comp (M.join N) = (L.comp M).join (L.comp N)
theorem LaPToP.DataStructures.HList.comp_join.{u} {α : Type u} [Inhabited α] (L : LaPToP.DataStructures.HList α) (M N : LaPToP.DataStructures.HList ℕ) : L.comp (M.join N) = (L.comp M).join (L.comp N)
`L (M;;N) = L M ;; L N` (distributivity).
Unpack to contents and apply the string indexing laws
(Str.at_map_of_lt, Str.sub_sub, Str.sub_append).
- No associated Lean code or declarations.
Functions are ordinary data in LaPToP. Higher-order specifications and implementations are therefore first-class, building on Definition 4.1 when the domain is finite or inductive.