data.seq.computation
⟷
Mathlib.Data.Seq.Computation
The following section lists changes to this file in mathlib3 and mathlib4 that occured after the initial port. Most recent changes are shown first. Hovering over a commit will show all commits associated with the same mathlib3 commit.
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(last sync)
mathlib commit https://github.com/leanprover-community/mathlib/commit/65a1391a0106c9204fe45bc73a039f056558cb83
@@ -1226,7 +1226,7 @@ def LiftRel (R : α → β → Prop) (ca : Computation α) (cb : Computation β)
#print Computation.LiftRel.swap /-
theorem LiftRel.swap (R : α → β → Prop) (ca : Computation α) (cb : Computation β) :
LiftRel (swap R) cb ca ↔ LiftRel R ca cb :=
- and_comm' _ _
+ and_comm _ _
#align computation.lift_rel.swap Computation.LiftRel.swap
-/
mathlib commit https://github.com/leanprover-community/mathlib/commit/65a1391a0106c9204fe45bc73a039f056558cb83
@@ -128,7 +128,7 @@ theorem destruct_eq_pure {s : Computation α} {a : α} : destruct s = Sum.inl a
· contradiction
· apply Subtype.eq; funext n
induction' n with n IH
- · injection h with h'; rwa [h'] at f0
+ · injection h with h'; rwa [h'] at f0
· exact s.2 IH
#align computation.destruct_eq_ret Computation.destruct_eq_pure
-/
@@ -250,7 +250,7 @@ def corec (f : β → Sum α β) (b : β) : Computation α :=
induction' n with n IH <;> intro o
· change (corec.F f o).1 = some a' → (corec.F f (corec.F f o).2).1 = some a'
cases' o with a b <;> intro h; · exact h
- dsimp [corec.F] at h ; dsimp [corec.F]
+ dsimp [corec.F] at h; dsimp [corec.F]
cases' f b with a b'; · exact h
· contradiction
· rw [Stream'.corec'_eq (corec.F f) (corec.F f o).2, Stream'.corec'_eq (corec.F f) o]
@@ -329,12 +329,12 @@ theorem eq_of_bisim (bisim : IsBisimulation R) {s₁ s₂} (r : s₁ ~ s₂) : s
And.imp id (fun r => ⟨tail s, tail s', by cases s <;> rfl, by cases s' <;> rfl, r⟩) this
have := bisim r; revert r this
apply rec_on s _ _ <;> intros <;> apply rec_on s' _ _ <;> intros <;> intro r this
- · constructor; dsimp at this ; rw [this]; assumption
- · rw [destruct_ret, destruct_think] at this
+ · constructor; dsimp at this; rw [this]; assumption
+ · rw [destruct_ret, destruct_think] at this
exact False.elim this
- · rw [destruct_ret, destruct_think] at this
+ · rw [destruct_ret, destruct_think] at this
exact False.elim this
- · simp at this ; simp [*]
+ · simp at this; simp [*]
exact ⟨s₁, s₂, rfl, rfl, r⟩
#align computation.eq_of_bisim Computation.eq_of_bisim
-/
@@ -393,7 +393,7 @@ theorem terminates_of_mem {s : Computation α} {a : α} (h : a ∈ s) : Terminat
#print Computation.terminates_def /-
theorem terminates_def (s : Computation α) : Terminates s ↔ ∃ n, (s.1 n).isSome :=
- ⟨fun ⟨⟨a, n, h⟩⟩ => ⟨n, by dsimp [Stream'.get] at h ; rw [← h]; exact rfl⟩, fun ⟨n, h⟩ =>
+ ⟨fun ⟨⟨a, n, h⟩⟩ => ⟨n, by dsimp [Stream'.get] at h; rw [← h]; exact rfl⟩, fun ⟨n, h⟩ =>
⟨⟨Option.get h, n, (Option.eq_some_of_isSome h).symm⟩⟩⟩
#align computation.terminates_def Computation.terminates_def
-/
@@ -698,7 +698,7 @@ theorem results_thinkN {s : Computation α} {a m} :
#print Computation.results_thinkN_pure /-
theorem results_thinkN_pure (a : α) (n) : Results (thinkN (pure a) n) a n := by
- have := results_thinkN n (results_ret a) <;> rwa [Nat.zero_add] at this
+ have := results_thinkN n (results_ret a) <;> rwa [Nat.zero_add] at this
#align computation.results_thinkN_ret Computation.results_thinkN_pure
-/
@@ -963,10 +963,10 @@ theorem of_results_bind {s : Computation α} {f : α → Computation β} {b k} :
Results (bind s f) b k → ∃ a m n, Results s a m ∧ Results (f a) b n ∧ k = n + m :=
by
induction' k with n IH generalizing s <;> apply rec_on s (fun a => _) fun s' => _ <;> intro e
- · simp [thinkN] at e ; refine' ⟨a, _, _, results_ret _, e, rfl⟩
+ · simp [thinkN] at e; refine' ⟨a, _, _, results_ret _, e, rfl⟩
· have := congr_arg head (eq_thinkN e); contradiction
- · simp at e ; refine' ⟨a, _, n + 1, results_ret _, e, rfl⟩
- · simp at e ;
+ · simp at e; refine' ⟨a, _, n + 1, results_ret _, e, rfl⟩
+ · simp at e;
exact by
let ⟨a, m, n', h1, h2, e'⟩ := IH e
rw [e'] <;> exact ⟨a, m.succ, n', results_think h1, h2, rfl⟩
@@ -987,7 +987,7 @@ theorem bind_promises {s : Computation α} {f : α → Computation β} {a b} (h1
(h2 : f a ~> b) : bind s f ~> b := fun b' bB =>
by
rcases exists_of_mem_bind bB with ⟨a', a's, ba'⟩
- rw [← h1 a's] at ba' ; exact h2 ba'
+ rw [← h1 a's] at ba'; exact h2 ba'
#align computation.bind_promises Computation.bind_promises
-/
@@ -1038,7 +1038,7 @@ theorem mem_map (f : α → β) {a} {s : Computation α} (m : a ∈ s) : f a ∈
#print Computation.exists_of_mem_map /-
theorem exists_of_mem_map {f : α → β} {b : β} {s : Computation α} (h : b ∈ map f s) :
∃ a, a ∈ s ∧ f a = b := by
- rw [← bind_ret] at h <;>
+ rw [← bind_ret] at h <;>
exact
let ⟨a, as, fb⟩ := exists_of_mem_bind h
⟨a, as, mem_unique (ret_mem _) fb⟩
@@ -1396,7 +1396,7 @@ theorem liftRel_pure_right (R : α → β → Prop) (ca : Computation α) (b :
@[simp]
theorem liftRel_pure (R : α → β → Prop) (a : α) (b : β) : LiftRel R (pure a) (pure b) ↔ R a b := by
rw [lift_rel_return_left] <;>
- exact ⟨fun ⟨b', mb', ab'⟩ => by rwa [eq_of_ret_mem mb'] at ab' , fun ab => ⟨_, ret_mem _, ab⟩⟩
+ exact ⟨fun ⟨b', mb', ab'⟩ => by rwa [eq_of_ret_mem mb'] at ab', fun ab => ⟨_, ret_mem _, ab⟩⟩
#align computation.lift_rel_return Computation.liftRel_pure
-/
@@ -1496,9 +1496,9 @@ theorem LiftRelRec.lem {R : α → β → Prop} (C : Computation α → Computat
(H : ∀ {ca cb}, C ca cb → LiftRelAux R C (destruct ca) (destruct cb)) (ca cb) (Hc : C ca cb) (a)
(ha : a ∈ ca) : LiftRel R ca cb := by
revert cb; refine' mem_rec_on ha _ fun ca' IH => _ <;> intro cb Hc <;> have h := H Hc
- · simp at h ; simp [h]
+ · simp at h; simp [h]
· have h := H Hc; simp; revert h;
- apply cb.rec_on (fun b => _) fun cb' => _ <;> intro h <;> simp at h <;> simp [h]
+ apply cb.rec_on (fun b => _) fun cb' => _ <;> intro h <;> simp at h <;> simp [h]
exact IH _ h
#align computation.lift_rel_rec.lem Computation.LiftRelRec.lem
-/
mathlib commit https://github.com/leanprover-community/mathlib/commit/b1abe23ae96fef89ad30d9f4362c307f72a55010
@@ -393,7 +393,7 @@ theorem terminates_of_mem {s : Computation α} {a : α} (h : a ∈ s) : Terminat
#print Computation.terminates_def /-
theorem terminates_def (s : Computation α) : Terminates s ↔ ∃ n, (s.1 n).isSome :=
- ⟨fun ⟨⟨a, n, h⟩⟩ => ⟨n, by dsimp [Stream'.nth] at h ; rw [← h]; exact rfl⟩, fun ⟨n, h⟩ =>
+ ⟨fun ⟨⟨a, n, h⟩⟩ => ⟨n, by dsimp [Stream'.get] at h ; rw [← h]; exact rfl⟩, fun ⟨n, h⟩ =>
⟨⟨Option.get h, n, (Option.eq_some_of_isSome h).symm⟩⟩⟩
#align computation.terminates_def Computation.terminates_def
-/
@@ -752,7 +752,7 @@ def map (f : α → β) : Computation α → Computation β
| ⟨s, al⟩ =>
⟨s.map fun o => Option.casesOn o none (some ∘ f), fun n b =>
by
- dsimp [Stream'.map, Stream'.nth]
+ dsimp [Stream'.map, Stream'.get]
induction' e : s n with a <;> intro h
· contradiction; · rw [al e, ← h]⟩
#align computation.map Computation.map
mathlib commit https://github.com/leanprover-community/mathlib/commit/ce64cd319bb6b3e82f31c2d38e79080d377be451
@@ -5,8 +5,8 @@ Authors: Mario Carneiro
Coinductive formalization of unbounded computations.
-/
-import Mathbin.Data.Stream.Init
-import Mathbin.Tactic.Basic
+import Data.Stream.Init
+import Tactic.Basic
#align_import data.seq.computation from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a"
mathlib commit https://github.com/leanprover-community/mathlib/commit/442a83d738cb208d3600056c489be16900ba701d
@@ -1089,40 +1089,40 @@ theorem ret_orElse (a : α) (c₂ : Computation α) : (pure a <|> c₂) = pure a
#align computation.ret_orelse Computation.ret_orElse
-/
-#print Computation.orelse_pure /-
+#print Computation.orElse_pure /-
@[simp]
-theorem orelse_pure (c₁ : Computation α) (a : α) : (think c₁ <|> pure a) = pure a :=
+theorem orElse_pure (c₁ : Computation α) (a : α) : (think c₁ <|> pure a) = pure a :=
destruct_eq_pure <| by unfold HasOrelse.orelse <;> simp [orelse]
-#align computation.orelse_ret Computation.orelse_pure
+#align computation.orelse_ret Computation.orElse_pure
-/
-#print Computation.orelse_think /-
+#print Computation.orElse_think /-
@[simp]
-theorem orelse_think (c₁ c₂ : Computation α) : (think c₁ <|> think c₂) = think (c₁ <|> c₂) :=
+theorem orElse_think (c₁ c₂ : Computation α) : (think c₁ <|> think c₂) = think (c₁ <|> c₂) :=
destruct_eq_think <| by unfold HasOrelse.orelse <;> simp [orelse]
-#align computation.orelse_think Computation.orelse_think
+#align computation.orelse_think Computation.orElse_think
-/
-#print Computation.empty_orelse /-
+#print Computation.empty_orElse /-
@[simp]
-theorem empty_orelse (c) : (empty α <|> c) = c :=
+theorem empty_orElse (c) : (empty α <|> c) = c :=
by
apply eq_of_bisim (fun c₁ c₂ => (Empty α <|> c₂) = c₁) _ rfl
intro s' s h; rw [← h]
apply rec_on s <;> intro s <;> rw [think_empty] <;> simp
rw [← think_empty]
-#align computation.empty_orelse Computation.empty_orelse
+#align computation.empty_orelse Computation.empty_orElse
-/
-#print Computation.orelse_empty /-
+#print Computation.orElse_empty /-
@[simp]
-theorem orelse_empty (c : Computation α) : (c <|> empty α) = c :=
+theorem orElse_empty (c : Computation α) : (c <|> empty α) = c :=
by
apply eq_of_bisim (fun c₁ c₂ => (c₂ <|> Empty α) = c₁) _ rfl
intro s' s h; rw [← h]
apply rec_on s <;> intro s <;> rw [think_empty] <;> simp
rw [← think_empty]
-#align computation.orelse_empty Computation.orelse_empty
+#align computation.orelse_empty Computation.orElse_empty
-/
#print Computation.Equiv /-
@@ -1293,8 +1293,8 @@ theorem LiftRel.imp {R S : α → β → Prop} (H : ∀ {a b}, R a b → S a b)
#align computation.lift_rel.imp Computation.LiftRel.imp
-/
-#print Computation.terminates_of_LiftRel /-
-theorem terminates_of_LiftRel {R : α → β → Prop} {s t} :
+#print Computation.terminates_of_liftRel /-
+theorem terminates_of_liftRel {R : α → β → Prop} {s t} :
LiftRel R s t → (Terminates s ↔ Terminates t)
| ⟨l, r⟩ =>
⟨fun ⟨⟨a, as⟩⟩ =>
@@ -1303,16 +1303,16 @@ theorem terminates_of_LiftRel {R : α → β → Prop} {s t} :
fun ⟨⟨b, bt⟩⟩ =>
let ⟨a, as, ab⟩ := r bt
⟨⟨a, as⟩⟩⟩
-#align computation.terminates_of_lift_rel Computation.terminates_of_LiftRel
+#align computation.terminates_of_lift_rel Computation.terminates_of_liftRel
-/
-#print Computation.rel_of_LiftRel /-
-theorem rel_of_LiftRel {R : α → β → Prop} {ca cb} :
+#print Computation.rel_of_liftRel /-
+theorem rel_of_liftRel {R : α → β → Prop} {ca cb} :
LiftRel R ca cb → ∀ {a b}, a ∈ ca → b ∈ cb → R a b
| ⟨l, r⟩, a, b, ma, mb => by
let ⟨b', mb', ab'⟩ := l ma
rw [mem_unique mb mb'] <;> exact ab'
-#align computation.rel_of_lift_rel Computation.rel_of_LiftRel
+#align computation.rel_of_lift_rel Computation.rel_of_liftRel
-/
#print Computation.liftRel_of_mem /-
@@ -1323,25 +1323,25 @@ theorem liftRel_of_mem {R : α → β → Prop} {a b ca cb} (ma : a ∈ ca) (mb
#align computation.lift_rel_of_mem Computation.liftRel_of_mem
-/
-#print Computation.exists_of_LiftRel_left /-
-theorem exists_of_LiftRel_left {R : α → β → Prop} {ca cb} (H : LiftRel R ca cb) {a} (h : a ∈ ca) :
+#print Computation.exists_of_liftRel_left /-
+theorem exists_of_liftRel_left {R : α → β → Prop} {ca cb} (H : LiftRel R ca cb) {a} (h : a ∈ ca) :
∃ b, b ∈ cb ∧ R a b :=
H.left h
-#align computation.exists_of_lift_rel_left Computation.exists_of_LiftRel_left
+#align computation.exists_of_lift_rel_left Computation.exists_of_liftRel_left
-/
-#print Computation.exists_of_LiftRel_right /-
-theorem exists_of_LiftRel_right {R : α → β → Prop} {ca cb} (H : LiftRel R ca cb) {b} (h : b ∈ cb) :
+#print Computation.exists_of_liftRel_right /-
+theorem exists_of_liftRel_right {R : α → β → Prop} {ca cb} (H : LiftRel R ca cb) {b} (h : b ∈ cb) :
∃ a, a ∈ ca ∧ R a b :=
H.right h
-#align computation.exists_of_lift_rel_right Computation.exists_of_LiftRel_right
+#align computation.exists_of_lift_rel_right Computation.exists_of_liftRel_right
-/
#print Computation.liftRel_def /-
theorem liftRel_def {R : α → β → Prop} {ca cb} :
LiftRel R ca cb ↔ (Terminates ca ↔ Terminates cb) ∧ ∀ {a b}, a ∈ ca → b ∈ cb → R a b :=
⟨fun h =>
- ⟨terminates_of_LiftRel h, fun a b ma mb =>
+ ⟨terminates_of_liftRel h, fun a b ma mb =>
by
let ⟨b', mb', ab⟩ := h.left ma
rwa [mem_unique mb mb']⟩,
@@ -1503,15 +1503,15 @@ theorem LiftRelRec.lem {R : α → β → Prop} (C : Computation α → Computat
#align computation.lift_rel_rec.lem Computation.LiftRelRec.lem
-/
-#print Computation.lift_rel_rec /-
-theorem lift_rel_rec {R : α → β → Prop} (C : Computation α → Computation β → Prop)
+#print Computation.liftRel_rec /-
+theorem liftRel_rec {R : α → β → Prop} (C : Computation α → Computation β → Prop)
(H : ∀ {ca cb}, C ca cb → LiftRelAux R C (destruct ca) (destruct cb)) (ca cb) (Hc : C ca cb) :
LiftRel R ca cb :=
liftRel_mem_cases (LiftRelRec.lem C (@H) ca cb Hc) fun b hb =>
(LiftRel.swap _ _ _).2 <|
LiftRelRec.lem (swap C) (fun cb ca h => cast (LiftRelAux.swap _ _ _ _).symm <| H h) cb ca Hc b
hb
-#align computation.lift_rel_rec Computation.lift_rel_rec
+#align computation.lift_rel_rec Computation.liftRel_rec
-/
end Computation
mathlib commit https://github.com/leanprover-community/mathlib/commit/442a83d738cb208d3600056c489be16900ba701d
@@ -1425,8 +1425,6 @@ theorem liftRel_mem_cases {R : α → β → Prop} {ca cb} (Ha : ∀ a ∈ ca, L
#align computation.lift_rel_mem_cases Computation.liftRel_mem_cases
-/
-/- warning: computation.lift_rel_congr clashes with computation.lift_gcongr -> Computation.liftRel_congr
-Case conversion may be inaccurate. Consider using '#align computation.lift_rel_congr Computation.liftRel_congrₓ'. -/
#print Computation.liftRel_congr /-
theorem liftRel_congr {R : α → β → Prop} {ca ca' : Computation α} {cb cb' : Computation β}
(ha : ca ~ ca') (hb : cb ~ cb') : LiftRel R ca cb ↔ LiftRel R ca' cb' :=
mathlib commit https://github.com/leanprover-community/mathlib/commit/8ea5598db6caeddde6cb734aa179cc2408dbd345
@@ -4,15 +4,12 @@ Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro
Coinductive formalization of unbounded computations.
-
-! This file was ported from Lean 3 source module data.seq.computation
-! leanprover-community/mathlib commit 70fd9563a21e7b963887c9360bd29b2393e6225a
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
-/
import Mathbin.Data.Stream.Init
import Mathbin.Tactic.Basic
+#align_import data.seq.computation from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a"
+
open Function
universe u v w
mathlib commit https://github.com/leanprover-community/mathlib/commit/8efcf8022aac8e01df8d302dcebdbc25d6a886c8
@@ -1001,7 +1001,7 @@ instance : Monad Computation where
instance : LawfulMonad Computation where
id_map := @map_id
- bind_pure_comp_eq_map := @bind_pure
+ bind_pure_comp := @bind_pure
pure_bind := @ret_bind
bind_assoc := @bind_assoc
mathlib commit https://github.com/leanprover-community/mathlib/commit/9fb8964792b4237dac6200193a0d533f1b3f7423
@@ -298,7 +298,6 @@ section Bisim
variable (R : Computation α → Computation α → Prop)
--- mathport name: «expr ~ »
local infixl:50 " ~ " => R
#print Computation.BisimO /-
@@ -490,7 +489,6 @@ def Promises (s : Computation α) (a : α) : Prop :=
#align computation.promises Computation.Promises
-/
--- mathport name: «expr ~> »
infixl:50 " ~> " => Promises
#print Computation.mem_promises /-
@@ -507,8 +505,6 @@ section get
variable (s : Computation α) [h : Terminates s]
-include s h
-
#print Computation.length /-
/-- `length s` gets the number of steps of a terminating computation -/
def length : ℕ :=
@@ -980,12 +976,14 @@ theorem of_results_bind {s : Computation α} {f : α → Computation β} {b k} :
#align computation.of_results_bind Computation.of_results_bind
-/
+#print Computation.exists_of_mem_bind /-
theorem exists_of_mem_bind {s : Computation α} {f : α → Computation β} {b} (h : b ∈ bind s f) :
∃ a ∈ s, b ∈ f a :=
let ⟨k, h⟩ := exists_results_of_mem h
let ⟨a, m, n, h1, h2, e⟩ := of_results_bind h
⟨a, h1.Mem, h2.Mem⟩
#align computation.exists_of_mem_bind Computation.exists_of_mem_bind
+-/
#print Computation.bind_promises /-
theorem bind_promises {s : Computation α} {f : α → Computation β} {a b} (h1 : s ~> a)
@@ -1065,6 +1063,7 @@ theorem terminates_map_iff (f : α → β) (s : Computation α) : Terminates (ma
#align computation.terminates_map_iff Computation.terminates_map_iff
-/
+#print Computation.orElse /-
-- Parallel computation
/-- `c₁ <|> c₂` calculates `c₁` and `c₂` simultaneously, returning
the first one that gives a result. -/
@@ -1079,27 +1078,35 @@ def orElse (c₁ c₂ : Computation α) : Computation α :=
| Sum.inr c₂' => Sum.inr (c₁', c₂'))
(c₁, c₂)
#align computation.orelse Computation.orElse
+-/
instance : Alternative Computation :=
{ Computation.monad with
orelse := @orElse
failure := @empty }
+#print Computation.ret_orElse /-
@[simp]
theorem ret_orElse (a : α) (c₂ : Computation α) : (pure a <|> c₂) = pure a :=
destruct_eq_pure <| by unfold HasOrelse.orelse <;> simp [orelse]
#align computation.ret_orelse Computation.ret_orElse
+-/
+#print Computation.orelse_pure /-
@[simp]
theorem orelse_pure (c₁ : Computation α) (a : α) : (think c₁ <|> pure a) = pure a :=
destruct_eq_pure <| by unfold HasOrelse.orelse <;> simp [orelse]
#align computation.orelse_ret Computation.orelse_pure
+-/
+#print Computation.orelse_think /-
@[simp]
theorem orelse_think (c₁ c₂ : Computation α) : (think c₁ <|> think c₂) = think (c₁ <|> c₂) :=
destruct_eq_think <| by unfold HasOrelse.orelse <;> simp [orelse]
#align computation.orelse_think Computation.orelse_think
+-/
+#print Computation.empty_orelse /-
@[simp]
theorem empty_orelse (c) : (empty α <|> c) = c :=
by
@@ -1108,7 +1115,9 @@ theorem empty_orelse (c) : (empty α <|> c) = c :=
apply rec_on s <;> intro s <;> rw [think_empty] <;> simp
rw [← think_empty]
#align computation.empty_orelse Computation.empty_orelse
+-/
+#print Computation.orelse_empty /-
@[simp]
theorem orelse_empty (c : Computation α) : (c <|> empty α) = c :=
by
@@ -1117,6 +1126,7 @@ theorem orelse_empty (c : Computation α) : (c <|> empty α) = c :=
apply rec_on s <;> intro s <;> rw [think_empty] <;> simp
rw [← think_empty]
#align computation.orelse_empty Computation.orelse_empty
+-/
#print Computation.Equiv /-
/-- `c₁ ~ c₂` asserts that `c₁` and `c₂` either both terminate with the same result,
@@ -1126,7 +1136,6 @@ def Equiv (c₁ c₂ : Computation α) : Prop :=
#align computation.equiv Computation.Equiv
-/
--- mathport name: «expr ~ »
infixl:50 " ~ " => Equiv
#print Computation.Equiv.refl /-
@@ -1349,6 +1358,7 @@ theorem liftRel_def {R : α → β → Prop} {ca cb} :
#align computation.lift_rel_def Computation.liftRel_def
-/
+#print Computation.liftRel_bind /-
theorem liftRel_bind {δ} (R : α → β → Prop) (S : γ → δ → Prop) {s1 : Computation α}
{s2 : Computation β} {f1 : α → Computation γ} {f2 : β → Computation δ} (h1 : LiftRel R s1 s2)
(h2 : ∀ {a b}, R a b → LiftRel S (f1 a) (f2 b)) : LiftRel S (bind s1 f1) (bind s2 f2) :=
@@ -1366,6 +1376,7 @@ theorem liftRel_bind {δ} (R : α → β → Prop) (S : γ → δ → Prop) {s1
let ⟨c, c₂, cd⟩ := r2 d1
⟨_, mem_bind a2 c₂, cd⟩⟩
#align computation.lift_rel_bind Computation.liftRel_bind
+-/
#print Computation.liftRel_pure_left /-
@[simp]
@@ -1428,17 +1439,21 @@ theorem liftRel_congr {R : α → β → Prop} {ca ca' : Computation α} {cb cb'
#align computation.lift_rel_congr Computation.liftRel_congr
-/
+#print Computation.liftRel_map /-
theorem liftRel_map {δ} (R : α → β → Prop) (S : γ → δ → Prop) {s1 : Computation α}
{s2 : Computation β} {f1 : α → γ} {f2 : β → δ} (h1 : LiftRel R s1 s2)
(h2 : ∀ {a b}, R a b → S (f1 a) (f2 b)) : LiftRel S (map f1 s1) (map f2 s2) := by
rw [← bind_ret, ← bind_ret] <;> apply lift_rel_bind _ _ h1 <;> simp <;> exact @h2
#align computation.lift_rel_map Computation.liftRel_map
+-/
+#print Computation.map_congr /-
theorem map_congr (R : α → α → Prop) (S : β → β → Prop) {s1 s2 : Computation α} {f : α → β}
(h1 : s1 ~ s2) : map f s1 ~ map f s2 := by
rw [← lift_eq_iff_equiv] <;>
exact lift_rel_map Eq _ ((lift_eq_iff_equiv _ _).2 h1) fun a b => congr_arg _
#align computation.map_congr Computation.map_congr
+-/
#print Computation.LiftRelAux /-
def LiftRelAux (R : α → β → Prop) (C : Computation α → Computation β → Prop) :
mathlib commit https://github.com/leanprover-community/mathlib/commit/13361559d66b84f80b6d5a1c4a26aa5054766725
@@ -1417,6 +1417,8 @@ theorem liftRel_mem_cases {R : α → β → Prop} {ca cb} (Ha : ∀ a ∈ ca, L
#align computation.lift_rel_mem_cases Computation.liftRel_mem_cases
-/
+/- warning: computation.lift_rel_congr clashes with computation.lift_gcongr -> Computation.liftRel_congr
+Case conversion may be inaccurate. Consider using '#align computation.lift_rel_congr Computation.liftRel_congrₓ'. -/
#print Computation.liftRel_congr /-
theorem liftRel_congr {R : α → β → Prop} {ca ca' : Computation α} {cb cb' : Computation β}
(ha : ca ~ ca') (hb : cb ~ cb') : LiftRel R ca cb ↔ LiftRel R ca' cb' :=
mathlib commit https://github.com/leanprover-community/mathlib/commit/5f25c089cb34db4db112556f23c50d12da81b297
@@ -458,7 +458,7 @@ theorem not_terminates_empty : ¬Terminates (empty α) := fun ⟨⟨a, h⟩⟩ =
theorem eq_empty_of_not_terminates {s} (H : ¬Terminates s) : s = empty α :=
by
apply Subtype.eq; funext n
- induction' h : s.val n with ; · rfl
+ induction' h : s.val n with; · rfl
refine' absurd _ H; exact ⟨⟨_, _, h.symm⟩⟩
#align computation.eq_empty_of_not_terminates Computation.eq_empty_of_not_terminates
-/
mathlib commit https://github.com/leanprover-community/mathlib/commit/cca40788df1b8755d5baf17ab2f27dacc2e17acb
@@ -131,7 +131,7 @@ theorem destruct_eq_pure {s : Computation α} {a : α} : destruct s = Sum.inl a
· contradiction
· apply Subtype.eq; funext n
induction' n with n IH
- · injection h with h'; rwa [h'] at f0
+ · injection h with h'; rwa [h'] at f0
· exact s.2 IH
#align computation.destruct_eq_ret Computation.destruct_eq_pure
-/
@@ -253,7 +253,7 @@ def corec (f : β → Sum α β) (b : β) : Computation α :=
induction' n with n IH <;> intro o
· change (corec.F f o).1 = some a' → (corec.F f (corec.F f o).2).1 = some a'
cases' o with a b <;> intro h; · exact h
- dsimp [corec.F] at h; dsimp [corec.F]
+ dsimp [corec.F] at h ; dsimp [corec.F]
cases' f b with a b'; · exact h
· contradiction
· rw [Stream'.corec'_eq (corec.F f) (corec.F f o).2, Stream'.corec'_eq (corec.F f) o]
@@ -333,12 +333,12 @@ theorem eq_of_bisim (bisim : IsBisimulation R) {s₁ s₂} (r : s₁ ~ s₂) : s
And.imp id (fun r => ⟨tail s, tail s', by cases s <;> rfl, by cases s' <;> rfl, r⟩) this
have := bisim r; revert r this
apply rec_on s _ _ <;> intros <;> apply rec_on s' _ _ <;> intros <;> intro r this
- · constructor; dsimp at this; rw [this]; assumption
- · rw [destruct_ret, destruct_think] at this
+ · constructor; dsimp at this ; rw [this]; assumption
+ · rw [destruct_ret, destruct_think] at this
exact False.elim this
- · rw [destruct_ret, destruct_think] at this
+ · rw [destruct_ret, destruct_think] at this
exact False.elim this
- · simp at this; simp [*]
+ · simp at this ; simp [*]
exact ⟨s₁, s₂, rfl, rfl, r⟩
#align computation.eq_of_bisim Computation.eq_of_bisim
-/
@@ -358,7 +358,7 @@ instance : Membership α (Computation α) :=
#print Computation.le_stable /-
theorem le_stable (s : Computation α) {a m n} (h : m ≤ n) : s.1 m = some a → s.1 n = some a := by
- cases' s with f al; induction' h with n h IH; exacts[id, fun h2 => al (IH h2)]
+ cases' s with f al; induction' h with n h IH; exacts [id, fun h2 => al (IH h2)]
#align computation.le_stable Computation.le_stable
-/
@@ -397,7 +397,7 @@ theorem terminates_of_mem {s : Computation α} {a : α} (h : a ∈ s) : Terminat
#print Computation.terminates_def /-
theorem terminates_def (s : Computation α) : Terminates s ↔ ∃ n, (s.1 n).isSome :=
- ⟨fun ⟨⟨a, n, h⟩⟩ => ⟨n, by dsimp [Stream'.nth] at h; rw [← h]; exact rfl⟩, fun ⟨n, h⟩ =>
+ ⟨fun ⟨⟨a, n, h⟩⟩ => ⟨n, by dsimp [Stream'.nth] at h ; rw [← h]; exact rfl⟩, fun ⟨n, h⟩ =>
⟨⟨Option.get h, n, (Option.eq_some_of_isSome h).symm⟩⟩⟩
#align computation.terminates_def Computation.terminates_def
-/
@@ -705,7 +705,7 @@ theorem results_thinkN {s : Computation α} {a m} :
#print Computation.results_thinkN_pure /-
theorem results_thinkN_pure (a : α) (n) : Results (thinkN (pure a) n) a n := by
- have := results_thinkN n (results_ret a) <;> rwa [Nat.zero_add] at this
+ have := results_thinkN n (results_ret a) <;> rwa [Nat.zero_add] at this
#align computation.results_thinkN_ret Computation.results_thinkN_pure
-/
@@ -742,7 +742,7 @@ def memRecOn {C : Computation α → Sort v} {a s} (M : a ∈ s) (h1 : C (pure a
haveI T := terminates_of_mem M
rw [eq_thinkN' s, get_eq_of_mem s M]
generalize length s = n
- induction' n with n IH; exacts[h1, h2 _ IH]
+ induction' n with n IH; exacts [h1, h2 _ IH]
#align computation.mem_rec_on Computation.memRecOn
-/
@@ -970,10 +970,10 @@ theorem of_results_bind {s : Computation α} {f : α → Computation β} {b k} :
Results (bind s f) b k → ∃ a m n, Results s a m ∧ Results (f a) b n ∧ k = n + m :=
by
induction' k with n IH generalizing s <;> apply rec_on s (fun a => _) fun s' => _ <;> intro e
- · simp [thinkN] at e; refine' ⟨a, _, _, results_ret _, e, rfl⟩
+ · simp [thinkN] at e ; refine' ⟨a, _, _, results_ret _, e, rfl⟩
· have := congr_arg head (eq_thinkN e); contradiction
- · simp at e; refine' ⟨a, _, n + 1, results_ret _, e, rfl⟩
- · simp at e;
+ · simp at e ; refine' ⟨a, _, n + 1, results_ret _, e, rfl⟩
+ · simp at e ;
exact by
let ⟨a, m, n', h1, h2, e'⟩ := IH e
rw [e'] <;> exact ⟨a, m.succ, n', results_think h1, h2, rfl⟩
@@ -992,7 +992,7 @@ theorem bind_promises {s : Computation α} {f : α → Computation β} {a b} (h1
(h2 : f a ~> b) : bind s f ~> b := fun b' bB =>
by
rcases exists_of_mem_bind bB with ⟨a', a's, ba'⟩
- rw [← h1 a's] at ba'; exact h2 ba'
+ rw [← h1 a's] at ba' ; exact h2 ba'
#align computation.bind_promises Computation.bind_promises
-/
@@ -1043,7 +1043,7 @@ theorem mem_map (f : α → β) {a} {s : Computation α} (m : a ∈ s) : f a ∈
#print Computation.exists_of_mem_map /-
theorem exists_of_mem_map {f : α → β} {b : β} {s : Computation α} (h : b ∈ map f s) :
∃ a, a ∈ s ∧ f a = b := by
- rw [← bind_ret] at h <;>
+ rw [← bind_ret] at h <;>
exact
let ⟨a, as, fb⟩ := exists_of_mem_bind h
⟨a, as, mem_unique (ret_mem _) fb⟩
@@ -1388,7 +1388,7 @@ theorem liftRel_pure_right (R : α → β → Prop) (ca : Computation α) (b :
@[simp]
theorem liftRel_pure (R : α → β → Prop) (a : α) (b : β) : LiftRel R (pure a) (pure b) ↔ R a b := by
rw [lift_rel_return_left] <;>
- exact ⟨fun ⟨b', mb', ab'⟩ => by rwa [eq_of_ret_mem mb'] at ab', fun ab => ⟨_, ret_mem _, ab⟩⟩
+ exact ⟨fun ⟨b', mb', ab'⟩ => by rwa [eq_of_ret_mem mb'] at ab' , fun ab => ⟨_, ret_mem _, ab⟩⟩
#align computation.lift_rel_return Computation.liftRel_pure
-/
@@ -1484,9 +1484,9 @@ theorem LiftRelRec.lem {R : α → β → Prop} (C : Computation α → Computat
(H : ∀ {ca cb}, C ca cb → LiftRelAux R C (destruct ca) (destruct cb)) (ca cb) (Hc : C ca cb) (a)
(ha : a ∈ ca) : LiftRel R ca cb := by
revert cb; refine' mem_rec_on ha _ fun ca' IH => _ <;> intro cb Hc <;> have h := H Hc
- · simp at h; simp [h]
+ · simp at h ; simp [h]
· have h := H Hc; simp; revert h;
- apply cb.rec_on (fun b => _) fun cb' => _ <;> intro h <;> simp at h <;> simp [h]
+ apply cb.rec_on (fun b => _) fun cb' => _ <;> intro h <;> simp at h <;> simp [h]
exact IH _ h
#align computation.lift_rel_rec.lem Computation.LiftRelRec.lem
-/
mathlib commit https://github.com/leanprover-community/mathlib/commit/917c3c072e487b3cccdbfeff17e75b40e45f66cb
@@ -980,12 +980,6 @@ theorem of_results_bind {s : Computation α} {f : α → Computation β} {b k} :
#align computation.of_results_bind Computation.of_results_bind
-/
-/- warning: computation.exists_of_mem_bind -> Computation.exists_of_mem_bind is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}} {β : Type.{u2}} {s : Computation.{u1} α} {f : α -> (Computation.{u2} β)} {b : β}, (Membership.Mem.{u2, u2} β (Computation.{u2} β) (Computation.hasMem.{u2} β) b (Computation.bind.{u1, u2} α β s f)) -> (Exists.{succ u1} α (fun (a : α) => Exists.{0} (Membership.Mem.{u1, u1} α (Computation.{u1} α) (Computation.hasMem.{u1} α) a s) (fun (H : Membership.Mem.{u1, u1} α (Computation.{u1} α) (Computation.hasMem.{u1} α) a s) => Membership.Mem.{u2, u2} β (Computation.{u2} β) (Computation.hasMem.{u2} β) b (f a))))
-but is expected to have type
- forall {α : Type.{u1}} {β : Type.{u2}} {s : Computation.{u1} α} {f : α -> (Computation.{u2} β)} {b : β}, (Membership.mem.{u2, u2} β (Computation.{u2} β) (Computation.instMembershipComputation.{u2} β) b (Computation.bind.{u1, u2} α β s f)) -> (Exists.{succ u1} α (fun (a : α) => And (Membership.mem.{u1, u1} α (Computation.{u1} α) (Computation.instMembershipComputation.{u1} α) a s) (Membership.mem.{u2, u2} β (Computation.{u2} β) (Computation.instMembershipComputation.{u2} β) b (f a))))
-Case conversion may be inaccurate. Consider using '#align computation.exists_of_mem_bind Computation.exists_of_mem_bindₓ'. -/
theorem exists_of_mem_bind {s : Computation α} {f : α → Computation β} {b} (h : b ∈ bind s f) :
∃ a ∈ s, b ∈ f a :=
let ⟨k, h⟩ := exists_results_of_mem h
@@ -1071,12 +1065,6 @@ theorem terminates_map_iff (f : α → β) (s : Computation α) : Terminates (ma
#align computation.terminates_map_iff Computation.terminates_map_iff
-/
-/- warning: computation.orelse -> Computation.orElse is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}}, (Computation.{u1} α) -> (Computation.{u1} α) -> (Computation.{u1} α)
-but is expected to have type
- forall {α : Type.{u1}}, (Computation.{u1} α) -> (Unit -> (Computation.{u1} α)) -> (Computation.{u1} α)
-Case conversion may be inaccurate. Consider using '#align computation.orelse Computation.orElseₓ'. -/
-- Parallel computation
/-- `c₁ <|> c₂` calculates `c₁` and `c₂` simultaneously, returning
the first one that gives a result. -/
@@ -1097,45 +1085,21 @@ instance : Alternative Computation :=
orelse := @orElse
failure := @empty }
-/- warning: computation.ret_orelse -> Computation.ret_orElse is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}} (a : α) (c₂ : Computation.{u1} α), Eq.{succ u1} (Computation.{u1} α) (HasOrelse.orelse.{u1, u1} Computation.{u1} (Alternative.toHasOrelse.{u1, u1} Computation.{u1} Computation.alternative.{u1}) α (Computation.pure.{u1} α a) c₂) (Computation.pure.{u1} α a)
-but is expected to have type
- forall {α : Type.{u1}} (a : α) (c₂ : Computation.{u1} α), Eq.{succ u1} (Computation.{u1} α) (HOrElse.hOrElse.{u1, u1, u1} (Computation.{u1} α) (Computation.{u1} α) (Computation.{u1} α) (instHOrElse.{u1} (Computation.{u1} α) (instOrElse.{u1, u1} Computation.{u1} α Computation.instAlternativeComputation.{u1})) (Computation.pure.{u1} α a) (fun (x._@.Mathlib.Data.Seq.Computation._hyg.10396 : Unit) => c₂)) (Computation.pure.{u1} α a)
-Case conversion may be inaccurate. Consider using '#align computation.ret_orelse Computation.ret_orElseₓ'. -/
@[simp]
theorem ret_orElse (a : α) (c₂ : Computation α) : (pure a <|> c₂) = pure a :=
destruct_eq_pure <| by unfold HasOrelse.orelse <;> simp [orelse]
#align computation.ret_orelse Computation.ret_orElse
-/- warning: computation.orelse_ret -> Computation.orelse_pure is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}} (c₁ : Computation.{u1} α) (a : α), Eq.{succ u1} (Computation.{u1} α) (HasOrelse.orelse.{u1, u1} Computation.{u1} (Alternative.toHasOrelse.{u1, u1} Computation.{u1} Computation.alternative.{u1}) α (Computation.think.{u1} α c₁) (Computation.pure.{u1} α a)) (Computation.pure.{u1} α a)
-but is expected to have type
- forall {α : Type.{u1}} (c₁ : Computation.{u1} α) (a : α), Eq.{succ u1} (Computation.{u1} α) (HOrElse.hOrElse.{u1, u1, u1} (Computation.{u1} α) (Computation.{u1} α) (Computation.{u1} α) (instHOrElse.{u1} (Computation.{u1} α) (instOrElse.{u1, u1} Computation.{u1} α Computation.instAlternativeComputation.{u1})) (Computation.think.{u1} α c₁) (fun (x._@.Mathlib.Data.Seq.Computation._hyg.10424 : Unit) => Computation.pure.{u1} α a)) (Computation.pure.{u1} α a)
-Case conversion may be inaccurate. Consider using '#align computation.orelse_ret Computation.orelse_pureₓ'. -/
@[simp]
theorem orelse_pure (c₁ : Computation α) (a : α) : (think c₁ <|> pure a) = pure a :=
destruct_eq_pure <| by unfold HasOrelse.orelse <;> simp [orelse]
#align computation.orelse_ret Computation.orelse_pure
-/- warning: computation.orelse_think -> Computation.orelse_think is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}} (c₁ : Computation.{u1} α) (c₂ : Computation.{u1} α), Eq.{succ u1} (Computation.{u1} α) (HasOrelse.orelse.{u1, u1} Computation.{u1} (Alternative.toHasOrelse.{u1, u1} Computation.{u1} Computation.alternative.{u1}) α (Computation.think.{u1} α c₁) (Computation.think.{u1} α c₂)) (Computation.think.{u1} α (HasOrelse.orelse.{u1, u1} Computation.{u1} (Alternative.toHasOrelse.{u1, u1} Computation.{u1} Computation.alternative.{u1}) α c₁ c₂))
-but is expected to have type
- forall {α : Type.{u1}} (c₁ : Computation.{u1} α) (c₂ : Computation.{u1} α), Eq.{succ u1} (Computation.{u1} α) (HOrElse.hOrElse.{u1, u1, u1} (Computation.{u1} α) (Computation.{u1} α) (Computation.{u1} α) (instHOrElse.{u1} (Computation.{u1} α) (instOrElse.{u1, u1} Computation.{u1} α Computation.instAlternativeComputation.{u1})) (Computation.think.{u1} α c₁) (fun (x._@.Mathlib.Data.Seq.Computation._hyg.10460 : Unit) => Computation.think.{u1} α c₂)) (Computation.think.{u1} α (HOrElse.hOrElse.{u1, u1, u1} (Computation.{u1} α) (Computation.{u1} α) (Computation.{u1} α) (instHOrElse.{u1} (Computation.{u1} α) (instOrElse.{u1, u1} Computation.{u1} α Computation.instAlternativeComputation.{u1})) c₁ (fun (x._@.Mathlib.Data.Seq.Computation._hyg.10459 : Unit) => c₂)))
-Case conversion may be inaccurate. Consider using '#align computation.orelse_think Computation.orelse_thinkₓ'. -/
@[simp]
theorem orelse_think (c₁ c₂ : Computation α) : (think c₁ <|> think c₂) = think (c₁ <|> c₂) :=
destruct_eq_think <| by unfold HasOrelse.orelse <;> simp [orelse]
#align computation.orelse_think Computation.orelse_think
-/- warning: computation.empty_orelse -> Computation.empty_orelse is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}} (c : Computation.{u1} α), Eq.{succ u1} (Computation.{u1} α) (HasOrelse.orelse.{u1, u1} Computation.{u1} (Alternative.toHasOrelse.{u1, u1} Computation.{u1} Computation.alternative.{u1}) α (Computation.empty.{u1} α) c) c
-but is expected to have type
- forall {α : Type.{u1}} (c : Computation.{u1} α), Eq.{succ u1} (Computation.{u1} α) (HOrElse.hOrElse.{u1, u1, u1} (Computation.{u1} α) (Computation.{u1} α) (Computation.{u1} α) (instHOrElse.{u1} (Computation.{u1} α) (instOrElse.{u1, u1} Computation.{u1} α Computation.instAlternativeComputation.{u1})) (Computation.empty.{u1} α) (fun (x._@.Mathlib.Data.Seq.Computation._hyg.10484 : Unit) => c)) c
-Case conversion may be inaccurate. Consider using '#align computation.empty_orelse Computation.empty_orelseₓ'. -/
@[simp]
theorem empty_orelse (c) : (empty α <|> c) = c :=
by
@@ -1145,12 +1109,6 @@ theorem empty_orelse (c) : (empty α <|> c) = c :=
rw [← think_empty]
#align computation.empty_orelse Computation.empty_orelse
-/- warning: computation.orelse_empty -> Computation.orelse_empty is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}} (c : Computation.{u1} α), Eq.{succ u1} (Computation.{u1} α) (HasOrelse.orelse.{u1, u1} Computation.{u1} (Alternative.toHasOrelse.{u1, u1} Computation.{u1} Computation.alternative.{u1}) α c (Computation.empty.{u1} α)) c
-but is expected to have type
- forall {α : Type.{u1}} (c : Computation.{u1} α), Eq.{succ u1} (Computation.{u1} α) (HOrElse.hOrElse.{u1, u1, u1} (Computation.{u1} α) (Computation.{u1} α) (Computation.{u1} α) (instHOrElse.{u1} (Computation.{u1} α) (instOrElse.{u1, u1} Computation.{u1} α Computation.instAlternativeComputation.{u1})) c (fun (x._@.Mathlib.Data.Seq.Computation._hyg.10682 : Unit) => Computation.empty.{u1} α)) c
-Case conversion may be inaccurate. Consider using '#align computation.orelse_empty Computation.orelse_emptyₓ'. -/
@[simp]
theorem orelse_empty (c : Computation α) : (c <|> empty α) = c :=
by
@@ -1391,12 +1349,6 @@ theorem liftRel_def {R : α → β → Prop} {ca cb} :
#align computation.lift_rel_def Computation.liftRel_def
-/
-/- warning: computation.lift_rel_bind -> Computation.liftRel_bind is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} {δ : Type.{u4}} (R : α -> β -> Prop) (S : γ -> δ -> Prop) {s1 : Computation.{u1} α} {s2 : Computation.{u2} β} {f1 : α -> (Computation.{u3} γ)} {f2 : β -> (Computation.{u4} δ)}, (Computation.LiftRel.{u1, u2} α β R s1 s2) -> (forall {a : α} {b : β}, (R a b) -> (Computation.LiftRel.{u3, u4} γ δ S (f1 a) (f2 b))) -> (Computation.LiftRel.{u3, u4} γ δ S (Computation.bind.{u1, u3} α γ s1 f1) (Computation.bind.{u2, u4} β δ s2 f2))
-but is expected to have type
- forall {α : Type.{u2}} {β : Type.{u3}} {γ : Type.{u4}} {δ : Type.{u1}} (R : α -> β -> Prop) (S : γ -> δ -> Prop) {s1 : Computation.{u2} α} {s2 : Computation.{u3} β} {f1 : α -> (Computation.{u4} γ)} {f2 : β -> (Computation.{u1} δ)}, (Computation.LiftRel.{u2, u3} α β R s1 s2) -> (forall {a : α} {b : β}, (R a b) -> (Computation.LiftRel.{u4, u1} γ δ S (f1 a) (f2 b))) -> (Computation.LiftRel.{u4, u1} γ δ S (Computation.bind.{u2, u4} α γ s1 f1) (Computation.bind.{u3, u1} β δ s2 f2))
-Case conversion may be inaccurate. Consider using '#align computation.lift_rel_bind Computation.liftRel_bindₓ'. -/
theorem liftRel_bind {δ} (R : α → β → Prop) (S : γ → δ → Prop) {s1 : Computation α}
{s2 : Computation β} {f1 : α → Computation γ} {f2 : β → Computation δ} (h1 : LiftRel R s1 s2)
(h2 : ∀ {a b}, R a b → LiftRel S (f1 a) (f2 b)) : LiftRel S (bind s1 f1) (bind s2 f2) :=
@@ -1474,24 +1426,12 @@ theorem liftRel_congr {R : α → β → Prop} {ca ca' : Computation α} {cb cb'
#align computation.lift_rel_congr Computation.liftRel_congr
-/
-/- warning: computation.lift_rel_map -> Computation.liftRel_map is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} {δ : Type.{u4}} (R : α -> β -> Prop) (S : γ -> δ -> Prop) {s1 : Computation.{u1} α} {s2 : Computation.{u2} β} {f1 : α -> γ} {f2 : β -> δ}, (Computation.LiftRel.{u1, u2} α β R s1 s2) -> (forall {a : α} {b : β}, (R a b) -> (S (f1 a) (f2 b))) -> (Computation.LiftRel.{u3, u4} γ δ S (Computation.map.{u1, u3} α γ f1 s1) (Computation.map.{u2, u4} β δ f2 s2))
-but is expected to have type
- forall {α : Type.{u2}} {β : Type.{u3}} {γ : Type.{u4}} {δ : Type.{u1}} (R : α -> β -> Prop) (S : γ -> δ -> Prop) {s1 : Computation.{u2} α} {s2 : Computation.{u3} β} {f1 : α -> γ} {f2 : β -> δ}, (Computation.LiftRel.{u2, u3} α β R s1 s2) -> (forall {a : α} {b : β}, (R a b) -> (S (f1 a) (f2 b))) -> (Computation.LiftRel.{u4, u1} γ δ S (Computation.map.{u2, u4} α γ f1 s1) (Computation.map.{u3, u1} β δ f2 s2))
-Case conversion may be inaccurate. Consider using '#align computation.lift_rel_map Computation.liftRel_mapₓ'. -/
theorem liftRel_map {δ} (R : α → β → Prop) (S : γ → δ → Prop) {s1 : Computation α}
{s2 : Computation β} {f1 : α → γ} {f2 : β → δ} (h1 : LiftRel R s1 s2)
(h2 : ∀ {a b}, R a b → S (f1 a) (f2 b)) : LiftRel S (map f1 s1) (map f2 s2) := by
rw [← bind_ret, ← bind_ret] <;> apply lift_rel_bind _ _ h1 <;> simp <;> exact @h2
#align computation.lift_rel_map Computation.liftRel_map
-/- warning: computation.map_congr -> Computation.map_congr is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}} {β : Type.{u2}}, (α -> α -> Prop) -> (β -> β -> Prop) -> (forall {s1 : Computation.{u1} α} {s2 : Computation.{u1} α} {f : α -> β}, (Computation.Equiv.{u1} α s1 s2) -> (Computation.Equiv.{u2} β (Computation.map.{u1, u2} α β f s1) (Computation.map.{u1, u2} α β f s2)))
-but is expected to have type
- forall {α : Type.{u1}} {β : Type.{u2}} {R : Computation.{u1} α} {S : Computation.{u1} α} {s1 : α -> β}, (Computation.Equiv.{u1} α R S) -> (Computation.Equiv.{u2} β (Computation.map.{u1, u2} α β s1 R) (Computation.map.{u1, u2} α β s1 S))
-Case conversion may be inaccurate. Consider using '#align computation.map_congr Computation.map_congrₓ'. -/
theorem map_congr (R : α → α → Prop) (S : β → β → Prop) {s1 s2 : Computation α} {f : α → β}
(h1 : s1 ~ s2) : map f s1 ~ map f s2 := by
rw [← lift_eq_iff_equiv] <;>
mathlib commit https://github.com/leanprover-community/mathlib/commit/917c3c072e487b3cccdbfeff17e75b40e45f66cb
@@ -52,10 +52,7 @@ instance : CoeTC α (Computation α) :=
/-- `think c` is the computation that delays for one "tick" and then performs
computation `c`. -/
def think (c : Computation α) : Computation α :=
- ⟨none::c.1, fun n a h => by
- cases' n with n
- contradiction
- exact c.2 h⟩
+ ⟨none::c.1, fun n a h => by cases' n with n; contradiction; exact c.2 h⟩
#align computation.think Computation.think
-/
@@ -132,11 +129,9 @@ theorem destruct_eq_pure {s : Computation α} {a : α} : destruct s = Sum.inl a
dsimp [destruct]
induction' f0 : s.1 0 with <;> intro h
· contradiction
- · apply Subtype.eq
- funext n
+ · apply Subtype.eq; funext n
induction' n with n IH
- · injection h with h'
- rwa [h'] at f0
+ · injection h with h'; rwa [h'] at f0
· exact s.2 IH
#align computation.destruct_eq_ret Computation.destruct_eq_pure
-/
@@ -146,13 +141,10 @@ theorem destruct_eq_think {s : Computation α} {s'} : destruct s = Sum.inr s'
by
dsimp [destruct]
induction' f0 : s.1 0 with a' <;> intro h
- · injection h with h'
- rw [← h']
+ · injection h with h'; rw [← h']
cases' s with f al
- apply Subtype.eq
- dsimp [think, tail]
- rw [← f0]
- exact (Stream'.eta f).symm
+ apply Subtype.eq; dsimp [think, tail]
+ rw [← f0]; exact (Stream'.eta f).symm
· contradiction
#align computation.destruct_eq_think Computation.destruct_eq_think
-/
@@ -232,11 +224,8 @@ def recOn {C : Computation α → Sort v} (s : Computation α) (h1 : ∀ a, C (p
(h2 : ∀ s, C (think s)) : C s :=
by
induction' H : destruct s with v v
- · rw [destruct_eq_ret H]
- apply h1
- · cases' v with a s'
- rw [destruct_eq_think H]
- apply h2
+ · rw [destruct_eq_ret H]; apply h1
+ · cases' v with a s'; rw [destruct_eq_think H]; apply h2
#align computation.rec_on Computation.recOn
-/
@@ -263,12 +252,9 @@ def corec (f : β → Sum α β) (b : β) : Computation α :=
revert h; generalize Sum.inr b = o; revert o
induction' n with n IH <;> intro o
· change (corec.F f o).1 = some a' → (corec.F f (corec.F f o).2).1 = some a'
- cases' o with a b <;> intro h
- · exact h
- dsimp [corec.F] at h
- dsimp [corec.F]
- cases' f b with a b'
- · exact h
+ cases' o with a b <;> intro h; · exact h
+ dsimp [corec.F] at h; dsimp [corec.F]
+ cases' f b with a b'; · exact h
· contradiction
· rw [Stream'.corec'_eq (corec.F f) (corec.F f o).2, Stream'.corec'_eq (corec.F f) o]
exact IH (corec.F f o).2
@@ -347,16 +333,12 @@ theorem eq_of_bisim (bisim : IsBisimulation R) {s₁ s₂} (r : s₁ ~ s₂) : s
And.imp id (fun r => ⟨tail s, tail s', by cases s <;> rfl, by cases s' <;> rfl, r⟩) this
have := bisim r; revert r this
apply rec_on s _ _ <;> intros <;> apply rec_on s' _ _ <;> intros <;> intro r this
- · constructor
- dsimp at this
- rw [this]
- assumption
+ · constructor; dsimp at this; rw [this]; assumption
· rw [destruct_ret, destruct_think] at this
exact False.elim this
· rw [destruct_ret, destruct_think] at this
exact False.elim this
- · simp at this
- simp [*]
+ · simp at this; simp [*]
exact ⟨s₁, s₂, rfl, rfl, r⟩
#align computation.eq_of_bisim Computation.eq_of_bisim
-/
@@ -375,11 +357,8 @@ instance : Membership α (Computation α) :=
⟨Computation.Mem⟩
#print Computation.le_stable /-
-theorem le_stable (s : Computation α) {a m n} (h : m ≤ n) : s.1 m = some a → s.1 n = some a :=
- by
- cases' s with f al
- induction' h with n h IH
- exacts[id, fun h2 => al (IH h2)]
+theorem le_stable (s : Computation α) {a m n} (h : m ≤ n) : s.1 m = some a → s.1 n = some a := by
+ cases' s with f al; induction' h with n h IH; exacts[id, fun h2 => al (IH h2)]
#align computation.le_stable Computation.le_stable
-/
@@ -418,12 +397,8 @@ theorem terminates_of_mem {s : Computation α} {a : α} (h : a ∈ s) : Terminat
#print Computation.terminates_def /-
theorem terminates_def (s : Computation α) : Terminates s ↔ ∃ n, (s.1 n).isSome :=
- ⟨fun ⟨⟨a, n, h⟩⟩ =>
- ⟨n, by
- dsimp [Stream'.nth] at h
- rw [← h]
- exact rfl⟩,
- fun ⟨n, h⟩ => ⟨⟨Option.get h, n, (Option.eq_some_of_isSome h).symm⟩⟩⟩
+ ⟨fun ⟨⟨a, n, h⟩⟩ => ⟨n, by dsimp [Stream'.nth] at h; rw [← h]; exact rfl⟩, fun ⟨n, h⟩ =>
+ ⟨⟨Option.get h, n, (Option.eq_some_of_isSome h).symm⟩⟩⟩
#align computation.terminates_def Computation.terminates_def
-/
@@ -459,10 +434,7 @@ instance think_terminates (s : Computation α) : ∀ [Terminates s], Terminates
#print Computation.of_think_mem /-
theorem of_think_mem {s : Computation α} {a} : a ∈ think s → a ∈ s
- | ⟨n, h⟩ => by
- cases' n with n'
- contradiction
- exact ⟨n', h⟩
+ | ⟨n, h⟩ => by cases' n with n'; contradiction; exact ⟨n', h⟩
#align computation.of_think_mem Computation.of_think_mem
-/
@@ -590,11 +562,7 @@ theorem get_promises : s ~> get s := fun a => get_eq_of_mem _
-/
#print Computation.mem_of_promises /-
-theorem mem_of_promises {a} (p : s ~> a) : a ∈ s :=
- by
- cases h
- cases' h with a' h
- rw [p h]
+theorem mem_of_promises {a} (p : s ~> a) : a ∈ s := by cases h; cases' h with a' h; rw [p h];
exact h
#align computation.mem_of_promises Computation.mem_of_promises
-/
@@ -697,9 +665,7 @@ theorem length_think (s : Computation α) [h : Terminates s] : length (think s)
Nat.find_spec ((terminates_def _).1 s.think_terminates)
cases' length (think s) with n
· contradiction
- · apply Nat.succ_le_succ
- apply Nat.find_min'
- apply this
+ · apply Nat.succ_le_succ; apply Nat.find_min'; apply this
#align computation.length_think Computation.length_think
-/
@@ -756,15 +722,10 @@ theorem eq_thinkN {s : Computation α} {a n} (h : Results s a n) : s = thinkN (p
by
revert s
induction' n with n IH <;> intro s <;> apply rec_on s (fun a' => _) fun s => _ <;> intro h
- · rw [← eq_of_ret_mem h.mem]
- rfl
- · cases' of_results_think h with n h
- cases h
- contradiction
- · have := h.len_unique (results_ret _)
- contradiction
- · rw [IH (results_think_iff.1 h)]
- rfl
+ · rw [← eq_of_ret_mem h.mem]; rfl
+ · cases' of_results_think h with n h; cases h; contradiction
+ · have := h.len_unique (results_ret _); contradiction
+ · rw [IH (results_think_iff.1 h)]; rfl
#align computation.eq_thinkN Computation.eq_thinkN
-/
@@ -965,14 +926,9 @@ theorem results_bind {s : Computation α} {f : α → Computation β} {a b m n}
by
have := h1.mem; revert m
apply mem_rec_on this _ fun s IH => _ <;> intro m h1
- · rw [ret_bind]
- rw [h1.len_unique (results_ret _)]
- exact h2
- · rw [think_bind]
- cases' of_results_think h1 with m' h
- cases' h with h1 e
- rw [e]
- exact results_think (IH h1)
+ · rw [ret_bind]; rw [h1.len_unique (results_ret _)]; exact h2
+ · rw [think_bind]; cases' of_results_think h1 with m' h; cases' h with h1 e
+ rw [e]; exact results_think (IH h1)
#align computation.results_bind Computation.results_bind
-/
@@ -1014,13 +970,10 @@ theorem of_results_bind {s : Computation α} {f : α → Computation β} {b k} :
Results (bind s f) b k → ∃ a m n, Results s a m ∧ Results (f a) b n ∧ k = n + m :=
by
induction' k with n IH generalizing s <;> apply rec_on s (fun a => _) fun s' => _ <;> intro e
- · simp [thinkN] at e
- refine' ⟨a, _, _, results_ret _, e, rfl⟩
- · have := congr_arg head (eq_thinkN e)
- contradiction
- · simp at e
- refine' ⟨a, _, n + 1, results_ret _, e, rfl⟩
- · simp at e
+ · simp [thinkN] at e; refine' ⟨a, _, _, results_ret _, e, rfl⟩
+ · have := congr_arg head (eq_thinkN e); contradiction
+ · simp at e; refine' ⟨a, _, n + 1, results_ret _, e, rfl⟩
+ · simp at e;
exact by
let ⟨a, m, n', h1, h2, e'⟩ := IH e
rw [e'] <;> exact ⟨a, m.succ, n', results_think h1, h2, rfl⟩
@@ -1591,11 +1544,8 @@ theorem LiftRelRec.lem {R : α → β → Prop} (C : Computation α → Computat
(H : ∀ {ca cb}, C ca cb → LiftRelAux R C (destruct ca) (destruct cb)) (ca cb) (Hc : C ca cb) (a)
(ha : a ∈ ca) : LiftRel R ca cb := by
revert cb; refine' mem_rec_on ha _ fun ca' IH => _ <;> intro cb Hc <;> have h := H Hc
- · simp at h
- simp [h]
- · have h := H Hc
- simp
- revert h
+ · simp at h; simp [h]
+ · have h := H Hc; simp; revert h;
apply cb.rec_on (fun b => _) fun cb' => _ <;> intro h <;> simp at h <;> simp [h]
exact IH _ h
#align computation.lift_rel_rec.lem Computation.LiftRelRec.lem
mathlib commit https://github.com/leanprover-community/mathlib/commit/95a87616d63b3cb49d3fe678d416fbe9c4217bf4
@@ -1148,7 +1148,7 @@ instance : Alternative Computation :=
lean 3 declaration is
forall {α : Type.{u1}} (a : α) (c₂ : Computation.{u1} α), Eq.{succ u1} (Computation.{u1} α) (HasOrelse.orelse.{u1, u1} Computation.{u1} (Alternative.toHasOrelse.{u1, u1} Computation.{u1} Computation.alternative.{u1}) α (Computation.pure.{u1} α a) c₂) (Computation.pure.{u1} α a)
but is expected to have type
- forall {α : Type.{u1}} (a : α) (c₂ : Computation.{u1} α), Eq.{succ u1} (Computation.{u1} α) (HOrElse.hOrElse.{u1, u1, u1} (Computation.{u1} α) (Computation.{u1} α) (Computation.{u1} α) (instHOrElse.{u1} (Computation.{u1} α) (instOrElse.{u1, u1} Computation.{u1} α Computation.instAlternativeComputation.{u1})) (Computation.pure.{u1} α a) (fun (x._@.Mathlib.Data.Seq.Computation._hyg.10321 : Unit) => c₂)) (Computation.pure.{u1} α a)
+ forall {α : Type.{u1}} (a : α) (c₂ : Computation.{u1} α), Eq.{succ u1} (Computation.{u1} α) (HOrElse.hOrElse.{u1, u1, u1} (Computation.{u1} α) (Computation.{u1} α) (Computation.{u1} α) (instHOrElse.{u1} (Computation.{u1} α) (instOrElse.{u1, u1} Computation.{u1} α Computation.instAlternativeComputation.{u1})) (Computation.pure.{u1} α a) (fun (x._@.Mathlib.Data.Seq.Computation._hyg.10396 : Unit) => c₂)) (Computation.pure.{u1} α a)
Case conversion may be inaccurate. Consider using '#align computation.ret_orelse Computation.ret_orElseₓ'. -/
@[simp]
theorem ret_orElse (a : α) (c₂ : Computation α) : (pure a <|> c₂) = pure a :=
@@ -1159,7 +1159,7 @@ theorem ret_orElse (a : α) (c₂ : Computation α) : (pure a <|> c₂) = pure a
lean 3 declaration is
forall {α : Type.{u1}} (c₁ : Computation.{u1} α) (a : α), Eq.{succ u1} (Computation.{u1} α) (HasOrelse.orelse.{u1, u1} Computation.{u1} (Alternative.toHasOrelse.{u1, u1} Computation.{u1} Computation.alternative.{u1}) α (Computation.think.{u1} α c₁) (Computation.pure.{u1} α a)) (Computation.pure.{u1} α a)
but is expected to have type
- forall {α : Type.{u1}} (c₁ : Computation.{u1} α) (a : α), Eq.{succ u1} (Computation.{u1} α) (HOrElse.hOrElse.{u1, u1, u1} (Computation.{u1} α) (Computation.{u1} α) (Computation.{u1} α) (instHOrElse.{u1} (Computation.{u1} α) (instOrElse.{u1, u1} Computation.{u1} α Computation.instAlternativeComputation.{u1})) (Computation.think.{u1} α c₁) (fun (x._@.Mathlib.Data.Seq.Computation._hyg.10349 : Unit) => Computation.pure.{u1} α a)) (Computation.pure.{u1} α a)
+ forall {α : Type.{u1}} (c₁ : Computation.{u1} α) (a : α), Eq.{succ u1} (Computation.{u1} α) (HOrElse.hOrElse.{u1, u1, u1} (Computation.{u1} α) (Computation.{u1} α) (Computation.{u1} α) (instHOrElse.{u1} (Computation.{u1} α) (instOrElse.{u1, u1} Computation.{u1} α Computation.instAlternativeComputation.{u1})) (Computation.think.{u1} α c₁) (fun (x._@.Mathlib.Data.Seq.Computation._hyg.10424 : Unit) => Computation.pure.{u1} α a)) (Computation.pure.{u1} α a)
Case conversion may be inaccurate. Consider using '#align computation.orelse_ret Computation.orelse_pureₓ'. -/
@[simp]
theorem orelse_pure (c₁ : Computation α) (a : α) : (think c₁ <|> pure a) = pure a :=
@@ -1170,7 +1170,7 @@ theorem orelse_pure (c₁ : Computation α) (a : α) : (think c₁ <|> pure a) =
lean 3 declaration is
forall {α : Type.{u1}} (c₁ : Computation.{u1} α) (c₂ : Computation.{u1} α), Eq.{succ u1} (Computation.{u1} α) (HasOrelse.orelse.{u1, u1} Computation.{u1} (Alternative.toHasOrelse.{u1, u1} Computation.{u1} Computation.alternative.{u1}) α (Computation.think.{u1} α c₁) (Computation.think.{u1} α c₂)) (Computation.think.{u1} α (HasOrelse.orelse.{u1, u1} Computation.{u1} (Alternative.toHasOrelse.{u1, u1} Computation.{u1} Computation.alternative.{u1}) α c₁ c₂))
but is expected to have type
- forall {α : Type.{u1}} (c₁ : Computation.{u1} α) (c₂ : Computation.{u1} α), Eq.{succ u1} (Computation.{u1} α) (HOrElse.hOrElse.{u1, u1, u1} (Computation.{u1} α) (Computation.{u1} α) (Computation.{u1} α) (instHOrElse.{u1} (Computation.{u1} α) (instOrElse.{u1, u1} Computation.{u1} α Computation.instAlternativeComputation.{u1})) (Computation.think.{u1} α c₁) (fun (x._@.Mathlib.Data.Seq.Computation._hyg.10385 : Unit) => Computation.think.{u1} α c₂)) (Computation.think.{u1} α (HOrElse.hOrElse.{u1, u1, u1} (Computation.{u1} α) (Computation.{u1} α) (Computation.{u1} α) (instHOrElse.{u1} (Computation.{u1} α) (instOrElse.{u1, u1} Computation.{u1} α Computation.instAlternativeComputation.{u1})) c₁ (fun (x._@.Mathlib.Data.Seq.Computation._hyg.10384 : Unit) => c₂)))
+ forall {α : Type.{u1}} (c₁ : Computation.{u1} α) (c₂ : Computation.{u1} α), Eq.{succ u1} (Computation.{u1} α) (HOrElse.hOrElse.{u1, u1, u1} (Computation.{u1} α) (Computation.{u1} α) (Computation.{u1} α) (instHOrElse.{u1} (Computation.{u1} α) (instOrElse.{u1, u1} Computation.{u1} α Computation.instAlternativeComputation.{u1})) (Computation.think.{u1} α c₁) (fun (x._@.Mathlib.Data.Seq.Computation._hyg.10460 : Unit) => Computation.think.{u1} α c₂)) (Computation.think.{u1} α (HOrElse.hOrElse.{u1, u1, u1} (Computation.{u1} α) (Computation.{u1} α) (Computation.{u1} α) (instHOrElse.{u1} (Computation.{u1} α) (instOrElse.{u1, u1} Computation.{u1} α Computation.instAlternativeComputation.{u1})) c₁ (fun (x._@.Mathlib.Data.Seq.Computation._hyg.10459 : Unit) => c₂)))
Case conversion may be inaccurate. Consider using '#align computation.orelse_think Computation.orelse_thinkₓ'. -/
@[simp]
theorem orelse_think (c₁ c₂ : Computation α) : (think c₁ <|> think c₂) = think (c₁ <|> c₂) :=
@@ -1181,7 +1181,7 @@ theorem orelse_think (c₁ c₂ : Computation α) : (think c₁ <|> think c₂)
lean 3 declaration is
forall {α : Type.{u1}} (c : Computation.{u1} α), Eq.{succ u1} (Computation.{u1} α) (HasOrelse.orelse.{u1, u1} Computation.{u1} (Alternative.toHasOrelse.{u1, u1} Computation.{u1} Computation.alternative.{u1}) α (Computation.empty.{u1} α) c) c
but is expected to have type
- forall {α : Type.{u1}} (c : Computation.{u1} α), Eq.{succ u1} (Computation.{u1} α) (HOrElse.hOrElse.{u1, u1, u1} (Computation.{u1} α) (Computation.{u1} α) (Computation.{u1} α) (instHOrElse.{u1} (Computation.{u1} α) (instOrElse.{u1, u1} Computation.{u1} α Computation.instAlternativeComputation.{u1})) (Computation.empty.{u1} α) (fun (x._@.Mathlib.Data.Seq.Computation._hyg.10409 : Unit) => c)) c
+ forall {α : Type.{u1}} (c : Computation.{u1} α), Eq.{succ u1} (Computation.{u1} α) (HOrElse.hOrElse.{u1, u1, u1} (Computation.{u1} α) (Computation.{u1} α) (Computation.{u1} α) (instHOrElse.{u1} (Computation.{u1} α) (instOrElse.{u1, u1} Computation.{u1} α Computation.instAlternativeComputation.{u1})) (Computation.empty.{u1} α) (fun (x._@.Mathlib.Data.Seq.Computation._hyg.10484 : Unit) => c)) c
Case conversion may be inaccurate. Consider using '#align computation.empty_orelse Computation.empty_orelseₓ'. -/
@[simp]
theorem empty_orelse (c) : (empty α <|> c) = c :=
@@ -1196,7 +1196,7 @@ theorem empty_orelse (c) : (empty α <|> c) = c :=
lean 3 declaration is
forall {α : Type.{u1}} (c : Computation.{u1} α), Eq.{succ u1} (Computation.{u1} α) (HasOrelse.orelse.{u1, u1} Computation.{u1} (Alternative.toHasOrelse.{u1, u1} Computation.{u1} Computation.alternative.{u1}) α c (Computation.empty.{u1} α)) c
but is expected to have type
- forall {α : Type.{u1}} (c : Computation.{u1} α), Eq.{succ u1} (Computation.{u1} α) (HOrElse.hOrElse.{u1, u1, u1} (Computation.{u1} α) (Computation.{u1} α) (Computation.{u1} α) (instHOrElse.{u1} (Computation.{u1} α) (instOrElse.{u1, u1} Computation.{u1} α Computation.instAlternativeComputation.{u1})) c (fun (x._@.Mathlib.Data.Seq.Computation._hyg.10607 : Unit) => Computation.empty.{u1} α)) c
+ forall {α : Type.{u1}} (c : Computation.{u1} α), Eq.{succ u1} (Computation.{u1} α) (HOrElse.hOrElse.{u1, u1, u1} (Computation.{u1} α) (Computation.{u1} α) (Computation.{u1} α) (instHOrElse.{u1} (Computation.{u1} α) (instOrElse.{u1, u1} Computation.{u1} α Computation.instAlternativeComputation.{u1})) c (fun (x._@.Mathlib.Data.Seq.Computation._hyg.10682 : Unit) => Computation.empty.{u1} α)) c
Case conversion may be inaccurate. Consider using '#align computation.orelse_empty Computation.orelse_emptyₓ'. -/
@[simp]
theorem orelse_empty (c : Computation α) : (c <|> empty α) = c :=
mathlib commit https://github.com/leanprover-community/mathlib/commit/f8c79b0a623404854a2902b836eac32156fd7712
@@ -1148,7 +1148,7 @@ instance : Alternative Computation :=
lean 3 declaration is
forall {α : Type.{u1}} (a : α) (c₂ : Computation.{u1} α), Eq.{succ u1} (Computation.{u1} α) (HasOrelse.orelse.{u1, u1} Computation.{u1} (Alternative.toHasOrelse.{u1, u1} Computation.{u1} Computation.alternative.{u1}) α (Computation.pure.{u1} α a) c₂) (Computation.pure.{u1} α a)
but is expected to have type
- forall {α : Type.{u1}} (a : α) (c₂ : Computation.{u1} α), Eq.{succ u1} (Computation.{u1} α) (HOrElse.hOrElse.{u1, u1, u1} (Computation.{u1} α) (Computation.{u1} α) (Computation.{u1} α) (instHOrElse.{u1} (Computation.{u1} α) (instOrElse.{u1, u1} Computation.{u1} α Computation.instAlternativeComputation.{u1})) (Computation.pure.{u1} α a) (fun (x._@.Mathlib.Data.Seq.Computation._hyg.10376 : Unit) => c₂)) (Computation.pure.{u1} α a)
+ forall {α : Type.{u1}} (a : α) (c₂ : Computation.{u1} α), Eq.{succ u1} (Computation.{u1} α) (HOrElse.hOrElse.{u1, u1, u1} (Computation.{u1} α) (Computation.{u1} α) (Computation.{u1} α) (instHOrElse.{u1} (Computation.{u1} α) (instOrElse.{u1, u1} Computation.{u1} α Computation.instAlternativeComputation.{u1})) (Computation.pure.{u1} α a) (fun (x._@.Mathlib.Data.Seq.Computation._hyg.10321 : Unit) => c₂)) (Computation.pure.{u1} α a)
Case conversion may be inaccurate. Consider using '#align computation.ret_orelse Computation.ret_orElseₓ'. -/
@[simp]
theorem ret_orElse (a : α) (c₂ : Computation α) : (pure a <|> c₂) = pure a :=
@@ -1159,7 +1159,7 @@ theorem ret_orElse (a : α) (c₂ : Computation α) : (pure a <|> c₂) = pure a
lean 3 declaration is
forall {α : Type.{u1}} (c₁ : Computation.{u1} α) (a : α), Eq.{succ u1} (Computation.{u1} α) (HasOrelse.orelse.{u1, u1} Computation.{u1} (Alternative.toHasOrelse.{u1, u1} Computation.{u1} Computation.alternative.{u1}) α (Computation.think.{u1} α c₁) (Computation.pure.{u1} α a)) (Computation.pure.{u1} α a)
but is expected to have type
- forall {α : Type.{u1}} (c₁ : Computation.{u1} α) (a : α), Eq.{succ u1} (Computation.{u1} α) (HOrElse.hOrElse.{u1, u1, u1} (Computation.{u1} α) (Computation.{u1} α) (Computation.{u1} α) (instHOrElse.{u1} (Computation.{u1} α) (instOrElse.{u1, u1} Computation.{u1} α Computation.instAlternativeComputation.{u1})) (Computation.think.{u1} α c₁) (fun (x._@.Mathlib.Data.Seq.Computation._hyg.10404 : Unit) => Computation.pure.{u1} α a)) (Computation.pure.{u1} α a)
+ forall {α : Type.{u1}} (c₁ : Computation.{u1} α) (a : α), Eq.{succ u1} (Computation.{u1} α) (HOrElse.hOrElse.{u1, u1, u1} (Computation.{u1} α) (Computation.{u1} α) (Computation.{u1} α) (instHOrElse.{u1} (Computation.{u1} α) (instOrElse.{u1, u1} Computation.{u1} α Computation.instAlternativeComputation.{u1})) (Computation.think.{u1} α c₁) (fun (x._@.Mathlib.Data.Seq.Computation._hyg.10349 : Unit) => Computation.pure.{u1} α a)) (Computation.pure.{u1} α a)
Case conversion may be inaccurate. Consider using '#align computation.orelse_ret Computation.orelse_pureₓ'. -/
@[simp]
theorem orelse_pure (c₁ : Computation α) (a : α) : (think c₁ <|> pure a) = pure a :=
@@ -1170,7 +1170,7 @@ theorem orelse_pure (c₁ : Computation α) (a : α) : (think c₁ <|> pure a) =
lean 3 declaration is
forall {α : Type.{u1}} (c₁ : Computation.{u1} α) (c₂ : Computation.{u1} α), Eq.{succ u1} (Computation.{u1} α) (HasOrelse.orelse.{u1, u1} Computation.{u1} (Alternative.toHasOrelse.{u1, u1} Computation.{u1} Computation.alternative.{u1}) α (Computation.think.{u1} α c₁) (Computation.think.{u1} α c₂)) (Computation.think.{u1} α (HasOrelse.orelse.{u1, u1} Computation.{u1} (Alternative.toHasOrelse.{u1, u1} Computation.{u1} Computation.alternative.{u1}) α c₁ c₂))
but is expected to have type
- forall {α : Type.{u1}} (c₁ : Computation.{u1} α) (c₂ : Computation.{u1} α), Eq.{succ u1} (Computation.{u1} α) (HOrElse.hOrElse.{u1, u1, u1} (Computation.{u1} α) (Computation.{u1} α) (Computation.{u1} α) (instHOrElse.{u1} (Computation.{u1} α) (instOrElse.{u1, u1} Computation.{u1} α Computation.instAlternativeComputation.{u1})) (Computation.think.{u1} α c₁) (fun (x._@.Mathlib.Data.Seq.Computation._hyg.10440 : Unit) => Computation.think.{u1} α c₂)) (Computation.think.{u1} α (HOrElse.hOrElse.{u1, u1, u1} (Computation.{u1} α) (Computation.{u1} α) (Computation.{u1} α) (instHOrElse.{u1} (Computation.{u1} α) (instOrElse.{u1, u1} Computation.{u1} α Computation.instAlternativeComputation.{u1})) c₁ (fun (x._@.Mathlib.Data.Seq.Computation._hyg.10439 : Unit) => c₂)))
+ forall {α : Type.{u1}} (c₁ : Computation.{u1} α) (c₂ : Computation.{u1} α), Eq.{succ u1} (Computation.{u1} α) (HOrElse.hOrElse.{u1, u1, u1} (Computation.{u1} α) (Computation.{u1} α) (Computation.{u1} α) (instHOrElse.{u1} (Computation.{u1} α) (instOrElse.{u1, u1} Computation.{u1} α Computation.instAlternativeComputation.{u1})) (Computation.think.{u1} α c₁) (fun (x._@.Mathlib.Data.Seq.Computation._hyg.10385 : Unit) => Computation.think.{u1} α c₂)) (Computation.think.{u1} α (HOrElse.hOrElse.{u1, u1, u1} (Computation.{u1} α) (Computation.{u1} α) (Computation.{u1} α) (instHOrElse.{u1} (Computation.{u1} α) (instOrElse.{u1, u1} Computation.{u1} α Computation.instAlternativeComputation.{u1})) c₁ (fun (x._@.Mathlib.Data.Seq.Computation._hyg.10384 : Unit) => c₂)))
Case conversion may be inaccurate. Consider using '#align computation.orelse_think Computation.orelse_thinkₓ'. -/
@[simp]
theorem orelse_think (c₁ c₂ : Computation α) : (think c₁ <|> think c₂) = think (c₁ <|> c₂) :=
@@ -1181,7 +1181,7 @@ theorem orelse_think (c₁ c₂ : Computation α) : (think c₁ <|> think c₂)
lean 3 declaration is
forall {α : Type.{u1}} (c : Computation.{u1} α), Eq.{succ u1} (Computation.{u1} α) (HasOrelse.orelse.{u1, u1} Computation.{u1} (Alternative.toHasOrelse.{u1, u1} Computation.{u1} Computation.alternative.{u1}) α (Computation.empty.{u1} α) c) c
but is expected to have type
- forall {α : Type.{u1}} (c : Computation.{u1} α), Eq.{succ u1} (Computation.{u1} α) (HOrElse.hOrElse.{u1, u1, u1} (Computation.{u1} α) (Computation.{u1} α) (Computation.{u1} α) (instHOrElse.{u1} (Computation.{u1} α) (instOrElse.{u1, u1} Computation.{u1} α Computation.instAlternativeComputation.{u1})) (Computation.empty.{u1} α) (fun (x._@.Mathlib.Data.Seq.Computation._hyg.10464 : Unit) => c)) c
+ forall {α : Type.{u1}} (c : Computation.{u1} α), Eq.{succ u1} (Computation.{u1} α) (HOrElse.hOrElse.{u1, u1, u1} (Computation.{u1} α) (Computation.{u1} α) (Computation.{u1} α) (instHOrElse.{u1} (Computation.{u1} α) (instOrElse.{u1, u1} Computation.{u1} α Computation.instAlternativeComputation.{u1})) (Computation.empty.{u1} α) (fun (x._@.Mathlib.Data.Seq.Computation._hyg.10409 : Unit) => c)) c
Case conversion may be inaccurate. Consider using '#align computation.empty_orelse Computation.empty_orelseₓ'. -/
@[simp]
theorem empty_orelse (c) : (empty α <|> c) = c :=
@@ -1196,7 +1196,7 @@ theorem empty_orelse (c) : (empty α <|> c) = c :=
lean 3 declaration is
forall {α : Type.{u1}} (c : Computation.{u1} α), Eq.{succ u1} (Computation.{u1} α) (HasOrelse.orelse.{u1, u1} Computation.{u1} (Alternative.toHasOrelse.{u1, u1} Computation.{u1} Computation.alternative.{u1}) α c (Computation.empty.{u1} α)) c
but is expected to have type
- forall {α : Type.{u1}} (c : Computation.{u1} α), Eq.{succ u1} (Computation.{u1} α) (HOrElse.hOrElse.{u1, u1, u1} (Computation.{u1} α) (Computation.{u1} α) (Computation.{u1} α) (instHOrElse.{u1} (Computation.{u1} α) (instOrElse.{u1, u1} Computation.{u1} α Computation.instAlternativeComputation.{u1})) c (fun (x._@.Mathlib.Data.Seq.Computation._hyg.10662 : Unit) => Computation.empty.{u1} α)) c
+ forall {α : Type.{u1}} (c : Computation.{u1} α), Eq.{succ u1} (Computation.{u1} α) (HOrElse.hOrElse.{u1, u1, u1} (Computation.{u1} α) (Computation.{u1} α) (Computation.{u1} α) (instHOrElse.{u1} (Computation.{u1} α) (instOrElse.{u1, u1} Computation.{u1} α Computation.instAlternativeComputation.{u1})) c (fun (x._@.Mathlib.Data.Seq.Computation._hyg.10607 : Unit) => Computation.empty.{u1} α)) c
Case conversion may be inaccurate. Consider using '#align computation.orelse_empty Computation.orelse_emptyₓ'. -/
@[simp]
theorem orelse_empty (c : Computation α) : (c <|> empty α) = c :=
mathlib commit https://github.com/leanprover-community/mathlib/commit/bd9851ca476957ea4549eb19b40e7b5ade9428cc
@@ -17,9 +17,6 @@ This file provides a `Computation` type where `Computation α` is the type of
unbounded computations returning `α`.
-/
-set_option autoImplicit true
-
-
open Function
universe u v w
@@ -1234,14 +1231,17 @@ def LiftRelAux (R : α → β → Prop) (C : Computation α → Computation β
| Sum.inr ca, Sum.inr cb => C ca cb
#align computation.lift_rel_aux Computation.LiftRelAux
+variable {R : α → β → Prop} {C : Computation α → Computation β → Prop}
+
-- Porting note: was attribute [simp] LiftRelAux
-- but right now `simp` on defs is a Lean 4 catastrophe
-- Instead we add the equation lemmas and tag them @[simp]
-@[simp] lemma liftRelAux_inl_inl : LiftRelAux R C (Sum.inl a) (Sum.inl b) = R a b := rfl
-@[simp] lemma liftRelAux_inl_inr {cb} :
+@[simp] lemma liftRelAux_inl_inl {a : α} {b : β} :
+ LiftRelAux R C (Sum.inl a) (Sum.inl b) = R a b := rfl
+@[simp] lemma liftRelAux_inl_inr {a : α} {cb} :
LiftRelAux R C (Sum.inl a) (Sum.inr cb) = ∃ b, b ∈ cb ∧ R a b :=
rfl
-@[simp] lemma liftRelAux_inr_inl {ca} :
+@[simp] lemma liftRelAux_inr_inl {b : β} {ca} :
LiftRelAux R C (Sum.inr ca) (Sum.inl b) = ∃ a, a ∈ ca ∧ R a b :=
rfl
@[simp] lemma liftRelAux_inr_inr {ca cb} :
@@ -750,7 +750,7 @@ theorem bind_pure (f : α → β) (s) : bind s (pure ∘ f) = map f s := by
-- Porting note: used to use `rw [bind_pure]`
@[simp]
theorem bind_pure' (s : Computation α) : bind s pure = s := by
- apply eq_of_bisim fun c₁ c₂ => c₁ = c₂ ∨ ∃ s, c₁ = bind s (pure) ∧ c₂ = s
+ apply eq_of_bisim fun c₁ c₂ => c₁ = c₂ ∨ ∃ s, c₁ = bind s pure ∧ c₂ = s
· intro c₁ c₂ h
match c₁, c₂, h with
| _, c₂, Or.inl (Eq.refl _) => cases' destruct c₂ with b cb <;> simp
@@ -271,7 +271,6 @@ section Bisim
variable (R : Computation α → Computation α → Prop)
--- mathport name: «expr ~ »
/-- bisimilarity relation-/
local infixl:50 " ~ " => R
@@ -430,7 +429,6 @@ def Promises (s : Computation α) (a : α) : Prop :=
∀ ⦃a'⦄, a' ∈ s → a = a'
#align computation.promises Computation.Promises
--- mathport name: «expr ~> »
/-- `Promises s a`, or `s ~> a`, asserts that although the computation `s`
may not terminate, if it does, then the result is `a`. -/
scoped infixl:50 " ~> " => Promises
@@ -969,7 +967,6 @@ def Equiv (c₁ c₂ : Computation α) : Prop :=
∀ a, a ∈ c₁ ↔ a ∈ c₂
#align computation.equiv Computation.Equiv
--- mathport name: «expr ~ »
/-- equivalence relation for computations-/
scoped infixl:50 " ~ " => Equiv
λ
by fun
(#11301)
Per the style guidelines, λ
is disallowed in mathlib.
This is close to exhaustive; I left some tactic code alone when it seemed to me that tactic could be upstreamed soon.
Notes
=>
to ↦
.Mathlib/Order/SupClosed
.λ x,
, which I also replaced.@@ -253,7 +253,7 @@ attribute [simp] lmap rmap
theorem corec_eq (f : β → Sum α β) (b : β) : destruct (corec f b) = rmap (corec f) (f b) := by
dsimp [corec, destruct]
rw [show Stream'.corec' (Corec.f f) (Sum.inr b) 0 =
- Sum.rec Option.some (λ _ => none) (f b) by
+ Sum.rec Option.some (fun _ ↦ none) (f b) by
dsimp [Corec.f, Stream'.corec', Stream'.corec, Stream'.map, Stream'.get, Stream'.iterate]
match (f b) with
| Sum.inl x => rfl
@@ -1278,8 +1278,8 @@ theorem LiftRelRec.lem {R : α → β → Prop} (C : Computation α → Computat
(H : ∀ {ca cb}, C ca cb → LiftRelAux R C (destruct ca) (destruct cb)) (ca cb) (Hc : C ca cb) (a)
(ha : a ∈ ca) : LiftRel R ca cb := by
revert cb
- refine' memRecOn (C := (λ ca => ∀ (cb : Computation β), C ca cb → LiftRel R ca cb))
- ha _ (fun ca' IH => _) <;> intro cb Hc <;> have h := H Hc
+ refine memRecOn (C := (fun ca ↦ ∀ (cb : Computation β), C ca cb → LiftRel R ca cb))
+ ha ?_ (fun ca' IH => ?_) <;> intro cb Hc <;> have h := H Hc
· simp only [destruct_pure, LiftRelAux.ret_left] at h
simp [h]
· simp only [liftRel_think_left]
@@ -310,8 +310,7 @@ theorem eq_of_bisim (bisim : IsBisimulation R) {s₁ s₂} (r : s₁ ~ s₂) : s
exact False.elim h
· rw [destruct_pure, destruct_think] at h
exact False.elim h
- · simp at h
- simp [*]
+ · simp_all
· exact ⟨s₁, s₂, rfl, rfl, r⟩
#align computation.eq_of_bisim Computation.eq_of_bisim
@@ -705,7 +704,7 @@ theorem destruct_map (f : α → β) (s) : destruct (map f s) = lmap f (rmap (ma
@[simp]
theorem map_id : ∀ s : Computation α, map id s = s
| ⟨f, al⟩ => by
- apply Subtype.eq; simp [map, Function.comp]
+ apply Subtype.eq; simp only [map, comp_apply, id_eq]
have e : @Option.rec α (fun _ => Option α) none some = id := by ext ⟨⟩ <;> rfl
have h : ((fun x: Option α => x) = id) := rfl
simp [e, h, Stream'.map_id]
Homogenises porting notes via capitalisation and addition of whitespace.
It makes the following changes:
@@ -244,7 +244,7 @@ def rmap (f : β → γ) : Sum α β → Sum α γ
attribute [simp] lmap rmap
--- porting note: this was far less painful in mathlib3. There seem to be two issues;
+-- Porting note: this was far less painful in mathlib3. There seem to be two issues;
-- firstly, in mathlib3 we have `corec.F._match_1` and it's the obvious map α ⊕ β → option α.
-- In mathlib4 we have `Corec.f.match_1` and it's something completely different.
-- Secondly, the proof that `Stream'.corec' (Corec.f f) (Sum.inr b) 0` is this function
@@ -1238,7 +1238,8 @@ def LiftRelAux (R : α → β → Prop) (C : Computation α → Computation β
| Sum.inr ca, Sum.inr cb => C ca cb
#align computation.lift_rel_aux Computation.LiftRelAux
---porting note: was attribute [simp] LiftRelAux but right now `simp` on defs is a Lean 4 catastrophe
+-- Porting note: was attribute [simp] LiftRelAux
+-- but right now `simp` on defs is a Lean 4 catastrophe
-- Instead we add the equation lemmas and tag them @[simp]
@[simp] lemma liftRelAux_inl_inl : LiftRelAux R C (Sum.inl a) (Sum.inl b) = R a b := rfl
@[simp] lemma liftRelAux_inl_inr {cb} :
refine
s (#10762)
I replaced a few "terminal" refine/refine'
s with exact
.
The strategy was very simple-minded: essentially any refine
whose following line had smaller indentation got replaced by exact
and then I cleaned up the mess.
This PR certainly leaves some further terminal refine
s, but maybe the current change is beneficial.
@@ -825,11 +825,11 @@ theorem of_results_bind {s : Computation α} {f : α → Computation β} {b k} :
Results (bind s f) b k → ∃ a m n, Results s a m ∧ Results (f a) b n ∧ k = n + m := by
induction' k with n IH generalizing s <;> apply recOn s (fun a => _) fun s' => _ <;> intro e h
· simp only [ret_bind, Nat.zero_eq] at h
- refine' ⟨e, _, _, results_pure _, h, rfl⟩
+ exact ⟨e, _, _, results_pure _, h, rfl⟩
· have := congr_arg head (eq_thinkN h)
contradiction
· simp only [ret_bind] at h
- refine' ⟨e, _, n + 1, results_pure _, h, rfl⟩
+ exact ⟨e, _, n + 1, results_pure _, h, rfl⟩
· simp only [think_bind, results_think_iff] at h
let ⟨a, m, n', h1, h2, e'⟩ := IH h
rw [e']
@@ -42,7 +42,7 @@ variable {α : Type u} {β : Type v} {γ : Type w}
-- constructors
/-- `pure a` is the computation that immediately terminates with result `a`. -/
--- porting notes: `return` is reserved, so changed to `pure`
+-- Porting note: `return` is reserved, so changed to `pure`
def pure (a : α) : Computation α :=
⟨Stream'.const (some a), fun _ _ => id⟩
#align computation.return Computation.pure
@@ -750,7 +750,7 @@ theorem bind_pure (f : α → β) (s) : bind s (pure ∘ f) = map f s := by
· exact Or.inr ⟨s, rfl, rfl⟩
#align computation.bind_ret Computation.bind_pure
--- porting notes: used to use `rw [bind_pure]`
+-- Porting note: used to use `rw [bind_pure]`
@[simp]
theorem bind_pure' (s : Computation α) : bind s pure = s := by
apply eq_of_bisim fun c₁ c₂ => c₁ = c₂ ∨ ∃ s, c₁ = bind s (pure) ∧ c₂ = s
@@ -1175,7 +1175,7 @@ theorem liftRel_pure_right (R : α → β → Prop) (ca : Computation α) (b :
LiftRel R ca (pure b) ↔ ∃ a, a ∈ ca ∧ R a b := by rw [LiftRel.swap, liftRel_pure_left]
#align computation.lift_rel_return_right Computation.liftRel_pure_right
--- porting notes: `simpNF` wants to simplify based on `liftRel_pure_right` but point is to prove
+-- Porting note: `simpNF` wants to simplify based on `liftRel_pure_right` but point is to prove
-- a general invariant on `LiftRel`
@[simp, nolint simpNF]
theorem liftRel_pure (R : α → β → Prop) (a : α) (b : β) :
@@ -1222,7 +1222,7 @@ theorem liftRel_map {δ} (R : α → β → Prop) (S : γ → δ → Prop) {s1 :
intros a b h; exact ⟨f1 a, ⟨ret_mem _, @h2 a b h⟩⟩
#align computation.lift_rel_map Computation.liftRel_map
--- porting notes: deleted initial arguments `(_R : α → α → Prop) (_S : β → β → Prop)`: unused
+-- Porting note: deleted initial arguments `(_R : α → α → Prop) (_S : β → β → Prop)`: unused
theorem map_congr {s1 s2 : Computation α} {f : α → β}
(h1 : s1 ~ s2) : map f s1 ~ map f s2 := by
rw [← lift_eq_iff_equiv]
Stream'.nth
to Stream'.get
(#7514)
Many of nth
(e.g. list.nth
, stream.seq.nth
) are renamed to get?
in Mathlib 4, but Stream'.nth
had been remained as it.
@@ -254,7 +254,7 @@ theorem corec_eq (f : β → Sum α β) (b : β) : destruct (corec f b) = rmap (
dsimp [corec, destruct]
rw [show Stream'.corec' (Corec.f f) (Sum.inr b) 0 =
Sum.rec Option.some (λ _ => none) (f b) by
- dsimp [Corec.f, Stream'.corec', Stream'.corec, Stream'.map, Stream'.nth, Stream'.iterate]
+ dsimp [Corec.f, Stream'.corec', Stream'.corec, Stream'.map, Stream'.get, Stream'.iterate]
match (f b) with
| Sum.inl x => rfl
| Sum.inr x => rfl
@@ -360,7 +360,7 @@ theorem terminates_of_mem {s : Computation α} {a : α} (h : a ∈ s) : Terminat
theorem terminates_def (s : Computation α) : Terminates s ↔ ∃ n, (s.1 n).isSome :=
⟨fun ⟨⟨a, n, h⟩⟩ =>
⟨n, by
- dsimp [Stream'.nth] at h
+ dsimp [Stream'.get] at h
rw [← h]
exact rfl⟩,
fun ⟨n, h⟩ => ⟨⟨Option.get _ h, n, (Option.eq_some_of_isSome h).symm⟩⟩⟩
@@ -646,7 +646,7 @@ def terminatesRecOn
def map (f : α → β) : Computation α → Computation β
| ⟨s, al⟩ =>
⟨s.map fun o => Option.casesOn o none (some ∘ f), fun n b => by
- dsimp [Stream'.map, Stream'.nth]
+ dsimp [Stream'.map, Stream'.get]
induction' e : s n with a <;> intro h
· contradiction
· rw [al e]; exact h⟩
Removes nonterminal simps on lines looking like simp [...]
@@ -725,10 +725,10 @@ theorem ret_bind (a) (f : α → Computation β) : bind (pure a) f = f a := by
· intro c₁ c₂ h
match c₁, c₂, h with
| _, _, Or.inl ⟨rfl, rfl⟩ =>
- simp [bind, Bind.f]
+ simp only [BisimO, bind, Bind.f, corec_eq, rmap, destruct_pure]
cases' destruct (f a) with b cb <;> simp [Bind.g]
| _, c, Or.inr rfl =>
- simp [Bind.f]
+ simp only [BisimO, Bind.f, corec_eq, rmap]
cases' destruct c with b cb <;> simp [Bind.g]
· simp
#align computation.ret_bind Computation.ret_bind
@@ -1076,12 +1076,12 @@ theorem LiftRel.trans (R : α → α → Prop) (H : Transitive R) : Transitive (
#align computation.lift_rel.trans Computation.LiftRel.trans
theorem LiftRel.equiv (R : α → α → Prop) : Equivalence R → Equivalence (LiftRel R)
- -- Porting note: The code below was:
+ | ⟨refl, symm, trans⟩ => ⟨LiftRel.refl R refl, by apply LiftRel.symm; apply symm,
+ by apply LiftRel.trans; apply trans⟩
+ -- Porting note: The code above was:
-- | ⟨refl, symm, trans⟩ => ⟨LiftRel.refl R refl, LiftRel.symm R symm, LiftRel.trans R trans⟩
--
-- The code fails to identify `symm` as being symmetric.
- | ⟨refl, symm, trans⟩ => ⟨LiftRel.refl R refl, by apply LiftRel.symm; apply symm,
- by apply LiftRel.trans; apply trans⟩
#align computation.lift_rel.equiv Computation.LiftRel.equiv
theorem LiftRel.imp {R S : α → β → Prop} (H : ∀ {a b}, R a b → S a b) (s t) :
@@ -92,7 +92,7 @@ def empty (α) : Computation α :=
instance : Inhabited (Computation α) :=
⟨empty _⟩
-/-- `run_for c n` evaluates `c` for `n` steps and returns the result, or `none`
+/-- `runFor c n` evaluates `c` for `n` steps and returns the result, or `none`
if it did not terminate after `n` steps. -/
def runFor : Computation α → ℕ → Option α :=
Subtype.val
@@ -192,14 +192,14 @@ theorem think_empty : empty α = think (empty α) :=
/-- Recursion principle for computations, compare with `List.recOn`. -/
def recOn {C : Computation α → Sort v} (s : Computation α) (h1 : ∀ a, C (pure a))
(h2 : ∀ s, C (think s)) : C s :=
- match H: (destruct s) with
- | Sum.inl v => by
- rw [destruct_eq_pure H]
- apply h1
- | Sum.inr v => match v with
- | ⟨a, s'⟩ => by
- rw [destruct_eq_think H]
- apply h2
+ match H : destruct s with
+ | Sum.inl v => by
+ rw [destruct_eq_pure H]
+ apply h1
+ | Sum.inr v => match v with
+ | ⟨a, s'⟩ => by
+ rw [destruct_eq_think H]
+ apply h2
#align computation.rec_on Computation.recOn
/-- Corecursor constructor for `corec`-/
@@ -293,11 +293,10 @@ def IsBisimulation :=
theorem eq_of_bisim (bisim : IsBisimulation R) {s₁ s₂} (r : s₁ ~ s₂) : s₁ = s₂ := by
apply Subtype.eq
apply Stream'.eq_of_bisim fun x y => ∃ s s' : Computation α, s.1 = x ∧ s'.1 = y ∧ R s s'
- dsimp [Stream'.IsBisimulation]
- intro t₁ t₂ e
- exact
+ · dsimp [Stream'.IsBisimulation]
+ intro t₁ t₂ e
match t₁, t₂, e with
- | _, _, ⟨s, s', rfl, rfl, r⟩ => by
+ | _, _, ⟨s, s', rfl, rfl, r⟩ =>
suffices head s = head s' ∧ R (tail s) (tail s') from
And.imp id (fun r => ⟨tail s, tail s', by cases s; rfl, by cases s'; rfl, r⟩) this
have h := bisim r; revert r h
@@ -313,7 +312,7 @@ theorem eq_of_bisim (bisim : IsBisimulation R) {s₁ s₂} (r : s₁ ~ s₂) : s
exact False.elim h
· simp at h
simp [*]
- exact ⟨s₁, s₂, rfl, rfl, r⟩
+ · exact ⟨s₁, s₂, rfl, rfl, r⟩
#align computation.eq_of_bisim Computation.eq_of_bisim
end Bisim
@@ -390,8 +389,8 @@ instance think_terminates (s : Computation α) : ∀ [Terminates s], Terminates
theorem of_think_mem {s : Computation α} {a} : a ∈ think s → a ∈ s
| ⟨n, h⟩ => by
cases' n with n'
- contradiction
- exact ⟨n', h⟩
+ · contradiction
+ · exact ⟨n', h⟩
#align computation.of_think_mem Computation.of_think_mem
theorem of_think_terminates {s : Computation α} : Terminates (think s) → Terminates s
@@ -447,9 +446,6 @@ section get
variable (s : Computation α) [h : Terminates s]
--- porting notes: no include?
---include s h
-
/-- `length s` gets the number of steps of a terminating computation -/
def length : ℕ :=
Nat.find ((terminates_def _).1 h)
@@ -727,14 +723,13 @@ theorem ret_bind (a) (f : α → Computation β) : bind (pure a) f = f a := by
apply
eq_of_bisim fun c₁ c₂ => c₁ = bind (pure a) f ∧ c₂ = f a ∨ c₁ = corec (Bind.f f) (Sum.inr c₂)
· intro c₁ c₂ h
- exact
- match c₁, c₂, h with
- | _, _, Or.inl ⟨rfl, rfl⟩ => by
- simp [bind, Bind.f]
- cases' destruct (f a) with b cb <;> simp [Bind.g]
- | _, c, Or.inr rfl => by
- simp [Bind.f]
- cases' destruct c with b cb <;> simp [Bind.g]
+ match c₁, c₂, h with
+ | _, _, Or.inl ⟨rfl, rfl⟩ =>
+ simp [bind, Bind.f]
+ cases' destruct (f a) with b cb <;> simp [Bind.g]
+ | _, c, Or.inr rfl =>
+ simp [Bind.f]
+ cases' destruct c with b cb <;> simp [Bind.g]
· simp
#align computation.ret_bind Computation.ret_bind
@@ -747,12 +742,11 @@ theorem think_bind (c) (f : α → Computation β) : bind (think c) f = think (b
theorem bind_pure (f : α → β) (s) : bind s (pure ∘ f) = map f s := by
apply eq_of_bisim fun c₁ c₂ => c₁ = c₂ ∨ ∃ s, c₁ = bind s (pure ∘ f) ∧ c₂ = map f s
· intro c₁ c₂ h
- exact
- match c₁, c₂, h with
- | _, c₂, Or.inl (Eq.refl _) => by cases' destruct c₂ with b cb <;> simp
- | _, _, Or.inr ⟨s, rfl, rfl⟩ => by
- apply recOn s <;> intro s <;> simp
- exact Or.inr ⟨s, rfl, rfl⟩
+ match c₁, c₂, h with
+ | _, c₂, Or.inl (Eq.refl _) => cases' destruct c₂ with b cb <;> simp
+ | _, _, Or.inr ⟨s, rfl, rfl⟩ =>
+ apply recOn s <;> intro s <;> simp
+ exact Or.inr ⟨s, rfl, rfl⟩
· exact Or.inr ⟨s, rfl, rfl⟩
#align computation.bind_ret Computation.bind_pure
@@ -761,11 +755,10 @@ theorem bind_pure (f : α → β) (s) : bind s (pure ∘ f) = map f s := by
theorem bind_pure' (s : Computation α) : bind s pure = s := by
apply eq_of_bisim fun c₁ c₂ => c₁ = c₂ ∨ ∃ s, c₁ = bind s (pure) ∧ c₂ = s
· intro c₁ c₂ h
- exact
- match c₁, c₂, h with
- | _, c₂, Or.inl (Eq.refl _) => by cases' destruct c₂ with b cb <;> simp
- | _, _, Or.inr ⟨s, rfl, rfl⟩ => by
- apply recOn s <;> intro s <;> simp
+ match c₁, c₂, h with
+ | _, c₂, Or.inl (Eq.refl _) => cases' destruct c₂ with b cb <;> simp
+ | _, _, Or.inr ⟨s, rfl, rfl⟩ =>
+ apply recOn s <;> intro s <;> simp
· exact Or.inr ⟨s, rfl, rfl⟩
#align computation.bind_ret' Computation.bind_pure'
@@ -776,15 +769,14 @@ theorem bind_assoc (s : Computation α) (f : α → Computation β) (g : β →
eq_of_bisim fun c₁ c₂ =>
c₁ = c₂ ∨ ∃ s, c₁ = bind (bind s f) g ∧ c₂ = bind s fun x : α => bind (f x) g
· intro c₁ c₂ h
- exact
- match c₁, c₂, h with
- | _, c₂, Or.inl (Eq.refl _) => by cases' destruct c₂ with b cb <;> simp
- | _, _, Or.inr ⟨s, rfl, rfl⟩ => by
- apply recOn s <;> intro s <;> simp
- · generalize f s = fs
- apply recOn fs <;> intro t <;> simp
- · cases' destruct (g t) with b cb <;> simp
- · exact Or.inr ⟨s, rfl, rfl⟩
+ match c₁, c₂, h with
+ | _, c₂, Or.inl (Eq.refl _) => cases' destruct c₂ with b cb <;> simp
+ | _, _, Or.inr ⟨s, rfl, rfl⟩ =>
+ apply recOn s <;> intro s <;> simp
+ · generalize f s = fs
+ apply recOn fs <;> intro t <;> simp
+ · cases' destruct (g t) with b cb <;> simp
+ · exact Or.inr ⟨s, rfl, rfl⟩
· exact Or.inr ⟨s, rfl, rfl⟩
#align computation.bind_assoc Computation.bind_assoc
@@ -832,16 +824,16 @@ theorem length_bind (s : Computation α) (f : α → Computation β) [_T1 : Term
theorem of_results_bind {s : Computation α} {f : α → Computation β} {b k} :
Results (bind s f) b k → ∃ a m n, Results s a m ∧ Results (f a) b n ∧ k = n + m := by
induction' k with n IH generalizing s <;> apply recOn s (fun a => _) fun s' => _ <;> intro e h
- · simp [thinkN] at h
+ · simp only [ret_bind, Nat.zero_eq] at h
refine' ⟨e, _, _, results_pure _, h, rfl⟩
· have := congr_arg head (eq_thinkN h)
contradiction
- · simp at h
+ · simp only [ret_bind] at h
refine' ⟨e, _, n + 1, results_pure _, h, rfl⟩
- · simp at h
- exact by
- let ⟨a, m, n', h1, h2, e'⟩ := IH h
- rw [e']; exact ⟨a, m.succ, n', results_think h1, h2, rfl⟩
+ · simp only [think_bind, results_think_iff] at h
+ let ⟨a, m, n', h1, h2, e'⟩ := IH h
+ rw [e']
+ exact ⟨a, m.succ, n', results_think h1, h2, rfl⟩
#align computation.of_results_bind Computation.of_results_bind
theorem exists_of_mem_bind {s : Computation α} {f : α → Computation β} {b} (h : b ∈ bind s f) :
@@ -894,9 +886,8 @@ theorem mem_map (f : α → β) {a} {s : Computation α} (m : a ∈ s) : f a ∈
theorem exists_of_mem_map {f : α → β} {b : β} {s : Computation α} (h : b ∈ map f s) :
∃ a, a ∈ s ∧ f a = b := by
rw [← bind_pure] at h
- exact
- let ⟨a, as, fb⟩ := exists_of_mem_bind h
- ⟨a, as, mem_unique (ret_mem _) fb⟩
+ let ⟨a, as, fb⟩ := exists_of_mem_bind h
+ exact ⟨a, as, mem_unique (ret_mem _) fb⟩
#align computation.exists_of_mem_map Computation.exists_of_mem_map
instance terminates_map (f : α → β) (s : Computation α) [Terminates s] : Terminates (map f s) := by
@@ -941,37 +932,37 @@ theorem ret_orElse (a : α) (c₂ : Computation α) : (pure a <|> c₂) = pure a
-- Porting note: Added unfolds as the code does not work without it
@[simp]
-theorem orelse_pure (c₁ : Computation α) (a : α) : (think c₁ <|> pure a) = pure a :=
+theorem orElse_pure (c₁ : Computation α) (a : α) : (think c₁ <|> pure a) = pure a :=
destruct_eq_pure <| by
unfold HOrElse.hOrElse instHOrElse
unfold OrElse.orElse instOrElse Alternative.orElse instAlternativeComputation
simp [orElse]
-#align computation.orelse_ret Computation.orelse_pure
+#align computation.orelse_ret Computation.orElse_pure
-- Porting note: Added unfolds as the code does not work without it
@[simp]
-theorem orelse_think (c₁ c₂ : Computation α) : (think c₁ <|> think c₂) = think (c₁ <|> c₂) :=
+theorem orElse_think (c₁ c₂ : Computation α) : (think c₁ <|> think c₂) = think (c₁ <|> c₂) :=
destruct_eq_think <| by
unfold HOrElse.hOrElse instHOrElse
unfold OrElse.orElse instOrElse Alternative.orElse instAlternativeComputation
simp [orElse]
-#align computation.orelse_think Computation.orelse_think
+#align computation.orelse_think Computation.orElse_think
@[simp]
-theorem empty_orelse (c) : (empty α <|> c) = c := by
+theorem empty_orElse (c) : (empty α <|> c) = c := by
apply eq_of_bisim (fun c₁ c₂ => (empty α <|> c₂) = c₁) _ rfl
intro s' s h; rw [← h]
apply recOn s <;> intro s <;> rw [think_empty] <;> simp
rw [← think_empty]
-#align computation.empty_orelse Computation.empty_orelse
+#align computation.empty_orelse Computation.empty_orElse
@[simp]
-theorem orelse_empty (c : Computation α) : (c <|> empty α) = c := by
+theorem orElse_empty (c : Computation α) : (c <|> empty α) = c := by
apply eq_of_bisim (fun c₁ c₂ => (c₂ <|> empty α) = c₁) _ rfl
intro s' s h; rw [← h]
apply recOn s <;> intro s <;> rw [think_empty] <;> simp
rw [← think_empty]
-#align computation.orelse_empty Computation.orelse_empty
+#align computation.orelse_empty Computation.orElse_empty
/-- `c₁ ~ c₂` asserts that `c₁` and `c₂` either both terminate with the same result,
or both loop forever. -/
@@ -1053,11 +1044,8 @@ theorem LiftRel.swap (R : α → β → Prop) (ca : Computation α) (cb : Comput
theorem lift_eq_iff_equiv (c₁ c₂ : Computation α) : LiftRel (· = ·) c₁ c₂ ↔ c₁ ~ c₂ :=
⟨fun ⟨h1, h2⟩ a =>
- ⟨fun a1 => by
- let ⟨b, b2, ab⟩ := h1 a1
- rwa [ab], fun a2 => by
- let ⟨b, b1, ab⟩ := h2 a2
- rwa [← ab]⟩,
+ ⟨fun a1 => by let ⟨b, b2, ab⟩ := h1 a1; rwa [ab],
+ fun a2 => by let ⟨b, b1, ab⟩ := h2 a2; rwa [← ab]⟩,
fun e => ⟨fun {a} a1 => ⟨a, (e _).1 a1, rfl⟩, fun {a} a2 => ⟨a, (e _).2 a2, rfl⟩⟩⟩
#align computation.lift_eq_iff_equiv Computation.lift_eq_iff_equiv
@@ -1107,7 +1095,7 @@ theorem LiftRel.imp {R S : α → β → Prop} (H : ∀ {a b}, R a b → S a b)
⟨a, as, H ab⟩⟩
#align computation.lift_rel.imp Computation.LiftRel.imp
-theorem terminates_of_LiftRel {R : α → β → Prop} {s t} :
+theorem terminates_of_liftRel {R : α → β → Prop} {s t} :
LiftRel R s t → (Terminates s ↔ Terminates t)
| ⟨l, r⟩ =>
⟨fun ⟨⟨_, as⟩⟩ =>
@@ -1116,14 +1104,14 @@ theorem terminates_of_LiftRel {R : α → β → Prop} {s t} :
fun ⟨⟨_, bt⟩⟩ =>
let ⟨a, as, _⟩ := r bt
⟨⟨a, as⟩⟩⟩
-#align computation.terminates_of_lift_rel Computation.terminates_of_LiftRel
+#align computation.terminates_of_lift_rel Computation.terminates_of_liftRel
-theorem rel_of_LiftRel {R : α → β → Prop} {ca cb} :
+theorem rel_of_liftRel {R : α → β → Prop} {ca cb} :
LiftRel R ca cb → ∀ {a b}, a ∈ ca → b ∈ cb → R a b
| ⟨l, _⟩, a, b, ma, mb => by
let ⟨b', mb', ab'⟩ := l ma
rw [mem_unique mb mb']; exact ab'
-#align computation.rel_of_lift_rel Computation.rel_of_LiftRel
+#align computation.rel_of_lift_rel Computation.rel_of_liftRel
theorem liftRel_of_mem {R : α → β → Prop} {a b ca cb} (ma : a ∈ ca) (mb : b ∈ cb) (ab : R a b) :
LiftRel R ca cb :=
@@ -1131,20 +1119,20 @@ theorem liftRel_of_mem {R : α → β → Prop} {a b ca cb} (ma : a ∈ ca) (mb
rw [mem_unique mb' mb]; exact ⟨a, ma, ab⟩⟩
#align computation.lift_rel_of_mem Computation.liftRel_of_mem
-theorem exists_of_LiftRel_left {R : α → β → Prop} {ca cb} (H : LiftRel R ca cb) {a} (h : a ∈ ca) :
+theorem exists_of_liftRel_left {R : α → β → Prop} {ca cb} (H : LiftRel R ca cb) {a} (h : a ∈ ca) :
∃ b, b ∈ cb ∧ R a b :=
H.left h
-#align computation.exists_of_lift_rel_left Computation.exists_of_LiftRel_left
+#align computation.exists_of_lift_rel_left Computation.exists_of_liftRel_left
-theorem exists_of_LiftRel_right {R : α → β → Prop} {ca cb} (H : LiftRel R ca cb) {b} (h : b ∈ cb) :
+theorem exists_of_liftRel_right {R : α → β → Prop} {ca cb} (H : LiftRel R ca cb) {b} (h : b ∈ cb) :
∃ a, a ∈ ca ∧ R a b :=
H.right h
-#align computation.exists_of_lift_rel_right Computation.exists_of_LiftRel_right
+#align computation.exists_of_lift_rel_right Computation.exists_of_liftRel_right
theorem liftRel_def {R : α → β → Prop} {ca cb} :
LiftRel R ca cb ↔ (Terminates ca ↔ Terminates cb) ∧ ∀ {a b}, a ∈ ca → b ∈ cb → R a b :=
⟨fun h =>
- ⟨terminates_of_LiftRel h, fun {a b} ma mb => by
+ ⟨terminates_of_liftRel h, fun {a b} ma mb => by
let ⟨b', mb', ab⟩ := h.left ma
rwa [mem_unique mb mb']⟩,
fun ⟨l, r⟩ =>
@@ -1229,7 +1217,8 @@ theorem liftRel_map {δ} (R : α → β → Prop) (S : γ → δ → Prop) {s1 :
-- rw [← bind_pure, ← bind_pure]; apply lift_rel_bind _ _ h1; simp; exact @h2
--
-- The code fails to work on the last exact.
- rw [← bind_pure, ← bind_pure]; apply liftRel_bind _ _ h1; simp
+ rw [← bind_pure, ← bind_pure]; apply liftRel_bind _ _ h1
+ simp only [comp_apply, liftRel_pure_right]
intros a b h; exact ⟨f1 a, ⟨ret_mem _, @h2 a b h⟩⟩
#align computation.lift_rel_map Computation.liftRel_map
@@ -1251,14 +1240,14 @@ def LiftRelAux (R : α → β → Prop) (C : Computation α → Computation β
--porting note: was attribute [simp] LiftRelAux but right now `simp` on defs is a Lean 4 catastrophe
-- Instead we add the equation lemmas and tag them @[simp]
-@[simp] lemma LiftRelAux_inl_inl : LiftRelAux R C (Sum.inl a) (Sum.inl b) = R a b := rfl
-@[simp] lemma LiftRelAux_inl_inr {cb} :
+@[simp] lemma liftRelAux_inl_inl : LiftRelAux R C (Sum.inl a) (Sum.inl b) = R a b := rfl
+@[simp] lemma liftRelAux_inl_inr {cb} :
LiftRelAux R C (Sum.inl a) (Sum.inr cb) = ∃ b, b ∈ cb ∧ R a b :=
rfl
-@[simp] lemma LiftRelAux_inr_inl {ca} :
+@[simp] lemma liftRelAux_inr_inl {ca} :
LiftRelAux R C (Sum.inr ca) (Sum.inl b) = ∃ a, a ∈ ca ∧ R a b :=
rfl
-@[simp] lemma LiftRelAux_inr_inr {ca cb} :
+@[simp] lemma liftRelAux_inr_inr {ca cb} :
LiftRelAux R C (Sum.inr ca) (Sum.inr cb) = C ca cb :=
rfl
@@ -1291,21 +1280,21 @@ theorem LiftRelRec.lem {R : α → β → Prop} (C : Computation α → Computat
revert cb
refine' memRecOn (C := (λ ca => ∀ (cb : Computation β), C ca cb → LiftRel R ca cb))
ha _ (fun ca' IH => _) <;> intro cb Hc <;> have h := H Hc
- · simp at h
+ · simp only [destruct_pure, LiftRelAux.ret_left] at h
simp [h]
- · simp
+ · simp only [liftRel_think_left]
revert h
apply cb.recOn (fun b => _) fun cb' => _ <;> intros _ h <;> simp at h <;> simp [h]
exact IH _ h
#align computation.lift_rel_rec.lem Computation.LiftRelRec.lem
-theorem lift_rel_rec {R : α → β → Prop} (C : Computation α → Computation β → Prop)
+theorem liftRel_rec {R : α → β → Prop} (C : Computation α → Computation β → Prop)
(H : ∀ {ca cb}, C ca cb → LiftRelAux R C (destruct ca) (destruct cb)) (ca cb) (Hc : C ca cb) :
LiftRel R ca cb :=
liftRel_mem_cases (LiftRelRec.lem C (@H) ca cb Hc) fun b hb =>
(LiftRel.swap _ _ _).2 <|
LiftRelRec.lem (swap C) (fun {_ _} h => cast (LiftRelAux.swap _ _ _ _).symm <| H h) cb ca Hc b
hb
-#align computation.lift_rel_rec Computation.lift_rel_rec
+#align computation.lift_rel_rec Computation.liftRel_rec
end Computation
@@ -711,7 +711,7 @@ theorem map_id : ∀ s : Computation α, map id s = s
| ⟨f, al⟩ => by
apply Subtype.eq; simp [map, Function.comp]
have e : @Option.rec α (fun _ => Option α) none some = id := by ext ⟨⟩ <;> rfl
- have h : ((fun x: Option α => x) = id) := by rfl
+ have h : ((fun x: Option α => x) = id) := rfl
simp [e, h, Stream'.map_id]
#align computation.map_id Computation.map_id
@@ -1220,7 +1220,7 @@ theorem liftRel_congr {R : α → β → Prop} {ca ca' : Computation α} {cb cb'
and_congr
(forall_congr' fun _ => imp_congr (ha _) <| exists_congr fun _ => and_congr (hb _) Iff.rfl)
(forall_congr' fun _ => imp_congr (hb _) <| exists_congr fun _ => and_congr (ha _) Iff.rfl)
-#align computation.lift_gcongr Computation.liftRel_congr
+#align computation.lift_rel_congr Computation.liftRel_congr
theorem liftRel_map {δ} (R : α → β → Prop) (S : γ → δ → Prop) {s1 : Computation α}
{s2 : Computation β} {f1 : α → γ} {f2 : β → δ} (h1 : LiftRel R s1 s2)
Autoimplicits are highly controversial and also defeat the performance-improving work in #6474.
The intent of this PR is to make autoImplicit
opt-in on a per-file basis, by disabling it in the lakefile and enabling it again with set_option autoImplicit true
in the few files that rely on it.
That also keeps this PR small, as opposed to attempting to "fix" files to not need it any more.
I claim that many of the uses of autoImplicit
in these files are accidental; situations such as:
variables
are in scope, but pasting the lemma in the wrong sectionHaving set_option autoImplicit false
as the default prevents these types of mistake being made in the 90% of files where autoImplicit
s are not used at all, and causes them to be caught by CI during review.
I think there were various points during the port where we encouraged porters to delete the universes u v
lines; I think having autoparams for universe variables only would cover a lot of the cases we actually use them, while avoiding any real shortcomings.
A Zulip poll (after combining overlapping votes accordingly) was in favor of this change with 5:5:18
as the no:dontcare:yes
vote ratio.
While this PR was being reviewed, a handful of files gained some more likely-accidental autoImplicits. In these places, set_option autoImplicit true
has been placed locally within a section, rather than at the top of the file.
@@ -17,6 +17,8 @@ This file provides a `Computation` type where `Computation α` is the type of
unbounded computations returning `α`.
-/
+set_option autoImplicit true
+
open Function
Per https://github.com/leanprover/lean4/issues/2343, we are going to need to change the automatic generation of instance names, as they become too long.
This PR ensures that everywhere in Mathlib that refers to an instance by name, that name is given explicitly, rather than being automatically generated.
There are four exceptions, which are now commented, with links to https://github.com/leanprover/lean4/issues/2343.
This was implemented by running Mathlib against a modified Lean that appended _ᾰ
to all automatically generated names, and fixing everything.
Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
@@ -923,7 +923,7 @@ def orElse (c₁ : Computation α) (c₂ : Unit → Computation α) : Computatio
(c₁, c₂ ())
#align computation.orelse Computation.orElse
-instance : Alternative Computation :=
+instance instAlternativeComputation : Alternative Computation :=
{ Computation.monad with
orElse := @orElse
failure := @empty }
@@ -4,15 +4,12 @@ Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro
Coinductive formalization of unbounded computations.
-
-! This file was ported from Lean 3 source module data.seq.computation
-! leanprover-community/mathlib commit 1f0096e6caa61e9c849ec2adbd227e960e9dff58
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
-/
import Mathlib.Data.Stream.Init
import Mathlib.Tactic.Common
+#align_import data.seq.computation from "leanprover-community/mathlib"@"1f0096e6caa61e9c849ec2adbd227e960e9dff58"
+
/-!
# Coinductive formalization of unbounded computations.
@@ -901,7 +901,7 @@ theorem exists_of_mem_map {f : α → β} {b : β} {s : Computation α} (h : b
#align computation.exists_of_mem_map Computation.exists_of_mem_map
instance terminates_map (f : α → β) (s : Computation α) [Terminates s] : Terminates (map f s) := by
- rw [← bind_pure]; exact terminates_of_mem (mem_bind (get_mem s) (get_mem (f (get s))))
+ rw [← bind_pure]; exact terminates_of_mem (mem_bind (get_mem s) (get_mem (f (get s))))
#align computation.terminates_map Computation.terminates_map
theorem terminates_map_iff (f : α → β) (s : Computation α) : Terminates (map f s) ↔ Terminates s :=
This is the second half of the changes originally in #5699, removing all occurrences of ;
after a space and implementing a linter rule to enforce it.
In most cases this 2-character substring has a space after it, so the following command was run first:
find . -type f -name "*.lean" -exec sed -i -E 's/ ; /; /g' {} \;
The remaining cases were few enough in number that they were done manually.
@@ -178,7 +178,7 @@ theorem tail_pure (a : α) : tail (pure a) = pure a :=
@[simp]
theorem tail_think (s : Computation α) : tail (think s) = s := by
- cases' s with f al ; apply Subtype.eq ; dsimp [tail, think]
+ cases' s with f al; apply Subtype.eq; dsimp [tail, think]
#align computation.tail_think Computation.tail_think
@[simp]
@@ -407,7 +407,7 @@ theorem not_terminates_empty : ¬Terminates (empty α) := fun ⟨⟨a, h⟩⟩ =
theorem eq_empty_of_not_terminates {s} (H : ¬Terminates s) : s = empty α := by
apply Subtype.eq; funext n
- induction' h : s.val n with _ ; · rfl
+ induction' h : s.val n with _; · rfl
refine' absurd _ H; exact ⟨⟨_, _, h.symm⟩⟩
#align computation.eq_empty_of_not_terminates Computation.eq_empty_of_not_terminates
@@ -469,7 +469,7 @@ theorem get_eq_of_mem {a} : a ∈ s → get s = a :=
mem_unique (get_mem _)
#align computation.get_eq_of_mem Computation.get_eq_of_mem
-theorem mem_of_get_eq {a} : get s = a → a ∈ s := by intro h ; rw [← h] ; apply get_mem
+theorem mem_of_get_eq {a} : get s = a → a ∈ s := by intro h; rw [← h]; apply get_mem
#align computation.mem_of_get_eq Computation.mem_of_get_eq
@[simp]
@@ -513,7 +513,7 @@ theorem results_of_terminates (s : Computation α) [_T : Terminates s] :
#align computation.results_of_terminates Computation.results_of_terminates
theorem results_of_terminates' (s : Computation α) [T : Terminates s] {a} (h : a ∈ s) :
- Results s a (length s) := by rw [← get_eq_of_mem _ h] ; apply results_of_terminates
+ Results s a (length s) := by rw [← get_eq_of_mem _ h]; apply results_of_terminates
#align computation.results_of_terminates' Computation.results_of_terminates'
theorem Results.mem {s : Computation α} {a n} : Results s a n → a ∈ s
@@ -534,7 +534,7 @@ theorem Results.val_unique {s : Computation α} {a b m n} (h1 : Results s a m) (
#align computation.results.val_unique Computation.Results.val_unique
theorem Results.len_unique {s : Computation α} {a b m n} (h1 : Results s a m) (h2 : Results s b n) :
- m = n := by haveI := h1.terminates ; haveI := h2.terminates ; rw [← h1.length, h2.length]
+ m = n := by haveI := h1.terminates; haveI := h2.terminates; rw [← h1.length, h2.length]
#align computation.results.len_unique Computation.Results.len_unique
theorem exists_results_of_mem {s : Computation α} {a} (h : a ∈ s) : ∃ n, Results s a n :=
@@ -563,7 +563,7 @@ theorem length_think (s : Computation α) [h : Terminates s] : length (think s)
· exact Nat.find_min' _ (Nat.find_spec ((terminates_def _).1 h))
· have : (Option.isSome ((think s).val (length (think s))) : Prop) :=
Nat.find_spec ((terminates_def _).1 s.think_terminates)
- revert this ; cases' length (think s) with n <;> intro this
+ revert this; cases' length (think s) with n <;> intro this
· simp [think, Stream'.cons] at this
· apply Nat.succ_le_succ
apply Nat.find_min'
@@ -586,7 +586,7 @@ theorem of_results_think {s : Computation α} {a n} (h : Results (think s) a n)
theorem results_think_iff {s : Computation α} {a n} : Results (think s) a (n + 1) ↔ Results s a n :=
⟨fun h => by
let ⟨n', r, e⟩ := of_results_think h
- injection e with h' ; rw [Nat.add, Nat.add] at h'; rwa [h'], results_think⟩
+ injection e with h'; rw [Nat.add, Nat.add] at h'; rwa [h'], results_think⟩
#align computation.results_think_iff Computation.results_think_iff
theorem results_thinkN {s : Computation α} {a m} :
@@ -597,7 +597,7 @@ set_option linter.uppercaseLean3 false in
#align computation.results_thinkN Computation.results_thinkN
theorem results_thinkN_pure (a : α) (n) : Results (thinkN (pure a) n) a n := by
- have := results_thinkN n (results_pure a) ; rwa [Nat.zero_add] at this
+ have := results_thinkN n (results_pure a); rwa [Nat.zero_add] at this
set_option linter.uppercaseLean3 false in
#align computation.results_thinkN_ret Computation.results_thinkN_pure
@@ -699,7 +699,7 @@ theorem map_pure (f : α → β) (a) : map f (pure a) = pure (f a) :=
@[simp]
theorem map_think (f : α → β) : ∀ s, map f (think s) = think (map f s)
- | ⟨s, al⟩ => by apply Subtype.eq ; dsimp [think, map] ; rw [Stream'.map_cons]
+ | ⟨s, al⟩ => by apply Subtype.eq; dsimp [think, map]; rw [Stream'.map_cons]
#align computation.map_think Computation.map_think
@[simp]
@@ -710,7 +710,7 @@ theorem destruct_map (f : α → β) (s) : destruct (map f s) = lmap f (rmap (ma
@[simp]
theorem map_id : ∀ s : Computation α, map id s = s
| ⟨f, al⟩ => by
- apply Subtype.eq ; simp [map, Function.comp]
+ apply Subtype.eq; simp [map, Function.comp]
have e : @Option.rec α (fun _ => Option α) none some = id := by ext ⟨⟩ <;> rfl
have h : ((fun x: Option α => x) = id) := by rfl
simp [e, h, Stream'.map_id]
@@ -718,7 +718,7 @@ theorem map_id : ∀ s : Computation α, map id s = s
theorem map_comp (f : α → β) (g : β → γ) : ∀ s : Computation α, map (g ∘ f) s = map g (map f s)
| ⟨s, al⟩ => by
- apply Subtype.eq ; dsimp [map]
+ apply Subtype.eq; dsimp [map]
apply congr_arg fun f : _ → Option γ => Stream'.map f s
ext ⟨⟩ <;> rfl
#align computation.map_comp Computation.map_comp
@@ -842,7 +842,7 @@ theorem of_results_bind {s : Computation α} {f : α → Computation β} {b k} :
· simp at h
exact by
let ⟨a, m, n', h1, h2, e'⟩ := IH h
- rw [e'] ; exact ⟨a, m.succ, n', results_think h1, h2, rfl⟩
+ rw [e']; exact ⟨a, m.succ, n', results_think h1, h2, rfl⟩
#align computation.of_results_bind Computation.of_results_bind
theorem exists_of_mem_bind {s : Computation α} {f : α → Computation β} {b} (h : b ∈ bind s f) :
@@ -889,19 +889,19 @@ theorem map_think' {α β} : ∀ (f : α → β) (s), f <$> think s = think (f <
#align computation.map_think' Computation.map_think'
theorem mem_map (f : α → β) {a} {s : Computation α} (m : a ∈ s) : f a ∈ map f s := by
- rw [← bind_pure] ; apply mem_bind m ; apply ret_mem
+ rw [← bind_pure]; apply mem_bind m; apply ret_mem
#align computation.mem_map Computation.mem_map
theorem exists_of_mem_map {f : α → β} {b : β} {s : Computation α} (h : b ∈ map f s) :
∃ a, a ∈ s ∧ f a = b := by
- rw [← bind_pure] at h ;
- exact
- let ⟨a, as, fb⟩ := exists_of_mem_bind h
- ⟨a, as, mem_unique (ret_mem _) fb⟩
+ rw [← bind_pure] at h
+ exact
+ let ⟨a, as, fb⟩ := exists_of_mem_bind h
+ ⟨a, as, mem_unique (ret_mem _) fb⟩
#align computation.exists_of_mem_map Computation.exists_of_mem_map
instance terminates_map (f : α → β) (s : Computation α) [Terminates s] : Terminates (map f s) := by
- rw [← bind_pure] ; exact terminates_of_mem (mem_bind (get_mem s) (get_mem (f (get s))))
+ rw [← bind_pure]; exact terminates_of_mem (mem_bind (get_mem s) (get_mem (f (get s))))
#align computation.terminates_map Computation.terminates_map
theorem terminates_map_iff (f : α → β) (s : Computation α) : Terminates (map f s) ↔ Terminates s :=
@@ -1002,7 +1002,7 @@ theorem Equiv.equivalence : Equivalence (@Equiv α) :=
#align computation.equiv.equivalence Computation.Equiv.equivalence
theorem equiv_of_mem {s t : Computation α} {a} (h1 : a ∈ s) (h2 : a ∈ t) : s ~ t := fun a' =>
- ⟨fun ma => by rw [mem_unique ma h1] ; exact h2, fun ma => by rw [mem_unique ma h2] ; exact h1⟩
+ ⟨fun ma => by rw [mem_unique ma h1]; exact h2, fun ma => by rw [mem_unique ma h2]; exact h1⟩
#align computation.equiv_of_mem Computation.equiv_of_mem
theorem terminates_congr {c₁ c₂ : Computation α} (h : c₁ ~ c₂) : Terminates c₁ ↔ Terminates c₂ := by
@@ -1123,13 +1123,13 @@ theorem rel_of_LiftRel {R : α → β → Prop} {ca cb} :
LiftRel R ca cb → ∀ {a b}, a ∈ ca → b ∈ cb → R a b
| ⟨l, _⟩, a, b, ma, mb => by
let ⟨b', mb', ab'⟩ := l ma
- rw [mem_unique mb mb'] ; exact ab'
+ rw [mem_unique mb mb']; exact ab'
#align computation.rel_of_lift_rel Computation.rel_of_LiftRel
theorem liftRel_of_mem {R : α → β → Prop} {a b ca cb} (ma : a ∈ ca) (mb : b ∈ cb) (ab : R a b) :
LiftRel R ca cb :=
- ⟨fun {a'} ma' => by rw [mem_unique ma' ma] ; exact ⟨b, mb, ab⟩, fun {b'} mb' => by
- rw [mem_unique mb' mb] ; exact ⟨a, ma, ab⟩⟩
+ ⟨fun {a'} ma' => by rw [mem_unique ma' ma]; exact ⟨b, mb, ab⟩, fun {b'} mb' => by
+ rw [mem_unique mb' mb]; exact ⟨a, ma, ab⟩⟩
#align computation.lift_rel_of_mem Computation.liftRel_of_mem
theorem exists_of_LiftRel_left {R : α → β → Prop} {ca cb} (H : LiftRel R ca cb) {a} (h : a ∈ ca) :
@@ -1179,8 +1179,8 @@ theorem liftRel_bind {δ} (R : α → β → Prop) (S : γ → δ → Prop) {s1
theorem liftRel_pure_left (R : α → β → Prop) (a : α) (cb : Computation β) :
LiftRel R (pure a) cb ↔ ∃ b, b ∈ cb ∧ R a b :=
⟨fun ⟨l, _⟩ => l (ret_mem _), fun ⟨b, mb, ab⟩ =>
- ⟨fun {a'} ma' => by rw [eq_of_pure_mem ma'] ; exact ⟨b, mb, ab⟩, fun {b'} mb' =>
- ⟨_, ret_mem _, by rw [mem_unique mb' mb] ; exact ab⟩⟩⟩
+ ⟨fun {a'} ma' => by rw [eq_of_pure_mem ma']; exact ⟨b, mb, ab⟩, fun {b'} mb' =>
+ ⟨_, ret_mem _, by rw [mem_unique mb' mb]; exact ab⟩⟩⟩
#align computation.lift_rel_return_left Computation.liftRel_pure_left
@[simp]
@@ -1193,8 +1193,8 @@ theorem liftRel_pure_right (R : α → β → Prop) (ca : Computation α) (b :
@[simp, nolint simpNF]
theorem liftRel_pure (R : α → β → Prop) (a : α) (b : β) :
LiftRel R (pure a) (pure b) ↔ R a b := by
- rw [liftRel_pure_left] ;
- exact ⟨fun ⟨b', mb', ab'⟩ => by rwa [eq_of_pure_mem mb'] at ab', fun ab => ⟨_, ret_mem _, ab⟩⟩
+ rw [liftRel_pure_left]
+ exact ⟨fun ⟨b', mb', ab'⟩ => by rwa [eq_of_pure_mem mb'] at ab', fun ab => ⟨_, ret_mem _, ab⟩⟩
#align computation.lift_rel_return Computation.liftRel_pure
@[simp]
@@ -1208,7 +1208,7 @@ theorem liftRel_think_left (R : α → β → Prop) (ca : Computation α) (cb :
@[simp]
theorem liftRel_think_right (R : α → β → Prop) (ca : Computation α) (cb : Computation β) :
LiftRel R ca (think cb) ↔ LiftRel R ca cb := by
- rw [← LiftRel.swap R, ← LiftRel.swap R] ; apply liftRel_think_left
+ rw [← LiftRel.swap R, ← LiftRel.swap R]; apply liftRel_think_left
#align computation.lift_rel_think_right Computation.liftRel_think_right
theorem liftRel_mem_cases {R : α → β → Prop} {ca cb} (Ha : ∀ a ∈ ca, LiftRel R ca cb)
@@ -1237,8 +1237,8 @@ theorem liftRel_map {δ} (R : α → β → Prop) (S : γ → δ → Prop) {s1 :
-- porting notes: deleted initial arguments `(_R : α → α → Prop) (_S : β → β → Prop)`: unused
theorem map_congr {s1 s2 : Computation α} {f : α → β}
(h1 : s1 ~ s2) : map f s1 ~ map f s2 := by
- rw [← lift_eq_iff_equiv] ;
- exact liftRel_map Eq _ ((lift_eq_iff_equiv _ _).2 h1) fun {a} b => congr_arg _
+ rw [← lift_eq_iff_equiv]
+ exact liftRel_map Eq _ ((lift_eq_iff_equiv _ _).2 h1) fun {a} b => congr_arg _
#align computation.map_congr Computation.map_congr
/-- Alternate definition of `LiftRel` over relations between `Computation`s-/
@@ -1269,7 +1269,7 @@ theorem LiftRelAux.ret_left (R : α → β → Prop) (C : Computation α → Com
apply cb.recOn (fun b => _) fun cb => _
· intro b
exact
- ⟨fun h => ⟨_, ret_mem _, h⟩, fun ⟨b', mb, h⟩ => by rw [mem_unique (ret_mem _) mb] ; exact h⟩
+ ⟨fun h => ⟨_, ret_mem _, h⟩, fun ⟨b', mb, h⟩ => by rw [mem_unique (ret_mem _) mb]; exact h⟩
· intro
rw [destruct_think]
exact ⟨fun ⟨b, h, r⟩ => ⟨b, think_mem h, r⟩, fun ⟨b, h, r⟩ => ⟨b, of_think_mem h, r⟩⟩
This PR is the result of running
find . -type f -name "*.lean" -exec sed -i -E 's/^( +)\. /\1· /' {} \;
find . -type f -name "*.lean" -exec sed -i -E 'N;s/^( +·)\n +(.*)$/\1 \2/;P;D' {} \;
which firstly replaces .
focusing dots with ·
and secondly removes isolated instances of such dots, unifying them with the following line. A new rule is placed in the style linter to verify this.
@@ -58,8 +58,8 @@ instance : CoeTC α (Computation α) :=
def think (c : Computation α) : Computation α :=
⟨Stream'.cons none c.1, fun n a h => by
cases' n with n
- . contradiction
- . exact c.2 h⟩
+ · contradiction
+ · exact c.2 h⟩
#align computation.think Computation.think
/-- `thinkN c n` is the computation that delays for `n` ticks and then performs
@@ -304,8 +304,8 @@ theorem eq_of_bisim (bisim : IsBisimulation R) {s₁ s₂} (r : s₁ ~ s₂) : s
have h := bisim r; revert r h
apply recOn s _ _ <;> intro r' <;> apply recOn s' _ _ <;> intro a' r h
· constructor <;> dsimp at h
- . rw [h]
- . rw [h] at r
+ · rw [h]
+ · rw [h] at r
rw [tail_pure, tail_pure,h]
assumption
· rw [destruct_pure, destruct_think] at h
@@ -653,7 +653,7 @@ def map (f : α → β) : Computation α → Computation β
⟨s.map fun o => Option.casesOn o none (some ∘ f), fun n b => by
dsimp [Stream'.map, Stream'.nth]
induction' e : s n with a <;> intro h
- . contradiction
+ · contradiction
· rw [al e]; exact h⟩
#align computation.map Computation.map
@@ -761,13 +761,13 @@ theorem bind_pure (f : α → β) (s) : bind s (pure ∘ f) = map f s := by
@[simp]
theorem bind_pure' (s : Computation α) : bind s pure = s := by
apply eq_of_bisim fun c₁ c₂ => c₁ = c₂ ∨ ∃ s, c₁ = bind s (pure) ∧ c₂ = s
- . intro c₁ c₂ h
+ · intro c₁ c₂ h
exact
match c₁, c₂, h with
| _, c₂, Or.inl (Eq.refl _) => by cases' destruct c₂ with b cb <;> simp
| _, _, Or.inr ⟨s, rfl, rfl⟩ => by
apply recOn s <;> intro s <;> simp
- . exact Or.inr ⟨s, rfl, rfl⟩
+ · exact Or.inr ⟨s, rfl, rfl⟩
#align computation.bind_ret' Computation.bind_pure'
@[simp]
We disable the "relaxed" auto-implicit feature, so only single character identifiers become eligible as auto-implicits. See discussion on zulip and 2.
Co-authored-by: Scott Morrison <scott.morrison@gmail.com> Co-authored-by: Scott Morrison <scott.morrison@anu.edu.au>
@@ -1253,11 +1253,15 @@ def LiftRelAux (R : α → β → Prop) (C : Computation α → Computation β
--porting note: was attribute [simp] LiftRelAux but right now `simp` on defs is a Lean 4 catastrophe
-- Instead we add the equation lemmas and tag them @[simp]
@[simp] lemma LiftRelAux_inl_inl : LiftRelAux R C (Sum.inl a) (Sum.inl b) = R a b := rfl
-@[simp] lemma LiftRelAux_inl_inr : LiftRelAux R C (Sum.inl a) (Sum.inr cb) = ∃ b, b ∈ cb ∧ R a b :=
+@[simp] lemma LiftRelAux_inl_inr {cb} :
+ LiftRelAux R C (Sum.inl a) (Sum.inr cb) = ∃ b, b ∈ cb ∧ R a b :=
rfl
-@[simp] lemma LiftRelAux_inr_inl : LiftRelAux R C (Sum.inr ca) (Sum.inl b) = ∃ a, a ∈ ca ∧ R a b :=
+@[simp] lemma LiftRelAux_inr_inl {ca} :
+ LiftRelAux R C (Sum.inr ca) (Sum.inl b) = ∃ a, a ∈ ca ∧ R a b :=
+ rfl
+@[simp] lemma LiftRelAux_inr_inr {ca cb} :
+ LiftRelAux R C (Sum.inr ca) (Sum.inr cb) = C ca cb :=
rfl
-@[simp] lemma LiftRelAux_inr_inr : LiftRelAux R C (Sum.inr ca) (Sum.inr cb) = C ca cb := rfl
@[simp]
theorem LiftRelAux.ret_left (R : α → β → Prop) (C : Computation α → Computation β → Prop) (a cb) :
@@ -914,7 +914,7 @@ theorem terminates_map_iff (f : α → β) (s : Computation α) : Terminates (ma
-- Parallel computation
/-- `c₁ <|> c₂` calculates `c₁` and `c₂` simultaneously, returning
the first one that gives a result. -/
-def orElse (c₁: Computation α) (c₂: Unit → Computation α): Computation α :=
+def orElse (c₁ : Computation α) (c₂ : Unit → Computation α) : Computation α :=
@Computation.corec α (Computation α × Computation α)
(fun ⟨c₁, c₂⟩ =>
match destruct c₁ with
@@ -28,7 +28,7 @@ universe u v w
/-
coinductive Computation (α : Type u) : Type u
| pure : α → Computation α
-| think : Computation α → Xomputation α
+| think : Computation α → Computation α
-/
/-- `Computation α` is the type of unbounded computations returning `α`.
An element of `Computation α` is an infinite sequence of `Option α` such
@@ -629,7 +629,7 @@ theorem eq_thinkN' (s : Computation α) [_h : Terminates s] :
set_option linter.uppercaseLean3 false in
#align computation.eq_thinkN' Computation.eq_thinkN'
-/-- Recursor based on memberhip-/
+/-- Recursor based on membership-/
def memRecOn {C : Computation α → Sort v} {a s} (M : a ∈ s) (h1 : C (pure a))
(h2 : ∀ s, C s → C (think s)) : C s := by
haveI T := terminates_of_mem M
@@ -332,7 +332,7 @@ instance : Membership α (Computation α) :=
theorem le_stable (s : Computation α) {a m n} (h : m ≤ n) : s.1 m = some a → s.1 n = some a := by
cases' s with f al
induction' h with n _ IH
- exacts[id, fun h2 => al (IH h2)]
+ exacts [id, fun h2 => al (IH h2)]
#align computation.le_stable Computation.le_stable
theorem mem_unique {s : Computation α} {a b : α} : a ∈ s → b ∈ s → a = b
@@ -635,7 +635,7 @@ def memRecOn {C : Computation α → Sort v} {a s} (M : a ∈ s) (h1 : C (pure a
haveI T := terminates_of_mem M
rw [eq_thinkN' s, get_eq_of_mem s M]
generalize length s = n
- induction' n with n IH; exacts[h1, h2 _ IH]
+ induction' n with n IH; exacts [h1, h2 _ IH]
#align computation.mem_rec_on Computation.memRecOn
/-- Recursor based on assertion of `Terminates`-/
gcongr
for "relational congruence" (#3965)
This PR implements a new tactic, gcongr
, which applies "relational congruence" rules, reducing a relational goal between a LHS and RHS matching the same pattern to relational subgoals between the differing inputs to the pattern. For example,
example {a b x c d : ℝ} (h1 : a + 1 ≤ b + 1) (h2 : c + 2 ≤ d + 2) :
x ^ 4 * a + c ≤ x ^ 4 * b + d := by
gcongr
· linarith
· linarith
This example has the goal of proving the relation ≤
between a LHS and RHS both of the pattern
x ^ 4 * ?_ + ?_
(with inputs a
, c
on the left and b
, d
on the right); after the use of gcongr
, we have the simpler goals a ≤ b
and c ≤ d
.
For a sense of the style of argument facilitated by the tactic, this commit (which will be PR'd separately) gives >100 examples of use cases in the existing library.
The tactic's syntax allows for a pattern to be provided explicitly; this is useful if a non-maximal match is desired:
example {a b c d x : ℝ} (h : a + c + 1 ≤ b + d + 1) :
x ^ 4 * (a + c) + 5 ≤ x ^ 4 * (b + d) + 5 := by
gcongr x ^ 4 * ?_ + 5
linarith
This feature is the analogue for general relations of the mathlib3 congrm
tactic.
The "relational congruence" rules used are the library lemmas which have been tagged with the attribute @[gcongr]
. For example, the first example constructs the proof term
add_le_add (mul_le_mul_of_nonneg_left _ (pow_bit0_nonneg x 2)) _
using the relational congruence lemmas add_le_add
and mul_le_mul_of_nonneg_left
. In this initial implementation, the @[gcongr]
tagging has been set up for arithmetic head functions (+
, *
etc) and the relations ≤
, <
and congruence-mod-n
.
The tactic attempts to discharge side goals to these "relational congruence" lemmas (such as the side goal 0 ≤ x ^ 4
in the above application of mul_le_mul_of_nonneg_left
) using the tactic gcongr_discharger
, which wraps positivity
but can also be extended. Side goals not discharged in this way are left for the user.
Co-authored-by: Mario Carneiro <di.gama@gmail.com>
Co-authored-by: Mario Carneiro <di.gama@gmail.com> Co-authored-by: Moritz Doll <moritz.doll@googlemail.com>
@@ -1221,7 +1221,7 @@ theorem liftRel_congr {R : α → β → Prop} {ca ca' : Computation α} {cb cb'
and_congr
(forall_congr' fun _ => imp_congr (ha _) <| exists_congr fun _ => and_congr (hb _) Iff.rfl)
(forall_congr' fun _ => imp_congr (hb _) <| exists_congr fun _ => and_congr (ha _) Iff.rfl)
-#align computation.lift_rel_congr Computation.liftRel_congr
+#align computation.lift_gcongr Computation.liftRel_congr
theorem liftRel_map {δ} (R : α → β → Prop) (S : γ → δ → Prop) {s1 : Computation α}
{s2 : Computation β} {f1 : α → γ} {f2 : β → δ} (h1 : LiftRel R s1 s2)
I ran codespell Mathlib
and got tired halfway through the suggestions.
@@ -1241,7 +1241,7 @@ theorem map_congr {s1 s2 : Computation α} {f : α → β}
exact liftRel_map Eq _ ((lift_eq_iff_equiv _ _).2 h1) fun {a} b => congr_arg _
#align computation.map_congr Computation.map_congr
-/-- Alternate defintion of `LiftRel` over relations between `Computation`s-/
+/-- Alternate definition of `LiftRel` over relations between `Computation`s-/
def LiftRelAux (R : α → β → Prop) (C : Computation α → Computation β → Prop) :
Sum α (Computation α) → Sum β (Computation β) → Prop
| Sum.inl a, Sum.inl b => R a b
This makes a mathlib4 version of mathlib3's tactic.basic
, now called Mathlib.Tactic.Common
, which imports all tactics which do not have significant theory requirements, and then is imported all across the base of the hierarchy.
This ensures that all common tactics are available nearly everywhere in the library, rather than having to be imported one-by-one as you need them.
Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
@@ -11,7 +11,7 @@ Coinductive formalization of unbounded computations.
! if you have ported upstream changes.
-/
import Mathlib.Data.Stream.Init
-import Mathlib.Tactic.Basic
+import Mathlib.Tactic.Common
/-!
# Coinductive formalization of unbounded computations.
@@ -11,7 +11,7 @@ Coinductive formalization of unbounded computations.
! if you have ported upstream changes.
-/
import Mathlib.Data.Stream.Init
-import Mathlib.Tactic.Common
+import Mathlib.Tactic.Basic
/-!
# Coinductive formalization of unbounded computations.
@@ -11,7 +11,7 @@ Coinductive formalization of unbounded computations.
! if you have ported upstream changes.
-/
import Mathlib.Data.Stream.Init
-import Mathlib.Tactic.Basic
+import Mathlib.Tactic.Common
/-!
# Coinductive formalization of unbounded computations.
This marks many existing lemmas for Stream'
as simp, and adds a few new ones. Notably, I've removed the simp attribute from take_succ
because that lemma can result in huge goal states (since it duplicates the stream).
@@ -178,7 +178,7 @@ theorem tail_pure (a : α) : tail (pure a) = pure a :=
@[simp]
theorem tail_think (s : Computation α) : tail (think s) = s := by
- cases' s with f al ; apply Subtype.eq ; dsimp [tail, think] ; rw [Stream'.tail_cons]
+ cases' s with f al ; apply Subtype.eq ; dsimp [tail, think]
#align computation.tail_think Computation.tail_think
@[simp]
@@ -719,7 +719,6 @@ theorem map_id : ∀ s : Computation α, map id s = s
theorem map_comp (f : α → β) (g : β → γ) : ∀ s : Computation α, map (g ∘ f) s = map g (map f s)
| ⟨s, al⟩ => by
apply Subtype.eq ; dsimp [map]
- rw [Stream'.map_map]
apply congr_arg fun f : _ → Option γ => Stream'.map f s
ext ⟨⟩ <;> rfl
#align computation.map_comp Computation.map_comp
@@ -436,7 +436,7 @@ def Promises (s : Computation α) (a : α) : Prop :=
-- mathport name: «expr ~> »
/-- `Promises s a`, or `s ~> a`, asserts that although the computation `s`
may not terminate, if it does, then the result is `a`. -/
-infixl:50 " ~> " => Promises
+scoped infixl:50 " ~> " => Promises
theorem mem_promises {s : Computation α} {a : α} : a ∈ s → s ~> a := fun h _ => mem_unique h
#align computation.mem_promises Computation.mem_promises
@@ -983,7 +983,7 @@ def Equiv (c₁ c₂ : Computation α) : Prop :=
-- mathport name: «expr ~ »
/-- equivalence relation for computations-/
-infixl:50 " ~ " => Equiv
+scoped infixl:50 " ~ " => Equiv
@[refl]
theorem Equiv.refl (s : Computation α) : s ~ s := fun _ => Iff.rfl
Implements a linter for lean 3 declarations containing capital letters (as suggested on Zulip).
Co-authored-by: Mario Carneiro <di.gama@gmail.com>
@@ -67,6 +67,7 @@ def think (c : Computation α) : Computation α :=
def thinkN (c : Computation α) : ℕ → Computation α
| 0 => c
| n + 1 => think (thinkN c n)
+set_option linter.uppercaseLean3 false in
#align computation.thinkN Computation.thinkN
-- check for immediate result
@@ -210,6 +211,7 @@ def Corec.f (f : β → Sum α β) : Sum α β → Option α × Sum α β
| Sum.inl a => some a
| Sum.inr _ => none,
f b)
+set_option linter.uppercaseLean3 false in
#align computation.corec.F Computation.Corec.f
/-- `corec f b` is the corecursor for `Computation α` as a coinductive type.
@@ -412,14 +414,17 @@ theorem eq_empty_of_not_terminates {s} (H : ¬Terminates s) : s = empty α := by
theorem thinkN_mem {s : Computation α} {a} : ∀ n, a ∈ thinkN s n ↔ a ∈ s
| 0 => Iff.rfl
| n + 1 => Iff.trans ⟨of_think_mem, think_mem⟩ (thinkN_mem n)
+set_option linter.uppercaseLean3 false in
#align computation.thinkN_mem Computation.thinkN_mem
instance thinkN_terminates (s : Computation α) : ∀ [Terminates s] (n), Terminates (thinkN s n)
| ⟨⟨a, h⟩⟩, n => ⟨⟨a, (thinkN_mem n).2 h⟩⟩
+set_option linter.uppercaseLean3 false in
#align computation.thinkN_terminates Computation.thinkN_terminates
theorem of_thinkN_terminates (s : Computation α) (n) : Terminates (thinkN s n) → Terminates s
| ⟨⟨a, h⟩⟩ => ⟨⟨a, (thinkN_mem _).1 h⟩⟩
+set_option linter.uppercaseLean3 false in
#align computation.of_thinkN_terminates Computation.of_thinkN_terminates
/-- `Promises s a`, or `s ~> a`, asserts that although the computation `s`
@@ -477,6 +482,7 @@ theorem get_think : get (think s) = get s :=
@[simp]
theorem get_thinkN (n) : get (thinkN s n) = get s :=
get_eq_of_mem _ <| (thinkN_mem _).2 (get_mem _)
+set_option linter.uppercaseLean3 false in
#align computation.get_thinkN Computation.get_thinkN
theorem get_promises : s ~> get s := fun _ => get_eq_of_mem _
@@ -587,16 +593,19 @@ theorem results_thinkN {s : Computation α} {a m} :
∀ n, Results s a m → Results (thinkN s n) a (m + n)
| 0, h => h
| n + 1, h => results_think (results_thinkN n h)
+set_option linter.uppercaseLean3 false in
#align computation.results_thinkN Computation.results_thinkN
theorem results_thinkN_pure (a : α) (n) : Results (thinkN (pure a) n) a n := by
have := results_thinkN n (results_pure a) ; rwa [Nat.zero_add] at this
+set_option linter.uppercaseLean3 false in
#align computation.results_thinkN_ret Computation.results_thinkN_pure
@[simp]
theorem length_thinkN (s : Computation α) [_h : Terminates s] (n) :
length (thinkN s n) = length s + n :=
(results_thinkN n (results_of_terminates _)).length
+set_option linter.uppercaseLean3 false in
#align computation.length_thinkN Computation.length_thinkN
theorem eq_thinkN {s : Computation α} {a n} (h : Results s a n) : s = thinkN (pure a) n := by
@@ -611,11 +620,13 @@ theorem eq_thinkN {s : Computation α} {a n} (h : Results s a n) : s = thinkN (p
contradiction
· rw [IH (results_think_iff.1 h)]
rfl
+set_option linter.uppercaseLean3 false in
#align computation.eq_thinkN Computation.eq_thinkN
theorem eq_thinkN' (s : Computation α) [_h : Terminates s] :
s = thinkN (pure (get s)) (length s) :=
eq_thinkN (results_of_terminates _)
+set_option linter.uppercaseLean3 false in
#align computation.eq_thinkN' Computation.eq_thinkN'
/-- Recursor based on memberhip-/
@@ -650,6 +661,7 @@ def map (f : α → β) : Computation α → Computation β
def Bind.g : Sum β (Computation β) → Sum β (Sum (Computation α) (Computation β))
| Sum.inl b => Sum.inl b
| Sum.inr cb' => Sum.inr <| Sum.inr cb'
+set_option linter.uppercaseLean3 false in
#align computation.bind.G Computation.Bind.g
/-- bind over a function mapping `α` to a `Computation`-/
@@ -660,6 +672,7 @@ def Bind.f (f : α → Computation β) :
| Sum.inl a => Bind.g <| destruct (f a)
| Sum.inr ca' => Sum.inr <| Sum.inl ca'
| Sum.inr cb => Bind.g <| destruct cb
+set_option linter.uppercaseLean3 false in
#align computation.bind.F Computation.Bind.f
/-- Compose two computations into a monadic `bind` operation. -/
@@ -1010,6 +1023,7 @@ theorem think_equiv (s : Computation α) : think s ~ s := fun _ => ⟨of_think_m
#align computation.think_equiv Computation.think_equiv
theorem thinkN_equiv (s : Computation α) (n) : thinkN s n ~ s := fun _ => thinkN_mem n
+set_option linter.uppercaseLean3 false in
#align computation.thinkN_equiv Computation.thinkN_equiv
theorem bind_congr {s1 s2 : Computation α} {f1 f2 : α → Computation β} (h1 : s1 ~ s2)
All dependencies are ported!