Skip to content

Commit bb5d6f0

Browse files
committed
Merge remote-tracking branch 'upstream/main' into grind-lint
2 parents 78c62bb + d7d7fae commit bb5d6f0

File tree

27 files changed

+315
-407
lines changed

27 files changed

+315
-407
lines changed

Cslib.lean

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,5 +64,4 @@ import Cslib.Languages.LambdaCalculus.LocallyNameless.Untyped.Properties
6464
import Cslib.Languages.LambdaCalculus.Named.Untyped.Basic
6565
import Cslib.Logics.LinearLogic.CLL.Basic
6666
import Cslib.Logics.LinearLogic.CLL.CutElimination
67-
import Cslib.Logics.LinearLogic.CLL.MProof
6867
import Cslib.Logics.LinearLogic.CLL.PhaseSemantics.Basic

Cslib/Computability/Automata/DA.lean

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ open scoped Cslib.FLTS
2929

3030
namespace Cslib.Automata
3131

32+
/-- A deterministic automaton extends a `FLTS` with a unique initial state. -/
3233
structure DA (State Symbol : Type*) extends FLTS State Symbol where
3334
/-- The initial state of the automaton. -/
3435
start : State
@@ -66,7 +67,7 @@ theorem mtr_extract_eq_run {da : DA State Symbol} {xs : ωSequence Symbol} {n :
6667

6768
/-- A deterministic automaton that accepts finite strings (lists of symbols). -/
6869
structure FinAcc (State Symbol : Type*) extends DA State Symbol where
69-
/-- The accept states. -/
70+
/-- The set of accepting states. -/
7071
accept : Set State
7172

7273
namespace FinAcc
@@ -77,33 +78,39 @@ the string to an accept state.
7778
This is the standard string recognition performed by DFAs in the literature. -/
7879
@[simp, scoped grind =]
7980
instance : Acceptor (DA.FinAcc State Symbol) Symbol where
80-
Accepts (a : DA.FinAcc State Symbol) (xs : List Symbol) := a.mtr a.start xs ∈ a.accept
81+
Accepts (a : DA.FinAcc State Symbol) (xs : List Symbol) :=
82+
a.mtr a.start xs ∈ a.accept
8183

8284
end FinAcc
8385

8486
/-- Deterministic Buchi automaton. -/
8587
structure Buchi (State Symbol : Type*) extends DA State Symbol where
86-
/-- The accept states -/
88+
/-- The set of accepting states. -/
8789
accept : Set State
8890

8991
namespace Buchi
9092

93+
/-- An infinite run is accepting iff accepting states occur infinitely many times. -/
9194
@[simp, scoped grind =]
9295
instance : ωAcceptor (Buchi State Symbol) Symbol where
93-
Accepts (a : Buchi State Symbol) (xs : ωSequence Symbol) := ∃ᶠ k in atTop, a.run xs k ∈ a.accept
96+
Accepts (a : Buchi State Symbol) (xs : ωSequence Symbol) :=
97+
∃ᶠ k in atTop, a.run xs k ∈ a.accept
9498

9599
end Buchi
96100

97101
/-- Deterministic Muller automaton. -/
98102
structure Muller (State Symbol : Type*) extends DA State Symbol where
99-
/-- The accepting set of sets of states. -/
103+
/-- The set of sets of accepting states. -/
100104
accept : Set (Set State)
101105

102106
namespace Muller
103107

108+
/-- An infinite run is accepting iff the set of states that occur infinitely many times
109+
is one of the sets in `accept`. -/
104110
@[simp, scoped grind =]
105111
instance : ωAcceptor (Muller State Symbol) Symbol where
106-
Accepts (a : Muller State Symbol) (xs : ωSequence Symbol) := (a.run xs).infOcc ∈ a.accept
112+
Accepts (a : Muller State Symbol) (xs : ωSequence Symbol) :=
113+
(a.run xs).infOcc ∈ a.accept
107114

108115
end Muller
109116

Cslib/Computability/Automata/EpsilonNA.lean

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ abbrev εNA.εClosure (a : εNA State Symbol) (S : Set State) := a.τClosure S
3030

3131
namespace εNA
3232

33+
/-- The finite-word acceptance condition of an `εNA` is a set of accepting states. -/
3334
structure FinAcc (State Symbol : Type*) extends εNA State Symbol where
35+
/-- The set of accepting states. -/
3436
accept : Set State
3537

3638
namespace FinAcc

Cslib/Computability/Automata/NA.lean

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ open Filter
3131

3232
namespace Cslib.Automata
3333

34+
/-- A nondeterministic automaton extends a `LTS` with a set of initial states. -/
3435
structure NA (State Symbol : Type*) extends LTS State Symbol where
3536
/-- The set of initial states of the automaton. -/
3637
start : Set State
@@ -64,7 +65,7 @@ end NARunGrind
6465

6566
/-- A nondeterministic automaton that accepts finite strings (lists of symbols). -/
6667
structure FinAcc (State Symbol : Type*) extends NA State Symbol where
67-
/-- The accept states. -/
68+
/-- The set of accepting states. -/
6869
accept : Set State
6970

7071
namespace FinAcc
@@ -82,10 +83,12 @@ end FinAcc
8283

8384
/-- Nondeterministic Buchi automaton. -/
8485
structure Buchi (State Symbol : Type*) extends NA State Symbol where
86+
/-- The set of accepting states. -/
8587
accept : Set State
8688

8789
namespace Buchi
8890

91+
/-- An infinite run is accepting iff accepting states occur infinitely many times. -/
8992
@[simp, scoped grind =]
9093
instance : ωAcceptor (Buchi State Symbol) Symbol where
9194
Accepts (a : Buchi State Symbol) (xs : ωSequence Symbol) :=
@@ -95,10 +98,13 @@ end Buchi
9598

9699
/-- Nondeterministic Muller automaton. -/
97100
structure Muller (State Symbol : Type*) extends NA State Symbol where
101+
/-- The set of sets of accepting states. -/
98102
accept : Set (Set State)
99103

100104
namespace Muller
101105

106+
/-- An infinite run is accepting iff the set of states that occur infinitely many times
107+
is one of the sets in `accept`. -/
102108
@[simp, scoped grind =]
103109
instance : ωAcceptor (Muller State Symbol) Symbol where
104110
Accepts (a : Muller State Symbol) (xs : ωSequence Symbol) :=

Cslib/Computability/Automata/Prod.lean

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,15 @@ variable {State1 State2 Symbol : Type*}
1717

1818
namespace DA
1919

20-
/-
21-
TODO: This operation could be generalised to FLTS and lifted here.
22-
-/
20+
/-- The product of two deterministic automata.
21+
TODO: This operation could be generalised to FLTS and lifted here. -/
2322
@[scoped grind =]
2423
def prod (da1 : DA State1 Symbol) (da2 : DA State2 Symbol) : DA (State1 × State2) Symbol where
2524
start := (da1.start, da2.start)
2625
tr := fun (s1, s2) x ↦ (da1.tr s1 x, da2.tr s2 x)
2726

27+
/-- A state is reachable by the product automaton iff its components are reachable by
28+
the respective component automata. -/
2829
@[simp, scoped grind =]
2930
theorem prod_mtr_eq (da1 : DA State1 Symbol) (da2 : DA State2 Symbol)
3031
(s : State1 × State2) (xs : List Symbol) :

Cslib/Computability/Automata/Sum.lean

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,13 @@ open scoped Run
1616

1717
variable {Symbol I : Type*} {State : I → Type*}
1818

19+
/-- The sum of an indexed family of nondeterministic automata. -/
1920
@[scoped grind =]
2021
def iSum (na : (i : I) → NA (State i) Symbol) : NA (Σ i, State i) Symbol where
2122
start := ⋃ i, Sigma.mk i '' (na i).start
2223
Tr s x t := ∃ i s_i t_i, (na i).Tr s_i x t_i ∧ ⟨i, s_i⟩ = s ∧ ⟨i, t_i⟩ = t
2324

25+
/-- An infinite run of the sum automaton is an infinite run of one of its component automata. -/
2426
@[simp, scoped grind =]
2527
theorem iSum_run_iff {na : (i : I) → NA (State i) Symbol}
2628
{xs : ωSequence Symbol} {ss : ωSequence (Σ i, State i)} :
@@ -54,6 +56,8 @@ namespace Buchi
5456

5557
open ωAcceptor
5658

59+
/-- The ω-language accepted by the Buchi sum automata is the union of the ω-languages accepted
60+
by its component automata. -/
5761
@[simp]
5862
theorem iSum_language_eq {na : (i : I) → NA (State i) Symbol} {acc : (i : I) → Set (State i)} :
5963
language (Buchi.mk (iSum na) (⋃ i, Sigma.mk i '' (acc i))) =

Cslib/Computability/Languages/OmegaLanguage.lean

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,13 @@ A.k.a. ω-power.
117117
def omegaPow [Inhabited α] (l : Language α) : ωLanguage α :=
118118
{ s | ∃ xs : ωSequence (List α), xs.flatten = s ∧ ∀ k, xs k ∈ l - 1 }
119119

120-
/-- Use the postfix notation ^ω` for `omegaPow`. -/
120+
/-- Notation class for `omegaPow`. -/
121121
@[notation_class]
122122
class OmegaPow (α : Type*) (β : outParam (Type*)) where
123+
/-- The `omegaPow` operation. -/
123124
omegaPow : α → β
124125

126+
/-- Use the postfix notation ^ω` for `omegaPow`. -/
125127
postfix:1024 "^ω" => OmegaPow.omegaPow
126128

127129
instance [Inhabited α] : OmegaPow (Language α) (ωLanguage α) :=
@@ -131,17 +133,18 @@ theorem omegaPow_def [Inhabited α] (l : Language α) :
131133
l^ω = { s | ∃ xs : ωSequence (List α), xs.flatten = s ∧ ∀ k, xs k ∈ l - 1 }
132134
:= rfl
133135

134-
/- The ω-limit of a language `l` is the ω-language of infinite sequences each of which
135-
contains infinitely many distinct prefixes in `l`.
136-
-/
136+
/-- The ω-limit of a language `l` is the ω-language of infinite sequences each of which
137+
contains infinitely many distinct prefixes in `l`. -/
137138
def omegaLim (l : Language α) : ωLanguage α :=
138139
{ s | ∃ᶠ m in atTop, s.extract 0 m ∈ l }
139140

140-
/-- Use the postfix notation ↗ω` for `omegaLim`. -/
141+
/-- Notation class for `omegaLim`. -/
141142
@[notation_class]
142143
class OmegaLim (α : Type*) (β : outParam (Type*)) where
144+
/-- The `omegaLim` operation. -/
143145
omegaLim : α → β
144146

147+
/-- Use the postfix notation ↗ω` for `omegaLim`. -/
145148
postfix:1024 "↗ω" => OmegaLim.omegaLim
146149

147150
instance instOmegaLim : OmegaLim (Language α) (ωLanguage α) :=

Cslib/Foundations/Data/Nat/Segment.lean

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,15 @@ import Mathlib.Data.Nat.Nth
1111
open Function Set
1212

1313
/-!
14+
# Segments defined by a strictly monotonic function on Nat
15+
1416
Given a strictly monotonic function `f : ℕ → ℕ` and `k : ℕ` with `k ≥ f 0`,
1517
`Nat.segment f k` is the unique `m : ℕ` such that `f m ≤ k < f (k + 1)`.
1618
`Nat.segment f k` is defined to be 0 for `k < f 0`.
1719
This file defines `Nat.segment` and proves various properties aboout it.
1820
-/
21+
22+
/-- The `f`-segment of `k`, where `f : ℕ → ℕ` will be assumed to be at least StrictMono. -/
1923
@[scoped grind]
2024
noncomputable def Nat.segment (f : ℕ → ℕ) (k : ℕ) : ℕ :=
2125
open scoped Classical in

Cslib/Foundations/Data/OmegaSequence/Defs.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ variable {α : Type u} {β : Type v} {δ : Type w}
2828

2929
/-- An `ωSequence α` is an infinite sequence of elements of `α`. -/
3030
structure ωSequence (α : Type u) where
31+
/-- The function that defines this infinite sequence. -/
3132
get : ℕ → α
3233

3334
instance : FunLike (ωSequence α) ℕ α where

Cslib/Foundations/Data/Relation.lean

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -52,27 +52,20 @@ theorem Relation.ReflTransGen.diamond_confluence (h : Diamond R) : Confluence R
5252
exact ⟨D', ⟨B_D', ReflTransGen.trans CD D_D'⟩⟩
5353

5454
-- not sure why this doesn't compile as an "instance" but oh well
55+
/-- A pair of subrelations lifts to transitivity on the relation. -/
5556
def trans_of_subrelation {α : Type _} (s s' r : α → α → Prop) (hr : Transitive r)
5657
(h : ∀ a b : α, s a b → r a b) (h' : ∀ a b : α, s' a b → r a b) : Trans s s' r where
57-
trans := by
58-
intro a b c hab hbc
59-
replace hab := h _ _ hab
60-
replace hbc := h' _ _ hbc
61-
exact hr hab hbc
58+
trans hab hbc := hr (h _ _ hab) (h' _ _ hbc)
6259

60+
/-- A subrelation lifts to transitivity on the left of the relation. -/
6361
def trans_of_subrelation_left {α : Type _} (s r : α → α → Prop) (hr : Transitive r)
6462
(h : ∀ a b : α, s a b → r a b) : Trans s r r where
65-
trans := by
66-
intro a b c hab hbc
67-
replace hab := h _ _ hab
68-
exact hr hab hbc
63+
trans hab hbc := hr (h _ _ hab) hbc
6964

65+
/-- A subrelation lifts to transitivity on the right of the relation. -/
7066
def trans_of_subrelation_right {α : Type _} (s r : α → α → Prop) (hr : Transitive r)
7167
(h : ∀ a b : α, s a b → r a b) : Trans r s r where
72-
trans := by
73-
intro a b c hab hbc
74-
replace hbc := h _ _ hbc
75-
exact hr hab hbc
68+
trans hab hbc := hr hab (h _ _ hbc)
7669

7770
/-- This is a straightforward but useful specialisation of a more general result in
7871
`Mathlib.Logic.Relation`. -/

0 commit comments

Comments
 (0)