computability.regular_expressionsMathlib.Computability.RegularExpressions

This file has been ported!

Changes since the initial port

The following section lists changes to this file in mathlib3 and mathlib4 that occured after the initial port. Most recent changes are shown first. Hovering over a commit will show all commits associated with the same mathlib3 commit.

Changes in mathlib3

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(last sync)

Changes in mathlib3port

mathlib3
mathlib3port
Diff
@@ -157,7 +157,7 @@ theorem matches'_mul (P Q : RegularExpression α) : (P * Q).matches' = P.matches
 @[simp]
 theorem matches'_pow (P : RegularExpression α) : ∀ n : ℕ, (P ^ n).matches' = P.matches' ^ n
   | 0 => matches'_epsilon
-  | n + 1 => (matches'_mul _ _).trans <| Eq.trans (congr_arg _ (matches_pow n)) (pow_succ _ _).symm
+  | n + 1 => (matches'_mul _ _).trans <| Eq.trans (congr_arg _ (matches_pow n)) (pow_succ' _ _).symm
 #align regular_expression.matches_pow RegularExpression.matches'_pow
 -/
 
Diff
@@ -296,12 +296,12 @@ theorem mul_rmatch_iff (P Q : RegularExpression α) (x : List α) :
     · intro h
       refine' ⟨[], [], rfl, _⟩
       rw [rmatch, rmatch]
-      rwa [Bool.coe_and_iff] at h 
+      rwa [Bool.coe_and_iff] at h
     · rintro ⟨t, u, h₁, h₂⟩
       cases' List.append_eq_nil.1 h₁.symm with ht hu
       subst ht
       subst hu
-      repeat' rw [rmatch] at h₂ 
+      repeat' rw [rmatch] at h₂
       simp [h₂]
   · rw [rmatch, deriv]
     split_ifs with hepsilon
@@ -313,13 +313,13 @@ theorem mul_rmatch_iff (P Q : RegularExpression α) (x : List α) :
       · rintro ⟨t, u, h, hP, hQ⟩
         cases' t with b t
         · right
-          rw [List.nil_append] at h 
-          rw [← h] at hQ 
+          rw [List.nil_append] at h
+          rw [← h] at hQ
           exact hQ
         · left
-          simp only [List.cons_append] at h 
+          simp only [List.cons_append] at h
           refine' ⟨t, u, h.2, _, hQ⟩
-          rw [rmatch] at hP 
+          rw [rmatch] at hP
           convert hP
           exact h.1
     · rw [ih]
@@ -327,9 +327,9 @@ theorem mul_rmatch_iff (P Q : RegularExpression α) (x : List α) :
       · exact ⟨a :: t, u, by tauto⟩
       · cases' t with b t
         · contradiction
-        · simp only [List.cons_append] at h 
+        · simp only [List.cons_append] at h
           refine' ⟨t, u, h.2, _, hQ⟩
-          rw [rmatch] at hP 
+          rw [rmatch] at hP
           convert hP
           exact h.1
 #align regular_expression.mul_rmatch_iff RegularExpression.mul_rmatch_iff
@@ -359,7 +359,7 @@ theorem star_rmatch_iff (P : RegularExpression α) :
           by
           rw [hs, List.length_cons, List.length_append]
           apply A
-        rw [IH _ hwf] at hu 
+        rw [IH _ hwf] at hu
         rcases hu with ⟨S', hsum, helem⟩
         use(a :: t) :: S'
         constructor
@@ -376,13 +376,13 @@ theorem star_rmatch_iff (P : RegularExpression α) :
         cases' S with t' U
         · exact ⟨[], [], by tauto⟩
         · cases' t' with b t
-          · simp only [forall_eq_or_imp, List.mem_cons] at helem 
-            simp only [eq_self_iff_true, not_true, Ne.def, false_and_iff] at helem 
+          · simp only [forall_eq_or_imp, List.mem_cons] at helem
+            simp only [eq_self_iff_true, not_true, Ne.def, false_and_iff] at helem
             cases helem
-          simp only [List.join, List.cons_append] at hsum 
+          simp only [List.join, List.cons_append] at hsum
           refine' ⟨t, U.join, hsum.2, _, _⟩
           · specialize helem (b :: t) (by simp)
-            rw [rmatch] at helem 
+            rw [rmatch] at helem
             convert helem.2
             exact hsum.1
           · have hwf : U.join.length < (List.cons a x).length :=
@@ -429,12 +429,12 @@ theorem rmatch_iff_matches' (P : RegularExpression α) : ∀ x : List α, P.rmat
       Set.image_prod]
     constructor
     · rintro ⟨x, y, hsum, hmatch₁, hmatch₂⟩
-      rw [ih₁] at hmatch₁ 
-      rw [ih₂] at hmatch₂ 
+      rw [ih₁] at hmatch₁
+      rw [ih₂] at hmatch₂
       exact ⟨x, hmatch₁, y, hmatch₂, hsum.symm⟩
     · rintro ⟨x, hmatch₁, y, hmatch₂, hsum⟩
-      rw [← ih₁] at hmatch₁ 
-      rw [← ih₂] at hmatch₂ 
+      rw [← ih₁] at hmatch₁
+      rw [← ih₂] at hmatch₂
       exact ⟨x, y, hsum.symm, hmatch₁, hmatch₂⟩
   case star _ ih =>
     rw [star_rmatch_iff, Language.kstar_def_nonempty]
Diff
@@ -335,7 +335,7 @@ theorem mul_rmatch_iff (P Q : RegularExpression α) (x : List α) :
 #align regular_expression.mul_rmatch_iff RegularExpression.mul_rmatch_iff
 -/
 
-/- ./././Mathport/Syntax/Translate/Command.lean:298:8: warning: using_well_founded used, estimated equivalent -/
+/- ./././Mathport/Syntax/Translate/Command.lean:299:8: warning: using_well_founded used, estimated equivalent -/
 #print RegularExpression.star_rmatch_iff /-
 theorem star_rmatch_iff (P : RegularExpression α) :
     ∀ x : List α, (star P).rmatch x ↔ ∃ S : List (List α), x = S.join ∧ ∀ t ∈ S, t ≠ [] ∧ P.rmatch t
@@ -394,8 +394,7 @@ theorem star_rmatch_iff (P : RegularExpression α) :
             refine' ⟨U, rfl, fun t h => helem t _⟩
             right
             assumption
-termination_by
-  _ x =>
+termination_by x =>
   WellFounded.wrap (r := fun L₁ L₂ : List _ => L₁.length < L₂.length) (InvImage.wf _ Nat.lt_wfRel) x
 #align regular_expression.star_rmatch_iff RegularExpression.star_rmatch_iff
 -/
Diff
@@ -335,6 +335,7 @@ theorem mul_rmatch_iff (P Q : RegularExpression α) (x : List α) :
 #align regular_expression.mul_rmatch_iff RegularExpression.mul_rmatch_iff
 -/
 
+/- ./././Mathport/Syntax/Translate/Command.lean:298:8: warning: using_well_founded used, estimated equivalent -/
 #print RegularExpression.star_rmatch_iff /-
 theorem star_rmatch_iff (P : RegularExpression α) :
     ∀ x : List α, (star P).rmatch x ↔ ∃ S : List (List α), x = S.join ∧ ∀ t ∈ S, t ≠ [] ∧ P.rmatch t
@@ -393,7 +394,9 @@ theorem star_rmatch_iff (P : RegularExpression α) :
             refine' ⟨U, rfl, fun t h => helem t _⟩
             right
             assumption
-termination_by' ⟨fun L₁ L₂ : List _ => L₁.length < L₂.length, InvImage.wf _ Nat.lt_wfRel⟩
+termination_by
+  _ x =>
+  WellFounded.wrap (r := fun L₁ L₂ : List _ => L₁.length < L₂.length) (InvImage.wf _ Nat.lt_wfRel) x
 #align regular_expression.star_rmatch_iff RegularExpression.star_rmatch_iff
 -/
 
Diff
@@ -279,7 +279,7 @@ theorem add_rmatch_iff (P Q : RegularExpression α) (x : List α) :
     (P + Q).rmatch x ↔ P.rmatch x ∨ Q.rmatch x :=
   by
   induction' x with _ _ ih generalizing P Q
-  · simp only [rmatch, match_epsilon, Bool.or_coe_iff]
+  · simp only [rmatch, match_epsilon, Bool.coe_or_iff]
   · repeat' rw [rmatch]
     rw [deriv]
     exact ih _ _
@@ -296,7 +296,7 @@ theorem mul_rmatch_iff (P Q : RegularExpression α) (x : List α) :
     · intro h
       refine' ⟨[], [], rfl, _⟩
       rw [rmatch, rmatch]
-      rwa [Bool.and_coe_iff] at h 
+      rwa [Bool.coe_and_iff] at h 
     · rintro ⟨t, u, h₁, h₂⟩
       cases' List.append_eq_nil.1 h₁.symm with ht hu
       subst ht
Diff
@@ -3,8 +3,8 @@ Copyright (c) 2020 Fox Thomson. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Fox Thomson
 -/
-import Mathbin.Tactic.Rcases
-import Mathbin.Computability.Language
+import Tactic.Rcases
+import Computability.Language
 
 #align_import computability.regular_expressions from "leanprover-community/mathlib"@"d64d67d000b974f0d86a2be7918cf800be6271c8"
 
Diff
@@ -360,7 +360,7 @@ theorem star_rmatch_iff (P : RegularExpression α) :
           apply A
         rw [IH _ hwf] at hu 
         rcases hu with ⟨S', hsum, helem⟩
-        use (a :: t) :: S'
+        use(a :: t) :: S'
         constructor
         · simp [hs, hsum]
         · intro t' ht'
Diff
@@ -2,15 +2,12 @@
 Copyright (c) 2020 Fox Thomson. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Fox Thomson
-
-! This file was ported from Lean 3 source module computability.regular_expressions
-! leanprover-community/mathlib commit d64d67d000b974f0d86a2be7918cf800be6271c8
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
 -/
 import Mathbin.Tactic.Rcases
 import Mathbin.Computability.Language
 
+#align_import computability.regular_expressions from "leanprover-community/mathlib"@"d64d67d000b974f0d86a2be7918cf800be6271c8"
+
 /-!
 # Regular Expressions
 
Diff
@@ -142,10 +142,12 @@ theorem matches'_char (a : α) : (char a).matches' = {[a]} :=
 #align regular_expression.matches_char RegularExpression.matches'_char
 -/
 
+#print RegularExpression.matches'_add /-
 @[simp]
 theorem matches'_add (P Q : RegularExpression α) : (P + Q).matches' = P.matches' + Q.matches' :=
   rfl
 #align regular_expression.matches_add RegularExpression.matches'_add
+-/
 
 #print RegularExpression.matches'_mul /-
 @[simp]
@@ -154,11 +156,13 @@ theorem matches'_mul (P Q : RegularExpression α) : (P * Q).matches' = P.matches
 #align regular_expression.matches_mul RegularExpression.matches'_mul
 -/
 
+#print RegularExpression.matches'_pow /-
 @[simp]
 theorem matches'_pow (P : RegularExpression α) : ∀ n : ℕ, (P ^ n).matches' = P.matches' ^ n
   | 0 => matches'_epsilon
   | n + 1 => (matches'_mul _ _).trans <| Eq.trans (congr_arg _ (matches_pow n)) (pow_succ _ _).symm
 #align regular_expression.matches_pow RegularExpression.matches'_pow
+-/
 
 #print RegularExpression.matches'_star /-
 @[simp]
@@ -179,8 +183,6 @@ def matchEpsilon : RegularExpression α → Bool
 #align regular_expression.match_epsilon RegularExpression.matchEpsilon
 -/
 
-include dec
-
 #print RegularExpression.deriv /-
 /-- `P.deriv a` matches `x` if `P` matches `a :: x`, the Brzozowski derivative of `P` with respect
   to `a` -/
@@ -457,8 +459,6 @@ instance (P : RegularExpression α) : DecidablePred P.matches' :=
   rw [← rmatch_iff_matches]
   exact Eq.decidable _ _
 
-omit dec
-
 #print RegularExpression.map /-
 /-- Map the alphabet of a regular expression. -/
 @[simp]
@@ -472,12 +472,14 @@ def map (f : α → β) : RegularExpression α → RegularExpression β
 #align regular_expression.map RegularExpression.map
 -/
 
+#print RegularExpression.map_pow /-
 @[simp]
 protected theorem map_pow (f : α → β) (P : RegularExpression α) :
     ∀ n : ℕ, map f (P ^ n) = map f P ^ n
   | 0 => rfl
   | n + 1 => (congr_arg ((· * ·) (map f P)) (map_pow n) : _)
 #align regular_expression.map_pow RegularExpression.map_pow
+-/
 
 #print RegularExpression.map_id /-
 @[simp]
@@ -491,6 +493,7 @@ theorem map_id : ∀ P : RegularExpression α, P.map id = P
 #align regular_expression.map_id RegularExpression.map_id
 -/
 
+#print RegularExpression.map_map /-
 @[simp]
 theorem map_map (g : β → γ) (f : α → β) : ∀ P : RegularExpression α, (P.map f).map g = P.map (g ∘ f)
   | 0 => rfl
@@ -500,7 +503,9 @@ theorem map_map (g : β → γ) (f : α → β) : ∀ P : RegularExpression α,
   | R * S => by simp_rw [map, map_map]
   | star R => by simp_rw [map, map_map]
 #align regular_expression.map_map RegularExpression.map_map
+-/
 
+#print RegularExpression.matches'_map /-
 /-- The language of the map is the map of the language. -/
 @[simp]
 theorem matches'_map (f : α → β) :
@@ -516,6 +521,7 @@ theorem matches'_map (f : α → β) :
     simp_rw [← map_pow]
     exact image_Union.symm
 #align regular_expression.matches_map RegularExpression.matches'_map
+-/
 
 end RegularExpression
 
Diff
@@ -297,12 +297,12 @@ theorem mul_rmatch_iff (P Q : RegularExpression α) (x : List α) :
     · intro h
       refine' ⟨[], [], rfl, _⟩
       rw [rmatch, rmatch]
-      rwa [Bool.and_coe_iff] at h
+      rwa [Bool.and_coe_iff] at h 
     · rintro ⟨t, u, h₁, h₂⟩
       cases' List.append_eq_nil.1 h₁.symm with ht hu
       subst ht
       subst hu
-      repeat' rw [rmatch] at h₂
+      repeat' rw [rmatch] at h₂ 
       simp [h₂]
   · rw [rmatch, deriv]
     split_ifs with hepsilon
@@ -314,13 +314,13 @@ theorem mul_rmatch_iff (P Q : RegularExpression α) (x : List α) :
       · rintro ⟨t, u, h, hP, hQ⟩
         cases' t with b t
         · right
-          rw [List.nil_append] at h
-          rw [← h] at hQ
+          rw [List.nil_append] at h 
+          rw [← h] at hQ 
           exact hQ
         · left
-          simp only [List.cons_append] at h
+          simp only [List.cons_append] at h 
           refine' ⟨t, u, h.2, _, hQ⟩
-          rw [rmatch] at hP
+          rw [rmatch] at hP 
           convert hP
           exact h.1
     · rw [ih]
@@ -328,9 +328,9 @@ theorem mul_rmatch_iff (P Q : RegularExpression α) (x : List α) :
       · exact ⟨a :: t, u, by tauto⟩
       · cases' t with b t
         · contradiction
-        · simp only [List.cons_append] at h
+        · simp only [List.cons_append] at h 
           refine' ⟨t, u, h.2, _, hQ⟩
-          rw [rmatch] at hP
+          rw [rmatch] at hP 
           convert hP
           exact h.1
 #align regular_expression.mul_rmatch_iff RegularExpression.mul_rmatch_iff
@@ -359,7 +359,7 @@ theorem star_rmatch_iff (P : RegularExpression α) :
           by
           rw [hs, List.length_cons, List.length_append]
           apply A
-        rw [IH _ hwf] at hu
+        rw [IH _ hwf] at hu 
         rcases hu with ⟨S', hsum, helem⟩
         use (a :: t) :: S'
         constructor
@@ -376,13 +376,13 @@ theorem star_rmatch_iff (P : RegularExpression α) :
         cases' S with t' U
         · exact ⟨[], [], by tauto⟩
         · cases' t' with b t
-          · simp only [forall_eq_or_imp, List.mem_cons] at helem
-            simp only [eq_self_iff_true, not_true, Ne.def, false_and_iff] at helem
+          · simp only [forall_eq_or_imp, List.mem_cons] at helem 
+            simp only [eq_self_iff_true, not_true, Ne.def, false_and_iff] at helem 
             cases helem
-          simp only [List.join, List.cons_append] at hsum
+          simp only [List.join, List.cons_append] at hsum 
           refine' ⟨t, U.join, hsum.2, _, _⟩
           · specialize helem (b :: t) (by simp)
-            rw [rmatch] at helem
+            rw [rmatch] at helem 
             convert helem.2
             exact hsum.1
           · have hwf : U.join.length < (List.cons a x).length :=
@@ -393,8 +393,8 @@ theorem star_rmatch_iff (P : RegularExpression α) :
             rw [IH _ hwf]
             refine' ⟨U, rfl, fun t h => helem t _⟩
             right
-            assumption termination_by'
-  ⟨fun L₁ L₂ : List _ => L₁.length < L₂.length, InvImage.wf _ Nat.lt_wfRel⟩
+            assumption
+termination_by' ⟨fun L₁ L₂ : List _ => L₁.length < L₂.length, InvImage.wf _ Nat.lt_wfRel⟩
 #align regular_expression.star_rmatch_iff RegularExpression.star_rmatch_iff
 -/
 
@@ -422,18 +422,18 @@ theorem rmatch_iff_matches' (P : RegularExpression α) : ∀ x : List α, P.rmat
   case plus _ _ ih₁ ih₂ =>
     rw [add_rmatch_iff, ih₁, ih₂]
     rfl
-  case
-    comp P Q ih₁ ih₂ =>
+  case comp P Q ih₁
+    ih₂ =>
     simp only [mul_rmatch_iff, comp_def, Language.mul_def, exists_and_left, Set.mem_image2,
       Set.image_prod]
     constructor
     · rintro ⟨x, y, hsum, hmatch₁, hmatch₂⟩
-      rw [ih₁] at hmatch₁
-      rw [ih₂] at hmatch₂
+      rw [ih₁] at hmatch₁ 
+      rw [ih₂] at hmatch₂ 
       exact ⟨x, hmatch₁, y, hmatch₂, hsum.symm⟩
     · rintro ⟨x, hmatch₁, y, hmatch₂, hsum⟩
-      rw [← ih₁] at hmatch₁
-      rw [← ih₂] at hmatch₂
+      rw [← ih₁] at hmatch₁ 
+      rw [← ih₂] at hmatch₂ 
       exact ⟨x, y, hsum.symm, hmatch₁, hmatch₂⟩
   case star _ ih =>
     rw [star_rmatch_iff, Language.kstar_def_nonempty]
Diff
@@ -30,7 +30,7 @@ computer science such as the POSIX standard.
 
 open List Set
 
-open Computability
+open scoped Computability
 
 universe u
 
Diff
@@ -142,12 +142,6 @@ theorem matches'_char (a : α) : (char a).matches' = {[a]} :=
 #align regular_expression.matches_char RegularExpression.matches'_char
 -/
 
-/- warning: regular_expression.matches_add -> RegularExpression.matches'_add is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} (P : RegularExpression.{u1} α) (Q : RegularExpression.{u1} α), Eq.{succ u1} (Language.{u1} α) (RegularExpression.matches'.{u1} α (HAdd.hAdd.{u1, u1, u1} (RegularExpression.{u1} α) (RegularExpression.{u1} α) (RegularExpression.{u1} α) (instHAdd.{u1} (RegularExpression.{u1} α) (RegularExpression.hasAdd.{u1} α)) P Q)) (HAdd.hAdd.{u1, u1, u1} (Language.{u1} α) (Language.{u1} α) (Language.{u1} α) (instHAdd.{u1} (Language.{u1} α) (Language.hasAdd.{u1} α)) (RegularExpression.matches'.{u1} α P) (RegularExpression.matches'.{u1} α Q))
-but is expected to have type
-  forall {α : Type.{u1}} (P : RegularExpression.{u1} α) (Q : RegularExpression.{u1} α), Eq.{succ u1} (Language.{u1} α) (RegularExpression.matches'.{u1} α (HAdd.hAdd.{u1, u1, u1} (RegularExpression.{u1} α) (RegularExpression.{u1} α) (RegularExpression.{u1} α) (instHAdd.{u1} (RegularExpression.{u1} α) (RegularExpression.instAddRegularExpression.{u1} α)) P Q)) (HAdd.hAdd.{u1, u1, u1} (Language.{u1} α) (Language.{u1} α) (Language.{u1} α) (instHAdd.{u1} (Language.{u1} α) (Language.instAddLanguage.{u1} α)) (RegularExpression.matches'.{u1} α P) (RegularExpression.matches'.{u1} α Q))
-Case conversion may be inaccurate. Consider using '#align regular_expression.matches_add RegularExpression.matches'_addₓ'. -/
 @[simp]
 theorem matches'_add (P Q : RegularExpression α) : (P + Q).matches' = P.matches' + Q.matches' :=
   rfl
@@ -160,12 +154,6 @@ theorem matches'_mul (P Q : RegularExpression α) : (P * Q).matches' = P.matches
 #align regular_expression.matches_mul RegularExpression.matches'_mul
 -/
 
-/- warning: regular_expression.matches_pow -> RegularExpression.matches'_pow is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} (P : RegularExpression.{u1} α) (n : Nat), Eq.{succ u1} (Language.{u1} α) (RegularExpression.matches'.{u1} α (HPow.hPow.{u1, 0, u1} (RegularExpression.{u1} α) Nat (RegularExpression.{u1} α) (instHPow.{u1, 0} (RegularExpression.{u1} α) Nat (RegularExpression.Nat.hasPow.{u1} α)) P n)) (HPow.hPow.{u1, 0, u1} (Language.{u1} α) Nat (Language.{u1} α) (instHPow.{u1, 0} (Language.{u1} α) Nat (Monoid.Pow.{u1} (Language.{u1} α) (MonoidWithZero.toMonoid.{u1} (Language.{u1} α) (Semiring.toMonoidWithZero.{u1} (Language.{u1} α) (Language.semiring.{u1} α))))) (RegularExpression.matches'.{u1} α P) n)
-but is expected to have type
-  forall {α : Type.{u1}} (P : RegularExpression.{u1} α) (n : Nat), Eq.{succ u1} (Language.{u1} α) (RegularExpression.matches'.{u1} α (HPow.hPow.{u1, 0, u1} (RegularExpression.{u1} α) Nat (RegularExpression.{u1} α) (instHPow.{u1, 0} (RegularExpression.{u1} α) Nat (RegularExpression.instPowRegularExpressionNat.{u1} α)) P n)) (HPow.hPow.{u1, 0, u1} (Language.{u1} α) Nat (Language.{u1} α) (instHPow.{u1, 0} (Language.{u1} α) Nat (Monoid.Pow.{u1} (Language.{u1} α) (MonoidWithZero.toMonoid.{u1} (Language.{u1} α) (Semiring.toMonoidWithZero.{u1} (Language.{u1} α) (Language.instSemiringLanguage.{u1} α))))) (RegularExpression.matches'.{u1} α P) n)
-Case conversion may be inaccurate. Consider using '#align regular_expression.matches_pow RegularExpression.matches'_powₓ'. -/
 @[simp]
 theorem matches'_pow (P : RegularExpression α) : ∀ n : ℕ, (P ^ n).matches' = P.matches' ^ n
   | 0 => matches'_epsilon
@@ -484,12 +472,6 @@ def map (f : α → β) : RegularExpression α → RegularExpression β
 #align regular_expression.map RegularExpression.map
 -/
 
-/- warning: regular_expression.map_pow -> RegularExpression.map_pow is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} {β : Type.{u2}} (f : α -> β) (P : RegularExpression.{u1} α) (n : Nat), Eq.{succ u2} (RegularExpression.{u2} β) (RegularExpression.map.{u1, u2} α β f (HPow.hPow.{u1, 0, u1} (RegularExpression.{u1} α) Nat (RegularExpression.{u1} α) (instHPow.{u1, 0} (RegularExpression.{u1} α) Nat (RegularExpression.Nat.hasPow.{u1} α)) P n)) (HPow.hPow.{u2, 0, u2} (RegularExpression.{u2} β) Nat (RegularExpression.{u2} β) (instHPow.{u2, 0} (RegularExpression.{u2} β) Nat (RegularExpression.Nat.hasPow.{u2} β)) (RegularExpression.map.{u1, u2} α β f P) n)
-but is expected to have type
-  forall {α : Type.{u2}} {β : Type.{u1}} (f : α -> β) (P : RegularExpression.{u2} α) (n : Nat), Eq.{succ u1} (RegularExpression.{u1} β) (RegularExpression.map.{u2, u1} α β f (HPow.hPow.{u2, 0, u2} (RegularExpression.{u2} α) Nat (RegularExpression.{u2} α) (instHPow.{u2, 0} (RegularExpression.{u2} α) Nat (RegularExpression.instPowRegularExpressionNat.{u2} α)) P n)) (HPow.hPow.{u1, 0, u1} (RegularExpression.{u1} β) Nat (RegularExpression.{u1} β) (instHPow.{u1, 0} (RegularExpression.{u1} β) Nat (RegularExpression.instPowRegularExpressionNat.{u1} β)) (RegularExpression.map.{u2, u1} α β f P) n)
-Case conversion may be inaccurate. Consider using '#align regular_expression.map_pow RegularExpression.map_powₓ'. -/
 @[simp]
 protected theorem map_pow (f : α → β) (P : RegularExpression α) :
     ∀ n : ℕ, map f (P ^ n) = map f P ^ n
@@ -509,12 +491,6 @@ theorem map_id : ∀ P : RegularExpression α, P.map id = P
 #align regular_expression.map_id RegularExpression.map_id
 -/
 
-/- warning: regular_expression.map_map -> RegularExpression.map_map is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} (g : β -> γ) (f : α -> β) (P : RegularExpression.{u1} α), Eq.{succ u3} (RegularExpression.{u3} γ) (RegularExpression.map.{u2, u3} β γ g (RegularExpression.map.{u1, u2} α β f P)) (RegularExpression.map.{u1, u3} α γ (Function.comp.{succ u1, succ u2, succ u3} α β γ g f) P)
-but is expected to have type
-  forall {α : Type.{u3}} {β : Type.{u1}} {γ : Type.{u2}} (g : β -> γ) (f : α -> β) (P : RegularExpression.{u3} α), Eq.{succ u2} (RegularExpression.{u2} γ) (RegularExpression.map.{u1, u2} β γ g (RegularExpression.map.{u3, u1} α β f P)) (RegularExpression.map.{u3, u2} α γ (Function.comp.{succ u3, succ u1, succ u2} α β γ g f) P)
-Case conversion may be inaccurate. Consider using '#align regular_expression.map_map RegularExpression.map_mapₓ'. -/
 @[simp]
 theorem map_map (g : β → γ) (f : α → β) : ∀ P : RegularExpression α, (P.map f).map g = P.map (g ∘ f)
   | 0 => rfl
@@ -525,12 +501,6 @@ theorem map_map (g : β → γ) (f : α → β) : ∀ P : RegularExpression α,
   | star R => by simp_rw [map, map_map]
 #align regular_expression.map_map RegularExpression.map_map
 
-/- warning: regular_expression.matches_map -> RegularExpression.matches'_map is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} {β : Type.{u2}} (f : α -> β) (P : RegularExpression.{u1} α), Eq.{succ u2} (Language.{u2} β) (RegularExpression.matches'.{u2} β (RegularExpression.map.{u1, u2} α β f P)) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} (Language.{u1} α) (Language.{u2} β) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} α) (Language.semiring.{u1} α)) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} β) (Language.semiring.{u2} β))) (fun (_x : RingHom.{u1, u2} (Language.{u1} α) (Language.{u2} β) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} α) (Language.semiring.{u1} α)) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} β) (Language.semiring.{u2} β))) => (Language.{u1} α) -> (Language.{u2} β)) (RingHom.hasCoeToFun.{u1, u2} (Language.{u1} α) (Language.{u2} β) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} α) (Language.semiring.{u1} α)) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} β) (Language.semiring.{u2} β))) (Language.map.{u1, u2} α β f) (RegularExpression.matches'.{u1} α P))
-but is expected to have type
-  forall {α : Type.{u2}} {β : Type.{u1}} (f : α -> β) (P : RegularExpression.{u2} α), Eq.{succ u1} (Language.{u1} β) (RegularExpression.matches'.{u1} β (RegularExpression.map.{u2, u1} α β f P)) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} (Language.{u2} α) (Language.{u1} β) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} α) (Language.instSemiringLanguage.{u2} α)) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} β) (Language.instSemiringLanguage.{u1} β))) (Language.{u2} α) (fun (_x : Language.{u2} α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2397 : Language.{u2} α) => Language.{u1} β) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} (Language.{u2} α) (Language.{u1} β) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} α) (Language.instSemiringLanguage.{u2} α)) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} β) (Language.instSemiringLanguage.{u1} β))) (Language.{u2} α) (Language.{u1} β) (NonUnitalNonAssocSemiring.toMul.{u2} (Language.{u2} α) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (Language.{u2} α) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} α) (Language.instSemiringLanguage.{u2} α)))) (NonUnitalNonAssocSemiring.toMul.{u1} (Language.{u1} β) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Language.{u1} β) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} β) (Language.instSemiringLanguage.{u1} β)))) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} (Language.{u2} α) (Language.{u1} β) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} α) (Language.instSemiringLanguage.{u2} α)) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} β) (Language.instSemiringLanguage.{u1} β))) (Language.{u2} α) (Language.{u1} β) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (Language.{u2} α) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} α) (Language.instSemiringLanguage.{u2} α))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Language.{u1} β) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} β) (Language.instSemiringLanguage.{u1} β))) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} (Language.{u2} α) (Language.{u1} β) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} α) (Language.instSemiringLanguage.{u2} α)) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} β) (Language.instSemiringLanguage.{u1} β))) (Language.{u2} α) (Language.{u1} β) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} α) (Language.instSemiringLanguage.{u2} α)) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} β) (Language.instSemiringLanguage.{u1} β)) (RingHom.instRingHomClassRingHom.{u2, u1} (Language.{u2} α) (Language.{u1} β) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} α) (Language.instSemiringLanguage.{u2} α)) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} β) (Language.instSemiringLanguage.{u1} β)))))) (Language.map.{u2, u1} α β f) (RegularExpression.matches'.{u2} α P))
-Case conversion may be inaccurate. Consider using '#align regular_expression.matches_map RegularExpression.matches'_mapₓ'. -/
 /-- The language of the map is the map of the language. -/
 @[simp]
 theorem matches'_map (f : α → β) :
Diff
@@ -537,9 +537,7 @@ theorem matches'_map (f : α → β) :
     ∀ P : RegularExpression α, (P.map f).matches' = Language.map f P.matches'
   | 0 => (map_zero _).symm
   | 1 => (map_one _).symm
-  | Char a => by
-    rw [eq_comm]
-    exact image_singleton
+  | Char a => by rw [eq_comm]; exact image_singleton
   | R + S => by simp only [matches_map, map, matches_add, map_add]
   | R * S => by simp only [matches_map, map, matches_mul, map_mul]
   | star R => by
Diff
@@ -529,7 +529,7 @@ theorem map_map (g : β → γ) (f : α → β) : ∀ P : RegularExpression α,
 lean 3 declaration is
   forall {α : Type.{u1}} {β : Type.{u2}} (f : α -> β) (P : RegularExpression.{u1} α), Eq.{succ u2} (Language.{u2} β) (RegularExpression.matches'.{u2} β (RegularExpression.map.{u1, u2} α β f P)) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} (Language.{u1} α) (Language.{u2} β) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} α) (Language.semiring.{u1} α)) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} β) (Language.semiring.{u2} β))) (fun (_x : RingHom.{u1, u2} (Language.{u1} α) (Language.{u2} β) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} α) (Language.semiring.{u1} α)) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} β) (Language.semiring.{u2} β))) => (Language.{u1} α) -> (Language.{u2} β)) (RingHom.hasCoeToFun.{u1, u2} (Language.{u1} α) (Language.{u2} β) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} α) (Language.semiring.{u1} α)) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} β) (Language.semiring.{u2} β))) (Language.map.{u1, u2} α β f) (RegularExpression.matches'.{u1} α P))
 but is expected to have type
-  forall {α : Type.{u2}} {β : Type.{u1}} (f : α -> β) (P : RegularExpression.{u2} α), Eq.{succ u1} (Language.{u1} β) (RegularExpression.matches'.{u1} β (RegularExpression.map.{u2, u1} α β f P)) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} (Language.{u2} α) (Language.{u1} β) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} α) (Language.instSemiringLanguage.{u2} α)) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} β) (Language.instSemiringLanguage.{u1} β))) (Language.{u2} α) (fun (_x : Language.{u2} α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : Language.{u2} α) => Language.{u1} β) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} (Language.{u2} α) (Language.{u1} β) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} α) (Language.instSemiringLanguage.{u2} α)) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} β) (Language.instSemiringLanguage.{u1} β))) (Language.{u2} α) (Language.{u1} β) (NonUnitalNonAssocSemiring.toMul.{u2} (Language.{u2} α) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (Language.{u2} α) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} α) (Language.instSemiringLanguage.{u2} α)))) (NonUnitalNonAssocSemiring.toMul.{u1} (Language.{u1} β) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Language.{u1} β) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} β) (Language.instSemiringLanguage.{u1} β)))) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} (Language.{u2} α) (Language.{u1} β) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} α) (Language.instSemiringLanguage.{u2} α)) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} β) (Language.instSemiringLanguage.{u1} β))) (Language.{u2} α) (Language.{u1} β) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (Language.{u2} α) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} α) (Language.instSemiringLanguage.{u2} α))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Language.{u1} β) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} β) (Language.instSemiringLanguage.{u1} β))) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} (Language.{u2} α) (Language.{u1} β) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} α) (Language.instSemiringLanguage.{u2} α)) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} β) (Language.instSemiringLanguage.{u1} β))) (Language.{u2} α) (Language.{u1} β) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} α) (Language.instSemiringLanguage.{u2} α)) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} β) (Language.instSemiringLanguage.{u1} β)) (RingHom.instRingHomClassRingHom.{u2, u1} (Language.{u2} α) (Language.{u1} β) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} α) (Language.instSemiringLanguage.{u2} α)) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} β) (Language.instSemiringLanguage.{u1} β)))))) (Language.map.{u2, u1} α β f) (RegularExpression.matches'.{u2} α P))
+  forall {α : Type.{u2}} {β : Type.{u1}} (f : α -> β) (P : RegularExpression.{u2} α), Eq.{succ u1} (Language.{u1} β) (RegularExpression.matches'.{u1} β (RegularExpression.map.{u2, u1} α β f P)) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} (Language.{u2} α) (Language.{u1} β) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} α) (Language.instSemiringLanguage.{u2} α)) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} β) (Language.instSemiringLanguage.{u1} β))) (Language.{u2} α) (fun (_x : Language.{u2} α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2397 : Language.{u2} α) => Language.{u1} β) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} (Language.{u2} α) (Language.{u1} β) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} α) (Language.instSemiringLanguage.{u2} α)) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} β) (Language.instSemiringLanguage.{u1} β))) (Language.{u2} α) (Language.{u1} β) (NonUnitalNonAssocSemiring.toMul.{u2} (Language.{u2} α) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (Language.{u2} α) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} α) (Language.instSemiringLanguage.{u2} α)))) (NonUnitalNonAssocSemiring.toMul.{u1} (Language.{u1} β) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Language.{u1} β) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} β) (Language.instSemiringLanguage.{u1} β)))) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} (Language.{u2} α) (Language.{u1} β) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} α) (Language.instSemiringLanguage.{u2} α)) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} β) (Language.instSemiringLanguage.{u1} β))) (Language.{u2} α) (Language.{u1} β) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (Language.{u2} α) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} α) (Language.instSemiringLanguage.{u2} α))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Language.{u1} β) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} β) (Language.instSemiringLanguage.{u1} β))) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} (Language.{u2} α) (Language.{u1} β) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} α) (Language.instSemiringLanguage.{u2} α)) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} β) (Language.instSemiringLanguage.{u1} β))) (Language.{u2} α) (Language.{u1} β) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} α) (Language.instSemiringLanguage.{u2} α)) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} β) (Language.instSemiringLanguage.{u1} β)) (RingHom.instRingHomClassRingHom.{u2, u1} (Language.{u2} α) (Language.{u1} β) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} α) (Language.instSemiringLanguage.{u2} α)) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} β) (Language.instSemiringLanguage.{u1} β)))))) (Language.map.{u2, u1} α β f) (RegularExpression.matches'.{u2} α P))
 Case conversion may be inaccurate. Consider using '#align regular_expression.matches_map RegularExpression.matches'_mapₓ'. -/
 /-- The language of the map is the map of the language. -/
 @[simp]
Diff
@@ -544,7 +544,7 @@ theorem matches'_map (f : α → β) :
   | R * S => by simp only [matches_map, map, matches_mul, map_mul]
   | star R => by
     simp_rw [map, matches, matches_map]
-    rw [Language.kstar_eq_supᵢ_pow, Language.kstar_eq_supᵢ_pow]
+    rw [Language.kstar_eq_iSup_pow, Language.kstar_eq_iSup_pow]
     simp_rw [← map_pow]
     exact image_Union.symm
 #align regular_expression.matches_map RegularExpression.matches'_map
Diff
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Fox Thomson
 
 ! This file was ported from Lean 3 source module computability.regular_expressions
-! leanprover-community/mathlib commit a239cd3e7ac2c7cde36c913808f9d40c411344f6
+! leanprover-community/mathlib commit d64d67d000b974f0d86a2be7918cf800be6271c8
 ! Please do not edit these lines, except to modify the commit id
 ! if you have ported upstream changes.
 -/
@@ -14,6 +14,9 @@ import Mathbin.Computability.Language
 /-!
 # Regular Expressions
 
+> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.
+> Any changes to this file require a corresponding PR to mathlib4.
+
 This file contains the formal definition for regular expressions and basic lemmas. Note these are
 regular expressions in terms of formal language theory. Note this is different to regex's used in
 computer science such as the POSIX standard.
Diff
@@ -33,6 +33,7 @@ universe u
 
 variable {α β γ : Type _} [dec : DecidableEq α]
 
+#print RegularExpression /-
 /-- This is the definition of regular expressions. The names used here is to mirror the definition
 of a Kleene algebra (https://en.wikipedia.org/wiki/Kleene_algebra).
 * `0` (`zero`) matches nothing
@@ -50,6 +51,7 @@ inductive RegularExpression (α : Type u) : Type u
   | comp : RegularExpression → RegularExpression → RegularExpression
   | star : RegularExpression → RegularExpression
 #align regular_expression RegularExpression
+-/
 
 namespace RegularExpression
 
@@ -75,73 +77,106 @@ instance : Pow (RegularExpression α) ℕ :=
 
 attribute [match_pattern] Mul.mul
 
+#print RegularExpression.zero_def /-
 @[simp]
 theorem zero_def : (zero : RegularExpression α) = 0 :=
   rfl
 #align regular_expression.zero_def RegularExpression.zero_def
+-/
 
+#print RegularExpression.one_def /-
 @[simp]
 theorem one_def : (epsilon : RegularExpression α) = 1 :=
   rfl
 #align regular_expression.one_def RegularExpression.one_def
+-/
 
+#print RegularExpression.plus_def /-
 @[simp]
 theorem plus_def (P Q : RegularExpression α) : plus P Q = P + Q :=
   rfl
 #align regular_expression.plus_def RegularExpression.plus_def
+-/
 
+#print RegularExpression.comp_def /-
 @[simp]
 theorem comp_def (P Q : RegularExpression α) : comp P Q = P * Q :=
   rfl
 #align regular_expression.comp_def RegularExpression.comp_def
+-/
 
+#print RegularExpression.matches' /-
 /-- `matches P` provides a language which contains all strings that `P` matches -/
 @[simp]
-def matches : RegularExpression α → Language α
+def matches' : RegularExpression α → Language α
   | 0 => 0
   | 1 => 1
   | Char a => {[a]}
-  | P + Q => P.matches + Q.matches
-  | P * Q => P.matches * Q.matches
-  | star P => P.matches∗
-#align regular_expression.matches RegularExpression.matches
+  | P + Q => P.matches' + Q.matches'
+  | P * Q => P.matches' * Q.matches'
+  | star P => P.matches'∗
+#align regular_expression.matches RegularExpression.matches'
+-/
 
+#print RegularExpression.matches'_zero /-
 @[simp]
-theorem matches_zero : (0 : RegularExpression α).matches = 0 :=
+theorem matches'_zero : (0 : RegularExpression α).matches' = 0 :=
   rfl
-#align regular_expression.matches_zero RegularExpression.matches_zero
+#align regular_expression.matches_zero RegularExpression.matches'_zero
+-/
 
+#print RegularExpression.matches'_epsilon /-
 @[simp]
-theorem matches_epsilon : (1 : RegularExpression α).matches = 1 :=
+theorem matches'_epsilon : (1 : RegularExpression α).matches' = 1 :=
   rfl
-#align regular_expression.matches_epsilon RegularExpression.matches_epsilon
+#align regular_expression.matches_epsilon RegularExpression.matches'_epsilon
+-/
 
+#print RegularExpression.matches'_char /-
 @[simp]
-theorem matches_char (a : α) : (char a).matches = {[a]} :=
+theorem matches'_char (a : α) : (char a).matches' = {[a]} :=
   rfl
-#align regular_expression.matches_char RegularExpression.matches_char
+#align regular_expression.matches_char RegularExpression.matches'_char
+-/
 
+/- warning: regular_expression.matches_add -> RegularExpression.matches'_add is a dubious translation:
+lean 3 declaration is
+  forall {α : Type.{u1}} (P : RegularExpression.{u1} α) (Q : RegularExpression.{u1} α), Eq.{succ u1} (Language.{u1} α) (RegularExpression.matches'.{u1} α (HAdd.hAdd.{u1, u1, u1} (RegularExpression.{u1} α) (RegularExpression.{u1} α) (RegularExpression.{u1} α) (instHAdd.{u1} (RegularExpression.{u1} α) (RegularExpression.hasAdd.{u1} α)) P Q)) (HAdd.hAdd.{u1, u1, u1} (Language.{u1} α) (Language.{u1} α) (Language.{u1} α) (instHAdd.{u1} (Language.{u1} α) (Language.hasAdd.{u1} α)) (RegularExpression.matches'.{u1} α P) (RegularExpression.matches'.{u1} α Q))
+but is expected to have type
+  forall {α : Type.{u1}} (P : RegularExpression.{u1} α) (Q : RegularExpression.{u1} α), Eq.{succ u1} (Language.{u1} α) (RegularExpression.matches'.{u1} α (HAdd.hAdd.{u1, u1, u1} (RegularExpression.{u1} α) (RegularExpression.{u1} α) (RegularExpression.{u1} α) (instHAdd.{u1} (RegularExpression.{u1} α) (RegularExpression.instAddRegularExpression.{u1} α)) P Q)) (HAdd.hAdd.{u1, u1, u1} (Language.{u1} α) (Language.{u1} α) (Language.{u1} α) (instHAdd.{u1} (Language.{u1} α) (Language.instAddLanguage.{u1} α)) (RegularExpression.matches'.{u1} α P) (RegularExpression.matches'.{u1} α Q))
+Case conversion may be inaccurate. Consider using '#align regular_expression.matches_add RegularExpression.matches'_addₓ'. -/
 @[simp]
-theorem matches_add (P Q : RegularExpression α) : (P + Q).matches = P.matches + Q.matches :=
+theorem matches'_add (P Q : RegularExpression α) : (P + Q).matches' = P.matches' + Q.matches' :=
   rfl
-#align regular_expression.matches_add RegularExpression.matches_add
+#align regular_expression.matches_add RegularExpression.matches'_add
 
+#print RegularExpression.matches'_mul /-
 @[simp]
-theorem matches_mul (P Q : RegularExpression α) : (P * Q).matches = P.matches * Q.matches :=
+theorem matches'_mul (P Q : RegularExpression α) : (P * Q).matches' = P.matches' * Q.matches' :=
   rfl
-#align regular_expression.matches_mul RegularExpression.matches_mul
+#align regular_expression.matches_mul RegularExpression.matches'_mul
+-/
 
+/- warning: regular_expression.matches_pow -> RegularExpression.matches'_pow is a dubious translation:
+lean 3 declaration is
+  forall {α : Type.{u1}} (P : RegularExpression.{u1} α) (n : Nat), Eq.{succ u1} (Language.{u1} α) (RegularExpression.matches'.{u1} α (HPow.hPow.{u1, 0, u1} (RegularExpression.{u1} α) Nat (RegularExpression.{u1} α) (instHPow.{u1, 0} (RegularExpression.{u1} α) Nat (RegularExpression.Nat.hasPow.{u1} α)) P n)) (HPow.hPow.{u1, 0, u1} (Language.{u1} α) Nat (Language.{u1} α) (instHPow.{u1, 0} (Language.{u1} α) Nat (Monoid.Pow.{u1} (Language.{u1} α) (MonoidWithZero.toMonoid.{u1} (Language.{u1} α) (Semiring.toMonoidWithZero.{u1} (Language.{u1} α) (Language.semiring.{u1} α))))) (RegularExpression.matches'.{u1} α P) n)
+but is expected to have type
+  forall {α : Type.{u1}} (P : RegularExpression.{u1} α) (n : Nat), Eq.{succ u1} (Language.{u1} α) (RegularExpression.matches'.{u1} α (HPow.hPow.{u1, 0, u1} (RegularExpression.{u1} α) Nat (RegularExpression.{u1} α) (instHPow.{u1, 0} (RegularExpression.{u1} α) Nat (RegularExpression.instPowRegularExpressionNat.{u1} α)) P n)) (HPow.hPow.{u1, 0, u1} (Language.{u1} α) Nat (Language.{u1} α) (instHPow.{u1, 0} (Language.{u1} α) Nat (Monoid.Pow.{u1} (Language.{u1} α) (MonoidWithZero.toMonoid.{u1} (Language.{u1} α) (Semiring.toMonoidWithZero.{u1} (Language.{u1} α) (Language.instSemiringLanguage.{u1} α))))) (RegularExpression.matches'.{u1} α P) n)
+Case conversion may be inaccurate. Consider using '#align regular_expression.matches_pow RegularExpression.matches'_powₓ'. -/
 @[simp]
-theorem matches_pow (P : RegularExpression α) : ∀ n : ℕ, (P ^ n).matches = P.matches ^ n
-  | 0 => matches_epsilon
-  | n + 1 => (matches_mul _ _).trans <| Eq.trans (congr_arg _ (matches_pow n)) (pow_succ _ _).symm
-#align regular_expression.matches_pow RegularExpression.matches_pow
+theorem matches'_pow (P : RegularExpression α) : ∀ n : ℕ, (P ^ n).matches' = P.matches' ^ n
+  | 0 => matches'_epsilon
+  | n + 1 => (matches'_mul _ _).trans <| Eq.trans (congr_arg _ (matches_pow n)) (pow_succ _ _).symm
+#align regular_expression.matches_pow RegularExpression.matches'_pow
 
+#print RegularExpression.matches'_star /-
 @[simp]
-theorem matches_star (P : RegularExpression α) : P.unit.matches = P.matches∗ :=
+theorem matches'_star (P : RegularExpression α) : P.unit.matches' = P.matches'∗ :=
   rfl
-#align regular_expression.matches_star RegularExpression.matches_star
+#align regular_expression.matches_star RegularExpression.matches'_star
+-/
 
+#print RegularExpression.matchEpsilon /-
 /-- `match_epsilon P` is true if and only if `P` matches the empty string -/
 def matchEpsilon : RegularExpression α → Bool
   | 0 => false
@@ -151,9 +186,11 @@ def matchEpsilon : RegularExpression α → Bool
   | P * Q => P.matchEpsilon && Q.matchEpsilon
   | star P => true
 #align regular_expression.match_epsilon RegularExpression.matchEpsilon
+-/
 
 include dec
 
+#print RegularExpression.deriv /-
 /-- `P.deriv a` matches `x` if `P` matches `a :: x`, the Brzozowski derivative of `P` with respect
   to `a` -/
 def deriv : RegularExpression α → α → RegularExpression α
@@ -164,53 +201,73 @@ def deriv : RegularExpression α → α → RegularExpression α
   | P * Q, a => if P.matchEpsilon then deriv P a * Q + deriv Q a else deriv P a * Q
   | star P, a => deriv P a * star P
 #align regular_expression.deriv RegularExpression.deriv
+-/
 
+#print RegularExpression.deriv_zero /-
 @[simp]
 theorem deriv_zero (a : α) : deriv 0 a = 0 :=
   rfl
 #align regular_expression.deriv_zero RegularExpression.deriv_zero
+-/
 
+#print RegularExpression.deriv_one /-
 @[simp]
 theorem deriv_one (a : α) : deriv 1 a = 0 :=
   rfl
 #align regular_expression.deriv_one RegularExpression.deriv_one
+-/
 
+#print RegularExpression.deriv_char_self /-
 @[simp]
 theorem deriv_char_self (a : α) : deriv (char a) a = 1 :=
   if_pos rfl
 #align regular_expression.deriv_char_self RegularExpression.deriv_char_self
+-/
 
+#print RegularExpression.deriv_char_of_ne /-
 @[simp]
 theorem deriv_char_of_ne (h : a ≠ b) : deriv (char a) b = 0 :=
   if_neg h
 #align regular_expression.deriv_char_of_ne RegularExpression.deriv_char_of_ne
+-/
 
+#print RegularExpression.deriv_add /-
 @[simp]
 theorem deriv_add (P Q : RegularExpression α) (a : α) : deriv (P + Q) a = deriv P a + deriv Q a :=
   rfl
 #align regular_expression.deriv_add RegularExpression.deriv_add
+-/
 
+#print RegularExpression.deriv_star /-
 @[simp]
 theorem deriv_star (P : RegularExpression α) (a : α) : deriv P.unit a = deriv P a * star P :=
   rfl
 #align regular_expression.deriv_star RegularExpression.deriv_star
+-/
 
+#print RegularExpression.rmatch /-
 /-- `P.rmatch x` is true if and only if `P` matches `x`. This is a computable definition equivalent
   to `matches`. -/
 def rmatch : RegularExpression α → List α → Bool
   | P, [] => matchEpsilon P
   | P, a :: as => rmatch (P.deriv a) as
 #align regular_expression.rmatch RegularExpression.rmatch
+-/
 
+#print RegularExpression.zero_rmatch /-
 @[simp]
 theorem zero_rmatch (x : List α) : rmatch 0 x = false := by
   induction x <;> simp [rmatch, match_epsilon, *]
 #align regular_expression.zero_rmatch RegularExpression.zero_rmatch
+-/
 
+#print RegularExpression.one_rmatch_iff /-
 theorem one_rmatch_iff (x : List α) : rmatch 1 x ↔ x = [] := by
   induction x <;> simp [rmatch, match_epsilon, *]
 #align regular_expression.one_rmatch_iff RegularExpression.one_rmatch_iff
+-/
 
+#print RegularExpression.char_rmatch_iff /-
 theorem char_rmatch_iff (a : α) (x : List α) : rmatch (char a) x ↔ x = [a] :=
   by
   cases' x with _ x
@@ -225,7 +282,9 @@ theorem char_rmatch_iff (a : α) (x : List α) : rmatch (char a) x ↔ x = [a] :
   rw [zero_rmatch]
   tauto
 #align regular_expression.char_rmatch_iff RegularExpression.char_rmatch_iff
+-/
 
+#print RegularExpression.add_rmatch_iff /-
 theorem add_rmatch_iff (P Q : RegularExpression α) (x : List α) :
     (P + Q).rmatch x ↔ P.rmatch x ∨ Q.rmatch x :=
   by
@@ -235,7 +294,9 @@ theorem add_rmatch_iff (P Q : RegularExpression α) (x : List α) :
     rw [deriv]
     exact ih _ _
 #align regular_expression.add_rmatch_iff RegularExpression.add_rmatch_iff
+-/
 
+#print RegularExpression.mul_rmatch_iff /-
 theorem mul_rmatch_iff (P Q : RegularExpression α) (x : List α) :
     (P * Q).rmatch x ↔ ∃ t u : List α, x = t ++ u ∧ P.rmatch t ∧ Q.rmatch u :=
   by
@@ -282,7 +343,9 @@ theorem mul_rmatch_iff (P Q : RegularExpression α) (x : List α) :
           convert hP
           exact h.1
 #align regular_expression.mul_rmatch_iff RegularExpression.mul_rmatch_iff
+-/
 
+#print RegularExpression.star_rmatch_iff /-
 theorem star_rmatch_iff (P : RegularExpression α) :
     ∀ x : List α, (star P).rmatch x ↔ ∃ S : List (List α), x = S.join ∧ ∀ t ∈ S, t ≠ [] ∧ P.rmatch t
   | x =>
@@ -342,9 +405,11 @@ theorem star_rmatch_iff (P : RegularExpression α) :
             assumption termination_by'
   ⟨fun L₁ L₂ : List _ => L₁.length < L₂.length, InvImage.wf _ Nat.lt_wfRel⟩
 #align regular_expression.star_rmatch_iff RegularExpression.star_rmatch_iff
+-/
 
+#print RegularExpression.rmatch_iff_matches' /-
 @[simp]
-theorem rmatch_iff_matches (P : RegularExpression α) : ∀ x : List α, P.rmatch x ↔ x ∈ P.matches :=
+theorem rmatch_iff_matches' (P : RegularExpression α) : ∀ x : List α, P.rmatch x ↔ x ∈ P.matches' :=
   by
   intro x
   induction P generalizing x
@@ -391,9 +456,10 @@ theorem rmatch_iff_matches (P : RegularExpression α) : ∀ x : List α, P.rmatc
       tauto
     · rw [ih y]
       tauto
-#align regular_expression.rmatch_iff_matches RegularExpression.rmatch_iff_matches
+#align regular_expression.rmatch_iff_matches RegularExpression.rmatch_iff_matches'
+-/
 
-instance (P : RegularExpression α) : DecidablePred P.matches :=
+instance (P : RegularExpression α) : DecidablePred P.matches' :=
   by
   intro x
   change Decidable (x ∈ P.matches)
@@ -402,6 +468,7 @@ instance (P : RegularExpression α) : DecidablePred P.matches :=
 
 omit dec
 
+#print RegularExpression.map /-
 /-- Map the alphabet of a regular expression. -/
 @[simp]
 def map (f : α → β) : RegularExpression α → RegularExpression β
@@ -412,7 +479,14 @@ def map (f : α → β) : RegularExpression α → RegularExpression β
   | R * S => map R * map S
   | star R => star (map R)
 #align regular_expression.map RegularExpression.map
+-/
 
+/- warning: regular_expression.map_pow -> RegularExpression.map_pow is a dubious translation:
+lean 3 declaration is
+  forall {α : Type.{u1}} {β : Type.{u2}} (f : α -> β) (P : RegularExpression.{u1} α) (n : Nat), Eq.{succ u2} (RegularExpression.{u2} β) (RegularExpression.map.{u1, u2} α β f (HPow.hPow.{u1, 0, u1} (RegularExpression.{u1} α) Nat (RegularExpression.{u1} α) (instHPow.{u1, 0} (RegularExpression.{u1} α) Nat (RegularExpression.Nat.hasPow.{u1} α)) P n)) (HPow.hPow.{u2, 0, u2} (RegularExpression.{u2} β) Nat (RegularExpression.{u2} β) (instHPow.{u2, 0} (RegularExpression.{u2} β) Nat (RegularExpression.Nat.hasPow.{u2} β)) (RegularExpression.map.{u1, u2} α β f P) n)
+but is expected to have type
+  forall {α : Type.{u2}} {β : Type.{u1}} (f : α -> β) (P : RegularExpression.{u2} α) (n : Nat), Eq.{succ u1} (RegularExpression.{u1} β) (RegularExpression.map.{u2, u1} α β f (HPow.hPow.{u2, 0, u2} (RegularExpression.{u2} α) Nat (RegularExpression.{u2} α) (instHPow.{u2, 0} (RegularExpression.{u2} α) Nat (RegularExpression.instPowRegularExpressionNat.{u2} α)) P n)) (HPow.hPow.{u1, 0, u1} (RegularExpression.{u1} β) Nat (RegularExpression.{u1} β) (instHPow.{u1, 0} (RegularExpression.{u1} β) Nat (RegularExpression.instPowRegularExpressionNat.{u1} β)) (RegularExpression.map.{u2, u1} α β f P) n)
+Case conversion may be inaccurate. Consider using '#align regular_expression.map_pow RegularExpression.map_powₓ'. -/
 @[simp]
 protected theorem map_pow (f : α → β) (P : RegularExpression α) :
     ∀ n : ℕ, map f (P ^ n) = map f P ^ n
@@ -420,6 +494,7 @@ protected theorem map_pow (f : α → β) (P : RegularExpression α) :
   | n + 1 => (congr_arg ((· * ·) (map f P)) (map_pow n) : _)
 #align regular_expression.map_pow RegularExpression.map_pow
 
+#print RegularExpression.map_id /-
 @[simp]
 theorem map_id : ∀ P : RegularExpression α, P.map id = P
   | 0 => rfl
@@ -429,7 +504,14 @@ theorem map_id : ∀ P : RegularExpression α, P.map id = P
   | R * S => by simp_rw [map, map_id]
   | star R => by simp_rw [map, map_id]
 #align regular_expression.map_id RegularExpression.map_id
+-/
 
+/- warning: regular_expression.map_map -> RegularExpression.map_map is a dubious translation:
+lean 3 declaration is
+  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} (g : β -> γ) (f : α -> β) (P : RegularExpression.{u1} α), Eq.{succ u3} (RegularExpression.{u3} γ) (RegularExpression.map.{u2, u3} β γ g (RegularExpression.map.{u1, u2} α β f P)) (RegularExpression.map.{u1, u3} α γ (Function.comp.{succ u1, succ u2, succ u3} α β γ g f) P)
+but is expected to have type
+  forall {α : Type.{u3}} {β : Type.{u1}} {γ : Type.{u2}} (g : β -> γ) (f : α -> β) (P : RegularExpression.{u3} α), Eq.{succ u2} (RegularExpression.{u2} γ) (RegularExpression.map.{u1, u2} β γ g (RegularExpression.map.{u3, u1} α β f P)) (RegularExpression.map.{u3, u2} α γ (Function.comp.{succ u3, succ u1, succ u2} α β γ g f) P)
+Case conversion may be inaccurate. Consider using '#align regular_expression.map_map RegularExpression.map_mapₓ'. -/
 @[simp]
 theorem map_map (g : β → γ) (f : α → β) : ∀ P : RegularExpression α, (P.map f).map g = P.map (g ∘ f)
   | 0 => rfl
@@ -440,10 +522,16 @@ theorem map_map (g : β → γ) (f : α → β) : ∀ P : RegularExpression α,
   | star R => by simp_rw [map, map_map]
 #align regular_expression.map_map RegularExpression.map_map
 
+/- warning: regular_expression.matches_map -> RegularExpression.matches'_map is a dubious translation:
+lean 3 declaration is
+  forall {α : Type.{u1}} {β : Type.{u2}} (f : α -> β) (P : RegularExpression.{u1} α), Eq.{succ u2} (Language.{u2} β) (RegularExpression.matches'.{u2} β (RegularExpression.map.{u1, u2} α β f P)) (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (RingHom.{u1, u2} (Language.{u1} α) (Language.{u2} β) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} α) (Language.semiring.{u1} α)) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} β) (Language.semiring.{u2} β))) (fun (_x : RingHom.{u1, u2} (Language.{u1} α) (Language.{u2} β) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} α) (Language.semiring.{u1} α)) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} β) (Language.semiring.{u2} β))) => (Language.{u1} α) -> (Language.{u2} β)) (RingHom.hasCoeToFun.{u1, u2} (Language.{u1} α) (Language.{u2} β) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} α) (Language.semiring.{u1} α)) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} β) (Language.semiring.{u2} β))) (Language.map.{u1, u2} α β f) (RegularExpression.matches'.{u1} α P))
+but is expected to have type
+  forall {α : Type.{u2}} {β : Type.{u1}} (f : α -> β) (P : RegularExpression.{u2} α), Eq.{succ u1} (Language.{u1} β) (RegularExpression.matches'.{u1} β (RegularExpression.map.{u2, u1} α β f P)) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (RingHom.{u2, u1} (Language.{u2} α) (Language.{u1} β) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} α) (Language.instSemiringLanguage.{u2} α)) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} β) (Language.instSemiringLanguage.{u1} β))) (Language.{u2} α) (fun (_x : Language.{u2} α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.2391 : Language.{u2} α) => Language.{u1} β) _x) (MulHomClass.toFunLike.{max u2 u1, u2, u1} (RingHom.{u2, u1} (Language.{u2} α) (Language.{u1} β) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} α) (Language.instSemiringLanguage.{u2} α)) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} β) (Language.instSemiringLanguage.{u1} β))) (Language.{u2} α) (Language.{u1} β) (NonUnitalNonAssocSemiring.toMul.{u2} (Language.{u2} α) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (Language.{u2} α) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} α) (Language.instSemiringLanguage.{u2} α)))) (NonUnitalNonAssocSemiring.toMul.{u1} (Language.{u1} β) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Language.{u1} β) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} β) (Language.instSemiringLanguage.{u1} β)))) (NonUnitalRingHomClass.toMulHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} (Language.{u2} α) (Language.{u1} β) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} α) (Language.instSemiringLanguage.{u2} α)) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} β) (Language.instSemiringLanguage.{u1} β))) (Language.{u2} α) (Language.{u1} β) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u2} (Language.{u2} α) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} α) (Language.instSemiringLanguage.{u2} α))) (NonAssocSemiring.toNonUnitalNonAssocSemiring.{u1} (Language.{u1} β) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} β) (Language.instSemiringLanguage.{u1} β))) (RingHomClass.toNonUnitalRingHomClass.{max u2 u1, u2, u1} (RingHom.{u2, u1} (Language.{u2} α) (Language.{u1} β) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} α) (Language.instSemiringLanguage.{u2} α)) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} β) (Language.instSemiringLanguage.{u1} β))) (Language.{u2} α) (Language.{u1} β) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} α) (Language.instSemiringLanguage.{u2} α)) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} β) (Language.instSemiringLanguage.{u1} β)) (RingHom.instRingHomClassRingHom.{u2, u1} (Language.{u2} α) (Language.{u1} β) (Semiring.toNonAssocSemiring.{u2} (Language.{u2} α) (Language.instSemiringLanguage.{u2} α)) (Semiring.toNonAssocSemiring.{u1} (Language.{u1} β) (Language.instSemiringLanguage.{u1} β)))))) (Language.map.{u2, u1} α β f) (RegularExpression.matches'.{u2} α P))
+Case conversion may be inaccurate. Consider using '#align regular_expression.matches_map RegularExpression.matches'_mapₓ'. -/
 /-- The language of the map is the map of the language. -/
 @[simp]
-theorem matches_map (f : α → β) :
-    ∀ P : RegularExpression α, (P.map f).matches = Language.map f P.matches
+theorem matches'_map (f : α → β) :
+    ∀ P : RegularExpression α, (P.map f).matches' = Language.map f P.matches'
   | 0 => (map_zero _).symm
   | 1 => (map_one _).symm
   | Char a => by
@@ -456,7 +544,7 @@ theorem matches_map (f : α → β) :
     rw [Language.kstar_eq_supᵢ_pow, Language.kstar_eq_supᵢ_pow]
     simp_rw [← map_pow]
     exact image_Union.symm
-#align regular_expression.matches_map RegularExpression.matches_map
+#align regular_expression.matches_map RegularExpression.matches'_map
 
 end RegularExpression
 

Changes in mathlib4

mathlib3
mathlib4
chore: adapt to multiple goal linter 1 (#12338)

A PR accompanying #12339.

Zulip discussion

Diff
@@ -246,7 +246,7 @@ theorem add_rmatch_iff (P Q : RegularExpression α) (x : List α) :
     (P + Q).rmatch x ↔ P.rmatch x ∨ Q.rmatch x := by
   induction' x with _ _ ih generalizing P Q
   · simp only [rmatch, matchEpsilon, Bool.coe_or_iff]
-  · repeat' rw [rmatch]
+  · repeat rw [rmatch]
     rw [deriv_add]
     exact ih _ _
 #align regular_expression.add_rmatch_iff RegularExpression.add_rmatch_iff
@@ -264,7 +264,7 @@ theorem mul_rmatch_iff (P Q : RegularExpression α) (x : List α) :
       cases' List.append_eq_nil.1 h₁.symm with ht hu
       subst ht
       subst hu
-      repeat' rw [rmatch] at h₂
+      repeat rw [rmatch] at h₂
       simp [h₂]
   · rw [rmatch]; simp [deriv]
     split_ifs with hepsilon
chore: avoid Ne.def (adaptation for nightly-2024-03-27) (#11801)
Diff
@@ -335,7 +335,7 @@ theorem star_rmatch_iff (P : RegularExpression α) :
         · exact ⟨[], [], by tauto⟩
         · cases' t' with b t
           · simp only [forall_eq_or_imp, List.mem_cons] at helem
-            simp only [eq_self_iff_true, not_true, Ne.def, false_and_iff] at helem
+            simp only [eq_self_iff_true, not_true, Ne, false_and_iff] at helem
           simp only [List.join, List.cons_append, List.cons_eq_cons] at hsum
           refine' ⟨t, U.join, hsum.2, _, _⟩
           · specialize helem (b :: t) (by simp)
change the order of operation in zsmulRec and nsmulRec (#11451)

We change the following field in the definition of an additive commutative monoid:

 nsmul_succ : ∀ (n : ℕ) (x : G),
-  AddMonoid.nsmul (n + 1) x = x + AddMonoid.nsmul n x
+  AddMonoid.nsmul (n + 1) x = AddMonoid.nsmul n x + x

where the latter is more natural

We adjust the definitions of ^ in monoids, groups, etc. Originally there was a warning comment about why this natural order was preferred

use x * npowRec n x and not npowRec n x * x in the definition to make sure that definitional unfolding of npowRec is blocked, to avoid deep recursion issues.

but it seems to no longer apply.

Remarks on the PR :

  • pow_succ and pow_succ' have switched their meanings.
  • Most of the time, the proofs were adjusted by priming/unpriming one lemma, or exchanging left and right; a few proofs were more complicated to adjust.
  • In particular, [Mathlib/NumberTheory/RamificationInertia.lean] used Ideal.IsPrime.mul_mem_pow which is defined in [Mathlib/RingTheory/DedekindDomain/Ideal.lean]. Changing the order of operation forced me to add the symmetric lemma Ideal.IsPrime.mem_pow_mul.
  • the docstring for Cauchy condensation test in [Mathlib/Analysis/PSeries.lean] was mathematically incorrect, I added the mention that the function is antitone.
Diff
@@ -146,8 +146,9 @@ theorem matches'_mul (P Q : RegularExpression α) : (P * Q).matches' = P.matches
 @[simp]
 theorem matches'_pow (P : RegularExpression α) : ∀ n : ℕ, (P ^ n).matches' = P.matches' ^ n
   | 0 => matches'_epsilon
-  | n + 1 => (matches'_mul _ _).trans <|
-      Eq.trans (congr_arg _ (matches'_pow P n)) (pow_succ _ _).symm
+  | n + 1 => (matches'_mul _ _).trans <| Eq.trans
+      (congrFun (congrArg HMul.hMul (matches'_pow P n)) (matches' P))
+      (pow_succ _ n).symm
 #align regular_expression.matches_pow RegularExpression.matches'_pow
 
 @[simp]
@@ -394,7 +395,7 @@ def map (f : α → β) : RegularExpression α → RegularExpression β
 protected theorem map_pow (f : α → β) (P : RegularExpression α) :
     ∀ n : ℕ, map f (P ^ n) = map f P ^ n
   | 0 => by dsimp; rfl
-  | n + 1 => (congr_arg (map f P * ·) (RegularExpression.map_pow f P n) : _)
+  | n + 1 => (congr_arg (· * map f P) (RegularExpression.map_pow f P n) : _)
 #align regular_expression.map_pow RegularExpression.map_pow
 
 @[simp]
chore: remove unneeded decreasing_by and termination_by (#11386)

The termination checker has been getting more capable, and many of the termination_by or decreasing_by clauses in Mathlib are no longer needed.

(Note that termination_by? will show the automatically derived termination expression, so no information is being lost by removing these.)

Co-authored-by: Scott Morrison <scott.morrison@gmail.com>

Diff
@@ -349,7 +349,7 @@ theorem star_rmatch_iff (P : RegularExpression α) :
             refine' ⟨U, rfl, fun t h => helem t _⟩
             right
             assumption
-  termination_by t => (P,t.length)
+  termination_by t => (P, t.length)
 #align regular_expression.star_rmatch_iff RegularExpression.star_rmatch_iff
 
 @[simp]
chore: move Mathlib to v4.7.0-rc1 (#11162)

This is a very large PR, but it has been reviewed piecemeal already in PRs to the bump/v4.7.0 branch as we update to intermediate nightlies.

Co-authored-by: Scott Morrison <scott.morrison@gmail.com> Co-authored-by: Kyle Miller <kmill31415@gmail.com> Co-authored-by: damiano <adomani@gmail.com>

Diff
@@ -112,7 +112,9 @@ def matches' : RegularExpression α → Language α
   | 1 => 1
   | char a => {[a]}
   | P + Q => P.matches' + Q.matches'
-  | P * Q => P.matches' * Q.matches'
+  -- Adaptation note: around nightly-2024-02-25, we need to write `comp x y` in the pattern here,
+  -- instead of `x * y`.
+  | comp P Q => P.matches' * Q.matches'
   | star P => P.matches'∗
 #align regular_expression.matches RegularExpression.matches'
 
@@ -159,7 +161,9 @@ def matchEpsilon : RegularExpression α → Bool
   | 1 => true
   | char _ => false
   | P + Q => P.matchEpsilon || Q.matchEpsilon
-  | P * Q => P.matchEpsilon && Q.matchEpsilon
+  -- Adaptation note: around nightly-2024-02-25, we need to write `comp x y` in the pattern here,
+  -- instead of `x * y`.
+  | comp P Q => P.matchEpsilon && Q.matchEpsilon
   | star _P => true
 #align regular_expression.match_epsilon RegularExpression.matchEpsilon
 
@@ -171,7 +175,9 @@ def deriv : RegularExpression α → α → RegularExpression α
   | 1, _ => 0
   | char a₁, a₂ => if a₁ = a₂ then 1 else 0
   | P + Q, a => deriv P a + deriv Q a
-  | P * Q, a => if P.matchEpsilon then deriv P a * Q + deriv Q a else deriv P a * Q
+  -- Adaptation note: around nightly-2024-02-25, we need to write `comp x y` in the pattern here,
+  -- instead of `x * y`.
+  | comp P Q, a => if P.matchEpsilon then deriv P a * Q + deriv Q a else deriv P a * Q
   | star P, a => deriv P a * star P
 #align regular_expression.deriv RegularExpression.deriv
 
@@ -378,7 +384,9 @@ def map (f : α → β) : RegularExpression α → RegularExpression β
   | 1 => 1
   | char a => char (f a)
   | R + S => map f R + map f S
-  | R * S => map f R * map f S
+  -- Adaptation note: around nightly-2024-02-25, we need to write `comp x y` in the pattern here,
+  -- instead of `x * y`.
+  | comp R S => map f R * map f S
   | star R => star (map f R)
 #align regular_expression.map RegularExpression.map
 
@@ -395,7 +403,9 @@ theorem map_id : ∀ P : RegularExpression α, P.map id = P
   | 1 => rfl
   | char a => rfl
   | R + S => by simp_rw [map, map_id]
-  | R * S => by simp_rw [map, map_id]
+  -- Adaptation note: around nightly-2024-02-25, we need to write `comp x y` in the pattern here,
+  -- instead of `x * y`.
+  | comp R S => by simp_rw [map, map_id]; rfl
   | star R => by simp_rw [map, map_id]
 #align regular_expression.map_id RegularExpression.map_id
 
@@ -405,7 +415,9 @@ theorem map_map (g : β → γ) (f : α → β) : ∀ P : RegularExpression α,
   | 1 => rfl
   | char a => rfl
   | R + S => by simp only [map, Function.comp_apply, map_map]
-  | R * S => by simp only [map, Function.comp_apply, map_map]
+  -- Adaptation note: around nightly-2024-02-25, we need to write `comp x y` in the pattern here,
+  -- instead of `x * y`.
+  | comp R S => by simp only [map, Function.comp_apply, map_map]
   | star R => by simp only [map, Function.comp_apply, map_map]
 #align regular_expression.map_map RegularExpression.map_map
 
@@ -420,7 +432,9 @@ theorem matches'_map (f : α → β) :
     exact image_singleton
   -- Porting note: the following close with last `rw` but not with `simp`?
   | R + S => by simp only [matches'_map, map, matches'_add]; rw [map_add]
-  | R * S => by simp only [matches'_map, map, matches'_mul]; rw [map_mul]
+  -- Adaptation note: around nightly-2024-02-25, we need to write `comp x y` in the pattern here,
+  -- instead of `x * y` (and the `erw` was just `rw`).
+  | comp R S => by simp only [matches'_map, map, matches'_mul]; erw [map_mul]
   | star R => by
     simp_rw [map, matches', matches'_map]
     rw [Language.kstar_eq_iSup_pow, Language.kstar_eq_iSup_pow]
style: homogenise porting notes (#11145)

Homogenises porting notes via capitalisation and addition of whitespace.

It makes the following changes:

  • converts "--porting note" into "-- Porting note";
  • converts "porting note" into "Porting note".
Diff
@@ -18,7 +18,7 @@ computer science such as the POSIX standard.
 
 * Show that this regular expressions and DFA/NFA's are equivalent. -/
 
--- porting note: this has been commented out
+-- Porting note: this has been commented out
 -- * `attribute [pattern] has_mul.mul` has been added into this file, it could be moved.
 
 
@@ -50,7 +50,7 @@ inductive RegularExpression (α : Type u) : Type u
 #align regular_expression RegularExpression
 
 
--- porting note: `simpNF` gets grumpy about how the `foo_def`s below can simplify these..
+-- Porting note: `simpNF` gets grumpy about how the `foo_def`s below can simplify these..
 attribute [nolint simpNF] RegularExpression.zero.sizeOf_spec
 attribute [nolint simpNF] RegularExpression.epsilon.sizeOf_spec
 attribute [nolint simpNF] RegularExpression.plus.sizeOf_spec
@@ -80,7 +80,7 @@ instance : Zero (RegularExpression α) :=
 instance : Pow (RegularExpression α) ℕ :=
   ⟨fun n r => npowRec r n⟩
 
--- porting note: declaration in an imported module
+-- Porting note: declaration in an imported module
 --attribute [match_pattern] Mul.mul
 
 @[simp]
@@ -103,9 +103,9 @@ theorem comp_def (P Q : RegularExpression α) : comp P Q = P * Q :=
   rfl
 #align regular_expression.comp_def RegularExpression.comp_def
 
--- porting note: `matches` is reserved, moved to `matches'`
+-- Porting note: `matches` is reserved, moved to `matches'`
 /-- `matches' P` provides a language which contains all strings that `P` matches -/
--- porting note: was '@[simp] but removed based on
+-- Porting note: was '@[simp] but removed based on
 -- https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/simpNF.20issues.20in.20Computability.2ERegularExpressions.20!4.232306/near/328355362
 def matches' : RegularExpression α → Language α
   | 0 => 0
@@ -418,7 +418,7 @@ theorem matches'_map (f : α → β) :
   | char a => by
     rw [eq_comm]
     exact image_singleton
-  -- porting note: the following close with last `rw` but not with `simp`?
+  -- Porting note: the following close with last `rw` but not with `simp`?
   | R + S => by simp only [matches'_map, map, matches'_add]; rw [map_add]
   | R * S => by simp only [matches'_map, map, matches'_mul]; rw [map_mul]
   | star R => by
chore: tidy various files (#10007)
Diff
@@ -354,8 +354,7 @@ theorem rmatch_iff_matches' (P : RegularExpression α) (x : List α) :
     rw [zero_def, zero_rmatch]
     tauto
   | epsilon =>
-    rw [one_def, one_rmatch_iff]
-    rfl
+    rw [one_def, one_rmatch_iff, matches'_epsilon, Language.mem_one]
   | char =>
     rw [char_rmatch_iff]
     rfl
chore: move to v4.6.0-rc1, merging adaptations from bump/v4.6.0 (#10176)

Co-authored-by: Scott Morrison <scott.morrison@gmail.com> Co-authored-by: Eric Wieser <wieser.eric@gmail.com> Co-authored-by: Joachim Breitner <mail@joachim-breitner.de>

Diff
@@ -343,7 +343,7 @@ theorem star_rmatch_iff (P : RegularExpression α) :
             refine' ⟨U, rfl, fun t h => helem t _⟩
             right
             assumption
-  termination_by star_rmatch_iff P t => (P,t.length)
+  termination_by t => (P,t.length)
 #align regular_expression.star_rmatch_iff RegularExpression.star_rmatch_iff
 
 @[simp]
style: use cases x with | ... instead of cases x; case => ... (#9321)

This converts usages of the pattern

cases h
case inl h' => ...
case inr h' => ...

which derive from mathported code, to the "structured cases" syntax:

cases h with
| inl h' => ...
| inr h' => ...

The case where the subgoals are handled with · instead of case is more contentious (and much more numerous) so I left those alone. This pattern also appears with cases', induction, induction', and rcases. Furthermore, there is a similar transformation for by_cases:

by_cases h : cond
case pos => ...
case neg => ...

is replaced by:

if h : cond then
  ...
else
  ...

Co-authored-by: Mario Carneiro <di.gama@gmail.com>

Diff
@@ -315,11 +315,11 @@ theorem star_rmatch_iff (P : RegularExpression α) :
         constructor
         · simp [hs, hsum]
         · intro t' ht'
-          cases ht'
-          case head ht' =>
+          cases ht' with
+          | head ht' =>
             simp only [ne_eq, not_false_iff, true_and, rmatch]
             exact ht
-          case tail ht' => exact helem t' ht'
+          | tail _ ht' => exact helem t' ht'
     · rintro ⟨S, hsum, helem⟩
       cases' x with a x
       · rfl
@@ -349,23 +349,23 @@ theorem star_rmatch_iff (P : RegularExpression α) :
 @[simp]
 theorem rmatch_iff_matches' (P : RegularExpression α) (x : List α) :
     P.rmatch x ↔ x ∈ P.matches' := by
-  induction P generalizing x
-  case zero =>
+  induction P generalizing x with
+  | zero =>
     rw [zero_def, zero_rmatch]
     tauto
-  case epsilon =>
+  | epsilon =>
     rw [one_def, one_rmatch_iff]
     rfl
-  case char =>
+  | char =>
     rw [char_rmatch_iff]
     rfl
-  case plus _ _ ih₁ ih₂ =>
+  | plus _ _ ih₁ ih₂ =>
     rw [plus_def, add_rmatch_iff, ih₁, ih₂]
     rfl
-  case comp P Q ih₁ ih₂ =>
+  | comp P Q ih₁ ih₂ =>
     simp only [comp_def, mul_rmatch_iff, matches'_mul, Language.mem_mul, *]
     tauto
-  case star _ ih =>
+  | star _ ih =>
     simp only [star_rmatch_iff, matches'_star, ih, Language.mem_kstar_iff_exists_nonempty, and_comm]
 #align regular_expression.rmatch_iff_matches RegularExpression.rmatch_iff_matches'
 
chore(Computability/RegularExpressions): golf (#9218)

Golf a proof. Also add Language.mem_kstar_iff_exists_nonempty.

Diff
@@ -347,52 +347,26 @@ theorem star_rmatch_iff (P : RegularExpression α) :
 #align regular_expression.star_rmatch_iff RegularExpression.star_rmatch_iff
 
 @[simp]
-theorem rmatch_iff_matches' (P : RegularExpression α) :
-    ∀ x : List α, P.rmatch x ↔ x ∈ P.matches' := by
-  intro x
+theorem rmatch_iff_matches' (P : RegularExpression α) (x : List α) :
+    P.rmatch x ↔ x ∈ P.matches' := by
   induction P generalizing x
-  all_goals
-    try rw [zero_def]
-    try rw [one_def]
-    try rw [plus_def]
-    try rw [comp_def]
   case zero =>
-    rw [zero_rmatch]
+    rw [zero_def, zero_rmatch]
     tauto
   case epsilon =>
-    rw [one_rmatch_iff]
+    rw [one_def, one_rmatch_iff]
     rfl
   case char =>
     rw [char_rmatch_iff]
     rfl
   case plus _ _ ih₁ ih₂ =>
-    rw [add_rmatch_iff, ih₁, ih₂]
+    rw [plus_def, add_rmatch_iff, ih₁, ih₂]
     rfl
   case comp P Q ih₁ ih₂ =>
-    simp only [mul_rmatch_iff, comp_def, Language.mul_def, exists_and_left, Set.mem_image2,
-      Set.image_prod]
-    constructor
-    · rintro ⟨x, y, hsum, hmatch₁, hmatch₂⟩
-      rw [ih₁] at hmatch₁
-      rw [ih₂] at hmatch₂
-      exact ⟨x, y, hmatch₁, hmatch₂, hsum.symm⟩
-    · rintro ⟨x, y, hmatch₁, hmatch₂, hsum⟩
-      rw [← ih₁] at hmatch₁
-      rw [← ih₂] at hmatch₂
-      exact ⟨x, y, hsum.symm, hmatch₁, hmatch₂⟩
+    simp only [comp_def, mul_rmatch_iff, matches'_mul, Language.mem_mul, *]
+    tauto
   case star _ ih =>
-    rw [star_rmatch_iff]
-    simp only [ne_eq, matches', Language.kstar_def_nonempty, mem_setOf_eq]
-    constructor
-    all_goals
-      rintro ⟨S, hx, hS⟩
-      refine' ⟨S, hx, _⟩
-      intro y
-      specialize hS y
-    · rw [← ih y]
-      tauto
-    · rw [ih y]
-      tauto
+    simp only [star_rmatch_iff, matches'_star, ih, Language.mem_kstar_iff_exists_nonempty, and_comm]
 #align regular_expression.rmatch_iff_matches RegularExpression.rmatch_iff_matches'
 
 instance (P : RegularExpression α) : DecidablePred (· ∈ P.matches') := fun _ ↦
chore: Replace (· op ·) a by (a op ·) (#8843)

I used the regex \(\(· (.) ·\) (.)\), replacing with ($2 $1 ·).

Diff
@@ -413,7 +413,7 @@ def map (f : α → β) : RegularExpression α → RegularExpression β
 protected theorem map_pow (f : α → β) (P : RegularExpression α) :
     ∀ n : ℕ, map f (P ^ n) = map f P ^ n
   | 0 => by dsimp; rfl
-  | n + 1 => (congr_arg ((· * ·) (map f P)) (RegularExpression.map_pow f P n) : _)
+  | n + 1 => (congr_arg (map f P * ·) (RegularExpression.map_pow f P n) : _)
 #align regular_expression.map_pow RegularExpression.map_pow
 
 @[simp]
chore: fix the names of some Bool lemmas (#7841)
Diff
@@ -238,7 +238,7 @@ theorem char_rmatch_iff (a : α) (x : List α) : rmatch (char a) x ↔ x = [a] :
 theorem add_rmatch_iff (P Q : RegularExpression α) (x : List α) :
     (P + Q).rmatch x ↔ P.rmatch x ∨ Q.rmatch x := by
   induction' x with _ _ ih generalizing P Q
-  · simp only [rmatch, matchEpsilon, Bool.or_coe_iff]
+  · simp only [rmatch, matchEpsilon, Bool.coe_or_iff]
   · repeat' rw [rmatch]
     rw [deriv_add]
     exact ih _ _
@@ -252,7 +252,7 @@ theorem mul_rmatch_iff (P Q : RegularExpression α) (x : List α) :
     · intro h
       refine' ⟨[], [], rfl, _⟩
       rw [rmatch, rmatch]
-      rwa [Bool.and_coe_iff] at h
+      rwa [Bool.coe_and_iff] at h
     · rintro ⟨t, u, h₁, h₂⟩
       cases' List.append_eq_nil.1 h₁.symm with ht hu
       subst ht
chore: remove unused simps (#6632)

Co-authored-by: Eric Wieser <wieser.eric@gmail.com>

Diff
@@ -320,7 +320,7 @@ theorem star_rmatch_iff (P : RegularExpression α) :
             simp only [ne_eq, not_false_iff, true_and, rmatch]
             exact ht
           case tail ht' => exact helem t' ht'
-    · rintro ⟨S, hsum, helem⟩; dsimp
+    · rintro ⟨S, hsum, helem⟩
       cases' x with a x
       · rfl
       · rw [rmatch, deriv, mul_rmatch_iff]
chore: banish Type _ and Sort _ (#6499)

We remove all possible occurences of Type _ and Sort _ in favor of Type* and Sort*.

This has nice performance benefits.

Diff
@@ -29,7 +29,7 @@ open Computability
 
 universe u
 
-variable {α β γ : Type _} [dec : DecidableEq α]
+variable {α β γ : Type*} [dec : DecidableEq α]
 
 /-- This is the definition of regular expressions. The names used here is to mirror the definition
 of a Kleene algebra (https://en.wikipedia.org/wiki/Kleene_algebra).
chore: fix some Set defeq abuse, golf (#6114)
  • Use {x | p x} instead of fun x ↦ p x to define a set here and there.
  • Golf some proofs.
  • Replace Con.ker_apply_eq_preimage with Con.ker_apply. The old version used to abuse definitional equality between Set M and M → Prop.
  • Fix Submonoid.mk* lemmas to use ⟨_, _⟩, not ⟨⟨_, _⟩, _⟩.
Diff
@@ -395,11 +395,8 @@ theorem rmatch_iff_matches' (P : RegularExpression α) :
       tauto
 #align regular_expression.rmatch_iff_matches RegularExpression.rmatch_iff_matches'
 
-instance (P : RegularExpression α) : DecidablePred P.matches' := by
-  intro x
-  change Decidable (x ∈ P.matches')
-  rw [← rmatch_iff_matches']
-  exact instDecidableEqBool (rmatch P x) True
+instance (P : RegularExpression α) : DecidablePred (· ∈ P.matches') := fun _ ↦
+  decidable_of_iff _ (rmatch_iff_matches' _ _)
 
 /-- Map the alphabet of a regular expression. -/
 @[simp]
chore: script to replace headers with #align_import statements (#5979)

Open in Gitpod

Co-authored-by: Eric Wieser <wieser.eric@gmail.com> Co-authored-by: Scott Morrison <scott.morrison@gmail.com>

Diff
@@ -2,14 +2,11 @@
 Copyright (c) 2020 Fox Thomson. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Fox Thomson
-
-! This file was ported from Lean 3 source module computability.regular_expressions
-! leanprover-community/mathlib commit 369525b73f229ccd76a6ec0e0e0bf2be57599768
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
 -/
 import Mathlib.Computability.Language
 
+#align_import computability.regular_expressions from "leanprover-community/mathlib"@"369525b73f229ccd76a6ec0e0e0bf2be57599768"
+
 /-!
 # Regular Expressions
 
chore: remove occurrences of semicolon after space (#5713)

This is the second half of the changes originally in #5699, removing all occurrences of ; after a space and implementing a linter rule to enforce it.

In most cases this 2-character substring has a space after it, so the following command was run first:

find . -type f -name "*.lean" -exec sed -i -E 's/ ; /; /g' {} \;

The remaining cases were few enough in number that they were done manually.

Diff
@@ -323,7 +323,7 @@ theorem star_rmatch_iff (P : RegularExpression α) :
             simp only [ne_eq, not_false_iff, true_and, rmatch]
             exact ht
           case tail ht' => exact helem t' ht'
-    · rintro ⟨S, hsum, helem⟩ ; dsimp
+    · rintro ⟨S, hsum, helem⟩; dsimp
       cases' x with a x
       · rfl
       · rw [rmatch, deriv, mul_rmatch_iff]
chore: Rename to sSup/iSup (#3938)

As discussed on Zulip

Renames

  • supₛsSup
  • infₛsInf
  • supᵢiSup
  • infᵢiInf
  • bsupₛbsSup
  • binfₛbsInf
  • bsupᵢbiSup
  • binfᵢbiInf
  • csupₛcsSup
  • cinfₛcsInf
  • csupᵢciSup
  • cinfᵢciInf
  • unionₛsUnion
  • interₛsInter
  • unionᵢiUnion
  • interᵢiInter
  • bunionₛbsUnion
  • binterₛbsInter
  • bunionᵢbiUnion
  • binterᵢbiInter

Co-authored-by: Parcly Taxel <reddeloostw@gmail.com>

Diff
@@ -456,9 +456,9 @@ theorem matches'_map (f : α → β) :
   | R * S => by simp only [matches'_map, map, matches'_mul]; rw [map_mul]
   | star R => by
     simp_rw [map, matches', matches'_map]
-    rw [Language.kstar_eq_supᵢ_pow, Language.kstar_eq_supᵢ_pow]
+    rw [Language.kstar_eq_iSup_pow, Language.kstar_eq_iSup_pow]
     simp_rw [← map_pow]
-    exact image_unionᵢ.symm
+    exact image_iUnion.symm
 #align regular_expression.matches_map RegularExpression.matches'_map
 
 end RegularExpression
chore: bye-bye, solo bys! (#3825)

This PR puts, with one exception, every single remaining by that lies all by itself on its own line to the previous line, thus matching the current behaviour of start-port.sh. The exception is when the by begins the second or later argument to a tuple or anonymous constructor; see https://github.com/leanprover-community/mathlib4/pull/3825#discussion_r1186702599.

Essentially this is s/\n *by$/ by/g, but with manual editing to satisfy the linter's max-100-char-line requirement. The Python style linter is also modified to catch these "isolated bys".

Diff
@@ -338,8 +338,7 @@ theorem star_rmatch_iff (P : RegularExpression α) :
             rw [rmatch] at helem
             convert helem.2
             exact hsum.1
-          · have hwf : U.join.length < (List.cons a x).length :=
-              by
+          · have hwf : U.join.length < (List.cons a x).length := by
               rw [hsum.1, hsum.2]
               simp only [List.length_append, List.length_join, List.length]
               apply A
@@ -351,8 +350,8 @@ theorem star_rmatch_iff (P : RegularExpression α) :
 #align regular_expression.star_rmatch_iff RegularExpression.star_rmatch_iff
 
 @[simp]
-theorem rmatch_iff_matches' (P : RegularExpression α) : ∀ x : List α, P.rmatch x ↔ x ∈ P.matches' :=
-by
+theorem rmatch_iff_matches' (P : RegularExpression α) :
+    ∀ x : List α, P.rmatch x ↔ x ∈ P.matches' := by
   intro x
   induction P generalizing x
   all_goals
chore: tidy various files (#3408)
Diff
@@ -226,16 +226,16 @@ theorem one_rmatch_iff (x : List α) : rmatch 1 x ↔ x = [] := by
 
 theorem char_rmatch_iff (a : α) (x : List α) : rmatch (char a) x ↔ x = [a] := by
   cases' x with _ x
-  . exact of_decide_eq_true rfl
+  · exact of_decide_eq_true rfl
   cases' x with head tail
-  . rw [rmatch, deriv]
+  · rw [rmatch, deriv]
     split_ifs
-    . tauto
-    . simp [List.singleton_inj]; tauto
-  . rw [rmatch, rmatch, deriv]
+    · tauto
+    · simp [List.singleton_inj]; tauto
+  · rw [rmatch, rmatch, deriv]
     split_ifs with h
-    . simp only [deriv_one, zero_rmatch, cons.injEq, and_false]
-    . simp only [deriv_zero, zero_rmatch, cons.injEq, and_false]
+    · simp only [deriv_one, zero_rmatch, cons.injEq, and_false]
+    · simp only [deriv_zero, zero_rmatch, cons.injEq, and_false]
 #align regular_expression.char_rmatch_iff RegularExpression.char_rmatch_iff
 
 theorem add_rmatch_iff (P Q : RegularExpression α) (x : List α) :
feat Port/Computability.RegularExpressions (#2306)

port of computability.regular_expressions

The previous file defined attribute [match_pattern] Mul.mul but this is not allowed in Lean 4

Dependencies 2 + 140

141 files ported (98.6%)
67539 lines ported (99.8%)
Show graph

The unported dependencies are