Skip to content

Commit 2f677bf

Browse files
Garmelonkim-emmathlib4-botmathlib-nightly-testing[bot]leanprover-community-mathlib4-bot
authored
chore: bump toolchain to v4.31.0-rc1 (#609)
Co-authored-by: Kim Morrison <477956+kim-em@users.noreply.github.com> Co-authored-by: mathlib4-bot <github-mathlib4-bot@leanprover.zulipchat.com> Co-authored-by: mathlib-nightly-testing[bot] <258991302+mathlib-nightly-testing[bot]@users.noreply.github.com> Co-authored-by: leanprover-community-mathlib4-bot <129911861+leanprover-community-mathlib4-bot@users.noreply.github.com> Co-authored-by: Kim Morrison <kim@tqft.net> Co-authored-by: leanprover-community-mathlib4-bot <leanprover-community-mathlib4-bot@users.noreply.github.com> Co-authored-by: Chris Henson <chrishenson.net@gmail.com> Co-authored-by: Chris Henson <46805207+chenson2018@users.noreply.github.com> Co-authored-by: Ching-Tsun Chou <chingtsun.chou@gmail.com> Co-authored-by: Alexandre Rademaker <arademaker@gmail.com> Co-authored-by: mathlib-nightly-testing[bot] <mathlib-nightly-testing[bot]@users.noreply.github.com> Co-authored-by: Fabrizio Montesi <famontesi@gmail.com>
1 parent d0c137a commit 2f677bf

16 files changed

Lines changed: 116 additions & 116 deletions

File tree

Cslib.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module -- shake: keep-all
1+
module -- shake: keep-all --deprecated_module: ignore
22

33
public import Cslib.Algorithms.Lean.MergeSort.MergeSort
44
public import Cslib.Algorithms.Lean.TimeM

Cslib/Computability/Automata/DA/Congr.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ theorem congr_language_eq {a : Quotient c.eq} : language (FinAcc.mk c.toDA {a})
6262
/-- A grind regression found moving to nightly-2026-03-31 (changes from lean#13166) -/
6363
constructor <;>
6464
· intro h
65-
simpa [mem_language, Accepts, congr_mtr_eq] using h
65+
simpa [mem_language, Accepts, congr_mtr_eq] using! h
6666

6767
end FinAcc
6868

Cslib/Computability/Languages/Congruences/BuchiCongruence.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ theorem buchiFamily_cover [Inhabited Symbol] [Finite State] :
142142
simp_all only [extract_drop, color]
143143
split_ifs with h
144144
· have : f k ≤ f (k + 1) := by lia
145-
have : f 0 + (f k - f 0) = f k := by lia
145+
have : f 0 + (f k - f 0) = f k := by grind
146146
have : f 0 + (f (k + 1) - f 0) = f (k + 1) := by lia
147147
simp_all
148148
rfl

Cslib/Computability/Machines/SingleTapeTuring/Basic.lean

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -384,8 +384,6 @@ This section defines the notion of time-bounded Turing Machines
384384

385385
section TimeComputable
386386

387-
variable [Inhabited Symbol] [Fintype Symbol]
388-
389387
/-- A Turing machine + a time function +
390388
a proof it outputs `f` in at most `time(input.length)` steps. -/
391389
structure TimeComputable (f : List Symbol → List Symbol) where
@@ -470,8 +468,6 @@ section PolyTimeComputable
470468

471469
open Polynomial
472470

473-
variable [Inhabited Symbol] [Fintype Symbol]
474-
475471
/-- A Turing machine + a polynomial time function +
476472
a proof it outputs `f` in at most `time(input.length)` steps. -/
477473
structure PolyTimeComputable (f : List Symbol → List Symbol) extends TimeComputable f where

Cslib/Crypto/Protocols/SecretSharing/Shamir.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ private theorem privacyCorrectionPolynomial_eval
153153
(privacyCorrectionPolynomial (F := F) params s secret₀ secret₁).eval (params.point i) =
154154
(secret₀ - secret₁) / params.point i := by
155155
classical
156-
simpa using
156+
simpa using!
157157
(_root_.Lagrange.eval_interpolate_at_node
158158
(s := s.attach)
159159
(v := fun j : s => params.point j)

Cslib/Foundations/Control/Monad/Free.lean

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,8 @@ lemma liftM_lift_bind (interp : {ι : Type u} → F ι → m ι) (op : F β) (co
230230
@[simp]
231231
lemma liftM_lift [LawfulMonad m] (interp : {ι : Type u} → F ι → m ι) (op : F β) :
232232
(lift op).liftM interp = interp op := by
233-
simp_rw [lift, FreeM.liftM, _root_.bind_pure]
233+
rw [lift, FreeM.liftM]
234+
simp
234235

235236
@[simp]
236237
lemma liftM_bind [LawfulMonad m]

Cslib/Foundations/Control/Monad/Free/Effects.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ instance instMonadWithReaderOf : MonadWithReaderOf σ (FreeReader σ) where
449449
| pure a => rfl
450450
| liftBind op cont ih =>
451451
cases op
452-
simpa [withTheReader, instMonadWithReaderOf, run] using (ih (f s) s)
452+
simpa [withTheReader, instMonadWithReaderOf, run] using! (ih (f s) s)
453453

454454
end FreeReader
455455

Cslib/Foundations/Data/HasFresh.lean

Lines changed: 62 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,17 @@ module -- shake: keep-downstream
88

99
public import Cslib.Init
1010
public import Mathlib.Analysis.Normed.Field.Lemmas
11+
meta import Lean.Elab.ConfigEval
1112
import Qq
1213

1314
/-! Computable chacterization of infinite types. -/
1415

16+
namespace Cslib
17+
1518
@[expose] public section
1619

1720
universe u
1821

19-
namespace Cslib
20-
2122
/-- A type `α` has a computable `fresh` function if it is always possible, for any finite set
2223
of `α`, to compute a fresh element not in the set. -/
2324
class HasFresh (α : Type u) where
@@ -33,6 +34,63 @@ in proofs. -/
3334
theorem HasFresh.fresh_exists {α : Type u} [HasFresh α] (s : Finset α) : ∃ a, a ∉ s :=
3435
⟨fresh s, fresh_notMem s⟩
3536

37+
export HasFresh (fresh fresh_notMem fresh_exists)
38+
39+
/-- `HasFresh α` implies a computably infinite type. -/
40+
instance HasFresh.to_infinite (α : Type u) [HasFresh α] : Infinite α := by
41+
apply Infinite.of_not_fintype
42+
rintro ⟨elems, _⟩
43+
grind [fresh_notMem elems]
44+
45+
/-- All infinite types have an associated (at least noncomputable) fresh function.
46+
This, in conjunction with `HasFresh.to_infinite`, characterizes `HasFresh`. -/
47+
noncomputable instance (α : Type u) [Infinite α] : HasFresh α where
48+
fresh s := Infinite.exists_notMem_finset s |>.choose
49+
fresh_notMem s := by grind
50+
51+
open Finset in
52+
/-- Construct a fresh element from an embedding of `ℕ` using `Nat.find`. -/
53+
@[implicit_reducible]
54+
def HasFresh.ofNatEmbed {α : Type u} [DecidableEq α] (e : ℕ ↪ α) : HasFresh α where
55+
fresh s := e (Nat.find (p := fun n ↦ e n ∉ s) ⟨(s.preimage e e.2.injOn).max.succ,
56+
fun h ↦ not_lt_of_ge (le_max <| mem_preimage.2 h) (WithBot.lt_succ _)⟩)
57+
fresh_notMem s := Nat.find_spec (p := fun n ↦ e n ∉ s) _
58+
59+
/-- Construct a fresh element given a function `f` with `x < f x`. -/
60+
@[implicit_reducible]
61+
def HasFresh.ofSucc {α : Type u} [Inhabited α] [SemilatticeSup α] (f : α → α) (hf : ∀ x, x < f x) :
62+
HasFresh α where
63+
fresh s := if hs : s.Nonempty then f (s.sup' hs id) else default
64+
fresh_notMem s h := if hs : s.Nonempty
65+
then not_le_of_gt (hf (s.sup' hs id)) <| by rw [dif_pos hs] at h; exact s.le_sup' id h
66+
else hs ⟨_, h⟩
67+
68+
/-- `ℕ` has a computable fresh function. -/
69+
instance : HasFresh ℕ :=
70+
.ofSucc (· + 1) Nat.lt_add_one
71+
72+
/-- `ℤ` has a computable fresh function. -/
73+
instance : HasFresh ℤ :=
74+
.ofSucc (· + 1) Int.lt_succ
75+
76+
/-- `ℚ` has a computable fresh function. -/
77+
instance : HasFresh ℚ :=
78+
.ofSucc (· + 1) fun x ↦ lt_add_of_pos_right x one_pos
79+
80+
/-- If `α` has a computable fresh function, then so does `Finset α`. -/
81+
instance {α : Type u} [DecidableEq α] [HasFresh α] : HasFresh (Finset α) :=
82+
.ofSucc (fun s ↦ insert (fresh s) s) fun s ↦ Finset.ssubset_insert <| fresh_notMem s
83+
84+
/-- If `α` is inhabited, then `Multiset α` has a computable fresh function. -/
85+
instance {α : Type u} [DecidableEq α] [Inhabited α] : HasFresh (Multiset α) :=
86+
.ofSucc (fun s ↦ default ::ₘ s) fun _ ↦ Multiset.lt_cons_self _ _
87+
88+
/-- `ℕ → ℕ` has a computable fresh function. -/
89+
instance : HasFresh (ℕ → ℕ) :=
90+
.ofSucc (fun f x ↦ f x + 1) fun _ ↦ Pi.lt_def.2fun _ ↦ Nat.le_succ _, 0, Nat.lt_succ_self _⟩
91+
92+
end
93+
3694
public meta section
3795

3896
open Lean Elab Term Meta Parser Tactic
@@ -45,7 +103,7 @@ structure FreeUnionConfig where
45103
finset : Bool := true
46104

47105
/-- Elaborate a FreeUnionConfig. -/
48-
declare_config_elab elabFreeUnionConfig FreeUnionConfig
106+
declare_term_config_elab elabFreeUnionConfig FreeUnionConfig
49107

50108
/--
51109
Given a `DecidableEq Var` instance, this elaborator automatically constructs
@@ -87,7 +145,7 @@ set_option linter.style.emptyLine false in
87145
def HasFresh.freeUnion : TermElab := fun stx _ => do
88146
match stx with
89147
| `(free_union $cfg $[[$maps,*]]? $var:term) =>
90-
let cfg ← elabFreeUnionConfig cfg |>.run { elaborator := .anonymous } |>.run' { goals := [] }
148+
let cfg ← elabFreeUnionConfig cfg
91149

92150
-- the type of our variables
93151
let var ← elabType var
@@ -124,59 +182,4 @@ def HasFresh.freeUnion : TermElab := fun stx _ => do
124182

125183
end
126184

127-
export HasFresh (fresh fresh_notMem fresh_exists)
128-
129-
/-- `HasFresh α` implies a computably infinite type. -/
130-
instance HasFresh.to_infinite (α : Type u) [HasFresh α] : Infinite α := by
131-
apply Infinite.of_not_fintype
132-
rintro ⟨elems, _⟩
133-
grind [fresh_notMem elems]
134-
135-
/-- All infinite types have an associated (at least noncomputable) fresh function.
136-
This, in conjunction with `HasFresh.to_infinite`, characterizes `HasFresh`. -/
137-
noncomputable instance (α : Type u) [Infinite α] : HasFresh α where
138-
fresh s := Infinite.exists_notMem_finset s |>.choose
139-
fresh_notMem s := by grind
140-
141-
open Finset in
142-
/-- Construct a fresh element from an embedding of `ℕ` using `Nat.find`. -/
143-
@[implicit_reducible]
144-
def HasFresh.ofNatEmbed {α : Type u} [DecidableEq α] (e : ℕ ↪ α) : HasFresh α where
145-
fresh s := e (Nat.find (p := fun n ↦ e n ∉ s) ⟨(s.preimage e e.2.injOn).max.succ,
146-
fun h ↦ not_lt_of_ge (le_max <| mem_preimage.2 h) (WithBot.lt_succ _)⟩)
147-
fresh_notMem s := Nat.find_spec (p := fun n ↦ e n ∉ s) _
148-
149-
/-- Construct a fresh element given a function `f` with `x < f x`. -/
150-
@[implicit_reducible]
151-
def HasFresh.ofSucc {α : Type u} [Inhabited α] [SemilatticeSup α] (f : α → α) (hf : ∀ x, x < f x) :
152-
HasFresh α where
153-
fresh s := if hs : s.Nonempty then f (s.sup' hs id) else default
154-
fresh_notMem s h := if hs : s.Nonempty
155-
then not_le_of_gt (hf (s.sup' hs id)) <| by rw [dif_pos hs] at h; exact s.le_sup' id h
156-
else hs ⟨_, h⟩
157-
158-
/-- `ℕ` has a computable fresh function. -/
159-
instance : HasFresh ℕ :=
160-
.ofSucc (· + 1) Nat.lt_add_one
161-
162-
/-- `ℤ` has a computable fresh function. -/
163-
instance : HasFresh ℤ :=
164-
.ofSucc (· + 1) Int.lt_succ
165-
166-
/-- `ℚ` has a computable fresh function. -/
167-
instance : HasFresh ℚ :=
168-
.ofSucc (· + 1) fun x ↦ lt_add_of_pos_right x one_pos
169-
170-
/-- If `α` has a computable fresh function, then so does `Finset α`. -/
171-
instance {α : Type u} [DecidableEq α] [HasFresh α] : HasFresh (Finset α) :=
172-
.ofSucc (fun s ↦ insert (fresh s) s) fun s ↦ Finset.ssubset_insert <| fresh_notMem s
173-
174-
/-- If `α` is inhabited, then `Multiset α` has a computable fresh function. -/
175-
instance {α : Type u} [DecidableEq α] [Inhabited α] : HasFresh (Multiset α) :=
176-
.ofSucc (fun s ↦ default ::ₘ s) fun _ ↦ Multiset.lt_cons_self _ _
177-
178-
/-- `ℕ → ℕ` has a computable fresh function. -/
179-
instance : HasFresh (ℕ → ℕ) :=
180-
.ofSucc (fun f x ↦ f x + 1) fun _ ↦ Pi.lt_def.2fun _ ↦ Nat.le_succ _, 0, Nat.lt_succ_self _⟩
181-
182185
end Cslib

Cslib/Languages/LambdaCalculus/LocallyNameless/Fsub/Safety.lean

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,14 @@ set_option linter.tacticAnalysis.verifyGrindOnly false in
7575
/-- Any typable term either has a reduction step or is a value. -/
7676
lemma Typing.progress (der : Typing [] t τ) : t.Value ∨ ∃ t', t ⭢βᵛ t' := by
7777
generalize eq : [] = Γ at der
78-
have der' : Typing Γ t τ := by assumption
79-
induction der <;> subst eq <;> simp only [forall_const] at *
78+
have der' : Typing Γ t τ := der
79+
induction der <;> subst eq
8080
case var mem => grind
8181
case app t₁ _ _ t₂ l r ih_l ih_r =>
8282
right
83-
cases ih_l l with
83+
cases ih_l rfl l with
8484
| inl val_l =>
85-
cases ih_r r with
85+
cases ih_r rfl r with
8686
| inl val_r =>
8787
have ⟨σ, t₁, eq⟩ := l.canonical_form_abs val_l
8888
exists t₁ ^ᵗᵗ t₂
@@ -97,7 +97,7 @@ lemma Typing.progress (der : Typing [] t τ) : t.Value ∨ ∃ t', t ⭢βᵛ t'
9797
grind
9898
case tapp σ' der _ ih =>
9999
right
100-
specialize ih der
100+
specialize ih rfl der
101101
cases ih with
102102
| inl val =>
103103
obtain ⟨_, t, _⟩ := der.canonical_form_tabs val
@@ -107,9 +107,9 @@ lemma Typing.progress (der : Typing [] t τ) : t.Value ∨ ∃ t', t ⭢βᵛ t'
107107
obtain ⟨t', _⟩ := red
108108
exists .tapp t' σ'
109109
grind
110-
case let' t₁ σ t₂ τ L der _ _ ih =>
110+
case let' t₁ σ t₂ τ L der _ ih _ =>
111111
right
112-
cases ih der with
112+
cases ih rfl der with
113113
| inl _ =>
114114
exists t₂ ^ᵗᵗ t₁
115115
grind
@@ -118,24 +118,24 @@ lemma Typing.progress (der : Typing [] t τ) : t.Value ∨ ∃ t', t ⭢βᵛ t'
118118
exists t₁'.let' t₂
119119
grind
120120
case inl der _ ih =>
121-
cases (ih der) with
121+
cases (ih rfl der) with
122122
| inl val => grind
123123
| inr red =>
124124
right
125125
obtain ⟨t', _⟩ := red
126126
exists .inl t'
127127
grind
128128
case inr der _ ih =>
129-
cases (ih der) with
129+
cases (ih rfl der) with
130130
| inl val => grind
131131
| inr red =>
132132
right
133133
obtain ⟨t', _⟩ := red
134134
exists .inr t'
135135
grind
136-
case case t₁ _ _ t₂ _ t₃ _ der _ _ _ _ ih =>
136+
case case t₁ _ _ t₂ _ t₃ _ der _ _ ih _ _ =>
137137
right
138-
cases ih der with
138+
cases ih rfl der with
139139
| inl val =>
140140
have ⟨t₁, lr⟩ := der.canonical_form_sum val
141141
cases lr <;> [exists t₂ ^ᵗᵗ t₁; exists t₃ ^ᵗᵗ t₁] <;> grind

Cslib/Logics/LinearLogic/CLL/PhaseSemantics/Basic.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ lemma biorth_least_fact (G : Set P) :
264264
symm at hF ⊢
265265
apply ClosureOperator.IsClosed.closure_eq (congrArg orthogonal (congrArg orthogonal hF))
266266
have hF_closed : c.IsClosed F := (c.isClosed_iff).2 this.symm
267-
simpa [c] using ClosureOperator.closure_min hGF hF_closed
267+
simpa [c] using! ClosureOperator.closure_min hGF hF_closed
268268
apply h_min
269269

270270
/-- `0` is the least fact (w.r.t. inclusion). -/
@@ -304,7 +304,7 @@ lemma inter_isFact_of_isFact {A B : Set P}
304304
let FB : Fact P := ⟨B, hB⟩
305305
have h := sInf_isFact (S := ({FA, FB} : Set (Fact P)))
306306
simpa [carriersInf, Set.image_pair, sInf_insert, sInf_singleton, inf_eq_inter]
307-
using h
307+
using! h
308308

309309
instance : InfSet (Fact P) where
310310
sInf S := ⟨carriersInf S, sInf_isFact (S := S)⟩

0 commit comments

Comments
 (0)