Skip to content

Commit

Permalink
chore: move panicWith out of UnionFind (#983)
Browse files Browse the repository at this point in the history
  • Loading branch information
fgdorais authored Oct 14, 2024
1 parent 0d328c8 commit ad3ba5f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
1 change: 1 addition & 0 deletions Batteries.lean
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ import Batteries.Test.Internal.DummyLabelAttr
import Batteries.Util.Cache
import Batteries.Util.ExtendedBinder
import Batteries.Util.LibraryNote
import Batteries.Util.Panic
import Batteries.Util.Pickle
import Batteries.Util.ProofWanted
import Batteries.WF
10 changes: 5 additions & 5 deletions Batteries/Data/UnionFind/Basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@ Copyright (c) 2021 Mario Carneiro. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro
-/
import Batteries.Tactic.Alias
import Batteries.Tactic.Lint.Misc
import Batteries.Tactic.SeqFocus
import Batteries.Util.Panic
import Batteries.Data.Array.Lemmas

@[deprecated (since := "2024-10-05")]
protected alias Batteries.UnionFind.panicWith := Batteries.panicWith

namespace Batteries

/-- Union-find node type -/
Expand All @@ -18,11 +23,6 @@ structure UFNode where

namespace UnionFind

/-- Panic with return value -/
def panicWith (v : α) (msg : String) : α := @panic α ⟨v⟩ msg

@[simp] theorem panicWith_eq (v : α) (msg) : panicWith v msg = v := rfl

/-- Parent of a union-find node, defaults to self when the node is a root -/
def parentD (arr : Array UFNode) (i : Nat) : Nat :=
if h : i < arr.size then (arr.get ⟨i, h⟩).parent else i
Expand Down
12 changes: 12 additions & 0 deletions Batteries/Util/Panic.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/-
Copyright (c) 2024 François G. Dorais. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: François G. Dorais
-/

namespace Batteries

/-- Panic with a specific default value `v`. -/
def panicWith (v : α) (msg : String) : α := @panic α ⟨v⟩ msg

@[simp] theorem panicWith_eq (v : α) (msg) : panicWith v msg = v := rfl

0 comments on commit ad3ba5f

Please sign in to comment.