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
self_eq_mul_add_iff {l m n : Language α} (hm : [] ∉ m) : l = m * l + n ↔ l = m∗ * n where mp h := by apply le_antisymm · intro x hx induction hlen : x.length using Nat.strong_induction_on generalizing x with | _ _ ih subst hlen rw [h] at hx obtain hx | hx := hx · obtain ⟨a, ha, b, hb, rfl⟩ := mem_mul.mp hx rw [length_append] at ih have hal : 0 < a.length := length_pos_iff.mpr <| ne_of_mem_of_not_mem ha hm specialize ih b.length (Nat.lt_add_left_iff_pos.mpr hal) hb rfl rw [← one_add_self_mul_kstar_eq_kstar, one_add_mul, mul_assoc] right exact ⟨_, ha, _, ih, rfl⟩ · exact ⟨[], nil_mem_kstar _, _, ⟨hx, nil_append _⟩⟩ · rw [kstar_eq_iSup_pow, iSup_mul, iSup_le_iff] intro i induction i with rw [h] | zero => rw [pow_zero, one_mul, add_comm] exact le_self_add | succ _ ih => rw [add_comm, pow_add, pow_one, mul_assoc] exact le_add_right (mul_le_mul_left' ih _) mpr h := by rw [h, add_comm, ← mul_assoc, ← one_add_mul, one_add_self_mul_kstar_eq_kstar]
theorem
Computability
[ "Mathlib.Algebra.Order.Kleene", "Mathlib.Algebra.Ring.Hom.Defs", "Mathlib.Data.Set.Lattice", "Mathlib.Tactic.DeriveFintype" ]
Mathlib/Computability/Language.lean
self_eq_mul_add_iff
**Arden's lemma**
reverse (l : Language α) : Language α := { w : List α | w.reverse ∈ l } @[simp]
def
Computability
[ "Mathlib.Algebra.Order.Kleene", "Mathlib.Algebra.Ring.Hom.Defs", "Mathlib.Data.Set.Lattice", "Mathlib.Tactic.DeriveFintype" ]
Mathlib/Computability/Language.lean
reverse
Language `l.reverse` is defined as the set of words from `l` backwards.
mem_reverse : a ∈ l.reverse ↔ a.reverse ∈ l := Iff.rfl
lemma
Computability
[ "Mathlib.Algebra.Order.Kleene", "Mathlib.Algebra.Ring.Hom.Defs", "Mathlib.Data.Set.Lattice", "Mathlib.Tactic.DeriveFintype" ]
Mathlib/Computability/Language.lean
mem_reverse
null
reverse_mem_reverse : a.reverse ∈ l.reverse ↔ a ∈ l := by rw [mem_reverse, List.reverse_reverse]
lemma
Computability
[ "Mathlib.Algebra.Order.Kleene", "Mathlib.Algebra.Ring.Hom.Defs", "Mathlib.Data.Set.Lattice", "Mathlib.Tactic.DeriveFintype" ]
Mathlib/Computability/Language.lean
reverse_mem_reverse
null
reverse_eq_image (l : Language α) : l.reverse = List.reverse '' l := ((List.reverse_involutive.toPerm _).image_eq_preimage _).symm @[simp]
lemma
Computability
[ "Mathlib.Algebra.Order.Kleene", "Mathlib.Algebra.Ring.Hom.Defs", "Mathlib.Data.Set.Lattice", "Mathlib.Tactic.DeriveFintype" ]
Mathlib/Computability/Language.lean
reverse_eq_image
null
reverse_zero : (0 : Language α).reverse = 0 := rfl @[simp]
lemma
Computability
[ "Mathlib.Algebra.Order.Kleene", "Mathlib.Algebra.Ring.Hom.Defs", "Mathlib.Data.Set.Lattice", "Mathlib.Tactic.DeriveFintype" ]
Mathlib/Computability/Language.lean
reverse_zero
null
reverse_one : (1 : Language α).reverse = 1 := by simp [reverse, ← one_def]
lemma
Computability
[ "Mathlib.Algebra.Order.Kleene", "Mathlib.Algebra.Ring.Hom.Defs", "Mathlib.Data.Set.Lattice", "Mathlib.Tactic.DeriveFintype" ]
Mathlib/Computability/Language.lean
reverse_one
null
reverse_involutive : Function.Involutive (reverse : Language α → _) := List.reverse_involutive.preimage
lemma
Computability
[ "Mathlib.Algebra.Order.Kleene", "Mathlib.Algebra.Ring.Hom.Defs", "Mathlib.Data.Set.Lattice", "Mathlib.Tactic.DeriveFintype" ]
Mathlib/Computability/Language.lean
reverse_involutive
null
reverse_bijective : Function.Bijective (reverse : Language α → _) := reverse_involutive.bijective
lemma
Computability
[ "Mathlib.Algebra.Order.Kleene", "Mathlib.Algebra.Ring.Hom.Defs", "Mathlib.Data.Set.Lattice", "Mathlib.Tactic.DeriveFintype" ]
Mathlib/Computability/Language.lean
reverse_bijective
null
reverse_injective : Function.Injective (reverse : Language α → _) := reverse_involutive.injective
lemma
Computability
[ "Mathlib.Algebra.Order.Kleene", "Mathlib.Algebra.Ring.Hom.Defs", "Mathlib.Data.Set.Lattice", "Mathlib.Tactic.DeriveFintype" ]
Mathlib/Computability/Language.lean
reverse_injective
null
reverse_surjective : Function.Surjective (reverse : Language α → _) := reverse_involutive.surjective @[simp]
lemma
Computability
[ "Mathlib.Algebra.Order.Kleene", "Mathlib.Algebra.Ring.Hom.Defs", "Mathlib.Data.Set.Lattice", "Mathlib.Tactic.DeriveFintype" ]
Mathlib/Computability/Language.lean
reverse_surjective
null
reverse_reverse (l : Language α) : l.reverse.reverse = l := reverse_involutive l @[simp]
lemma
Computability
[ "Mathlib.Algebra.Order.Kleene", "Mathlib.Algebra.Ring.Hom.Defs", "Mathlib.Data.Set.Lattice", "Mathlib.Tactic.DeriveFintype" ]
Mathlib/Computability/Language.lean
reverse_reverse
null
reverse_add (l m : Language α) : (l + m).reverse = l.reverse + m.reverse := rfl @[simp]
lemma
Computability
[ "Mathlib.Algebra.Order.Kleene", "Mathlib.Algebra.Ring.Hom.Defs", "Mathlib.Data.Set.Lattice", "Mathlib.Tactic.DeriveFintype" ]
Mathlib/Computability/Language.lean
reverse_add
null
reverse_mul (l m : Language α) : (l * m).reverse = m.reverse * l.reverse := by simp only [mul_def, reverse_eq_image, image2_image_left, image2_image_right, image_image2, List.reverse_append] apply image2_swap @[simp]
lemma
Computability
[ "Mathlib.Algebra.Order.Kleene", "Mathlib.Algebra.Ring.Hom.Defs", "Mathlib.Data.Set.Lattice", "Mathlib.Tactic.DeriveFintype" ]
Mathlib/Computability/Language.lean
reverse_mul
null
reverse_iSup {ι : Sort*} (l : ι → Language α) : (⨆ i, l i).reverse = ⨆ i, (l i).reverse := preimage_iUnion @[simp]
lemma
Computability
[ "Mathlib.Algebra.Order.Kleene", "Mathlib.Algebra.Ring.Hom.Defs", "Mathlib.Data.Set.Lattice", "Mathlib.Tactic.DeriveFintype" ]
Mathlib/Computability/Language.lean
reverse_iSup
null
reverse_iInf {ι : Sort*} (l : ι → Language α) : (⨅ i, l i).reverse = ⨅ i, (l i).reverse := preimage_iInter variable (α) in
lemma
Computability
[ "Mathlib.Algebra.Order.Kleene", "Mathlib.Algebra.Ring.Hom.Defs", "Mathlib.Data.Set.Lattice", "Mathlib.Tactic.DeriveFintype" ]
Mathlib/Computability/Language.lean
reverse_iInf
null
@[simps] reverseIso : Language α ≃+* (Language α)ᵐᵒᵖ where toFun l := .op l.reverse invFun l' := l'.unop.reverse left_inv := reverse_reverse right_inv l' := MulOpposite.unop_injective <| reverse_reverse l'.unop map_mul' l₁ l₂ := MulOpposite.unop_injective <| reverse_mul l₁ l₂ map_add' l₁ l₂ := MulOpposite.unop_injective <| reverse_add l₁ l₂ @[simp]
def
Computability
[ "Mathlib.Algebra.Order.Kleene", "Mathlib.Algebra.Ring.Hom.Defs", "Mathlib.Data.Set.Lattice", "Mathlib.Tactic.DeriveFintype" ]
Mathlib/Computability/Language.lean
reverseIso
`Language.reverse` as a ring isomorphism to the opposite ring.
reverse_pow (l : Language α) (n : ℕ) : (l ^ n).reverse = l.reverse ^ n := MulOpposite.op_injective (map_pow (reverseIso α) l n) @[simp]
lemma
Computability
[ "Mathlib.Algebra.Order.Kleene", "Mathlib.Algebra.Ring.Hom.Defs", "Mathlib.Data.Set.Lattice", "Mathlib.Tactic.DeriveFintype" ]
Mathlib/Computability/Language.lean
reverse_pow
null
reverse_kstar (l : Language α) : l∗.reverse = l.reverse∗ := by simp only [kstar_eq_iSup_pow, reverse_iSup, reverse_pow]
lemma
Computability
[ "Mathlib.Algebra.Order.Kleene", "Mathlib.Algebra.Ring.Hom.Defs", "Mathlib.Data.Set.Lattice", "Mathlib.Tactic.DeriveFintype" ]
Mathlib/Computability/Language.lean
reverse_kstar
null
Symbol (T N : Type*) /-- Terminal symbols (of the same type as the language) -/ | terminal (t : T) : Symbol T N /-- Nonterminal symbols (must not be present when the word being generated is finalized) -/ | nonterminal (n : N) : Symbol T N deriving DecidableEq, Repr, Fintype attribute [nolint docBlame] Symbol.proxyType Symbol.proxyTypeEquiv
inductive
Computability
[ "Mathlib.Algebra.Order.Kleene", "Mathlib.Algebra.Ring.Hom.Defs", "Mathlib.Data.Set.Lattice", "Mathlib.Tactic.DeriveFintype" ]
Mathlib/Computability/Language.lean
Symbol
Symbols for use by all kinds of grammars.
leftQuotient (x : List α) : Language α := { y | x ++ y ∈ L } variable (L) in @[simp]
def
Computability
[ "Mathlib.Computability.DFA", "Mathlib.Data.Set.Finite.Basic" ]
Mathlib/Computability/MyhillNerode.lean
leftQuotient
The *left quotient* of `x` is the set of suffixes `y` such that `x ++ y` is in `L`.
leftQuotient_nil : L.leftQuotient [] = L := rfl variable (L) in
theorem
Computability
[ "Mathlib.Computability.DFA", "Mathlib.Data.Set.Finite.Basic" ]
Mathlib/Computability/MyhillNerode.lean
leftQuotient_nil
null
leftQuotient_append (x y : List α) : L.leftQuotient (x ++ y) = (L.leftQuotient x).leftQuotient y := by simp [leftQuotient, Language] @[simp]
theorem
Computability
[ "Mathlib.Computability.DFA", "Mathlib.Data.Set.Finite.Basic" ]
Mathlib/Computability/MyhillNerode.lean
leftQuotient_append
null
mem_leftQuotient (x y : List α) : y ∈ L.leftQuotient x ↔ x ++ y ∈ L := Iff.rfl
theorem
Computability
[ "Mathlib.Computability.DFA", "Mathlib.Data.Set.Finite.Basic" ]
Mathlib/Computability/MyhillNerode.lean
mem_leftQuotient
null
leftQuotient_accepts_apply (M : DFA α σ) (x : List α) : leftQuotient M.accepts x = M.acceptsFrom (M.eval x) := by ext y simp [DFA.mem_accepts, DFA.mem_acceptsFrom, DFA.eval, DFA.evalFrom_of_append]
theorem
Computability
[ "Mathlib.Computability.DFA", "Mathlib.Data.Set.Finite.Basic" ]
Mathlib/Computability/MyhillNerode.lean
leftQuotient_accepts_apply
null
leftQuotient_accepts (M : DFA α σ) : leftQuotient M.accepts = M.acceptsFrom ∘ M.eval := funext <| leftQuotient_accepts_apply M
theorem
Computability
[ "Mathlib.Computability.DFA", "Mathlib.Data.Set.Finite.Basic" ]
Mathlib/Computability/MyhillNerode.lean
leftQuotient_accepts
null
IsRegular.finite_range_leftQuotient (h : L.IsRegular) : (Set.range L.leftQuotient).Finite := by have ⟨σ, x, M, hM⟩ := h rw [← hM, leftQuotient_accepts] exact Set.finite_of_finite_preimage (Set.toFinite _) (Set.range_comp_subset_range M.eval M.acceptsFrom) variable (L) in
theorem
Computability
[ "Mathlib.Computability.DFA", "Mathlib.Data.Set.Finite.Basic" ]
Mathlib/Computability/MyhillNerode.lean
IsRegular.finite_range_leftQuotient
null
toDFA : DFA α (Set.range L.leftQuotient) where step s a := by refine ⟨s.val.leftQuotient [a], ?_⟩ obtain ⟨y, hy⟩ := s.prop exists y ++ [a] rw [← hy, leftQuotient_append] start := ⟨L, by exists []⟩ accept := { s | [] ∈ s.val } @[simp]
def
Computability
[ "Mathlib.Computability.DFA", "Mathlib.Data.Set.Finite.Basic" ]
Mathlib/Computability/MyhillNerode.lean
toDFA
The left quotients of a language are the states of an automaton that accepts the language.
mem_accept_toDFA (s : Set.range L.leftQuotient) : s ∈ L.toDFA.accept ↔ [] ∈ s.val := Iff.rfl @[simp]
theorem
Computability
[ "Mathlib.Computability.DFA", "Mathlib.Data.Set.Finite.Basic" ]
Mathlib/Computability/MyhillNerode.lean
mem_accept_toDFA
null
step_toDFA (s : Set.range L.leftQuotient) (a : α) : (L.toDFA.step s a).val = s.val.leftQuotient [a] := rfl variable (L) in @[simp]
theorem
Computability
[ "Mathlib.Computability.DFA", "Mathlib.Data.Set.Finite.Basic" ]
Mathlib/Computability/MyhillNerode.lean
step_toDFA
null
start_toDFA : L.toDFA.start.val = L := rfl variable (L) in @[simp]
theorem
Computability
[ "Mathlib.Computability.DFA", "Mathlib.Data.Set.Finite.Basic" ]
Mathlib/Computability/MyhillNerode.lean
start_toDFA
null
accepts_toDFA : L.toDFA.accepts = L := by ext x rw [DFA.mem_accepts] suffices L.toDFA.eval x = L.leftQuotient x by simp [this] induction x using List.reverseRecOn with | nil => simp | append_singleton x a ih => simp [ih, leftQuotient_append]
theorem
Computability
[ "Mathlib.Computability.DFA", "Mathlib.Data.Set.Finite.Basic" ]
Mathlib/Computability/MyhillNerode.lean
accepts_toDFA
null
IsRegular.of_finite_range_leftQuotient (h : Set.Finite (Set.range L.leftQuotient)) : L.IsRegular := Language.isRegular_iff.mpr ⟨_, h.fintype, L.toDFA, by simp⟩
theorem
Computability
[ "Mathlib.Computability.DFA", "Mathlib.Data.Set.Finite.Basic" ]
Mathlib/Computability/MyhillNerode.lean
IsRegular.of_finite_range_leftQuotient
null
isRegular_iff_finite_range_leftQuotient : L.IsRegular ↔ (Set.range L.leftQuotient).Finite := ⟨IsRegular.finite_range_leftQuotient, .of_finite_range_leftQuotient⟩
theorem
Computability
[ "Mathlib.Computability.DFA", "Mathlib.Data.Set.Finite.Basic" ]
Mathlib/Computability/MyhillNerode.lean
isRegular_iff_finite_range_leftQuotient
**Myhill–Nerode theorem**. A language is regular if and only if the set of left quotients is finite.
NFA (α : Type u) (σ : Type v) where /-- The NFA's transition function -/ step : σ → α → Set σ /-- Set of starting states -/ start : Set σ /-- Set of accepting states -/ accept : Set σ variable {α : Type u} {σ : Type v} {M : NFA α σ}
structure
Computability
[ "Mathlib.Computability.DFA", "Mathlib.Data.Fintype.Powerset" ]
Mathlib/Computability/NFA.lean
NFA
An NFA is a set of states (`σ`), a transition function from state to state labelled by the alphabet (`step`), a set of starting states (`start`) and a set of acceptance states (`accept`). Note the transition function sends a state to a `Set` of states. These are the states that it may be sent to.
stepSet (S : Set σ) (a : α) : Set σ := ⋃ s ∈ S, M.step s a
def
Computability
[ "Mathlib.Computability.DFA", "Mathlib.Data.Fintype.Powerset" ]
Mathlib/Computability/NFA.lean
stepSet
`M.stepSet S a` is the union of `M.step s a` for all `s ∈ S`.
mem_stepSet {s : σ} {S : Set σ} {a : α} : s ∈ M.stepSet S a ↔ ∃ t ∈ S, s ∈ M.step t a := by simp [stepSet] variable (M) in @[simp]
theorem
Computability
[ "Mathlib.Computability.DFA", "Mathlib.Data.Fintype.Powerset" ]
Mathlib/Computability/NFA.lean
mem_stepSet
null
stepSet_empty (a : α) : M.stepSet ∅ a = ∅ := by simp [stepSet] variable (M) in @[simp]
theorem
Computability
[ "Mathlib.Computability.DFA", "Mathlib.Data.Fintype.Powerset" ]
Mathlib/Computability/NFA.lean
stepSet_empty
null
stepSet_singleton (s : σ) (a : α) : M.stepSet {s} a = M.step s a := by simp [stepSet] variable (M) in
theorem
Computability
[ "Mathlib.Computability.DFA", "Mathlib.Data.Fintype.Powerset" ]
Mathlib/Computability/NFA.lean
stepSet_singleton
null
evalFrom (S : Set σ) : List α → Set σ := List.foldl M.stepSet S variable (M) in @[simp]
def
Computability
[ "Mathlib.Computability.DFA", "Mathlib.Data.Fintype.Powerset" ]
Mathlib/Computability/NFA.lean
evalFrom
`M.evalFrom S x` computes all possible paths through `M` with input `x` starting at an element of `S`.
evalFrom_nil (S : Set σ) : M.evalFrom S [] = S := rfl variable (M) in @[simp]
theorem
Computability
[ "Mathlib.Computability.DFA", "Mathlib.Data.Fintype.Powerset" ]
Mathlib/Computability/NFA.lean
evalFrom_nil
null
evalFrom_singleton (S : Set σ) (a : α) : M.evalFrom S [a] = M.stepSet S a := rfl variable (M) in @[simp]
theorem
Computability
[ "Mathlib.Computability.DFA", "Mathlib.Data.Fintype.Powerset" ]
Mathlib/Computability/NFA.lean
evalFrom_singleton
null
evalFrom_cons (S : Set σ) (a : α) (x : List α) : M.evalFrom S (a :: x) = M.evalFrom (M.stepSet S a) x := rfl @[simp]
theorem
Computability
[ "Mathlib.Computability.DFA", "Mathlib.Data.Fintype.Powerset" ]
Mathlib/Computability/NFA.lean
evalFrom_cons
null
evalFrom_append_singleton (S : Set σ) (x : List α) (a : α) : M.evalFrom S (x ++ [a]) = M.stepSet (M.evalFrom S x) a := by simp only [evalFrom, List.foldl_append, List.foldl_cons, List.foldl_nil] variable (M) in @[simp]
theorem
Computability
[ "Mathlib.Computability.DFA", "Mathlib.Data.Fintype.Powerset" ]
Mathlib/Computability/NFA.lean
evalFrom_append_singleton
null
evalFrom_biUnion {ι : Type*} (t : Set ι) (f : ι → Set σ) : ∀ (x : List α), M.evalFrom (⋃ i ∈ t, f i) x = ⋃ i ∈ t, M.evalFrom (f i) x | [] => by simp | a :: x => by simp [stepSet, evalFrom_biUnion _ _ x] variable (M) in
theorem
Computability
[ "Mathlib.Computability.DFA", "Mathlib.Data.Fintype.Powerset" ]
Mathlib/Computability/NFA.lean
evalFrom_biUnion
null
evalFrom_eq_biUnion_singleton (S : Set σ) (x : List α) : M.evalFrom S x = ⋃ s ∈ S, M.evalFrom {s} x := by simp [← evalFrom_biUnion]
theorem
Computability
[ "Mathlib.Computability.DFA", "Mathlib.Data.Fintype.Powerset" ]
Mathlib/Computability/NFA.lean
evalFrom_eq_biUnion_singleton
null
mem_evalFrom_iff_exists {s : σ} {S : Set σ} {x : List α} : s ∈ M.evalFrom S x ↔ ∃ t ∈ S, s ∈ M.evalFrom {t} x := by rw [evalFrom_eq_biUnion_singleton] simp variable (M) in
theorem
Computability
[ "Mathlib.Computability.DFA", "Mathlib.Data.Fintype.Powerset" ]
Mathlib/Computability/NFA.lean
mem_evalFrom_iff_exists
null
eval : List α → Set σ := M.evalFrom M.start variable (M) in @[simp]
def
Computability
[ "Mathlib.Computability.DFA", "Mathlib.Data.Fintype.Powerset" ]
Mathlib/Computability/NFA.lean
eval
`M.eval x` computes all possible paths though `M` with input `x` starting at an element of `M.start`.
eval_nil : M.eval [] = M.start := rfl variable (M) in @[simp]
theorem
Computability
[ "Mathlib.Computability.DFA", "Mathlib.Data.Fintype.Powerset" ]
Mathlib/Computability/NFA.lean
eval_nil
null
eval_singleton (a : α) : M.eval [a] = M.stepSet M.start a := rfl variable (M) in @[simp]
theorem
Computability
[ "Mathlib.Computability.DFA", "Mathlib.Data.Fintype.Powerset" ]
Mathlib/Computability/NFA.lean
eval_singleton
null
eval_append_singleton (x : List α) (a : α) : M.eval (x ++ [a]) = M.stepSet (M.eval x) a := evalFrom_append_singleton .. variable (M) in
theorem
Computability
[ "Mathlib.Computability.DFA", "Mathlib.Data.Fintype.Powerset" ]
Mathlib/Computability/NFA.lean
eval_append_singleton
null
accepts : Language α := {x | ∃ S ∈ M.accept, S ∈ M.eval x}
def
Computability
[ "Mathlib.Computability.DFA", "Mathlib.Data.Fintype.Powerset" ]
Mathlib/Computability/NFA.lean
accepts
`M.accepts` is the language of `x` such that there is an accept state in `M.eval x`.
mem_accepts {x : List α} : x ∈ M.accepts ↔ ∃ S ∈ M.accept, S ∈ M.evalFrom M.start x := by rfl variable (M) in
theorem
Computability
[ "Mathlib.Computability.DFA", "Mathlib.Data.Fintype.Powerset" ]
Mathlib/Computability/NFA.lean
mem_accepts
null
Path : σ → σ → List α → Type (max u v) | nil (s : σ) : Path s s [] | cons (t s u : σ) (a : α) (x : List α) : t ∈ M.step s a → Path t u x → Path s u (a :: x)
inductive
Computability
[ "Mathlib.Computability.DFA", "Mathlib.Data.Fintype.Powerset" ]
Mathlib/Computability/NFA.lean
Path
`M.Path` represents a concrete path through the NFA from a start state to an end state for a particular word. Note that due to the non-deterministic nature of the automata, there can be more than one `Path` for a given word. Also note that this is `Type` and not a `Prop`, so that we can speak about the properties of a particular `Path`, such as the set of states visited along the way (defined as `Path.supp`).
@[simp] Path.supp [DecidableEq σ] {s t : σ} {x : List α} : M.Path s t x → Finset σ | nil s => {s} | cons _ _ _ _ _ _ p => {s} ∪ p.supp
def
Computability
[ "Mathlib.Computability.DFA", "Mathlib.Data.Fintype.Powerset" ]
Mathlib/Computability/NFA.lean
Path.supp
Set of states visited by a path.
mem_evalFrom_iff_nonempty_path {s t : σ} {x : List α} : t ∈ M.evalFrom {s} x ↔ Nonempty (M.Path s t x) where mp h := match x with | [] => have h : s = t := by simp at h; tauto ⟨h ▸ Path.nil s⟩ | a :: x => have h : ∃ s' ∈ M.step s a, t ∈ M.evalFrom {s'} x := by rw [evalFrom_cons, mem_evalFrom_iff_exists, stepSet_singleton] at h; exact h let ⟨s', h₁, h₂⟩ := h let ⟨p'⟩ := mem_evalFrom_iff_nonempty_path.1 h₂ ⟨Path.cons s' _ _ _ _ h₁ p'⟩ mpr p := match p with | ⟨Path.nil s⟩ => by simp | ⟨Path.cons s' s t a x h₁ h₂⟩ => by rw [evalFrom_cons, stepSet_singleton, mem_evalFrom_iff_exists] exact ⟨s', h₁, mem_evalFrom_iff_nonempty_path.2 ⟨h₂⟩⟩
theorem
Computability
[ "Mathlib.Computability.DFA", "Mathlib.Data.Fintype.Powerset" ]
Mathlib/Computability/NFA.lean
mem_evalFrom_iff_nonempty_path
null
accepts_iff_exists_path {x : List α} : x ∈ M.accepts ↔ ∃ s ∈ M.start, ∃ t ∈ M.accept, Nonempty (M.Path s t x) := by simp only [← mem_evalFrom_iff_nonempty_path, mem_accepts, mem_evalFrom_iff_exists (S := M.start)] tauto variable (M) in
theorem
Computability
[ "Mathlib.Computability.DFA", "Mathlib.Data.Fintype.Powerset" ]
Mathlib/Computability/NFA.lean
accepts_iff_exists_path
null
toDFA : DFA α (Set σ) where step := M.stepSet start := M.start accept := { S | ∃ s ∈ S, s ∈ M.accept } @[simp]
def
Computability
[ "Mathlib.Computability.DFA", "Mathlib.Data.Fintype.Powerset" ]
Mathlib/Computability/NFA.lean
toDFA
`M.toDFA` is a `DFA` constructed from an `NFA` `M` using the subset construction. The states is the type of `Set`s of `M.state` and the step function is `M.stepSet`.
toDFA_correct : M.toDFA.accepts = M.accepts := by ext x rw [mem_accepts, DFA.mem_accepts] constructor <;> · exact fun ⟨w, h2, h3⟩ => ⟨w, h3, h2⟩
theorem
Computability
[ "Mathlib.Computability.DFA", "Mathlib.Data.Fintype.Powerset" ]
Mathlib/Computability/NFA.lean
toDFA_correct
null
pumping_lemma [Fintype σ] {x : List α} (hx : x ∈ M.accepts) (hlen : Fintype.card (Set σ) ≤ List.length x) : ∃ a b c, x = a ++ b ++ c ∧ a.length + b.length ≤ Fintype.card (Set σ) ∧ b ≠ [] ∧ {a} * {b}∗ * {c} ≤ M.accepts := by rw [← toDFA_correct] at hx ⊢ exact M.toDFA.pumping_lemma hx hlen
theorem
Computability
[ "Mathlib.Computability.DFA", "Mathlib.Data.Fintype.Powerset" ]
Mathlib/Computability/NFA.lean
pumping_lemma
null
@[simps] toNFA (M : DFA α σ) : NFA α σ where step s a := {M.step s a} start := {M.start} accept := M.accept @[simp]
def
Computability
[ "Mathlib.Computability.DFA", "Mathlib.Data.Fintype.Powerset" ]
Mathlib/Computability/NFA.lean
toNFA
`M.toNFA` is an `NFA` constructed from a `DFA` `M` by using the same start and accept states and a transition function which sends `s` with input `a` to the singleton `M.step s a`.
toNFA_evalFrom_match (M : DFA α σ) (start : σ) (s : List α) : M.toNFA.evalFrom {start} s = {M.evalFrom start s} := by change List.foldl M.toNFA.stepSet {start} s = {List.foldl M.step start s} induction s generalizing start with | nil => tauto | cons a s ih => rw [List.foldl, List.foldl, show M.toNFA.stepSet {start} a = {M.step start a} by simp [NFA.stepSet] ] tauto @[simp]
theorem
Computability
[ "Mathlib.Computability.DFA", "Mathlib.Data.Fintype.Powerset" ]
Mathlib/Computability/NFA.lean
toNFA_evalFrom_match
null
toNFA_correct (M : DFA α σ) : M.toNFA.accepts = M.accepts := by ext x rw [NFA.mem_accepts, toNFA_start, toNFA_evalFrom_match] constructor · rintro ⟨S, hS₁, hS₂⟩ rwa [Set.mem_singleton_iff.mp hS₂] at hS₁ · exact fun h => ⟨M.eval x, h, rfl⟩
theorem
Computability
[ "Mathlib.Computability.DFA", "Mathlib.Data.Fintype.Powerset" ]
Mathlib/Computability/NFA.lean
toNFA_correct
null
@[simps] reverse : NFA α σ where step s a := { s' | s ∈ M.step s' a } start := M.accept accept := M.start variable (M) in @[simp]
def
Computability
[ "Mathlib.Computability.DFA", "Mathlib.Data.Fintype.Powerset" ]
Mathlib/Computability/NFA.lean
reverse
`M.reverse` constructs an NFA with the same states as `M`, but all the transitions reversed. The resulting automaton accepts a word `x` if and only if `M` accepts `List.reverse x`.
reverse_reverse : M.reverse.reverse = M := by simp [reverse]
theorem
Computability
[ "Mathlib.Computability.DFA", "Mathlib.Data.Fintype.Powerset" ]
Mathlib/Computability/NFA.lean
reverse_reverse
null
disjoint_stepSet_reverse {a : α} {S S' : Set σ} : Disjoint S (M.reverse.stepSet S' a) ↔ Disjoint S' (M.stepSet S a) := by rw [← not_iff_not] simp only [Set.not_disjoint_iff, mem_stepSet, reverse_step, Set.mem_setOf_eq] tauto
theorem
Computability
[ "Mathlib.Computability.DFA", "Mathlib.Data.Fintype.Powerset" ]
Mathlib/Computability/NFA.lean
disjoint_stepSet_reverse
null
disjoint_evalFrom_reverse {x : List α} {S S' : Set σ} (h : Disjoint S (M.reverse.evalFrom S' x)) : Disjoint S' (M.evalFrom S x.reverse) := by simp only [evalFrom, List.foldl_reverse] at h ⊢ induction x generalizing S S' with | nil => rw [disjoint_comm] exact h | cons x xs ih => rw [List.foldl_cons] at h rw [List.foldr_cons, ← NFA.disjoint_stepSet_reverse, disjoint_comm] exact ih h
theorem
Computability
[ "Mathlib.Computability.DFA", "Mathlib.Data.Fintype.Powerset" ]
Mathlib/Computability/NFA.lean
disjoint_evalFrom_reverse
null
disjoint_evalFrom_reverse_iff {x : List α} {S S' : Set σ} : Disjoint S (M.reverse.evalFrom S' x) ↔ Disjoint S' (M.evalFrom S x.reverse) := ⟨disjoint_evalFrom_reverse, fun h ↦ List.reverse_reverse x ▸ disjoint_evalFrom_reverse h⟩ @[simp]
theorem
Computability
[ "Mathlib.Computability.DFA", "Mathlib.Data.Fintype.Powerset" ]
Mathlib/Computability/NFA.lean
disjoint_evalFrom_reverse_iff
null
mem_accepts_reverse {x : List α} : x ∈ M.reverse.accepts ↔ x.reverse ∈ M.accepts := by simp [mem_accepts, ← Set.not_disjoint_iff, disjoint_evalFrom_reverse_iff]
theorem
Computability
[ "Mathlib.Computability.DFA", "Mathlib.Data.Fintype.Powerset" ]
Mathlib/Computability/NFA.lean
mem_accepts_reverse
null
protected IsRegular.reverse {L : Language α} (h : L.IsRegular) : L.reverse.IsRegular := have ⟨σ, _, M, hM⟩ := h ⟨_, inferInstance, M.toNFA.reverse.toDFA, by ext; simp [hM]⟩
theorem
Computability
[ "Mathlib.Computability.DFA", "Mathlib.Data.Fintype.Powerset" ]
Mathlib/Computability/NFA.lean
IsRegular.reverse
null
protected IsRegular.of_reverse {L : Language α} (h : L.reverse.IsRegular) : L.IsRegular := L.reverse_reverse ▸ h.reverse
theorem
Computability
[ "Mathlib.Computability.DFA", "Mathlib.Data.Fintype.Powerset" ]
Mathlib/Computability/NFA.lean
IsRegular.of_reverse
null
@[simp] isRegular_reverse_iff {L : Language α} : L.reverse.IsRegular ↔ L.IsRegular := ⟨.of_reverse, .reverse⟩
theorem
Computability
[ "Mathlib.Computability.DFA", "Mathlib.Data.Fintype.Powerset" ]
Mathlib/Computability/NFA.lean
isRegular_reverse_iff
Regular languages are closed under reversal.
private lbp (m n : ℕ) : Prop := m = n + 1 ∧ ∀ k ≤ n, false ∈ p k
def
Computability
[ "Mathlib.Computability.Primrec", "Mathlib.Data.Nat.PSub", "Mathlib.Data.PFun" ]
Mathlib/Computability/Partrec.lean
lbp
null
private wf_lbp (H : ∃ n, true ∈ p n ∧ ∀ k < n, (p k).Dom) : WellFounded (lbp p) := ⟨by let ⟨n, pn⟩ := H suffices ∀ m k, n ≤ k + m → Acc (lbp p) k by exact fun a => this _ _ (Nat.le_add_left _ _) intro m k kn induction m generalizing k with (refine ⟨_, fun y r => ?_⟩; rcases r with ⟨rfl, a⟩) | zero => injection mem_unique pn.1 (a _ kn) | succ m IH => exact IH _ (by rw [Nat.add_right_comm]; exact kn)⟩ variable (H : ∃ n, true ∈ p n ∧ ∀ k < n, (p k).Dom)
def
Computability
[ "Mathlib.Computability.Primrec", "Mathlib.Data.Nat.PSub", "Mathlib.Data.PFun" ]
Mathlib/Computability/Partrec.lean
wf_lbp
null
rfindX : { n // true ∈ p n ∧ ∀ m < n, false ∈ p m } := suffices ∀ k, (∀ n < k, false ∈ p n) → { n // true ∈ p n ∧ ∀ m < n, false ∈ p m } from this 0 fun _ => (Nat.not_lt_zero _).elim @WellFounded.fix _ _ (lbp p) (wf_lbp p H) (by intro m IH al have pm : (p m).Dom := by rcases H with ⟨n, h₁, h₂⟩ rcases lt_trichotomy m n with (h₃ | h₃ | h₃) · exact h₂ _ h₃ · rw [h₃] exact h₁.fst · injection mem_unique h₁ (al _ h₃) cases e : (p m).get pm · suffices ∀ᵉ k ≤ m, false ∈ p k from IH _ ⟨rfl, this⟩ fun n h => this _ (le_of_lt_succ h) intro n h rcases h.lt_or_eq_dec with h | h · exact al _ h · rw [h] exact ⟨_, e⟩ · exact ⟨m, ⟨_, e⟩, al⟩)
def
Computability
[ "Mathlib.Computability.Primrec", "Mathlib.Data.Nat.PSub", "Mathlib.Data.PFun" ]
Mathlib/Computability/Partrec.lean
rfindX
Find the smallest `n` satisfying `p n`, where all `p k` for `k < n` are defined as false. Returns a subtype.
rfind (p : ℕ →. Bool) : Part ℕ := ⟨_, fun h => (rfindX p h).1⟩
def
Computability
[ "Mathlib.Computability.Primrec", "Mathlib.Data.Nat.PSub", "Mathlib.Data.PFun" ]
Mathlib/Computability/Partrec.lean
rfind
Find the smallest `n` satisfying `p n`, where all `p k` for `k < n` are defined as false. Returns a `Part`.
rfind_spec {p : ℕ →. Bool} {n : ℕ} (h : n ∈ rfind p) : true ∈ p n := h.snd ▸ (rfindX p h.fst).2.1
theorem
Computability
[ "Mathlib.Computability.Primrec", "Mathlib.Data.Nat.PSub", "Mathlib.Data.PFun" ]
Mathlib/Computability/Partrec.lean
rfind_spec
null
rfind_min {p : ℕ →. Bool} {n : ℕ} (h : n ∈ rfind p) : ∀ {m : ℕ}, m < n → false ∈ p m := @(h.snd ▸ @((rfindX p h.fst).2.2)) @[simp]
theorem
Computability
[ "Mathlib.Computability.Primrec", "Mathlib.Data.Nat.PSub", "Mathlib.Data.PFun" ]
Mathlib/Computability/Partrec.lean
rfind_min
null
rfind_dom {p : ℕ →. Bool} : (rfind p).Dom ↔ ∃ n, true ∈ p n ∧ ∀ {m : ℕ}, m < n → (p m).Dom := Iff.rfl
theorem
Computability
[ "Mathlib.Computability.Primrec", "Mathlib.Data.Nat.PSub", "Mathlib.Data.PFun" ]
Mathlib/Computability/Partrec.lean
rfind_dom
null
rfind_dom' {p : ℕ →. Bool} : (rfind p).Dom ↔ ∃ n, true ∈ p n ∧ ∀ {m : ℕ}, m ≤ n → (p m).Dom := exists_congr fun _ => and_congr_right fun pn => ⟨fun H _ h => (Decidable.eq_or_lt_of_le h).elim (fun e => e.symm ▸ pn.fst) (H _), fun H _ h => H (le_of_lt h)⟩ @[simp]
theorem
Computability
[ "Mathlib.Computability.Primrec", "Mathlib.Data.Nat.PSub", "Mathlib.Data.PFun" ]
Mathlib/Computability/Partrec.lean
rfind_dom'
null
mem_rfind {p : ℕ →. Bool} {n : ℕ} : n ∈ rfind p ↔ true ∈ p n ∧ ∀ {m : ℕ}, m < n → false ∈ p m := ⟨fun h => ⟨rfind_spec h, @rfind_min _ _ h⟩, fun ⟨h₁, h₂⟩ => by let ⟨m, hm⟩ := dom_iff_mem.1 <| (@rfind_dom p).2 ⟨_, h₁, fun {m} mn => (h₂ mn).fst⟩ rcases lt_trichotomy m n with (h | h | h) · injection mem_unique (h₂ h) (rfind_spec hm) · rwa [← h] · injection mem_unique h₁ (rfind_min hm h)⟩
theorem
Computability
[ "Mathlib.Computability.Primrec", "Mathlib.Data.Nat.PSub", "Mathlib.Data.PFun" ]
Mathlib/Computability/Partrec.lean
mem_rfind
null
rfind_min' {p : ℕ → Bool} {m : ℕ} (pm : p m) : ∃ n ∈ rfind p, n ≤ m := have : true ∈ (p : ℕ →. Bool) m := ⟨trivial, pm⟩ let ⟨n, hn⟩ := dom_iff_mem.1 <| (@rfind_dom p).2 ⟨m, this, fun {_} _ => ⟨⟩⟩ ⟨n, hn, not_lt.1 fun h => by injection mem_unique this (rfind_min hn h)⟩
theorem
Computability
[ "Mathlib.Computability.Primrec", "Mathlib.Data.Nat.PSub", "Mathlib.Data.PFun" ]
Mathlib/Computability/Partrec.lean
rfind_min'
null
rfind_zero_none (p : ℕ →. Bool) (p0 : p 0 = Part.none) : rfind p = Part.none := eq_none_iff.2 fun _ h => let ⟨_, _, h₂⟩ := rfind_dom'.1 h.fst (p0 ▸ h₂ (zero_le _) : (@Part.none Bool).Dom)
theorem
Computability
[ "Mathlib.Computability.Primrec", "Mathlib.Data.Nat.PSub", "Mathlib.Data.PFun" ]
Mathlib/Computability/Partrec.lean
rfind_zero_none
null
rfindOpt {α} (f : ℕ → Option α) : Part α := (rfind fun n => (f n).isSome).bind fun n => f n
def
Computability
[ "Mathlib.Computability.Primrec", "Mathlib.Data.Nat.PSub", "Mathlib.Data.PFun" ]
Mathlib/Computability/Partrec.lean
rfindOpt
Find the smallest `n` satisfying `f n`, where all `f k` for `k < n` are defined as false. Returns a `Part`.
rfindOpt_spec {α} {f : ℕ → Option α} {a} (h : a ∈ rfindOpt f) : ∃ n, a ∈ f n := let ⟨n, _, h₂⟩ := mem_bind_iff.1 h ⟨n, mem_coe.1 h₂⟩
theorem
Computability
[ "Mathlib.Computability.Primrec", "Mathlib.Data.Nat.PSub", "Mathlib.Data.PFun" ]
Mathlib/Computability/Partrec.lean
rfindOpt_spec
null
rfindOpt_dom {α} {f : ℕ → Option α} : (rfindOpt f).Dom ↔ ∃ n a, a ∈ f n := ⟨fun h => (rfindOpt_spec ⟨h, rfl⟩).imp fun _ h => ⟨_, h⟩, fun h => by have h' : ∃ n, (f n).isSome := h.imp fun n => Option.isSome_iff_exists.2 have s := Nat.find_spec h' have fd : (rfind fun n => (f n).isSome).Dom := ⟨Nat.find h', by simpa using s.symm, fun _ _ => trivial⟩ refine ⟨fd, ?_⟩ have := rfind_spec (get_mem fd) simpa using this⟩
theorem
Computability
[ "Mathlib.Computability.Primrec", "Mathlib.Data.Nat.PSub", "Mathlib.Data.PFun" ]
Mathlib/Computability/Partrec.lean
rfindOpt_dom
null
rfindOpt_mono {α} {f : ℕ → Option α} (H : ∀ {a m n}, m ≤ n → a ∈ f m → a ∈ f n) {a} : a ∈ rfindOpt f ↔ ∃ n, a ∈ f n := ⟨rfindOpt_spec, fun ⟨n, h⟩ => by have h' := rfindOpt_dom.2 ⟨_, _, h⟩ obtain ⟨k, hk⟩ := rfindOpt_spec ⟨h', rfl⟩ have := (H (le_max_left _ _) h).symm.trans (H (le_max_right _ _) hk) simp at this; simp [this, get_mem]⟩
theorem
Computability
[ "Mathlib.Computability.Primrec", "Mathlib.Data.Nat.PSub", "Mathlib.Data.PFun" ]
Mathlib/Computability/Partrec.lean
rfindOpt_mono
null
Partrec : (ℕ →. ℕ) → Prop | zero : Partrec (pure 0) | succ : Partrec succ | left : Partrec ↑fun n : ℕ => n.unpair.1 | right : Partrec ↑fun n : ℕ => n.unpair.2 | pair {f g} : Partrec f → Partrec g → Partrec fun n => pair <$> f n <*> g n | comp {f g} : Partrec f → Partrec g → Partrec fun n => g n >>= f | prec {f g} : Partrec f → Partrec g → Partrec (unpaired fun a n => n.rec (f a) fun y IH => do let i ← IH; g (pair a (pair y i))) | rfind {f} : Partrec f → Partrec fun a => rfind fun n => (fun m => m = 0) <$> f (pair a n)
inductive
Computability
[ "Mathlib.Computability.Primrec", "Mathlib.Data.Nat.PSub", "Mathlib.Data.PFun" ]
Mathlib/Computability/Partrec.lean
Partrec
`Partrec f` means that the partial function `f : ℕ →. ℕ` is partially recursive.
of_eq {f g : ℕ →. ℕ} (hf : Partrec f) (H : ∀ n, f n = g n) : Partrec g := (funext H : f = g) ▸ hf
theorem
Computability
[ "Mathlib.Computability.Primrec", "Mathlib.Data.Nat.PSub", "Mathlib.Data.PFun" ]
Mathlib/Computability/Partrec.lean
of_eq
null
of_eq_tot {f : ℕ →. ℕ} {g : ℕ → ℕ} (hf : Partrec f) (H : ∀ n, g n ∈ f n) : Partrec g := hf.of_eq fun n => eq_some_iff.2 (H n)
theorem
Computability
[ "Mathlib.Computability.Primrec", "Mathlib.Data.Nat.PSub", "Mathlib.Data.PFun" ]
Mathlib/Computability/Partrec.lean
of_eq_tot
null
of_primrec {f : ℕ → ℕ} (hf : Nat.Primrec f) : Partrec f := by induction hf with | zero => exact zero | succ => exact succ | left => exact left | right => exact right | pair _ _ pf pg => refine (pf.pair pg).of_eq_tot fun n => ?_ simp [Seq.seq] | comp _ _ pf pg => refine (pf.comp pg).of_eq_tot fun n => (by simp) | prec _ _ pf pg => refine (pf.prec pg).of_eq_tot fun n => ?_ simp only [unpaired, PFun.coe_val, bind_eq_bind] induction n.unpair.2 with | zero => simp | succ m IH => simp only [mem_bind_iff, mem_some_iff] exact ⟨_, IH, rfl⟩
theorem
Computability
[ "Mathlib.Computability.Primrec", "Mathlib.Data.Nat.PSub", "Mathlib.Data.PFun" ]
Mathlib/Computability/Partrec.lean
of_primrec
null
protected some : Partrec some := of_primrec Primrec.id
theorem
Computability
[ "Mathlib.Computability.Primrec", "Mathlib.Data.Nat.PSub", "Mathlib.Data.PFun" ]
Mathlib/Computability/Partrec.lean
some
null
none : Partrec fun _ => none := (of_primrec (Nat.Primrec.const 1)).rfind.of_eq fun _ => eq_none_iff.2 fun _ ⟨h, _⟩ => by simp at h
theorem
Computability
[ "Mathlib.Computability.Primrec", "Mathlib.Data.Nat.PSub", "Mathlib.Data.PFun" ]
Mathlib/Computability/Partrec.lean
none
null
prec' {f g h} (hf : Partrec f) (hg : Partrec g) (hh : Partrec h) : Partrec fun a => (f a).bind fun n => n.rec (g a) fun y IH => do {let i ← IH; h (Nat.pair a (Nat.pair y i))} := ((prec hg hh).comp (pair Partrec.some hf)).of_eq fun a => ext fun s => by simp [Seq.seq]
theorem
Computability
[ "Mathlib.Computability.Primrec", "Mathlib.Data.Nat.PSub", "Mathlib.Data.PFun" ]
Mathlib/Computability/Partrec.lean
prec'
null
ppred : Partrec fun n => ppred n := have : Primrec₂ fun n m => if n = Nat.succ m then 0 else 1 := (Primrec.ite (@PrimrecRel.comp _ _ _ _ _ _ _ _ _ Primrec.eq Primrec.fst (_root_.Primrec.succ.comp Primrec.snd)) (_root_.Primrec.const 0) (_root_.Primrec.const 1)).to₂ (of_primrec (Primrec₂.unpaired'.2 this)).rfind.of_eq fun n => by cases n <;> simp · exact eq_none_iff.2 fun a ⟨⟨m, h, _⟩, _⟩ => by simp at h · refine eq_some_iff.2 ?_ simp only [mem_rfind, decide_true, mem_some_iff, false_eq_decide_iff, true_and] intro m h simp [ne_of_gt h]
theorem
Computability
[ "Mathlib.Computability.Primrec", "Mathlib.Data.Nat.PSub", "Mathlib.Data.PFun" ]
Mathlib/Computability/Partrec.lean
ppred
null
Partrec {α σ} [Primcodable α] [Primcodable σ] (f : α →. σ) := Nat.Partrec fun n => Part.bind (decode (α := α) n) fun a => (f a).map encode
def
Computability
[ "Mathlib.Computability.Primrec", "Mathlib.Data.Nat.PSub", "Mathlib.Data.PFun" ]
Mathlib/Computability/Partrec.lean
Partrec
Partially recursive partial functions `α → σ` between `Primcodable` types
Partrec₂ {α β σ} [Primcodable α] [Primcodable β] [Primcodable σ] (f : α → β →. σ) := Partrec fun p : α × β => f p.1 p.2
def
Computability
[ "Mathlib.Computability.Primrec", "Mathlib.Data.Nat.PSub", "Mathlib.Data.PFun" ]
Mathlib/Computability/Partrec.lean
Partrec₂
Partially recursive partial functions `α → β → σ` between `Primcodable` types
Computable {α σ} [Primcodable α] [Primcodable σ] (f : α → σ) := Partrec (f : α →. σ)
def
Computability
[ "Mathlib.Computability.Primrec", "Mathlib.Data.Nat.PSub", "Mathlib.Data.PFun" ]
Mathlib/Computability/Partrec.lean
Computable
Computable functions `α → σ` between `Primcodable` types: a function is computable if and only if it is partially recursive (as a partial function)
Computable₂ {α β σ} [Primcodable α] [Primcodable β] [Primcodable σ] (f : α → β → σ) := Computable fun p : α × β => f p.1 p.2
def
Computability
[ "Mathlib.Computability.Primrec", "Mathlib.Data.Nat.PSub", "Mathlib.Data.PFun" ]
Mathlib/Computability/Partrec.lean
Computable₂
Computable functions `α → β → σ` between `Primcodable` types
Primrec.to_comp {α σ} [Primcodable α] [Primcodable σ] {f : α → σ} (hf : Primrec f) : Computable f := (Nat.Partrec.ppred.comp (Nat.Partrec.of_primrec hf)).of_eq fun n => by simp; cases decode (α := α) n <;> simp nonrec theorem Primrec₂.to_comp {α β σ} [Primcodable α] [Primcodable β] [Primcodable σ] {f : α → β → σ} (hf : Primrec₂ f) : Computable₂ f := hf.to_comp
theorem
Computability
[ "Mathlib.Computability.Primrec", "Mathlib.Data.Nat.PSub", "Mathlib.Data.PFun" ]
Mathlib/Computability/Partrec.lean
Primrec.to_comp
null