refactor: unname some unused variables

This commit is contained in:
Sebastian Ullrich 2022-06-03 20:55:32 +02:00 committed by Leonardo de Moura
parent 8ffa07ab25
commit ae7b895f7a
153 changed files with 558 additions and 558 deletions

View file

@ -56,7 +56,7 @@ theorem em (p : Prop) : p ¬p :=
| Or.inl hne => Or.inr (mt p_implies_uv hne)
| Or.inr h => Or.inl h
theorem exists_true_of_nonempty {α : Sort u} : Nonempty α → ∃ x : α, True
theorem exists_true_of_nonempty {α : Sort u} : Nonempty α → ∃ _ : α, True
| ⟨x⟩ => ⟨x, trivial⟩
noncomputable def inhabited_of_nonempty {α : Sort u} (h : Nonempty α) : Inhabited α :=
@ -75,7 +75,7 @@ noncomputable def decidableInhabited (a : Prop) : Inhabited (Decidable a) where
default := inferInstance
noncomputable def typeDecidableEq (α : Sort u) : DecidableEq α :=
fun x y => inferInstance
fun _ _ => inferInstance
noncomputable def typeDecidable (α : Sort u) : PSum α (α → False) :=
match (propDecidable (Nonempty α)) with

View file

@ -27,11 +27,11 @@ class CoeTail (α : Sort u) (β : Sort v) where
class CoeHTCT (α : Sort u) (β : Sort v) where
coe : α → β
class CoeDep (α : Sort u) (a : α) (β : Sort v) where
class CoeDep (α : Sort u) (_ : α) (β : Sort v) where
coe : β
/- Combines CoeHead, CoeTC, CoeTail, CoeDep -/
class CoeT (α : Sort u) (a : α) (β : Sort v) where
class CoeT (α : Sort u) (_ : α) (β : Sort v) where
coe : β
class CoeFun (α : Sort u) (γ : outParam (α → Sort v)) where

View file

@ -50,7 +50,7 @@ variable {ε : Type u}
def orElseLazy (x : Except ε α) (y : Unit → Except ε α) : Except ε α :=
match x with
| Except.ok a => Except.ok a
| Except.error e => y ()
| Except.error _ => y ()
instance : Monad (Except ε) where
pure := Except.pure

View file

@ -16,7 +16,7 @@ namespace ReaderT
fun s => x₁ s <|> x₂ () s
@[inline] protected def failure [Alternative m] : ReaderT ρ m α :=
fun s => failure
fun _ => failure
instance [Alternative m] [Monad m] : Alternative (ReaderT ρ m) where
failure := ReaderT.failure

View file

@ -53,7 +53,7 @@ instance : Monad (StateT σ m) where
fun s => x₁ s <|> x₂ () s
@[inline] protected def failure [Alternative m] {α : Type u} : StateT σ m α :=
fun s => failure
fun _ => failure
instance [Alternative m] : Alternative (StateT σ m) where
failure := StateT.failure
@ -63,7 +63,7 @@ instance [Alternative m] : Alternative (StateT σ m) where
fun s => pure (s, s)
@[inline] protected def set : σ → StateT σ m PUnit :=
fun s' s => pure (⟨⟩, s')
fun s' _ => pure (⟨⟩, s')
@[inline] protected def modifyGet (f : σα × σ) : StateT σ m α :=
fun s => pure (f s)

View file

@ -21,19 +21,19 @@ namespace StateCpsT
runK x s (fun a s => pure (a, s))
@[inline] def run' {α σ : Type u} {m : Type u → Type v} [Monad m] (x : StateCpsT σ m α) (s : σ) : m α :=
runK x s (fun a s => pure a)
runK x s (fun a _ => pure a)
instance : Monad (StateCpsT σ m) where
map f x := fun δ s k => x δ s fun a s => k (f a) s
pure a := fun δ s k => k a s
pure a := fun _ s k => k a s
bind x f := fun δ s k => x δ s fun a s => f a δ s k
instance : LawfulMonad (StateCpsT σ m) := by
refine' { .. } <;> intros <;> rfl
instance : MonadStateOf σ (StateCpsT σ m) where
get := fun δ s k => k s s
set s := fun δ _ k => k ⟨⟩ s
get := fun _ s k => k s s
set s := fun _ _ k => k ⟨⟩ s
modifyGet f := fun _ s k => let (a, s) := f s; k a s
@[inline] protected def lift [Monad m] (x : m α) : StateCpsT σ m α :=
@ -68,6 +68,6 @@ instance [Monad m] : MonadLift m (StateCpsT σ m) where
@[simp] theorem run_eq [Monad m] (x : StateCpsT σ m α) (s : σ) : x.run s = x.runK s (fun a s => pure (a, s)) := rfl
@[simp] theorem run'_eq [Monad m] (x : StateCpsT σ m α) (s : σ) : x.run' s = x.runK s (fun a s => pure a) := rfl
@[simp] theorem run'_eq [Monad m] (x : StateCpsT σ m α) (s : σ) : x.run' s = x.runK s (fun a _ => pure a) := rfl
end StateCpsT

View file

@ -89,7 +89,7 @@ class ForIn (m : Type u₁ → Type u₂) (ρ : Type u) (α : outParam (Type v))
export ForIn (forIn)
class ForIn' (m : Type u₁ → Type u₂) (ρ : Type u) (α : outParam (Type v)) (d : outParam $ Membership α ρ) where
class ForIn' (m : Type u₁ → Type u₂) (ρ : Type u) (α : outParam (Type v)) (_ : outParam $ Membership α ρ) where
forIn' {β} [Monad m] (x : ρ) (b : β) (f : (a : α) → a ∈ x → β → m (ForInStep β)) : m β
export ForIn' (forIn')
@ -273,10 +273,10 @@ end Ne
theorem Bool.of_not_eq_true : {b : Bool} → ¬ (b = true) → b = false
| true, h => absurd rfl h
| false, h => rfl
| false, _ => rfl
theorem Bool.of_not_eq_false : {b : Bool} → ¬ (b = false) → b = true
| true, h => rfl
| true, _ => rfl
| false, h => absurd rfl h
theorem ne_of_beq_false [BEq α] [LawfulBEq α] {a b : α} (h : (a == b) = false) : a ≠ b := by
@ -366,12 +366,12 @@ theorem Exists.elim {α : Sort u} {p : α → Prop} {b : Prop}
theorem decide_true_eq_true (h : Decidable True) : @decide True h = true :=
match h with
| isTrue h => rfl
| isTrue _ => rfl
| isFalse h => False.elim <| h ⟨⟩
theorem decide_false_eq_false (h : Decidable False) : @decide False h = false :=
match h with
| isFalse h => rfl
| isFalse _ => rfl
| isTrue h => False.elim h
/-- Similar to `decide`, but uses an explicit instance -/
@ -436,7 +436,7 @@ end
@[macroInline] instance {p q} [Decidable p] [Decidable q] : Decidable (p → q) :=
if hp : p then
if hq : q then isTrue (fun h => hq)
if hq : q then isTrue (fun _ => hq)
else isFalse (fun h => absurd (h hp) hq)
else isTrue (fun h => absurd h hp)
@ -456,34 +456,34 @@ instance {p q} [Decidable p] [Decidable q] : Decidable (p ↔ q) :=
theorem if_pos {c : Prop} {h : Decidable c} (hc : c) {α : Sort u} {t e : α} : (ite c t e) = t :=
match h with
| isTrue hc => rfl
| isTrue _ => rfl
| isFalse hnc => absurd hc hnc
theorem if_neg {c : Prop} {h : Decidable c} (hnc : ¬c) {α : Sort u} {t e : α} : (ite c t e) = e :=
match h with
| isTrue hc => absurd hc hnc
| isFalse hnc => rfl
| isFalse _ => rfl
theorem dif_pos {c : Prop} {h : Decidable c} (hc : c) {α : Sort u} {t : c → α} {e : ¬ c → α} : (dite c t e) = t hc :=
match h with
| isTrue hc => rfl
| isTrue _ => rfl
| isFalse hnc => absurd hc hnc
theorem dif_neg {c : Prop} {h : Decidable c} (hnc : ¬c) {α : Sort u} {t : c → α} {e : ¬ c → α} : (dite c t e) = e hnc :=
match h with
| isTrue hc => absurd hc hnc
| isFalse hnc => rfl
| isFalse _ => rfl
-- Remark: dite and ite are "defally equal" when we ignore the proofs.
theorem dif_eq_if (c : Prop) {h : Decidable c} {α : Sort u} (t : α) (e : α) : dite c (fun h => t) (fun h => e) = ite c t e :=
theorem dif_eq_if (c : Prop) {h : Decidable c} {α : Sort u} (t : α) (e : α) : dite c (fun _ => t) (fun _ => e) = ite c t e :=
match h with
| isTrue hc => rfl
| isFalse hnc => rfl
| isTrue _ => rfl
| isFalse _ => rfl
instance {c t e : Prop} [dC : Decidable c] [dT : Decidable t] [dE : Decidable e] : Decidable (if c then t else e) :=
match dC with
| isTrue hc => dT
| isFalse hc => dE
| isTrue _ => dT
| isFalse _ => dE
instance {c : Prop} {t : c → Prop} {e : ¬c → Prop} [dC : Decidable c] [dT : ∀ h, Decidable (t h)] [dE : ∀ h, Decidable (e h)] : Decidable (if h : c then t h else e h) :=
match dC with
@ -511,7 +511,7 @@ instance : Inhabited Prop where
deriving instance Inhabited for NonScalar, PNonScalar, True, ForInStep
theorem nonempty_of_exists {α : Sort u} {p : α → Prop} : Exists (fun x => p x) → Nonempty α
| ⟨w, h⟩ => ⟨w⟩
| ⟨w, _⟩ => ⟨w⟩
/- Subsingleton -/
@ -532,11 +532,11 @@ instance (p : Prop) : Subsingleton p :=
instance (p : Prop) : Subsingleton (Decidable p) :=
Subsingleton.intro fun
| isTrue t₁ => fun
| isTrue t₂ => rfl
| isTrue _ => rfl
| isFalse f₂ => absurd t₁ f₂
| isFalse f₁ => fun
| isTrue t₂ => absurd t₂ f₁
| isFalse f₂ => rfl
| isFalse _ => rfl
theorem recSubsingleton
{p : Prop} [h : Decidable p]
@ -576,7 +576,7 @@ def existsOfSubtype {α : Type u} {p : α → Prop} : { x // p x } → Exists (f
variable {α : Type u} {p : α → Prop}
protected theorem eq : ∀ {a1 a2 : {x // p x}}, val a1 = val a2 → a1 = a2
| ⟨x, h1⟩, ⟨_, _⟩, rfl => rfl
| ⟨_, _ ⟩, ⟨_, _⟩, rfl => rfl
theorem eta (a : {x // p x}) (h : p (val a)) : mk (val a) h = a := by
cases a
@ -597,10 +597,10 @@ end Subtype
section
variable {α : Type u} {β : Type v}
instance Sum.inhabitedLeft [h : Inhabited α] : Inhabited (Sum α β) where
instance Sum.inhabitedLeft [_ : Inhabited α] : Inhabited (Sum α β) where
default := Sum.inl default
instance Sum.inhabitedRight [h : Inhabited β] : Inhabited (Sum α β) where
instance Sum.inhabitedRight [_ : Inhabited β] : Inhabited (Sum α β) where
default := Sum.inr default
instance {α : Type u} {β : Type v} [DecidableEq α] [DecidableEq β] : DecidableEq (Sum α β) := fun a b =>
@ -611,8 +611,8 @@ instance {α : Type u} {β : Type v} [DecidableEq α] [DecidableEq β] : Decidab
| Sum.inr a, Sum.inr b =>
if h : a = b then isTrue (h ▸ rfl)
else isFalse fun h' => Sum.noConfusion h' fun h' => absurd h' h
| Sum.inr a, Sum.inl b => isFalse fun h => Sum.noConfusion h
| Sum.inl a, Sum.inr b => isFalse fun h => Sum.noConfusion h
| Sum.inr _, Sum.inl _ => isFalse fun h => Sum.noConfusion h
| Sum.inl _, Sum.inr _ => isFalse fun h => Sum.noConfusion h
end
@ -627,8 +627,8 @@ instance [DecidableEq α] [DecidableEq β] : DecidableEq (α × β) :=
| isTrue e₁ =>
match decEq b b' with
| isTrue e₂ => isTrue (e₁ ▸ e₂ ▸ rfl)
| isFalse n₂ => isFalse fun h => Prod.noConfusion h fun e₁' e₂' => absurd e₂' n₂
| isFalse n₁ => isFalse fun h => Prod.noConfusion h fun e₁' e₂' => absurd e₁' n₁
| isFalse n₂ => isFalse fun h => Prod.noConfusion h fun _ e₂' => absurd e₂' n₂
| isFalse n₁ => isFalse fun h => Prod.noConfusion h fun e₁' _ => absurd e₁' n₁
instance [BEq α] [BEq β] : BEq (α × β) where
beq := fun (a₁, b₁) (a₂, b₂) => a₁ == a₂ && b₁ == b₂
@ -640,7 +640,7 @@ instance prodHasDecidableLt
[LT α] [LT β] [DecidableEq α] [DecidableEq β]
[(a b : α) → Decidable (a < b)] [(a b : β) → Decidable (a < b)]
: (s t : α × β) → Decidable (s < t) :=
fun t s => inferInstanceAs (Decidable (_ _))
fun _ _ => inferInstanceAs (Decidable (_ _))
theorem Prod.lt_def [LT α] [LT β] (s t : α × β) : (s < t) = (s.1 < t.1 (s.1 = t.1 ∧ s.2 < t.2)) :=
rfl
@ -825,7 +825,7 @@ protected abbrev hrecOn
end
end Quot
def Quotient {α : Sort u} (s : Setoid α) :=
def Quotient {α : Sort u} (_ : Setoid α) :=
@Quot α Setoid.r
namespace Quotient
@ -1017,7 +1017,7 @@ variable {α : Sort u} {β : α → Sort v}
protected def Equiv (f₁ f₂ : ∀ (x : α), β x) : Prop := ∀ x, f₁ x = f₂ x
protected theorem Equiv.refl (f : ∀ (x : α), β x) : Function.Equiv f f :=
fun x => rfl
fun _ => rfl
protected theorem Equiv.symm {f₁ f₂ : ∀ (x : α), β x} : Function.Equiv f₁ f₂ → Function.Equiv f₂ f₁ :=
fun h x => Eq.symm (h x)
@ -1060,7 +1060,7 @@ instance {α : Sort u} {β : α → Sort v} [∀ a, Subsingleton (β a)] : Subsi
/- Squash -/
def Squash (α : Type u) := Quot (fun (a b : α) => True)
def Squash (α : Type u) := Quot (fun (_ _ : α) => True)
def Squash.mk {α : Type u} (x : α) : Squash α := Quot.mk _ x
@ -1068,7 +1068,7 @@ theorem Squash.ind {α : Type u} {motive : Squash α → Prop} (h : ∀ (a : α)
Quot.ind h
@[inline] def Squash.lift {α β} [Subsingleton β] (s : Squash α) (f : α → β) : β :=
Quot.lift f (fun a b _ => Subsingleton.elim _ _) s
Quot.lift f (fun _ _ _ => Subsingleton.elim _ _) s
instance : Subsingleton (Squash α) where
allEq a b := by

View file

@ -160,12 +160,12 @@ theorem Context.evalList_mergeIdem (ctx : Context α) (h : ContextInformation.is
theorem insert_nonEmpty : insert x xs ≠ [] := by
induction xs with
| nil => simp [insert]
| cons x xs ih => simp [insert]; split <;> simp
| cons x xs _ => simp [insert]; split <;> simp
theorem Context.sort_loop_nonEmpty (xs : List Nat) (h : xs ≠ []) : sort.loop xs ys ≠ [] := by
induction ys generalizing xs with
| nil => simp [sort.loop]; assumption
| cons y ys ih => simp [sort.loop]; apply ih; apply insert_nonEmpty
| cons y _ ih => simp [sort.loop]; apply ih; apply insert_nonEmpty
theorem Context.evalList_insert
(ctx : Context α)
@ -197,7 +197,7 @@ theorem Context.evalList_sort_congr
: evalList α ctx (sort.loop a c) = evalList α ctx (sort.loop b c) := by
induction c generalizing a b with
| nil => simp [sort.loop, h₂]
| cons c cs ih =>
| cons c _ ih =>
simp [sort.loop]; apply ih; simp [evalList_insert ctx h, evalList]
cases a with
| nil => apply absurd h₃; simp
@ -214,7 +214,7 @@ theorem Context.evalList_sort_loop_swap
: evalList α ctx (sort.loop xs (y::ys)) = evalList α ctx (sort.loop (y::xs) ys) := by
induction ys generalizing y xs with
| nil => simp [sort.loop, evalList_insert ctx h]
| cons z zs ih =>
| cons z zs _ =>
simp [sort.loop]; apply evalList_sort_congr ctx h
simp [evalList_insert ctx h]
cases h₂ : insert y xs
@ -260,7 +260,7 @@ theorem Context.evalList_sort (ctx : Context α) (h : ContextInformation.isComm
theorem Context.toList_nonEmpty (e : Expr) : e.toList ≠ [] := by
induction e with
| var => simp [Expr.toList]
| op l r ih₁ ih₂ =>
| op l r ih₁ _ =>
simp [Expr.toList]
cases h : l.toList with
| nil => contradiction

View file

@ -347,12 +347,12 @@ def allM {α : Type u} {m : Type → Type w} [Monad m] (p : α → m Bool) (as :
@[inline]
def findSomeRevM? {α : Type u} {β : Type v} {m : Type v → Type w} [Monad m] (as : Array α) (f : α → m (Option β)) : m (Option β) :=
let rec @[specialize] find : (i : Nat) → i ≤ as.size → m (Option β)
| 0, h => pure none
| 0, _ => pure none
| i+1, h => do
have : i < as.size := Nat.lt_of_lt_of_le (Nat.lt_succ_self _) h
let r ← f (as.get ⟨i, this⟩)
match r with
| some v => pure r
| some _ => pure r
| none =>
have : i ≤ as.size := Nat.le_of_lt this
find i this
@ -469,7 +469,7 @@ def toList (as : Array α) : List α :=
as.foldr List.cons []
instance {α : Type u} [Repr α] : Repr (Array α) where
reprPrec a n :=
reprPrec a _ :=
let _ : Std.ToFormat α := ⟨repr⟩
if a.size == 0 then
"#[]"
@ -706,7 +706,7 @@ def insertAt (as : Array α) (i : Nat) (a : α) : Array α :=
as.insertAtAux i as.size
def toListLitAux (a : Array α) (n : Nat) (hsz : a.size = n) : ∀ (i : Nat), i ≤ a.size → List α → List α
| 0, hi, acc => acc
| 0, _, acc => acc
| (i+1), hi, acc => toListLitAux a n hsz i (Nat.le_of_succ_le hi) (a.getLit i hsz (Nat.lt_of_lt_of_eq (Nat.lt_of_lt_of_le (Nat.lt_succ_self i) hi) hsz) :: acc)
def toArrayLit (a : Array α) (n : Nat) (hsz : a.size = n) : Array α :=
@ -773,7 +773,7 @@ def isPrefixOf [BEq α] (as bs : Array α) : Bool :=
false
private def allDiffAuxAux [BEq α] (as : Array α) (a : α) : forall (i : Nat), i < as.size → Bool
| 0, h => true
| 0, _ => true
| i+1, h =>
have : i < as.size := Nat.lt_trans (Nat.lt_succ_self _) h;
a != as.get ⟨i, this⟩ && allDiffAuxAux as a i this

View file

@ -31,7 +31,7 @@ theorem isValidUInt32 (n : Nat) (h : isValidCharNat n) : n < UInt32.size := by
| Or.inl h =>
apply Nat.lt_trans h
decide
| Or.inr ⟨h₁, h₂⟩ =>
| Or.inr ⟨_, h₂⟩ =>
apply Nat.lt_trans h₂
decide

View file

@ -31,7 +31,7 @@ protected def ofNat' {n : Nat} (a : Nat) (h : n > 0) : Fin n :=
private theorem mlt {b : Nat} : {a : Nat} → a < n → b % n < n
| 0, h => Nat.mod_lt _ h
| a+1, h =>
| _+1, h =>
have : n > 0 := Nat.lt_trans (Nat.zero_lt_succ _) h;
Nat.mod_lt _ this
@ -113,7 +113,7 @@ theorem val_ne_of_ne {i j : Fin n} (h : i ≠ j) : val i ≠ val j :=
fun h' => absurd (eq_of_val_eq h') h
theorem modn_lt : ∀ {m : Nat} (i : Fin n), m > 0 → (i % m).val < m
| m, ⟨a, h⟩, hp => Nat.lt_of_le_of_lt (mod_le _ _) (mod_lt _ hp)
| _, ⟨_, _⟩, hp => Nat.lt_of_le_of_lt (mod_le _ _) (mod_lt _ hp)
end Fin

View file

@ -73,9 +73,9 @@ private structure SpaceResult where
{ r₂ with space := r₁.space + r₂.space }
private def spaceUptoLine : Format → Bool → Nat → SpaceResult
| nil, flatten, w => {}
| line, flatten, w => if flatten then { space := 1 } else { foundLine := true }
| text s, flatten, w =>
| nil, _, _ => {}
| line, flatten, _ => if flatten then { space := 1 } else { foundLine := true }
| text s, flatten, _ =>
let p := s.posOf '\n';
let off := s.offsetOfPos p;
{ foundLine := p != s.endPos, foundFlattenedHardLine := flatten && p != s.endPos, space := off }
@ -95,7 +95,7 @@ private structure WorkGroup where
items : List WorkItem
private partial def spaceUptoLine' : List WorkGroup → Nat → SpaceResult
| [], w => {}
| [], _ => {}
| { items := [], .. }::gs, w => spaceUptoLine' gs w
| g@{ items := i::is, .. }::gs, w => merge w (spaceUptoLine i.f g.flatten w) (spaceUptoLine' ({ g with items := is }::gs))
@ -216,8 +216,8 @@ instance : MonadPrettyFormat (StateM State) where
pushOutput s := modify fun ⟨out, col⟩ => ⟨out ++ s, col + s.length⟩
pushNewline indent := modify fun ⟨out, col⟩ => ⟨out ++ "\n".pushn ' ' indent, indent⟩
currColumn := return (←get).column
startTag n := return ()
endTags n := return ()
startTag _ := return ()
endTags _ := return ()
/-- Pretty-print a `Format` object as a string with expected width `w`. -/
@[export lean_format_pretty]
@ -240,8 +240,8 @@ instance : ToFormat String where
format s := Format.text s
def Format.joinSep {α : Type u} [ToFormat α] : List α → Format → Format
| [], sep => nil
| [a], sep => format a
| [], _ => nil
| [a], _ => format a
| a::as, sep => format a ++ sep ++ joinSep as sep
def Format.prefixJoin {α : Type u} [ToFormat α] (pre : Format) : List α → Format
@ -249,7 +249,7 @@ def Format.prefixJoin {α : Type u} [ToFormat α] (pre : Format) : List α → F
| a::as => pre ++ format a ++ prefixJoin pre as
def Format.joinSuffix {α : Type u} [ToFormat α] : List α → Format → Format
| [], suffix => nil
| [], _ => nil
| a::as, suffix => format a ++ suffix ++ joinSuffix as suffix
end Std

View file

@ -21,7 +21,7 @@ private def formatInfo (showInfo : Bool) (info : SourceInfo) (f : Format) : Form
partial def formatStxAux (maxDepth : Option Nat) (showInfo : Bool) : Nat → Syntax → Format
| _, atom info val => formatInfo showInfo info $ format (repr val)
| _, ident info _ val pre => formatInfo showInfo info $ format "`" ++ format val
| _, ident info _ val _ => formatInfo showInfo info $ format "`" ++ format val
| _, missing => "<missing>"
| depth, node _ kind args =>
let depth := depth + 1;

View file

@ -57,4 +57,4 @@ instance : Hashable Int where
| Int.negSucc n => UInt64.ofNat (2 * n + 1)
instance (P : Prop) : Hashable P where
hash p := 0
hash _ := 0

View file

@ -107,8 +107,8 @@ protected def decEq (a b : @& Int) : Decidable (a = b) :=
| negSucc a, negSucc b => match decEq a b with
| isTrue h => isTrue <| h ▸ rfl
| isFalse h => isFalse <| fun h' => Int.noConfusion h' (fun h' => absurd h' h)
| ofNat a, negSucc b => isFalse <| fun h => Int.noConfusion h
| negSucc a, ofNat b => isFalse <| fun h => Int.noConfusion h
| ofNat _, negSucc _ => isFalse <| fun h => Int.noConfusion h
| negSucc _, ofNat _ => isFalse <| fun h => Int.noConfusion h
instance : DecidableEq Int := Int.decEq
@ -117,7 +117,7 @@ set_option bootstrap.genMatcherCode false in
private def decNonneg (m : @& Int) : Decidable (NonNeg m) :=
match m with
| ofNat m => isTrue <| NonNeg.mk m
| negSucc m => isFalse <| fun h => nomatch h
| negSucc _ => isFalse <| fun h => nomatch h
@[extern "lean_int_dec_le"]
instance decLe (a b : @& Int) : Decidable (a ≤ b) :=
@ -159,7 +159,7 @@ instance : Mod Int where
def toNat : Int → Nat
| ofNat n => n
| negSucc n => 0
| negSucc _ => 0
def natMod (m n : Int) : Nat := (m % n).toNat

View file

@ -89,14 +89,14 @@ theorem append_cons (as : List α) (b : α) (bs : List α) : as ++ b :: bs = as
instance : EmptyCollection (List α) := ⟨List.nil⟩
protected def erase {α} [BEq α] : List αα → List α
| [], b => []
| [], _ => []
| a::as, b => match a == b with
| true => as
| false => a :: List.erase as b
def eraseIdx : List α → Nat → List α
| [], _ => []
| a::as, 0 => as
| _::as, 0 => as
| a::as, n+1 => a :: eraseIdx as n
def isEmpty : List α → Bool
@ -236,7 +236,7 @@ theorem mem_of_elem_eq_true [DecidableEq α] {a : α} {as : List α} : elem a as
theorem elem_eq_true_of_mem [DecidableEq α] {a : α} {as : List α} (h : a ∈ as) : elem a as = true := by
induction h with
| head _ => simp [elem]
| tail _ h ih => simp [elem]; split; rfl; assumption
| tail _ _ ih => simp [elem]; split; rfl; assumption
instance [DecidableEq α] (a : α) (as : List α) : Decidable (a ∈ as) :=
decidable_of_decidable_of_iff (Iff.intro mem_of_elem_eq_true elem_eq_true_of_mem)
@ -303,12 +303,12 @@ def removeAll [BEq α] (xs ys : List α) : List α :=
def drop : Nat → List α → List α
| 0, a => a
| n+1, [] => []
| n+1, a::as => drop n as
| _+1, [] => []
| n+1, _::as => drop n as
def take : Nat → List α → List α
| 0, a => []
| n+1, [] => []
| 0, _ => []
| _+1, [] => []
| n+1, a::as => a :: take n as
def takeWhile (p : α → Bool) : List α → List α
@ -368,14 +368,14 @@ theorem iota_eq_iotaTR : @iota = @iotaTR :=
funext fun n => by simp [iotaTR, aux]
def enumFrom : Nat → List α → List (Nat × α)
| n, [] => nil
| _, [] => nil
| n, x :: xs => (n, x) :: enumFrom (n + 1) xs
def enum : List α → List (Nat × α) := enumFrom 0
def init : List α → List α
| [] => []
| [a] => []
| [_] => []
| a::l => a::init l
def intersperse (sep : α) : List α → List α
@ -399,8 +399,8 @@ instance [LT α] : LT (List α) := ⟨List.lt⟩
instance hasDecidableLt [LT α] [h : DecidableRel (α:=α) (·<·)] : (l₁ l₂ : List α) → Decidable (l₁ < l₂)
| [], [] => isFalse (fun h => nomatch h)
| [], b::bs => isTrue (List.lt.nil _ _)
| a::as, [] => isFalse (fun h => nomatch h)
| [], _::bs => isTrue (List.lt.nil _ _)
| _::as, [] => isFalse (fun h => nomatch h)
| a::as, b::bs =>
match h a b with
| isTrue h₁ => isTrue (List.lt.head _ _ h₁)
@ -420,8 +420,8 @@ instance hasDecidableLt [LT α] [h : DecidableRel (α:=α) (·<·)] : (l₁ l₂
instance [LT α] : LE (List α) := ⟨List.le⟩
instance [LT α] [h : DecidableRel ((· < ·) : αα → Prop)] : (l₁ l₂ : List α) → Decidable (l₁ ≤ l₂) :=
fun a b => inferInstanceAs (Decidable (Not _))
instance [LT α] [_ : DecidableRel ((· < ·) : αα → Prop)] : (l₁ l₂ : List α) → Decidable (l₁ ≤ l₂) :=
fun _ _ => inferInstanceAs (Decidable (Not _))
/-- `isPrefixOf l₁ l₂` returns `true` Iff `l₁` is a prefix of `l₂`. -/
def isPrefixOf [BEq α] : List α → List α → Bool
@ -436,7 +436,7 @@ def isSuffixOf [BEq α] (l₁ l₂ : List α) : Bool :=
@[specialize] def isEqv : List α → List α → (αα → Bool) → Bool
| [], [], _ => true
| a::as, b::bs, eqv => eqv a b && isEqv as bs eqv
| _, _, eqv => false
| _, _, _ => false
protected def beq [BEq α] : List α → List α → Bool
| [], [] => true
@ -446,7 +446,7 @@ protected def beq [BEq α] : List α → List α → Bool
instance [BEq α] : BEq (List α) := ⟨List.beq⟩
@[simp] def replicate : (n : Nat) → (a : α) → List α
| 0, a => []
| 0, _ => []
| n+1, a => a :: replicate n a
def replicateTR {α : Type u} (n : Nat) (a : α) : List α :=
@ -466,7 +466,7 @@ theorem replicateTR_loop_replicate_eq (a : α) (m n : Nat) :
def dropLast {α} : List α → List α
| [] => []
| [a] => []
| [_] => []
| a::as => a :: dropLast as
@[simp] theorem length_replicate (n : Nat) (a : α) : (replicate n a).length = n := by
@ -475,7 +475,7 @@ def dropLast {α} : List α → List α
@[simp] theorem length_concat (as : List α) (a : α) : (concat as a).length = as.length + 1 := by
induction as with
| nil => rfl
| cons x xs ih => simp [concat, ih]
| cons _ xs ih => simp [concat, ih]
@[simp] theorem length_set (as : List α) (i : Nat) (a : α) : (as.set i a).length = as.length := by
induction as generalizing i with
@ -495,12 +495,12 @@ def dropLast {α} : List α → List α
@[simp] theorem length_append (as bs : List α) : (as ++ bs).length = as.length + bs.length := by
induction as with
| nil => simp
| cons a as ih => simp [ih, Nat.succ_add]
| cons _ as ih => simp [ih, Nat.succ_add]
@[simp] theorem length_map (as : List α) (f : α → β) : (as.map f).length = as.length := by
induction as with
| nil => simp [List.map]
| cons a as ih => simp [List.map, ih]
| cons _ as ih => simp [List.map, ih]
@[simp] theorem length_reverse (as : List α) : (as.reverse).length = as.length := by
induction as with

View file

@ -15,13 +15,13 @@ namespace List
and `Init.Util` depends on `Init.Data.List.Basic`. -/
def get! [Inhabited α] : List α → Nat → α
| a::as, 0 => a
| a::as, n+1 => get! as n
| a::_, 0 => a
| _::as, n+1 => get! as n
| _, _ => panic! "invalid index"
def get? : List α → Nat → Option α
| a::as, 0 => some a
| a::as, n+1 => get? as n
| a::_, 0 => some a
| _::as, n+1 => get? as n
| _, _ => none
def getD (as : List α) (idx : Nat) (a₀ : α) : α :=
@ -44,20 +44,20 @@ def head : (as : List α) → as ≠ [] → α
def tail! : List α → List α
| [] => panic! "empty list"
| a::as => as
| _::as => as
def tail? : List α → Option (List α)
| [] => none
| a::as => some as
| _::as => some as
def tailD : List α → List α → List α
| [], as₀ => as₀
| a::as, _ => as
| _::as, _ => as
def getLast : ∀ (as : List α), as ≠ [] → α
| [], h => absurd rfl h
| [a], h => a
| a::b::as, h => getLast (b::as) (fun h => List.noConfusion h)
| [a], _ => a
| _::b::as, _ => getLast (b::as) (fun h => List.noConfusion h)
def getLast! [Inhabited α] : List αα
| [] => panic! "empty list"
@ -178,7 +178,7 @@ theorem le_antisymm [LT α] [s : Antisymm (¬ · < · : αα → Prop)] {as
have : a = b := s.antisymm hab hba
simp [this, ih]
instance [LT α] [s : Antisymm (¬ · < · : αα → Prop)] : Antisymm (· ≤ · : List α → List α → Prop) where
instance [LT α] [_ : Antisymm (¬ · < · : αα → Prop)] : Antisymm (· ≤ · : List α → List α → Prop) where
antisymm h₁ h₂ := le_antisymm h₁ h₂
end List

View file

@ -90,14 +90,14 @@ def filterMapM {m : Type u → Type v} [Monad m] {α β : Type u} (f : α → m
@[specialize]
protected def foldlM {m : Type u → Type v} [Monad m] {s : Type u} {α : Type w} : (f : s → α → m s) → (init : s) → List α → m s
| f, s, [] => pure s
| _, s, [] => pure s
| f, s, a :: as => do
let s' ← f s a
List.foldlM f s' as
@[specialize]
def foldrM {m : Type u → Type v} [Monad m] {s : Type u} {α : Type w} : (f : α → s → m s) → (init : s) → List α → m s
| f, s, [] => pure s
| _, s, [] => pure s
| f, s, a :: as => do
let s' ← foldrM f s as
f a s'
@ -178,7 +178,7 @@ instance : ForIn' m (List α) α inferInstance where
@[simp] theorem forIn'_eq_forIn {α : Type u} {β : Type v} {m : Type v → Type w} [Monad m] (as : List α) (init : β) (f : α → β → m (ForInStep β)) : forIn' as init (fun a _ b => f a b) = forIn as init f := by
simp [forIn', forIn, List.forIn, List.forIn']
have : ∀ cs h, List.forIn'.loop cs (fun a x b => f a b) as init h = List.forIn.loop f as init := by
have : ∀ cs h, List.forIn'.loop cs (fun a _ b => f a b) as init h = List.forIn.loop f as init := by
intro cs h
induction as generalizing cs init with
| nil => intros; rfl

View file

@ -82,7 +82,7 @@ instance : LawfulBEq Nat where
| n+1 => congrArg succ (Nat.zero_add n)
theorem succ_add : ∀ (n m : Nat), (succ n) + m = succ (n + m)
| n, 0 => rfl
| _, 0 => rfl
| n, m+1 => congrArg succ (succ_add n m)
theorem add_succ (n m : Nat) : n + succ m = succ (n + m) :=
@ -102,7 +102,7 @@ protected theorem add_comm : ∀ (n m : Nat), n + m = m + n
apply this
protected theorem add_assoc : ∀ (n m k : Nat), (n + m) + k = n + (m + k)
| n, m, 0 => rfl
| _, _, 0 => rfl
| n, m, succ k => congrArg succ (Nat.add_assoc n m k)
protected theorem add_left_comm (n m k : Nat) : n + (m + k) = m + (n + k) := by
@ -188,11 +188,11 @@ theorem succ_sub_succ_eq_sub (n m : Nat) : succ n - succ m = n - m := by
theorem pred_le : ∀ (n : Nat), pred n ≤ n
| zero => Nat.le.refl
| succ n => le_succ _
| succ _ => le_succ _
theorem pred_lt : ∀ {n : Nat}, n ≠ 0 → pred n < n
| zero, h => absurd rfl h
| succ n, h => lt_succ_of_le (Nat.le_refl _)
| succ _, _ => lt_succ_of_le (Nat.le_refl _)
theorem sub_le (n m : Nat) : n - m ≤ n := by
induction m with
@ -200,9 +200,9 @@ theorem sub_le (n m : Nat) : n - m ≤ n := by
| succ m ih => apply Nat.le_trans (pred_le (n - m)) ih
theorem sub_lt : ∀ {n m : Nat}, 0 < n → 0 < m → n - m < n
| 0, m, h1, h2 => absurd h1 (Nat.lt_irrefl 0)
| n+1, 0, h1, h2 => absurd h2 (Nat.lt_irrefl 0)
| n+1, m+1, h1, h2 =>
| 0, _, h1, h2 => absurd h1 (Nat.lt_irrefl 0)
| _+1, 0, h1, h2 => absurd h2 (Nat.lt_irrefl 0)
| n+1, m+1, _, _ =>
Eq.symm (succ_sub_succ_eq_sub n m) ▸
show n - m < succ n from
lt_succ_of_le (sub_le n m)
@ -248,7 +248,7 @@ def lt.step {n m : Nat} : n < m → n < succ m := le_step
theorem eq_zero_or_pos : ∀ (n : Nat), n = 0 n > 0
| 0 => Or.inl rfl
| n+1 => Or.inr (succ_pos _)
| _+1 => Or.inr (succ_pos _)
def lt.base (n : Nat) : n < succ n := Nat.le_refl (succ n)
@ -311,9 +311,9 @@ theorem le_add_left (n m : Nat): n ≤ m + n :=
Nat.add_comm n m ▸ le_add_right n m
theorem le.dest : ∀ {n m : Nat}, n ≤ m → Exists (fun k => n + k = m)
| zero, zero, h => ⟨0, rfl⟩
| zero, succ n, h => ⟨succ n, Nat.add_comm 0 (succ n) ▸ rfl⟩
| succ n, zero, h => absurd h (not_succ_le_zero _)
| zero, zero, _ => ⟨0, rfl⟩
| zero, succ n, _ => ⟨succ n, Nat.add_comm 0 (succ n) ▸ rfl⟩
| succ _, zero, h => absurd h (not_succ_le_zero _)
| succ n, succ m, h =>
have : n ≤ m := Nat.le_of_succ_le_succ h
have : Exists (fun k => n + k = m) := dest this
@ -519,7 +519,7 @@ theorem succ_pred {a : Nat} (h : a ≠ 0) : a.pred.succ = a := by
theorem sub_ne_zero_of_lt : {a b : Nat} → a < b → b - a ≠ 0
| 0, 0, h => absurd h (Nat.lt_irrefl 0)
| 0, succ b, h => by simp
| 0, succ b, _ => by simp
| succ a, 0, h => absurd h (Nat.not_lt_zero a.succ)
| succ a, succ b, h => by rw [Nat.succ_sub_succ]; exact sub_ne_zero_of_lt (Nat.lt_of_succ_lt_succ h)

View file

@ -119,7 +119,7 @@ theorem mod_one (x : Nat) : x % 1 = 0 := by
have : (y : Nat) → y < 1 → y = 0 := by
intro y
cases y with
| zero => intro h; rfl
| zero => intro _; rfl
| succ y => intro h; apply absurd (Nat.lt_of_succ_lt_succ h) (Nat.not_lt_zero y)
exact this _ h

View file

@ -30,8 +30,8 @@ def Var.denote (ctx : Context) (v : Var) : Nat :=
bif v == fixedVar then 1 else go ctx v
where
go : List Nat → Nat → Nat
| [], i => 0
| a::as, 0 => a
| [], _ => 0
| a::_, 0 => a
| _::as, i+1 => go as i
inductive Expr where

View file

@ -31,7 +31,7 @@ def toMonad [Monad m] [Alternative m] : Option α → m α
| none, _ => false
@[inline] protected def bind : Option α → (α → Option β) → Option β
| none, b => none
| none, _ => none
| some a, b => b a
@[inline] protected def map (f : α → β) (o : Option α) : Option β :=
@ -44,7 +44,7 @@ def toMonad [Monad m] [Alternative m] : Option α → m α
return none
theorem map_id : (Option.map id : Option α → Option α) = id :=
funext (fun o => match o with | none => rfl | some x => rfl)
funext (fun o => match o with | none => rfl | some _ => rfl)
instance : Functor Option where
map := Option.map
@ -69,14 +69,14 @@ instance : OrElse (Option α) where
orElse := Option.orElse
@[inline] protected def lt (r : αα → Prop) : Option α → Option α → Prop
| none, some x => True
| none, some _ => True
| some x, some y => r x y
| _, _ => False
instance (r : αα → Prop) [s : DecidableRel r] : DecidableRel (Option.lt r)
| none, some y => isTrue trivial
| none, some _ => isTrue trivial
| some x, some y => s x y
| some x, none => isFalse not_false
| some _, none => isFalse not_false
| none, none => isFalse not_false
end Option

View file

@ -9,10 +9,10 @@ import Init.Data.Option.Basic
universe u v
theorem Option.eq_of_eq_some {α : Type u} : ∀ {x y : Option α}, (∀z, x = some z ↔ y = some z) → x = y
| none, none, h => rfl
| none, none, _ => rfl
| none, some z, h => Option.noConfusion ((h z).2 rfl)
| some z, none, h => Option.noConfusion ((h z).1 rfl)
| some z, some w, h => Option.noConfusion ((h w).2 rfl) (congrArg some)
| some _, some w, h => Option.noConfusion ((h w).2 rfl) (congrArg some)
theorem Option.eq_none_of_isNone {α : Type u} : ∀ {o : Option α}, o.isNone → o = none
| none, h => rfl
| none, _ => rfl

View file

@ -84,7 +84,7 @@ The parameter `r` is the "remaining" magnitude.
-/
private partial def randNatAux {gen : Type u} [RandomGen gen] (genLo genMag : Nat) : Nat → (Nat × gen) → Nat × gen
| 0, (v, g) => (v, g)
| r'@(r+1), (v, g) =>
| r'@(_+1), (v, g) =>
let (x, g') := RandomGen.next g
let v' := v*genMag + (x - genLo)
randNatAux genLo genMag (r' / genMag - 1) (v', g')

View file

@ -29,7 +29,7 @@ abbrev reprArg [Repr α] (a : α) : Format :=
/- Auxiliary class for marking types that should be considered atomic by `Repr` methods.
We use it at `Repr (List α)` to decide whether `bracketFill` should be used or not. -/
class ReprAtom (α : Type u)
class ReprAtom (_ : Type u)
-- This instance is needed because `id` is not reducible
instance [Repr α] : Repr (id α) :=
@ -62,7 +62,7 @@ instance [Repr α] : Repr (ULift.{v} α) where
Repr.addAppParen ("ULift.up " ++ reprArg v.1) prec
instance : Repr Unit where
reprPrec v _ := "()"
reprPrec _ _ := "()"
instance [Repr α] : Repr (Option α) where
reprPrec
@ -88,7 +88,7 @@ instance [Repr α] [ReprTuple β] : ReprTuple (α × β) where
instance [Repr α] [ReprTuple β] : Repr (α × β) where
reprPrec | (a, b), _ => Format.bracket "(" (Format.joinSep (reprTuple b [repr a]).reverse ("," ++ Format.line)) ")"
instance {β : α → Type v} [Repr α] [s : (x : α) → Repr (β x)] : Repr (Sigma β) where
instance {β : α → Type v} [Repr α] [_ : (x : α) → Repr (β x)] : Repr (Sigma β) where
reprPrec | ⟨a, b⟩, _ => Format.bracket "⟨" (repr a ++ ", " ++ repr b) "⟩"
instance {p : α → Prop} [Repr α] : Repr (Subtype p) where
@ -116,7 +116,7 @@ def digitChar (n : Nat) : Char :=
'*'
def toDigitsCore (base : Nat) : Nat → Nat → List Char → List Char
| 0, n, ds => ds
| 0, _, ds => ds
| fuel+1, n, ds =>
let d := digitChar <| n % base;
let n' := n / base;

View file

@ -45,7 +45,7 @@ def toList (s : String) : List Char :=
s.data
private def utf8GetAux : List Char → Pos → Pos → Char
| [], i, p => default
| [], _, _ => default
| c::cs, i, p => if i = p then c else utf8GetAux cs (i + c) p
@[extern "lean_string_utf8_get"]
@ -56,7 +56,7 @@ def getOp (self : String) (idx : Pos) : Char :=
self.get idx
private def utf8SetAux (c' : Char) : List Char → Pos → Pos → List Char
| [], i, p => []
| [], _, _ => []
| c::cs, i, p =>
if i = p then (c'::cs) else c::(utf8SetAux c' cs (i + c) p)
@ -73,7 +73,7 @@ def next (s : @& String) (p : @& Pos) : Pos :=
p + c
private def utf8PrevAux : List Char → Pos → Pos → Pos
| [], i, p => 0
| [], _, _ => 0
| c::cs, i, p =>
let i' := i + c
if i' = p then i else utf8PrevAux cs i' p
@ -232,7 +232,7 @@ def remainingBytes : Iterator → Nat
| ⟨s, i⟩ => s.endPos.byteIdx - i.byteIdx
def pos : Iterator → Pos
| ⟨s, i⟩ => i
| ⟨_, i⟩ => i
def curr : Iterator → Char
| ⟨s, i⟩ => get s i
@ -250,7 +250,7 @@ def hasNext : Iterator → Bool
| ⟨s, i⟩ => i.byteIdx < s.endPos.byteIdx
def hasPrev : Iterator → Bool
| ⟨s, i⟩ => i.byteIdx > 0
| ⟨_, i⟩ => i.byteIdx > 0
def setCurr : Iterator → Char → Iterator
| ⟨s, i⟩, c => ⟨s.set i c, i⟩
@ -403,11 +403,11 @@ return the offset there of the previous codepoint. -/
if absP = b then p else { byteIdx := (s.prev absP).byteIdx - b.byteIdx }
def nextn : Substring → Nat → String.Pos → String.Pos
| ss, 0, p => p
| _, 0, p => p
| ss, i+1, p => ss.nextn i (ss.next p)
def prevn : Substring → Nat → String.Pos → String.Pos
| ss, 0, p => p
| _, 0, p => p
| ss, i+1, p => ss.prevn i (ss.prev p)
@[inline] def front (s : Substring) : Char :=
@ -423,16 +423,16 @@ or `s.bsize` if `c` doesn't occur. -/
| ss@⟨s, b, e⟩, n => ⟨s, b + ss.nextn n 0, e⟩
@[inline] def dropRight : Substring → Nat → Substring
| ss@⟨s, b, e⟩, n => ⟨s, b, b + ss.prevn n ⟨ss.bsize⟩⟩
| ss@⟨s, b, _⟩, n => ⟨s, b, b + ss.prevn n ⟨ss.bsize⟩⟩
@[inline] def take : Substring → Nat → Substring
| ss@⟨s, b, e⟩, n => ⟨s, b, b + ss.nextn n 0⟩
| ss@⟨s, b, _⟩, n => ⟨s, b, b + ss.nextn n 0⟩
@[inline] def takeRight : Substring → Nat → Substring
| ss@⟨s, b, e⟩, n => ⟨s, b + ss.prevn n ⟨ss.bsize⟩, e⟩
@[inline] def atEnd : Substring → String.Pos → Bool
| ⟨s, b, e⟩, p => b + p == e
| ⟨_, b, e⟩, p => b + p == e
@[inline] def extract : Substring → String.Pos → String.Pos → Substring
| ⟨s, b, e⟩, b', e' => if b' ≥ e' then ⟨"", 0, 0⟩ else ⟨s, e.min (b+b'), e.min (b+e')⟩

View file

@ -46,7 +46,7 @@ instance {p : Prop} : ToString (Decidable p) := ⟨fun h =>
| Decidable.isFalse _ => "false"⟩
protected def List.toStringAux {α : Type u} [ToString α] : Bool → List α → String
| b, [] => ""
| _, [] => ""
| true, x::xs => toString x ++ List.toStringAux false xs
| false, x::xs => ", " ++ toString x ++ List.toStringAux false xs
@ -64,7 +64,7 @@ instance {α : Type u} [ToString α] : ToString (ULift.{v} α) :=
⟨fun v => toString v.1⟩
instance : ToString Unit :=
⟨fun u => "()"⟩
⟨fun _ => "()"⟩
instance : ToString Nat :=
⟨fun n => Nat.repr n⟩
@ -117,7 +117,7 @@ instance {α : Type u} {β : Type v} [ToString α] [ToString β] : ToString (Sum
instance {α : Type u} {β : Type v} [ToString α] [ToString β] : ToString (α × β) := ⟨fun (a, b) =>
"(" ++ toString a ++ ", " ++ toString b ++ ")"⟩
instance {α : Type u} {β : α → Type v} [ToString α] [s : ∀ x, ToString (β x)] : ToString (Sigma β) := ⟨fun ⟨a, b⟩ =>
instance {α : Type u} {β : α → Type v} [ToString α] [_ : ∀ x, ToString (β x)] : ToString (Sigma β) := ⟨fun ⟨a, b⟩ =>
"⟨" ++ toString a ++ ", " ++ toString b ++ "⟩"⟩
instance {α : Type u} {p : α → Prop} [ToString α] : ToString (Subtype p) := ⟨fun s =>

View file

@ -106,7 +106,7 @@ def getRoot : Name → Name
@[export lean_is_inaccessible_user_name]
def isInaccessibleUserName : Name → Bool
| Name.str _ s _ => s.contains '✝' || s == "_inaccessible"
| Name.num p idx _ => isInaccessibleUserName p
| Name.num p _ _ => isInaccessibleUserName p
| _ => false
def escapePart (s : String) : Option String :=
@ -250,7 +250,7 @@ partial def getTailInfo? : Syntax → Option SourceInfo
| ident info .. => info
| node SourceInfo.none _ args =>
args.findSomeRev? getTailInfo?
| node info _ args => info
| node info _ _ => info
| _ => none
def getTailInfo (stx : Syntax) : SourceInfo :=
@ -291,7 +291,7 @@ partial def setTailInfoAux (info : SourceInfo) : Syntax → Option Syntax
match updateLast args (setTailInfoAux info) args.size with
| some args => some <| node info k args
| none => none
| stx => none
| _ => none
def setTailInfo (stx : Syntax) (info : SourceInfo) : Syntax :=
match setTailInfoAux info stx with
@ -318,8 +318,8 @@ partial def setHeadInfoAux (info : SourceInfo) : Syntax → Option Syntax
| node i k args =>
match updateFirst args (setHeadInfoAux info) 0 with
| some args => some <| node i k args
| noxne => none
| stx => none
| _ => none
| _ => none
def setHeadInfo (stx : Syntax) (info : SourceInfo) : Syntax :=
match setHeadInfoAux info stx with
@ -787,7 +787,7 @@ private def getEscapedNameParts? (acc : List String) : Name → Option (List Str
| Name.str n s _ => do
let s ← Name.escapePart s
getEscapedNameParts? (s::acc) n
| Name.num n i _ => none
| Name.num _ _ _ => none
private def quoteNameMk : Name → Syntax
| Name.anonymous => mkCIdent ``Name.anonymous

View file

@ -13,7 +13,7 @@ universe u v w
fun x => f (g x)
@[inline] def Function.const {α : Sort u} (β : Sort v) (a : α) : β → α :=
fun x => a
fun _ => a
set_option checkBinderAnnotations false in
@[reducible] def inferInstance {α : Sort u} [i : α] : α := i
@ -109,8 +109,8 @@ inductive HEq : {α : Sort u} → α → {β : Sort u} → β → Prop where
theorem eq_of_heq {α : Sort u} {a a' : α} (h : HEq a a') : Eq a a' :=
have : (α β : Sort u) → (a : α) → (b : β) → HEq a b → (h : Eq α β) → Eq (cast h a) b :=
fun α β a b h₁ =>
HEq.rec (motive := fun {β} (b : β) (h : HEq a b) => (h₂ : Eq α β) → Eq (cast h₂ a) b)
fun α _ a _ h₁ =>
HEq.rec (motive := fun {β} (b : β) (_ : HEq a b) => (h₂ : Eq α β) → Eq (cast h₂ a) b)
(fun (h₂ : Eq α α) => rfl)
h₁
this α α a a' h rfl
@ -171,7 +171,7 @@ structure Subtype {α : Sort u} (p : α → Prop) where
@[reducible] def typedExpr (α : Sort u) (a : α) : α := a
/-- Auxiliary Declaration used to implement the named patterns `x@h:p` -/
@[reducible] def namedPattern {α : Sort u} (x a : α) (h : Eq x a) : α := a
@[reducible] def namedPattern {α : Sort u} (x a : α) (_ : Eq x a) : α := a
/- Auxiliary axiom used to implement `sorry`. -/
@[extern "lean_sorry", neverExtract]
@ -179,10 +179,10 @@ axiom sorryAx (α : Sort u) (synthetic := false) : α
theorem eq_false_of_ne_true : {b : Bool} → Not (Eq b true) → Eq b false
| true, h => False.elim (h rfl)
| false, h => rfl
| false, _ => rfl
theorem eq_true_of_ne_false : {b : Bool} → Not (Eq b false) → Eq b true
| true, h => rfl
| true, _ => rfl
| false, h => False.elim (h rfl)
theorem ne_false_of_eq_true : {b : Bool} → Eq b true → Not (Eq b false)
@ -236,7 +236,7 @@ structure PLift (α : Sort u) : Type u where
/- Bijection between α and PLift α -/
theorem PLift.up_down {α : Sort u} : ∀ (b : PLift α), Eq (up (down b)) b
| up a => rfl
| up _ => rfl
theorem PLift.down_up {α : Sort u} (a : α) : Eq (down (up a)) a :=
rfl
@ -256,7 +256,7 @@ structure ULift.{r, s} (α : Type s) : Type (max s r) where
/- Bijection between α and ULift.{v} α -/
theorem ULift.up_down {α : Type u} : ∀ (b : ULift.{v} α), Eq (up (down b)) b
| up a => rfl
| up _ => rfl
theorem ULift.down_up {α : Type u} (a : α) : Eq (down (up.{v} a)) a :=
rfl
@ -282,13 +282,13 @@ abbrev DecidableEq (α : Sort u) :=
def decEq {α : Sort u} [s : DecidableEq α] (a b : α) : Decidable (Eq a b) :=
s a b
theorem decide_eq_true : [s : Decidable p] → p → Eq (decide p) true
theorem decide_eq_true : [_ : Decidable p] → p → Eq (decide p) true
| isTrue _, _ => rfl
| isFalse h₁, h₂ => absurd h₂ h₁
theorem decide_eq_false : [s : Decidable p] → Not p → Eq (decide p) false
theorem decide_eq_false : [_ : Decidable p] → Not p → Eq (decide p) false
| isTrue h₁, h₂ => absurd h₁ h₂
| isFalse h, _ => rfl
| isFalse _, _ => rfl
theorem of_decide_eq_true [s : Decidable p] : Eq (decide p) true → p := fun h =>
match (generalizing := false) s with
@ -302,7 +302,7 @@ theorem of_decide_eq_false [s : Decidable p] : Eq (decide p) false → Not p :=
theorem of_decide_eq_self_eq_true [s : DecidableEq α] (a : α) : Eq (decide (Eq a a)) true :=
match (generalizing := false) s a a with
| isTrue h₁ => rfl
| isTrue _ => rfl
| isFalse h₁ => absurd rfl h₁
@[inline] instance : DecidableEq Bool :=
@ -384,7 +384,7 @@ instance : Inhabited Nat where
default := Nat.zero
/- For numeric literals notation -/
class OfNat (α : Type u) (n : Nat) where
class OfNat (α : Type u) (_ : Nat) where
ofNat : α
@[defaultInstance 100] /- low prio -/
@ -585,7 +585,7 @@ attribute [matchPattern] Nat.add Add.add HAdd.hAdd Neg.neg
set_option bootstrap.genMatcherCode false in
@[extern "lean_nat_mul"]
protected def Nat.mul : (@& Nat) → (@& Nat) → Nat
| a, 0 => 0
| _, 0 => 0
| a, Nat.succ b => Nat.add (Nat.mul a b) a
instance : Mul Nat where
@ -604,26 +604,26 @@ set_option bootstrap.genMatcherCode false in
@[extern "lean_nat_dec_eq"]
def Nat.beq : (@& Nat) → (@& Nat) → Bool
| zero, zero => true
| zero, succ m => false
| succ n, zero => false
| zero, succ _ => false
| succ _, zero => false
| succ n, succ m => beq n m
instance : BEq Nat where
beq := Nat.beq
theorem Nat.eq_of_beq_eq_true : {n m : Nat} → Eq (beq n m) true → Eq n m
| zero, zero, h => rfl
| zero, succ m, h => Bool.noConfusion h
| succ n, zero, h => Bool.noConfusion h
| zero, zero, _ => rfl
| zero, succ _, h => Bool.noConfusion h
| succ _, zero, h => Bool.noConfusion h
| succ n, succ m, h =>
have : Eq (beq n m) true := h
have : Eq n m := eq_of_beq_eq_true this
this ▸ rfl
theorem Nat.ne_of_beq_eq_false : {n m : Nat} → Eq (beq n m) false → Not (Eq n m)
| zero, zero, h₁, h₂ => Bool.noConfusion h₁
| zero, succ m, h₁, h₂ => Nat.noConfusion h₂
| succ n, zero, h₁, h₂ => Nat.noConfusion h₂
| zero, zero, h₁, _ => Bool.noConfusion h₁
| zero, succ _, _, h₂ => Nat.noConfusion h₂
| succ _, zero, _, h₂ => Nat.noConfusion h₂
| succ n, succ m, h₁, h₂ =>
have : Eq (beq n m) false := h₁
Nat.noConfusion h₂ (fun h₂ => absurd h₂ (ne_of_beq_eq_false this))
@ -640,8 +640,8 @@ set_option bootstrap.genMatcherCode false in
@[extern "lean_nat_dec_le"]
def Nat.ble : @& Nat → @& Nat → Bool
| zero, zero => true
| zero, succ m => true
| succ n, zero => false
| zero, succ _ => true
| succ _, zero => false
| succ n, succ m => ble n m
protected inductive Nat.le (n : Nat) : Nat → Prop
@ -659,7 +659,7 @@ instance : LT Nat where
theorem Nat.not_succ_le_zero : ∀ (n : Nat), LE.le (succ n) 0 → False
| 0, h => nomatch h
| succ n, h => nomatch h
| succ _, h => nomatch h
theorem Nat.not_lt_zero (n : Nat) : Not (LT.lt n 0) :=
not_succ_le_zero n
@ -705,8 +705,8 @@ def Nat.pred : (@& Nat) → Nat
theorem Nat.pred_le_pred : {n m : Nat} → LE.le n m → LE.le (pred n) (pred m)
| _, _, Nat.le.refl => Nat.le.refl
| 0, succ m, Nat.le.step h => h
| succ n, succ m, Nat.le.step h => Nat.le_trans (le_succ _) h
| 0, succ _, Nat.le.step h => h
| succ _, succ _, Nat.le.step h => Nat.le_trans (le_succ _) h
theorem Nat.le_of_succ_le_succ {n m : Nat} : LE.le (succ n) (succ m) → LE.le n m :=
pred_le_pred
@ -715,9 +715,9 @@ theorem Nat.le_of_lt_succ {m n : Nat} : LT.lt m (succ n) → LE.le m n :=
le_of_succ_le_succ
protected theorem Nat.eq_or_lt_of_le : {n m: Nat} → LE.le n m → Or (Eq n m) (LT.lt n m)
| zero, zero, h => Or.inl rfl
| zero, succ n, h => Or.inr (Nat.succ_le_succ (Nat.zero_le _))
| succ n, zero, h => absurd h (not_succ_le_zero _)
| zero, zero, _ => Or.inl rfl
| zero, succ _, _ => Or.inr (Nat.succ_le_succ (Nat.zero_le _))
| succ _, zero, h => absurd h (not_succ_le_zero _)
| succ n, succ m, h =>
have : LE.le n m := Nat.le_of_succ_le_succ h
match Nat.eq_or_lt_of_le this with
@ -755,7 +755,7 @@ protected theorem Nat.lt_of_le_of_ne {n m : Nat} (h₁ : LE.le n m) (h₂ : Not
| Or.inl h₃ => h₃
| Or.inr h₃ => absurd (Nat.le_antisymm h₁ h₃) h₂
theorem Nat.le_of_ble_eq_true (h : Eq (Nat.ble n m) true) : LE.le n m :=
theorem Nat.le_of_ble_eq_true (_ : Eq (Nat.ble n m) true) : LE.le n m :=
match n, m with
| 0, _ => Nat.zero_le _
| succ _, succ _ => Nat.succ_le_succ (le_of_ble_eq_true h)
@ -766,7 +766,7 @@ theorem Nat.ble_self_eq_true : (n : Nat) → Eq (Nat.ble n n) true
theorem Nat.ble_succ_eq_true : {n m : Nat} → Eq (Nat.ble n m) true → Eq (Nat.ble n (succ m)) true
| 0, _, _ => rfl
| succ n, succ m, h => ble_succ_eq_true (n := n) h
| succ n, succ _, h => ble_succ_eq_true (n := n) h
theorem Nat.ble_eq_true_of_le (h : LE.le n m) : Eq (Nat.ble n m) true :=
match h with
@ -807,7 +807,7 @@ structure Fin (n : Nat) where
isLt : LT.lt val n
theorem Fin.eq_of_val_eq {n} : ∀ {i j : Fin n}, Eq i.val j.val → Eq i j
| ⟨v, h⟩, ⟨_, _⟩, rfl => rfl
| ⟨_, _⟩, ⟨_, _⟩, rfl => rfl
theorem Fin.val_eq_of_eq {n} {i j : Fin n} (h : Eq i j) : Eq i.val j.val :=
h ▸ rfl
@ -1021,7 +1021,7 @@ def Char.ofNat (n : Nat) : Char :=
(fun _ => { val := ⟨{ val := 0, isLt := by decide }⟩, valid := Or.inl (by decide) })
theorem Char.eq_of_val_eq : ∀ {c d : Char}, Eq c.val d.val → Eq c d
| ⟨v, h⟩, ⟨_, _⟩, rfl => rfl
| ⟨_, _⟩, ⟨_, _⟩, rfl => rfl
theorem Char.val_eq_of_eq : ∀ {c d : Char}, Eq c d → Eq c.val d.val
| _, _, rfl => rfl
@ -1072,8 +1072,8 @@ instance {α} : Inhabited (List α) where
protected def List.hasDecEq {α: Type u} [DecidableEq α] : (a b : List α) → Decidable (Eq a b)
| nil, nil => isTrue rfl
| cons a as, nil => isFalse (fun h => List.noConfusion h)
| nil, cons b bs => isFalse (fun h => List.noConfusion h)
| cons _ as, nil => isFalse (fun h => List.noConfusion h)
| nil, cons _ bs => isFalse (fun h => List.noConfusion h)
| cons a as, cons b bs =>
match decEq a b with
| isTrue hab =>
@ -1090,17 +1090,17 @@ def List.foldl {α β} (f : α → β → α) : (init : α) → List β → α
| a, cons b l => foldl f (f a b) l
def List.set : List α → Nat → α → List α
| cons a as, 0, b => cons b as
| cons _ as, 0, b => cons b as
| cons a as, Nat.succ n, b => cons a (set as n b)
| nil, _, _ => nil
def List.length : List α → Nat
| nil => 0
| cons a as => HAdd.hAdd (length as) 1
| cons _ as => HAdd.hAdd (length as) 1
def List.lengthTRAux : List α → Nat → Nat
| nil, n => n
| cons a as, n => lengthTRAux as (Nat.succ n)
| cons _ as, n => lengthTRAux as (Nat.succ n)
def List.lengthTR (as : List α) : Nat :=
lengthTRAux as 0
@ -1113,8 +1113,8 @@ def List.concat {α : Type u} : List αα → List α
| cons a as, b => cons a (concat as b)
def List.get {α : Type u} : (as : List α) → Fin as.length → α
| cons a as, ⟨0, _⟩ => a
| cons a as, ⟨Nat.succ i, h⟩ => get as ⟨i, Nat.le_of_succ_le_succ h⟩
| cons a _, ⟨0, _⟩ => a
| cons _ as, ⟨Nat.succ i, h⟩ => get as ⟨i, Nat.le_of_succ_le_succ h⟩
structure String where
data : List Char
@ -1469,7 +1469,7 @@ variable {ρ : Type u} {m : Type u → Type v} [Monad m] {α β : Type u}
pure
@[inline] protected def pure (a : α) : ReaderT ρ m α :=
fun r => pure a
fun _ => pure a
@[inline] protected def bind (x : ReaderT ρ m α) (f : α → ReaderT ρ m β) : ReaderT ρ m β :=
fun r => bind (x r) fun a => f a r
@ -1739,8 +1739,8 @@ instance : Inhabited Name where
protected def Name.hash : Name → UInt64
| Name.anonymous => UInt64.ofNatCore 1723 (by decide)
| Name.str p s h => h
| Name.num p v h => h
| Name.str _ _ h => h
| Name.num _ _ h => h
instance : Hashable Name where
hash := Name.hash
@ -1860,7 +1860,7 @@ namespace Syntax
def getKind (stx : Syntax) : SyntaxNodeKind :=
match stx with
| Syntax.node _ k args => k
| Syntax.node _ k _ => k
-- We use these "pseudo kinds" for antiquotation kinds.
-- For example, an antiquotation `$id:ident` (using Lean.Parser.Term.ident)
-- is compiled to ``if stx.isOfKind `ident ...``
@ -2139,7 +2139,7 @@ private def assembleParts : List Name → Name → Name
| List.nil, acc => acc
| List.cons (Name.str _ s _) ps, acc => assembleParts ps (Name.mkStr acc s)
| List.cons (Name.num _ n _) ps, acc => assembleParts ps (Name.mkNum acc n)
| _, acc => panic "Error: unreachable @ assembleParts"
| _, _ => panic "Error: unreachable @ assembleParts"
private def extractImported (scps : List MacroScope) (mainModule : Name) : Name → List Name → MacroScopesView
| n@(Name.str p str _), parts =>
@ -2154,12 +2154,12 @@ private def extractMainModule (scps : List MacroScope) : Name → List Name →
match beq str "_@" with
| true => { name := p, mainModule := assembleParts parts Name.anonymous, imported := Name.anonymous, scopes := scps }
| false => extractMainModule scps p (List.cons n parts)
| n@(Name.num p num _), acc => extractImported scps (assembleParts acc Name.anonymous) n List.nil
| n@(Name.num _ num _), acc => extractImported scps (assembleParts acc Name.anonymous) n List.nil
| _, _ => panic "Error: unreachable @ extractMainModule"
private def extractMacroScopesAux : Name → List MacroScope → MacroScopesView
| Name.num p scp _, acc => extractMacroScopesAux p (List.cons scp acc)
| Name.str p str _, acc => extractMainModule acc p List.nil -- str must be "_hyg"
| Name.str p _ _, acc => extractMainModule acc p List.nil -- str must be "_hyg"
| _, _ => panic "Error: unreachable @ extractMacroScopesAux"
/--

View file

@ -23,10 +23,10 @@ theorem eq_false (h : ¬ p) : p = False :=
theorem eq_false' (h : p → False) : p = False :=
propext <| Iff.intro (fun h' => absurd h' h) (fun h' => False.elim h')
theorem eq_true_of_decide {p : Prop} {s : Decidable p} (h : decide p = true) : p = True :=
propext <| Iff.intro (fun h => trivial) (fun _ => of_decide_eq_true h)
theorem eq_true_of_decide {p : Prop} {_ : Decidable p} (h : decide p = true) : p = True :=
propext <| Iff.intro (fun _ => trivial) (fun _ => of_decide_eq_true h)
theorem eq_false_of_decide {p : Prop} {s : Decidable p} (h : decide p = false) : p = False :=
theorem eq_false_of_decide {p : Prop} {_ : Decidable p} (h : decide p = false) : p = False :=
propext <| Iff.intro (fun h' => absurd h' (of_decide_eq_false h)) (fun h => False.elim h)
theorem implies_congr {p₁ p₂ : Sort u} {q₁ q₂ : Sort v} (h₁ : p₁ = p₂) (h₂ : q₁ = q₂) : (p₁ → q₁) = (p₂ → q₂) :=
@ -105,11 +105,11 @@ theorem dite_congr {s : Decidable b} [Decidable c]
@[simp] theorem and_false (p : Prop) : (p ∧ False) = False := propext <| Iff.intro (fun h => h.2) (fun h => False.elim h)
@[simp] theorem false_and (p : Prop) : (False ∧ p) = False := propext <| Iff.intro (fun h => h.1) (fun h => False.elim h)
@[simp] theorem or_self (p : Prop) : (p p) = p := propext <| Iff.intro (fun | Or.inl h => h | Or.inr h => h) (fun h => Or.inl h)
@[simp] theorem or_true (p : Prop) : (p True) = True := propext <| Iff.intro (fun h => trivial) (fun h => Or.inr trivial)
@[simp] theorem true_or (p : Prop) : (True p) = True := propext <| Iff.intro (fun h => trivial) (fun h => Or.inl trivial)
@[simp] theorem or_true (p : Prop) : (p True) = True := propext <| Iff.intro (fun _ => trivial) (fun _ => Or.inr trivial)
@[simp] theorem true_or (p : Prop) : (True p) = True := propext <| Iff.intro (fun _ => trivial) (fun _ => Or.inl trivial)
@[simp] theorem or_false (p : Prop) : (p False) = p := propext <| Iff.intro (fun | Or.inl h => h | Or.inr h => False.elim h) (fun h => Or.inl h)
@[simp] theorem false_or (p : Prop) : (False p) = p := propext <| Iff.intro (fun | Or.inr h => h | Or.inl h => False.elim h) (fun h => Or.inr h)
@[simp] theorem iff_self (p : Prop) : (p ↔ p) = True := propext <| Iff.intro (fun h => trivial) (fun _ => Iff.intro id id)
@[simp] theorem iff_self (p : Prop) : (p ↔ p) = True := propext <| Iff.intro (fun _ => trivial) (fun _ => Iff.intro id id)
@[simp] theorem iff_true (p : Prop) : (p ↔ True) = p := propext <| Iff.intro (fun h => h.mpr trivial) (fun h => Iff.intro (fun _ => trivial) (fun _ => h))
@[simp] theorem true_iff (p : Prop) : (True ↔ p) = p := propext <| Iff.intro (fun h => h.mp trivial) (fun h => Iff.intro (fun _ => h) (fun _ => trivial))
@[simp] theorem iff_false (p : Prop) : (p ↔ False) = ¬p := propext <| Iff.intro (fun h hp => h.mp hp) (fun h => Iff.intro h False.elim)

View file

@ -20,7 +20,7 @@ From now on, the inductive Compiler will automatically generate sizeOf instances
/- Every Type `α` has a default SizeOf instance that just returns 0 for every element of `α` -/
protected def default.sizeOf (α : Sort u) : α → Nat
| a => 0
| _ => 0
instance (priority := low) (α : Sort u) : SizeOf α where
sizeOf := default.sizeOf α

View file

@ -17,7 +17,7 @@ instance {ε σ : Type} {α : Type} [Inhabited ε] : Inhabited (EST ε σ α) :=
instance (σ : Type) : Monad (ST σ) := inferInstanceAs (Monad (EST _ _))
-- Auxiliary class for inferring the "state" of `EST` and `ST` monads
class STWorld (σ : outParam Type) (m : Type → Type)
class STWorld (_ : outParam Type) (_ : Type → Type)
instance {σ m n} [MonadLift m n] [STWorld σ m] : STWorld σ n := ⟨⟩
instance {ε σ} : STWorld σ (EST ε σ) := ⟨⟩
@ -44,7 +44,7 @@ namespace ST
/- References -/
constant RefPointed : NonemptyType.{0}
structure Ref (σ : Type) (α : Type) : Type where
structure Ref (_ : Type) (α : Type) : Type where
ref : RefPointed.type
h : Nonempty α

View file

@ -384,7 +384,7 @@ syntax (name := dbgTrace) "dbg_trace " str : tactic
/-- `stop` is a helper tactic for "discarding" the rest of a proof. It is useful when working on the middle of a complex proofs,
and less messy than commenting the remainder of the proof. -/
macro "stop" s:tacticSeq : tactic => `(repeat sorry)
macro "stop" _:tacticSeq : tactic => `(repeat sorry)
/--
The tactic `specialize h a₁ ... aₙ` works on local hypothesis `h`.

View file

@ -10,14 +10,14 @@ import Init.Data.ToString.Basic
universe u v
/- debugging helper functions -/
@[neverExtract, extern "lean_dbg_trace"]
def dbgTrace {α : Type u} (s : String) (f : Unit → α) : α := f ()
def dbgTrace {α : Type u} (_ : String) (f : Unit → α) : α := f ()
def dbgTraceVal {α : Type u} [ToString α] (a : α) : α :=
dbgTrace (toString a) (fun _ => a)
/- Display the given message if `a` is shared, that is, RC(a) > 1 -/
@[neverExtract, extern "lean_dbg_trace_if_shared"]
def dbgTraceIfShared {α : Type u} (s : String) (a : α) : α := a
def dbgTraceIfShared {α : Type u} (_ : String) (a : α) : α := a
@[extern "lean_dbg_sleep"]
def dbgSleep {α : Type u} (ms : UInt32) (f : Unit → α) : α := f ()
@ -37,10 +37,10 @@ def dbgSleep {α : Type u} (ms : UInt32) (f : Unit → α) : α := f ()
@[extern "lean_ptr_addr"]
unsafe def ptrAddrUnsafe {α : Type u} (a : @& α) : USize := 0
@[inline] unsafe def withPtrAddrUnsafe {α : Type u} {β : Type v} (a : α) (k : USize → β) (h : ∀ u₁ u₂, k u₁ = k u₂) : β :=
@[inline] unsafe def withPtrAddrUnsafe {α : Type u} {β : Type v} (a : α) (k : USize → β) (_ : ∀ u₁ u₂, k u₁ = k u₂) : β :=
k (ptrAddrUnsafe a)
@[inline] unsafe def withPtrEqUnsafe {α : Type u} (a b : α) (k : Unit → Bool) (h : a = b → k () = true) : Bool :=
@[inline] unsafe def withPtrEqUnsafe {α : Type u} (a b : α) (k : Unit → Bool) (_ : a = b → k () = true) : Bool :=
if ptrAddrUnsafe a == ptrAddrUnsafe b then true else k ()
@[implementedBy withPtrEqUnsafe]

View file

@ -43,7 +43,7 @@ class WellFoundedRelation (α : Sort u) where
namespace WellFounded
def apply {α : Sort u} {r : αα → Prop} (wf : WellFounded r) (a : α) : Acc r a :=
WellFounded.recOn (motive := fun x => (y : α) → Acc r y)
WellFounded.recOn (motive := fun _ => (y : α) → Acc r y)
wf (fun p => p) a
section
@ -51,7 +51,7 @@ variable {α : Sort u} {r : αα → Prop} (hwf : WellFounded r)
theorem recursion {C : α → Sort v} (a : α) (h : ∀ x, (∀ y, r y x → C y) → C x) : C a := by
induction (apply hwf a) with
| intro x₁ ac₁ ih => exact h x₁ ih
| intro x₁ _ ih => exact h x₁ ih
theorem induction {C : α → Prop} (a : α) (h : ∀ x, (∀ y, r y x → C y) → C x) : C a :=
recursion hwf a h
@ -62,11 +62,11 @@ variable (F : ∀ x, (∀ y, r y x → C y) → C x)
set_option codegen false in
def fixF (x : α) (a : Acc r x) : C x := by
induction a with
| intro x₁ ac₁ ih => exact F x₁ ih
| intro x₁ _ ih => exact F x₁ ih
def fixFEq (x : α) (acx : Acc r x) : fixF F x acx = F x (fun (y : α) (p : r y x) => fixF F y (Acc.inv acx p)) := by
induction acx with
| intro x r ih => exact rfl
| intro x r _ => exact rfl
end
@ -79,7 +79,7 @@ def fix (hwf : WellFounded r) (F : ∀ x, (∀ y, r y x → C y) → C x) (x :
-- Well-founded fixpoint satisfies fixpoint equation
theorem fix_eq (hwf : WellFounded r) (F : ∀ x, (∀ y, r y x → C y) → C x) (x : α) :
fix hwf F x = F x (fun y h => fix hwf F y) :=
fix hwf F x = F x (fun y _ => fix hwf F y) :=
fixFEq F x (apply hwf x)
end WellFounded
@ -101,7 +101,7 @@ variable {α : Sort u} {r q : αα → Prop}
def accessible {a : α} (h₁ : Subrelation q r) (ac : Acc r a) : Acc q a := by
induction ac with
| intro x ax ih =>
| intro x _ ih =>
apply Acc.intro
intro y h
exact ih y (h₁ h)
@ -216,9 +216,9 @@ variable {ra : αα → Prop} {rb : β → β → Prop}
def lexAccessible (aca : (a : α) → Acc ra a) (acb : (b : β) → Acc rb b) (a : α) (b : β) : Acc (Lex ra rb) (a, b) := by
induction (aca a) generalizing b with
| intro xa aca iha =>
| intro xa _ iha =>
induction (acb b) with
| intro xb acb ihb =>
| intro xb _ ihb =>
apply Acc.intro (xa, xb)
intro p lt
cases lt with
@ -268,9 +268,9 @@ variable {r : αα → Prop} {s : ∀ (a : α), β a → β a → Prop}
def lexAccessible {a} (aca : Acc r a) (acb : (a : α) → WellFounded (s a)) (b : β a) : Acc (Lex r s) ⟨a, b⟩ := by
induction aca with
| intro xa aca iha =>
| intro xa _ iha =>
induction (WellFounded.apply (acb xa) b) with
| intro xb acb ihb =>
| intro xb _ ihb =>
apply Acc.intro
intro p lt
cases lt with
@ -291,17 +291,17 @@ section
variable {α : Sort u} {β : Sort v}
def lexNdep (r : αα → Prop) (s : β → β → Prop) :=
Lex r (fun a => s)
Lex r (fun _ => s)
def lexNdepWf {r : αα → Prop} {s : β → β → Prop} (ha : WellFounded r) (hb : WellFounded s) : WellFounded (lexNdep r s) :=
WellFounded.intro fun ⟨a, b⟩ => lexAccessible (WellFounded.apply ha a) (fun x => hb) b
WellFounded.intro fun ⟨a, b⟩ => lexAccessible (WellFounded.apply ha a) (fun _ => hb) b
end
section
variable {α : Sort u} {β : Sort v}
-- Reverse lexicographical order based on r and s
inductive RevLex (r : αα → Prop) (s : β → β → Prop) : @PSigma α (fun a => β) → @PSigma α (fun a => β) → Prop where
inductive RevLex (r : αα → Prop) (s : β → β → Prop) : @PSigma α (fun _ => β) → @PSigma α (fun _ => β) → Prop where
| left : {a₁ a₂ : α} → (b : β) → r a₁ a₂ → RevLex r s ⟨a₁, b⟩ ⟨a₂, b⟩
| right : (a₁ : α) → {b₁ : β} → (a₂ : α) → {b₂ : β} → s b₁ b₂ → RevLex r s ⟨a₁, b₁⟩ ⟨a₂, b₂⟩
end
@ -313,10 +313,10 @@ variable {r : αα → Prop} {s : β → β → Prop}
def revLexAccessible {b} (acb : Acc s b) (aca : (a : α) → Acc r a): (a : α) → Acc (RevLex r s) ⟨a, b⟩ := by
induction acb with
| intro xb acb ihb =>
| intro xb _ ihb =>
intro a
induction (aca a) with
| intro xa aca iha =>
| intro xa _ iha =>
apply Acc.intro
intro p lt
cases lt with
@ -328,10 +328,10 @@ def revLex (ha : WellFounded r) (hb : WellFounded s) : WellFounded (RevLex r s)
end
section
def SkipLeft (α : Type u) {β : Type v} (s : β → β → Prop) : @PSigma α (fun a => β) → @PSigma α (fun a => β) → Prop :=
def SkipLeft (α : Type u) {β : Type v} (s : β → β → Prop) : @PSigma α (fun _ => β) → @PSigma α (fun _ => β) → Prop :=
RevLex emptyRelation s
def skipLeft (α : Type u) {β : Type v} (hb : WellFoundedRelation β) : WellFoundedRelation (PSigma fun a : α => β) where
def skipLeft (α : Type u) {β : Type v} (hb : WellFoundedRelation β) : WellFoundedRelation (PSigma fun _ : α => β) where
rel := SkipLeft α hb.rel
wf := revLex emptyWf.wf hb.wf

View file

@ -74,7 +74,7 @@ private partial def checkOutParam : Nat → Array FVarId → Expr → Except Str
Except.error s!"invalid class, parameter #{i} depends on `outParam`, but it is not an `outParam`"
else
checkOutParam (i+1) outParams b
| i, outParams, e => pure (outParams.size > 0)
| _, outParams, _ => pure (outParams.size > 0)
def addClass (env : Environment) (clsName : Name) : Except String Environment := do
if isClass env clsName then

View file

@ -87,7 +87,7 @@ private def parseOptNum : Nat → String.Iterator → Nat → String.Iterator ×
else (it, r)
def expandExternPatternAux (args : List String) : Nat → String.Iterator → String → String
| 0, it, r => r
| 0, _, r => r
| i+1, it, r =>
if ¬ it.hasNext then r
else let c := it.curr
@ -156,7 +156,7 @@ def getExternConstArityExport (env : Environment) (declName : Name) : IO (Option
let (arity, _) ← (getExternConstArity declName).toIO { fileName := "<compiler>", fileMap := default } { env := env }
return some arity
catch
| IO.Error.userError msg => return none
| IO.Error.userError _ => return none
| _ => return none
end Lean

View file

@ -82,6 +82,6 @@ def addBoxedVersionAux (decl : Decl) : CompilerM Unit := do
def addBoxedVersion (env : Environment) (decl : Decl) : Except String Environment :=
match (addBoxedVersionAux decl Options.empty).run { env := env } with
| EStateM.Result.ok _ s => Except.ok s.env
| EStateM.Result.error msg s => Except.error msg
| EStateM.Result.error msg _ => Except.error msg
end Lean.IR

View file

@ -326,7 +326,7 @@ def FnBody.setBody : FnBody → FnBody → FnBody
| FnBody.dec x n c p _, b => FnBody.dec x n c p b
| FnBody.del x _, b => FnBody.del x b
| FnBody.mdata d _, b => FnBody.mdata d b
| other, b => other
| other, _ => other
@[inline] def FnBody.resetBody (b : FnBody) : FnBody :=
b.setBody FnBody.nil
@ -427,7 +427,7 @@ def getInfo : Decl → DeclInfo
def updateBody! (d : Decl) (bNew : FnBody) : Decl :=
match d with
| Decl.fdecl f xs t b info => Decl.fdecl f xs t bNew info
| Decl.fdecl f xs t _ info => Decl.fdecl f xs t bNew info
| _ => panic! "expected definition"
end Decl
@ -473,27 +473,27 @@ def LocalContext.addParams (ctx : LocalContext) (ps : Array Param) : LocalContex
def LocalContext.isJP (ctx : LocalContext) (idx : Index) : Bool :=
match ctx.find? idx with
| some (LocalContextEntry.joinPoint _ _) => true
| other => false
| _ => false
def LocalContext.getJPBody (ctx : LocalContext) (j : JoinPointId) : Option FnBody :=
match ctx.find? j.idx with
| some (LocalContextEntry.joinPoint _ b) => some b
| other => none
| _ => none
def LocalContext.getJPParams (ctx : LocalContext) (j : JoinPointId) : Option (Array Param) :=
match ctx.find? j.idx with
| some (LocalContextEntry.joinPoint ys _) => some ys
| other => none
| _ => none
def LocalContext.isParam (ctx : LocalContext) (idx : Index) : Bool :=
match ctx.find? idx with
| some (LocalContextEntry.param _) => true
| other => false
| _ => false
def LocalContext.isLocalVar (ctx : LocalContext) (idx : Index) : Bool :=
match ctx.find? idx with
| some (LocalContextEntry.localVar _ _) => true
| other => false
| _ => false
def LocalContext.contains (ctx : LocalContext) (idx : Index) : Bool :=
Std.RBMap.contains ctx idx
@ -505,12 +505,12 @@ def LocalContext.getType (ctx : LocalContext) (x : VarId) : Option IRType :=
match ctx.find? x.idx with
| some (LocalContextEntry.param t) => some t
| some (LocalContextEntry.localVar t _) => some t
| other => none
| _ => none
def LocalContext.getValue (ctx : LocalContext) (x : VarId) : Option Expr :=
match ctx.find? x.idx with
| some (LocalContextEntry.localVar _ v) => some v
| other => none
| _ => none
abbrev IndexRenaming := RBMap Index Index compare

View file

@ -105,7 +105,7 @@ def mkInitParamMap (env : Environment) (decls : Array Decl) : ParamMap :=
namespace ApplyParamMap
partial def visitFnBody (fn : FunId) (paramMap : ParamMap) : FnBody → FnBody
| FnBody.jdecl j xs v b =>
| FnBody.jdecl j _ v b =>
let v := visitFnBody fn paramMap v
let b := visitFnBody fn paramMap b
match paramMap.find? (ParamMap.Key.jp fn j) with
@ -122,7 +122,7 @@ partial def visitFnBody (fn : FunId) (paramMap : ParamMap) : FnBody → FnBody
def visitDecls (decls : Array Decl) (paramMap : ParamMap) : Array Decl :=
decls.map fun decl => match decl with
| Decl.fdecl f xs ty b info =>
| Decl.fdecl f _ ty b info =>
let b := visitFnBody f paramMap b
match paramMap.find? (ParamMap.Key.decl f) with
| some xs => Decl.fdecl f xs ty b info

View file

@ -290,7 +290,7 @@ def visitVDeclExpr (x : VarId) (ty : IRType) (e : Expr) (b : FnBody) : M FnBody
| Expr.ap f ys =>
boxArgsIfNeeded ys fun ys =>
unboxResultIfNeeded x ty (Expr.ap f ys) b
| other =>
| _ =>
return FnBody.vdecl x ty e b
partial def visitFnBody : FnBody → M FnBody

View file

@ -120,7 +120,7 @@ def checkExpr (ty : IRType) : Expr → M Unit
if !ty.isStruct && !ty.isUnion && c.isRef then
(checkObjType ty) *> checkArgs ys
| Expr.reset _ x => checkObjVar x *> checkObjType ty
| Expr.reuse x i u ys => checkObjVar x *> checkArgs ys *> checkObjType ty
| Expr.reuse x _ _ ys => checkObjVar x *> checkArgs ys *> checkObjType ty
| Expr.box xty x => checkObjType ty *> checkScalarVar x *> checkVarType x (fun t => t == xty)
| Expr.unbox x => checkScalarType ty *> checkObjVar x
| Expr.proj i x => do
@ -130,7 +130,7 @@ def checkExpr (ty : IRType) : Expr → M Unit
| IRType.tobject => checkObjType ty
| IRType.struct _ tys => if h : i < tys.size then checkEqTypes (tys.get ⟨i,h⟩) ty else throw "invalid proj index"
| IRType.union _ tys => if h : i < tys.size then checkEqTypes (tys.get ⟨i,h⟩) ty else throw "invalid proj index"
| other => throw s!"unexpected IR type '{xType}'"
| _ => throw s!"unexpected IR type '{xType}'"
| Expr.uproj _ x => checkObjVar x *> checkType ty (fun t => t == IRType.usize)
| Expr.sproj _ _ x => checkObjVar x *> checkScalarType ty
| Expr.isShared x => checkObjVar x *> checkType ty (fun t => t == IRType.uint8)

View file

@ -45,7 +45,7 @@ def tracePrefixOptionName := `trace.compiler.ir
private def isLogEnabledFor (opts : Options) (optName : Name) : Bool :=
match opts.find optName with
| some (DataValue.ofBool v) => v
| other => opts.getBool tracePrefixOptionName
| _ => opts.getBool tracePrefixOptionName
private def logDeclsAux (optName : Name) (cls : Name) (decls : Array Decl) : CompilerM Unit := do
let opts ← read
@ -79,7 +79,7 @@ private def mkEntryArray (decls : List Decl) : Array Decl :=
/- Remove duplicates by adding decls into a map -/
let map : HashMap Name Decl := {}
let map := decls.foldl (init := map) fun map decl => map.insert decl.name decl
map.fold (fun a k v => a.push v) #[]
map.fold (fun a _ v => a.push v) #[]
builtin_initialize declMapExt : SimplePersistentEnvExtension Decl DeclMap ←
registerSimplePersistentEnvExtension {

View file

@ -186,7 +186,7 @@ partial def projValue : Value → Nat → Value
def interpExpr : Expr → M Value
| Expr.ctor i ys => return ctor i (← ys.mapM fun y => findArgValue y)
| Expr.proj i x => return projValue (← findVarValue x) i
| Expr.fap fid ys => do
| Expr.fap fid _ => do
let ctx ← read
match getFunctionSummary? ctx.env fid with
| some v => pure v
@ -225,7 +225,7 @@ def updateJPParamsAssignment (ys : Array Param) (xs : Array Arg) : M Bool := do
pure true
private partial def resetNestedJPParams : FnBody → M Unit
| FnBody.jdecl _ ys b k => do
| FnBody.jdecl _ ys _ k => do
let ctx ← read
let currFnIdx := ctx.currFnIdx
ys.forM resetParamAssignment

View file

@ -138,7 +138,7 @@ def emitFnDecls : M Unit := do
def emitMainFn : M Unit := do
let d ← getDecl `main
match d with
| Decl.fdecl (f := f) (xs := xs) (type := t) (body := b) .. => do
| Decl.fdecl (f := _) (xs := xs) (type := _) (body := _) .. => do
unless xs.size == 2 || xs.size == 1 do throw "invalid main function, incorrect arity when generating code"
let env ← getEnv
let usesLeanAPI := usesModuleFrom env `Lean
@ -199,7 +199,7 @@ def emitMainFn : M Unit := do
" return 1;",
"}"]
emitLn "}"
| other => throw "function declaration expected"
| _ => throw "function declaration expected"
def hasMainFn : M Bool := do
let env ← getEnv
@ -261,7 +261,7 @@ partial def declareVars : FnBody → Bool → M Bool
pure d
else
declareVar x t; declareVars b true
| FnBody.jdecl j xs _ b, d => do declareParams xs; declareVars b (d || xs.size > 0)
| FnBody.jdecl _ xs _ b, d => do declareParams xs; declareVars b (d || xs.size > 0)
| e, d => if e.isTerminal then pure d else declareVars e.body d
def emitTag (x : VarId) (xType : IRType) : M Unit := do
@ -448,7 +448,7 @@ def emitBoxFn (xType : IRType) : M Unit :=
| IRType.uint32 => emit "lean_box_uint32"
| IRType.uint64 => emit "lean_box_uint64"
| IRType.float => emit "lean_box_float"
| other => emit "lean_box"
| _ => emit "lean_box"
def emitBox (z : VarId) (x : VarId) (xType : IRType) : M Unit := do
emitLhs z; emitBoxFn xType; emit "("; emit x; emitLn ");"
@ -460,7 +460,7 @@ def emitUnbox (z : VarId) (t : IRType) (x : VarId) : M Unit := do
| IRType.uint32 => emit "lean_unbox_uint32"
| IRType.uint64 => emit "lean_unbox_uint64"
| IRType.float => emit "lean_unbox_float"
| other => emit "lean_unbox";
| _ => emit "lean_unbox";
emit "("; emit x; emitLn ");"
def emitIsShared (z : VarId) (x : VarId) : M Unit := do
@ -600,7 +600,7 @@ partial def emitCase (x : VarId) (xType : IRType) (alts : Array Alt) : M Unit :=
partial def emitBlock (b : FnBody) : M Unit := do
match b with
| FnBody.jdecl j xs v b => emitBlock b
| FnBody.jdecl _ _ _ b => emitBlock b
| d@(FnBody.vdecl x t v b) =>
let ctx ← read
if isTailCallTo ctx.mainFn d then
@ -626,7 +626,7 @@ partial def emitBlock (b : FnBody) : M Unit := do
| FnBody.unreachable => emitLn "lean_internal_panic_unreachable();"
partial def emitJPs : FnBody → M Unit
| FnBody.jdecl j xs v b => do emit j; emitLn ":"; emitFnBody v; emitJPs b
| FnBody.jdecl j _ v b => do emit j; emitLn ":"; emitFnBody v; emitJPs b
| e => do unless e.isTerminal do emitJPs e.body
partial def emitFnBody (b : FnBody) : M Unit := do

View file

@ -30,7 +30,7 @@ partial def collectFnBody : FnBody → M Unit
match v with
| Expr.fap f _ => collect f *> collectFnBody b
| Expr.pap f _ => collect f *> collectFnBody b
| other => collectFnBody b
| _ => collectFnBody b
| FnBody.jdecl _ _ v b => collectFnBody v *> collectFnBody b
| FnBody.case _ _ _ alts => alts.forM fun alt => collectFnBody alt.body
| e => do unless e.isTerminal do collectFnBody e.body

View file

@ -93,7 +93,7 @@ partial def reuseToCtor (x : VarId) : FnBody → FnBody
else FnBody.dec y n c p (reuseToCtor x b)
| FnBody.vdecl z t v b =>
match v with
| Expr.reuse y c u xs =>
| Expr.reuse y c _ xs =>
if x == y then FnBody.vdecl z t (Expr.ctor c xs) b
else FnBody.vdecl z t v (reuseToCtor x b)
| _ =>
@ -248,7 +248,7 @@ partial def expand (mainFn : FnBody → Array FnBody → M FnBody)
return reshape bs b
partial def searchAndExpand : FnBody → Array FnBody → M FnBody
| d@(FnBody.vdecl x t (Expr.reset n y) b), bs =>
| d@(FnBody.vdecl x _ (Expr.reset n y) b), bs =>
if consumed x b then do
expand searchAndExpand bs x n y b
else

View file

@ -87,17 +87,17 @@ def formatParams (ps : Array Param) : Format :=
@[export lean_ir_format_fn_body_head]
def formatFnBodyHead : FnBody → Format
| FnBody.vdecl x ty e b => "let " ++ format x ++ " : " ++ format ty ++ " := " ++ format e
| FnBody.jdecl j xs v b => format j ++ formatParams xs ++ " := ..."
| FnBody.set x i y b => "set " ++ format x ++ "[" ++ format i ++ "] := " ++ format y
| FnBody.uset x i y b => "uset " ++ format x ++ "[" ++ format i ++ "] := " ++ format y
| FnBody.sset x i o y ty b => "sset " ++ format x ++ "[" ++ format i ++ ", " ++ format o ++ "] : " ++ format ty ++ " := " ++ format y
| FnBody.setTag x cidx b => "setTag " ++ format x ++ " := " ++ format cidx
| FnBody.inc x n c _ b => "inc" ++ (if n != 1 then Format.sbracket (format n) else "") ++ " " ++ format x
| FnBody.dec x n c _ b => "dec" ++ (if n != 1 then Format.sbracket (format n) else "") ++ " " ++ format x
| FnBody.del x b => "del " ++ format x
| FnBody.mdata d b => "mdata " ++ format d
| FnBody.case tid x xType cs => "case " ++ format x ++ " of ..."
| FnBody.vdecl x ty e _ => "let " ++ format x ++ " : " ++ format ty ++ " := " ++ format e
| FnBody.jdecl j xs _ _ => format j ++ formatParams xs ++ " := ..."
| FnBody.set x i y _ => "set " ++ format x ++ "[" ++ format i ++ "] := " ++ format y
| FnBody.uset x i y _ => "uset " ++ format x ++ "[" ++ format i ++ "] := " ++ format y
| FnBody.sset x i o y ty _ => "sset " ++ format x ++ "[" ++ format i ++ ", " ++ format o ++ "] : " ++ format ty ++ " := " ++ format y
| FnBody.setTag x cidx _ => "setTag " ++ format x ++ " := " ++ format cidx
| FnBody.inc x n _ _ _ => "inc" ++ (if n != 1 then Format.sbracket (format n) else "") ++ " " ++ format x
| FnBody.dec x n _ _ _ => "dec" ++ (if n != 1 then Format.sbracket (format n) else "") ++ " " ++ format x
| FnBody.del x _ => "del " ++ format x
| FnBody.mdata d _ => "mdata " ++ format d
| FnBody.case _ x _ _ => "case " ++ format x ++ " of ..."
| FnBody.jmp j ys => "jmp " ++ format j ++ formatArray ys
| FnBody.ret x => "ret " ++ format x
| FnBody.unreachable => "⊥"
@ -110,8 +110,8 @@ partial def formatFnBody (fnBody : FnBody) (indent : Nat := 2) : Format :=
| FnBody.uset x i y b => "uset " ++ format x ++ "[" ++ format i ++ "] := " ++ format y ++ ";" ++ Format.line ++ loop b
| FnBody.sset x i o y ty b => "sset " ++ format x ++ "[" ++ format i ++ ", " ++ format o ++ "] : " ++ format ty ++ " := " ++ format y ++ ";" ++ Format.line ++ loop b
| FnBody.setTag x cidx b => "setTag " ++ format x ++ " := " ++ format cidx ++ ";" ++ Format.line ++ loop b
| FnBody.inc x n c _ b => "inc" ++ (if n != 1 then Format.sbracket (format n) else "") ++ " " ++ format x ++ ";" ++ Format.line ++ loop b
| FnBody.dec x n c _ b => "dec" ++ (if n != 1 then Format.sbracket (format n) else "") ++ " " ++ format x ++ ";" ++ Format.line ++ loop b
| FnBody.inc x n _ _ b => "inc" ++ (if n != 1 then Format.sbracket (format n) else "") ++ " " ++ format x ++ ";" ++ Format.line ++ loop b
| FnBody.dec x n _ _ b => "dec" ++ (if n != 1 then Format.sbracket (format n) else "") ++ " " ++ format x ++ ";" ++ Format.line ++ loop b
| FnBody.del x b => "del " ++ format x ++ ";" ++ Format.line ++ loop b
| FnBody.mdata d b => "mdata " ++ format d ++ ";" ++ Format.line ++ loop b
| FnBody.case tid x xType cs => "case " ++ format x ++ " : " ++ format xType ++ " of" ++ cs.foldl (fun r c => r ++ Format.line ++ formatAlt loop indent c) Format.nil

View file

@ -28,7 +28,7 @@ instance : AndThen Collector where
private def collectArg : Arg → Collector
| Arg.var x => collectVar x
| irrelevant => skip
| _ => skip
private def collectArray {α : Type} (as : Array α) (f : α → Collector) : Collector :=
fun m => as.foldl (fun m a => f a m) m
@ -49,7 +49,7 @@ private def collectExpr : Expr → Collector
| Expr.ap x ys => collectVar x >> collectArgs ys
| Expr.box _ x => collectVar x
| Expr.unbox x => collectVar x
| Expr.lit v => skip
| Expr.lit _ => skip
| Expr.isShared x => collectVar x
| Expr.isTaggedPtr x => collectVar x
@ -125,7 +125,7 @@ instance : AndThen Collector where
private def collectArg : Arg → Collector
| Arg.var x => collectVar x
| irrelevant => skip
| _ => skip
private def collectArray {α : Type} (as : Array α) (f : α → Collector) : Collector :=
fun bv fv => as.foldl (fun fv a => f a bv fv) fv
@ -145,7 +145,7 @@ private def collectExpr : Expr → Collector
| Expr.ap x ys => collectVar x >> collectArgs ys
| Expr.box _ x => collectVar x
| Expr.unbox x => collectVar x
| Expr.lit v => skip
| Expr.lit _ => skip
| Expr.isShared x => collectVar x
| Expr.isTaggedPtr x => collectVar x
@ -206,13 +206,13 @@ def visitExpr (w : Index) : Expr → Bool
| Expr.ap x ys => visitVar w x || visitArgs w ys
| Expr.box _ x => visitVar w x
| Expr.unbox x => visitVar w x
| Expr.lit v => false
| Expr.lit _ => false
| Expr.isShared x => visitVar w x
| Expr.isTaggedPtr x => visitVar w x
partial def visitFnBody (w : Index) : FnBody → Bool
| FnBody.vdecl x _ v b => visitExpr w v || visitFnBody w b
| FnBody.jdecl j ys v b => visitFnBody w v || visitFnBody w b
| FnBody.vdecl _ _ v b => visitExpr w v || visitFnBody w b
| FnBody.jdecl _ _ v b => visitFnBody w v || visitFnBody w b
| FnBody.set x _ y b => visitVar w x || visitArg w y || visitFnBody w b
| FnBody.uset x _ y b => visitVar w x || visitVar w y || visitFnBody w b
| FnBody.sset x _ _ y _ b => visitVar w x || visitVar w y || visitFnBody w b

View file

@ -43,8 +43,8 @@ abbrev visitArgs (w : Index) (as : Array Arg) : M Bool := pure (HasIndex.visitAr
abbrev visitExpr (w : Index) (e : Expr) : M Bool := pure (HasIndex.visitExpr w e)
partial def visitFnBody (w : Index) : FnBody → M Bool
| FnBody.vdecl x _ v b => visitExpr w v <||> visitFnBody w b
| FnBody.jdecl j ys v b => visitFnBody w v <||> visitFnBody w b
| FnBody.vdecl _ _ v b => visitExpr w v <||> visitFnBody w b
| FnBody.jdecl _ _ v b => visitFnBody w v <||> visitFnBody w b
| FnBody.set x _ y b => visitVar w x <||> visitArg w y <||> visitFnBody w b
| FnBody.uset x _ y b => visitVar w x <||> visitVar w y <||> visitFnBody w b
| FnBody.sset x _ _ y _ b => visitVar w x <||> visitVar w y <||> visitFnBody w b
@ -96,7 +96,7 @@ abbrev Collector := LiveVarSet → LiveVarSet
private def collectArg : Arg → Collector
| Arg.var x => collectVar x
| irrelevant => skip
| _ => skip
private def collectArray {α : Type} (as : Array α) (f : α → Collector) : Collector := fun s =>
as.foldl (fun s a => f a s) s
@ -130,7 +130,7 @@ def collectExpr : Expr → Collector
| Expr.ap x ys => collectVar x ∘ collectArgs ys
| Expr.box _ x => collectVar x
| Expr.unbox x => collectVar x
| Expr.lit v => skip
| Expr.lit _ => skip
| Expr.isShared x => collectVar x
| Expr.isTaggedPtr x => collectVar x
@ -148,9 +148,9 @@ partial def collectFnBody : FnBody → JPLiveVarMap → Collector
| FnBody.dec x _ _ _ b, m => collectVar x ∘ collectFnBody b m
| FnBody.del x b, m => collectVar x ∘ collectFnBody b m
| FnBody.mdata _ b, m => collectFnBody b m
| FnBody.ret x, m => collectArg x
| FnBody.ret x, _ => collectArg x
| FnBody.case _ x _ alts, m => collectVar x ∘ collectArray alts (fun alt => collectFnBody alt.body m)
| FnBody.unreachable, m => skip
| FnBody.unreachable, _ => skip
| FnBody.jmp j xs, m => collectJP m j ∘ collectArgs xs
def updateJPLiveVarMap (j : JoinPointId) (ys : Array Param) (v : FnBody) (m : JPLiveVarMap) : JPLiveVarMap :=

View file

@ -69,7 +69,7 @@ def normExpr : Expr → M Expr
| Expr.unbox x, m => Expr.unbox (normVar x m)
| Expr.isShared x, m => Expr.isShared (normVar x m)
| Expr.isTaggedPtr x, m => Expr.isTaggedPtr (normVar x m)
| e@(Expr.lit v), m => e
| e@(Expr.lit _), _ => e
abbrev N := ReaderT IndexRenaming (StateM Nat)
@ -148,7 +148,7 @@ def mapExpr (f : VarId → VarId) : Expr → Expr
| Expr.unbox x => Expr.unbox (f x)
| Expr.isShared x => Expr.isShared (f x)
| Expr.isTaggedPtr x => Expr.isTaggedPtr (f x)
| e@(Expr.lit v) => e
| e@(Expr.lit _) => e
partial def mapFnBody (f : VarId → VarId) : FnBody → FnBody
| FnBody.vdecl x t v b => FnBody.vdecl x t (mapExpr f v) (mapFnBody f b)

View file

@ -16,7 +16,7 @@ partial def pushProjs (bs : Array FnBody) (alts : Array Alt) (altsF : Array Inde
let bs := bs.pop
let done (_ : Unit) := (bs.push b ++ ctx.reverse, alts)
let skip (_ : Unit) := pushProjs bs alts altsF (ctx.push b) (b.collectFreeIndices ctxF)
let push (x : VarId) (t : IRType) (v : Expr) :=
let push (x : VarId) (_ : IRType) (_ : Expr) :=
if !ctxF.contains x.idx then
let alts := alts.mapIdx fun i alt => alt.modifyBody fun b' =>
if (altsF.get! i).contains x.idx then b.setBody b'
@ -46,7 +46,7 @@ partial def FnBody.pushProj (b : FnBody) : FnBody :=
let alts := alts.map fun alt => alt.modifyBody pushProj
let term := FnBody.case tid x xType alts
reshape bs term
| other => reshape bs term
| _ => reshape bs term
/-- Push projections inside `case` branches. -/
def Decl.pushProj (d : Decl) : Decl :=

View file

@ -139,7 +139,7 @@ xs.size.fold (init := b) fun i b =>
else b
private def addIncBeforeConsumeAll (ctx : Context) (xs : Array Arg) (b : FnBody) (liveVarsAfter : LiveVarSet) : FnBody :=
addIncBeforeAux ctx xs (fun i => true) b liveVarsAfter
addIncBeforeAux ctx xs (fun _ => true) b liveVarsAfter
/- Add `dec` instructions for parameters that are references, are not alive in `b`, and are not borrow.
That is, we must make sure these parameters are consumed. -/
@ -148,21 +148,21 @@ private def addDecForDeadParams (ctx : Context) (ps : Array Param) (b : FnBody)
if !p.borrow && p.ty.isObj && !bLiveVars.contains p.x then addDec ctx p.x b else b
private def isPersistent : Expr → Bool
| Expr.fap c xs => xs.isEmpty -- all global constants are persistent objects
| Expr.fap _ xs => xs.isEmpty -- all global constants are persistent objects
| _ => false
/- We do not need to consume the projection of a variable that is not consumed -/
private def consumeExpr (m : VarMap) : Expr → Bool
| Expr.proj i x => match m.find? x with
| Expr.proj _ x => match m.find? x with
| some info => info.consume
| none => true
| other => true
| _ => true
/- Return true iff `v` at runtime is a scalar value stored in a tagged pointer.
We do not need RC operations for this kind of value. -/
private def isScalarBoxedInTaggedPtr (v : Expr) : Bool :=
match v with
| Expr.ctor c ys => c.size == 0 && c.ssize == 0 && c.usize == 0
| Expr.ctor c _ => c.size == 0 && c.ssize == 0 && c.usize == 0
| Expr.lit (LitVal.num n) => n ≤ maxSmallNat
| _ => false
@ -198,7 +198,7 @@ private def processVDecl (ctx : Context) (z : VarId) (t : IRType) (v : Expr) (b
let ysx := ys.push (Arg.var x) -- TODO: avoid temporary array allocation
addIncBeforeConsumeAll ctx ysx (FnBody.vdecl z t v b) bLiveVars
| (Expr.unbox x) => FnBody.vdecl z t v (addDecIfNeeded ctx x b bLiveVars)
| other => FnBody.vdecl z t v b -- Expr.reset, Expr.box, Expr.lit are handled here
| _ => FnBody.vdecl z t v b -- Expr.reset, Expr.box, Expr.lit are handled here
let liveVars := updateLiveVars v bLiveVars
let liveVars := liveVars.erase z
(b, liveVars)

View file

@ -63,7 +63,7 @@ partial def FnBody.simpCase (b : FnBody) : FnBody :=
| FnBody.case tid x xType alts =>
let alts := alts.map fun alt => alt.modifyBody simpCase;
reshape bs (mkSimpCase tid x xType alts)
| other => reshape bs term
| _ => reshape bs term
/-- Simplify `case`
- Remove unreachable branches.

View file

@ -70,7 +70,7 @@ def updateSorryDep (decls : Array Decl) : CompilerM (Array Decl) := do
let (_, s) ← Sorry.collect decls |>.run {}
return decls.map fun decl =>
match decl with
| Decl.fdecl f xs t b info =>
| Decl.fdecl f xs t b _ =>
match s.localSorryMap.find? f with
| some g => Decl.fdecl f xs t b { info with sorryDep? := some g }
| _ => decl

View file

@ -8,7 +8,7 @@ import Lean.Data.Name
namespace String
private def mangleAux : Nat → String.Iterator → String → String
| 0, it, r => r
| 0, _, r => r
| i+1, it, r =>
let c := it.curr
if c.isAlpha || c.isDigit then

View file

@ -229,7 +229,7 @@ def getObjValD (j : Json) (k : String) : Json :=
def setObjVal! : Json → String → Json → Json
| obj kvs, k, v => obj <| kvs.insert compare k v
| j , _, _ => panic! "Json.setObjVal!: not an object: {j}"
| _ , _, _ => panic! "Json.setObjVal!: not an object: {j}"
inductive Structured where
| arr (elems : Array Json)

View file

@ -168,7 +168,7 @@ partial def objectCore (anyCore : Unit → Parsec Json) : Parsec (RBNode String
-- takes a unit parameter so that
-- we can use the equation compiler and recursion
partial def anyCore (u : Unit) : Parsec Json := do
partial def anyCore (_ : Unit) : Parsec Json := do
let c ← peek!
if c = '[' then
skip; ws

View file

@ -27,7 +27,7 @@ instance : OfNat RequestID n := ⟨RequestID.num n⟩
instance : ToString RequestID where
toString
| RequestID.str s => s!"\"s\""
| RequestID.str _ => s!"\"s\""
| RequestID.num n => toString n
| RequestID.null => "null"

View file

@ -73,7 +73,7 @@ def size (m : KVMap) : Nat :=
m.entries.length
def findCore : List (Name × DataValue) → Name → Option DataValue
| [], k' => none
| [], _ => none
| (k,v)::m, k' => if k == k' then some v else findCore m k'
def find : KVMap → Name → Option DataValue
@ -148,7 +148,7 @@ instance : ForIn m KVMap (Name × DataValue) where
forIn := KVMap.forIn
def subsetAux : List (Name × DataValue) → KVMap → Bool
| [], m₂ => true
| [], _ => true
| (k, v₁)::m₁, m₂ =>
match m₂.find k with
| some v₂ => v₁ == v₂ && subsetAux m₁ m₂
@ -167,13 +167,13 @@ class Value (α : Type) where
toDataValue : α → DataValue
ofDataValue? : DataValue → Option α
@[inline] def get? {α : Type} [s : Value α] (m : KVMap) (k : Name) : Option α :=
@[inline] def get? {α : Type} [_ : Value α] (m : KVMap) (k : Name) : Option α :=
m.find k |>.bind Value.ofDataValue?
@[inline] def get {α : Type} [s : Value α] (m : KVMap) (k : Name) (defVal : α) : α :=
@[inline] def get {α : Type} [_ : Value α] (m : KVMap) (k : Name) (defVal : α) : α :=
m.get? k |>.getD defVal
@[inline] def set {α : Type} [s : Value α] (m : KVMap) (k : Name) (v : α) : KVMap :=
@[inline] def set {α : Type} [_ : Value α] (m : KVMap) (k : Name) (v : α) : KVMap :=
m.insert k (Value.toDataValue v)
instance : Value DataValue where

View file

@ -30,10 +30,10 @@ structure WaitForDiagnosticsParams where
structure WaitForDiagnostics
instance : FromJson WaitForDiagnostics :=
⟨fun j => pure WaitForDiagnostics.mk⟩
⟨fun _ => pure WaitForDiagnostics.mk⟩
instance : ToJson WaitForDiagnostics :=
⟨fun o => mkObj []⟩
⟨fun _ => mkObj []⟩
inductive LeanFileProgressKind
| processing | fatalError

View file

@ -61,7 +61,7 @@ partial def collectDiagnostics (waitForDiagnosticsId : RequestID := 0) (target :
| Message.response id _ =>
if id == waitForDiagnosticsId then return []
else loop
| Message.responseError id code msg _ =>
| Message.responseError id _ msg _ =>
if id == waitForDiagnosticsId then
throw $ userError s!"Waiting for diagnostics failed: {msg}"
else loop

View file

@ -28,7 +28,7 @@ def utf16Length (s : String) : Nat :=
s.foldr (fun c acc => csize16 c + acc) 0
private def codepointPosToUtf16PosFromAux (s : String) : Nat → Pos → Nat → Nat
| 0, utf8pos, utf16pos => utf16pos
| 0, _, utf16pos => utf16pos
| cp+1, utf8pos, utf16pos => codepointPosToUtf16PosFromAux s cp (s.next utf8pos) (utf16pos + csize16 (s.get utf8pos))
/-- Computes the UTF-16 offset of the `n`-th Unicode codepoint
@ -41,7 +41,7 @@ def codepointPosToUtf16Pos (s : String) (pos : Nat) : Nat :=
codepointPosToUtf16PosFrom s pos 0
private partial def utf16PosToCodepointPosFromAux (s : String) : Nat → Pos → Nat → Nat
| 0, utf8pos, cp => cp
| 0, _, cp => cp
| utf16pos, utf8pos, cp => utf16PosToCodepointPosFromAux s (utf16pos - csize16 (s.get utf8pos)) (s.next utf8pos) (cp + 1)
/-- Computes the position of the Unicode codepoint at UTF-16 offset

View file

@ -18,8 +18,8 @@ namespace Name
def getPrefix : Name → Name
| anonymous => anonymous
| str p s _ => p
| num p s _ => p
| str p _ _ => p
| num p _ _ => p
def getString! : Name → String
| str _ s _ => s
@ -31,9 +31,9 @@ def getNumParts : Name → Nat
| num p _ _ => getNumParts p + 1
def updatePrefix : Name → Name → Name
| anonymous, newP => anonymous
| str p s _, newP => Name.mkStr newP s
| num p s _, newP => Name.mkNum newP s
| anonymous, _ => anonymous
| str _ s _, newP => Name.mkStr newP s
| num _ s _, newP => Name.mkNum newP s
def components' : Name → List Name
| anonymous => []

View file

@ -65,17 +65,17 @@ def setOptionFromString (opts : Options) (entry : String) : IO Options := do
let key := Name.mkSimple key
let defValue ← getOptionDefaulValue key
match defValue with
| DataValue.ofString v => pure $ opts.setString key val
| DataValue.ofBool v =>
| DataValue.ofString _ => pure $ opts.setString key val
| DataValue.ofBool _ =>
if key == `true then pure $ opts.setBool key true
else if key == `false then pure $ opts.setBool key false
else throw $ IO.userError s!"invalid Bool option value '{val}'"
| DataValue.ofName v => pure $ opts.setName key val.toName
| DataValue.ofNat v =>
| DataValue.ofName _ => pure $ opts.setName key val.toName
| DataValue.ofNat _ =>
match val.toNat? with
| none => throw (IO.userError s!"invalid Nat option value '{val}'")
| some v => pure $ opts.setNat key v
| DataValue.ofInt v =>
| DataValue.ofInt _ =>
match val.toInt? with
| none => throw (IO.userError s!"invalid Int option value '{val}'")
| some v => pure $ opts.setInt key v

View file

@ -29,7 +29,7 @@ partial def insert (t : PrefixTreeNode α β) (cmp : αα → Ordering) (k
let t := insertEmpty ks
PrefixTreeNode.Node none (RBNode.singleton k t)
let rec loop
| PrefixTreeNode.Node v m, [] =>
| PrefixTreeNode.Node _ m, [] =>
PrefixTreeNode.Node (some val) m -- overrides old value
| PrefixTreeNode.Node v m, k :: ks =>
let t := match RBNode.find cmp m k with
@ -41,8 +41,8 @@ partial def insert (t : PrefixTreeNode α β) (cmp : αα → Ordering) (k
@[specialize]
partial def find? (t : PrefixTreeNode α β) (cmp : αα → Ordering) (k : List α) : Option β :=
let rec loop
| PrefixTreeNode.Node val m, [] => val
| PrefixTreeNode.Node val m, k :: ks =>
| PrefixTreeNode.Node val _, [] => val
| PrefixTreeNode.Node _ m, k :: ks =>
match RBNode.find cmp m k with
| none => none
| some t => loop t ks

View file

@ -83,7 +83,7 @@ where
private def updtAcc (v : Option α) (i : String.Pos) (acc : String.Pos × Option α) : String.Pos × Option α :=
match v, acc with
| some v, (j, w) => (i, some v) -- we pattern match on `acc` to enable memory reuse
| some v, (_, _) => (i, some v) -- we pattern match on `acc` to enable memory reuse
| none, acc => acc
partial def matchPrefix (s : String) (t : Trie α) (i : String.Pos) : String.Pos × Option α :=

View file

@ -356,9 +356,9 @@ def toConstantVal : ConstantInfo → ConstantVal
def isUnsafe : ConstantInfo → Bool
| defnInfo v => v.safety == DefinitionSafety.unsafe
| axiomInfo v => v.isUnsafe
| thmInfo v => false
| thmInfo _ => false
| opaqueInfo v => v.isUnsafe
| quotInfo v => false
| quotInfo _ => false
| inductInfo v => v.isUnsafe
| ctorInfo v => v.isUnsafe
| recInfo v => v.isUnsafe
@ -381,8 +381,8 @@ def value? : ConstantInfo → Option Expr
| _ => none
def hasValue : ConstantInfo → Bool
| defnInfo {value := r, ..} => true
| thmInfo {value := r, ..} => true
| defnInfo {value := _, ..} => true
| thmInfo {value := _, ..} => true
| _ => false
def value! : ConstantInfo → Expr

View file

@ -466,7 +466,7 @@ mutual
/- Elaborate function application arguments. -/
partial def main : M Expr := do
let s ← get
let _ ← get
let fType ← normalizeFunType
if fType.isForall then
let binderName := fType.bindingName!
@ -614,7 +614,7 @@ private def resolveLValAux (e : Expr) (eType : Expr) (lval : LVal) : TermElabM L
throwUnknownConstant (e.constName! ++ suffix)
else
throwInvalidFieldNotation e eType
| _, LVal.getOp _ idx => throwInvalidFieldNotation e eType
| _, LVal.getOp _ _ => throwInvalidFieldNotation e eType
| _, _ => throwInvalidFieldNotation e eType
/- whnfCore + implicit consumption.
@ -622,7 +622,7 @@ private def resolveLValAux (e : Expr) (eType : Expr) (lval : LVal) : TermElabM L
private partial def consumeImplicits (stx : Syntax) (e eType : Expr) (hasArgs : Bool) : TermElabM (Expr × Expr) := do
let eType ← whnfCore eType
match eType with
| Expr.forallE n d b c =>
| Expr.forallE _ d b c =>
if c.binderInfo.isImplicit || (hasArgs && c.binderInfo.isStrictImplicit) then
let mvar ← mkFreshExprMVar d
registerMVarErrorHoleInfo mvar.mvarId! stx
@ -883,7 +883,7 @@ private partial def elabAppFn (f : Syntax) (lvals : List LVal) (namedArgs : Arra
| `($(e).$field:ident) => elabFieldName e field
| `($e |>.$field:ident) => elabFieldName e field
| `($e[%$bracket $idx]) => elabAppFn e (LVal.getOp bracket idx :: lvals) namedArgs args expectedType? explicit ellipsis overloaded acc
| `($id:ident@$t:term) =>
| `($id:ident@$_:term) =>
throwError "unexpected occurrence of named pattern"
| `($id:ident) => do
elabAppFnId id [] lvals namedArgs args expectedType? explicit ellipsis overloaded acc
@ -894,7 +894,7 @@ private partial def elabAppFn (f : Syntax) (lvals : List LVal) (namedArgs : Arra
elabAppFn id lvals namedArgs args expectedType? (explicit := true) ellipsis overloaded acc
| `(@$id:ident.{$us,*}) =>
elabAppFn (f.getArg 1) lvals namedArgs args expectedType? (explicit := true) ellipsis overloaded acc
| `(@$t) => throwUnsupportedSyntax -- invalid occurrence of `@`
| `(@$_) => throwUnsupportedSyntax -- invalid occurrence of `@`
| `(_) => throwError "placeholders '_' cannot be used where a function is expected"
| `(.$id:ident) =>
let fConst ← mkConst (← resolveDotName id expectedType?)

View file

@ -295,7 +295,7 @@ partial def expandFunBinders (binders : Array Syntax) (body : Syntax) : MacroM (
let ident ← mkFreshIdent binder
let type := binder
loop body (i+1) (newBinders.push <| mkExplicitBinder ident type)
| Syntax.node _ ``Lean.Parser.Term.paren args =>
| Syntax.node _ ``Lean.Parser.Term.paren _ =>
-- `(` (termParser >> parenSpecial)? `)`
-- parenSpecial := (tupleTail <|> typeAscription)?
let binderBody := binder[1]

View file

@ -46,7 +46,7 @@ def withNamespace {α} (ns : Name) (elabFn : CommandElabM α) : CommandElabM α
pure a
private def popScopes (numScopes : Nat) : CommandElabM Unit :=
for i in [0:numScopes] do
for _ in [0:numScopes] do
popScope
private def checkAnonymousScope : List Scope → Bool

View file

@ -20,7 +20,7 @@ private def ensureValidNamespace (name : Name) : MacroM Unit := do
if s == "_root_" then
Macro.throwError s!"invalid namespace '{name}', '_root_' is a reserved namespace"
ensureValidNamespace p
| Name.num p .. => Macro.throwError s!"invalid namespace '{name}', it must not contain numeric parts"
| Name.num _ .. => Macro.throwError s!"invalid namespace '{name}', it must not contain numeric parts"
| Name.anonymous => pure ()
/- Auxiliary function for `expandDeclNamespace?` -/
@ -28,7 +28,7 @@ private def expandDeclIdNamespace? (declId : Syntax) : MacroM (Option (Name × S
let (id, optUnivDeclStx) := expandDeclIdCore declId
let scpView := extractMacroScopes id
match scpView.name with
| Name.str Name.anonymous s _ => return none
| Name.str Name.anonymous _ _ => return none
| Name.str pre s _ =>
ensureValidNamespace pre
let nameNew := { scpView with name := Name.mkSimple s }.review

View file

@ -22,7 +22,7 @@ where
mkElseAlt : TermElabM Syntax := do
let mut patterns := #[]
-- add `_` pattern for indices
for i in [:indVal.numIndices] do
for _ in [:indVal.numIndices] do
patterns := patterns.push (← `(_))
patterns := patterns.push (← `(_))
patterns := patterns.push (← `(_))
@ -37,13 +37,13 @@ where
let type ← Core.betaReduce type -- we 'beta-reduce' to eliminate "artificial" dependencies
let mut patterns := #[]
-- add `_` pattern for indices
for i in [:indVal.numIndices] do
for _ in [:indVal.numIndices] do
patterns := patterns.push (← `(_))
let mut ctorArgs1 := #[]
let mut ctorArgs2 := #[]
let mut rhs ← `(true)
-- add `_` for inductive parameters, they are inaccessible
for i in [:indVal.numParams] do
for _ in [:indVal.numParams] do
ctorArgs1 := ctorArgs1.push (← `(_))
ctorArgs2 := ctorArgs2.push (← `(_))
for i in [:ctorInfo.numFields] do

View file

@ -45,7 +45,7 @@ where
for ctorName₂ in indVal.ctors do
let mut patterns := #[]
-- add `_` pattern for indices
for i in [:indVal.numIndices] do
for _ in [:indVal.numIndices] do
patterns := patterns.push (← `(_))
if ctorName₁ == ctorName₂ then
let alt ← forallTelescopeReducing ctorInfo.type fun xs type => do
@ -54,7 +54,7 @@ where
let mut ctorArgs1 := #[]
let mut ctorArgs2 := #[]
-- add `_` for inductive parameters, they are inaccessible
for i in [:indVal.numParams] do
for _ in [:indVal.numParams] do
ctorArgs1 := ctorArgs1.push (← `(_))
ctorArgs2 := ctorArgs2.push (← `(_))
let mut todo := #[]

View file

@ -79,11 +79,11 @@ where
forallTelescopeReducing ctorInfo.type fun xs type => do
let mut patterns := #[]
-- add `_` pattern for indices
for i in [:indVal.numIndices] do
for _ in [:indVal.numIndices] do
patterns := patterns.push (← `(_))
let mut ctorArgs := #[]
-- add `_` for inductive parameters, they are inaccessible
for i in [:indVal.numParams] do
for _ in [:indVal.numParams] do
ctorArgs := ctorArgs.push (← `(_))
-- bound constructor arguments and their types
let mut binders := #[]

View file

@ -31,12 +31,12 @@ where
let type ← Core.betaReduce type -- we 'beta-reduce' to eliminate "artificial" dependencies
let mut patterns := #[]
-- add `_` pattern for indices
for i in [:indVal.numIndices] do
for _ in [:indVal.numIndices] do
patterns := patterns.push (← `(_))
let mut ctorArgs := #[]
let mut rhs ← `($(quote ctorIdx))
-- add `_` for inductive parameters, they are inaccessible
for i in [:indVal.numParams] do
for _ in [:indVal.numParams] do
ctorArgs := ctorArgs.push (← `(_))
for i in [:ctorInfo.numFields] do
let x := xs[indVal.numParams + i]

View file

@ -24,7 +24,7 @@ private def mkInhabitedInstanceUsing (inductiveTypeName : Name) (ctorName : Name
return false
where
addLocalInstancesForParamsAux {α} (k : LocalInst2Index → TermElabM α) : List Expr → Nat → LocalInst2Index → TermElabM α
| [], i, map => k map
| [], _, map => k map
| x::xs, i, map =>
try
let instType ← mkAppM `Inhabited #[x]
@ -73,9 +73,9 @@ where
binders := binders.push binder
let type ← `(Inhabited (@$(mkIdent inductiveTypeName):ident $indArgs:ident*))
let mut ctorArgs := #[]
for i in [:ctorVal.numParams] do
for _ in [:ctorVal.numParams] do
ctorArgs := ctorArgs.push (← `(_))
for i in [:ctorVal.numFields] do
for _ in [:ctorVal.numFields] do
ctorArgs := ctorArgs.push (← ``(Inhabited.default))
let val ← `(⟨@$(mkIdent ctorName):ident $ctorArgs:ident*⟩)
`(instance $binders:explicitBinder* : $type := $val)

View file

@ -27,14 +27,14 @@ where
let type ← Core.betaReduce type -- we 'beta-reduce' to eliminate "artificial" dependencies
let mut indPatterns := #[]
-- add `_` pattern for indices
for i in [:indVal.numIndices] do
for _ in [:indVal.numIndices] do
indPatterns := indPatterns.push (← `(_))
let mut ctorArgs1 := #[]
let mut ctorArgs2 := #[]
-- construct RHS top-down as continuation over the remaining comparison
let mut rhsCont : Syntax → TermElabM Syntax := fun rhs => pure rhs
-- add `_` for inductive parameters, they are inaccessible
for i in [:indVal.numParams] do
for _ in [:indVal.numParams] do
ctorArgs1 := ctorArgs1.push (← `(_))
ctorArgs2 := ctorArgs2.push (← `(_))
for i in [:ctorInfo.numFields] do

View file

@ -56,13 +56,13 @@ where
let alt ← forallTelescopeReducing ctorInfo.type fun xs type => do
let mut patterns := #[]
-- add `_` pattern for indices
for i in [:indVal.numIndices] do
for _ in [:indVal.numIndices] do
patterns := patterns.push (← `(_))
let mut ctorArgs := #[]
let mut rhs := Syntax.mkStrLit (toString ctorInfo.name)
rhs ← `(Format.text $rhs)
-- add `_` for inductive parameters, they are inaccessible
for i in [:indVal.numParams] do
for _ in [:indVal.numParams] do
ctorArgs := ctorArgs.push (← `(_))
for i in [:ctorInfo.numFields] do
let x := xs[indVal.numParams + i]

View file

@ -134,7 +134,7 @@ def mkHeader (ctx : Context) (className : Name) (arity : Nat) (indVal : Inductiv
let binders ← mkImplicitBinders argNames
let targetType ← mkInductiveApp indVal argNames
let mut targetNames := #[]
for i in [:arity] do
for _ in [:arity] do
targetNames := targetNames.push (← mkFreshUserName `x)
let binders := binders ++ (← mkInstImplicitBinders className indVal argNames)
let binders := binders ++ (← targetNames.mapM fun targetName => `(explicitBinderF| ($(mkIdent targetName) : $targetType)))

View file

@ -222,7 +222,7 @@ partial def CodeBlocl.toMessageData (codeBlock : CodeBlock) : MessageData :=
| Code.«break» _ => m!"break {us}"
| Code.«continue» _ => m!"continue {us}"
| Code.«return» _ v => m!"return {v} {us}"
| Code.«match» _ _ ds t alts =>
| Code.«match» _ _ ds _ alts =>
m!"match {ds} with"
++ alts.foldl (init := m!"") fun acc alt => acc ++ m!"\n| {alt.patterns} => {loop alt.rhs}"
loop codeBlock.code
@ -241,7 +241,7 @@ partial def hasExitPointPred (c : Code) (p : Code → Bool) : Bool :=
loop c
def hasExitPoint (c : Code) : Bool :=
hasExitPointPred c fun c => true
hasExitPointPred c fun _ => true
def hasReturn (c : Code) : Bool :=
hasExitPointPred c fun
@ -669,7 +669,7 @@ def mkSingletonDoSeq (doElem : Syntax) : Syntax :=
/-
If the given syntax is a `doIf`, return an equivalente `doIf` that has an `else` but no `else if`s or `if let`s. -/
private def expandDoIf? (stx : Syntax) : MacroM (Option Syntax) := match stx with
| `(doElem|if $p:doIfProp then $t else $e) => pure none
| `(doElem|if $_:doIfProp then $_ else $_) => pure none
| `(doElem|if%$i $cond:doIfCond then $t $[else if%$is $conds:doIfCond then $ts]* $[else $e?]?) => withRef stx do
let mut e := e?.getD (← `(doSeq|pure PUnit.unit))
let mut eIsSeq := true
@ -1162,7 +1162,7 @@ structure ToForInTermResult where
uvars : Array Var
term : Syntax
def mkForInBody (x : Syntax) (forInBody : CodeBlock) : M ToForInTermResult := do
def mkForInBody (_ : Syntax) (forInBody : CodeBlock) : M ToForInTermResult := do
let ctx ← read
let uvars := forInBody.uvars
let uvars := varSetToArray uvars
@ -1274,7 +1274,7 @@ mutual
let doElem := decl[3]
let k ← withNewMutableVars #[y] (isMutableLet doLetArrow) (doSeqToCode doElems)
match isDoExpr? doElem with
| some action => return mkVarDeclCore #[y] doLetArrow k
| some _ => return mkVarDeclCore #[y] doLetArrow k
| none =>
checkLetArrowRHS doElem
let c ← doSeqToCode [doElem]

View file

@ -39,7 +39,7 @@ private def throwForInFailure (forInInstance : Expr) : TermElabM Expr :=
catch
ex => tryPostpone; throwError "failed to construct 'ForIn' instance for collection{indentExpr colType}\nand monad{indentExpr m}"
match (← trySynthInstance forInInstance) with
| LOption.some val =>
| LOption.some _ =>
let ref ← getRef
let forInFn ← mkConst ``forIn
elabAppArgs forInFn #[] #[Arg.stx col, Arg.stx init, Arg.stx body] expectedType? (explicit := false) (ellipsis := false)
@ -64,7 +64,7 @@ private def throwForInFailure (forInInstance : Expr) : TermElabM Expr :=
catch
ex => tryPostpone; throwError "failed to construct `ForIn'` instance for collection{indentExpr colType}\nand monad{indentExpr m}"
match (← trySynthInstance forInInstance) with
| LOption.some val =>
| LOption.some _ =>
let ref ← getRef
let forInFn ← mkConst ``forIn'
elabAppArgs forInFn #[] #[Arg.expr colFVar, Arg.stx init, Arg.stx body] expectedType? (explicit := false) (ellipsis := false)

View file

@ -298,10 +298,10 @@ def Info.toElabInfo? : Info → Option ElabInfo
| ofTacticInfo i => some i.toElabInfo
| ofTermInfo i => some i.toElabInfo
| ofCommandInfo i => some i.toElabInfo
| ofMacroExpansionInfo i => none
| ofFieldInfo i => none
| ofCompletionInfo i => none
| ofCustomInfo i => none
| ofMacroExpansionInfo _ => none
| ofFieldInfo _ => none
| ofCompletionInfo _ => none
| ofCustomInfo _ => none
/--
Helper function for propagating the tactic metavariable context to its children nodes.

View file

@ -539,7 +539,7 @@ where
processInaccessible (e : Expr) : M Expr := do
let e' ← erasePatternRefAnnotations e
match e' with
| Expr.fvar fvarId _ =>
| Expr.fvar _ _ =>
if (← isExplicitPatternVar e') then
processVar e
else
@ -873,7 +873,7 @@ private def generalize (discrs : Array Discr) (matchType : Expr) (altViews : Arr
let ys := ysFVarIds.map mkFVar
let matchType' ← forallBoundedTelescope matchType discrs.size fun ds type => do
let type ← mkForallFVars ys type
let (discrs', ds') := Array.unzip <| Array.zip discrExprs ds |>.filter fun (di, d) => di.isFVar
let (discrs', ds') := Array.unzip <| Array.zip discrExprs ds |>.filter fun (di, _) => di.isFVar
let type := type.replaceFVars discrs' ds'
mkForallFVars ds type
if (← isTypeCorrect matchType') then

View file

@ -19,7 +19,7 @@ structure EqnInfoCore where
deriving Inhabited
partial def expand : Expr → Expr
| Expr.letE _ t v b _ => expand (b.instantiate1 v)
| Expr.letE _ _ v b _ => expand (b.instantiate1 v)
| Expr.mdata _ b _ => expand b
| e => e

View file

@ -16,7 +16,7 @@ open Meta
private def mkTupleElems (t : Expr) (arity : Nat) : Array Expr := Id.run do
let mut result := #[]
let mut t := t
for i in [:arity - 1] do
for _ in [:arity - 1] do
result := result.push (mkProj ``PSigma 0 t)
t := mkProj ``PSigma 1 t
result.push t
@ -137,7 +137,7 @@ where
| Expr.forallE n d b c =>
withLocalDecl n c.binderInfo (← visit d) fun x => do
mkForallFVars (usedLetOnly := false) #[x] (← visit (b.instantiate1 x))
| Expr.letE n t v b c =>
| Expr.letE n t v b _ =>
withLetDecl n (← visit t) (← visit v) fun x => do
mkLambdaFVars (usedLetOnly := false) #[x] (← visit (b.instantiate1 x))
| Expr.proj n i s .. => return mkProj n i (← visit s)

View file

@ -133,7 +133,7 @@ where
let hole ← `(_)
for preDef in preDefs, numArg in numArgs, argIdx in argCombination, i in [:preDefs.size] do
let mut vars := #[var]
for i in [:numArg - argIdx - 1] do
for _ in [:numArg - argIdx - 1] do
vars := vars.push hole
-- TODO: improve this.
-- The following trick allows a function `f` in a mutual block to invoke `g` appearing before it with the input argument.

View file

@ -79,7 +79,7 @@ end ArrayStxBuilder
-- Elaborate the content of a syntax quotation term
private partial def quoteSyntax : Syntax → TermElabM Syntax
| Syntax.ident info rawVal val preresolved => do
| Syntax.ident _ rawVal val preresolved => do
if !hygiene.get (← getOptions) then
return ← `(Syntax.ident info $(quote rawVal) $(quote val) $(quote preresolved))
-- Add global scopes at compilation time (now), add macro scope at runtime (in the quotation).
@ -249,7 +249,7 @@ structure HeadInfo where
/-- Adapt alternatives that do not introduce new discriminants in `doMatch`, but are covered by those that do so. -/
private def noOpMatchAdaptPats : HeadCheck → Alt → Alt
| shape k (some sz), (pats, rhs) => (List.replicate sz (Unhygienic.run `(_)) ++ pats, rhs)
| shape _ (some sz), (pats, rhs) => (List.replicate sz (Unhygienic.run `(_)) ++ pats, rhs)
| slice p s, (pats, rhs) => (List.replicate (p + 1 + s) (Unhygienic.run `(_)) ++ pats, rhs)
| _, alt => alt
@ -438,7 +438,7 @@ private partial def getHeadInfo (alt : Alt) : TermElabM HeadInfo :=
private def deduplicate (floatedLetDecls : Array Syntax) : Alt → TermElabM (Array Syntax × Alt)
-- NOTE: new macro scope so that introduced bindings do not collide
| (pats, rhs) => do
if let `($f:ident $[ $args:ident]*) := rhs then
if let `($_:ident $[ $args:ident]*) := rhs then
-- looks simple enough/created by this function, skip
return (floatedLetDecls, (pats, rhs))
withFreshMacroScope do

View file

@ -82,7 +82,7 @@ private def isSectionVariable (e : Expr) : TermElabM Bool := do
@[builtinQuotPrecheck ident] def precheckIdent : Precheck := fun stx =>
match stx with
| Syntax.ident info rawVal val preresolved => do
| Syntax.ident _ _ val preresolved => do
if !preresolved.isEmpty then
return
/- The precheck currently ignores field notation.
@ -99,7 +99,7 @@ private def isSectionVariable (e : Expr) : TermElabM Bool := do
let rs ← try resolveName stx val [] [] catch _ => pure []
for (e, _) in rs do
match e with
| Expr.fvar fvarId .. =>
| Expr.fvar _ .. =>
if quotPrecheck.allowSectionVars.get (← getOptions) && (← isSectionVariable e) then
return
| _ => pure ()
@ -111,7 +111,7 @@ private def isSectionVariable (e : Expr) : TermElabM Bool := do
precheck f
for arg in args do
match arg with
| `(argument| ($n := $e)) => precheck e
| `(argument| ($_ := $e)) => precheck e
| `(argument| $e:term) => precheck e
| `(argument| ..) => pure ()
| _ => throwUnsupportedSyntax

View file

@ -21,7 +21,7 @@ def mkRecAppWithSyntax (e : Expr) (stx : Syntax) : Expr :=
-/
def getRecAppSyntax? (e : Expr) : Option Syntax :=
match e with
| Expr.mdata d b _ =>
| Expr.mdata d _ _ =>
match d.find recAppKey with
| some (DataValue.ofSyntax stx) => some stx
| _ => none

View file

@ -291,7 +291,7 @@ def formatField (formatStruct : Struct → Format) (field : Field Struct) : Form
| FieldVal.default => "<default>"
partial def formatStruct : Struct → Format
| ⟨_, structName, _, fields, source⟩ =>
| ⟨_, _, _, fields, source⟩ =>
let fieldsFmt := Format.joinSep (fields.map (formatField formatStruct)) ", "
match source with
| Source.none => "{" ++ fieldsFmt ++ "}"
@ -419,7 +419,7 @@ private def expandNumLitFields (s : Struct) : TermElabM Struct :=
private def expandParentFields (s : Struct) : TermElabM Struct := do
let env ← getEnv
s.modifyFieldsM fun fields => fields.mapM fun field => match field with
| { lhs := FieldLHS.fieldName ref fieldName :: rest, .. } =>
| { lhs := FieldLHS.fieldName ref fieldName :: _, .. } =>
match findField? env s.structName fieldName with
| none => throwErrorAt ref "'{fieldName}' is not a field of structure '{s.structName}'"
| some baseStructName =>
@ -438,7 +438,7 @@ private abbrev FieldMap := HashMap Name Fields
private def mkFieldMap (fields : Fields) : TermElabM FieldMap :=
fields.foldlM (init := {}) fun fieldMap field =>
match field.lhs with
| FieldLHS.fieldName _ fieldName :: rest =>
| FieldLHS.fieldName _ fieldName :: _ =>
match fieldMap.find? fieldName with
| some (prevField::restFields) =>
if field.isSimple || prevField.isSimple then
@ -574,7 +574,7 @@ private def mkCtorHeaderAux : Nat → Expr → Expr → Array MVarId → Array (
private partial def getForallBody : Nat → Expr → Option Expr
| i+1, Expr.forallE _ _ b _ => getForallBody i b
| i+1, _ => none
| _+1, _ => none
| 0, type => type
private def propagateExpectedType (type : Expr) (numFields : Nat) (expectedType? : Option Expr) : TermElabM Unit :=
@ -838,7 +838,7 @@ partial def step (struct : Struct) : M Unit :=
unless (← isExprMVarAssigned mvarId) do
let ctx ← read
if (← withRef field.ref <| tryToSynthesizeDefault ctx.structs ctx.allStructNames ctx.maxDistance (getFieldName field) mvarId) then
modify fun s => { s with progress := true }
modify fun _ => { s with progress := true }
| _ => pure ()
partial def propagateLoop (hierarchyDepth : Nat) (d : Nat) (struct : Struct) : M Unit := do
@ -849,7 +849,7 @@ partial def propagateLoop (hierarchyDepth : Nat) (d : Nat) (struct : Struct) : M
if d > hierarchyDepth then
throwErrorAt field.ref "field '{getFieldName field}' is missing"
else withReader (fun ctx => { ctx with maxDistance := d }) do
modify fun s => { s with progress := false }
modify fun _ => { s with progress := false }
step struct
if (← get).progress then do
propagateLoop hierarchyDepth 0 struct

View file

@ -747,7 +747,7 @@ private partial def mkCoercionToCopiedParent (levelParams : List Name) (params :
let structName := view.declName
let sourceFieldNames := getStructureFieldsFlattened env structName
let structType := mkAppN (Lean.mkConst structName (levelParams.map mkLevelParam)) params
let Expr.const parentStructName us _ ← pure parentType.getAppFn | unreachable!
let Expr.const parentStructName _ _ ← pure parentType.getAppFn | unreachable!
let binfo := if view.isClass && isClass env parentStructName then BinderInfo.instImplicit else BinderInfo.default
withLocalDecl `self binfo structType fun source => do
let declType ← instantiateMVars (← mkForallFVars params (← mkForallFVars #[source] parentType))

View file

@ -365,7 +365,7 @@ mutual
pending TC problems become implicit parameters for the simp theorem.
-/
partial def synthesizeSyntheticMVars (mayPostpone := true) (ignoreStuckTC := false) : TermElabM Unit := do
let rec loop (u : Unit) : TermElabM Unit := do
let rec loop (_ : Unit) : TermElabM Unit := do
withRef (← getSomeSynthethicMVarsRef) <| withIncRecDepth do
unless (← get).syntheticMVars.isEmpty do
if ← synthesizeSyntheticMVarsStep (postponeOnError := false) (runTactics := false) then

View file

@ -60,7 +60,7 @@ def getGoals : TacticM (List MVarId) :=
return (← get).goals
def setGoals (mvarIds : List MVarId) : TacticM Unit :=
modify fun s => { s with goals := mvarIds }
modify fun _ => { s with goals := mvarIds }
def pruneSolvedGoals : TacticM Unit := do
let gs ← getGoals
@ -177,7 +177,7 @@ mutual
partial def evalTacticAux (stx : Syntax) : TacticM Unit :=
withRef stx <| withIncRecDepth <| withFreshMacroScope <| match stx with
| Syntax.node _ k args =>
| Syntax.node _ k _ =>
if k == nullKind then
-- Macro writers create a sequence of tactics `t₁ ... tₙ` using `mkNullNode #[t₁, ..., tₙ]`
stx.getArgs.forM evalTactic
@ -256,7 +256,7 @@ instance {α} : OrElse (TacticM α) where
orElse := Tactic.orElse
instance : Alternative TacticM where
failure := fun {α} => throwError "failed"
failure := fun {_} => throwError "failed"
orElse := Tactic.orElse
/-
@ -284,7 +284,7 @@ def appendGoals (mvarIds : List MVarId) : TacticM Unit :=
def replaceMainGoal (mvarIds : List MVarId) : TacticM Unit := do
let (mvarId :: mvarIds') ← getGoals | throwNoGoalsToBeSolved
modify fun s => { s with goals := mvarIds ++ mvarIds' }
modify fun _ => { s with goals := mvarIds ++ mvarIds' }
/-- Return the first goal. -/
def getMainGoal : TacticM MVarId := do

View file

@ -70,9 +70,9 @@ inductive MVarErrorKind where
instance : ToString MVarErrorKind where
toString
| MVarErrorKind.implicitArg ctx => "implicitArg"
| MVarErrorKind.implicitArg _ => "implicitArg"
| MVarErrorKind.hole => "hole"
| MVarErrorKind.custom msg => "custom"
| MVarErrorKind.custom _ => "custom"
structure MVarErrorInfo where
mvarId : MVarId
@ -1040,7 +1040,7 @@ private def elabUsingElabFnsAux (s : SavedState) (stx : Syntax) (expectedType? :
(try
elabFn.value stx expectedType?
catch ex => match ex with
| Exception.error ref msg =>
| Exception.error _ _ =>
if (← read).errToSorry then
exceptionToSorry ex expectedType?
else
@ -1092,7 +1092,7 @@ instance : MonadMacroAdapter TermElabM where
private def isExplicit (stx : Syntax) : Bool :=
match stx with
| `(@$f) => true
| `(@$_) => true
| _ => false
private def isExplicitApp (stx : Syntax) : Bool :=
@ -1115,22 +1115,22 @@ private def isHole (stx : Syntax) : Bool :=
match stx with
| `(_) => true
| `(? _) => true
| `(? $x:ident) => true
| `(? $_:ident) => true
| _ => false
private def isTacticBlock (stx : Syntax) : Bool :=
match stx with
| `(by $x:tacticSeq) => true
| `(by $_:tacticSeq) => true
| _ => false
private def isNoImplicitLambda (stx : Syntax) : Bool :=
match stx with
| `(no_implicit_lambda% $x:term) => true
| `(no_implicit_lambda% $_:term) => true
| _ => false
private def isTypeAscription (stx : Syntax) : Bool :=
match stx with
| `(($e : $type)) => true
| `(($_ : $type)) => true
| _ => false
def hasNoImplicitLambdaAnnotation (type : Expr) : Bool :=
@ -1541,7 +1541,7 @@ where process (candidates : List (Name × List String)) : TermElabM (List (Expr
`(v.head, id, [f₁, f₂])` where `id` is an identifier for `v.head`, and `f₁` and `f₂` are identifiers for fields `"bla"` and `"boo"`. -/
def resolveName' (ident : Syntax) (explicitLevels : List Level) (expectedType? : Option Expr := none) : TermElabM (List (Expr × Syntax × List Syntax)) := do
match ident with
| Syntax.ident info rawStr n preresolved =>
| Syntax.ident _ _ n preresolved =>
let r ← resolveName ident n preresolved explicitLevels expectedType?
r.mapM fun (c, fields) => do
let ids := ident.identComponents (nFields? := fields.length)
@ -1552,7 +1552,7 @@ def resolveId? (stx : Syntax) (kind := "term") (withInfo := false) : TermElabM (
match stx with
| Syntax.ident _ _ val preresolved => do
let rs ← try resolveName stx val preresolved [] catch _ => pure []
let rs := rs.filter fun ⟨f, projs⟩ => projs.isEmpty
let rs := rs.filter fun ⟨_, projs⟩ => projs.isEmpty
let fs := rs.map fun (f, _) => f
match fs with
| [] => return none

View file

@ -203,7 +203,7 @@ partial def ensureExtensionsArraySize (env : Environment) : IO Environment := do
where
loop (i : Nat) (env : Environment) : IO Environment := do
let envExtensions ← envExtensionsRef.get
if h : i < envExtensions.size then
if _ : i < envExtensions.size then
let s ← envExtensions[i].mkInitial
let env := { env with extensions := env.extensions.push s }
loop (i + 1) env
@ -592,7 +592,7 @@ where
loop (i : Nat) (env : Environment) : IO Environment := do
-- Recall that the size of the array stored `persistentEnvExtensionRef` may increase when we import user-defined environment extensions.
let pExtDescrs ← persistentEnvExtensionsRef.get
if h : i < pExtDescrs.size then
if _ : i < pExtDescrs.size then
let extDescr := pExtDescrs[i]
let s := extDescr.toEnvExtension.getState env
let prevSize := (← persistentEnvExtensionsRef.get).size

View file

@ -558,12 +558,12 @@ def getForallBody : Expr → Expr
function applications `f a₁ .. aₙ`, return `f`.
Otherwise return the input expression. -/
def getAppFn : Expr → Expr
| app f a _ => getAppFn f
| app f _ _ => getAppFn f
| e => e
def getAppNumArgsAux : Expr → Nat → Nat
| app f a _, n => getAppNumArgsAux f (n+1)
| e, n => n
| app f _ _, n => getAppNumArgsAux f (n+1)
| _, n => n
/-- Counts the number `n` of arguments for an expression `f a₁ .. aₙ`. -/
def getAppNumArgs (e : Expr) : Nat :=
@ -589,7 +589,7 @@ private def getAppRevArgsAux : Expr → Array Expr → Array Expr
@[specialize] def withAppAux (k : Expr → Array Expr → α) : Expr → Array Expr → Nat → α
| app f a _, as, i => withAppAux k f (as.set! i a) (i-1)
| f, as, i => k f as
| f, as, _ => k f as
/-- Given `e = f a₁ a₂ ... aₙ`, returns `k f #[a₁, ..., aₙ]`. -/
@[inline] def withApp (e : Expr) (k : Expr → Array Expr → α) : α :=
@ -606,12 +606,12 @@ private def getAppRevArgsAux : Expr → Array Expr → Array Expr
withAppRevAux k e (Array.mkEmpty e.getAppNumArgs)
def getRevArgD : Expr → Nat → Expr → Expr
| app f a _, 0, _ => a
| app _ a _, 0, _ => a
| app f _ _, i+1, v => getRevArgD f i v
| _, _, v => v
def getRevArg! : Expr → Nat → Expr
| app f a _, 0 => a
| app _ a _, 0 => a
| app f _ _, i+1 => getRevArg! f i
| _, _ => panic! "invalid index"
@ -979,7 +979,7 @@ def isHeadBetaTarget (e : Expr) (useZeta := false) : Bool :=
private def etaExpandedBody : Expr → Nat → Nat → Option Expr
| app f (bvar j _) _, n+1, i => if j == i then etaExpandedBody f n (i+1) else none
| _, n+1, _ => none
| _, _+1, _ => none
| f, 0, _ => if f.hasLooseBVars then none else some f
private def etaExpandedAux : Expr → Nat → Option Expr
@ -1046,8 +1046,8 @@ partial def consumeMDataAndTypeAnnotations (e : Expr) : Expr :=
| Expr.letE _ t v b _ => visit t || visit v || visit b
| Expr.app f a _ => visit f || visit a
| Expr.proj _ _ e _ => visit e
| e@(Expr.fvar fvarId _) => p fvarId
| e => false
| _@(Expr.fvar fvarId _) => p fvarId
| _ => false
visit e
def containsFVar (e : Expr) (fvarId : FVarId) : Bool :=
@ -1171,9 +1171,9 @@ partial def eta (e : Expr) : Expr :=
let rec @[specialize] visit (e : Expr) : Expr :=
if !e.hasLevelParam then e
else match e with
| lam n d b _ => e.updateLambdaE! (visit d) (visit b)
| forallE n d b _ => e.updateForallE! (visit d) (visit b)
| letE n t v b _ => e.updateLet! (visit t) (visit v) (visit b)
| lam _ d b _ => e.updateLambdaE! (visit d) (visit b)
| forallE _ d b _ => e.updateForallE! (visit d) (visit b)
| letE _ t v b _ => e.updateLet! (visit t) (visit v) (visit b)
| app f a _ => e.updateApp! (visit f) (visit a)
| proj _ _ s _ => e.updateProj! (visit s)
| mdata _ b _ => e.updateMData! (visit b)
@ -1272,7 +1272,7 @@ private def patternRefAnnotationKey := `_patWithRef
-/
def patternWithRef? (p : Expr) : Option (Syntax × Expr) :=
match p with
| Expr.mdata d b _ =>
| Expr.mdata d _ _ =>
match d.find patternRefAnnotationKey with
| some (DataValue.ofSyntax stx) => some (stx, p.mdataExpr!)
| _ => none

View file

@ -28,7 +28,7 @@ abbrev Key := Name
`KeyedDeclsAttribute` definition.
Important: `mkConst valueTypeName` and `γ` must be definitionally equal. -/
structure Def (γ : Type) where
structure Def (_ : Type) where
builtinName : Name := Name.anonymous -- Builtin attribute name, if any (e.g., `builtinTermElab)
name : Name -- Attribute name (e.g., `termElab)
descr : String -- Attribute description
@ -103,7 +103,7 @@ protected unsafe def init {γ} (df : Def γ) (attrDeclName : Name) : IO (KeyedDe
let ext : Extension γ ← registerScopedEnvExtension {
name := df.name
mkInitial := return mkStateOfTable (← tableRef.get)
ofOLeanEntry := fun s entry => do
ofOLeanEntry := fun _ entry => do
let ctx ← read
match ctx.env.evalConstCheck γ ctx.opts df.valueTypeName entry.declName with
| Except.ok f => return { toOLeanEntry := entry, value := f }

View file

@ -196,7 +196,7 @@ def isNeverZero : Level → Bool
| mvar .. => false
| succ .. => true
| max l₁ l₂ _ => isNeverZero l₁ || isNeverZero l₂
| imax l₁ l₂ _ => isNeverZero l₂
| imax _ l₂ _ => isNeverZero l₂
def ofNat : Nat → Level
| 0 => levelZero
@ -559,11 +559,11 @@ where
go (u v : Level) : Bool :=
u == v ||
match u, v with
| u, zero _ => true
| _, zero _ => true
| u, max v₁ v₂ _ => go u v₁ && go u v₂
| max u₁ u₂ _, v => go u₁ v || go u₂ v
| u, imax v₁ v₂ _ => go u v₁ && go u v₂
| imax u₁ u₂ _, v => go u₂ v
| imax _ u₂ _, v => go u₂ v
| succ u _, succ v _ => go u v
| _, _ =>
let v' := v.getLevelOffset

View file

@ -171,8 +171,8 @@ def bracket (l : String) (f : MessageData) (r : String) : MessageData := group (
def paren (f : MessageData) : MessageData := bracket "(" f ")"
def sbracket (f : MessageData) : MessageData := bracket "[" f "]"
def joinSep : List MessageData → MessageData → MessageData
| [], sep => Format.nil
| [a], sep => a
| [], _ => Format.nil
| [a], _ => a
| a::as, sep => a ++ sep ++ joinSep as sep
def ofList: List MessageData → MessageData
| [] => "[]"
@ -318,7 +318,7 @@ def toMessageData (e : KernelException) (opts : Options) : MessageData :=
match e with
| unknownConstant env constName => mkCtx env {} opts m!"(kernel) unknown constant '{constName}'"
| alreadyDeclared env constName => mkCtx env {} opts m!"(kernel) constant has already been declared '{constName}'"
| declTypeMismatch env decl givenType =>
| declTypeMismatch _ decl givenType =>
let process (n : Name) (expectedType : Expr) : MessageData :=
m!"(kernel) declaration type mismatch, '{n}' has type{indentExpr givenType}\nbut it is expected to have type{indentExpr expectedType}";
match decl with

Some files were not shown because too many files have changed in this diff Show more