chars int64 40 24k | content_type stringclasses 9
values | id stringlengths 13 64 | source stringclasses 5
values | subset stringclasses 31
values | text stringlengths 40 24k |
|---|---|---|---|---|---|
224 | leanexplore_declaration | leanexplore:387323 | leanexplore_sqlite | leanexplore_declarations | /-- A relation is semi-confluent when single and multiple steps with common origin
are multi-joinable. -/
abbrev SemiConfluent (r : α → α → Prop) :=
∀ {x y₁ y₂}, ReflTransGen r x y₂ → r x y₁ → Join (ReflTransGen r) y₁ y₂ |
184 | leanexplore_declaration | leanexplore:387324 | leanexplore_sqlite | leanexplore_declarations | /-- A relation has the Church Rosser property when equivalence implies multi-joinability. -/
abbrev ChurchRosser (r : α → α → Prop) := ∀ {x y}, EqvGen r x y → Join (ReflTransGen r) x y |
446 | leanexplore_declaration | leanexplore:387325 | leanexplore_sqlite | leanexplore_declarations | /-- Extending a multistep reduction by a single step preserves multi-joinability. -/
lemma Diamond.extend (h : Diamond r) :
ReflTransGen r a b → r a c → Join (ReflTransGen r) b c := by
intros ab ac
induction ab using ReflTransGen.head_induction_on generalizing c
case refl => exists c, .single ac
case head a... |
375 | leanexplore_declaration | leanexplore:387326 | leanexplore_sqlite | leanexplore_declarations | /-- The diamond property implies confluence. -/
theorem Diamond.toConfluent (h : Diamond r) : Confluent r := by
intros a b c ab bc
induction ab using ReflTransGen.head_induction_on generalizing c
case refl => exists c
case head _ _ a'_c' _ ih =>
obtain ⟨d, cd, c'_d⟩ := h.extend bc a'_c'
obtain ⟨d', b_d'... |
414 | leanexplore_declaration | leanexplore:387327 | leanexplore_sqlite | leanexplore_declarations | theorem Confluent.toChurchRosser (h : Confluent r) : ChurchRosser r := by
intro x y h_eqv
induction h_eqv with
| rel _ b => exists b; grind [ReflTransGen.single]
| refl a => exists a
| symm a b _ ih => exact symmetric_join ih
| trans _ _ _ _ _ ih1 ih2 =>
obtain ⟨u, _, hbu⟩ := ih1
obtain ⟨v, hbv,... |
290 | leanexplore_declaration | leanexplore:387328 | leanexplore_sqlite | leanexplore_declarations | theorem SemiConfluent.toConfluent (h : SemiConfluent r) : Confluent r := by
intro x y1 y2 h_xy1 h_xy2
induction h_xy1 with
| refl => use y2
| tail h_xz h_zy1 ih =>
obtain ⟨u, h_zu, _⟩ := ih
obtain ⟨v, _, _⟩ := h h_zu h_zy1
exists v
grind [ReflTransGen.trans] |
118 | leanexplore_declaration | leanexplore:387329 | leanexplore_sqlite | leanexplore_declarations | theorem SemiConfluent_iff_ChurchRosser : SemiConfluent r ↔ ChurchRosser r :=
List.TFAE.out confluent_equivalents 1 0 |
110 | leanexplore_declaration | leanexplore:387330 | leanexplore_sqlite | leanexplore_declarations | theorem Confluent_iff_ChurchRosser : Confluent r ↔ ChurchRosser r :=
List.TFAE.out confluent_equivalents 2 0 |
112 | leanexplore_declaration | leanexplore:387331 | leanexplore_sqlite | leanexplore_declarations | theorem Confluent_iff_SemiConfluent : Confluent r ↔ SemiConfluent r :=
List.TFAE.out confluent_equivalents 2 1 |
137 | leanexplore_declaration | leanexplore:387332 | leanexplore_sqlite | leanexplore_declarations | theorem Confluent_of_unique_end {x : α} (h : ∀ y : α, ReflTransGen r y x) : Confluent r := by
intro a b c hab hac
exact ⟨x, h b, h c⟩ |
160 | leanexplore_declaration | leanexplore:387333 | leanexplore_sqlite | leanexplore_declarations | /-- An element is reducible with respect to a relation if there is a value it is related to. -/
abbrev Reducible (r : α → α → Prop) (x : α) : Prop := ∃ y, r x y |
118 | leanexplore_declaration | leanexplore:387334 | leanexplore_sqlite | leanexplore_declarations | /-- An element is normal if it is not reducible. -/
abbrev Normal (r : α → α → Prop) (x : α) : Prop := ¬ Reducible r x |
105 | leanexplore_declaration | leanexplore:387335 | leanexplore_sqlite | leanexplore_declarations | theorem Normal_iff (r : α → α → Prop) (x : α) : Normal r x ↔ ∀ y, ¬ r x y := by
rw [Normal, not_exists] |
167 | leanexplore_declaration | leanexplore:387336 | leanexplore_sqlite | leanexplore_declarations | /-- An element is normalizable if it is related to a normal element. -/
abbrev Normalizable (r : α → α → Prop) (x : α) : Prop :=
∃ n, ReflTransGen r x n ∧ Normal r n |
140 | leanexplore_declaration | leanexplore:387337 | leanexplore_sqlite | leanexplore_declarations | /-- A relation is normalizing when every element is normalizable. -/
abbrev Normalizing (r : α → α → Prop) : Prop :=
∀ x, Normalizable r x |
182 | leanexplore_declaration | leanexplore:387338 | leanexplore_sqlite | leanexplore_declarations | /-- A multi-step from a normal form must be reflexive. -/
@[grind =>]
theorem Normal.reflTransGen_eq (h : Normal r x) (xy : ReflTransGen r x y) : x = y := by
induction xy <;> grind |
272 | leanexplore_declaration | leanexplore:387339 | leanexplore_sqlite | leanexplore_declarations | /-- For a Church-Rosser relation, elements in an equivalence class must be multi-step related. -/
theorem ChurchRosser.normal_eqvGen_reflTransGen (cr : ChurchRosser r) (norm : Normal r x)
(xy : EqvGen r y x) : ReflTransGen r y x := by
have ⟨_, _, _⟩ := cr xy
grind |
248 | leanexplore_declaration | leanexplore:387340 | leanexplore_sqlite | leanexplore_declarations | /-- For a Church-Rosser relation there is one normal form in each equivalence class. -/
theorem ChurchRosser.normal_eq (cr : ChurchRosser r) (nx : Normal r x) (ny : Normal r y)
(xy : EqvGen r x y) : x = y := by
have ⟨_, _, _⟩ := cr xy
grind |
280 | leanexplore_declaration | leanexplore:387341 | leanexplore_sqlite | leanexplore_declarations | /-- A pair of subrelations lifts to transitivity on the relation. -/
@[implicit_reducible]
def trans_of_subrelation (s s' r : α → α → Prop) (hr : IsTrans α r)
(h : Subrelation s r) (h' : Subrelation s' r) : Trans s s' r where
trans hab hbc := hr.trans _ _ _ (h hab) (h' hbc) |
255 | leanexplore_declaration | leanexplore:387342 | leanexplore_sqlite | leanexplore_declarations | /-- A subrelation lifts to transitivity on the left of the relation. -/
@[implicit_reducible]
def trans_of_subrelation_left (s r : α → α → Prop) (hr : IsTrans α r)
(h : Subrelation s r) : Trans s r r where
trans hab hbc := hr.trans _ _ _ (h hab) hbc |
257 | leanexplore_declaration | leanexplore:387343 | leanexplore_sqlite | leanexplore_declarations | /-- A subrelation lifts to transitivity on the right of the relation. -/
@[implicit_reducible]
def trans_of_subrelation_right (s r : α → α → Prop) (hr : IsTrans α r)
(h : Subrelation s r) : Trans r s r where
trans hab hbc := hr.trans _ _ _ hab (h hbc) |
219 | leanexplore_declaration | leanexplore:387344 | leanexplore_sqlite | leanexplore_declarations | /-- Confluence implies that multi-step joinability is an equivalence. -/
theorem Confluent.equivalence_join_reflTransGen (h : Confluent r) :
Equivalence (Join (ReflTransGen r)) := by
apply equivalence_join
grind |
250 | leanexplore_declaration | leanexplore:387345 | leanexplore_sqlite | leanexplore_declarations | /-- A relation is terminating when the inverse of its transitive closure is well-founded.
Note that this is also called Noetherian or strongly normalizing in the literature. -/
abbrev Terminating (r : α → α → Prop) := WellFounded (fun a b => r b a) |
189 | leanexplore_declaration | leanexplore:387346 | leanexplore_sqlite | leanexplore_declarations | theorem Terminating.toTransGen (ht : Terminating r) : Terminating (TransGen r) := by
suffices _ : (fun a b => TransGen r b a) = TransGen (Function.swap r) by grind
grind [transGen_swap] |
184 | leanexplore_declaration | leanexplore:387347 | leanexplore_sqlite | leanexplore_declarations | theorem Terminating.ofTransGen : Terminating (TransGen r) → Terminating r := by
suffices _ : (fun a b => TransGen r b a) = TransGen (Function.swap r) by grind
grind [transGen_swap] |
105 | leanexplore_declaration | leanexplore:387348 | leanexplore_sqlite | leanexplore_declarations | theorem Terminating.iff_transGen : Terminating (TransGen r) ↔ Terminating r :=
⟨ofTransGen, toTransGen⟩ |
274 | leanexplore_declaration | leanexplore:387349 | leanexplore_sqlite | leanexplore_declarations | theorem Terminating.subrelation {r' : α → α → Prop} (hr : Terminating r) (h : Subrelation r' r) :
Terminating r' := by
rw [Terminating, wellFounded_iff_isEmpty_descending_chain] at hr ⊢
rw [isEmpty_subtype]
intro f hf
exact hr.elim ⟨f, fun n ↦ by exact h (hf n)⟩ |
305 | leanexplore_declaration | leanexplore:387350 | leanexplore_sqlite | leanexplore_declarations | theorem Terminating.isNormalizing (h : Terminating r) : Normalizing r := by
unfold Terminating at h
intro t
apply WellFounded.induction h t
intro a ih
by_cases ha : Reducible r a
· obtain ⟨b, hab⟩ := ha
obtain ⟨n, hbn, hn⟩ := ih b hab
exact ⟨n, ReflTransGen.head hab hbn, hn⟩
· use a |
914 | leanexplore_declaration | leanexplore:387351 | leanexplore_sqlite | leanexplore_declarations | theorem Terminating.isConfluent_iff_all_unique_Normal (ht : Terminating r) :
Confluent r ↔ ∀ a : α, ∃! n : α, ReflTransGen r a n ∧ Normal r n := by
have hn : Normalizing r := ht.isNormalizing
constructor
· intro hc a
apply existsUnique_of_exists_of_unique (hn a)
rintro n₁ n₂ ⟨hr₁, hn₁⟩ ⟨hr₂, hn₂⟩
... |
142 | leanexplore_declaration | leanexplore:387352 | leanexplore_sqlite | leanexplore_declarations | /-- A relation is convergent when it is both confluent and terminating. -/
abbrev Convergent (r : α → α → Prop) := Confluent r ∧ Terminating r |
78 | leanexplore_declaration | leanexplore:387353 | leanexplore_sqlite | leanexplore_declarations | theorem Convergent.isTerminating (h : Convergent r) : Terminating r := h.right |
73 | leanexplore_declaration | leanexplore:387354 | leanexplore_sqlite | leanexplore_declarations | theorem Convergent.isConfluent (h : Convergent r) : Confluent r := h.left |
100 | leanexplore_declaration | leanexplore:387355 | leanexplore_sqlite | leanexplore_declarations | theorem Convergent.isNormalizing (h : Convergent r) : Normalizing r := h.isTerminating.isNormalizing |
180 | leanexplore_declaration | leanexplore:387356 | leanexplore_sqlite | leanexplore_declarations | theorem Convergent.unique_Normal (h : Convergent r) :
∀ a : α, ∃! n : α, ReflTransGen r a n ∧ Normal r n :=
h.isTerminating.isConfluent_iff_all_unique_Normal.mp h.isConfluent |
203 | leanexplore_declaration | leanexplore:387357 | leanexplore_sqlite | leanexplore_declarations | /-- A relation is locally confluent when all reductions with a common origin are multi-joinable -/
abbrev LocallyConfluent (r : α → α → Prop) :=
∀ {a b c : α}, r a b → r a c → Join (ReflTransGen r) b c |
137 | leanexplore_declaration | leanexplore:387358 | leanexplore_sqlite | leanexplore_declarations | theorem Confluent.toLocallyConfluent (h : Confluent r) : LocallyConfluent r := by
intro _ _ _ ab ac
exact h (.single ab) (.single ac) |
738 | leanexplore_declaration | leanexplore:387359 | leanexplore_sqlite | leanexplore_declarations | /-- Newman's lemma: a terminating, locally confluent relation is confluent. -/
theorem LocallyConfluent.Terminating_toConfluent (hlc : LocallyConfluent r) (ht : Terminating r) :
Confluent r := by
intro x
induction x using ht.induction with
| h x ih =>
intro y z xy xz
cases xy.cases_head with
| inl... |
214 | leanexplore_declaration | leanexplore:387360 | leanexplore_sqlite | leanexplore_declarations | /-- A relation is strongly confluent when single steps are reflexive- and multi-joinable. -/
abbrev StronglyConfluent (r : α → α → Prop) :=
∀ {x y₁ y₂}, r x y₁ → r x y₂ → ∃ z, ReflGen r y₁ z ∧ ReflTransGen r y₂ z |
202 | leanexplore_declaration | leanexplore:387361 | leanexplore_sqlite | leanexplore_declarations | /-- Generalization of `Confluent` to two relations. -/
def Commute (r₁ r₂ : α → α → Prop) := ∀ {x y₁ y₂},
ReflTransGen r₁ x y₁ → ReflTransGen r₂ x y₂ → ∃ z, ReflTransGen r₂ y₁ z ∧ ReflTransGen r₁ y₂ z |
132 | leanexplore_declaration | leanexplore:387362 | leanexplore_sqlite | leanexplore_declarations | theorem Commute.symmetric : Symmetric (@Commute α) := by
intro r₁ r₂ h x y₁ y₂ x_y₁ x_y₂
obtain ⟨_, _, _⟩ := h x_y₂ x_y₁
grind |
62 | leanexplore_declaration | leanexplore:387363 | leanexplore_sqlite | leanexplore_declarations | theorem Commute.toConfluent : Commute r r = Confluent r := rfl |
187 | leanexplore_declaration | leanexplore:387364 | leanexplore_sqlite | leanexplore_declarations | /-- Generalization of `StronglyConfluent` to two relations. -/
def StronglyCommute (r₁ r₂ : α → α → Prop) :=
∀ {x y₁ y₂}, r₁ x y₁ → r₂ x y₂ → ∃ z, ReflGen r₂ y₁ z ∧ ReflTransGen r₁ y₂ z |
94 | leanexplore_declaration | leanexplore:387365 | leanexplore_sqlite | leanexplore_declarations | theorem StronglyCommute.toStronglyConfluent : StronglyCommute r r = StronglyConfluent r := rfl |
155 | leanexplore_declaration | leanexplore:387366 | leanexplore_sqlite | leanexplore_declarations | /-- Generalization of `Diamond` to two relations. -/
def DiamondCommute (r₁ r₂ : α → α → Prop) :=
∀ {x y₁ y₂}, r₁ x y₁ → r₂ x y₂ → ∃ z, r₂ y₁ z ∧ r₁ y₂ z |
75 | leanexplore_declaration | leanexplore:387367 | leanexplore_sqlite | leanexplore_declarations | theorem DiamondCommute.toDiamond : DiamondCommute r r = Diamond r := by rfl |
401 | leanexplore_declaration | leanexplore:387368 | leanexplore_sqlite | leanexplore_declarations | theorem StronglyCommute.extend (h : StronglyCommute r₁ r₂) (xy : ReflTransGen r₁ x y)
(xz : r₂ x z) : ∃ w, ReflGen r₂ y w ∧ ReflTransGen r₁ z w := by
induction xy with
| refl => exact ⟨z, .single xz, .refl⟩
| @tail b c _ bc ih =>
obtain ⟨w, bw, zw⟩ := ih
cases bw with
| refl => exact ⟨c, .refl, zw... |
304 | leanexplore_declaration | leanexplore:387369 | leanexplore_sqlite | leanexplore_declarations | theorem StronglyCommute.toCommute (h : StronglyCommute r₁ r₂) : Commute r₁ r₂ := by
intro x y₁ y₂ x_y₁ x_y₂
induction x_y₂ with
| refl => exists y₁
| @tail a b xa ab ih =>
obtain ⟨z, y₁_z, y₂_z⟩ := ih
obtain ⟨w, zw, bw⟩ := h.extend y₂_z ab
exact ⟨w, y₁_z.trans zw.to_reflTransGen, bw⟩ |
110 | leanexplore_declaration | leanexplore:387370 | leanexplore_sqlite | leanexplore_declarations | theorem StronglyConfluent.toConfluent (h : StronglyConfluent r) : Confluent r :=
StronglyCommute.toCommute h |
86 | leanexplore_declaration | leanexplore:387371 | leanexplore_sqlite | leanexplore_declarations | @[scoped grind <=]
theorem join_inl (r₁_ab : r₁ a b) : (r₁ ⊔ r₂) a b :=
Or.inl r₁_ab |
86 | leanexplore_declaration | leanexplore:387372 | leanexplore_sqlite | leanexplore_declarations | @[scoped grind <=]
theorem join_inr (r₂_ab : r₂ a b) : (r₁ ⊔ r₂) a b :=
Or.inr r₂_ab |
141 | leanexplore_declaration | leanexplore:387373 | leanexplore_sqlite | leanexplore_declarations | @[scoped grind <=]
theorem join_inl_reflTransGen (r₁_ab : ReflTransGen r₁ a b) : ReflTransGen (r₁ ⊔ r₂) a b := by
induction r₁_ab <;> grind |
141 | leanexplore_declaration | leanexplore:387374 | leanexplore_sqlite | leanexplore_declarations | @[scoped grind <=]
theorem join_inr_reflTransGen (r₂_ab : ReflTransGen r₂ a b) : ReflTransGen (r₁ ⊔ r₂) a b := by
induction r₂_ab <;> grind |
409 | leanexplore_declaration | leanexplore:387375 | leanexplore_sqlite | leanexplore_declarations | lemma Commute.join_left (c₁ : Commute r₁ r₃) (c₂ : Commute r₂ r₃) : Commute (r₁ ⊔ r₂) r₃ := by
intro x y z xy xz
induction xy with
| refl => grind
| @tail b c _ bc ih =>
have ⟨w, bw, _⟩ := ih
cases bc with
| inl bc =>
obtain ⟨_, _, _⟩ := c₁ (.single bc) bw
grind [ReflTransGen.trans]
... |
426 | leanexplore_declaration | leanexplore:387376 | leanexplore_sqlite | leanexplore_declarations | theorem Commute.join_confluent (c₁ : Confluent r₁) (c₂ : Confluent r₂) (comm : Commute r₁ r₂) :
Confluent (r₁ ⊔ r₂) := by
intro a b c ab ac
induction ab generalizing c with
| refl => exists c
| @tail x y ax xy ih =>
have h_comm : Commute (r₁ ⊔ r₂) (r₁ ⊔ r₂) := by apply_rules [join_left, symmetric]
o... |
307 | leanexplore_declaration | leanexplore:387377 | leanexplore_sqlite | leanexplore_declarations | /-- If a relation is squeezed by a relation and its multi-step closure, they are multi-step equal -/
theorem reflTransGen_mono_closed (h₁ : Subrelation r₁ r₂) (h₂ : Subrelation r₂ (ReflTransGen r₁)) :
ReflTransGen r₁ = ReflTransGen r₂ := by
ext
exact ⟨ReflTransGen.mono @h₁, reflTransGen_closed @h₂⟩ |
173 | leanexplore_declaration | leanexplore:387378 | leanexplore_sqlite | leanexplore_declarations | lemma ReflGen.compRel_symm : ReflGen (SymmGen r) a b → ReflGen (SymmGen r) b a
| .refl => .refl
| .single (.inl h) => .single (.inr h)
| .single (.inr h) => .single (.inl h) |
576 | leanexplore_declaration | leanexplore:387379 | leanexplore_sqlite | leanexplore_declarations | @[simp, grind =]
theorem reflTransGen_compRel : ReflTransGen (SymmGen r) = EqvGen r := by
ext a b
constructor
· intro h
induction h with
| refl => exact .refl _
| tail hab hbc ih =>
cases hbc with
| inl h => exact ih.trans _ _ _ (.rel _ _ h)
| inr h => exact ih.trans _ _ _ (.symm _ _... |
397 | leanexplore_declaration | leanexplore:387380 | leanexplore_sqlite | leanexplore_declarations | /-- `Relator.RightUnique` corresponds to deterministic reductions, which are confluent, as all
multi-reductions with a common origin start the same (this fact is
`Relation.ReflTransGen.total_of_right_unique`.) -/
theorem RightUnique.toConfluent (hr : Relator.RightUnique r) : Confluent r := by
intro a b c ab ac
obta... |
508 | leanexplore_declaration | leanexplore:387381 | leanexplore_sqlite | leanexplore_declarations | /--
This command adds notations for relations. This should not usually be called directly, but from
the `reduction_sys` attribute.
As an example `reduction_notation foo "β"` will add the notations "⭢β" and "↠β".
Note that the string used will afterwards be registered as a notation. This means that if you have... |
266 | leanexplore_declaration | leanexplore:387382 | leanexplore_sqlite | leanexplore_declarations | /--
This attribute calls the `reduction_notation` command for the annotated declaration, such as in:
```
@[reduction_sys "ₙ", simp]
def PredReduction (a b : ℕ) : Prop := a = b + 1
```
-/
syntax (name := reduction_sys) "reduction_sys" (ppSpace str)? : attr |
217 | leanexplore_declaration | leanexplore:387383 | leanexplore_sqlite | leanexplore_declarations | /-- `f : ι → Set α` saturates `s : Set α` iff `f i` is a subset of `s`
whenever `f i` and `s` has any intersection at all. -/
def Saturates (f : ι → Set α) (s : Set α) : Prop :=
∀ i : ι, (f i ∩ s).Nonempty → f i ⊆ s |
257 | leanexplore_declaration | leanexplore:387384 | leanexplore_sqlite | leanexplore_declarations | /-- If `f` saturates `s`, then `f` saturates its complement `sᶜ` as well. -/
@[simp, scoped grind .]
theorem saturates_compl (hs : Saturates f s) : Saturates f sᶜ := by
rintro i ⟨_, _⟩ y _ _
have : (f i ∩ s).Nonempty := ⟨y, by grind⟩
grind [Saturates] |
466 | leanexplore_declaration | leanexplore:387385 | leanexplore_sqlite | leanexplore_declarations | /-- If `f` is a cover and saturates `s`, then `s` is the union of all `f i` that intersects `s`. -/
theorem saturates_eq_biUnion (hs : Saturates f s) (hc : ⋃ i, f i = univ) :
s = ⋃ i ∈ {i | (f i ∩ s).Nonempty}, f i := by
ext x
simp only [mem_setOf_eq, mem_iUnion, exists_prop]
constructor
· intro h_x
obt... |
475 | leanexplore_declaration | leanexplore:387386 | leanexplore_sqlite | leanexplore_declarations | /--
An infinite tape representation using a list of `Option` values,
where the list is eventually `none`.
Represented as a `List (Option Symbol)` that does not end with `none`.
-/
structure StackTape (Symbol : Type) where
/-- The underlying list representation -/
toList : List (Option Symbol)
/--
The list can ... |
89 | leanexplore_declaration | leanexplore:387387 | leanexplore_sqlite | leanexplore_declarations | /-- The empty `StackTape` -/
@[scoped grind]
def nil : StackTape Symbol := ⟨[], by grind⟩ |
62 | leanexplore_declaration | leanexplore:387388 | leanexplore_sqlite | leanexplore_declarations | instance : Inhabited (StackTape Symbol) where
default := nil |
56 | leanexplore_declaration | leanexplore:387389 | leanexplore_sqlite | leanexplore_declarations | instance : EmptyCollection (StackTape Symbol) :=
⟨nil⟩ |
64 | leanexplore_declaration | leanexplore:387390 | leanexplore_sqlite | leanexplore_declarations | @[simp]
lemma empty_eq_nil : (∅ : StackTape Symbol) = nil := rfl |
86 | leanexplore_declaration | leanexplore:387391 | leanexplore_sqlite | leanexplore_declarations | @[simp, scoped grind =]
lemma nil_toList : (nil : StackTape Symbol).toList = [] := rfl |
295 | leanexplore_declaration | leanexplore:387392 | leanexplore_sqlite | leanexplore_declarations | /-- Prepend an `Option` to the `StackTape` -/
@[scoped grind]
def cons (x : Option Symbol) (xs : StackTape Symbol) : StackTape Symbol :=
match x, xs with
| none, ⟨[], _⟩ => ⟨[], by grind⟩
| none, ⟨hd :: tl, hl⟩ => ⟨none :: hd :: tl, by grind⟩
| some a, ⟨l, hl⟩ => ⟨some a :: l, by grind⟩ |
113 | leanexplore_declaration | leanexplore:387393 | leanexplore_sqlite | leanexplore_declarations | @[simp, scoped grind =]
lemma cons_none_nil_toList : (cons none (nil : StackTape Symbol)).toList = [] := by grind |
157 | leanexplore_declaration | leanexplore:387394 | leanexplore_sqlite | leanexplore_declarations | @[simp, scoped grind =]
lemma cons_some_toList (a : Symbol) (l : StackTape Symbol) :
(cons (some a) l).toList = some a :: l.toList := by simp only [cons] |
210 | leanexplore_declaration | leanexplore:387395 | leanexplore_sqlite | leanexplore_declarations | /-- Remove the first element of the `StackTape`, returning the rest -/
@[scoped grind]
def tail (l : StackTape Symbol) : StackTape Symbol :=
match hl : l.toList with
| [] => nil
| hd :: t => ⟨t, by grind⟩ |
168 | leanexplore_declaration | leanexplore:387396 | leanexplore_sqlite | leanexplore_declarations | /-- Get the first element of the `StackTape`. -/
@[scoped grind]
def head (l : StackTape Symbol) : Option Symbol :=
match l.toList with
| [] => none
| h :: _ => h |
252 | leanexplore_declaration | leanexplore:387397 | leanexplore_sqlite | leanexplore_declarations | lemma eq_iff (l1 l2 : StackTape Symbol) :
l1 = l2 ↔ l1.head = l2.head ∧ l1.tail = l2.tail := by
constructor
· grind
· intro ⟨hhead, htail⟩
cases l1 with | mk as1 h1 =>
cases l2 with | mk as2 h2 =>
cases as1 <;> cases as2 <;> grind |
203 | leanexplore_declaration | leanexplore:387398 | leanexplore_sqlite | leanexplore_declarations | @[simp]
lemma head_cons (o : Option Symbol) (l : StackTape Symbol) : (cons o l).head = o := by
cases o with
| none =>
cases l with | mk toList hl =>
cases toList <;> grind
| some a => grind |
223 | leanexplore_declaration | leanexplore:387399 | leanexplore_sqlite | leanexplore_declarations | @[simp]
lemma tail_cons (o : Option Symbol) (l : StackTape Symbol) : (cons o l).tail = l := by
cases o with
| none =>
cases l with | mk toList h =>
cases toList <;> grind
| some a =>
simp only [cons, tail] |
111 | leanexplore_declaration | leanexplore:387400 | leanexplore_sqlite | leanexplore_declarations | @[simp]
lemma cons_head_tail (l : StackTape Symbol) :
cons (l.head) (l.tail) = l := by
rw [eq_iff]
simp |
164 | leanexplore_declaration | leanexplore:387401 | leanexplore_sqlite | leanexplore_declarations | /-- Create a `StackTape` from a list by mapping all elements to `some` -/
@[scoped grind]
def map_some (l : List Symbol) : StackTape Symbol := ⟨l.map some, by simp⟩ |
169 | leanexplore_declaration | leanexplore:387402 | leanexplore_sqlite | leanexplore_declarations | /-- The length of the `StackTape` is the number of elements up to the last non-`none` element -/
@[scoped grind]
def length (l : StackTape Symbol) : ℕ := l.toList.length |
84 | leanexplore_declaration | leanexplore:387403 | leanexplore_sqlite | leanexplore_declarations | lemma length_tail_le (l : StackTape Symbol) : l.tail.length ≤ l.length := by
grind |
196 | leanexplore_declaration | leanexplore:387404 | leanexplore_sqlite | leanexplore_declarations | @[scoped grind =]
lemma length_cons_none (l : StackTape Symbol) :
(cons none l).length = l.length + if l.length = 0 then 0 else 1 := by
cases l with | mk toList h =>
cases toList <;> grind |
136 | leanexplore_declaration | leanexplore:387405 | leanexplore_sqlite | leanexplore_declarations | @[scoped grind =]
lemma length_cons_some (a : Symbol) (l : StackTape Symbol) :
(cons (some a) l).length = l.length + 1 := by
grind |
128 | leanexplore_declaration | leanexplore:387406 | leanexplore_sqlite | leanexplore_declarations | lemma length_cons_le (o : Option Symbol) (l : StackTape Symbol) :
(cons o l).length ≤ l.length + 1 := by
cases o <;> grind |
108 | leanexplore_declaration | leanexplore:387407 | leanexplore_sqlite | leanexplore_declarations | @[simp, scoped grind =]
lemma length_map_some (l : List Symbol) : (map_some l).length = l.length := by grind |
90 | leanexplore_declaration | leanexplore:387408 | leanexplore_sqlite | leanexplore_declarations | @[simp, scoped grind =]
lemma length_nil : (nil : StackTape Symbol).length = 0 := by grind |
703 | leanexplore_declaration | leanexplore:387409 | leanexplore_sqlite | leanexplore_declarations | /-- A linter for checking that new declarations fall under some preexisting namespace. -/
@[env_linter]
public meta def topNamespace : Batteries.Tactic.Lint.Linter where
noErrorsFound := "No declarations are outside a namespace."
errorsFound := "TOP LEVEL DECLARATIONS:"
test declName := do
if ← isAutoDecl dec... |
325 | leanexplore_declaration | leanexplore:387410 | leanexplore_sqlite | leanexplore_declarations | /--
The notation typeclass for inference systems.
This enables the notation `⇓a`, where `a : α` is a derivable value.
-/
class InferenceSystem (α : Type u) where
/--
`⇓a` is a derivation of `a`, that is, a witness that `a` is derivable.
The meaning of this notation is type-dependent.
-/
derivation (s : α) : S... |
233 | leanexplore_declaration | leanexplore:387411 | leanexplore_sqlite | leanexplore_declarations | @[inherit_doc] scoped notation "⇓" a:90 => InferenceSystem.derivation a
/-- Rewrites the conclusion of a proof into an equal one. -/
@[scoped grind =]
def rwConclusion [InferenceSystem α] {Γ Δ : α} (h : Γ = Δ) (p : ⇓Γ) : ⇓Δ := h ▸ p |
160 | leanexplore_declaration | leanexplore:387412 | leanexplore_sqlite | leanexplore_declarations | /-- Rewrites the conclusion of a proof into an equal one. -/
@[scoped grind =]
def rwConclusion [InferenceSystem α] {Γ Δ : α} (h : Γ = Δ) (p : ⇓Γ) : ⇓Δ := h ▸ p |
126 | leanexplore_declaration | leanexplore:387413 | leanexplore_sqlite | leanexplore_declarations | /-- `a` is derivable if it is the conclusion of some derivation. -/
def Derivable [InferenceSystem α] (a : α) := Nonempty (⇓a) |
150 | leanexplore_declaration | leanexplore:387414 | leanexplore_sqlite | leanexplore_declarations | /-- Shows derivability from a derivation. -/
theorem Derivable.fromDerivation [InferenceSystem α] {a : α} (d : ⇓a) : Derivable a :=
Nonempty.intro d |
91 | leanexplore_declaration | leanexplore:387415 | leanexplore_sqlite | leanexplore_declarations | instance [InferenceSystem α] {a : α} : Coe (⇓a) (Derivable a) := ⟨Derivable.fromDerivation⟩ |
206 | leanexplore_declaration | leanexplore:387416 | leanexplore_sqlite | leanexplore_declarations | /-- Extracts (noncomputably) a derivation from the fact that a conclusion is derivable. -/
noncomputable def Derivable.toDerivation [InferenceSystem α] {a : α} (d : Derivable a) : ⇓a :=
Classical.choice d |
105 | leanexplore_declaration | leanexplore:387417 | leanexplore_sqlite | leanexplore_declarations | noncomputable instance [InferenceSystem α] {a : α} : Coe (Derivable a) (⇓a) :=
⟨Derivable.toDerivation⟩ |
684 | leanexplore_declaration | leanexplore:387418 | leanexplore_sqlite | leanexplore_declarations | /-- A logical equivalence for a given type of `Judgement`s is a congruence on propositions that
preserves validity of judgements under any judgemental context. -/
class LogicalEquivalence
(Proposition : Type u) [HasContext Proposition]
(Judgement : Type v) [HasHContext Judgement Proposition]
(Valid : Judgem... |
79 | leanexplore_declaration | leanexplore:387419 | leanexplore_sqlite | leanexplore_declarations | @[inherit_doc]
scoped infix:29 " ≡ " => LogicalEquivalence.eqv
end Cslib.Logic |
285 | leanexplore_declaration | leanexplore:387420 | leanexplore_sqlite | leanexplore_declarations | /--
A Functional Labelled Transition System (`FLTS`) for a type of states (`State`) and a type of
transition labels (`Label`) consists of a labelled transition function (`tr`).
-/
structure FLTS (State Label : Type*) where
/-- The transition function. -/
tr : State → Label → State |
327 | leanexplore_declaration | leanexplore:387421 | leanexplore_sqlite | leanexplore_declarations | /-- Extended transition function.
Implementation note: compared to [Hopcroft2006], the definition consumes the input list of symbols
from the left (instead of the right), in order to match the way lists are constructed.
-/
@[scoped grind =]
def mtr (flts : FLTS State Label) (s : State) (μs : List Label) := μs.foldl fl... |
107 | leanexplore_declaration | leanexplore:387422 | leanexplore_sqlite | leanexplore_declarations | @[simp, scoped grind =]
theorem mtr_nil_eq {flts : FLTS State Label} {s : State} : flts.mtr s [] = s := rfl |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.