fact
stringlengths
6
3.84k
type
stringclasses
11 values
library
stringclasses
32 values
imports
listlengths
1
14
filename
stringlengths
20
95
symbolic_name
stringlengths
1
90
docstring
stringlengths
7
20k
oneOneEquiv_refl {α} [Primcodable α] (p : α → Prop) : OneOneEquiv p p := ⟨oneOneReducible_refl _, oneOneReducible_refl _⟩ @[symm]
theorem
Computability
[ "Mathlib.Computability.Halting" ]
Mathlib/Computability/Reduce.lean
oneOneEquiv_refl
null
OneOneEquiv.symm {α β} [Primcodable α] [Primcodable β] {p : α → Prop} {q : β → Prop} : OneOneEquiv p q → OneOneEquiv q p := And.symm @[trans]
theorem
Computability
[ "Mathlib.Computability.Halting" ]
Mathlib/Computability/Reduce.lean
OneOneEquiv.symm
null
OneOneEquiv.trans {α β γ} [Primcodable α] [Primcodable β] [Primcodable γ] {p : α → Prop} {q : β → Prop} {r : γ → Prop} : OneOneEquiv p q → OneOneEquiv q r → OneOneEquiv p r | ⟨pq, qp⟩, ⟨qr, rq⟩ => ⟨pq.trans qr, rq.trans qp⟩
theorem
Computability
[ "Mathlib.Computability.Halting" ]
Mathlib/Computability/Reduce.lean
OneOneEquiv.trans
null
equivalence_of_oneOneEquiv {α} [Primcodable α] : Equivalence (@OneOneEquiv α α _ _) := ⟨oneOneEquiv_refl, fun {_ _} => OneOneEquiv.symm, fun {_ _ _} => OneOneEquiv.trans⟩
theorem
Computability
[ "Mathlib.Computability.Halting" ]
Mathlib/Computability/Reduce.lean
equivalence_of_oneOneEquiv
null
OneOneEquiv.to_many_one {α β} [Primcodable α] [Primcodable β] {p : α → Prop} {q : β → Prop} : OneOneEquiv p q → ManyOneEquiv p q | ⟨pq, qp⟩ => ⟨pq.to_many_one, qp.to_many_one⟩
theorem
Computability
[ "Mathlib.Computability.Halting" ]
Mathlib/Computability/Reduce.lean
OneOneEquiv.to_many_one
null
toNat (p : Set α) : Set ℕ := { n | p ((Encodable.decode (α := α) n).getD default) } @[simp]
def
Computability
[ "Mathlib.Computability.Halting" ]
Mathlib/Computability/Reduce.lean
toNat
a computable bijection -/ nonrec def Equiv.Computable {α β} [Primcodable α] [Primcodable β] (e : α ≃ β) := Computable e ∧ Computable e.symm theorem Equiv.Computable.symm {α β} [Primcodable α] [Primcodable β] {e : α ≃ β} : e.Computable → e.symm.Computable := And.symm theorem Equiv.Computable.trans {α β γ} [Primcodable α] [Primcodable β] [Primcodable γ] {e₁ : α ≃ β} {e₂ : β ≃ γ} : e₁.Computable → e₂.Computable → (e₁.trans e₂).Computable | ⟨l₁, r₁⟩, ⟨l₂, r₂⟩ => ⟨l₂.comp l₁, r₁.comp r₂⟩ theorem Computable.eqv (α) [Denumerable α] : (Denumerable.eqv α).Computable := ⟨Computable.encode, Computable.ofNat _⟩ theorem Computable.equiv₂ (α β) [Denumerable α] [Denumerable β] : (Denumerable.equiv₂ α β).Computable := (Computable.eqv _).trans (Computable.eqv _).symm theorem OneOneEquiv.of_equiv {α β} [Primcodable α] [Primcodable β] {e : α ≃ β} (h : e.Computable) {p} : OneOneEquiv (p ∘ e) p := ⟨OneOneReducible.of_equiv _ h.1, OneOneReducible.of_equiv_symm _ h.2⟩ theorem ManyOneEquiv.of_equiv {α β} [Primcodable α] [Primcodable β] {e : α ≃ β} (h : e.Computable) {p} : ManyOneEquiv (p ∘ e) p := (OneOneEquiv.of_equiv h).to_many_one theorem ManyOneEquiv.le_congr_left {α β γ} [Primcodable α] [Primcodable β] [Primcodable γ] {p : α → Prop} {q : β → Prop} {r : γ → Prop} (h : ManyOneEquiv p q) : p ≤₀ r ↔ q ≤₀ r := ⟨h.2.trans, h.1.trans⟩ theorem ManyOneEquiv.le_congr_right {α β γ} [Primcodable α] [Primcodable β] [Primcodable γ] {p : α → Prop} {q : β → Prop} {r : γ → Prop} (h : ManyOneEquiv q r) : p ≤₀ q ↔ p ≤₀ r := ⟨fun h' => h'.trans h.1, fun h' => h'.trans h.2⟩ theorem OneOneEquiv.le_congr_left {α β γ} [Primcodable α] [Primcodable β] [Primcodable γ] {p : α → Prop} {q : β → Prop} {r : γ → Prop} (h : OneOneEquiv p q) : p ≤₁ r ↔ q ≤₁ r := ⟨h.2.trans, h.1.trans⟩ theorem OneOneEquiv.le_congr_right {α β γ} [Primcodable α] [Primcodable β] [Primcodable γ] {p : α → Prop} {q : β → Prop} {r : γ → Prop} (h : OneOneEquiv q r) : p ≤₁ q ↔ p ≤₁ r := ⟨fun h' => h'.trans h.1, fun h' => h'.trans h.2⟩ theorem ManyOneEquiv.congr_left {α β γ} [Primcodable α] [Primcodable β] [Primcodable γ] {p : α → Prop} {q : β → Prop} {r : γ → Prop} (h : ManyOneEquiv p q) : ManyOneEquiv p r ↔ ManyOneEquiv q r := and_congr h.le_congr_left h.le_congr_right theorem ManyOneEquiv.congr_right {α β γ} [Primcodable α] [Primcodable β] [Primcodable γ] {p : α → Prop} {q : β → Prop} {r : γ → Prop} (h : ManyOneEquiv q r) : ManyOneEquiv p q ↔ ManyOneEquiv p r := and_congr h.le_congr_right h.le_congr_left theorem OneOneEquiv.congr_left {α β γ} [Primcodable α] [Primcodable β] [Primcodable γ] {p : α → Prop} {q : β → Prop} {r : γ → Prop} (h : OneOneEquiv p q) : OneOneEquiv p r ↔ OneOneEquiv q r := and_congr h.le_congr_left h.le_congr_right theorem OneOneEquiv.congr_right {α β γ} [Primcodable α] [Primcodable β] [Primcodable γ] {p : α → Prop} {q : β → Prop} {r : γ → Prop} (h : OneOneEquiv q r) : OneOneEquiv p q ↔ OneOneEquiv p r := and_congr h.le_congr_right h.le_congr_left @[simp] theorem ULower.down_computable {α} [Primcodable α] : (ULower.equiv α).Computable := ⟨Primrec.ulower_down.to_comp, Primrec.ulower_up.to_comp⟩ theorem manyOneEquiv_up {α} [Primcodable α] {p : α → Prop} : ManyOneEquiv (p ∘ ULower.up) p := ManyOneEquiv.of_equiv ULower.down_computable.symm local infixl:1001 " ⊕' " => Sum.elim open Nat.Primrec theorem OneOneReducible.disjoin_left {α β} [Primcodable α] [Primcodable β] {p : α → Prop} {q : β → Prop} : p ≤₁ p ⊕' q := ⟨Sum.inl, Computable.sumInl, fun _ _ => Sum.inl.inj_iff.1, fun _ => Iff.rfl⟩ theorem OneOneReducible.disjoin_right {α β} [Primcodable α] [Primcodable β] {p : α → Prop} {q : β → Prop} : q ≤₁ p ⊕' q := ⟨Sum.inr, Computable.sumInr, fun _ _ => Sum.inr.inj_iff.1, fun _ => Iff.rfl⟩ theorem disjoin_manyOneReducible {α β γ} [Primcodable α] [Primcodable β] [Primcodable γ] {p : α → Prop} {q : β → Prop} {r : γ → Prop} : p ≤₀ r → q ≤₀ r → (p ⊕' q) ≤₀ r | ⟨f, c₁, h₁⟩, ⟨g, c₂, h₂⟩ => ⟨Sum.elim f g, Computable.id.sumCasesOn (c₁.comp Computable.snd).to₂ (c₂.comp Computable.snd).to₂, fun x => by cases x <;> [apply h₁; apply h₂]⟩ theorem disjoin_le {α β γ} [Primcodable α] [Primcodable β] [Primcodable γ] {p : α → Prop} {q : β → Prop} {r : γ → Prop} : (p ⊕' q) ≤₀ r ↔ p ≤₀ r ∧ q ≤₀ r := ⟨fun h => ⟨OneOneReducible.disjoin_left.to_many_one.trans h, OneOneReducible.disjoin_right.to_many_one.trans h⟩, fun ⟨h₁, h₂⟩ => disjoin_manyOneReducible h₁ h₂⟩ variable {α : Type u} [Primcodable α] [Inhabited α] {β : Type v} [Primcodable β] [Inhabited β] /-- Computable and injective mapping of predicates to sets of natural numbers.
toNat_manyOneReducible {p : Set α} : toNat p ≤₀ p := ⟨fun n => (Encodable.decode (α := α) n).getD default, Computable.option_getD Computable.decode (Computable.const _), fun _ => Iff.rfl⟩ @[simp]
theorem
Computability
[ "Mathlib.Computability.Halting" ]
Mathlib/Computability/Reduce.lean
toNat_manyOneReducible
null
manyOneReducible_toNat {p : Set α} : p ≤₀ toNat p := ⟨Encodable.encode, Computable.encode, by simp [toNat, setOf]⟩ @[simp]
theorem
Computability
[ "Mathlib.Computability.Halting" ]
Mathlib/Computability/Reduce.lean
manyOneReducible_toNat
null
manyOneReducible_toNat_toNat {p : Set α} {q : Set β} : toNat p ≤₀ toNat q ↔ p ≤₀ q := ⟨fun h => manyOneReducible_toNat.trans (h.trans toNat_manyOneReducible), fun h => toNat_manyOneReducible.trans (h.trans manyOneReducible_toNat)⟩ @[simp]
theorem
Computability
[ "Mathlib.Computability.Halting" ]
Mathlib/Computability/Reduce.lean
manyOneReducible_toNat_toNat
null
toNat_manyOneEquiv {p : Set α} : ManyOneEquiv (toNat p) p := by simp [ManyOneEquiv] @[simp]
theorem
Computability
[ "Mathlib.Computability.Halting" ]
Mathlib/Computability/Reduce.lean
toNat_manyOneEquiv
null
manyOneEquiv_toNat (p : Set α) (q : Set β) : ManyOneEquiv (toNat p) (toNat q) ↔ ManyOneEquiv p q := by simp [ManyOneEquiv]
theorem
Computability
[ "Mathlib.Computability.Halting" ]
Mathlib/Computability/Reduce.lean
manyOneEquiv_toNat
null
ManyOneDegree : Type := Quotient (⟨ManyOneEquiv, equivalence_of_manyOneEquiv⟩ : Setoid (Set ℕ))
def
Computability
[ "Mathlib.Computability.Halting" ]
Mathlib/Computability/Reduce.lean
ManyOneDegree
A many-one degree is an equivalence class of sets up to many-one equivalence.
of (p : α → Prop) : ManyOneDegree := Quotient.mk'' (toNat p) @[elab_as_elim]
def
Computability
[ "Mathlib.Computability.Halting" ]
Mathlib/Computability/Reduce.lean
of
The many-one degree of a set on a primcodable type.
protected ind_on {C : ManyOneDegree → Prop} (d : ManyOneDegree) (h : ∀ p : Set ℕ, C (of p)) : C d := Quotient.inductionOn' d h
theorem
Computability
[ "Mathlib.Computability.Halting" ]
Mathlib/Computability/Reduce.lean
ind_on
null
protected liftOn {φ} (d : ManyOneDegree) (f : Set ℕ → φ) (h : ∀ p q, ManyOneEquiv p q → f p = f q) : φ := Quotient.liftOn' d f h @[simp]
abbrev
Computability
[ "Mathlib.Computability.Halting" ]
Mathlib/Computability/Reduce.lean
liftOn
Lifts a function on sets of natural numbers to many-one degrees.
protected liftOn_eq {φ} (p : Set ℕ) (f : Set ℕ → φ) (h : ∀ p q, ManyOneEquiv p q → f p = f q) : (of p).liftOn f h = f p := rfl
theorem
Computability
[ "Mathlib.Computability.Halting" ]
Mathlib/Computability/Reduce.lean
liftOn_eq
null
@[reducible, simp] protected liftOn₂ {φ} (d₁ d₂ : ManyOneDegree) (f : Set ℕ → Set ℕ → φ) (h : ∀ p₁ p₂ q₁ q₂, ManyOneEquiv p₁ p₂ → ManyOneEquiv q₁ q₂ → f p₁ q₁ = f p₂ q₂) : φ := d₁.liftOn (fun p => d₂.liftOn (f p) fun _ _ hq => h _ _ _ _ (by rfl) hq) (by intro p₁ p₂ hp induction d₂ using ManyOneDegree.ind_on apply h · assumption · rfl) @[simp]
def
Computability
[ "Mathlib.Computability.Halting" ]
Mathlib/Computability/Reduce.lean
liftOn₂
Lifts a binary function on sets of natural numbers to many-one degrees.
protected liftOn₂_eq {φ} (p q : Set ℕ) (f : Set ℕ → Set ℕ → φ) (h : ∀ p₁ p₂ q₁ q₂, ManyOneEquiv p₁ p₂ → ManyOneEquiv q₁ q₂ → f p₁ q₁ = f p₂ q₂) : (of p).liftOn₂ (of q) f h = f p q := rfl @[simp]
theorem
Computability
[ "Mathlib.Computability.Halting" ]
Mathlib/Computability/Reduce.lean
liftOn₂_eq
null
of_eq_of {p : α → Prop} {q : β → Prop} : of p = of q ↔ ManyOneEquiv p q := by rw [of, of, Quotient.eq''] simp
theorem
Computability
[ "Mathlib.Computability.Halting" ]
Mathlib/Computability/Reduce.lean
of_eq_of
null
instInhabited : Inhabited ManyOneDegree := ⟨of (∅ : Set ℕ)⟩
instance
Computability
[ "Mathlib.Computability.Halting" ]
Mathlib/Computability/Reduce.lean
instInhabited
null
instLE : LE ManyOneDegree := ⟨fun d₁ d₂ => ManyOneDegree.liftOn₂ d₁ d₂ (· ≤₀ ·) fun _p₁ _p₂ _q₁ _q₂ hp hq => propext (hp.le_congr_left.trans hq.le_congr_right)⟩ @[simp]
instance
Computability
[ "Mathlib.Computability.Halting" ]
Mathlib/Computability/Reduce.lean
instLE
For many-one degrees `d₁` and `d₂`, `d₁ ≤ d₂` if the sets in `d₁` are many-one reducible to the sets in `d₂`.
of_le_of {p : α → Prop} {q : β → Prop} : of p ≤ of q ↔ p ≤₀ q := manyOneReducible_toNat_toNat
theorem
Computability
[ "Mathlib.Computability.Halting" ]
Mathlib/Computability/Reduce.lean
of_le_of
null
private le_refl (d : ManyOneDegree) : d ≤ d := by induction d using ManyOneDegree.ind_on; simp; rfl
theorem
Computability
[ "Mathlib.Computability.Halting" ]
Mathlib/Computability/Reduce.lean
le_refl
null
private le_antisymm {d₁ d₂ : ManyOneDegree} : d₁ ≤ d₂ → d₂ ≤ d₁ → d₁ = d₂ := by induction d₁ using ManyOneDegree.ind_on induction d₂ using ManyOneDegree.ind_on intro hp hq simp_all only [ManyOneEquiv, of_le_of, of_eq_of, true_and]
theorem
Computability
[ "Mathlib.Computability.Halting" ]
Mathlib/Computability/Reduce.lean
le_antisymm
null
private le_trans {d₁ d₂ d₃ : ManyOneDegree} : d₁ ≤ d₂ → d₂ ≤ d₃ → d₁ ≤ d₃ := by induction d₁ using ManyOneDegree.ind_on induction d₂ using ManyOneDegree.ind_on induction d₃ using ManyOneDegree.ind_on apply ManyOneReducible.trans
theorem
Computability
[ "Mathlib.Computability.Halting" ]
Mathlib/Computability/Reduce.lean
le_trans
null
instPartialOrder : PartialOrder ManyOneDegree where le := (· ≤ ·) le_refl := le_refl le_trans _ _ _ := le_trans le_antisymm _ _ := le_antisymm
instance
Computability
[ "Mathlib.Computability.Halting" ]
Mathlib/Computability/Reduce.lean
instPartialOrder
null
instAdd : Add ManyOneDegree := ⟨fun d₁ d₂ => d₁.liftOn₂ d₂ (fun a b => of (a ⊕' b)) (by rintro a b c d ⟨hl₁, hr₁⟩ ⟨hl₂, hr₂⟩ rw [of_eq_of] exact ⟨disjoin_manyOneReducible (hl₁.trans OneOneReducible.disjoin_left.to_many_one) (hl₂.trans OneOneReducible.disjoin_right.to_many_one), disjoin_manyOneReducible (hr₁.trans OneOneReducible.disjoin_left.to_many_one) (hr₂.trans OneOneReducible.disjoin_right.to_many_one)⟩)⟩ @[simp]
instance
Computability
[ "Mathlib.Computability.Halting" ]
Mathlib/Computability/Reduce.lean
instAdd
The join of two degrees, induced by the disjoint union of two underlying sets.
add_of (p : Set α) (q : Set β) : of (p ⊕' q) = of p + of q := of_eq_of.mpr ⟨disjoin_manyOneReducible (manyOneReducible_toNat.trans OneOneReducible.disjoin_left.to_many_one) (manyOneReducible_toNat.trans OneOneReducible.disjoin_right.to_many_one), disjoin_manyOneReducible (toNat_manyOneReducible.trans OneOneReducible.disjoin_left.to_many_one) (toNat_manyOneReducible.trans OneOneReducible.disjoin_right.to_many_one)⟩ @[simp]
theorem
Computability
[ "Mathlib.Computability.Halting" ]
Mathlib/Computability/Reduce.lean
add_of
null
protected add_le {d₁ d₂ d₃ : ManyOneDegree} : d₁ + d₂ ≤ d₃ ↔ d₁ ≤ d₃ ∧ d₂ ≤ d₃ := by induction d₁ using ManyOneDegree.ind_on induction d₂ using ManyOneDegree.ind_on induction d₃ using ManyOneDegree.ind_on simpa only [← add_of, of_le_of] using disjoin_le @[simp]
theorem
Computability
[ "Mathlib.Computability.Halting" ]
Mathlib/Computability/Reduce.lean
add_le
null
protected le_add_left (d₁ d₂ : ManyOneDegree) : d₁ ≤ d₁ + d₂ := (ManyOneDegree.add_le.1 (le_refl _)).1 @[simp]
theorem
Computability
[ "Mathlib.Computability.Halting" ]
Mathlib/Computability/Reduce.lean
le_add_left
null
protected le_add_right (d₁ d₂ : ManyOneDegree) : d₂ ≤ d₁ + d₂ := (ManyOneDegree.add_le.1 (le_refl _)).2
theorem
Computability
[ "Mathlib.Computability.Halting" ]
Mathlib/Computability/Reduce.lean
le_add_right
null
instSemilatticeSup : SemilatticeSup ManyOneDegree := { ManyOneDegree.instPartialOrder with sup := (· + ·) le_sup_left := ManyOneDegree.le_add_left le_sup_right := ManyOneDegree.le_add_right sup_le := fun _ _ _ h₁ h₂ => ManyOneDegree.add_le.2 ⟨h₁, h₂⟩ }
instance
Computability
[ "Mathlib.Computability.Halting" ]
Mathlib/Computability/Reduce.lean
instSemilatticeSup
null
RegularExpression (α : Type u) : Type u | zero : RegularExpression α | epsilon : RegularExpression α | char : α → RegularExpression α | plus : RegularExpression α → RegularExpression α → RegularExpression α | comp : RegularExpression α → RegularExpression α → RegularExpression α | star : RegularExpression α → RegularExpression α
inductive
Computability
[ "Mathlib.Computability.Language", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Computability/RegularExpressions.lean
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 * `1` (`epsilon`) matches only the empty string * `char a` matches only the string 'a' * `star P` matches any finite concatenation of strings which match `P` * `P + Q` (`plus P Q`) matches anything which match `P` or `Q` * `P * Q` (`comp P Q`) matches `x ++ y` if `x` matches `P` and `y` matches `Q`
@[simp] zero_def : (zero : RegularExpression α) = 0 := rfl @[simp]
theorem
Computability
[ "Mathlib.Computability.Language", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Computability/RegularExpressions.lean
zero_def
null
one_def : (epsilon : RegularExpression α) = 1 := rfl @[simp]
theorem
Computability
[ "Mathlib.Computability.Language", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Computability/RegularExpressions.lean
one_def
null
plus_def (P Q : RegularExpression α) : plus P Q = P + Q := rfl @[simp]
theorem
Computability
[ "Mathlib.Computability.Language", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Computability/RegularExpressions.lean
plus_def
null
comp_def (P Q : RegularExpression α) : comp P Q = P * Q := rfl
theorem
Computability
[ "Mathlib.Computability.Language", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Computability/RegularExpressions.lean
comp_def
null
@[simp] 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'∗
def
Computability
[ "Mathlib.Computability.Language", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Computability/RegularExpressions.lean
matches'
`matches' P` provides a language which contains all strings that `P` matches. Not named `matches` since that is a reserved word.
matches'_zero : (0 : RegularExpression α).matches' = 0 := rfl
theorem
Computability
[ "Mathlib.Computability.Language", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Computability/RegularExpressions.lean
matches'_zero
null
matches'_epsilon : (1 : RegularExpression α).matches' = 1 := rfl
theorem
Computability
[ "Mathlib.Computability.Language", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Computability/RegularExpressions.lean
matches'_epsilon
null
matches'_char (a : α) : (char a).matches' = {[a]} := rfl
theorem
Computability
[ "Mathlib.Computability.Language", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Computability/RegularExpressions.lean
matches'_char
null
matches'_add (P Q : RegularExpression α) : (P + Q).matches' = P.matches' + Q.matches' := rfl
theorem
Computability
[ "Mathlib.Computability.Language", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Computability/RegularExpressions.lean
matches'_add
null
matches'_mul (P Q : RegularExpression α) : (P * Q).matches' = P.matches' * Q.matches' := rfl @[simp]
theorem
Computability
[ "Mathlib.Computability.Language", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Computability/RegularExpressions.lean
matches'_mul
null
matches'_pow (P : RegularExpression α) : ∀ n : ℕ, (P ^ n).matches' = P.matches' ^ n | 0 => matches'_epsilon | n + 1 => (matches'_mul _ _).trans <| Eq.trans (congrFun (congrArg HMul.hMul (matches'_pow P n)) (matches' P)) (pow_succ _ n).symm
theorem
Computability
[ "Mathlib.Computability.Language", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Computability/RegularExpressions.lean
matches'_pow
null
matches'_star (P : RegularExpression α) : P.star.matches' = P.matches'∗ := rfl
theorem
Computability
[ "Mathlib.Computability.Language", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Computability/RegularExpressions.lean
matches'_star
null
matchEpsilon : RegularExpression α → Bool | 0 => false | 1 => true | char _ => false | P + Q => P.matchEpsilon || Q.matchEpsilon | P * Q => P.matchEpsilon && Q.matchEpsilon | star _P => true
def
Computability
[ "Mathlib.Computability.Language", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Computability/RegularExpressions.lean
matchEpsilon
`matchEpsilon P` is true if and only if `P` matches the empty string
deriv : RegularExpression α → α → RegularExpression α | 0, _ => 0 | 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 | star P, a => deriv P a * star P @[simp]
def
Computability
[ "Mathlib.Computability.Language", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Computability/RegularExpressions.lean
deriv
`P.deriv a` matches `x` if `P` matches `a :: x`, the Brzozowski derivative of `P` with respect to `a`
deriv_zero (a : α) : deriv 0 a = 0 := rfl @[simp]
theorem
Computability
[ "Mathlib.Computability.Language", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Computability/RegularExpressions.lean
deriv_zero
null
deriv_one (a : α) : deriv 1 a = 0 := rfl @[simp]
theorem
Computability
[ "Mathlib.Computability.Language", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Computability/RegularExpressions.lean
deriv_one
null
deriv_char_self (a : α) : deriv (char a) a = 1 := if_pos rfl @[simp]
theorem
Computability
[ "Mathlib.Computability.Language", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Computability/RegularExpressions.lean
deriv_char_self
null
deriv_char_of_ne (h : a ≠ b) : deriv (char a) b = 0 := if_neg h @[simp]
theorem
Computability
[ "Mathlib.Computability.Language", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Computability/RegularExpressions.lean
deriv_char_of_ne
null
deriv_add (P Q : RegularExpression α) (a : α) : deriv (P + Q) a = deriv P a + deriv Q a := rfl @[simp]
theorem
Computability
[ "Mathlib.Computability.Language", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Computability/RegularExpressions.lean
deriv_add
null
deriv_star (P : RegularExpression α) (a : α) : deriv P.star a = deriv P a * star P := rfl
theorem
Computability
[ "Mathlib.Computability.Language", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Computability/RegularExpressions.lean
deriv_star
null
rmatch : RegularExpression α → List α → Bool | P, [] => matchEpsilon P | P, a :: as => rmatch (P.deriv a) as @[simp]
def
Computability
[ "Mathlib.Computability.Language", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Computability/RegularExpressions.lean
rmatch
`P.rmatch x` is true if and only if `P` matches `x`. This is a computable definition equivalent to `matches'`.
zero_rmatch (x : List α) : rmatch 0 x = false := by induction x <;> simp [rmatch, matchEpsilon, *]
theorem
Computability
[ "Mathlib.Computability.Language", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Computability/RegularExpressions.lean
zero_rmatch
null
one_rmatch_iff (x : List α) : rmatch 1 x ↔ x = [] := by induction x <;> simp [rmatch, matchEpsilon, *]
theorem
Computability
[ "Mathlib.Computability.Language", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Computability/RegularExpressions.lean
one_rmatch_iff
null
char_rmatch_iff (a : α) (x : List α) : rmatch (char a) x ↔ x = [a] := by rcases x with - | ⟨_, x⟩ · exact of_decide_eq_true rfl · rcases x with - | ⟨head, tail⟩ · rw [rmatch, deriv, List.singleton_inj] split <;> tauto · rw [rmatch, rmatch, deriv, cons.injEq] split · simp_rw [deriv_one, zero_rmatch, reduceCtorEq, and_false] · simp_rw [deriv_zero, zero_rmatch, reduceCtorEq, and_false]
theorem
Computability
[ "Mathlib.Computability.Language", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Computability/RegularExpressions.lean
char_rmatch_iff
null
add_rmatch_iff (P Q : RegularExpression α) (x : List α) : (P + Q).rmatch x ↔ P.rmatch x ∨ Q.rmatch x := by induction x generalizing P Q with | nil => simp only [rmatch, matchEpsilon, Bool.or_eq_true_iff] | cons _ _ ih => rw [rmatch, deriv_add] exact ih _ _
theorem
Computability
[ "Mathlib.Computability.Language", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Computability/RegularExpressions.lean
add_rmatch_iff
null
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 induction x generalizing P Q with | nil => rw [rmatch]; simp only [matchEpsilon] constructor · intro h refine ⟨[], [], rfl, ?_⟩ rw [rmatch, rmatch] rwa [Bool.and_eq_true_iff] at h · rintro ⟨t, u, h₁, h₂⟩ obtain ⟨ht, hu⟩ := List.append_eq_nil_iff.1 h₁.symm subst ht hu repeat rw [rmatch] at h₂ simp [h₂] | cons a x ih => rw [rmatch]; simp only [deriv] split_ifs with hepsilon · rw [add_rmatch_iff, ih] constructor · rintro (⟨t, u, _⟩ | h) · exact ⟨a :: t, u, by tauto⟩ · exact ⟨[], a :: x, rfl, hepsilon, h⟩ · rintro ⟨t, u, h, hP, hQ⟩ rcases t with - | ⟨b, t⟩ · right rw [List.nil_append] at h rw [← h] at hQ exact hQ · left rw [List.cons_append, List.cons_eq_cons] at h refine ⟨t, u, h.2, ?_, hQ⟩ rw [rmatch] at hP convert hP exact h.1 · rw [ih] constructor <;> rintro ⟨t, u, h, hP, hQ⟩ · exact ⟨a :: t, u, by tauto⟩ · rcases t with - | ⟨b, t⟩ · contradiction · rw [List.cons_append, List.cons_eq_cons] at h refine ⟨t, u, h.2, ?_, hQ⟩ rw [rmatch] at hP convert hP exact h.1
theorem
Computability
[ "Mathlib.Computability.Language", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Computability/RegularExpressions.lean
mul_rmatch_iff
null
star_rmatch_iff (P : RegularExpression α) : ∀ x : List α, (star P).rmatch x ↔ ∃ S : List (List α), x = S.flatten ∧ ∀ t ∈ S, t ≠ [] ∧ P.rmatch t := fun x => by have IH := fun t (_h : List.length t < List.length x) => star_rmatch_iff P t clear star_rmatch_iff constructor · rcases x with - | ⟨a, x⟩ · intro _h use []; dsimp; tauto · rw [rmatch, deriv, mul_rmatch_iff] rintro ⟨t, u, hs, ht, hu⟩ have hwf : u.length < (List.cons a x).length := by rw [hs, List.length_cons, List.length_append] omega rw [IH _ hwf] at hu rcases hu with ⟨S', hsum, helem⟩ use (a :: t) :: S' constructor · simp [hs, hsum] · intro t' ht' cases ht' with | head ht' => simp only [ne_eq, not_false_iff, true_and, rmatch, reduceCtorEq] exact ht | tail _ ht' => exact helem t' ht' · rintro ⟨S, hsum, helem⟩ rcases x with - | ⟨a, x⟩ · rfl · rw [rmatch, deriv, mul_rmatch_iff] rcases S with - | ⟨t', U⟩ · exact ⟨[], [], by tauto⟩ · obtain - | ⟨b, t⟩ := t' · simp only [forall_eq_or_imp, List.mem_cons] at helem simp only [not_true, Ne, false_and] at helem simp only [List.flatten, List.cons_append, List.cons_eq_cons] at hsum refine ⟨t, U.flatten, hsum.2, ?_, ?_⟩ · specialize helem (b :: t) (by simp) rw [rmatch] at helem convert helem.2 exact hsum.1 · grind termination_by t => (P, t.length) @[simp]
theorem
Computability
[ "Mathlib.Computability.Language", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Computability/RegularExpressions.lean
star_rmatch_iff
null
rmatch_iff_matches' (P : RegularExpression α) (x : List α) : P.rmatch x ↔ x ∈ P.matches' := by induction P generalizing x with | zero => rw [zero_def, zero_rmatch] tauto | epsilon => rw [one_def, one_rmatch_iff, matches'_epsilon, Language.mem_one] | char => rw [char_rmatch_iff] rfl | plus _ _ ih₁ ih₂ => rw [plus_def, add_rmatch_iff, ih₁, ih₂] rfl | comp P Q ih₁ ih₂ => simp only [comp_def, mul_rmatch_iff, matches'_mul, Language.mem_mul, *] tauto | star _ ih => simp only [star_rmatch_iff, matches'_star, ih, Language.mem_kstar_iff_exists_nonempty, and_comm]
theorem
Computability
[ "Mathlib.Computability.Language", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Computability/RegularExpressions.lean
rmatch_iff_matches'
null
@[simp] map (f : α → β) : RegularExpression α → RegularExpression β | 0 => 0 | 1 => 1 | char a => char (f a) | R + S => map f R + map f S | R * S => map f R * map f S | star R => star (map f R) @[simp]
def
Computability
[ "Mathlib.Computability.Language", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Computability/RegularExpressions.lean
map
Map the alphabet of a regular expression.
protected map_pow (f : α → β) (P : RegularExpression α) : ∀ n : ℕ, map f (P ^ n) = map f P ^ n | 0 => by unfold map; rfl | n + 1 => (congr_arg (· * map f P) (RegularExpression.map_pow f P n) :) @[simp]
theorem
Computability
[ "Mathlib.Computability.Language", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Computability/RegularExpressions.lean
map_pow
null
map_id : ∀ P : RegularExpression α, P.map id = P | 0 => rfl | 1 => rfl | char _ => rfl | R + S => by simp_rw [map, map_id] | R * S => by simp_rw [map, map_id] | star R => by simp_rw [map, map_id] @[simp]
theorem
Computability
[ "Mathlib.Computability.Language", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Computability/RegularExpressions.lean
map_id
null
map_map (g : β → γ) (f : α → β) : ∀ P : RegularExpression α, (P.map f).map g = P.map (g ∘ f) | 0 => rfl | 1 => rfl | char _ => rfl | R + S => by simp only [map, map_map] | R * S => by simp only [map, map_map] | star R => by simp only [map, map_map]
theorem
Computability
[ "Mathlib.Computability.Language", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Computability/RegularExpressions.lean
map_map
null
@[simp] 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 | R + S => by simp only [matches'_map, map, matches'_add, map_add] | R * S => by simp [matches'_map] | star R => by simp [matches'_map]
theorem
Computability
[ "Mathlib.Computability.Language", "Mathlib.Tactic.AdaptationNote" ]
Mathlib/Computability/RegularExpressions.lean
matches'_map
The language of the map is the map of the language.
BlankExtends {Γ} [Inhabited Γ] (l₁ l₂ : List Γ) : Prop := ∃ n, l₂ = l₁ ++ List.replicate n default @[refl]
def
Computability
[ "Mathlib.Data.Vector.Basic", "Mathlib.Logic.Function.Iterate", "Mathlib.Tactic.ApplyFun", "Mathlib.Data.List.GetD" ]
Mathlib/Computability/Tape.lean
BlankExtends
The `BlankExtends` partial order holds of `l₁` and `l₂` if `l₂` is obtained by adding blanks (`default : Γ`) to the end of `l₁`.
BlankExtends.refl {Γ} [Inhabited Γ] (l : List Γ) : BlankExtends l l := ⟨0, by simp⟩ @[trans]
theorem
Computability
[ "Mathlib.Data.Vector.Basic", "Mathlib.Logic.Function.Iterate", "Mathlib.Tactic.ApplyFun", "Mathlib.Data.List.GetD" ]
Mathlib/Computability/Tape.lean
BlankExtends.refl
null
BlankExtends.trans {Γ} [Inhabited Γ] {l₁ l₂ l₃ : List Γ} : BlankExtends l₁ l₂ → BlankExtends l₂ l₃ → BlankExtends l₁ l₃ := by rintro ⟨i, rfl⟩ ⟨j, rfl⟩ exact ⟨i + j, by simp⟩
theorem
Computability
[ "Mathlib.Data.Vector.Basic", "Mathlib.Logic.Function.Iterate", "Mathlib.Tactic.ApplyFun", "Mathlib.Data.List.GetD" ]
Mathlib/Computability/Tape.lean
BlankExtends.trans
null
BlankExtends.below_of_le {Γ} [Inhabited Γ] {l l₁ l₂ : List Γ} : BlankExtends l l₁ → BlankExtends l l₂ → l₁.length ≤ l₂.length → BlankExtends l₁ l₂ := by rintro ⟨i, rfl⟩ ⟨j, rfl⟩ h; use j - i simp only [List.length_append, Nat.add_le_add_iff_left, List.length_replicate] at h simp only [← List.replicate_add, Nat.add_sub_cancel' h, List.append_assoc]
theorem
Computability
[ "Mathlib.Data.Vector.Basic", "Mathlib.Logic.Function.Iterate", "Mathlib.Tactic.ApplyFun", "Mathlib.Data.List.GetD" ]
Mathlib/Computability/Tape.lean
BlankExtends.below_of_le
null
BlankExtends.above {Γ} [Inhabited Γ] {l l₁ l₂ : List Γ} (h₁ : BlankExtends l l₁) (h₂ : BlankExtends l l₂) : { l' // BlankExtends l₁ l' ∧ BlankExtends l₂ l' } := if h : l₁.length ≤ l₂.length then ⟨l₂, h₁.below_of_le h₂ h, BlankExtends.refl _⟩ else ⟨l₁, BlankExtends.refl _, h₂.below_of_le h₁ (le_of_not_ge h)⟩
def
Computability
[ "Mathlib.Data.Vector.Basic", "Mathlib.Logic.Function.Iterate", "Mathlib.Tactic.ApplyFun", "Mathlib.Data.List.GetD" ]
Mathlib/Computability/Tape.lean
BlankExtends.above
Any two extensions by blank `l₁,l₂` of `l` have a common join (which can be taken to be the longer of `l₁` and `l₂`).
BlankExtends.above_of_le {Γ} [Inhabited Γ] {l l₁ l₂ : List Γ} : BlankExtends l₁ l → BlankExtends l₂ l → l₁.length ≤ l₂.length → BlankExtends l₁ l₂ := by rintro ⟨i, rfl⟩ ⟨j, e⟩ h; use i - j refine List.append_cancel_right (e.symm.trans ?_) rw [List.append_assoc, ← List.replicate_add, Nat.sub_add_cancel] apply_fun List.length at e simp only [List.length_append, List.length_replicate] at e rwa [← Nat.add_le_add_iff_left, e, Nat.add_le_add_iff_right]
theorem
Computability
[ "Mathlib.Data.Vector.Basic", "Mathlib.Logic.Function.Iterate", "Mathlib.Tactic.ApplyFun", "Mathlib.Data.List.GetD" ]
Mathlib/Computability/Tape.lean
BlankExtends.above_of_le
null
BlankRel {Γ} [Inhabited Γ] (l₁ l₂ : List Γ) : Prop := BlankExtends l₁ l₂ ∨ BlankExtends l₂ l₁ @[refl]
def
Computability
[ "Mathlib.Data.Vector.Basic", "Mathlib.Logic.Function.Iterate", "Mathlib.Tactic.ApplyFun", "Mathlib.Data.List.GetD" ]
Mathlib/Computability/Tape.lean
BlankRel
`BlankRel` is the symmetric closure of `BlankExtends`, turning it into an equivalence relation. Two lists are related by `BlankRel` if one extends the other by blanks.
BlankRel.refl {Γ} [Inhabited Γ] (l : List Γ) : BlankRel l l := Or.inl (BlankExtends.refl _) @[symm]
theorem
Computability
[ "Mathlib.Data.Vector.Basic", "Mathlib.Logic.Function.Iterate", "Mathlib.Tactic.ApplyFun", "Mathlib.Data.List.GetD" ]
Mathlib/Computability/Tape.lean
BlankRel.refl
null
BlankRel.symm {Γ} [Inhabited Γ] {l₁ l₂ : List Γ} : BlankRel l₁ l₂ → BlankRel l₂ l₁ := Or.symm @[trans]
theorem
Computability
[ "Mathlib.Data.Vector.Basic", "Mathlib.Logic.Function.Iterate", "Mathlib.Tactic.ApplyFun", "Mathlib.Data.List.GetD" ]
Mathlib/Computability/Tape.lean
BlankRel.symm
null
BlankRel.trans {Γ} [Inhabited Γ] {l₁ l₂ l₃ : List Γ} : BlankRel l₁ l₂ → BlankRel l₂ l₃ → BlankRel l₁ l₃ := by rintro (h₁ | h₁) (h₂ | h₂) · exact Or.inl (h₁.trans h₂) · rcases le_total l₁.length l₃.length with h | h · exact Or.inl (h₁.above_of_le h₂ h) · exact Or.inr (h₂.above_of_le h₁ h) · rcases le_total l₁.length l₃.length with h | h · exact Or.inl (h₁.below_of_le h₂ h) · exact Or.inr (h₂.below_of_le h₁ h) · exact Or.inr (h₂.trans h₁)
theorem
Computability
[ "Mathlib.Data.Vector.Basic", "Mathlib.Logic.Function.Iterate", "Mathlib.Tactic.ApplyFun", "Mathlib.Data.List.GetD" ]
Mathlib/Computability/Tape.lean
BlankRel.trans
null
BlankRel.above {Γ} [Inhabited Γ] {l₁ l₂ : List Γ} (h : BlankRel l₁ l₂) : { l // BlankExtends l₁ l ∧ BlankExtends l₂ l } := by refine if hl : l₁.length ≤ l₂.length then ⟨l₂, Or.elim h id fun h' ↦ ?_, BlankExtends.refl _⟩ else ⟨l₁, BlankExtends.refl _, Or.elim h (fun h' ↦ ?_) id⟩ · exact (BlankExtends.refl _).above_of_le h' hl · exact (BlankExtends.refl _).above_of_le h' (le_of_not_ge hl)
def
Computability
[ "Mathlib.Data.Vector.Basic", "Mathlib.Logic.Function.Iterate", "Mathlib.Tactic.ApplyFun", "Mathlib.Data.List.GetD" ]
Mathlib/Computability/Tape.lean
BlankRel.above
Given two `BlankRel` lists, there exists (constructively) a common join.
BlankRel.below {Γ} [Inhabited Γ] {l₁ l₂ : List Γ} (h : BlankRel l₁ l₂) : { l // BlankExtends l l₁ ∧ BlankExtends l l₂ } := by refine if hl : l₁.length ≤ l₂.length then ⟨l₁, BlankExtends.refl _, Or.elim h id fun h' ↦ ?_⟩ else ⟨l₂, Or.elim h (fun h' ↦ ?_) id, BlankExtends.refl _⟩ · exact (BlankExtends.refl _).above_of_le h' hl · exact (BlankExtends.refl _).above_of_le h' (le_of_not_ge hl)
def
Computability
[ "Mathlib.Data.Vector.Basic", "Mathlib.Logic.Function.Iterate", "Mathlib.Tactic.ApplyFun", "Mathlib.Data.List.GetD" ]
Mathlib/Computability/Tape.lean
BlankRel.below
Given two `BlankRel` lists, there exists (constructively) a common meet.
BlankRel.equivalence (Γ) [Inhabited Γ] : Equivalence (@BlankRel Γ _) := ⟨BlankRel.refl, @BlankRel.symm _ _, @BlankRel.trans _ _⟩
theorem
Computability
[ "Mathlib.Data.Vector.Basic", "Mathlib.Logic.Function.Iterate", "Mathlib.Tactic.ApplyFun", "Mathlib.Data.List.GetD" ]
Mathlib/Computability/Tape.lean
BlankRel.equivalence
null
BlankRel.setoid (Γ) [Inhabited Γ] : Setoid (List Γ) := ⟨_, BlankRel.equivalence _⟩
def
Computability
[ "Mathlib.Data.Vector.Basic", "Mathlib.Logic.Function.Iterate", "Mathlib.Tactic.ApplyFun", "Mathlib.Data.List.GetD" ]
Mathlib/Computability/Tape.lean
BlankRel.setoid
Construct a setoid instance for `BlankRel`.
ListBlank (Γ) [Inhabited Γ] := Quotient (BlankRel.setoid Γ)
def
Computability
[ "Mathlib.Data.Vector.Basic", "Mathlib.Logic.Function.Iterate", "Mathlib.Tactic.ApplyFun", "Mathlib.Data.List.GetD" ]
Mathlib/Computability/Tape.lean
ListBlank
A `ListBlank Γ` is a quotient of `List Γ` by extension by blanks at the end. This is used to represent half-tapes of a Turing machine, so that we can pretend that the list continues infinitely with blanks.
ListBlank.inhabited {Γ} [Inhabited Γ] : Inhabited (ListBlank Γ) := ⟨Quotient.mk'' []⟩
instance
Computability
[ "Mathlib.Data.Vector.Basic", "Mathlib.Logic.Function.Iterate", "Mathlib.Tactic.ApplyFun", "Mathlib.Data.List.GetD" ]
Mathlib/Computability/Tape.lean
ListBlank.inhabited
null
ListBlank.hasEmptyc {Γ} [Inhabited Γ] : EmptyCollection (ListBlank Γ) := ⟨Quotient.mk'' []⟩
instance
Computability
[ "Mathlib.Data.Vector.Basic", "Mathlib.Logic.Function.Iterate", "Mathlib.Tactic.ApplyFun", "Mathlib.Data.List.GetD" ]
Mathlib/Computability/Tape.lean
ListBlank.hasEmptyc
null
protected ListBlank.liftOn {Γ} [Inhabited Γ] {α} (l : ListBlank Γ) (f : List Γ → α) (H : ∀ a b, BlankExtends a b → f a = f b) : α := l.liftOn' f <| by rintro a b (h | h) <;> [exact H _ _ h; exact (H _ _ h).symm]
abbrev
Computability
[ "Mathlib.Data.Vector.Basic", "Mathlib.Logic.Function.Iterate", "Mathlib.Tactic.ApplyFun", "Mathlib.Data.List.GetD" ]
Mathlib/Computability/Tape.lean
ListBlank.liftOn
A modified version of `Quotient.liftOn'` specialized for `ListBlank`, with the stronger precondition `BlankExtends` instead of `BlankRel`.
ListBlank.mk {Γ} [Inhabited Γ] : List Γ → ListBlank Γ := Quotient.mk'' @[elab_as_elim]
def
Computability
[ "Mathlib.Data.Vector.Basic", "Mathlib.Logic.Function.Iterate", "Mathlib.Tactic.ApplyFun", "Mathlib.Data.List.GetD" ]
Mathlib/Computability/Tape.lean
ListBlank.mk
The quotient map turning a `List` into a `ListBlank`.
protected ListBlank.induction_on {Γ} [Inhabited Γ] {p : ListBlank Γ → Prop} (q : ListBlank Γ) (h : ∀ a, p (ListBlank.mk a)) : p q := Quotient.inductionOn' q h
theorem
Computability
[ "Mathlib.Data.Vector.Basic", "Mathlib.Logic.Function.Iterate", "Mathlib.Tactic.ApplyFun", "Mathlib.Data.List.GetD" ]
Mathlib/Computability/Tape.lean
ListBlank.induction_on
null
ListBlank.head {Γ} [Inhabited Γ] (l : ListBlank Γ) : Γ := by apply l.liftOn List.headI rintro a _ ⟨i, rfl⟩ cases a · cases i <;> rfl rfl @[simp]
def
Computability
[ "Mathlib.Data.Vector.Basic", "Mathlib.Logic.Function.Iterate", "Mathlib.Tactic.ApplyFun", "Mathlib.Data.List.GetD" ]
Mathlib/Computability/Tape.lean
ListBlank.head
The head of a `ListBlank` is well defined.
ListBlank.head_mk {Γ} [Inhabited Γ] (l : List Γ) : ListBlank.head (ListBlank.mk l) = l.headI := rfl
theorem
Computability
[ "Mathlib.Data.Vector.Basic", "Mathlib.Logic.Function.Iterate", "Mathlib.Tactic.ApplyFun", "Mathlib.Data.List.GetD" ]
Mathlib/Computability/Tape.lean
ListBlank.head_mk
null
ListBlank.tail {Γ} [Inhabited Γ] (l : ListBlank Γ) : ListBlank Γ := by apply l.liftOn (fun l ↦ ListBlank.mk l.tail) rintro a _ ⟨i, rfl⟩ refine Quotient.sound' (Or.inl ?_) cases a · rcases i with - | i <;> [exact ⟨0, rfl⟩; exact ⟨i, rfl⟩] exact ⟨i, rfl⟩ @[simp]
def
Computability
[ "Mathlib.Data.Vector.Basic", "Mathlib.Logic.Function.Iterate", "Mathlib.Tactic.ApplyFun", "Mathlib.Data.List.GetD" ]
Mathlib/Computability/Tape.lean
ListBlank.tail
The tail of a `ListBlank` is well defined (up to the tail of blanks).
ListBlank.tail_mk {Γ} [Inhabited Γ] (l : List Γ) : ListBlank.tail (ListBlank.mk l) = ListBlank.mk l.tail := rfl
theorem
Computability
[ "Mathlib.Data.Vector.Basic", "Mathlib.Logic.Function.Iterate", "Mathlib.Tactic.ApplyFun", "Mathlib.Data.List.GetD" ]
Mathlib/Computability/Tape.lean
ListBlank.tail_mk
null
ListBlank.cons {Γ} [Inhabited Γ] (a : Γ) (l : ListBlank Γ) : ListBlank Γ := by apply l.liftOn (fun l ↦ ListBlank.mk (List.cons a l)) rintro _ _ ⟨i, rfl⟩ exact Quotient.sound' (Or.inl ⟨i, rfl⟩) @[simp]
def
Computability
[ "Mathlib.Data.Vector.Basic", "Mathlib.Logic.Function.Iterate", "Mathlib.Tactic.ApplyFun", "Mathlib.Data.List.GetD" ]
Mathlib/Computability/Tape.lean
ListBlank.cons
We can cons an element onto a `ListBlank`.
ListBlank.cons_mk {Γ} [Inhabited Γ] (a : Γ) (l : List Γ) : ListBlank.cons a (ListBlank.mk l) = ListBlank.mk (a :: l) := rfl @[simp]
theorem
Computability
[ "Mathlib.Data.Vector.Basic", "Mathlib.Logic.Function.Iterate", "Mathlib.Tactic.ApplyFun", "Mathlib.Data.List.GetD" ]
Mathlib/Computability/Tape.lean
ListBlank.cons_mk
null
ListBlank.head_cons {Γ} [Inhabited Γ] (a : Γ) : ∀ l : ListBlank Γ, (l.cons a).head = a := Quotient.ind' fun _ ↦ rfl @[simp]
theorem
Computability
[ "Mathlib.Data.Vector.Basic", "Mathlib.Logic.Function.Iterate", "Mathlib.Tactic.ApplyFun", "Mathlib.Data.List.GetD" ]
Mathlib/Computability/Tape.lean
ListBlank.head_cons
null
ListBlank.tail_cons {Γ} [Inhabited Γ] (a : Γ) : ∀ l : ListBlank Γ, (l.cons a).tail = l := Quotient.ind' fun _ ↦ rfl
theorem
Computability
[ "Mathlib.Data.Vector.Basic", "Mathlib.Logic.Function.Iterate", "Mathlib.Tactic.ApplyFun", "Mathlib.Data.List.GetD" ]
Mathlib/Computability/Tape.lean
ListBlank.tail_cons
null
@[simp] ListBlank.cons_head_tail {Γ} [Inhabited Γ] : ∀ l : ListBlank Γ, l.tail.cons l.head = l := by apply Quotient.ind' refine fun l ↦ Quotient.sound' (Or.inr ?_) cases l · exact ⟨1, rfl⟩ · rfl
theorem
Computability
[ "Mathlib.Data.Vector.Basic", "Mathlib.Logic.Function.Iterate", "Mathlib.Tactic.ApplyFun", "Mathlib.Data.List.GetD" ]
Mathlib/Computability/Tape.lean
ListBlank.cons_head_tail
The `cons` and `head`/`tail` functions are mutually inverse, unlike in the case of `List` where this only holds for nonempty lists.
ListBlank.exists_cons {Γ} [Inhabited Γ] (l : ListBlank Γ) : ∃ a l', l = ListBlank.cons a l' := ⟨_, _, (ListBlank.cons_head_tail _).symm⟩
theorem
Computability
[ "Mathlib.Data.Vector.Basic", "Mathlib.Logic.Function.Iterate", "Mathlib.Tactic.ApplyFun", "Mathlib.Data.List.GetD" ]
Mathlib/Computability/Tape.lean
ListBlank.exists_cons
The `cons` and `head`/`tail` functions are mutually inverse, unlike in the case of `List` where this only holds for nonempty lists.
ListBlank.nth {Γ} [Inhabited Γ] (l : ListBlank Γ) (n : ℕ) : Γ := by apply l.liftOn (fun l ↦ List.getI l n) rintro l _ ⟨i, rfl⟩ rcases lt_or_ge n _ with h | h · rw [List.getI_append _ _ _ h] rw [List.getI_eq_default _ h] rcases le_or_gt _ n with h₂ | h₂ · rw [List.getI_eq_default _ h₂] rw [List.getI_eq_getElem _ h₂, List.getElem_append_right h, List.getElem_replicate] @[simp]
def
Computability
[ "Mathlib.Data.Vector.Basic", "Mathlib.Logic.Function.Iterate", "Mathlib.Tactic.ApplyFun", "Mathlib.Data.List.GetD" ]
Mathlib/Computability/Tape.lean
ListBlank.nth
The n-th element of a `ListBlank` is well defined for all `n : ℕ`, unlike in a `List`.
ListBlank.nth_mk {Γ} [Inhabited Γ] (l : List Γ) (n : ℕ) : (ListBlank.mk l).nth n = l.getI n := rfl @[simp]
theorem
Computability
[ "Mathlib.Data.Vector.Basic", "Mathlib.Logic.Function.Iterate", "Mathlib.Tactic.ApplyFun", "Mathlib.Data.List.GetD" ]
Mathlib/Computability/Tape.lean
ListBlank.nth_mk
null
ListBlank.nth_zero {Γ} [Inhabited Γ] (l : ListBlank Γ) : l.nth 0 = l.head := by conv => lhs; rw [← ListBlank.cons_head_tail l] exact Quotient.inductionOn' l.tail fun l ↦ rfl @[simp]
theorem
Computability
[ "Mathlib.Data.Vector.Basic", "Mathlib.Logic.Function.Iterate", "Mathlib.Tactic.ApplyFun", "Mathlib.Data.List.GetD" ]
Mathlib/Computability/Tape.lean
ListBlank.nth_zero
null
ListBlank.nth_succ {Γ} [Inhabited Γ] (l : ListBlank Γ) (n : ℕ) : l.nth (n + 1) = l.tail.nth n := by conv => lhs; rw [← ListBlank.cons_head_tail l] exact Quotient.inductionOn' l.tail fun l ↦ rfl @[ext]
theorem
Computability
[ "Mathlib.Data.Vector.Basic", "Mathlib.Logic.Function.Iterate", "Mathlib.Tactic.ApplyFun", "Mathlib.Data.List.GetD" ]
Mathlib/Computability/Tape.lean
ListBlank.nth_succ
null