The areas / V33. Data structures and computation
Mathlib.Data.WSeq.Relation
62 declarations. Mathlib docs · Source
theorem Stream'.WSeq.LiftRelO.match_1.congr_eq_1 E1 #
∀ {α : Type u_1} {β : Type u_2} (motive : Option (α × Stream'.WSeq α) → Option (β × Stream'.WSeq β) → Sort u_3)
(x : Option (α × Stream'.WSeq α)) (x_1 : Option (β × Stream'.WSeq β)) (h_1 : Unit → motive none none)
(h_2 : (a : α) → (s : Stream'.WSeq α) → (b : β) → (t : Stream'.WSeq β) → motive (some (a, s)) (some (b, t)))
(h_3 : (x : Option (α × Stream'.WSeq α)) → (x_2 : Option (β × Stream'.WSeq β)) → motive x x_2),
x = none →
x_1 = none →
(match x, x_1 with
| none, none => h_1 ()
| some (a, s), some (b, t) => h_2 a s b t
| x, x_2 => h_3 x x_2) ≍
h_1 ()
theorem Stream'.WSeq.LiftRelO.match_1.congr_eq_3 E1 #
∀ {α : Type u_1} {β : Type u_2} (motive : Option (α × Stream'.WSeq α) → Option (β × Stream'.WSeq β) → Sort u_3)
(x : Option (α × Stream'.WSeq α)) (x_1 : Option (β × Stream'.WSeq β)) (h_1 : Unit → motive none none)
(h_2 : (a : α) → (s : Stream'.WSeq α) → (b : β) → (t : Stream'.WSeq β) → motive (some (a, s)) (some (b, t)))
(h_3 : (x : Option (α × Stream'.WSeq α)) → (x_2 : Option (β × Stream'.WSeq β)) → motive x x_2)
(x_2 : Option (α × Stream'.WSeq α)) (x_3 : Option (β × Stream'.WSeq β)),
x = x_2 →
x_1 = x_3 →
(x_2 = none → x_3 = none → False) →
(∀ (a : α) (s : Stream'.WSeq α) (b : β) (t : Stream'.WSeq β), x_2 = some (a, s) → x_3 = some (b, t) → False) →
(match x, x_1 with
| none, none => h_1 ()
| some (a, s), some (b, t) => h_2 a s b t
| x, x_6 => h_3 x x_6) ≍
h_3 x_2 x_3
theorem Stream'.WSeq.LiftRelO.match_1.congr_eq_2 E1 #
∀ {α : Type u_1} {β : Type u_2} (motive : Option (α × Stream'.WSeq α) → Option (β × Stream'.WSeq β) → Sort u_3)
(x : Option (α × Stream'.WSeq α)) (x_1 : Option (β × Stream'.WSeq β)) (h_1 : Unit → motive none none)
(h_2 : (a : α) → (s : Stream'.WSeq α) → (b : β) → (t : Stream'.WSeq β) → motive (some (a, s)) (some (b, t)))
(h_3 : (x : Option (α × Stream'.WSeq α)) → (x_2 : Option (β × Stream'.WSeq β)) → motive x x_2) (a : α)
(s : Stream'.WSeq α) (b : β) (t : Stream'.WSeq β),
x = some (a, s) →
x_1 = some (b, t) →
(match x, x_1 with
| none, none => h_1 ()
| some (a, s), some (b, t) => h_2 a s b t
| x, x_2 => h_3 x x_2) ≍
h_2 a s b t
def Stream'.WSeq.LiftRelO E1 #
{α : Type u} →
{β : Type v} →
(α → β → Prop) →
(Stream'.WSeq α → Stream'.WSeq β → Prop) → Option (α × Stream'.WSeq α) → Option (β × Stream'.WSeq β) → Prop
lift a relation to a relation over weak sequences
theorem Stream'.WSeq.LiftRelO.imp E1 #
∀ {α : Type u} {β : Type v} {R S : α → β → Prop} {C D : Stream'.WSeq α → Stream'.WSeq β → Prop},
(∀ (a : α) (b : β), R a b → S a b) →
(∀ (s : Stream'.WSeq α) (t : Stream'.WSeq β), C s t → D s t) →
∀ {o : Option (α × Stream'.WSeq α)} {p : Option (β × Stream'.WSeq β)},
Stream'.WSeq.LiftRelO R C o p → Stream'.WSeq.LiftRelO S D o p
theorem Stream'.WSeq.LiftRelO.imp_right E1 #
∀ {α : Type u} {β : Type v} (R : α → β → Prop) {C D : Stream'.WSeq α → Stream'.WSeq β → Prop},
(∀ (s : Stream'.WSeq α) (t : Stream'.WSeq β), C s t → D s t) →
∀ {o : Option (α × Stream'.WSeq α)} {p : Option (β × Stream'.WSeq β)},
Stream'.WSeq.LiftRelO R C o p → Stream'.WSeq.LiftRelO R D o p
theorem Stream'.WSeq.LiftRelO.swap E1 #
∀ {α : Type u} {β : Type v} (R : α → β → Prop) (C : Stream'.WSeq α → Stream'.WSeq β → Prop),
Function.swap (Stream'.WSeq.LiftRelO R C) = Stream'.WSeq.LiftRelO (Function.swap R) (Function.swap C)
def Stream'.WSeq.BisimO E1 #
{α : Type u} →
(Stream'.WSeq α → Stream'.WSeq α → Prop) → Option (α × Stream'.WSeq α) → Option (α × Stream'.WSeq α) → Prop
Definition of bisimilarity for weak sequences
theorem Stream'.WSeq.BisimO.imp E1 #
∀ {α : Type u} {R S : Stream'.WSeq α → Stream'.WSeq α → Prop},
(∀ (s t : Stream'.WSeq α), R s t → S s t) →
∀ {o p : Option (α × Stream'.WSeq α)}, Stream'.WSeq.BisimO R o p → Stream'.WSeq.BisimO S o p
def Stream'.WSeq.LiftRel E1 #
{α : Type u} → {β : Type v} → (α → β → Prop) → Stream'.WSeq α → Stream'.WSeq β → Prop
Two weak sequences are LiftRel R related if they are either both empty,
or they are both nonempty and the heads are R related and the tails are
LiftRel R related. (This is a coinductive definition.)
theorem Stream'.WSeq.liftRel_destruct E1 #
∀ {α : Type u} {β : Type v} {R : α → β → Prop} {s : Stream'.WSeq α} {t : Stream'.WSeq β},
Stream'.WSeq.LiftRel R s t →
Computation.LiftRel (Stream'.WSeq.LiftRelO R (Stream'.WSeq.LiftRel R)) s.destruct t.destruct
theorem Stream'.WSeq.liftRel_destruct_iff E0 #
∀ {α : Type u} {β : Type v} {R : α → β → Prop} {s : Stream'.WSeq α} {t : Stream'.WSeq β},
Stream'.WSeq.LiftRel R s t ↔
Computation.LiftRel (Stream'.WSeq.LiftRelO R (Stream'.WSeq.LiftRel R)) s.destruct t.destruct
theorem Stream'.WSeq.LiftRel.swap_lem E1 #
∀ {α : Type u} {β : Type v} {R : α → β → Prop} {s1 : Stream'.WSeq α} {s2 : Stream'.WSeq β},
Stream'.WSeq.LiftRel R s1 s2 → Stream'.WSeq.LiftRel (Function.swap R) s2 s1
theorem Stream'.WSeq.LiftRel.swap E1 #
∀ {α : Type u} {β : Type v} (R : α → β → Prop),
Function.swap (Stream'.WSeq.LiftRel R) = Stream'.WSeq.LiftRel (Function.swap R)
instance Stream'.WSeq.LiftRelO.refl E0 #
∀ {α : Type u} (R : α → α → Prop) [Std.Refl R], Std.Refl (Stream'.WSeq.LiftRelO R fun x1 x2 ↦ x1 = x2)
instance Stream'.WSeq.LiftRel.refl E0 #
∀ {α : Type u} (R : α → α → Prop) [Std.Refl R], Std.Refl (Stream'.WSeq.LiftRel R)
instance Stream'.WSeq.LiftRel.symm E0 #
∀ {α : Type u} (R : α → α → Prop) [Std.Symm R], Std.Symm (Stream'.WSeq.LiftRel R)
instance Stream'.WSeq.LiftRel.trans E0 #
∀ {α : Type u} (R : α → α → Prop) [IsTrans α R], IsTrans (Stream'.WSeq α) (Stream'.WSeq.LiftRel R)
theorem Stream'.WSeq.LiftRel.equiv E1 #
∀ {α : Type u} (R : α → α → Prop), Equivalence R → Equivalence (Stream'.WSeq.LiftRel R)
def Stream'.WSeq.Equiv E1 #
{α : Type u} → Stream'.WSeq α → Stream'.WSeq α → Prop
If two sequences are equivalent, then they have the same values and
the same computational behavior (i.e. if one loops forever then so does
the other), although they may differ in the number of thinks needed to
arrive at the answer.
def Stream'.WSeq.«term_~ʷ_» E1 #
Lean.TrailingParserDescr
If two sequences are equivalent, then they have the same values and
the same computational behavior (i.e. if one loops forever then so does
the other), although they may differ in the number of thinks needed to
arrive at the answer.
theorem Stream'.WSeq.Equiv.refl E1 #
∀ {α : Type u} (s : Stream'.WSeq α), s ~ʷ s
theorem Stream'.WSeq.Equiv.symm E1 #
∀ {α : Type u} {s t : Stream'.WSeq α}, s ~ʷ t → t ~ʷ s
theorem Stream'.WSeq.Equiv.trans E1 #
∀ {α : Type u} {s t u : Stream'.WSeq α}, s ~ʷ t → t ~ʷ u → s ~ʷ u
theorem Stream'.WSeq.Equiv.equivalence E1 #
∀ {α : Type u}, Equivalence Stream'.WSeq.Equiv
theorem Stream'.WSeq.destruct_congr E1 #
∀ {α : Type u} {s t : Stream'.WSeq α},
s ~ʷ t → Computation.LiftRel (Stream'.WSeq.BisimO fun x1 x2 ↦ x1 ~ʷ x2) s.destruct t.destruct
theorem Stream'.WSeq.destruct_congr_iff E0 #
∀ {α : Type u} {s t : Stream'.WSeq α},
s ~ʷ t ↔ Computation.LiftRel (Stream'.WSeq.BisimO fun x1 x2 ↦ x1 ~ʷ x2) s.destruct t.destruct
theorem Stream'.WSeq.liftRel_dropn_destruct E1 #
∀ {α : Type u} {β : Type v} {R : α → β → Prop} {s : Stream'.WSeq α} {t : Stream'.WSeq β},
Stream'.WSeq.LiftRel R s t →
∀ (n : ℕ),
Computation.LiftRel (Stream'.WSeq.LiftRelO R (Stream'.WSeq.LiftRel R)) (s.drop n).destruct (t.drop n).destruct
theorem Stream'.WSeq.exists_of_liftRel_left E1 #
∀ {α : Type u} {β : Type v} {R : α → β → Prop} {s : Stream'.WSeq α} {t : Stream'.WSeq β},
Stream'.WSeq.LiftRel R s t → ∀ {a : α}, a ∈ s → ∃ b ∈ t, R a b
theorem Stream'.WSeq.exists_of_liftRel_right E1 #
∀ {α : Type u} {β : Type v} {R : α → β → Prop} {s : Stream'.WSeq α} {t : Stream'.WSeq β},
Stream'.WSeq.LiftRel R s t → ∀ {b : β}, b ∈ t → ∃ a ∈ s, R a b
theorem Stream'.WSeq.liftRel_nil E0 #
∀ {α : Type u} {β : Type v} (R : α → β → Prop), Stream'.WSeq.LiftRel R Stream'.WSeq.nil Stream'.WSeq.nil
theorem Stream'.WSeq.liftRel_cons E0 #
∀ {α : Type u} {β : Type v} (R : α → β → Prop) (a : α) (b : β) (s : Stream'.WSeq α) (t : Stream'.WSeq β),
Stream'.WSeq.LiftRel R (Stream'.WSeq.cons a s) (Stream'.WSeq.cons b t) ↔ R a b ∧ Stream'.WSeq.LiftRel R s t
theorem Stream'.WSeq.liftRel_think_left E0 #
∀ {α : Type u} {β : Type v} (R : α → β → Prop) (s : Stream'.WSeq α) (t : Stream'.WSeq β),
Stream'.WSeq.LiftRel R s.think t ↔ Stream'.WSeq.LiftRel R s t
theorem Stream'.WSeq.liftRel_think_right E0 #
∀ {α : Type u} {β : Type v} (R : α → β → Prop) (s : Stream'.WSeq α) (t : Stream'.WSeq β),
Stream'.WSeq.LiftRel R s t.think ↔ Stream'.WSeq.LiftRel R s t
theorem Stream'.WSeq.cons_congr E1 #
∀ {α : Type u} {s t : Stream'.WSeq α} (a : α), s ~ʷ t → Stream'.WSeq.cons a s ~ʷ Stream'.WSeq.cons a t
theorem Stream'.WSeq.think_equiv E1 #
∀ {α : Type u} (s : Stream'.WSeq α), s.think ~ʷ s
theorem Stream'.WSeq.think_congr E1 #
∀ {α : Type u} {s t : Stream'.WSeq α}, s ~ʷ t → s.think ~ʷ t.think
theorem Stream'.WSeq.head_congr E1 #
∀ {α : Type u} {s t : Stream'.WSeq α}, s ~ʷ t → s.head.Equiv t.head
theorem Stream'.WSeq.flatten_equiv E1 #
∀ {α : Type u} {c : Computation (Stream'.WSeq α)} {s : Stream'.WSeq α}, s ∈ c → Stream'.WSeq.flatten c ~ʷ s
theorem Stream'.WSeq.liftRel_flatten E1 #
∀ {α : Type u} {β : Type v} {R : α → β → Prop} {c1 : Computation (Stream'.WSeq α)} {c2 : Computation (Stream'.WSeq β)},
Computation.LiftRel (Stream'.WSeq.LiftRel R) c1 c2 →
Stream'.WSeq.LiftRel R (Stream'.WSeq.flatten c1) (Stream'.WSeq.flatten c2)
theorem Stream'.WSeq.flatten_congr E1 #
∀ {α : Type u} {c1 c2 : Computation (Stream'.WSeq α)},
Computation.LiftRel Stream'.WSeq.Equiv c1 c2 → Stream'.WSeq.flatten c1 ~ʷ Stream'.WSeq.flatten c2
theorem Stream'.WSeq.tail_congr E1 #
∀ {α : Type u} {s t : Stream'.WSeq α}, s ~ʷ t → s.tail ~ʷ t.tail
theorem Stream'.WSeq.dropn_congr E1 #
∀ {α : Type u} {s t : Stream'.WSeq α}, s ~ʷ t → ∀ (n : ℕ), s.drop n ~ʷ t.drop n
theorem Stream'.WSeq.get?_congr E1 #
∀ {α : Type u} {s t : Stream'.WSeq α}, s ~ʷ t → ∀ (n : ℕ), (s.get? n).Equiv (t.get? n)
theorem Stream'.WSeq.mem_congr E0 #
∀ {α : Type u} {s t : Stream'.WSeq α}, s ~ʷ t → ∀ (a : α), a ∈ s ↔ a ∈ t
theorem Stream'.WSeq.Equiv.ext E1 #
∀ {α : Type u} {s t : Stream'.WSeq α}, (∀ (n : ℕ), (s.get? n).Equiv (t.get? n)) → s ~ʷ t
theorem Stream'.WSeq.liftRel_map E1 #
∀ {α : Type u} {β : Type v} {γ : Type w} {δ : Type u_1} (R : α → β → Prop) (S : γ → δ → Prop) {s1 : Stream'.WSeq α}
{s2 : Stream'.WSeq β} {f1 : α → γ} {f2 : β → δ},
Stream'.WSeq.LiftRel R s1 s2 →
(∀ {a : α} {b : β}, R a b → S (f1 a) (f2 b)) →
Stream'.WSeq.LiftRel S (Stream'.WSeq.map f1 s1) (Stream'.WSeq.map f2 s2)
theorem Stream'.WSeq.map_congr E0 #
∀ {α : Type u} {β : Type v} (f : α → β) {s t : Stream'.WSeq α}, s ~ʷ t → Stream'.WSeq.map f s ~ʷ Stream'.WSeq.map f t
theorem Stream'.WSeq.liftRel_append E1 #
∀ {α : Type u} {β : Type v} (R : α → β → Prop) {s1 s2 : Stream'.WSeq α} {t1 t2 : Stream'.WSeq β},
Stream'.WSeq.LiftRel R s1 t1 → Stream'.WSeq.LiftRel R s2 t2 → Stream'.WSeq.LiftRel R (s1.append s2) (t1.append t2)
theorem Stream'.WSeq.liftRel_join.lem E1 #
∀ {α : Type u} {β : Type v} (R : α → β → Prop) {S : Stream'.WSeq (Stream'.WSeq α)} {T : Stream'.WSeq (Stream'.WSeq β)}
{U : Stream'.WSeq α → Stream'.WSeq β → Prop},
Stream'.WSeq.LiftRel (Stream'.WSeq.LiftRel R) S T →
(∀ (s1 : Stream'.WSeq α) (s2 : Stream'.WSeq β),
(∃ s t S T,
s1 = s.append S.join ∧
s2 = t.append T.join ∧ Stream'.WSeq.LiftRel R s t ∧ Stream'.WSeq.LiftRel (Stream'.WSeq.LiftRel R) S T) →
U s1 s2) →
∀ {a : Option (α × Stream'.WSeq α)}, a ∈ S.join.destruct → ∃ b ∈ T.join.destruct, Stream'.WSeq.LiftRelO R U a b
theorem Stream'.WSeq.liftRel_join E1 #
∀ {α : Type u} {β : Type v} (R : α → β → Prop) {S : Stream'.WSeq (Stream'.WSeq α)} {T : Stream'.WSeq (Stream'.WSeq β)},
Stream'.WSeq.LiftRel (Stream'.WSeq.LiftRel R) S T → Stream'.WSeq.LiftRel R S.join T.join
theorem Stream'.WSeq.join_congr E1 #
∀ {α : Type u} {S T : Stream'.WSeq (Stream'.WSeq α)}, Stream'.WSeq.LiftRel Stream'.WSeq.Equiv S T → S.join ~ʷ T.join
theorem Stream'.WSeq.liftRel_bind E1 #
∀ {α : Type u} {β : Type v} {γ : Type w} {δ : Type u_1} (R : α → β → Prop) (S : γ → δ → Prop) {s1 : Stream'.WSeq α}
{s2 : Stream'.WSeq β} {f1 : α → Stream'.WSeq γ} {f2 : β → Stream'.WSeq δ},
Stream'.WSeq.LiftRel R s1 s2 →
(∀ {a : α} {b : β}, R a b → Stream'.WSeq.LiftRel S (f1 a) (f2 b)) → Stream'.WSeq.LiftRel S (s1.bind f1) (s2.bind f2)
theorem Stream'.WSeq.bind_congr E1 #
∀ {α : Type u} {β : Type v} {s1 s2 : Stream'.WSeq α} {f1 f2 : α → Stream'.WSeq β},
s1 ~ʷ s2 → (∀ (a : α), f1 a ~ʷ f2 a) → s1.bind f1 ~ʷ s2.bind f2
theorem Stream'.WSeq.join_ret E0 #
∀ {α : Type u} (s : Stream'.WSeq α), (Stream'.WSeq.ret s).join ~ʷ s
theorem Stream'.WSeq.join_map_ret E0 #
∀ {α : Type u} (s : Stream'.WSeq α), (Stream'.WSeq.map Stream'.WSeq.ret s).join ~ʷ s
theorem Stream'.WSeq.join_append E0 #
∀ {α : Type u} (S T : Stream'.WSeq (Stream'.WSeq α)), (S.append T).join ~ʷ S.join.append T.join
theorem Stream'.WSeq.bind_ret E0 #
∀ {α : Type u} {β : Type v} (f : α → β) (s : Stream'.WSeq α), s.bind (Stream'.WSeq.ret ∘ f) ~ʷ Stream'.WSeq.map f s
theorem Stream'.WSeq.ret_bind E0 #
∀ {α : Type u} {β : Type v} (a : α) (f : α → Stream'.WSeq β), (Stream'.WSeq.ret a).bind f ~ʷ f a
theorem Stream'.WSeq.join_join E0 #
∀ {α : Type u} (SS : Stream'.WSeq (Stream'.WSeq (Stream'.WSeq α))),
SS.join.join ~ʷ (Stream'.WSeq.map Stream'.WSeq.join SS).join
theorem Stream'.WSeq.bind_assoc_comp E0 #
∀ {α : Type u} {β : Type v} {γ : Type w} (s : Stream'.WSeq α) (f : α → Stream'.WSeq β) (g : β → Stream'.WSeq γ),
(s.bind f).bind g ~ʷ s.bind ((fun y ↦ y.bind g) ∘ f)
theorem Stream'.WSeq.bind_assoc E0 #
∀ {α : Type u} {β : Type v} {γ : Type w} (s : Stream'.WSeq α) (f : α → Stream'.WSeq β) (g : β → Stream'.WSeq γ),
(s.bind f).bind g ~ʷ s.bind fun x ↦ (f x).bind g