Skip to content

Commit

Permalink
feat: port Data.Fin.Basic (#1084)
Browse files Browse the repository at this point in the history
mathlib3 SHA: 0bd2ea37bcba5769e14866170f251c9bc64e35d7



Co-authored-by: Moritz Doll <moritz.doll@googlemail.com>
Co-authored-by: Johan Commelin <johan@commelin.net>
  • Loading branch information
3 people committed Jan 12, 2023
1 parent 1306a15 commit 0cfa913
Show file tree
Hide file tree
Showing 5 changed files with 2,631 additions and 344 deletions.
17 changes: 17 additions & 0 deletions Mathlib/Data/ByteArray.lean
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,23 @@ import Mathlib.Data.Nat.Basic
import Mathlib.Data.Char
import Mathlib.Data.UInt

namespace Nat

/- Up -/

/-- A well-ordered relation for "upwards" induction on the natural numbers up to some bound `ub`. -/
def Up (ub a i : ℕ) := i < a ∧ i < ub

lemma Up.next {ub i} (h : i < ub) : Up ub (i+1) i := ⟨Nat.lt_succ_self _, h⟩

lemma Up.WF (ub) : WellFounded (Up ub) :=
Subrelation.wf (h₂ := (measure (ub - .)).wf) fun ⟨ia, iu⟩ ↦ Nat.sub_lt_sub_left iu ia

/-- A well-ordered relation for "upwards" induction on the natural numbers up to some bound `ub`. -/
def upRel (ub : ℕ) : WellFoundedRelation Nat := ⟨Up ub, Up.WF ub⟩

end Nat

/-- A terminal byte slice, a suffix of a byte array. -/
structure ByteSliceT := (arr : ByteArray) (off : Nat)

Expand Down

0 comments on commit 0cfa913

Please sign in to comment.