Skip to content

Commit af5523a

Browse files
committed
Incorporate Chris Henson's and Eric Wieser's comments
1 parent eeb27dc commit af5523a

File tree

11 files changed

+52
-65
lines changed

11 files changed

+52
-65
lines changed

Cslib/Computability/Automata/DA.lean

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,17 @@ namespace Cslib
2020

2121
open List
2222

23-
structure DA (State : Type _) (Symbol : Type _) where
23+
structure DA (State : Type*) (Symbol : Type*) where
2424
/-- The initial state of the automaton. -/
2525
start : State
2626
/-- The transition function of the automaton. -/
2727
tr : State → Symbol → State
2828

2929
namespace DA
3030

31-
variable {State State1 State2 : Type _} {Symbol : Type _}
31+
variable {State State1 State2 : Type*} {Symbol : Type*}
3232

33-
/-- Extended transition function.
34-
35-
Implementation note: compared to [Hopcroft2006], the definition consumes the input list of symbols
36-
from the left (instead of the right), in order to match the way lists are constructed.
37-
-/
33+
/-- Extended transition function. -/
3834
@[scoped grind =]
3935
def mtr (DA : DA State Symbol) (s : State) (xs : List Symbol) := xs.foldl DA.tr s
4036

Cslib/Computability/Automata/DFA.lean

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ open scoped DA Language
2121
/-- A Deterministic Finite Automaton (DFA) consists of a labelled transition function
2222
`tr` over finite sets of states and labels (called symbols), a starting state `start` and a finite
2323
set of accepting states `accept`. -/
24-
structure DFA (State : Type _) (Symbol : Type _) extends DA State Symbol where
24+
structure DFA (State : Type*) (Symbol : Type*) extends DA State Symbol where
2525
/-- The set of accepting states of the automaton. -/
2626
accept : Set State
2727
/-- The automaton is finite-state. -/
@@ -31,7 +31,7 @@ structure DFA (State : Type _) (Symbol : Type _) extends DA State Symbol where
3131

3232
namespace DFA
3333

34-
variable {State State1 State2 : Type _} {Symbol : Type _}
34+
variable {State State1 State2 : Type*} {Symbol : Type*}
3535

3636
/-- A DFA accepts a string if there is a multi-step accepting derivative with that trace from
3737
the start state. -/
@@ -75,12 +75,11 @@ theorem one_lang [Finite Symbol] : one.language = (1 : Language Symbol) := by
7575
· intro h ; by_contra h'
7676
have := dropLast_append_getLast h'
7777
grind
78-
· rw [Language.mem_one]
79-
grind
78+
· grind [Language.mem_one]
8079

8180
@[scoped grind =]
8281
def compl (dfa : DFA State Symbol) : DFA State Symbol :=
83-
{ dfa with accept := (dfa.accept)ᶜ }
82+
{ dfa with accept := dfa.acceptᶜ }
8483

8584
@[simp, scoped grind =]
8685
theorem compl_lang (dfa : DFA State Symbol) : dfa.compl.language = (dfa.language)ᶜ := by

Cslib/Computability/Automata/DFAToNFA.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ open scoped DA
1515

1616
namespace DFA
1717

18-
variable {State : Type _} {Symbol : Type _}
18+
variable {State : Type*} {Symbol : Type*}
1919

2020
section NFA
2121

Cslib/Computability/Automata/EpsilonNFA.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ symbol type. The special symbol ε is represented by the `Option.none` case.
1717
Internally, ε (`Option.none`) is treated as the `τ` label of the underlying transition system,
1818
allowing for reusing the definitions and results on saturated transitions of `LTS` to deal with
1919
ε-closure. -/
20-
structure εNFA (State : Type _) (Symbol : Type _) extends NA State (Option Symbol) where
20+
structure εNFA (State : Type*) (Symbol : Type*) extends NA State (Option Symbol) where
2121
/-- The set of accepting states of the automaton. -/
2222
accept : Set State
2323
/-- The automaton is finite-state. -/
2424
finite_state : Finite State
2525
/-- The type of symbols (also called 'alphabet') is finite. -/
2626
finite_symbol : Finite Symbol
2727

28-
variable {State : Type _} {Symbol : Type _}
28+
variable {State : Type*} {Symbol : Type*}
2929

3030
@[local grind =]
3131
private instance : HasTau (Option α) := ⟨.none⟩

Cslib/Computability/Automata/EpsilonNFAToNFA.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ private lemma LTS.noε_saturate_tr
2727

2828
namespace εNFA
2929

30-
variable {State : Type _} {Symbol : Type _}
30+
variable {State : Type*} {Symbol : Type*}
3131

3232
section NFA
3333

@@ -41,7 +41,7 @@ def toNFA (enfa : εNFA State Symbol) : NFA State Symbol where
4141
finite_symbol := enfa.finite_symbol
4242

4343
@[scoped grind =]
44-
lemma LTS.noε_saturate_mTr {s : State} {Label : Type _} {μs : List Label}
44+
lemma LTS.noε_saturate_mTr {s : State} {Label : Type*} {μs : List Label}
4545
{lts : LTS State (Option Label)} :
4646
lts.saturate.MTr s (μs.map (some ·)) = lts.saturate.noε.MTr s μs := by
4747
ext s'

Cslib/Computability/Automata/NA.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ type `State → Symbol → Set State`; it gets automatically expanded to the for
1717

1818
namespace Cslib
1919

20-
structure NA (State : Type _) (Symbol : Type _) extends LTS State Symbol where
20+
structure NA (State : Type*) (Symbol : Type*) extends LTS State Symbol where
2121
/-- The set of initial states of the automaton. -/
2222
start : Set State
2323

Cslib/Computability/Automata/NFA.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace Cslib
1111

1212
/-- A Nondeterministic Finite Automaton (NFA) is a nondeterministic automaton (NA)
1313
over finite sets of states and symbols. -/
14-
structure NFA (State : Type _) (Symbol : Type _) extends NA State Symbol where
14+
structure NFA (State : Type*) (Symbol : Type*) extends NA State Symbol where
1515
/-- The set of accepting states of the automaton. -/
1616
accept : Set State
1717
/-- The automaton is finite-state. -/
@@ -21,7 +21,7 @@ structure NFA (State : Type _) (Symbol : Type _) extends NA State Symbol where
2121

2222
namespace NFA
2323

24-
variable {State : Type _} {Symbol : Type _}
24+
variable {State : Type*} {Symbol : Type*}
2525

2626
/-- An NFA accepts a string if there is a multi-step accepting derivative with that trace from
2727
the start state. -/

Cslib/Computability/Automata/NFAToDFA.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ namespace Cslib
1313

1414
namespace NFA
1515

16-
variable {State : Type _} {Symbol : Type _}
16+
variable {State : Type*} {Symbol : Type*}
1717

1818
section SubsetConstruction
1919

Cslib/Computability/Languages/Language.lean

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,35 +20,25 @@ namespace Language
2020
open Set List
2121
open scoped Computability
2222

23-
variable {α : Type _} {l m : Language α}
23+
variable {α : Type*} {l m : Language α}
2424

2525
@[simp, scoped grind =]
2626
theorem mem_inf (x : List α) : x ∈ l ⊓ m ↔ x ∈ l ∧ x ∈ m :=
2727
Iff.rfl
2828

2929
@[simp]
30-
theorem mem_biInf {I : Type _} (s : Set I) (l : I → Language α) (x : List α) :
30+
theorem mem_biInf {I : Type*} (s : Set I) (l : I → Language α) (x : List α) :
3131
(x ∈ ⨅ i ∈ s, l i) ↔ ∀ i ∈ s, x ∈ l i :=
3232
mem_iInter₂
3333

3434
@[simp]
35-
theorem mem_biSup {I : Type _} (s : Set I) (l : I → Language α) (x : List α) :
35+
theorem mem_biSup {I : Type*} (s : Set I) (l : I → Language α) (x : List α) :
3636
(x ∈ ⨆ i ∈ s, l i) ↔ ∃ i ∈ s, x ∈ l i := by
37-
constructor
38-
· intro h
39-
obtain ⟨i, h_i, h_x⟩ := mem_iUnion₂.mp h
40-
use i
41-
· rintro ⟨i, h_i, h_x⟩
42-
apply mem_iUnion₂.mpr
43-
use i
44-
45-
theorem biInf_insert {I : Type _} (a : I) (s : Set I) (l : I → Language α) :
46-
(⨅ i ∈ insert a s, l i) = l a ⊓ ⨅ i ∈ s, l i := by
47-
apply biInter_insert
48-
49-
theorem biSup_insert {I : Type _} (a : I) (s : Set I) (l : I → Language α) :
50-
(⨆ i ∈ insert a s, l i) = l a ⊔ ⨆ i ∈ s, l i := by
51-
apply biUnion_insert
37+
constructor <;> intro h
38+
· have := mem_iUnion₂.mp h
39+
grind
40+
· apply mem_iUnion₂.mpr
41+
grind
5242

5343
-- This section will be removed once the following PR gets into mathlib:
5444
-- https://github.com/leanprover-community/mathlib4/pull/30913

Cslib/Computability/Languages/OmegaLanguage.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ open scoped Computability
5959

6060
universe v
6161

62-
variable {α β γ : Type _}
62+
variable {α β γ : Type*}
6363

6464
/-- An ω-language is a set of strings over an alphabet. -/
6565
def ωLanguage (α) :=

0 commit comments

Comments
 (0)