data.seq.parallel
⟷
Mathlib.Data.Seq.Parallel
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)
(last sync)
mathlib commit https://github.com/leanprover-community/mathlib/commit/65a1391a0106c9204fe45bc73a039f056558cb83
@@ -10,7 +10,7 @@ terminates_parallel and exists_of_mem_parallel.
(This operation is nondeterministic in the sense that it does not
honor sequence equivalence (irrelevance of computation time).)
-/
-import Data.Seq.Wseq
+import Data.Seq.WSeq
#align_import data.seq.parallel from "leanprover-community/mathlib"@"a7e36e48519ab281320c4d192da6a7b348ce40ad"
mathlib commit https://github.com/leanprover-community/mathlib/commit/65a1391a0106c9204fe45bc73a039f056558cb83
@@ -73,29 +73,29 @@ theorem terminates_parallel.aux :
intro l S c m T; revert l S
apply @terminates_rec_on _ _ c T _ _
· intro a l S m; apply lem1
- induction' l with c l IH generalizing m <;> simp at m ; · contradiction
+ induction' l with c l IH generalizing m <;> simp at m; · contradiction
cases' m with e m
· rw [← e]; simp [parallel.aux2]
cases' List.foldr parallel.aux2._match_1 (Sum.inr List.nil) l with a' ls
exacts [⟨a', rfl⟩, ⟨a, rfl⟩]
· cases' IH m with a' e
- simp [parallel.aux2]; simp [parallel.aux2] at e
+ simp [parallel.aux2]; simp [parallel.aux2] at e
rw [e]; exact ⟨a', rfl⟩
· intro s IH l S m
have H1 : ∀ l', parallel.aux2 l = Sum.inr l' → s ∈ l' :=
by
- induction' l with c l IH' generalizing m <;> intro l' e' <;> simp at m
+ induction' l with c l IH' generalizing m <;> intro l' e' <;> simp at m
· contradiction
- cases' m with e m <;> simp [parallel.aux2] at e'
- · rw [← e] at e'
+ cases' m with e m <;> simp [parallel.aux2] at e'
+ · rw [← e] at e'
cases' List.foldr parallel.aux2._match_1 (Sum.inr List.nil) l with a' ls <;>
injection e' with e'
rw [← e']; simp
· induction' e : List.foldr parallel.aux2._match_1 (Sum.inr List.nil) l with a' ls <;>
- rw [e] at e'
+ rw [e] at e'
· contradiction
have := IH' m _ e
- simp [parallel.aux2] at e'
+ simp [parallel.aux2] at e'
cases destruct c <;> injection e' with h'
rw [← h']; simp [this]
induction' h : parallel.aux2 l with a l'
@@ -142,7 +142,7 @@ theorem terminates_parallel {S : WSeq (Computation α)} {c} (h : c ∈ S) [T : T
induction' e : seq.nth S 0 with o
· have D : seq.destruct S = none := by dsimp [seq.destruct]; rw [e]; rfl
rw [D]; simp [parallel.aux1]; have TT := TT l'
- rwa [seq.destruct_eq_nil D, seq.tail_nil] at TT
+ rwa [seq.destruct_eq_nil D, seq.tail_nil] at TT
· have D : seq.destruct S = some (o, S.tail) := by dsimp [seq.destruct]; rw [e]; rfl
rw [D]; cases' o with c <;> simp [parallel.aux1, TT]
#align computation.terminates_parallel Computation.terminates_parallel
@@ -170,7 +170,7 @@ theorem exists_of_mem_parallel {S : WSeq (Computation α)} {a} (h : a ∈ parall
intro l; induction' l with c l IH <;> simp [parallel.aux2]
· intro a h; rcases h with ⟨c, hn, _⟩
exact False.elim hn
- · simp [parallel.aux2] at IH
+ · simp [parallel.aux2] at IH
cases' List.foldr parallel.aux2._match_1 (Sum.inr List.nil) l with a ls <;>
simp [parallel.aux2]
· rcases IH with ⟨c', cl, ac⟩
@@ -180,8 +180,8 @@ theorem exists_of_mem_parallel {S : WSeq (Computation α)} {a} (h : a ∈ parall
rw [destruct_eq_ret h]
apply ret_mem
· intro a' h; rcases h with ⟨d, dm, ad⟩
- simp at dm ; cases' dm with e dl
- · rw [e] at ad ; refine' ⟨c, List.mem_cons_self _ _, _⟩
+ simp at dm; cases' dm with e dl
+ · rw [e] at ad; refine' ⟨c, List.mem_cons_self _ _, _⟩
rw [destruct_eq_think h]
exact think_mem ad
· cases' IH a' ⟨d, dl, ad⟩ with d dm; cases' dm with dm ad
@@ -189,19 +189,19 @@ theorem exists_of_mem_parallel {S : WSeq (Computation α)} {a} (h : a ∈ parall
intro C aC;
refine' mem_rec_on aC _ fun C' IH => _ <;> intro l S e <;> have e' := congr_arg destruct e <;>
have := lem1 l <;>
- simp [parallel.aux1] at e' <;>
+ simp [parallel.aux1] at e' <;>
cases' parallel.aux2 l with a' l' <;>
injection e' with h'
- · rw [h'] at this ; rcases this with ⟨c, cl, ac⟩
+ · rw [h'] at this; rcases this with ⟨c, cl, ac⟩
exact ⟨c, Or.inl cl, ac⟩
- · induction' e : seq.destruct S with a <;> rw [e] at h'
+ · induction' e : seq.destruct S with a <;> rw [e] at h'
·
exact
let ⟨d, o, ad⟩ := IH _ _ h'
let ⟨c, cl, ac⟩ := this a ⟨d, o.resolve_right (wseq.not_mem_nil _), ad⟩
⟨c, Or.inl cl, ac⟩
· cases' a with o S';
- cases' o with c <;> simp [parallel.aux1] at h' <;> rcases IH _ _ h' with ⟨d, dl | dS', ad⟩
+ cases' o with c <;> simp [parallel.aux1] at h' <;> rcases IH _ _ h' with ⟨d, dl | dS', ad⟩
·
exact
let ⟨c, cl, ac⟩ := this a ⟨d, dl, ad⟩
@@ -209,8 +209,8 @@ theorem exists_of_mem_parallel {S : WSeq (Computation α)} {a} (h : a ∈ parall
· refine' ⟨d, Or.inr _, ad⟩
rw [seq.destruct_eq_cons e]
exact seq.mem_cons_of_mem _ dS'
- · simp at dl ; cases' dl with dc dl
- · rw [dc] at ad ; refine' ⟨c, Or.inr _, ad⟩
+ · simp at dl; cases' dl with dc dl
+ · rw [dc] at ad; refine' ⟨c, Or.inr _, ad⟩
rw [seq.destruct_eq_cons e]
apply seq.mem_cons
·
@@ -271,18 +271,18 @@ def parallelRec {S : WSeq (Computation α)} (C : α → Sort v) (H : ∀ s ∈ S
by
rw [← wseq.map_comp]; refine' (wseq.map_id _).symm.trans (congr_arg (fun f => wseq.map f S) _)
funext c; dsimp [id, Function.comp]; rw [← map_comp]; exact (map_id _).symm
- have pe := congr_arg parallel this; rw [← map_parallel] at pe
- have h' := h; rw [pe] at h'
+ have pe := congr_arg parallel this; rw [← map_parallel] at pe
+ have h' := h; rw [pe] at h'
haveI : terminates (parallel T) := (terminates_map_iff _ _).1 ⟨⟨_, h'⟩⟩
induction' e : get (parallel T) with a' c
have : a ∈ c ∧ c ∈ S := by
rcases exists_of_mem_map h' with ⟨d, dT, cd⟩
- rw [get_eq_of_mem _ dT] at e ; cases e; dsimp at cd ; cases cd
+ rw [get_eq_of_mem _ dT] at e; cases e; dsimp at cd; cases cd
rcases exists_of_mem_parallel dT with ⟨d', dT', ad'⟩
rcases wseq.exists_of_mem_map dT' with ⟨c', cs', e'⟩
- rw [← e'] at ad'
+ rw [← e'] at ad'
rcases exists_of_mem_map ad' with ⟨a', ac', e'⟩; injection e' with i1 i2
- constructor; rwa [i1, i2] at ac' ; rwa [i2] at cs'
+ constructor; rwa [i1, i2] at ac'; rwa [i2] at cs'
cases' this with ac cs; apply H _ cs _ ac
#align computation.parallel_rec Computation.parallelRec
-/
@@ -323,14 +323,14 @@ theorem parallel_congr_left {S T : WSeq (Computation α)} {a} (h1 : ∀ s ∈ S,
let h2 := (parallel_congr_lem H).1 h1
fun a' =>
⟨fun h => by
- have aa := parallel_promises h1 h <;> rw [← aa] <;> rw [← aa] at h <;>
+ have aa := parallel_promises h1 h <;> rw [← aa] <;> rw [← aa] at h <;>
exact
let ⟨s, sS, as⟩ := exists_of_mem_parallel h
let ⟨t, tT, st⟩ := wseq.exists_of_lift_rel_left H sS
let aT := (st _).1 as
mem_parallel h2 tT aT,
fun h => by
- have aa := parallel_promises h2 h <;> rw [← aa] <;> rw [← aa] at h <;>
+ have aa := parallel_promises h2 h <;> rw [← aa] <;> rw [← aa] at h <;>
exact
let ⟨s, sS, as⟩ := exists_of_mem_parallel h
let ⟨t, tT, st⟩ := wseq.exists_of_lift_rel_right H sS
mathlib commit https://github.com/leanprover-community/mathlib/commit/ce64cd319bb6b3e82f31c2d38e79080d377be451
@@ -10,7 +10,7 @@ terminates_parallel and exists_of_mem_parallel.
(This operation is nondeterministic in the sense that it does not
honor sequence equivalence (irrelevance of computation time).)
-/
-import Mathbin.Data.Seq.Wseq
+import Data.Seq.Wseq
#align_import data.seq.parallel from "leanprover-community/mathlib"@"a7e36e48519ab281320c4d192da6a7b348ce40ad"
mathlib commit https://github.com/leanprover-community/mathlib/commit/8ea5598db6caeddde6cb734aa179cc2408dbd345
@@ -9,14 +9,11 @@ The important theorems of this operation are proven as
terminates_parallel and exists_of_mem_parallel.
(This operation is nondeterministic in the sense that it does not
honor sequence equivalence (irrelevance of computation time).)
-
-! This file was ported from Lean 3 source module data.seq.parallel
-! leanprover-community/mathlib commit a7e36e48519ab281320c4d192da6a7b348ce40ad
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
-/
import Mathbin.Data.Seq.Wseq
+#align_import data.seq.parallel from "leanprover-community/mathlib"@"a7e36e48519ab281320c4d192da6a7b348ce40ad"
+
universe u v
namespace Computation
mathlib commit https://github.com/leanprover-community/mathlib/commit/9fb8964792b4237dac6200193a0d533f1b3f7423
@@ -151,6 +151,7 @@ theorem terminates_parallel {S : WSeq (Computation α)} {c} (h : c ∈ S) [T : T
#align computation.terminates_parallel Computation.terminates_parallel
-/
+#print Computation.exists_of_mem_parallel /-
theorem exists_of_mem_parallel {S : WSeq (Computation α)} {a} (h : a ∈ parallel S) :
∃ c ∈ S, a ∈ c :=
by
@@ -223,6 +224,7 @@ theorem exists_of_mem_parallel {S : WSeq (Computation α)} {a} (h : a ∈ parall
rw [seq.destruct_eq_cons e]
exact seq.mem_cons_of_mem _ dS'
#align computation.exists_of_mem_parallel Computation.exists_of_mem_parallel
+-/
#print Computation.map_parallel /-
theorem map_parallel (f : α → β) (S) : map f (parallel S) = parallel (S.map (map f)) :=
mathlib commit https://github.com/leanprover-community/mathlib/commit/5f25c089cb34db4db112556f23c50d12da81b297
@@ -21,8 +21,8 @@ universe u v
namespace Computation
-/- ./././Mathport/Syntax/Translate/Command.lean:229:11: unsupported: unusual advanced open style -/
-/- ./././Mathport/Syntax/Translate/Command.lean:229:11: unsupported: unusual advanced open style -/
+/- ./././Mathport/Syntax/Translate/Command.lean:230:11: unsupported: unusual advanced open style -/
+/- ./././Mathport/Syntax/Translate/Command.lean:230:11: unsupported: unusual advanced open style -/
variable {α : Type u} {β : Type v}
/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
mathlib commit https://github.com/leanprover-community/mathlib/commit/cca40788df1b8755d5baf17ab2f27dacc2e17acb
@@ -76,29 +76,29 @@ theorem terminates_parallel.aux :
intro l S c m T; revert l S
apply @terminates_rec_on _ _ c T _ _
· intro a l S m; apply lem1
- induction' l with c l IH generalizing m <;> simp at m; · contradiction
+ induction' l with c l IH generalizing m <;> simp at m ; · contradiction
cases' m with e m
· rw [← e]; simp [parallel.aux2]
cases' List.foldr parallel.aux2._match_1 (Sum.inr List.nil) l with a' ls
- exacts[⟨a', rfl⟩, ⟨a, rfl⟩]
+ exacts [⟨a', rfl⟩, ⟨a, rfl⟩]
· cases' IH m with a' e
- simp [parallel.aux2]; simp [parallel.aux2] at e
+ simp [parallel.aux2]; simp [parallel.aux2] at e
rw [e]; exact ⟨a', rfl⟩
· intro s IH l S m
have H1 : ∀ l', parallel.aux2 l = Sum.inr l' → s ∈ l' :=
by
- induction' l with c l IH' generalizing m <;> intro l' e' <;> simp at m
+ induction' l with c l IH' generalizing m <;> intro l' e' <;> simp at m
· contradiction
- cases' m with e m <;> simp [parallel.aux2] at e'
- · rw [← e] at e'
+ cases' m with e m <;> simp [parallel.aux2] at e'
+ · rw [← e] at e'
cases' List.foldr parallel.aux2._match_1 (Sum.inr List.nil) l with a' ls <;>
injection e' with e'
rw [← e']; simp
· induction' e : List.foldr parallel.aux2._match_1 (Sum.inr List.nil) l with a' ls <;>
- rw [e] at e'
+ rw [e] at e'
· contradiction
have := IH' m _ e
- simp [parallel.aux2] at e'
+ simp [parallel.aux2] at e'
cases destruct c <;> injection e' with h'
rw [← h']; simp [this]
induction' h : parallel.aux2 l with a l'
@@ -140,12 +140,12 @@ theorem terminates_parallel {S : WSeq (Computation α)} {c} (h : c ∈ S) [T : T
· rw [C]; skip; infer_instance
· apply destruct_eq_think; simp [parallel.aux1]; rw [h]; simp [rmap]
· rw [C]; apply @Computation.think_terminates _ _ _
- have TT : ∀ l', terminates (corec parallel.aux1 (l', S.tail)) := by intro ;
+ have TT : ∀ l', terminates (corec parallel.aux1 (l', S.tail)) := by intro;
apply IH _ _ _ (Or.inr _) T; rw [a]; cases' S with f al; rfl
induction' e : seq.nth S 0 with o
· have D : seq.destruct S = none := by dsimp [seq.destruct]; rw [e]; rfl
rw [D]; simp [parallel.aux1]; have TT := TT l'
- rwa [seq.destruct_eq_nil D, seq.tail_nil] at TT
+ rwa [seq.destruct_eq_nil D, seq.tail_nil] at TT
· have D : seq.destruct S = some (o, S.tail) := by dsimp [seq.destruct]; rw [e]; rfl
rw [D]; cases' o with c <;> simp [parallel.aux1, TT]
#align computation.terminates_parallel Computation.terminates_parallel
@@ -172,7 +172,7 @@ theorem exists_of_mem_parallel {S : WSeq (Computation α)} {a} (h : a ∈ parall
intro l; induction' l with c l IH <;> simp [parallel.aux2]
· intro a h; rcases h with ⟨c, hn, _⟩
exact False.elim hn
- · simp [parallel.aux2] at IH
+ · simp [parallel.aux2] at IH
cases' List.foldr parallel.aux2._match_1 (Sum.inr List.nil) l with a ls <;>
simp [parallel.aux2]
· rcases IH with ⟨c', cl, ac⟩
@@ -182,8 +182,8 @@ theorem exists_of_mem_parallel {S : WSeq (Computation α)} {a} (h : a ∈ parall
rw [destruct_eq_ret h]
apply ret_mem
· intro a' h; rcases h with ⟨d, dm, ad⟩
- simp at dm; cases' dm with e dl
- · rw [e] at ad; refine' ⟨c, List.mem_cons_self _ _, _⟩
+ simp at dm ; cases' dm with e dl
+ · rw [e] at ad ; refine' ⟨c, List.mem_cons_self _ _, _⟩
rw [destruct_eq_think h]
exact think_mem ad
· cases' IH a' ⟨d, dl, ad⟩ with d dm; cases' dm with dm ad
@@ -191,19 +191,19 @@ theorem exists_of_mem_parallel {S : WSeq (Computation α)} {a} (h : a ∈ parall
intro C aC;
refine' mem_rec_on aC _ fun C' IH => _ <;> intro l S e <;> have e' := congr_arg destruct e <;>
have := lem1 l <;>
- simp [parallel.aux1] at e' <;>
+ simp [parallel.aux1] at e' <;>
cases' parallel.aux2 l with a' l' <;>
injection e' with h'
- · rw [h'] at this; rcases this with ⟨c, cl, ac⟩
+ · rw [h'] at this ; rcases this with ⟨c, cl, ac⟩
exact ⟨c, Or.inl cl, ac⟩
- · induction' e : seq.destruct S with a <;> rw [e] at h'
+ · induction' e : seq.destruct S with a <;> rw [e] at h'
·
exact
let ⟨d, o, ad⟩ := IH _ _ h'
let ⟨c, cl, ac⟩ := this a ⟨d, o.resolve_right (wseq.not_mem_nil _), ad⟩
⟨c, Or.inl cl, ac⟩
· cases' a with o S';
- cases' o with c <;> simp [parallel.aux1] at h' <;> rcases IH _ _ h' with ⟨d, dl | dS', ad⟩
+ cases' o with c <;> simp [parallel.aux1] at h' <;> rcases IH _ _ h' with ⟨d, dl | dS', ad⟩
·
exact
let ⟨c, cl, ac⟩ := this a ⟨d, dl, ad⟩
@@ -211,8 +211,8 @@ theorem exists_of_mem_parallel {S : WSeq (Computation α)} {a} (h : a ∈ parall
· refine' ⟨d, Or.inr _, ad⟩
rw [seq.destruct_eq_cons e]
exact seq.mem_cons_of_mem _ dS'
- · simp at dl; cases' dl with dc dl
- · rw [dc] at ad; refine' ⟨c, Or.inr _, ad⟩
+ · simp at dl ; cases' dl with dc dl
+ · rw [dc] at ad ; refine' ⟨c, Or.inr _, ad⟩
rw [seq.destruct_eq_cons e]
apply seq.mem_cons
·
@@ -272,18 +272,18 @@ def parallelRec {S : WSeq (Computation α)} (C : α → Sort v) (H : ∀ s ∈ S
by
rw [← wseq.map_comp]; refine' (wseq.map_id _).symm.trans (congr_arg (fun f => wseq.map f S) _)
funext c; dsimp [id, Function.comp]; rw [← map_comp]; exact (map_id _).symm
- have pe := congr_arg parallel this; rw [← map_parallel] at pe
- have h' := h; rw [pe] at h'
+ have pe := congr_arg parallel this; rw [← map_parallel] at pe
+ have h' := h; rw [pe] at h'
haveI : terminates (parallel T) := (terminates_map_iff _ _).1 ⟨⟨_, h'⟩⟩
induction' e : get (parallel T) with a' c
have : a ∈ c ∧ c ∈ S := by
rcases exists_of_mem_map h' with ⟨d, dT, cd⟩
- rw [get_eq_of_mem _ dT] at e; cases e; dsimp at cd; cases cd
+ rw [get_eq_of_mem _ dT] at e ; cases e; dsimp at cd ; cases cd
rcases exists_of_mem_parallel dT with ⟨d', dT', ad'⟩
rcases wseq.exists_of_mem_map dT' with ⟨c', cs', e'⟩
- rw [← e'] at ad'
+ rw [← e'] at ad'
rcases exists_of_mem_map ad' with ⟨a', ac', e'⟩; injection e' with i1 i2
- constructor; rwa [i1, i2] at ac'; rwa [i2] at cs'
+ constructor; rwa [i1, i2] at ac' ; rwa [i2] at cs'
cases' this with ac cs; apply H _ cs _ ac
#align computation.parallel_rec Computation.parallelRec
-/
@@ -324,14 +324,14 @@ theorem parallel_congr_left {S T : WSeq (Computation α)} {a} (h1 : ∀ s ∈ S,
let h2 := (parallel_congr_lem H).1 h1
fun a' =>
⟨fun h => by
- have aa := parallel_promises h1 h <;> rw [← aa] <;> rw [← aa] at h <;>
+ have aa := parallel_promises h1 h <;> rw [← aa] <;> rw [← aa] at h <;>
exact
let ⟨s, sS, as⟩ := exists_of_mem_parallel h
let ⟨t, tT, st⟩ := wseq.exists_of_lift_rel_left H sS
let aT := (st _).1 as
mem_parallel h2 tT aT,
fun h => by
- have aa := parallel_promises h2 h <;> rw [← aa] <;> rw [← aa] at h <;>
+ have aa := parallel_promises h2 h <;> rw [← aa] <;> rw [← aa] at h <;>
exact
let ⟨s, sS, as⟩ := exists_of_mem_parallel h
let ⟨t, tT, st⟩ := wseq.exists_of_lift_rel_right H sS
mathlib commit https://github.com/leanprover-community/mathlib/commit/917c3c072e487b3cccdbfeff17e75b40e45f66cb
@@ -151,12 +151,6 @@ theorem terminates_parallel {S : WSeq (Computation α)} {c} (h : c ∈ S) [T : T
#align computation.terminates_parallel Computation.terminates_parallel
-/
-/- warning: computation.exists_of_mem_parallel -> Computation.exists_of_mem_parallel is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}} {S : Stream'.WSeq.{u1} (Computation.{u1} α)} {a : α}, (Membership.Mem.{u1, u1} α (Computation.{u1} α) (Computation.hasMem.{u1} α) a (Computation.parallel.{u1} α S)) -> (Exists.{succ u1} (Computation.{u1} α) (fun (c : Computation.{u1} α) => Exists.{0} (Membership.Mem.{u1, u1} (Computation.{u1} α) (Stream'.WSeq.{u1} (Computation.{u1} α)) (Stream'.WSeq.membership.{u1} (Computation.{u1} α)) c S) (fun (H : Membership.Mem.{u1, u1} (Computation.{u1} α) (Stream'.WSeq.{u1} (Computation.{u1} α)) (Stream'.WSeq.membership.{u1} (Computation.{u1} α)) c S) => Membership.Mem.{u1, u1} α (Computation.{u1} α) (Computation.hasMem.{u1} α) a c)))
-but is expected to have type
- forall {α : Type.{u1}} {S : Stream'.WSeq.{u1} (Computation.{u1} α)} {a : α}, (Membership.mem.{u1, u1} α (Computation.{u1} α) (Computation.instMembershipComputation.{u1} α) a (Computation.parallel.{u1} α S)) -> (Exists.{succ u1} (Computation.{u1} α) (fun (c : Computation.{u1} α) => And (Membership.mem.{u1, u1} (Computation.{u1} α) (Stream'.WSeq.{u1} (Computation.{u1} α)) (Stream'.WSeq.membership.{u1} (Computation.{u1} α)) c S) (Membership.mem.{u1, u1} α (Computation.{u1} α) (Computation.instMembershipComputation.{u1} α) a c)))
-Case conversion may be inaccurate. Consider using '#align computation.exists_of_mem_parallel Computation.exists_of_mem_parallelₓ'. -/
theorem exists_of_mem_parallel {S : WSeq (Computation α)} {a} (h : a ∈ parallel S) :
∃ c ∈ S, a ∈ c :=
by
mathlib commit https://github.com/leanprover-community/mathlib/commit/917c3c072e487b3cccdbfeff17e75b40e45f66cb
@@ -69,33 +69,21 @@ theorem terminates_parallel.aux :
have lem1 :
∀ l S, (∃ a : α, parallel.aux2 l = Sum.inl a) → terminates (corec parallel.aux1 (l, S)) :=
by
- intro l S e
- cases' e with a e
- have : corec parallel.aux1 (l, S) = return a :=
- by
- apply destruct_eq_ret
- simp [parallel.aux1]
- rw [e]
- simp [rmap]
- rw [this]
- infer_instance
- intro l S c m T
- revert l S
+ intro l S e; cases' e with a e
+ have : corec parallel.aux1 (l, S) = return a := by apply destruct_eq_ret; simp [parallel.aux1];
+ rw [e]; simp [rmap]
+ rw [this]; infer_instance
+ intro l S c m T; revert l S
apply @terminates_rec_on _ _ c T _ _
- · intro a l S m
- apply lem1
- induction' l with c l IH generalizing m <;> simp at m
- · contradiction
+ · intro a l S m; apply lem1
+ induction' l with c l IH generalizing m <;> simp at m; · contradiction
cases' m with e m
- · rw [← e]
- simp [parallel.aux2]
+ · rw [← e]; simp [parallel.aux2]
cases' List.foldr parallel.aux2._match_1 (Sum.inr List.nil) l with a' ls
exacts[⟨a', rfl⟩, ⟨a, rfl⟩]
· cases' IH m with a' e
- simp [parallel.aux2]
- simp [parallel.aux2] at e
- rw [e]
- exact ⟨a', rfl⟩
+ simp [parallel.aux2]; simp [parallel.aux2] at e
+ rw [e]; exact ⟨a', rfl⟩
· intro s IH l S m
have H1 : ∀ l', parallel.aux2 l = Sum.inr l' → s ∈ l' :=
by
@@ -105,26 +93,22 @@ theorem terminates_parallel.aux :
· rw [← e] at e'
cases' List.foldr parallel.aux2._match_1 (Sum.inr List.nil) l with a' ls <;>
injection e' with e'
- rw [← e']
- simp
+ rw [← e']; simp
· induction' e : List.foldr parallel.aux2._match_1 (Sum.inr List.nil) l with a' ls <;>
rw [e] at e'
· contradiction
have := IH' m _ e
simp [parallel.aux2] at e'
cases destruct c <;> injection e' with h'
- rw [← h']
- simp [this]
+ rw [← h']; simp [this]
induction' h : parallel.aux2 l with a l'
· exact lem1 _ _ ⟨a, h⟩
· have H2 : corec parallel.aux1 (l, S) = think _ :=
by
apply destruct_eq_think
simp [parallel.aux1]
- rw [h]
- simp [rmap]
- rw [H2]
- apply @Computation.think_terminates _ _ _
+ rw [h]; simp [rmap]
+ rw [H2]; apply @Computation.think_terminates _ _ _
have := H1 _ h
rcases seq.destruct S with (_ | ⟨_ | c, S'⟩) <;> simp [parallel.aux1] <;> apply IH <;>
simp [this]
@@ -142,68 +126,28 @@ theorem terminates_parallel {S : WSeq (Computation α)} {c} (h : c ∈ S) [T : T
let ⟨n, h⟩ := h
this n [] S c (Or.inr h) T
intro n; induction' n with n IH <;> intro l S c o T
- · cases' o with a a
- · exact terminates_parallel.aux a T
- have H : seq.destruct S = some (some c, _) :=
- by
- unfold seq.destruct Functor.map
- rw [← a]
- simp
+ · cases' o with a a; · exact terminates_parallel.aux a T
+ have H : seq.destruct S = some (some c, _) := by unfold seq.destruct Functor.map; rw [← a]; simp
induction' h : parallel.aux2 l with a l' <;> have C : corec parallel.aux1 (l, S) = _
- · apply destruct_eq_ret
- simp [parallel.aux1]
- rw [h]
- simp [rmap]
- · rw [C]
- skip
- infer_instance
- · apply destruct_eq_think
- simp [parallel.aux1]
- rw [h, H]
- simp [rmap]
- · rw [C]
- apply @Computation.think_terminates _ _ _
- apply terminates_parallel.aux _ T
- simp
- · cases' o with a a
- · exact terminates_parallel.aux a T
+ · apply destruct_eq_ret; simp [parallel.aux1]; rw [h]; simp [rmap]
+ · rw [C]; skip; infer_instance
+ · apply destruct_eq_think; simp [parallel.aux1]; rw [h, H]; simp [rmap]
+ · rw [C]; apply @Computation.think_terminates _ _ _
+ apply terminates_parallel.aux _ T; simp
+ · cases' o with a a; · exact terminates_parallel.aux a T
induction' h : parallel.aux2 l with a l' <;> have C : corec parallel.aux1 (l, S) = _
- · apply destruct_eq_ret
- simp [parallel.aux1]
- rw [h]
- simp [rmap]
- · rw [C]
- skip
- infer_instance
- · apply destruct_eq_think
- simp [parallel.aux1]
- rw [h]
- simp [rmap]
- · rw [C]
- apply @Computation.think_terminates _ _ _
- have TT : ∀ l', terminates (corec parallel.aux1 (l', S.tail)) :=
- by
- intro
- apply IH _ _ _ (Or.inr _) T
- rw [a]
- cases' S with f al
- rfl
+ · apply destruct_eq_ret; simp [parallel.aux1]; rw [h]; simp [rmap]
+ · rw [C]; skip; infer_instance
+ · apply destruct_eq_think; simp [parallel.aux1]; rw [h]; simp [rmap]
+ · rw [C]; apply @Computation.think_terminates _ _ _
+ have TT : ∀ l', terminates (corec parallel.aux1 (l', S.tail)) := by intro ;
+ apply IH _ _ _ (Or.inr _) T; rw [a]; cases' S with f al; rfl
induction' e : seq.nth S 0 with o
- · have D : seq.destruct S = none := by
- dsimp [seq.destruct]
- rw [e]
- rfl
- rw [D]
- simp [parallel.aux1]
- have TT := TT l'
+ · have D : seq.destruct S = none := by dsimp [seq.destruct]; rw [e]; rfl
+ rw [D]; simp [parallel.aux1]; have TT := TT l'
rwa [seq.destruct_eq_nil D, seq.tail_nil] at TT
- · have D : seq.destruct S = some (o, S.tail) :=
- by
- dsimp [seq.destruct]
- rw [e]
- rfl
- rw [D]
- cases' o with c <;> simp [parallel.aux1, TT]
+ · have D : seq.destruct S = some (o, S.tail) := by dsimp [seq.destruct]; rw [e]; rfl
+ rw [D]; cases' o with c <;> simp [parallel.aux1, TT]
#align computation.terminates_parallel Computation.terminates_parallel
-/
@@ -226,16 +170,13 @@ theorem exists_of_mem_parallel {S : WSeq (Computation α)} {a} (h : a ∈ parall
⟨c, h1.resolve_left id, h2⟩
let F : List (Computation α) → Sum α (List (Computation α)) → Prop :=
by
- intro l a
- cases' a with a l'
+ intro l a; cases' a with a l'
exact ∃ c ∈ l, a ∈ c
exact ∀ a', (∃ c ∈ l', a' ∈ c) → ∃ c ∈ l, a' ∈ c
have lem1 : ∀ l : List (Computation α), F l (parallel.aux2 l) :=
by
- intro l
- induction' l with c l IH <;> simp [parallel.aux2]
- · intro a h
- rcases h with ⟨c, hn, _⟩
+ intro l; induction' l with c l IH <;> simp [parallel.aux2]
+ · intro a h; rcases h with ⟨c, hn, _⟩
exact False.elim hn
· simp [parallel.aux2] at IH
cases' List.foldr parallel.aux2._match_1 (Sum.inr List.nil) l with a ls <;>
@@ -246,25 +187,20 @@ theorem exists_of_mem_parallel {S : WSeq (Computation α)} {a} (h : a ∈ parall
· refine' ⟨c, List.mem_cons_self _ _, _⟩
rw [destruct_eq_ret h]
apply ret_mem
- · intro a' h
- rcases h with ⟨d, dm, ad⟩
- simp at dm
- cases' dm with e dl
- · rw [e] at ad
- refine' ⟨c, List.mem_cons_self _ _, _⟩
+ · intro a' h; rcases h with ⟨d, dm, ad⟩
+ simp at dm; cases' dm with e dl
+ · rw [e] at ad; refine' ⟨c, List.mem_cons_self _ _, _⟩
rw [destruct_eq_think h]
exact think_mem ad
- · cases' IH a' ⟨d, dl, ad⟩ with d dm
- cases' dm with dm ad
+ · cases' IH a' ⟨d, dl, ad⟩ with d dm; cases' dm with dm ad
exact ⟨d, Or.inr dm, ad⟩
- intro C aC
+ intro C aC;
refine' mem_rec_on aC _ fun C' IH => _ <;> intro l S e <;> have e' := congr_arg destruct e <;>
have := lem1 l <;>
simp [parallel.aux1] at e' <;>
cases' parallel.aux2 l with a' l' <;>
injection e' with h'
- · rw [h'] at this
- rcases this with ⟨c, cl, ac⟩
+ · rw [h'] at this; rcases this with ⟨c, cl, ac⟩
exact ⟨c, Or.inl cl, ac⟩
· induction' e : seq.destruct S with a <;> rw [e] at h'
·
@@ -272,7 +208,7 @@ theorem exists_of_mem_parallel {S : WSeq (Computation α)} {a} (h : a ∈ parall
let ⟨d, o, ad⟩ := IH _ _ h'
let ⟨c, cl, ac⟩ := this a ⟨d, o.resolve_right (wseq.not_mem_nil _), ad⟩
⟨c, Or.inl cl, ac⟩
- · cases' a with o S'
+ · cases' a with o S';
cases' o with c <;> simp [parallel.aux1] at h' <;> rcases IH _ _ h' with ⟨d, dl | dS', ad⟩
·
exact
@@ -281,10 +217,8 @@ theorem exists_of_mem_parallel {S : WSeq (Computation α)} {a} (h : a ∈ parall
· refine' ⟨d, Or.inr _, ad⟩
rw [seq.destruct_eq_cons e]
exact seq.mem_cons_of_mem _ dS'
- · simp at dl
- cases' dl with dc dl
- · rw [dc] at ad
- refine' ⟨c, Or.inr _, ad⟩
+ · simp at dl; cases' dl with dc dl
+ · rw [dc] at ad; refine' ⟨c, Or.inr _, ad⟩
rw [seq.destruct_eq_cons e]
apply seq.mem_cons
·
@@ -314,13 +248,10 @@ theorem map_parallel (f : α → β) (S) : map f (parallel S) = parallel (S.map
have : parallel.aux2 (l.map (map f)) = lmap f (rmap (List.map (map f)) (parallel.aux2 l)) :=
by
simp [parallel.aux2]
- induction' l with c l IH <;> simp
- rw [IH]
+ induction' l with c l IH <;> simp; rw [IH]
cases List.foldr parallel.aux2._match_1 (Sum.inr List.nil) l <;> simp [parallel.aux2]
cases destruct c <;> simp
- simp [parallel.aux1]
- rw [this]
- cases' parallel.aux2 l with a l' <;> simp
+ simp [parallel.aux1]; rw [this]; cases' parallel.aux2 l with a l' <;> simp
apply S.rec_on _ (fun c S => _) fun S => _ <;> simp <;> simp [parallel.aux1] <;>
exact ⟨_, _, rfl, rfl⟩
#align computation.map_parallel Computation.map_parallel
@@ -345,34 +276,21 @@ def parallelRec {S : WSeq (Computation α)} (C : α → Sort v) (H : ∀ s ∈ S
let T : wseq (Computation (α × Computation α)) := S.map fun c => c.map fun a => (a, c)
have : S = T.map (map fun c => c.1) :=
by
- rw [← wseq.map_comp]
- refine' (wseq.map_id _).symm.trans (congr_arg (fun f => wseq.map f S) _)
- funext c
- dsimp [id, Function.comp]
- rw [← map_comp]
- exact (map_id _).symm
- have pe := congr_arg parallel this
- rw [← map_parallel] at pe
- have h' := h
- rw [pe] at h'
+ rw [← wseq.map_comp]; refine' (wseq.map_id _).symm.trans (congr_arg (fun f => wseq.map f S) _)
+ funext c; dsimp [id, Function.comp]; rw [← map_comp]; exact (map_id _).symm
+ have pe := congr_arg parallel this; rw [← map_parallel] at pe
+ have h' := h; rw [pe] at h'
haveI : terminates (parallel T) := (terminates_map_iff _ _).1 ⟨⟨_, h'⟩⟩
induction' e : get (parallel T) with a' c
have : a ∈ c ∧ c ∈ S := by
rcases exists_of_mem_map h' with ⟨d, dT, cd⟩
- rw [get_eq_of_mem _ dT] at e
- cases e
- dsimp at cd
- cases cd
+ rw [get_eq_of_mem _ dT] at e; cases e; dsimp at cd; cases cd
rcases exists_of_mem_parallel dT with ⟨d', dT', ad'⟩
rcases wseq.exists_of_mem_map dT' with ⟨c', cs', e'⟩
rw [← e'] at ad'
- rcases exists_of_mem_map ad' with ⟨a', ac', e'⟩
- injection e' with i1 i2
- constructor
- rwa [i1, i2] at ac'
- rwa [i2] at cs'
- cases' this with ac cs
- apply H _ cs _ ac
+ rcases exists_of_mem_map ad' with ⟨a', ac', e'⟩; injection e' with i1 i2
+ constructor; rwa [i1, i2] at ac'; rwa [i2] at cs'
+ cases' this with ac cs; apply H _ cs _ ac
#align computation.parallel_rec Computation.parallelRec
-/
mathlib commit https://github.com/leanprover-community/mathlib/commit/09079525fd01b3dda35e96adaa08d2f943e1648c
@@ -21,8 +21,8 @@ universe u v
namespace Computation
-/- ./././Mathport/Syntax/Translate/Command.lean:224:11: unsupported: unusual advanced open style -/
-/- ./././Mathport/Syntax/Translate/Command.lean:224:11: unsupported: unusual advanced open style -/
+/- ./././Mathport/Syntax/Translate/Command.lean:229:11: unsupported: unusual advanced open style -/
+/- ./././Mathport/Syntax/Translate/Command.lean:229:11: unsupported: unusual advanced open style -/
variable {α : Type u} {β : Type v}
/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
mathlib commit https://github.com/leanprover-community/mathlib/commit/730c6d4cab72b9d84fcfb9e95e8796e9cd8f40ba
@@ -26,17 +26,20 @@ namespace Computation
variable {α : Type u} {β : Type v}
/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
-def Parallel.aux2 : List (Computation α) → Sum α (List (Computation α)) :=
+#print Computation.parallel.aux2 /-
+def parallel.aux2 : List (Computation α) → Sum α (List (Computation α)) :=
List.foldr
(fun c o =>
match o with
| Sum.inl a => Sum.inl a
| Sum.inr ls => rmap (fun c' => c'::ls) (destruct c))
(Sum.inr [])
-#align computation.parallel.aux2 Computation.Parallel.aux2
+#align computation.parallel.aux2 Computation.parallel.aux2
+-/
/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
-def Parallel.aux1 :
+#print Computation.parallel.aux1 /-
+def parallel.aux1 :
List (Computation α) × WSeq (Computation α) →
Sum α (List (Computation α) × WSeq (Computation α))
| (l, S) =>
@@ -46,18 +49,22 @@ def Parallel.aux1 :
| none => (l', Seq.nil)
| some (none, S') => (l', S')
| some (some c, S') => (c::l', S'))
- (Parallel.aux2 l)
-#align computation.parallel.aux1 Computation.Parallel.aux1
+ (parallel.aux2 l)
+#align computation.parallel.aux1 Computation.parallel.aux1
+-/
+#print Computation.parallel /-
/-- Parallel computation of an infinite stream of computations,
taking the first result -/
def parallel (S : WSeq (Computation α)) : Computation α :=
- corec Parallel.aux1 ([], S)
+ corec parallel.aux1 ([], S)
#align computation.parallel Computation.parallel
+-/
-theorem TerminatesParallel.aux :
+#print Computation.terminates_parallel.aux /-
+theorem terminates_parallel.aux :
∀ {l : List (Computation α)} {S c},
- c ∈ l → Terminates c → Terminates (corec Parallel.aux1 (l, S)) :=
+ c ∈ l → Terminates c → Terminates (corec parallel.aux1 (l, S)) :=
by
have lem1 :
∀ l S, (∃ a : α, parallel.aux2 l = Sum.inl a) → terminates (corec parallel.aux1 (l, S)) :=
@@ -121,14 +128,16 @@ theorem TerminatesParallel.aux :
have := H1 _ h
rcases seq.destruct S with (_ | ⟨_ | c, S'⟩) <;> simp [parallel.aux1] <;> apply IH <;>
simp [this]
-#align computation.terminates_parallel.aux Computation.TerminatesParallel.aux
+#align computation.terminates_parallel.aux Computation.terminates_parallel.aux
+-/
+#print Computation.terminates_parallel /-
theorem terminates_parallel {S : WSeq (Computation α)} {c} (h : c ∈ S) [T : Terminates c] :
Terminates (parallel S) :=
by
suffices
∀ (n) (l : List (Computation α)) (S c),
- c ∈ l ∨ some (some c) = Seq.get? S n → Terminates c → Terminates (corec Parallel.aux1 (l, S))
+ c ∈ l ∨ some (some c) = Seq.get? S n → Terminates c → Terminates (corec parallel.aux1 (l, S))
from
let ⟨n, h⟩ := h
this n [] S c (Or.inr h) T
@@ -196,7 +205,14 @@ theorem terminates_parallel {S : WSeq (Computation α)} {c} (h : c ∈ S) [T : T
rw [D]
cases' o with c <;> simp [parallel.aux1, TT]
#align computation.terminates_parallel Computation.terminates_parallel
+-/
+/- warning: computation.exists_of_mem_parallel -> Computation.exists_of_mem_parallel is a dubious translation:
+lean 3 declaration is
+ forall {α : Type.{u1}} {S : Stream'.WSeq.{u1} (Computation.{u1} α)} {a : α}, (Membership.Mem.{u1, u1} α (Computation.{u1} α) (Computation.hasMem.{u1} α) a (Computation.parallel.{u1} α S)) -> (Exists.{succ u1} (Computation.{u1} α) (fun (c : Computation.{u1} α) => Exists.{0} (Membership.Mem.{u1, u1} (Computation.{u1} α) (Stream'.WSeq.{u1} (Computation.{u1} α)) (Stream'.WSeq.membership.{u1} (Computation.{u1} α)) c S) (fun (H : Membership.Mem.{u1, u1} (Computation.{u1} α) (Stream'.WSeq.{u1} (Computation.{u1} α)) (Stream'.WSeq.membership.{u1} (Computation.{u1} α)) c S) => Membership.Mem.{u1, u1} α (Computation.{u1} α) (Computation.hasMem.{u1} α) a c)))
+but is expected to have type
+ forall {α : Type.{u1}} {S : Stream'.WSeq.{u1} (Computation.{u1} α)} {a : α}, (Membership.mem.{u1, u1} α (Computation.{u1} α) (Computation.instMembershipComputation.{u1} α) a (Computation.parallel.{u1} α S)) -> (Exists.{succ u1} (Computation.{u1} α) (fun (c : Computation.{u1} α) => And (Membership.mem.{u1, u1} (Computation.{u1} α) (Stream'.WSeq.{u1} (Computation.{u1} α)) (Stream'.WSeq.membership.{u1} (Computation.{u1} α)) c S) (Membership.mem.{u1, u1} α (Computation.{u1} α) (Computation.instMembershipComputation.{u1} α) a c)))
+Case conversion may be inaccurate. Consider using '#align computation.exists_of_mem_parallel Computation.exists_of_mem_parallelₓ'. -/
theorem exists_of_mem_parallel {S : WSeq (Computation α)} {a} (h : a ∈ parallel S) :
∃ c ∈ S, a ∈ c :=
by
@@ -204,7 +220,7 @@ theorem exists_of_mem_parallel {S : WSeq (Computation α)} {a} (h : a ∈ parall
∀ C,
a ∈ C →
∀ (l : List (Computation α)) (S),
- corec Parallel.aux1 (l, S) = C → ∃ c, (c ∈ l ∨ c ∈ S) ∧ a ∈ c
+ corec parallel.aux1 (l, S) = C → ∃ c, (c ∈ l ∨ c ∈ S) ∧ a ∈ c
from
let ⟨c, h1, h2⟩ := this _ h [] S rfl
⟨c, h1.resolve_left id, h2⟩
@@ -280,6 +296,7 @@ theorem exists_of_mem_parallel {S : WSeq (Computation α)} {a} (h : a ∈ parall
exact seq.mem_cons_of_mem _ dS'
#align computation.exists_of_mem_parallel Computation.exists_of_mem_parallel
+#print Computation.map_parallel /-
theorem map_parallel (f : α → β) (S) : map f (parallel S) = parallel (S.map (map f)) :=
by
refine'
@@ -307,7 +324,9 @@ theorem map_parallel (f : α → β) (S) : map f (parallel S) = parallel (S.map
apply S.rec_on _ (fun c S => _) fun S => _ <;> simp <;> simp [parallel.aux1] <;>
exact ⟨_, _, rfl, rfl⟩
#align computation.map_parallel Computation.map_parallel
+-/
+#print Computation.parallel_empty /-
theorem parallel_empty (S : WSeq (Computation α)) (h : S.headI ~> none) : parallel S = empty _ :=
eq_empty_of_not_terminates fun ⟨⟨a, m⟩⟩ =>
by
@@ -316,7 +335,9 @@ theorem parallel_empty (S : WSeq (Computation α)) (h : S.headI ~> none) : paral
let ⟨c', h'⟩ := WSeq.head_some_of_get?_some nm
injection h h'
#align computation.parallel_empty Computation.parallel_empty
+-/
+#print Computation.parallelRec /-
-- The reason this isn't trivial from exists_of_mem_parallel is because it eliminates to Sort
def parallelRec {S : WSeq (Computation α)} (C : α → Sort v) (H : ∀ s ∈ S, ∀ a ∈ s, C a) {a}
(h : a ∈ parallel S) : C a :=
@@ -353,19 +374,25 @@ def parallelRec {S : WSeq (Computation α)} (C : α → Sort v) (H : ∀ s ∈ S
cases' this with ac cs
apply H _ cs _ ac
#align computation.parallel_rec Computation.parallelRec
+-/
+#print Computation.parallel_promises /-
theorem parallel_promises {S : WSeq (Computation α)} {a} (H : ∀ s ∈ S, s ~> a) : parallel S ~> a :=
fun a' ma' =>
let ⟨c, cs, ac⟩ := exists_of_mem_parallel ma'
H _ cs ac
#align computation.parallel_promises Computation.parallel_promises
+-/
+#print Computation.mem_parallel /-
theorem mem_parallel {S : WSeq (Computation α)} {a} (H : ∀ s ∈ S, s ~> a) {c} (cs : c ∈ S)
(ac : a ∈ c) : a ∈ parallel S := by
haveI := terminates_of_mem ac <;> haveI := terminates_parallel cs <;>
exact mem_of_promises _ (parallel_promises H)
#align computation.mem_parallel Computation.mem_parallel
+-/
+#print Computation.parallel_congr_lem /-
theorem parallel_congr_lem {S T : WSeq (Computation α)} {a} (H : S.LiftRel Equiv T) :
(∀ s ∈ S, s ~> a) ↔ ∀ t ∈ T, t ~> a :=
⟨fun h1 t tT =>
@@ -375,8 +402,10 @@ theorem parallel_congr_lem {S T : WSeq (Computation α)} {a} (H : S.LiftRel Equi
let ⟨t, tT, se⟩ := WSeq.exists_of_liftRel_left H sS
(promises_congr se _).2 (h2 _ tT)⟩
#align computation.parallel_congr_lem Computation.parallel_congr_lem
+-/
/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
+#print Computation.parallel_congr_left /-
-- The parallel operation is only deterministic when all computation paths lead to the same value
theorem parallel_congr_left {S T : WSeq (Computation α)} {a} (h1 : ∀ s ∈ S, s ~> a)
(H : S.LiftRel Equiv T) : parallel S ~ parallel T :=
@@ -397,12 +426,15 @@ theorem parallel_congr_left {S T : WSeq (Computation α)} {a} (h1 : ∀ s ∈ S,
let aT := (st _).2 as
mem_parallel h1 tT aT⟩
#align computation.parallel_congr_left Computation.parallel_congr_left
+-/
/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
+#print Computation.parallel_congr_right /-
theorem parallel_congr_right {S T : WSeq (Computation α)} {a} (h2 : ∀ t ∈ T, t ~> a)
(H : S.LiftRel Equiv T) : parallel S ~ parallel T :=
parallel_congr_left ((parallel_congr_lem H).2 h2) H
#align computation.parallel_congr_right Computation.parallel_congr_right
+-/
end Computation
mathlib commit https://github.com/leanprover-community/mathlib/commit/730c6d4cab72b9d84fcfb9e95e8796e9cd8f40ba
@@ -37,8 +37,8 @@ def Parallel.aux2 : List (Computation α) → Sum α (List (Computation α)) :=
/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
def Parallel.aux1 :
- List (Computation α) × Wseq (Computation α) →
- Sum α (List (Computation α) × Wseq (Computation α))
+ List (Computation α) × WSeq (Computation α) →
+ Sum α (List (Computation α) × WSeq (Computation α))
| (l, S) =>
rmap
(fun l' =>
@@ -51,7 +51,7 @@ def Parallel.aux1 :
/-- Parallel computation of an infinite stream of computations,
taking the first result -/
-def parallel (S : Wseq (Computation α)) : Computation α :=
+def parallel (S : WSeq (Computation α)) : Computation α :=
corec Parallel.aux1 ([], S)
#align computation.parallel Computation.parallel
@@ -123,7 +123,7 @@ theorem TerminatesParallel.aux :
simp [this]
#align computation.terminates_parallel.aux Computation.TerminatesParallel.aux
-theorem terminates_parallel {S : Wseq (Computation α)} {c} (h : c ∈ S) [T : Terminates c] :
+theorem terminates_parallel {S : WSeq (Computation α)} {c} (h : c ∈ S) [T : Terminates c] :
Terminates (parallel S) :=
by
suffices
@@ -197,7 +197,7 @@ theorem terminates_parallel {S : Wseq (Computation α)} {c} (h : c ∈ S) [T : T
cases' o with c <;> simp [parallel.aux1, TT]
#align computation.terminates_parallel Computation.terminates_parallel
-theorem exists_of_mem_parallel {S : Wseq (Computation α)} {a} (h : a ∈ parallel S) :
+theorem exists_of_mem_parallel {S : WSeq (Computation α)} {a} (h : a ∈ parallel S) :
∃ c ∈ S, a ∈ c :=
by
suffices
@@ -308,17 +308,17 @@ theorem map_parallel (f : α → β) (S) : map f (parallel S) = parallel (S.map
exact ⟨_, _, rfl, rfl⟩
#align computation.map_parallel Computation.map_parallel
-theorem parallel_empty (S : Wseq (Computation α)) (h : S.headI ~> none) : parallel S = empty _ :=
+theorem parallel_empty (S : WSeq (Computation α)) (h : S.headI ~> none) : parallel S = empty _ :=
eq_empty_of_not_terminates fun ⟨⟨a, m⟩⟩ =>
by
let ⟨c, cs, ac⟩ := exists_of_mem_parallel m
- let ⟨n, nm⟩ := Wseq.exists_nth_of_mem cs
- let ⟨c', h'⟩ := Wseq.head_some_of_nth_some nm
+ let ⟨n, nm⟩ := WSeq.exists_get?_of_mem cs
+ let ⟨c', h'⟩ := WSeq.head_some_of_get?_some nm
injection h h'
#align computation.parallel_empty Computation.parallel_empty
-- The reason this isn't trivial from exists_of_mem_parallel is because it eliminates to Sort
-def parallelRec {S : Wseq (Computation α)} (C : α → Sort v) (H : ∀ s ∈ S, ∀ a ∈ s, C a) {a}
+def parallelRec {S : WSeq (Computation α)} (C : α → Sort v) (H : ∀ s ∈ S, ∀ a ∈ s, C a) {a}
(h : a ∈ parallel S) : C a :=
by
let T : wseq (Computation (α × Computation α)) := S.map fun c => c.map fun a => (a, c)
@@ -354,31 +354,31 @@ def parallelRec {S : Wseq (Computation α)} (C : α → Sort v) (H : ∀ s ∈ S
apply H _ cs _ ac
#align computation.parallel_rec Computation.parallelRec
-theorem parallel_promises {S : Wseq (Computation α)} {a} (H : ∀ s ∈ S, s ~> a) : parallel S ~> a :=
+theorem parallel_promises {S : WSeq (Computation α)} {a} (H : ∀ s ∈ S, s ~> a) : parallel S ~> a :=
fun a' ma' =>
let ⟨c, cs, ac⟩ := exists_of_mem_parallel ma'
H _ cs ac
#align computation.parallel_promises Computation.parallel_promises
-theorem mem_parallel {S : Wseq (Computation α)} {a} (H : ∀ s ∈ S, s ~> a) {c} (cs : c ∈ S)
+theorem mem_parallel {S : WSeq (Computation α)} {a} (H : ∀ s ∈ S, s ~> a) {c} (cs : c ∈ S)
(ac : a ∈ c) : a ∈ parallel S := by
haveI := terminates_of_mem ac <;> haveI := terminates_parallel cs <;>
exact mem_of_promises _ (parallel_promises H)
#align computation.mem_parallel Computation.mem_parallel
-theorem parallel_congr_lem {S T : Wseq (Computation α)} {a} (H : S.LiftRel Equiv T) :
+theorem parallel_congr_lem {S T : WSeq (Computation α)} {a} (H : S.LiftRel Equiv T) :
(∀ s ∈ S, s ~> a) ↔ ∀ t ∈ T, t ~> a :=
⟨fun h1 t tT =>
- let ⟨s, sS, se⟩ := Wseq.exists_of_liftRel_right H tT
+ let ⟨s, sS, se⟩ := WSeq.exists_of_liftRel_right H tT
(promises_congr se _).1 (h1 _ sS),
fun h2 s sS =>
- let ⟨t, tT, se⟩ := Wseq.exists_of_liftRel_left H sS
+ let ⟨t, tT, se⟩ := WSeq.exists_of_liftRel_left H sS
(promises_congr se _).2 (h2 _ tT)⟩
#align computation.parallel_congr_lem Computation.parallel_congr_lem
/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
-- The parallel operation is only deterministic when all computation paths lead to the same value
-theorem parallel_congr_left {S T : Wseq (Computation α)} {a} (h1 : ∀ s ∈ S, s ~> a)
+theorem parallel_congr_left {S T : WSeq (Computation α)} {a} (h1 : ∀ s ∈ S, s ~> a)
(H : S.LiftRel Equiv T) : parallel S ~ parallel T :=
let h2 := (parallel_congr_lem H).1 h1
fun a' =>
@@ -399,7 +399,7 @@ theorem parallel_congr_left {S T : Wseq (Computation α)} {a} (h1 : ∀ s ∈ S,
#align computation.parallel_congr_left Computation.parallel_congr_left
/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
-theorem parallel_congr_right {S T : Wseq (Computation α)} {a} (h2 : ∀ t ∈ T, t ~> a)
+theorem parallel_congr_right {S T : WSeq (Computation α)} {a} (h2 : ∀ t ∈ T, t ~> a)
(H : S.LiftRel Equiv T) : parallel S ~ parallel T :=
parallel_congr_left ((parallel_congr_lem H).2 h2) H
#align computation.parallel_congr_right Computation.parallel_congr_right
mathlib commit https://github.com/leanprover-community/mathlib/commit/e05ead7993520a432bec94ac504842d90707ad63
@@ -128,7 +128,7 @@ theorem terminates_parallel {S : Wseq (Computation α)} {c} (h : c ∈ S) [T : T
by
suffices
∀ (n) (l : List (Computation α)) (S c),
- c ∈ l ∨ some (some c) = Seq.nth S n → Terminates c → Terminates (corec Parallel.aux1 (l, S))
+ c ∈ l ∨ some (some c) = Seq.get? S n → Terminates c → Terminates (corec Parallel.aux1 (l, S))
from
let ⟨n, h⟩ := h
this n [] S c (Or.inr h) T
mathlib commit https://github.com/leanprover-community/mathlib/commit/b685f506164f8d17a6404048bc4d696739c5d976
@@ -11,7 +11,7 @@ terminates_parallel and exists_of_mem_parallel.
honor sequence equivalence (irrelevance of computation time).)
! This file was ported from Lean 3 source module data.seq.parallel
-! leanprover-community/mathlib commit 77615d00fbf05cd7e55ba84176070a18bc097772
+! leanprover-community/mathlib commit a7e36e48519ab281320c4d192da6a7b348ce40ad
! Please do not edit these lines, except to modify the commit id
! if you have ported upstream changes.
-/
@@ -21,8 +21,8 @@ universe u v
namespace Computation
-open Wseq
-
+/- ./././Mathport/Syntax/Translate/Command.lean:224:11: unsupported: unusual advanced open style -/
+/- ./././Mathport/Syntax/Translate/Command.lean:224:11: unsupported: unusual advanced open style -/
variable {α : Type u} {β : Type v}
/- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
@@ -42,8 +42,8 @@ def Parallel.aux1 :
| (l, S) =>
rmap
(fun l' =>
- match SeqCat.destruct S with
- | none => (l', nil)
+ match Seq.destruct S with
+ | none => (l', Seq.nil)
| some (none, S') => (l', S')
| some (some c, S') => (c::l', S'))
(Parallel.aux2 l)
@@ -119,7 +119,7 @@ theorem TerminatesParallel.aux :
rw [H2]
apply @Computation.think_terminates _ _ _
have := H1 _ h
- rcases SeqCat.destruct S with (_ | ⟨_ | c, S'⟩) <;> simp [parallel.aux1] <;> apply IH <;>
+ rcases seq.destruct S with (_ | ⟨_ | c, S'⟩) <;> simp [parallel.aux1] <;> apply IH <;>
simp [this]
#align computation.terminates_parallel.aux Computation.TerminatesParallel.aux
@@ -128,17 +128,16 @@ theorem terminates_parallel {S : Wseq (Computation α)} {c} (h : c ∈ S) [T : T
by
suffices
∀ (n) (l : List (Computation α)) (S c),
- c ∈ l ∨ some (some c) = SeqCat.nth S n →
- Terminates c → Terminates (corec Parallel.aux1 (l, S))
+ c ∈ l ∨ some (some c) = Seq.nth S n → Terminates c → Terminates (corec Parallel.aux1 (l, S))
from
let ⟨n, h⟩ := h
this n [] S c (Or.inr h) T
intro n; induction' n with n IH <;> intro l S c o T
· cases' o with a a
· exact terminates_parallel.aux a T
- have H : SeqCat.destruct S = some (some c, _) :=
+ have H : seq.destruct S = some (some c, _) :=
by
- unfold SeqCat.destruct Functor.map
+ unfold seq.destruct Functor.map
rw [← a]
simp
induction' h : parallel.aux2 l with a l' <;> have C : corec parallel.aux1 (l, S) = _
@@ -180,19 +179,18 @@ theorem terminates_parallel {S : Wseq (Computation α)} {c} (h : c ∈ S) [T : T
rw [a]
cases' S with f al
rfl
- induction' e : SeqCat.nth S 0 with o
- · have D : SeqCat.destruct S = none :=
- by
- dsimp [SeqCat.destruct]
+ induction' e : seq.nth S 0 with o
+ · have D : seq.destruct S = none := by
+ dsimp [seq.destruct]
rw [e]
rfl
rw [D]
simp [parallel.aux1]
have TT := TT l'
- rwa [SeqCat.destruct_eq_nil D, SeqCat.tail_nil] at TT
- · have D : SeqCat.destruct S = some (o, S.tail) :=
+ rwa [seq.destruct_eq_nil D, seq.tail_nil] at TT
+ · have D : seq.destruct S = some (o, S.tail) :=
by
- dsimp [SeqCat.destruct]
+ dsimp [seq.destruct]
rw [e]
rfl
rw [D]
@@ -252,11 +250,11 @@ theorem exists_of_mem_parallel {S : Wseq (Computation α)} {a} (h : a ∈ parall
· rw [h'] at this
rcases this with ⟨c, cl, ac⟩
exact ⟨c, Or.inl cl, ac⟩
- · induction' e : SeqCat.destruct S with a <;> rw [e] at h'
+ · induction' e : seq.destruct S with a <;> rw [e] at h'
·
exact
let ⟨d, o, ad⟩ := IH _ _ h'
- let ⟨c, cl, ac⟩ := this a ⟨d, o.resolve_right (not_mem_nil _), ad⟩
+ let ⟨c, cl, ac⟩ := this a ⟨d, o.resolve_right (wseq.not_mem_nil _), ad⟩
⟨c, Or.inl cl, ac⟩
· cases' a with o S'
cases' o with c <;> simp [parallel.aux1] at h' <;> rcases IH _ _ h' with ⟨d, dl | dS', ad⟩
@@ -265,21 +263,21 @@ theorem exists_of_mem_parallel {S : Wseq (Computation α)} {a} (h : a ∈ parall
let ⟨c, cl, ac⟩ := this a ⟨d, dl, ad⟩
⟨c, Or.inl cl, ac⟩
· refine' ⟨d, Or.inr _, ad⟩
- rw [SeqCat.destruct_eq_cons e]
- exact SeqCat.mem_cons_of_mem _ dS'
+ rw [seq.destruct_eq_cons e]
+ exact seq.mem_cons_of_mem _ dS'
· simp at dl
cases' dl with dc dl
· rw [dc] at ad
refine' ⟨c, Or.inr _, ad⟩
- rw [SeqCat.destruct_eq_cons e]
- apply SeqCat.mem_cons
+ rw [seq.destruct_eq_cons e]
+ apply seq.mem_cons
·
exact
let ⟨c, cl, ac⟩ := this a ⟨d, dl, ad⟩
⟨c, Or.inl cl, ac⟩
· refine' ⟨d, Or.inr _, ad⟩
- rw [SeqCat.destruct_eq_cons e]
- exact SeqCat.mem_cons_of_mem _ dS'
+ rw [seq.destruct_eq_cons e]
+ exact seq.mem_cons_of_mem _ dS'
#align computation.exists_of_mem_parallel Computation.exists_of_mem_parallel
theorem map_parallel (f : α → β) (S) : map f (parallel S) = parallel (S.map (map f)) :=
@@ -314,8 +312,8 @@ theorem parallel_empty (S : Wseq (Computation α)) (h : S.headI ~> none) : paral
eq_empty_of_not_terminates fun ⟨⟨a, m⟩⟩ =>
by
let ⟨c, cs, ac⟩ := exists_of_mem_parallel m
- let ⟨n, nm⟩ := exists_nth_of_mem cs
- let ⟨c', h'⟩ := head_some_of_nth_some nm
+ let ⟨n, nm⟩ := Wseq.exists_nth_of_mem cs
+ let ⟨c', h'⟩ := Wseq.head_some_of_nth_some nm
injection h h'
#align computation.parallel_empty Computation.parallel_empty
@@ -323,11 +321,11 @@ theorem parallel_empty (S : Wseq (Computation α)) (h : S.headI ~> none) : paral
def parallelRec {S : Wseq (Computation α)} (C : α → Sort v) (H : ∀ s ∈ S, ∀ a ∈ s, C a) {a}
(h : a ∈ parallel S) : C a :=
by
- let T : Wseq (Computation (α × Computation α)) := S.map fun c => c.map fun a => (a, c)
+ let T : wseq (Computation (α × Computation α)) := S.map fun c => c.map fun a => (a, c)
have : S = T.map (map fun c => c.1) :=
by
- rw [← Wseq.map_comp]
- refine' (Wseq.map_id _).symm.trans (congr_arg (fun f => Wseq.map f S) _)
+ rw [← wseq.map_comp]
+ refine' (wseq.map_id _).symm.trans (congr_arg (fun f => wseq.map f S) _)
funext c
dsimp [id, Function.comp]
rw [← map_comp]
@@ -345,7 +343,7 @@ def parallelRec {S : Wseq (Computation α)} (C : α → Sort v) (H : ∀ s ∈ S
dsimp at cd
cases cd
rcases exists_of_mem_parallel dT with ⟨d', dT', ad'⟩
- rcases Wseq.exists_of_mem_map dT' with ⟨c', cs', e'⟩
+ rcases wseq.exists_of_mem_map dT' with ⟨c', cs', e'⟩
rw [← e'] at ad'
rcases exists_of_mem_map ad' with ⟨a', ac', e'⟩
injection e' with i1 i2
@@ -388,14 +386,14 @@ theorem parallel_congr_left {S T : Wseq (Computation α)} {a} (h1 : ∀ s ∈ S,
have aa := parallel_promises h1 h <;> rw [← aa] <;> rw [← aa] at h <;>
exact
let ⟨s, sS, as⟩ := exists_of_mem_parallel h
- let ⟨t, tT, st⟩ := Wseq.exists_of_liftRel_left H sS
+ let ⟨t, tT, st⟩ := wseq.exists_of_lift_rel_left H sS
let aT := (st _).1 as
mem_parallel h2 tT aT,
fun h => by
have aa := parallel_promises h2 h <;> rw [← aa] <;> rw [← aa] at h <;>
exact
let ⟨s, sS, as⟩ := exists_of_mem_parallel h
- let ⟨t, tT, st⟩ := Wseq.exists_of_liftRel_right H sS
+ let ⟨t, tT, st⟩ := wseq.exists_of_lift_rel_right H sS
let aT := (st _).2 as
mem_parallel h1 tT aT⟩
#align computation.parallel_congr_left Computation.parallel_congr_left
mathlib commit https://github.com/leanprover-community/mathlib/commit/bd9851ca476957ea4549eb19b40e7b5ade9428cc
@@ -143,8 +143,8 @@ theorem terminates_parallel {S : WSeq (Computation α)} {c} (h : c ∈ S) [T : T
infer_instance
· have C : corec parallel.aux1 (l, S) = _ := by
apply destruct_eq_think
- simp only [corec_eq, rmap, parallel.aux1._eq_1]
- rw [h, H]
+ · simp only [corec_eq, rmap, parallel.aux1._eq_1]
+ rw [h, H]
rw [C]
refine @Computation.think_terminates _ _ ?_
apply terminates_parallel.aux _ T
@@ -162,8 +162,8 @@ theorem terminates_parallel {S : WSeq (Computation α)} {c} (h : c ∈ S) [T : T
infer_instance
· have C : corec parallel.aux1 (l, S) = _ := by
apply destruct_eq_think
- simp only [corec_eq, rmap, parallel.aux1._eq_1]
- rw [h]
+ · simp only [corec_eq, rmap, parallel.aux1._eq_1]
+ rw [h]
rw [C]
refine @Computation.think_terminates _ _ ?_
have TT : ∀ l', Terminates (corec parallel.aux1 (l', S.tail)) := by
@@ -199,8 +199,8 @@ theorem exists_of_mem_parallel {S : WSeq (Computation α)} {a} (h : a ∈ parall
let F : List (Computation α) → Sum α (List (Computation α)) → Prop := by
intro l a
cases' a with a l'
- exact ∃ c ∈ l, a ∈ c
- exact ∀ a', (∃ c ∈ l', a' ∈ c) → ∃ c ∈ l, a' ∈ c
+ · exact ∃ c ∈ l, a ∈ c
+ · exact ∀ a', (∃ c ∈ l', a' ∈ c) → ∃ c ∈ l, a' ∈ c
have lem1 : ∀ l : List (Computation α), F l (parallel.aux2 l) := by
intro l
induction' l with c l IH <;> simp only [parallel.aux2, List.foldr]
@@ -333,8 +333,8 @@ def parallelRec {S : WSeq (Computation α)} (C : α → Sort v) (H : ∀ s ∈ S
rcases exists_of_mem_map ad' with ⟨a', ac', e'⟩
injection e' with i1 i2
constructor
- rwa [i1, i2] at ac'
- rwa [i2] at cs'
+ · rwa [i1, i2] at ac'
+ · rwa [i2] at cs'
cases' this with ac cs
apply H _ cs _ ac
#align computation.parallel_rec Computation.parallelRec
@@ -131,11 +131,7 @@ theorem terminates_parallel {S : WSeq (Computation α)} {c} (h : c ∈ S) [T : T
intro n; induction' n with n IH <;> intro l S c o T
· cases' o with a a
· exact terminates_parallel.aux a T
- have H : Seq.destruct S = some (some c, _) := by
- dsimp [Seq.destruct, (· <$> ·)]
- rw [← a]
- simp only [Option.map_some', Option.some.injEq]
- rfl
+ have H : Seq.destruct S = some (some c, Seq.tail S) := by simp [Seq.destruct, (· <$> ·), ← a]
induction' h : parallel.aux2 l with a l'
· have C : corec parallel.aux1 (l, S) = pure a := by
apply destruct_eq_pure
@@ -102,7 +102,6 @@ theorem terminates_parallel.aux :
(Sum.inr List.nil) l with a' ls <;> erw [e] at e'
· contradiction
have := IH' m _ e
- simp [parallel.aux2] at e'
-- Porting note: `revert e'` & `intro e'` are required.
revert e'
cases destruct c <;> intro e' <;> [injection e'; injection e' with h']
@@ -135,7 +134,7 @@ theorem terminates_parallel {S : WSeq (Computation α)} {c} (h : c ∈ S) [T : T
have H : Seq.destruct S = some (some c, _) := by
dsimp [Seq.destruct, (· <$> ·)]
rw [← a]
- simp
+ simp only [Option.map_some', Option.some.injEq]
rfl
induction' h : parallel.aux2 l with a l'
· have C : corec parallel.aux1 (l, S) = pure a := by
This is a very large PR, but it has been reviewed piecemeal already in PRs to the bump/v4.7.0
branch as we update to intermediate nightlies.
Co-authored-by: Scott Morrison <scott.morrison@gmail.com> Co-authored-by: Kyle Miller <kmill31415@gmail.com> Co-authored-by: damiano <adomani@gmail.com>
@@ -77,11 +77,7 @@ theorem terminates_parallel.aux :
cases' m with e m
· rw [← e]
simp only [parallel.aux2, rmap, List.foldr_cons, destruct_pure]
- cases' List.foldr (fun c o =>
- match o with
- | Sum.inl a => Sum.inl a
- | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c)) (Sum.inr List.nil) l with a' ls
- exacts [⟨a', rfl⟩, ⟨a, rfl⟩]
+ split <;> simp
· cases' IH m with a' e
simp only [parallel.aux2, rmap, List.foldr_cons]
simp? [parallel.aux2] at e says simp only [parallel.aux2, rmap] at e
@@ -94,13 +90,11 @@ theorem terminates_parallel.aux :
· rw [← e] at e'
-- Porting note: `revert e'` & `intro e'` are required.
revert e'
- cases' List.foldr (fun c o =>
- match o with
- | Sum.inl a => Sum.inl a
- | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c))
- (Sum.inr []) l with a' ls <;> intro e' <;> [injection e'; injection e' with e']
- rw [← e']
- simp
+ split
+ · simp
+ · simp only [destruct_think, Sum.inr.injEq]
+ rintro rfl
+ simp
· induction' e : List.foldr (fun c o =>
match o with
| Sum.inl a => Sum.inl a
@@ -297,12 +291,9 @@ theorem map_parallel (f : α → β) (S) : map f (parallel S) = parallel (S.map
simp only [parallel.aux2, rmap, lmap]
induction' l with c l IH <;> simp
rw [IH]
- cases List.foldr (fun c o =>
- match o with
- | Sum.inl a => Sum.inl a
- | Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c)) (Sum.inr List.nil) l <;>
- simp [parallel.aux2]
- cases destruct c <;> simp
+ cases List.foldr _ _ _
+ · simp
+ · cases destruct c <;> simp
simp only [BisimO, destruct_map, lmap, rmap, corec_eq, parallel.aux1._eq_1]
rw [this]
cases' parallel.aux2 l with a l' <;> simp
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.
@@ -228,7 +228,7 @@ theorem exists_of_mem_parallel {S : WSeq (Computation α)} {a} (h : a ∈ parall
intro IH <;>
simp only [parallel.aux2]
· rcases IH with ⟨c', cl, ac⟩
- refine' ⟨c', List.Mem.tail _ cl, ac⟩
+ exact ⟨c', List.Mem.tail _ cl, ac⟩
· induction' h : destruct c with a c' <;> simp only [rmap]
· refine' ⟨c, List.mem_cons_self _ _, _⟩
rw [destruct_eq_pure h]
have
, replace
and suffices
(#10640)
No changes to tactic file, it's just boring fixes throughout the library.
This follows on from #6964.
Co-authored-by: sgouezel <sebastien.gouezel@univ-rennes1.fr> Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
@@ -143,41 +143,39 @@ theorem terminates_parallel {S : WSeq (Computation α)} {c} (h : c ∈ S) [T : T
rw [← a]
simp
rfl
- induction' h : parallel.aux2 l with a l' <;> have C : corec parallel.aux1 (l, S) = _
- · -- Porting note: To adjust RHS of `C`, these lines are changed.
- apply destruct_eq_pure
- rw [corec_eq, parallel.aux1]
- dsimp only []
- rw [h]
- simp only [rmap]
- rfl
- · rw [C]
- skip
+ induction' h : parallel.aux2 l with a l'
+ · have C : corec parallel.aux1 (l, S) = pure a := by
+ apply destruct_eq_pure
+ rw [corec_eq, parallel.aux1]
+ dsimp only []
+ rw [h]
+ simp only [rmap]
+ rw [C]
infer_instance
- · apply destruct_eq_think
- simp only [corec_eq, rmap, parallel.aux1._eq_1]
- rw [h, H]
- · rw [C]
+ · have C : corec parallel.aux1 (l, S) = _ := by
+ apply destruct_eq_think
+ simp only [corec_eq, rmap, parallel.aux1._eq_1]
+ rw [h, H]
+ rw [C]
refine @Computation.think_terminates _ _ ?_
apply terminates_parallel.aux _ T
simp
· cases' o with a a
· exact terminates_parallel.aux a T
- induction' h : parallel.aux2 l with a l' <;> have C : corec parallel.aux1 (l, S) = _
- · -- Porting note: To adjust RHS of `C`, these lines are changed.
- apply destruct_eq_pure
- rw [corec_eq, parallel.aux1]
- dsimp only []
- rw [h]
- simp only [rmap]
- rfl
- · rw [C]
- skip
+ induction' h : parallel.aux2 l with a l'
+ · have C : corec parallel.aux1 (l, S) = pure a := by
+ apply destruct_eq_pure
+ rw [corec_eq, parallel.aux1]
+ dsimp only []
+ rw [h]
+ simp only [rmap]
+ rw [C]
infer_instance
- · apply destruct_eq_think
- simp only [corec_eq, rmap, parallel.aux1._eq_1]
- rw [h]
- · rw [C]
+ · have C : corec parallel.aux1 (l, S) = _ := by
+ apply destruct_eq_think
+ simp only [corec_eq, rmap, parallel.aux1._eq_1]
+ rw [h]
+ rw [C]
refine @Computation.think_terminates _ _ ?_
have TT : ∀ l', Terminates (corec parallel.aux1 (l', S.tail)) := by
intro
bump/v4.5.0
branch. (#9188)
This PR:
v4.5.0-rc1
v4.5.0-rc1
bump/v4.5.0
branch
Co-authored-by: Scott Morrison <scott.morrison@gmail.com> Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
@@ -237,7 +237,7 @@ theorem exists_of_mem_parallel {S : WSeq (Computation α)} {a} (h : a ∈ parall
apply ret_mem
· intro a' h
rcases h with ⟨d, dm, ad⟩
- simp? at dm says simp only [Bool.not_eq_true, List.mem_cons] at dm
+ simp? at dm says simp only [List.mem_cons] at dm
cases' dm with e dl
· rw [e] at ad
refine' ⟨c, List.mem_cons_self _ _, _⟩
@@ -84,7 +84,7 @@ theorem terminates_parallel.aux :
exacts [⟨a', rfl⟩, ⟨a, rfl⟩]
· cases' IH m with a' e
simp only [parallel.aux2, rmap, List.foldr_cons]
- simp [parallel.aux2] at e
+ simp? [parallel.aux2] at e says simp only [parallel.aux2, rmap] at e
rw [e]
exact ⟨a', rfl⟩
· intro s IH l S m
@@ -237,7 +237,7 @@ theorem exists_of_mem_parallel {S : WSeq (Computation α)} {a} (h : a ∈ parall
apply ret_mem
· intro a' h
rcases h with ⟨d, dm, ad⟩
- simp at dm
+ simp? at dm says simp only [Bool.not_eq_true, List.mem_cons] at dm
cases' dm with e dl
· rw [e] at ad
refine' ⟨c, List.mem_cons_self _ _, _⟩
This is the supremum of
along with some minor fixes from failures on nightly-testing as Mathlib master
is merged into it.
Note that some PRs for changes that are already compatible with the current toolchain and will be necessary have already been split out: #8380.
I am hopeful that in future we will be able to progressively merge adaptation PRs into a bump/v4.X.0
branch, so we never end up with a "big merge" like this. However one of these adaptation PRs (#8056) predates my new scheme for combined CI, and it wasn't possible to keep that PR viable in the meantime.
In particular this includes adjustments for the Lean PRs
We can get rid of all the
local macro_rules | `($x ^ $y) => `(HPow.hPow $x $y) -- Porting note: See issue [lean4#2220](https://github.com/leanprover/lean4/pull/2220)
macros across Mathlib (and in any projects that want to write natural number powers of reals).
Changes the default behaviour of simp
to (config := {decide := false})
. This makes simp
(and consequentially norm_num
) less powerful, but also more consistent, and less likely to blow up in long failures. This requires a variety of changes: changing some previously by simp
or norm_num
to decide
or rfl
, or adding (config := {decide := true})
.
This changed the behaviour of simp
so that simp [f]
will only unfold "fully applied" occurrences of f
. The old behaviour can be recovered with simp (config := { unfoldPartialApp := true })
. We may in future add a syntax for this, e.g. simp [!f]
; please provide feedback! In the meantime, we have made the following changes:
(config := { unfoldPartialApp := true })
in some places, to recover the old behaviour@[eqns]
to manually adjust the equation lemmas for a particular definition, recovering the old behaviour just for that definition. See #8371, where we do this for Function.comp
and Function.flip
.This change in Lean may require further changes down the line (e.g. adding the !f
syntax, and/or upstreaming the special treatment for Function.comp
and Function.flip
, and/or removing this special treatment). Please keep an open and skeptical mind about these changes!
Co-authored-by: leanprover-community-mathlib4-bot <leanprover-community-mathlib4-bot@users.noreply.github.com> Co-authored-by: Scott Morrison <scott.morrison@gmail.com> Co-authored-by: Eric Wieser <wieser.eric@gmail.com> Co-authored-by: Mauricio Collares <mauricio@collares.org>
@@ -328,7 +328,7 @@ def parallelRec {S : WSeq (Computation α)} (C : α → Sort v) (H : ∀ s ∈ S
rw [← WSeq.map_comp]
refine' (WSeq.map_id _).symm.trans (congr_arg (fun f => WSeq.map f S) _)
funext c
- dsimp [id, Function.comp]
+ dsimp [id, Function.comp_def]
rw [← map_comp]
exact (map_id _).symm
have pe := congr_arg parallel this
Removes nonterminal simps on lines looking like simp [...]
@@ -63,7 +63,7 @@ theorem terminates_parallel.aux :
cases' e with a e
have : corec parallel.aux1 (l, S) = return a := by
apply destruct_eq_pure
- simp [parallel.aux1]
+ simp only [parallel.aux1, rmap, corec_eq]
rw [e]
rw [this]
-- Porting note: This line is required.
@@ -76,14 +76,14 @@ theorem terminates_parallel.aux :
induction' l with c l IH <;> simp at m
cases' m with e m
· rw [← e]
- simp [parallel.aux2]
+ simp only [parallel.aux2, rmap, List.foldr_cons, destruct_pure]
cases' List.foldr (fun c o =>
match o with
| Sum.inl a => Sum.inl a
| Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c)) (Sum.inr List.nil) l with a' ls
exacts [⟨a', rfl⟩, ⟨a, rfl⟩]
· cases' IH m with a' e
- simp [parallel.aux2]
+ simp only [parallel.aux2, rmap, List.foldr_cons]
simp [parallel.aux2] at e
rw [e]
exact ⟨a', rfl⟩
@@ -118,7 +118,7 @@ theorem terminates_parallel.aux :
· exact lem1 _ _ ⟨a, h⟩
· have H2 : corec parallel.aux1 (l, S) = think _ := by
apply destruct_eq_think
- simp [parallel.aux1]
+ simp only [parallel.aux1, rmap, corec_eq]
rw [h]
rw [H2]
refine @Computation.think_terminates _ _ ?_
@@ -155,7 +155,7 @@ theorem terminates_parallel {S : WSeq (Computation α)} {c} (h : c ∈ S) [T : T
skip
infer_instance
· apply destruct_eq_think
- simp [parallel.aux1]
+ simp only [corec_eq, rmap, parallel.aux1._eq_1]
rw [h, H]
· rw [C]
refine @Computation.think_terminates _ _ ?_
@@ -175,7 +175,7 @@ theorem terminates_parallel {S : WSeq (Computation α)} {c} (h : c ∈ S) [T : T
skip
infer_instance
· apply destruct_eq_think
- simp [parallel.aux1]
+ simp only [corec_eq, rmap, parallel.aux1._eq_1]
rw [h]
· rw [C]
refine @Computation.think_terminates _ _ ?_
@@ -191,7 +191,7 @@ theorem terminates_parallel {S : WSeq (Computation α)} {c} (h : c ∈ S) [T : T
rw [e]
rfl
rw [D]
- simp [parallel.aux1]
+ simp only
have TT := TT l'
rwa [Seq.destruct_eq_nil D, Seq.tail_nil] at TT
· have D : Seq.destruct S = some (o, S.tail) := by
@@ -296,7 +296,7 @@ theorem map_parallel (f : α → β) (S) : map f (parallel S) = parallel (S.map
| _, _, ⟨l, S, rfl, rfl⟩ => by
have : parallel.aux2 (l.map (map f))
= lmap f (rmap (List.map (map f)) (parallel.aux2 l)) := by
- simp [parallel.aux2]
+ simp only [parallel.aux2, rmap, lmap]
induction' l with c l IH <;> simp
rw [IH]
cases List.foldr (fun c o =>
@@ -305,7 +305,7 @@ theorem map_parallel (f : α → β) (S) : map f (parallel S) = parallel (S.map
| Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c)) (Sum.inr List.nil) l <;>
simp [parallel.aux2]
cases destruct c <;> simp
- simp [parallel.aux1]
+ simp only [BisimO, destruct_map, lmap, rmap, corec_eq, parallel.aux1._eq_1]
rw [this]
cases' parallel.aux2 l with a l' <;> simp
induction' S using WSeq.recOn with c S S <;> simp <;>
@@ -3,6 +3,7 @@ Copyright (c) 2017 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro
-/
+import Mathlib.Init.Data.Prod
import Mathlib.Data.Seq.WSeq
#align_import data.seq.parallel from "leanprover-community/mathlib"@"a7e36e48519ab281320c4d192da6a7b348ce40ad"
@@ -307,7 +307,7 @@ theorem map_parallel (f : α → β) (S) : map f (parallel S) = parallel (S.map
simp [parallel.aux1]
rw [this]
cases' parallel.aux2 l with a l' <;> simp
- induction' S using WSeq.recOn with c S S <;> simp <;> simp [parallel.aux1] <;>
+ induction' S using WSeq.recOn with c S S <;> simp <;>
exact ⟨_, _, rfl, rfl⟩
#align computation.map_parallel Computation.map_parallel
@@ -2,14 +2,11 @@
Copyright (c) 2017 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro
-
-! This file was ported from Lean 3 source module data.seq.parallel
-! leanprover-community/mathlib commit a7e36e48519ab281320c4d192da6a7b348ce40ad
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
-/
import Mathlib.Data.Seq.WSeq
+#align_import data.seq.parallel from "leanprover-community/mathlib"@"a7e36e48519ab281320c4d192da6a7b348ce40ad"
+
/-!
# Parallel computation
Alongside any necessary spacing/flow changes to accommodate their removal.
@@ -292,7 +292,7 @@ theorem map_parallel (f : α → β) (S) : map f (parallel S) = parallel (S.map
c1 = map f (corec parallel.aux1 (l, S)) ∧
c2 = corec parallel.aux1 (l.map (map f), S.map (map f)))
_ ⟨[], S, rfl, rfl⟩
- intro c1 c2 h;
+ intro c1 c2 h
exact
match c1, c2, h with
| _, _, ⟨l, S, rfl, rfl⟩ => by
The main breaking change is that tac <;> [t1, t2]
is now written tac <;> [t1; t2]
, to avoid clashing with tactics like cases
and use
that take comma-separated lists.
@@ -100,7 +100,7 @@ theorem terminates_parallel.aux :
match o with
| Sum.inl a => Sum.inl a
| Sum.inr ls => rmap (fun c' => c' :: ls) (destruct c))
- (Sum.inr []) l with a' ls <;> intro e' <;> [injection e', injection e' with e']
+ (Sum.inr []) l with a' ls <;> intro e' <;> [injection e'; injection e' with e']
rw [← e']
simp
· induction' e : List.foldr (fun c o =>
@@ -113,7 +113,7 @@ theorem terminates_parallel.aux :
simp [parallel.aux2] at e'
-- Porting note: `revert e'` & `intro e'` are required.
revert e'
- cases destruct c <;> intro e' <;> [injection e', injection e' with h']
+ cases destruct c <;> intro e' <;> [injection e'; injection e' with h']
rw [← h']
simp [this]
induction' h : parallel.aux2 l with a l'
@@ -250,10 +250,10 @@ theorem exists_of_mem_parallel {S : WSeq (Computation α)} {a} (h : a ∈ parall
exact ⟨d, List.Mem.tail _ dm, ad⟩
intro C aC
-- Porting note: `revert e'` & `intro e'` are required.
- apply memRecOn aC <;> [skip, intro C' IH] <;> intro l S e <;> have e' := congr_arg destruct e <;>
+ apply memRecOn aC <;> [skip; intro C' IH] <;> intro l S e <;> have e' := congr_arg destruct e <;>
have := lem1 l <;> simp only [parallel.aux1, corec_eq, destruct_pure, destruct_think] at e' <;>
revert this e' <;> cases' parallel.aux2 l with a' l' <;> intro this e' <;>
- [injection e' with h', injection e', injection e', injection e' with h']
+ [injection e' with h'; injection e'; injection e'; injection e' with h']
· rw [h'] at this
rcases this with ⟨c, cl, ac⟩
exact ⟨c, Or.inl cl, ac⟩
The unported dependencies are