1import data.matrix.notation
6Helpers that don't currently fit elsewhere...
10lemma split_eq {m n : Type*} (x : m × n) (p p' : m × n) :
11 p = x ∨ p' = x ∨ (x ≠ p ∧ x ≠ p') := by tauto
13-- For `playfield`s, the piece type and/or piece index type.
22An auxiliary wrapper for `option X` that allows for overriding the `has_repr` instance
23for `option`, and rather, output just the value in the `some` and a custom provided
26structure option_wrapper :=
30instance wrapped_option_repr : has_repr (option_wrapper X) :=
31⟨λ ⟨val, s⟩, (option.map has_repr.repr val).get_or_else s⟩
35Construct an `option_wrapper` term from a provided `option X` and the `string`
36that will override the `has_repr.repr` for `none`.
38def option_wrap (val : option X) (none_s : string) : option_wrapper X := ⟨val, none_s⟩
40-- The size of the "vectors" for a `fin n' → X`, for `has_repr` definitions
44For a "vector" `X^n'` represented by the type `Π n' : ℕ, fin n' → X`, where
45the `X` has a `has_repr` instance itself, we can provide a `has_repr` for the "vector".
46This definition is used for displaying rows of the playfield, when it is defined
47via a `matrix`, likely through notation.
49def vec_repr : Π {n' : ℕ}, (fin n' → X) → string :=
50λ _ v, string.intercalate ", " ((vector.of_fn v).to_list.map repr)
52instance vec_repr_instance : has_repr (fin n' → X) := ⟨vec_repr⟩
55For a `matrix` `X^(m' × n')` where the `X` has a `has_repr` instance itself,
56we can provide a `has_repr` for the matrix, using `vec_repr` for each of the rows of the matrix.
57This definition is used for displaying the playfield, when it is defined
58via a `matrix`, likely through notation.
60def matrix_repr : Π {m' n'}, matrix (fin m') (fin n') X → string :=
61λ _ _ M, string.intercalate ";\n" ((vector.of_fn M).to_list.map repr)
63instance matrix_repr_instance :
64 has_repr (matrix (fin n') (fin m') X) := ⟨matrix_repr⟩
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list