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 ⌀ |
|---|---|---|---|---|---|---|
stepSet (S : Set σ) (a : α) : Set σ :=
⋃ s ∈ S, M.εClosure (M.step s a)
variable {M}
@[simp] | def | Computability | [
"Mathlib.Computability.NFA",
"Mathlib.Data.List.ReduceOption"
] | Mathlib/Computability/EpsilonNFA.lean | stepSet | `M.stepSet S a` is the union of the ε-closure of `M.step s a` for all `s ∈ S`. |
mem_stepSet_iff : s ∈ M.stepSet S a ↔ ∃ t ∈ S, s ∈ M.εClosure (M.step t a) := by
simp_rw [stepSet, mem_iUnion₂, exists_prop]
@[simp] | theorem | Computability | [
"Mathlib.Computability.NFA",
"Mathlib.Data.List.ReduceOption"
] | Mathlib/Computability/EpsilonNFA.lean | mem_stepSet_iff | null |
stepSet_empty (a : α) : M.stepSet ∅ a = ∅ := by
simp_rw [stepSet, mem_empty_iff_false, iUnion_false, iUnion_empty]
variable (M) | theorem | Computability | [
"Mathlib.Computability.NFA",
"Mathlib.Data.List.ReduceOption"
] | Mathlib/Computability/EpsilonNFA.lean | stepSet_empty | null |
evalFrom (start : Set σ) : List α → Set σ :=
List.foldl M.stepSet (M.εClosure start)
@[simp] | def | Computability | [
"Mathlib.Computability.NFA",
"Mathlib.Data.List.ReduceOption"
] | Mathlib/Computability/EpsilonNFA.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 [] = M.εClosure S :=
rfl
@[simp] | theorem | Computability | [
"Mathlib.Computability.NFA",
"Mathlib.Data.List.ReduceOption"
] | Mathlib/Computability/EpsilonNFA.lean | evalFrom_nil | null |
evalFrom_singleton (S : Set σ) (a : α) : M.evalFrom S [a] = M.stepSet (M.εClosure S) a :=
rfl
@[simp] | theorem | Computability | [
"Mathlib.Computability.NFA",
"Mathlib.Data.List.ReduceOption"
] | Mathlib/Computability/EpsilonNFA.lean | evalFrom_singleton | null |
evalFrom_append_singleton (S : Set σ) (x : List α) (a : α) :
M.evalFrom S (x ++ [a]) = M.stepSet (M.evalFrom S x) a := by
rw [evalFrom, List.foldl_append, List.foldl_cons, List.foldl_nil]
@[simp] | theorem | Computability | [
"Mathlib.Computability.NFA",
"Mathlib.Data.List.ReduceOption"
] | Mathlib/Computability/EpsilonNFA.lean | evalFrom_append_singleton | null |
evalFrom_empty (x : List α) : M.evalFrom ∅ x = ∅ := by
induction x using List.reverseRecOn with
| nil => rw [evalFrom_nil, εClosure_empty]
| append_singleton x a ih => rw [evalFrom_append_singleton, ih, stepSet_empty] | theorem | Computability | [
"Mathlib.Computability.NFA",
"Mathlib.Data.List.ReduceOption"
] | Mathlib/Computability/EpsilonNFA.lean | evalFrom_empty | null |
mem_evalFrom_iff_exists {s : σ} {S : Set σ} {x : List α} :
s ∈ M.evalFrom S x ↔ ∃ t ∈ S, s ∈ M.evalFrom {t} x := by
induction x using List.reverseRecOn generalizing s with
| nil => apply mem_εClosure_iff_exists
| append_singleton _ _ ih =>
simp_rw [evalFrom_append_singleton, mem_stepSet_iff, ih]
tauto | theorem | Computability | [
"Mathlib.Computability.NFA",
"Mathlib.Data.List.ReduceOption"
] | Mathlib/Computability/EpsilonNFA.lean | mem_evalFrom_iff_exists | null |
eval :=
M.evalFrom M.start
@[simp] | def | Computability | [
"Mathlib.Computability.NFA",
"Mathlib.Data.List.ReduceOption"
] | Mathlib/Computability/EpsilonNFA.lean | eval | `M.eval x` computes all possible paths through `M` with input `x` starting at an element of
`M.start`. |
eval_nil : M.eval [] = M.εClosure M.start :=
rfl
@[simp] | theorem | Computability | [
"Mathlib.Computability.NFA",
"Mathlib.Data.List.ReduceOption"
] | Mathlib/Computability/EpsilonNFA.lean | eval_nil | null |
eval_singleton (a : α) : M.eval [a] = M.stepSet (M.εClosure M.start) a :=
rfl
@[simp] | theorem | Computability | [
"Mathlib.Computability.NFA",
"Mathlib.Data.List.ReduceOption"
] | Mathlib/Computability/EpsilonNFA.lean | eval_singleton | null |
eval_append_singleton (x : List α) (a : α) : M.eval (x ++ [a]) = M.stepSet (M.eval x) a :=
evalFrom_append_singleton _ _ _ _ | theorem | Computability | [
"Mathlib.Computability.NFA",
"Mathlib.Data.List.ReduceOption"
] | Mathlib/Computability/EpsilonNFA.lean | eval_append_singleton | null |
accepts : Language α :=
{ x | ∃ S ∈ M.accept, S ∈ M.eval x } | def | Computability | [
"Mathlib.Computability.NFA",
"Mathlib.Data.List.ReduceOption"
] | Mathlib/Computability/EpsilonNFA.lean | accepts | `M.accepts` is the language of `x` such that there is an accept state in `M.eval x`. |
@[mk_iff]
IsPath : σ → σ → List (Option α) → Prop
| nil (s : σ) : IsPath s s []
| cons (t s u : σ) (a : Option α) (x : List (Option α)) :
t ∈ M.step s a → IsPath t u x → IsPath s u (a :: x)
@[simp] | inductive | Computability | [
"Mathlib.Computability.NFA",
"Mathlib.Data.List.ReduceOption"
] | Mathlib/Computability/EpsilonNFA.lean | IsPath | `M.IsPath` represents a traversal in `M` from a start state to an end state by following a list
of transitions in order. |
isPath_nil : M.IsPath s t [] ↔ s = t := by
rw [isPath_iff]
simp [eq_comm]
alias ⟨IsPath.eq_of_nil, _⟩ := isPath_nil
@[simp] | theorem | Computability | [
"Mathlib.Computability.NFA",
"Mathlib.Data.List.ReduceOption"
] | Mathlib/Computability/EpsilonNFA.lean | isPath_nil | null |
isPath_singleton {a : Option α} : M.IsPath s t [a] ↔ t ∈ M.step s a where
mp := by
rintro (_ | ⟨_, _, _, _, _, _, ⟨⟩⟩)
assumption
mpr := by tauto
alias ⟨_, IsPath.singleton⟩ := isPath_singleton | theorem | Computability | [
"Mathlib.Computability.NFA",
"Mathlib.Data.List.ReduceOption"
] | Mathlib/Computability/EpsilonNFA.lean | isPath_singleton | null |
isPath_append {x y : List (Option α)} :
M.IsPath s u (x ++ y) ↔ ∃ t, M.IsPath s t x ∧ M.IsPath t u y where
mp := by
induction x generalizing s with
| nil =>
rw [List.nil_append]
tauto
| cons x a ih =>
rintro (_ | ⟨t, _, _, _, _, _, h⟩)
apply ih at h
tauto
mpr := by
... | theorem | Computability | [
"Mathlib.Computability.NFA",
"Mathlib.Data.List.ReduceOption"
] | Mathlib/Computability/EpsilonNFA.lean | isPath_append | null |
mem_εClosure_iff_exists_path {s₁ s₂ : σ} :
s₂ ∈ M.εClosure {s₁} ↔ ∃ n, M.IsPath s₁ s₂ (.replicate n none) where
mp h := by
induction h with
| base t =>
use 0
subst t
apply IsPath.nil
| step _ _ _ _ ih =>
obtain ⟨n, _⟩ := ih
use n + 1
rw [List.replicate_add, isPath_a... | theorem | Computability | [
"Mathlib.Computability.NFA",
"Mathlib.Data.List.ReduceOption"
] | Mathlib/Computability/EpsilonNFA.lean | mem_εClosure_iff_exists_path | null |
mem_evalFrom_iff_exists_path {s₁ s₂ : σ} {x : List α} :
s₂ ∈ M.evalFrom {s₁} x ↔ ∃ x', x'.reduceOption = x ∧ M.IsPath s₁ s₂ x' := by
induction x using List.reverseRecOn generalizing s₂ with
| nil =>
rw [evalFrom_nil, mem_εClosure_iff_exists_path]
constructor
· intro ⟨n, _⟩
use List.replicate n... | theorem | Computability | [
"Mathlib.Computability.NFA",
"Mathlib.Data.List.ReduceOption"
] | Mathlib/Computability/EpsilonNFA.lean | mem_evalFrom_iff_exists_path | null |
mem_accepts_iff_exists_path {x : List α} :
x ∈ M.accepts ↔
∃ s₁ s₂ x', s₁ ∈ M.start ∧ s₂ ∈ M.accept ∧ x'.reduceOption = x ∧ M.IsPath s₁ s₂ x' where
mp := by
intro ⟨s₂, _, h⟩
rw [eval, mem_evalFrom_iff_exists] at h
obtain ⟨s₁, _, h⟩ := h
rw [mem_evalFrom_iff_exists_path] at h
tauto
mpr ... | theorem | Computability | [
"Mathlib.Computability.NFA",
"Mathlib.Data.List.ReduceOption"
] | Mathlib/Computability/EpsilonNFA.lean | mem_accepts_iff_exists_path | null |
toNFA : NFA α σ where
step S a := M.εClosure (M.step S a)
start := M.εClosure M.start
accept := M.accept
@[simp] | def | Computability | [
"Mathlib.Computability.NFA",
"Mathlib.Data.List.ReduceOption"
] | Mathlib/Computability/EpsilonNFA.lean | toNFA | `M.toNFA` is an `NFA` constructed from an `εNFA` `M`. |
toNFA_evalFrom_match (start : Set σ) :
M.toNFA.evalFrom (M.εClosure start) = M.evalFrom start :=
rfl
@[simp] | theorem | Computability | [
"Mathlib.Computability.NFA",
"Mathlib.Data.List.ReduceOption"
] | Mathlib/Computability/EpsilonNFA.lean | toNFA_evalFrom_match | null |
toNFA_correct : M.toNFA.accepts = M.accepts :=
rfl | theorem | Computability | [
"Mathlib.Computability.NFA",
"Mathlib.Data.List.ReduceOption"
] | Mathlib/Computability/EpsilonNFA.lean | toNFA_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 :=
M.toNFA.pumping_lemma hx hlen | theorem | Computability | [
"Mathlib.Computability.NFA",
"Mathlib.Data.List.ReduceOption"
] | Mathlib/Computability/EpsilonNFA.lean | pumping_lemma | null |
toεNFA (M : NFA α σ) : εNFA α σ where
step s a := a.casesOn' ∅ fun a ↦ M.step s a
start := M.start
accept := M.accept
@[simp] | def | Computability | [
"Mathlib.Computability.NFA",
"Mathlib.Data.List.ReduceOption"
] | Mathlib/Computability/EpsilonNFA.lean | toεNFA | `M.toεNFA` is an `εNFA` constructed from an `NFA` `M` by using the same start and accept
states and transition functions. |
toεNFA_εClosure (M : NFA α σ) (S : Set σ) : M.toεNFA.εClosure S = S := by
ext a
refine ⟨?_, εNFA.εClosure.base _⟩
rintro (⟨_, h⟩ | ⟨_, _, h, _⟩)
· exact h
· cases h
@[simp] | theorem | Computability | [
"Mathlib.Computability.NFA",
"Mathlib.Data.List.ReduceOption"
] | Mathlib/Computability/EpsilonNFA.lean | toεNFA_εClosure | null |
toεNFA_evalFrom_match (M : NFA α σ) (start : Set σ) :
M.toεNFA.evalFrom start = M.evalFrom start := by
rw [evalFrom, εNFA.evalFrom, toεNFA_εClosure]
suffices εNFA.stepSet (toεNFA M) = stepSet M by rw [this]
ext S s
simp only [stepSet, εNFA.stepSet, exists_prop, Set.mem_iUnion]
apply exists_congr
simp on... | theorem | Computability | [
"Mathlib.Computability.NFA",
"Mathlib.Data.List.ReduceOption"
] | Mathlib/Computability/EpsilonNFA.lean | toεNFA_evalFrom_match | null |
toεNFA_correct (M : NFA α σ) : M.toεNFA.accepts = M.accepts := by
rw [εNFA.accepts, εNFA.eval, toεNFA_evalFrom_match]
rfl | theorem | Computability | [
"Mathlib.Computability.NFA",
"Mathlib.Data.List.ReduceOption"
] | Mathlib/Computability/EpsilonNFA.lean | toεNFA_correct | null |
@[simp]
step_zero (s a) : (0 : εNFA α σ).step s a = ∅ :=
rfl
@[simp] | theorem | Computability | [
"Mathlib.Computability.NFA",
"Mathlib.Data.List.ReduceOption"
] | Mathlib/Computability/EpsilonNFA.lean | step_zero | null |
step_one (s a) : (1 : εNFA α σ).step s a = ∅ :=
rfl
@[simp] | theorem | Computability | [
"Mathlib.Computability.NFA",
"Mathlib.Data.List.ReduceOption"
] | Mathlib/Computability/EpsilonNFA.lean | step_one | null |
start_zero : (0 : εNFA α σ).start = ∅ :=
rfl
@[simp] | theorem | Computability | [
"Mathlib.Computability.NFA",
"Mathlib.Data.List.ReduceOption"
] | Mathlib/Computability/EpsilonNFA.lean | start_zero | null |
start_one : (1 : εNFA α σ).start = univ :=
rfl
@[simp] | theorem | Computability | [
"Mathlib.Computability.NFA",
"Mathlib.Data.List.ReduceOption"
] | Mathlib/Computability/EpsilonNFA.lean | start_one | null |
accept_zero : (0 : εNFA α σ).accept = ∅ :=
rfl
@[simp] | theorem | Computability | [
"Mathlib.Computability.NFA",
"Mathlib.Data.List.ReduceOption"
] | Mathlib/Computability/EpsilonNFA.lean | accept_zero | null |
accept_one : (1 : εNFA α σ).accept = univ :=
rfl | theorem | Computability | [
"Mathlib.Computability.NFA",
"Mathlib.Data.List.ReduceOption"
] | Mathlib/Computability/EpsilonNFA.lean | accept_one | null |
merge' {f g} (hf : Nat.Partrec f) (hg : Nat.Partrec g) :
∃ h, Nat.Partrec h ∧
∀ a, (∀ x ∈ h a, x ∈ f a ∨ x ∈ g a) ∧ ((h a).Dom ↔ (f a).Dom ∨ (g a).Dom) := by
obtain ⟨cf, rfl⟩ := Code.exists_code.1 hf
obtain ⟨cg, rfl⟩ := Code.exists_code.1 hg
have : Nat.Partrec fun n => Nat.rfindOpt fun k => cf.evaln k n... | theorem | Computability | [
"Mathlib.Computability.PartrecCode",
"Mathlib.Data.Set.Subsingleton"
] | Mathlib/Computability/Halting.lean | merge' | null |
merge' {f g : α →. σ} (hf : Partrec f) (hg : Partrec g) :
∃ k : α →. σ,
Partrec k ∧ ∀ a, (∀ x ∈ k a, x ∈ f a ∨ x ∈ g a) ∧ ((k a).Dom ↔ (f a).Dom ∨ (g a).Dom) := by
let ⟨k, hk, H⟩ := Nat.Partrec.merge' (bind_decode₂_iff.1 hf) (bind_decode₂_iff.1 hg)
let k' (a : α) := (k (encode a)).bind fun n => (decode (α... | theorem | Computability | [
"Mathlib.Computability.PartrecCode",
"Mathlib.Data.Set.Subsingleton"
] | Mathlib/Computability/Halting.lean | merge' | null |
merge {f g : α →. σ} (hf : Partrec f) (hg : Partrec g)
(H : ∀ (a), ∀ x ∈ f a, ∀ y ∈ g a, x = y) :
∃ k : α →. σ, Partrec k ∧ ∀ a x, x ∈ k a ↔ x ∈ f a ∨ x ∈ g a :=
let ⟨k, hk, K⟩ := merge' hf hg
⟨k, hk, fun a x =>
⟨(K _).1 _, fun h => by
have : (k a).Dom := (K _).2.2 (h.imp Exists.fst Exists.fst)
... | theorem | Computability | [
"Mathlib.Computability.PartrecCode",
"Mathlib.Data.Set.Subsingleton"
] | Mathlib/Computability/Halting.lean | merge | null |
cond {c : α → Bool} {f : α →. σ} {g : α →. σ} (hc : Computable c) (hf : Partrec f)
(hg : Partrec g) : Partrec fun a => cond (c a) (f a) (g a) :=
let ⟨cf, ef⟩ := exists_code.1 hf
let ⟨cg, eg⟩ := exists_code.1 hg
((eval_part.comp (Computable.cond hc (const cf) (const cg)) Computable.encode).bind
((@Computab... | theorem | Computability | [
"Mathlib.Computability.PartrecCode",
"Mathlib.Data.Set.Subsingleton"
] | Mathlib/Computability/Halting.lean | cond | null |
ComputablePred {α} [Primcodable α] (p : α → Prop) :=
∃ (_ : DecidablePred p), Computable fun a => decide (p a) | def | Computability | [
"Mathlib.Computability.PartrecCode",
"Mathlib.Data.Set.Subsingleton"
] | Mathlib/Computability/Halting.lean | ComputablePred | A computable predicate is one whose indicator function is computable. |
protected ComputablePred.decide {p : α → Prop} [DecidablePred p] (hp : ComputablePred p) :
Computable (fun a => decide (p a)) := by
convert hp.choose_spec | lemma | Computability | [
"Mathlib.Computability.PartrecCode",
"Mathlib.Data.Set.Subsingleton"
] | Mathlib/Computability/Halting.lean | ComputablePred.decide | null |
Computable.computablePred {p : α → Prop} [DecidablePred p]
(hp : Computable (fun a => decide (p a))) : ComputablePred p :=
⟨inferInstance, hp⟩ | lemma | Computability | [
"Mathlib.Computability.PartrecCode",
"Mathlib.Data.Set.Subsingleton"
] | Mathlib/Computability/Halting.lean | Computable.computablePred | null |
computablePred_iff_computable_decide {p : α → Prop} [DecidablePred p] :
ComputablePred p ↔ Computable (fun a => decide (p a)) where
mp := ComputablePred.decide
mpr := Computable.computablePred | lemma | Computability | [
"Mathlib.Computability.PartrecCode",
"Mathlib.Data.Set.Subsingleton"
] | Mathlib/Computability/Halting.lean | computablePred_iff_computable_decide | null |
PrimrecPred.computablePred {α} [Primcodable α] {p : α → Prop} :
(hp : PrimrecPred p) → ComputablePred p
| ⟨_, hp⟩ => hp.to_comp.computablePred | lemma | Computability | [
"Mathlib.Computability.PartrecCode",
"Mathlib.Data.Set.Subsingleton"
] | Mathlib/Computability/Halting.lean | PrimrecPred.computablePred | null |
REPred {α} [Primcodable α] (p : α → Prop) :=
Partrec fun a => Part.assert (p a) fun _ => Part.some () | def | Computability | [
"Mathlib.Computability.PartrecCode",
"Mathlib.Data.Set.Subsingleton"
] | Mathlib/Computability/Halting.lean | REPred | A recursively enumerable predicate is one which is the domain of a computable partial function. |
REPred.of_eq {α} [Primcodable α] {p q : α → Prop} (hp : REPred p) (H : ∀ a, p a ↔ q a) :
REPred q :=
(funext fun a => propext (H a) : p = q) ▸ hp | theorem | Computability | [
"Mathlib.Computability.PartrecCode",
"Mathlib.Data.Set.Subsingleton"
] | Mathlib/Computability/Halting.lean | REPred.of_eq | null |
Partrec.dom_re {α β} [Primcodable α] [Primcodable β] {f : α →. β} (h : Partrec f) :
REPred fun a => (f a).Dom :=
(h.map (Computable.const ()).to₂).of_eq fun n => Part.ext fun _ => by simp [Part.dom_iff_mem] | theorem | Computability | [
"Mathlib.Computability.PartrecCode",
"Mathlib.Data.Set.Subsingleton"
] | Mathlib/Computability/Halting.lean | Partrec.dom_re | null |
ComputablePred.of_eq {α} [Primcodable α] {p q : α → Prop} (hp : ComputablePred p)
(H : ∀ a, p a ↔ q a) : ComputablePred q :=
(funext fun a => propext (H a) : p = q) ▸ hp | theorem | Computability | [
"Mathlib.Computability.PartrecCode",
"Mathlib.Data.Set.Subsingleton"
] | Mathlib/Computability/Halting.lean | ComputablePred.of_eq | null |
computable_iff {p : α → Prop} :
ComputablePred p ↔ ∃ f : α → Bool, Computable f ∧ p = fun a => (f a : Prop) :=
⟨fun ⟨_, h⟩ => ⟨_, h, funext fun _ => propext (Bool.decide_iff _).symm⟩, by
rintro ⟨f, h, rfl⟩; exact ⟨by infer_instance, by simpa using h⟩⟩ | theorem | Computability | [
"Mathlib.Computability.PartrecCode",
"Mathlib.Data.Set.Subsingleton"
] | Mathlib/Computability/Halting.lean | computable_iff | null |
protected not {p : α → Prop} :
(hp : ComputablePred p) → ComputablePred fun a => ¬p a
| ⟨_, hp⟩ => Computable.computablePred <| Primrec.not.to_comp.comp hp |>.of_eq <| by simp | theorem | Computability | [
"Mathlib.Computability.PartrecCode",
"Mathlib.Data.Set.Subsingleton"
] | Mathlib/Computability/Halting.lean | not | null |
ite {f₁ f₂ : ℕ → ℕ} (hf₁ : Computable f₁) (hf₂ : Computable f₂)
{c : ℕ → Prop} [DecidablePred c] (hc : ComputablePred c) :
Computable fun k ↦ if c k then f₁ k else f₂ k := by
simpa [Bool.cond_decide] using hc.decide.cond hf₁ hf₂ | theorem | Computability | [
"Mathlib.Computability.PartrecCode",
"Mathlib.Data.Set.Subsingleton"
] | Mathlib/Computability/Halting.lean | ite | The computable functions are closed under if-then-else definitions
with computable predicates. |
to_re {p : α → Prop} (hp : ComputablePred p) : REPred p := by
obtain ⟨f, hf, rfl⟩ := computable_iff.1 hp
unfold REPred
dsimp only []
refine
(Partrec.cond hf (Decidable.Partrec.const' (Part.some ())) Partrec.none).of_eq fun n =>
Part.ext fun a => ?_
cases a; cases f n <;> simp | theorem | Computability | [
"Mathlib.Computability.PartrecCode",
"Mathlib.Data.Set.Subsingleton"
] | Mathlib/Computability/Halting.lean | to_re | null |
rice (C : Set (ℕ →. ℕ)) (h : ComputablePred fun c => eval c ∈ C) {f g} (hf : Nat.Partrec f)
(hg : Nat.Partrec g) (fC : f ∈ C) : g ∈ C := by
obtain ⟨_, h⟩ := h
obtain ⟨c, e⟩ :=
fixed_point₂
(Partrec.cond (h.comp fst) ((Partrec.nat_iff.2 hg).comp snd).to₂
((Partrec.nat_iff.2 hf).comp snd).to₂)... | theorem | Computability | [
"Mathlib.Computability.PartrecCode",
"Mathlib.Data.Set.Subsingleton"
] | Mathlib/Computability/Halting.lean | rice | **Rice's Theorem** |
rice₂ (C : Set Code) (H : ∀ cf cg, eval cf = eval cg → (cf ∈ C ↔ cg ∈ C)) :
(ComputablePred fun c => c ∈ C) ↔ C = ∅ ∨ C = Set.univ := by
classical exact
have hC : ∀ f, f ∈ C ↔ eval f ∈ eval '' C := fun f =>
⟨Set.mem_image_of_mem _, fun ⟨g, hg, e⟩ => (H _ _ e).1 hg⟩
⟨fun h =>
or_iff_not... | theorem | Computability | [
"Mathlib.Computability.PartrecCode",
"Mathlib.Data.Set.Subsingleton"
] | Mathlib/Computability/Halting.lean | rice₂ | null |
halting_problem_re (n) : REPred fun c => (eval c n).Dom :=
(eval_part.comp Computable.id (Computable.const _)).dom_re | theorem | Computability | [
"Mathlib.Computability.PartrecCode",
"Mathlib.Data.Set.Subsingleton"
] | Mathlib/Computability/Halting.lean | halting_problem_re | The Halting problem is recursively enumerable |
halting_problem (n) : ¬ComputablePred fun c => (eval c n).Dom
| h => rice { f | (f n).Dom } h Nat.Partrec.zero Nat.Partrec.none trivial | theorem | Computability | [
"Mathlib.Computability.PartrecCode",
"Mathlib.Data.Set.Subsingleton"
] | Mathlib/Computability/Halting.lean | halting_problem | The **Halting problem** is not computable |
computable_iff_re_compl_re {p : α → Prop} [DecidablePred p] :
ComputablePred p ↔ REPred p ∧ REPred fun a => ¬p a :=
⟨fun h => ⟨h.to_re, h.not.to_re⟩, fun ⟨h₁, h₂⟩ =>
⟨‹_›, by
obtain ⟨k, pk, hk⟩ :=
Partrec.merge (h₁.map (Computable.const true).to₂) (h₂.map (Computable.const false).to₂)
(b... | theorem | Computability | [
"Mathlib.Computability.PartrecCode",
"Mathlib.Data.Set.Subsingleton"
] | Mathlib/Computability/Halting.lean | computable_iff_re_compl_re | null |
computable_iff_re_compl_re' {p : α → Prop} :
ComputablePred p ↔ REPred p ∧ REPred fun a => ¬p a := by
classical exact computable_iff_re_compl_re | theorem | Computability | [
"Mathlib.Computability.PartrecCode",
"Mathlib.Data.Set.Subsingleton"
] | Mathlib/Computability/Halting.lean | computable_iff_re_compl_re' | null |
halting_problem_not_re (n) : ¬REPred fun c => ¬(eval c n).Dom
| h => halting_problem _ <| computable_iff_re_compl_re'.2 ⟨halting_problem_re _, h⟩ | theorem | Computability | [
"Mathlib.Computability.PartrecCode",
"Mathlib.Data.Set.Subsingleton"
] | Mathlib/Computability/Halting.lean | halting_problem_not_re | null |
Partrec' : ∀ {n}, (List.Vector ℕ n →. ℕ) → Prop
| prim {n f} : @Primrec' n f → @Partrec' n f
| comp {m n f} (g : Fin n → List.Vector ℕ m →. ℕ) :
Partrec' f → (∀ i, Partrec' (g i)) →
Partrec' fun v => (List.Vector.mOfFn fun i => g i v) >>= f
| rfind {n} {f : List.Vector ℕ (n + 1) → ℕ} :
@Partrec' (n ... | inductive | Computability | [
"Mathlib.Computability.PartrecCode",
"Mathlib.Data.Set.Subsingleton"
] | Mathlib/Computability/Halting.lean | Partrec' | A simplified basis for `Partrec`. |
to_part {n f} (pf : @Partrec' n f) : _root_.Partrec f := by
induction pf with
| prim hf => exact hf.to_prim.to_comp
| comp _ _ _ hf hg => exact (Partrec.vector_mOfFn hg).bind (hf.comp snd)
| rfind _ hf =>
have := hf.comp (vector_cons.comp snd fst)
have :=
((Primrec.eq.decide.comp _root_.Primrec.id... | theorem | Computability | [
"Mathlib.Computability.PartrecCode",
"Mathlib.Data.Set.Subsingleton"
] | Mathlib/Computability/Halting.lean | to_part | null |
of_eq {n} {f g : List.Vector ℕ n →. ℕ} (hf : Partrec' f) (H : ∀ i, f i = g i) :
Partrec' g :=
(funext H : f = g) ▸ hf | theorem | Computability | [
"Mathlib.Computability.PartrecCode",
"Mathlib.Data.Set.Subsingleton"
] | Mathlib/Computability/Halting.lean | of_eq | null |
of_prim {n} {f : List.Vector ℕ n → ℕ} (hf : Primrec f) : @Partrec' n f :=
prim (Nat.Primrec'.of_prim hf) | theorem | Computability | [
"Mathlib.Computability.PartrecCode",
"Mathlib.Data.Set.Subsingleton"
] | Mathlib/Computability/Halting.lean | of_prim | null |
head {n : ℕ} : @Partrec' n.succ (@head ℕ n) :=
prim Nat.Primrec'.head | theorem | Computability | [
"Mathlib.Computability.PartrecCode",
"Mathlib.Data.Set.Subsingleton"
] | Mathlib/Computability/Halting.lean | head | null |
tail {n f} (hf : @Partrec' n f) : @Partrec' n.succ fun v => f v.tail :=
(hf.comp _ fun i => @prim _ _ <| Nat.Primrec'.get i.succ).of_eq fun v => by
simp; rw [← ofFn_get v.tail]; congr; funext i; simp | theorem | Computability | [
"Mathlib.Computability.PartrecCode",
"Mathlib.Data.Set.Subsingleton"
] | Mathlib/Computability/Halting.lean | tail | null |
protected bind {n f g} (hf : @Partrec' n f) (hg : @Partrec' (n + 1) g) :
@Partrec' n fun v => (f v).bind fun a => g (a ::ᵥ v) :=
(@comp n (n + 1) g (fun i => Fin.cases f (fun i v => some (v.get i)) i) hg fun i => by
refine Fin.cases ?_ (fun i => ?_) i <;> simp [*]
exact prim (Nat.Primrec'.get _)).of_e... | theorem | Computability | [
"Mathlib.Computability.PartrecCode",
"Mathlib.Data.Set.Subsingleton"
] | Mathlib/Computability/Halting.lean | bind | null |
protected map {n f} {g : List.Vector ℕ (n + 1) → ℕ} (hf : @Partrec' n f)
(hg : @Partrec' (n + 1) g) : @Partrec' n fun v => (f v).map fun a => g (a ::ᵥ v) := by
simpa [(Part.bind_some_eq_map _ _).symm] using hf.bind hg | theorem | Computability | [
"Mathlib.Computability.PartrecCode",
"Mathlib.Data.Set.Subsingleton"
] | Mathlib/Computability/Halting.lean | map | null |
Vec {n m} (f : List.Vector ℕ n → List.Vector ℕ m) :=
∀ i, Partrec' fun v => (f v).get i
nonrec theorem Vec.prim {n m f} (hf : @Nat.Primrec'.Vec n m f) : Vec f := fun i => prim <| hf i | def | Computability | [
"Mathlib.Computability.PartrecCode",
"Mathlib.Data.Set.Subsingleton"
] | Mathlib/Computability/Halting.lean | Vec | Analogous to `Nat.Partrec'` for `ℕ`-valued functions, a predicate for partial recursive
vector-valued functions. |
protected nil {n} : @Vec n 0 fun _ => nil := fun i => i.elim0 | theorem | Computability | [
"Mathlib.Computability.PartrecCode",
"Mathlib.Data.Set.Subsingleton"
] | Mathlib/Computability/Halting.lean | nil | null |
protected cons {n m} {f : List.Vector ℕ n → ℕ} {g} (hf : @Partrec' n f)
(hg : @Vec n m g) : Vec fun v => f v ::ᵥ g v := fun i =>
Fin.cases (by simpa using hf) (fun i => by simp only [hg i, get_cons_succ]) i | theorem | Computability | [
"Mathlib.Computability.PartrecCode",
"Mathlib.Data.Set.Subsingleton"
] | Mathlib/Computability/Halting.lean | cons | null |
idv {n} : @Vec n n id :=
Vec.prim Nat.Primrec'.idv | theorem | Computability | [
"Mathlib.Computability.PartrecCode",
"Mathlib.Data.Set.Subsingleton"
] | Mathlib/Computability/Halting.lean | idv | null |
comp' {n m f g} (hf : @Partrec' m f) (hg : @Vec n m g) : Partrec' fun v => f (g v) :=
(hf.comp _ hg).of_eq fun v => by simp | theorem | Computability | [
"Mathlib.Computability.PartrecCode",
"Mathlib.Data.Set.Subsingleton"
] | Mathlib/Computability/Halting.lean | comp' | null |
comp₁ {n} (f : ℕ →. ℕ) {g : List.Vector ℕ n → ℕ} (hf : @Partrec' 1 fun v => f v.head)
(hg : @Partrec' n g) : @Partrec' n fun v => f (g v) := by
simpa using hf.comp' (Partrec'.cons hg Partrec'.nil) | theorem | Computability | [
"Mathlib.Computability.PartrecCode",
"Mathlib.Data.Set.Subsingleton"
] | Mathlib/Computability/Halting.lean | comp₁ | null |
rfindOpt {n} {f : List.Vector ℕ (n + 1) → ℕ} (hf : @Partrec' (n + 1) f) :
@Partrec' n fun v => Nat.rfindOpt fun a => ofNat (Option ℕ) (f (a ::ᵥ v)) :=
((rfind <|
(of_prim (Primrec.nat_sub.comp (_root_.Primrec.const 1) Primrec.vector_head)).comp₁
(fun n => Part.some (1 - n)) hf).bind
((prim N... | theorem | Computability | [
"Mathlib.Computability.PartrecCode",
"Mathlib.Data.Set.Subsingleton"
] | Mathlib/Computability/Halting.lean | rfindOpt | null |
of_part : ∀ {n f}, _root_.Partrec f → @Partrec' n f :=
@(suffices ∀ f, Nat.Partrec f → @Partrec' 1 fun v => f v.head from fun {n f} hf => by
let g := fun n₁ =>
(Part.ofOption (decode (α := List.Vector ℕ n) n₁)).bind (fun a => Part.map encode (f a))
exact
(comp₁ g (this g hf) (prim Nat.Prim... | theorem | Computability | [
"Mathlib.Computability.PartrecCode",
"Mathlib.Data.Set.Subsingleton"
] | Mathlib/Computability/Halting.lean | of_part | null |
part_iff {n f} : @Partrec' n f ↔ _root_.Partrec f :=
⟨to_part, of_part⟩ | theorem | Computability | [
"Mathlib.Computability.PartrecCode",
"Mathlib.Data.Set.Subsingleton"
] | Mathlib/Computability/Halting.lean | part_iff | null |
part_iff₁ {f : ℕ →. ℕ} : (@Partrec' 1 fun v => f v.head) ↔ _root_.Partrec f :=
part_iff.trans
⟨fun h =>
(h.comp <| (Primrec.vector_ofFn fun _ => _root_.Primrec.id).to_comp).of_eq fun v => by
simp only [id, head_ofFn],
fun h => h.comp vector_head⟩ | theorem | Computability | [
"Mathlib.Computability.PartrecCode",
"Mathlib.Data.Set.Subsingleton"
] | Mathlib/Computability/Halting.lean | part_iff₁ | null |
part_iff₂ {f : ℕ → ℕ →. ℕ} : (@Partrec' 2 fun v => f v.head v.tail.head) ↔ Partrec₂ f :=
part_iff.trans
⟨fun h =>
(h.comp <| vector_cons.comp fst <| vector_cons.comp snd (const nil)).of_eq fun v => by
simp only [head_cons, tail_cons],
fun h => h.comp vector_head (vector_head.comp vector_tail)⟩ | theorem | Computability | [
"Mathlib.Computability.PartrecCode",
"Mathlib.Data.Set.Subsingleton"
] | Mathlib/Computability/Halting.lean | part_iff₂ | null |
vec_iff {m n f} : @Vec m n f ↔ Computable f :=
⟨fun h => by simpa only [ofFn_get] using vector_ofFn fun i => to_part (h i), fun h i =>
of_part <| vector_get.comp h (const i)⟩ | theorem | Computability | [
"Mathlib.Computability.PartrecCode",
"Mathlib.Data.Set.Subsingleton"
] | Mathlib/Computability/Halting.lean | vec_iff | null |
Language (α) :=
Set (List α) | def | Computability | [
"Mathlib.Algebra.Order.Kleene",
"Mathlib.Algebra.Ring.Hom.Defs",
"Mathlib.Data.Set.Lattice",
"Mathlib.Tactic.DeriveFintype"
] | Mathlib/Computability/Language.lean | Language | A language is a set of strings over an alphabet. |
instCompleteAtomicBooleanAlgebra : CompleteAtomicBooleanAlgebra (Language α) :=
Set.instCompleteAtomicBooleanAlgebra
variable {l m : Language α} {a b x : List α} | instance | Computability | [
"Mathlib.Algebra.Order.Kleene",
"Mathlib.Algebra.Ring.Hom.Defs",
"Mathlib.Data.Set.Lattice",
"Mathlib.Tactic.DeriveFintype"
] | Mathlib/Computability/Language.lean | instCompleteAtomicBooleanAlgebra | null |
map (f : α → β) : Language α →+* Language β where
toFun := image (List.map f)
map_zero' := image_empty _
map_one' := image_singleton
map_add' := image_union _
map_mul' _ _ := image_image2_distrib <| fun _ _ => map_append
@[simp] | def | Computability | [
"Mathlib.Algebra.Order.Kleene",
"Mathlib.Algebra.Ring.Hom.Defs",
"Mathlib.Data.Set.Lattice",
"Mathlib.Tactic.DeriveFintype"
] | Mathlib/Computability/Language.lean | map | Zero language has no elements. -/
instance : Zero (Language α) :=
⟨(∅ : Set _)⟩
/-- `1 : Language α` contains only one element `[]`. -/
instance : One (Language α) :=
⟨{[]}⟩
instance : Inhabited (Language α) := ⟨(∅ : Set _)⟩
/-- The sum of two languages is their union. -/
instance : Add (Language α) :=
⟨((· ∪ ... |
map_id (l : Language α) : map id l = l := by simp [map]
@[simp] | theorem | Computability | [
"Mathlib.Algebra.Order.Kleene",
"Mathlib.Algebra.Ring.Hom.Defs",
"Mathlib.Data.Set.Lattice",
"Mathlib.Tactic.DeriveFintype"
] | Mathlib/Computability/Language.lean | map_id | null |
map_map (g : β → γ) (f : α → β) (l : Language α) : map g (map f l) = map (g ∘ f) l := by
simp [map, image_image] | theorem | Computability | [
"Mathlib.Algebra.Order.Kleene",
"Mathlib.Algebra.Ring.Hom.Defs",
"Mathlib.Data.Set.Lattice",
"Mathlib.Tactic.DeriveFintype"
] | Mathlib/Computability/Language.lean | map_map | null |
mem_kstar_iff_exists_nonempty {x : List α} :
x ∈ l∗ ↔ ∃ S : List (List α), x = S.flatten ∧ ∀ y ∈ S, y ∈ l ∧ y ≠ [] := by
constructor
· rintro ⟨S, rfl, h⟩
refine ⟨S.filter fun l ↦ !List.isEmpty l,
by simp [List.flatten_filter_not_isEmpty], fun y hy ↦ ?_⟩
simp only [mem_filter, Bool.not_eq_eq_eq_not... | lemma | Computability | [
"Mathlib.Algebra.Order.Kleene",
"Mathlib.Algebra.Ring.Hom.Defs",
"Mathlib.Data.Set.Lattice",
"Mathlib.Tactic.DeriveFintype"
] | Mathlib/Computability/Language.lean | mem_kstar_iff_exists_nonempty | null |
kstar_def_nonempty (l : Language α) :
l∗ = { x | ∃ S : List (List α), x = S.flatten ∧ ∀ y ∈ S, y ∈ l ∧ y ≠ [] } := by
ext x; apply mem_kstar_iff_exists_nonempty | theorem | Computability | [
"Mathlib.Algebra.Order.Kleene",
"Mathlib.Algebra.Ring.Hom.Defs",
"Mathlib.Data.Set.Lattice",
"Mathlib.Tactic.DeriveFintype"
] | Mathlib/Computability/Language.lean | kstar_def_nonempty | null |
le_iff (l m : Language α) : l ≤ m ↔ l + m = m :=
sup_eq_right.symm | theorem | Computability | [
"Mathlib.Algebra.Order.Kleene",
"Mathlib.Algebra.Ring.Hom.Defs",
"Mathlib.Data.Set.Lattice",
"Mathlib.Tactic.DeriveFintype"
] | Mathlib/Computability/Language.lean | le_iff | null |
le_mul_congr {l₁ l₂ m₁ m₂ : Language α} : l₁ ≤ m₁ → l₂ ≤ m₂ → l₁ * l₂ ≤ m₁ * m₂ := by
intro h₁ h₂ x hx
simp only [mul_def, mem_image2] at hx ⊢
tauto | theorem | Computability | [
"Mathlib.Algebra.Order.Kleene",
"Mathlib.Algebra.Ring.Hom.Defs",
"Mathlib.Data.Set.Lattice",
"Mathlib.Tactic.DeriveFintype"
] | Mathlib/Computability/Language.lean | le_mul_congr | null |
le_add_congr {l₁ l₂ m₁ m₂ : Language α} : l₁ ≤ m₁ → l₂ ≤ m₂ → l₁ + l₂ ≤ m₁ + m₂ :=
sup_le_sup | theorem | Computability | [
"Mathlib.Algebra.Order.Kleene",
"Mathlib.Algebra.Ring.Hom.Defs",
"Mathlib.Data.Set.Lattice",
"Mathlib.Tactic.DeriveFintype"
] | Mathlib/Computability/Language.lean | le_add_congr | null |
mem_iSup {ι : Sort v} {l : ι → Language α} {x : List α} : (x ∈ ⨆ i, l i) ↔ ∃ i, x ∈ l i :=
mem_iUnion | theorem | Computability | [
"Mathlib.Algebra.Order.Kleene",
"Mathlib.Algebra.Ring.Hom.Defs",
"Mathlib.Data.Set.Lattice",
"Mathlib.Tactic.DeriveFintype"
] | Mathlib/Computability/Language.lean | mem_iSup | null |
iSup_mul {ι : Sort v} (l : ι → Language α) (m : Language α) :
(⨆ i, l i) * m = ⨆ i, l i * m :=
image2_iUnion_left _ _ _ | theorem | Computability | [
"Mathlib.Algebra.Order.Kleene",
"Mathlib.Algebra.Ring.Hom.Defs",
"Mathlib.Data.Set.Lattice",
"Mathlib.Tactic.DeriveFintype"
] | Mathlib/Computability/Language.lean | iSup_mul | null |
mul_iSup {ι : Sort v} (l : ι → Language α) (m : Language α) :
(m * ⨆ i, l i) = ⨆ i, m * l i :=
image2_iUnion_right _ _ _ | theorem | Computability | [
"Mathlib.Algebra.Order.Kleene",
"Mathlib.Algebra.Ring.Hom.Defs",
"Mathlib.Data.Set.Lattice",
"Mathlib.Tactic.DeriveFintype"
] | Mathlib/Computability/Language.lean | mul_iSup | null |
iSup_add {ι : Sort v} [Nonempty ι] (l : ι → Language α) (m : Language α) :
(⨆ i, l i) + m = ⨆ i, l i + m :=
iSup_sup | theorem | Computability | [
"Mathlib.Algebra.Order.Kleene",
"Mathlib.Algebra.Ring.Hom.Defs",
"Mathlib.Data.Set.Lattice",
"Mathlib.Tactic.DeriveFintype"
] | Mathlib/Computability/Language.lean | iSup_add | null |
add_iSup {ι : Sort v} [Nonempty ι] (l : ι → Language α) (m : Language α) :
(m + ⨆ i, l i) = ⨆ i, m + l i :=
sup_iSup | theorem | Computability | [
"Mathlib.Algebra.Order.Kleene",
"Mathlib.Algebra.Ring.Hom.Defs",
"Mathlib.Data.Set.Lattice",
"Mathlib.Tactic.DeriveFintype"
] | Mathlib/Computability/Language.lean | add_iSup | null |
mem_pow {l : Language α} {x : List α} {n : ℕ} :
x ∈ l ^ n ↔ ∃ S : List (List α), x = S.flatten ∧ S.length = n ∧ ∀ y ∈ S, y ∈ l := by
induction n generalizing x with
| zero => simp
| succ n ihn =>
simp only [pow_succ', mem_mul, ihn]
constructor
· rintro ⟨a, ha, b, ⟨S, rfl, rfl, hS⟩, rfl⟩
exac... | theorem | Computability | [
"Mathlib.Algebra.Order.Kleene",
"Mathlib.Algebra.Ring.Hom.Defs",
"Mathlib.Data.Set.Lattice",
"Mathlib.Tactic.DeriveFintype"
] | Mathlib/Computability/Language.lean | mem_pow | null |
kstar_eq_iSup_pow (l : Language α) : l∗ = ⨆ i : ℕ, l ^ i := by
ext x
simp only [mem_kstar, mem_iSup, mem_pow]
grind
@[simp] | theorem | Computability | [
"Mathlib.Algebra.Order.Kleene",
"Mathlib.Algebra.Ring.Hom.Defs",
"Mathlib.Data.Set.Lattice",
"Mathlib.Tactic.DeriveFintype"
] | Mathlib/Computability/Language.lean | kstar_eq_iSup_pow | null |
map_kstar (f : α → β) (l : Language α) : map f l∗ = (map f l)∗ := by
rw [kstar_eq_iSup_pow, kstar_eq_iSup_pow]
simp_rw [← map_pow]
exact image_iUnion | theorem | Computability | [
"Mathlib.Algebra.Order.Kleene",
"Mathlib.Algebra.Ring.Hom.Defs",
"Mathlib.Data.Set.Lattice",
"Mathlib.Tactic.DeriveFintype"
] | Mathlib/Computability/Language.lean | map_kstar | null |
mul_self_kstar_comm (l : Language α) : l∗ * l = l * l∗ := by
simp only [kstar_eq_iSup_pow, mul_iSup, iSup_mul, ← pow_succ, ← pow_succ']
@[simp] | theorem | Computability | [
"Mathlib.Algebra.Order.Kleene",
"Mathlib.Algebra.Ring.Hom.Defs",
"Mathlib.Data.Set.Lattice",
"Mathlib.Tactic.DeriveFintype"
] | Mathlib/Computability/Language.lean | mul_self_kstar_comm | null |
one_add_self_mul_kstar_eq_kstar (l : Language α) : 1 + l * l∗ = l∗ := by
simp only [kstar_eq_iSup_pow, mul_iSup, ← pow_succ', ← pow_zero l]
exact sup_iSup_nat_succ _
@[simp] | theorem | Computability | [
"Mathlib.Algebra.Order.Kleene",
"Mathlib.Algebra.Ring.Hom.Defs",
"Mathlib.Data.Set.Lattice",
"Mathlib.Tactic.DeriveFintype"
] | Mathlib/Computability/Language.lean | one_add_self_mul_kstar_eq_kstar | null |
one_add_kstar_mul_self_eq_kstar (l : Language α) : 1 + l∗ * l = l∗ := by
rw [mul_self_kstar_comm, 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 | one_add_kstar_mul_self_eq_kstar | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.