@@ -133,16 +133,16 @@ def vector_cast (h: n = m) (xs: List.Vector α n): List.Vector α m := by
133133 subst h
134134 exact xs
135135
136- def compress [DecidableEq α] (xs: Rules μ α Pred ν ): Σ n , ((Rules μ α Pred n ) × (Indices n ν )) :=
137- let xs_list: List (Rule μ α Pred) := xs.toList
138- have hn : xs_list.length = ν := by
136+ def compress [DecidableEq α] (xs: Rules n α Pred l1 ): Σ l2 , ((Rules n α Pred l2 ) × (Indices l2 l1 )) :=
137+ let xs_list: List (Rule n α Pred) := xs.toList
138+ have hn : xs_list.length = l1 := by
139139 simp_all only [List.Vector.toList_length, xs_list]
140140
141141 -- sort to increase chance of cache hit
142142 -- TODO: let sxs := List.mergeSort xs
143143
144144 -- remove duplicates
145- let xs_noreps: { ys: List (Rule μ α Pred) // ∀ x ∈ xs_list, x ∈ ys } := eraseReps_sub xs_list
145+ let xs_noreps: { ys: List (Rule n α Pred) // ∀ x ∈ xs_list, x ∈ ys } := eraseReps_sub xs_list
146146
147147 -- get indices
148148 let xs_idxs: List.Vector (Fin (xs_noreps.val).length) (List.length xs_list) := indices xs_noreps
@@ -152,19 +152,19 @@ def compress [DecidableEq α] (xs: Rules μ α Pred ν): Σ n, ((Rules μ α Pre
152152
153153 -- find all indexes of the original expressions in the compressed expressions
154154 let indices: Indices (xs_noreps.val).length (List.length xs_list) := List.Vector.map (fun x => Index.val x) xs_idxs
155- let indices': Indices (xs_noreps.val).length ν := vector_cast hn indices
155+ let indices': Indices (xs_noreps.val).length l1 := vector_cast hn indices
156156
157157 Sigma.mk (List.length (xs_noreps.val)) (
158158 Subtype.mk xs_noreps rfl,
159159 indices'
160160 )
161161
162- def memVector (xs: List.Vector α ν ) (y: α): Prop :=
162+ def memVector (xs: List.Vector α l ) (y: α): Prop :=
163163 match xs with
164164 | ⟨[], _⟩ => False
165165 | ⟨x::xs, h⟩ => x = y \/ memVector ⟨xs, congrArg Nat.pred h⟩ y
166166
167- instance [DecidableEq α]: Membership α (List.Vector α ν ) where
167+ instance [DecidableEq α]: Membership α (List.Vector α l ) where
168168 mem := memVector
169169
170170theorem memVector_nil {n: Nat} {hxs: [].length = n}
@@ -189,7 +189,7 @@ theorem memVector_cons {n: Nat} {hxs: (x::xs).length = n}
189189 generalize_proofs at h
190190 exact h
191191
192- def indexOf' [DecidableEq α] (xs: List.Vector α ν ) (y: α) (h: y ∈ xs): Fin (xs.length) :=
192+ def indexOf' [DecidableEq α] (xs: List.Vector α l ) (y: α) (h: y ∈ xs): Fin (xs.length) :=
193193 match xs with
194194 | ⟨[], hxs⟩ => by
195195 exfalso
@@ -223,27 +223,27 @@ theorem memVector_emptyset [DecidableEq α] {y: Regex α}
223223 simp only [beq_iff_eq] at h2
224224 contradiction
225225
226- def indexOf [DecidableEq α] (xs: List.Vector (Regex α) ν ) (y: Regex α) (h: y ∈ xs \/ y = Regex.emptyset): Index (xs.length) :=
226+ def indexOf [DecidableEq α] (xs: List.Vector (Regex α) l ) (y: Regex α) (h: y ∈ xs \/ y = Regex.emptyset): Index (xs.length) :=
227227 if hy: y == Regex.emptyset
228228 then Index.emptyset
229229 else Index.val (indexOf' xs y (memVector_emptyset h hy))
230230
231- def ofIndex' (xs: Rules μ α Pred ν ) (index: Fin ν ): Rule μ α Pred :=
231+ def ofIndex' (xs: Rules n α Pred l ) (index: Fin l ): Rule n α Pred :=
232232 xs.get index
233233
234- def ofIndex (xs: Rules μ α Pred ν ) (index: Index ν ): Rule μ α Pred :=
234+ def ofIndex (xs: Rules n α Pred l ) (index: Index l ): Rule n α Pred :=
235235 match index with
236236 | Index.emptyset => Regex.emptyset
237237 | Index.val n => ofIndex' xs n
238238
239- def compressed [DecidableEq σ] (xs: List.Vector (Regex σ) ν ): Nat :=
239+ def compressed [DecidableEq σ] (xs: List.Vector (Regex σ) l ): Nat :=
240240 (List.erase (List.eraseReps xs.toList) Regex.emptyset).length
241241
242242-- theorem compressed_cons_emptyset [DecidableEq σ] (xs: List (Regex σ)):
243243-- compressed ⟨Regex.emptyset :: xs, h⟩ = compressed ⟨xs, congrArg Nat.pred h⟩ := by
244244-- sorry
245245
246- def numReps [DecidableEq α] (xs: List.Vector α μ ) (x: Option α := Option.none): Nat :=
246+ def numReps [DecidableEq α] (xs: List.Vector α l ) (x: Option α := Option.none): Nat :=
247247 match x with
248248 | Option.none =>
249249 match xs with
@@ -257,7 +257,7 @@ def numReps [DecidableEq α] (xs: List.Vector α μ) (x: Option α := Option.non
257257 then 1 + numReps ⟨xs, congrArg Nat.pred h⟩ (Option.some x')
258258 else numReps ⟨xs, congrArg Nat.pred h⟩ (Option.some x')
259259
260- theorem numReps_none_le_length [DecidableEq α] (xs: List.Vector α μ ):
260+ theorem numReps_none_le_length [DecidableEq α] (xs: List.Vector α l ):
261261 numReps xs Option.none <= xs.length := by
262262 induction xs with
263263 | nil =>
@@ -292,7 +292,7 @@ theorem numReps_none_le_length [DecidableEq α] (xs: List.Vector α μ):
292292 simp [List.Vector.length] at ih
293293 omega
294294
295- theorem numReps_some_le_length [DecidableEq α] (xs: List.Vector α μ ):
295+ theorem numReps_some_le_length [DecidableEq α] (xs: List.Vector α l ):
296296 numReps xs (Option.some y) <= xs.length := by
297297 induction xs generalizing y with
298298 | nil =>
@@ -319,15 +319,15 @@ theorem numReps_some_le_length [DecidableEq α] (xs: List.Vector α μ):
319319 have ih' := ih (y := x)
320320 omega
321321
322- theorem numReps_le_length [DecidableEq α] (xs: List.Vector α μ ) (y: Option α):
322+ theorem numReps_le_length [DecidableEq α] (xs: List.Vector α l ) (y: Option α):
323323 numReps xs y <= xs.length := by
324324 cases y with
325325 | none =>
326326 apply numReps_none_le_length
327327 | some y =>
328328 apply numReps_some_le_length
329329
330- -- def eraseReps [DecidableEq α] (xs: List.Vector α μ ) (x: Option α := Option.none): List.Vector α (μ - numReps xs x) :=
330+ -- def eraseReps [DecidableEq α] (xs: List.Vector α l ) (x: Option α := Option.none): List.Vector α (l - numReps xs x) :=
331331-- match x with
332332-- | Option.none =>
333333-- match xs with
@@ -394,7 +394,7 @@ theorem numReps_le_length [DecidableEq α] (xs: List.Vector α μ) (y: Option α
394394-- rw [Nat.sub_add_comm hsome]
395395-- ⟩
396396
397- def smallest [DecidableEq α] [LT α] [DecidableLT α] (xs: List.Vector α ν ) (y: α): Option (Fin ν ) :=
397+ def smallest [DecidableEq α] [LT α] [DecidableLT α] (xs: List.Vector α l ) (y: α): Option (Fin l ) :=
398398 match xs with
399399 | ⟨[], h⟩ => Option.none
400400 | ⟨x::xs, h⟩ =>
@@ -417,7 +417,7 @@ def smallest [DecidableEq α] [LT α] [DecidableLT α] (xs: List.Vector α ν) (
417417 simp
418418 ⟩
419419
420- -- def comp [DecidableEq σ] [LT (Regex σ)] [DecidableLT (Regex σ)] (xs: List.Vector (Regex σ) ν ) (dup: Option (Regex σ) := Option.none): (List.Vector (Regex σ) (compressed xs)) × (Indices ν (compressed xs)) :=
420+ -- def comp [DecidableEq σ] [LT (Regex σ)] [DecidableLT (Regex σ)] (xs: List.Vector (Regex σ) l ) (dup: Option (Regex σ) := Option.none): (List.Vector (Regex σ) (compressed xs)) × (Indices l (compressed xs)) :=
421421-- match xs with
422422-- | ⟨[], h⟩ => (⟨[], by simp [compressed, List.eraseReps, List.eraseRepsBy]⟩, ⟨[], h⟩)
423423-- | ⟨x::xs, h⟩ =>
@@ -436,12 +436,12 @@ def smallest [DecidableEq α] [LT α] [DecidableLT α] (xs: List.Vector α ν) (
436436-- | Option.some dup => sorry
437437-- | Option.some i => sorry
438438
439- def compressM [DecidableEq α] [Monad m] (xs: Rules μ α Pred ν ): m (Σ n , (Rules μ α Pred n ) × Indices n ν ) := do
439+ def compressM [DecidableEq α] [Monad m] (xs: Rules n α Pred l1 ): m (Σ l2 , (Rules n α Pred l2 ) × Indices l2 l1 ) := do
440440 return compress xs
441441
442442-- expand expands a list of expressions.
443- def expand (indices: Indices ν 1 ν 2 ) (xs: Rules μ α Pred ν 1 ): (Rules μ α Pred ν 2 ) :=
443+ def expand (indices: Indices l1 l2 ) (xs: Rules n α Pred l1 ): (Rules n α Pred l2 ) :=
444444 List.Vector.map (ofIndex xs) indices
445445
446- def expandM [Monad m] (indices: Indices ν 1 ν 2 ) (xs: Rules μ α Pred ν 1 ): m (Rules μ α Pred ν 2 ) :=
446+ def expandM [Monad m] (indices: Indices l1 l2 ) (xs: Rules n α Pred l1 ): m (Rules n α Pred l2 ) :=
447447 return (expand indices xs)
0 commit comments