List lemmas #
The position r0 ends up in r on adding it via List.orderedInsert _ r0 r.
Equations
- PhysLean.List.orderedInsertPos le1 r r0 = ⟨(List.takeWhile (fun (b : I) => decide ¬le1 r0 b) r).length, ⋯⟩
Instances For
The equivalence between Fin (r0 :: r).length and Fin (List.orderedInsert le1 r0 r).length
according to where the elements map, i.e. 0 is taken to orderedInsertPos le1 r r0.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The equivalence between Fin l.length ≃ Fin (List.insertionSort r l).length induced by the
sorting algorithm.
Equations
Instances For
Optional erase of an element in a list. For none returns the list, for some i returns
the list with the i'th element erased.
Equations
- PhysLean.List.optionErase l none = l
- PhysLean.List.optionErase l (some i_2) = l.eraseIdx ↑i_2
Instances For
Given a list i :: l the left-most minimal position a of i :: l wrt r.
That is the first position
of l such that for every element (i :: l)[b] before that position
r ((i :: l)[b]) ((i :: l)[a]) is not true. The use of i :: l here
rather then just l is to ensure that such a position exists. .
Equations
- PhysLean.List.insertionSortMinPos r i l = (PhysLean.List.insertionSortEquiv r (i :: l)).symm ⟨0, ⋯⟩
Instances For
The element of i :: l at insertionSortMinPos.
Equations
- PhysLean.List.insertionSortMin r i l = (i :: l).get (PhysLean.List.insertionSortMinPos r i l)
Instances For
The list remaining after dropping the element at the position determined by
insertionSortMinPos.
Equations
- PhysLean.List.insertionSortDropMinPos r i l = (i :: l).eraseIdx ↑(PhysLean.List.insertionSortMinPos r i l)
Instances For
Optional erase of an element in a list, with addition for none. For none adds a to the
front of the list, for some i removes the ith element of the list (does not add a).
E.g. optionEraseZ [0, 1, 2] 4 none = [4, 0, 1, 2] and
optionEraseZ [0, 1, 2] 4 (some 1) = [0, 2].
Equations
- PhysLean.List.optionEraseZ l a none = a :: l
- PhysLean.List.optionEraseZ l a (some i_2) = l.eraseIdx ↑i_2