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 ⌀ |
|---|---|---|---|---|---|---|
trNat_natEnd (n) : ∀ x ∈ trNat n, natEnd x = false :=
trNum_natEnd _ | theorem | Computability | [
"Mathlib.Computability.Halting",
"Mathlib.Computability.TuringMachine",
"Mathlib.Data.Num.Lemmas",
"Mathlib.Tactic.DeriveFintype",
"Mathlib.Computability.TMConfig"
] | Mathlib/Computability/TMToPartrec.lean | trNat_natEnd | null |
trList_ne_consₗ : ∀ (l), ∀ x ∈ trList l, x ≠ Γ'.consₗ
| a :: l, x, h => by
simp only [trList, List.mem_append, List.mem_cons] at h
obtain h | rfl | h := h
· rintro rfl
cases trNat_natEnd _ _ h
· rintro ⟨⟩
· exact trList_ne_consₗ l _ h | theorem | Computability | [
"Mathlib.Computability.Halting",
"Mathlib.Computability.TuringMachine",
"Mathlib.Data.Num.Lemmas",
"Mathlib.Tactic.DeriveFintype",
"Mathlib.Computability.TMConfig"
] | Mathlib/Computability/TMToPartrec.lean | trList_ne_consₗ | null |
head_main_ok {q s L} {c d : List Γ'} :
Reaches₁ (TM2.step tr) ⟨some (head main q), s, K'.elim (trList L) [] c d⟩
⟨some q, none, K'.elim (trList [L.headI]) [] c d⟩ := by
let o : Option Γ' := List.casesOn L none fun _ _ => some Γ'.cons
refine
(move_ok (by decide)
(splitAtPred_eq _ _ (trNat L.h... | theorem | Computability | [
"Mathlib.Computability.Halting",
"Mathlib.Computability.TuringMachine",
"Mathlib.Data.Num.Lemmas",
"Mathlib.Tactic.DeriveFintype",
"Mathlib.Computability.TMConfig"
] | Mathlib/Computability/TMToPartrec.lean | head_main_ok | null |
head_stack_ok {q s L₁ L₂ L₃} :
Reaches₁ (TM2.step tr)
⟨some (head stack q), s, K'.elim (trList L₁) [] [] (trList L₂ ++ Γ'.consₗ :: L₃)⟩
⟨some q, none, K'.elim (trList (L₂.headI :: L₁)) [] [] L₃⟩ := by
rcases L₂ with - | ⟨a, L₂⟩
· refine
TransGen.trans
(move_ok (by decide)
(sp... | theorem | Computability | [
"Mathlib.Computability.Halting",
"Mathlib.Computability.TuringMachine",
"Mathlib.Data.Num.Lemmas",
"Mathlib.Tactic.DeriveFintype",
"Mathlib.Computability.TMConfig"
] | Mathlib/Computability/TMToPartrec.lean | head_stack_ok | null |
succ_ok {q s n} {c d : List Γ'} :
Reaches₁ (TM2.step tr) ⟨some (Λ'.succ q), s, K'.elim (trList [n]) [] c d⟩
⟨some q, none, K'.elim (trList [n.succ]) [] c d⟩ := by
simp only [trList, trNat.eq_1, Nat.cast_succ, Num.add_one]
rcases (n : Num) with - | a
· refine TransGen.head rfl ?_
simp only [Option.me... | theorem | Computability | [
"Mathlib.Computability.Halting",
"Mathlib.Computability.TuringMachine",
"Mathlib.Data.Num.Lemmas",
"Mathlib.Tactic.DeriveFintype",
"Mathlib.Computability.TMConfig"
] | Mathlib/Computability/TMToPartrec.lean | succ_ok | null |
pred_ok (q₁ q₂ s v) (c d : List Γ') : ∃ s',
Reaches₁ (TM2.step tr) ⟨some (Λ'.pred q₁ q₂), s, K'.elim (trList v) [] c d⟩
(v.headI.rec ⟨some q₁, s', K'.elim (trList v.tail) [] c d⟩ fun n _ =>
⟨some q₂, s', K'.elim (trList (n::v.tail)) [] c d⟩) := by
rcases v with (_ | ⟨_ | n, v⟩)
· refine ⟨none, Tra... | theorem | Computability | [
"Mathlib.Computability.Halting",
"Mathlib.Computability.TuringMachine",
"Mathlib.Data.Num.Lemmas",
"Mathlib.Tactic.DeriveFintype",
"Mathlib.Computability.TMConfig"
] | Mathlib/Computability/TMToPartrec.lean | pred_ok | null |
trNormal_respects (c k v s) :
∃ b₂,
TrCfg (stepNormal c k v) b₂ ∧
Reaches₁ (TM2.step tr)
⟨some (trNormal c (trCont k)), s, K'.elim (trList v) [] [] (trContStack k)⟩ b₂ := by
induction c generalizing k v s with
| zero' => refine ⟨_, ⟨s, rfl⟩, TransGen.single ?_⟩; simp
| succ => refine ⟨... | theorem | Computability | [
"Mathlib.Computability.Halting",
"Mathlib.Computability.TuringMachine",
"Mathlib.Data.Num.Lemmas",
"Mathlib.Tactic.DeriveFintype",
"Mathlib.Computability.TMConfig"
] | Mathlib/Computability/TMToPartrec.lean | trNormal_respects | null |
tr_ret_respects (k v s) : ∃ b₂,
TrCfg (stepRet k v) b₂ ∧
Reaches₁ (TM2.step tr)
⟨some (Λ'.ret (trCont k)), s, K'.elim (trList v) [] [] (trContStack k)⟩ b₂ := by
induction k generalizing v s with
| halt => exact ⟨_, rfl, TransGen.single rfl⟩
| cons₁ fs as k _ =>
obtain ⟨s', h₁, h₂⟩ := trNorma... | theorem | Computability | [
"Mathlib.Computability.Halting",
"Mathlib.Computability.TuringMachine",
"Mathlib.Data.Num.Lemmas",
"Mathlib.Tactic.DeriveFintype",
"Mathlib.Computability.TMConfig"
] | Mathlib/Computability/TMToPartrec.lean | tr_ret_respects | null |
tr_respects : Respects step (TM2.step tr) TrCfg
| Cfg.ret _ _, _, ⟨_, rfl⟩ => tr_ret_respects _ _ _
| Cfg.halt _, _, rfl => rfl | theorem | Computability | [
"Mathlib.Computability.Halting",
"Mathlib.Computability.TuringMachine",
"Mathlib.Data.Num.Lemmas",
"Mathlib.Tactic.DeriveFintype",
"Mathlib.Computability.TMConfig"
] | Mathlib/Computability/TMToPartrec.lean | tr_respects | null |
init (c : Code) (v : List ℕ) : Cfg' :=
⟨some (trNormal c Cont'.halt), none, K'.elim (trList v) [] [] []⟩ | def | Computability | [
"Mathlib.Computability.Halting",
"Mathlib.Computability.TuringMachine",
"Mathlib.Data.Num.Lemmas",
"Mathlib.Tactic.DeriveFintype",
"Mathlib.Computability.TMConfig"
] | Mathlib/Computability/TMToPartrec.lean | init | The initial state, evaluating function `c` on input `v`. |
tr_init (c v) :
∃ b, TrCfg (stepNormal c Cont.halt v) b ∧ Reaches₁ (TM2.step tr) (init c v) b :=
trNormal_respects _ _ _ _ | theorem | Computability | [
"Mathlib.Computability.Halting",
"Mathlib.Computability.TuringMachine",
"Mathlib.Data.Num.Lemmas",
"Mathlib.Tactic.DeriveFintype",
"Mathlib.Computability.TMConfig"
] | Mathlib/Computability/TMToPartrec.lean | tr_init | null |
tr_eval (c v) : eval (TM2.step tr) (init c v) = halt <$> Code.eval c v := by
obtain ⟨i, h₁, h₂⟩ := tr_init c v
refine Part.ext fun x => ?_
rw [reaches_eval h₂.to_reflTransGen]; simp only [Part.map_eq_map, Part.mem_map_iff]
refine ⟨fun h => ?_, ?_⟩
· obtain ⟨c, hc₁, hc₂⟩ := tr_eval_rev tr_respects h₁ h
sim... | theorem | Computability | [
"Mathlib.Computability.Halting",
"Mathlib.Computability.TuringMachine",
"Mathlib.Data.Num.Lemmas",
"Mathlib.Tactic.DeriveFintype",
"Mathlib.Computability.TMConfig"
] | Mathlib/Computability/TMToPartrec.lean | tr_eval | null |
trStmts₁ : Λ' → Finset Λ'
| Q@(Λ'.move _ _ _ q) => insert Q <| trStmts₁ q
| Q@(Λ'.push _ _ q) => insert Q <| trStmts₁ q
| Q@(Λ'.read q) => insert Q <| Finset.univ.biUnion fun s => trStmts₁ (q s)
| Q@(Λ'.clear _ _ q) => insert Q <| trStmts₁ q
| Q@(Λ'.copy q) => insert Q <| trStmts₁ q
| Q@(Λ'.succ q) => inser... | def | Computability | [
"Mathlib.Computability.Halting",
"Mathlib.Computability.TuringMachine",
"Mathlib.Data.Num.Lemmas",
"Mathlib.Tactic.DeriveFintype",
"Mathlib.Computability.TMConfig"
] | Mathlib/Computability/TMToPartrec.lean | trStmts₁ | The set of machine states reachable via downward label jumps, discounting jumps via `ret`. |
trStmts₁_trans {q q'} : q' ∈ trStmts₁ q → trStmts₁ q' ⊆ trStmts₁ q := by
induction q with
| move _ _ _ q q_ih => _ | clear _ _ q q_ih => _ | copy q q_ih => _ | push _ _ q q_ih => _
| read q q_ih => _ | succ q q_ih => _ | pred q₁ q₂ q₁_ih q₂_ih => _ | ret => _ <;>
all_goals
simp +contextual only [trStmts₁, F... | theorem | Computability | [
"Mathlib.Computability.Halting",
"Mathlib.Computability.TuringMachine",
"Mathlib.Data.Num.Lemmas",
"Mathlib.Tactic.DeriveFintype",
"Mathlib.Computability.TMConfig"
] | Mathlib/Computability/TMToPartrec.lean | trStmts₁_trans | null |
trStmts₁_self (q) : q ∈ trStmts₁ q := by
induction q <;> · first |apply Finset.mem_singleton_self|apply Finset.mem_insert_self | theorem | Computability | [
"Mathlib.Computability.Halting",
"Mathlib.Computability.TuringMachine",
"Mathlib.Data.Num.Lemmas",
"Mathlib.Tactic.DeriveFintype",
"Mathlib.Computability.TMConfig"
] | Mathlib/Computability/TMToPartrec.lean | trStmts₁_self | null |
codeSupp' : Code → Cont' → Finset Λ'
| c@Code.zero', k => trStmts₁ (trNormal c k)
| c@Code.succ, k => trStmts₁ (trNormal c k)
| c@Code.tail, k => trStmts₁ (trNormal c k)
| c@(Code.cons f fs), k =>
trStmts₁ (trNormal c k) ∪
(codeSupp' f (Cont'.cons₁ fs k) ∪
(trStmts₁
(move₂ (fun _ =... | def | Computability | [
"Mathlib.Computability.Halting",
"Mathlib.Computability.TuringMachine",
"Mathlib.Data.Num.Lemmas",
"Mathlib.Tactic.DeriveFintype",
"Mathlib.Computability.TMConfig"
] | Mathlib/Computability/TMToPartrec.lean | codeSupp' | The (finite!) set of machine states visited during the course of evaluation of `c`,
including the state `ret k` but not any states after that (that is, the states visited while
evaluating `k`). |
codeSupp'_self (c k) : trStmts₁ (trNormal c k) ⊆ codeSupp' c k := by
cases c <;> first | rfl | exact Finset.union_subset_left (fun _ a ↦ a) | theorem | Computability | [
"Mathlib.Computability.Halting",
"Mathlib.Computability.TuringMachine",
"Mathlib.Data.Num.Lemmas",
"Mathlib.Tactic.DeriveFintype",
"Mathlib.Computability.TMConfig"
] | Mathlib/Computability/TMToPartrec.lean | codeSupp'_self | null |
contSupp : Cont' → Finset Λ'
| Cont'.cons₁ fs k =>
trStmts₁
(move₂ (fun _ => false) main aux <|
move₂ (fun s => s = Γ'.consₗ) stack main <|
move₂ (fun _ => false) aux stack <| trNormal fs (Cont'.cons₂ k)) ∪
(codeSupp' fs (Cont'.cons₂ k) ∪ (trStmts₁ (head stack <| Λ'.ret k) ∪ co... | def | Computability | [
"Mathlib.Computability.Halting",
"Mathlib.Computability.TuringMachine",
"Mathlib.Data.Num.Lemmas",
"Mathlib.Tactic.DeriveFintype",
"Mathlib.Computability.TMConfig"
] | Mathlib/Computability/TMToPartrec.lean | contSupp | The (finite!) set of machine states visited during the course of evaluation of a continuation
`k`, not including the initial state `ret k`. |
codeSupp (c : Code) (k : Cont') : Finset Λ' :=
codeSupp' c k ∪ contSupp k
@[simp] | def | Computability | [
"Mathlib.Computability.Halting",
"Mathlib.Computability.TuringMachine",
"Mathlib.Data.Num.Lemmas",
"Mathlib.Tactic.DeriveFintype",
"Mathlib.Computability.TMConfig"
] | Mathlib/Computability/TMToPartrec.lean | codeSupp | The (finite!) set of machine states visited during the course of evaluation of `c` in
continuation `k`. This is actually closed under forward simulation (see `tr_supports`), and the
existence of this set means that the machine constructed in this section is in fact a proper
Turing machine, with a finite set of states. |
codeSupp_self (c k) : trStmts₁ (trNormal c k) ⊆ codeSupp c k :=
Finset.Subset.trans (codeSupp'_self _ _) (Finset.union_subset_left fun _ a ↦ a)
@[simp] | theorem | Computability | [
"Mathlib.Computability.Halting",
"Mathlib.Computability.TuringMachine",
"Mathlib.Data.Num.Lemmas",
"Mathlib.Tactic.DeriveFintype",
"Mathlib.Computability.TMConfig"
] | Mathlib/Computability/TMToPartrec.lean | codeSupp_self | null |
codeSupp_zero (k) : codeSupp Code.zero' k = trStmts₁ (trNormal Code.zero' k) ∪ contSupp k :=
rfl
@[simp] | theorem | Computability | [
"Mathlib.Computability.Halting",
"Mathlib.Computability.TuringMachine",
"Mathlib.Data.Num.Lemmas",
"Mathlib.Tactic.DeriveFintype",
"Mathlib.Computability.TMConfig"
] | Mathlib/Computability/TMToPartrec.lean | codeSupp_zero | null |
codeSupp_succ (k) : codeSupp Code.succ k = trStmts₁ (trNormal Code.succ k) ∪ contSupp k :=
rfl
@[simp] | theorem | Computability | [
"Mathlib.Computability.Halting",
"Mathlib.Computability.TuringMachine",
"Mathlib.Data.Num.Lemmas",
"Mathlib.Tactic.DeriveFintype",
"Mathlib.Computability.TMConfig"
] | Mathlib/Computability/TMToPartrec.lean | codeSupp_succ | null |
codeSupp_tail (k) : codeSupp Code.tail k = trStmts₁ (trNormal Code.tail k) ∪ contSupp k :=
rfl
@[simp] | theorem | Computability | [
"Mathlib.Computability.Halting",
"Mathlib.Computability.TuringMachine",
"Mathlib.Data.Num.Lemmas",
"Mathlib.Tactic.DeriveFintype",
"Mathlib.Computability.TMConfig"
] | Mathlib/Computability/TMToPartrec.lean | codeSupp_tail | null |
codeSupp_cons (f fs k) :
codeSupp (Code.cons f fs) k =
trStmts₁ (trNormal (Code.cons f fs) k) ∪ codeSupp f (Cont'.cons₁ fs k) := by
simp [codeSupp, codeSupp', contSupp, Finset.union_assoc]
@[simp] | theorem | Computability | [
"Mathlib.Computability.Halting",
"Mathlib.Computability.TuringMachine",
"Mathlib.Data.Num.Lemmas",
"Mathlib.Tactic.DeriveFintype",
"Mathlib.Computability.TMConfig"
] | Mathlib/Computability/TMToPartrec.lean | codeSupp_cons | null |
codeSupp_comp (f g k) :
codeSupp (Code.comp f g) k =
trStmts₁ (trNormal (Code.comp f g) k) ∪ codeSupp g (Cont'.comp f k) := by
simp only [codeSupp, codeSupp', trNormal, Finset.union_assoc, contSupp]
rw [← Finset.union_assoc _ _ (contSupp k),
Finset.union_eq_right.2 (codeSupp'_self _ _)]
@[simp] | theorem | Computability | [
"Mathlib.Computability.Halting",
"Mathlib.Computability.TuringMachine",
"Mathlib.Data.Num.Lemmas",
"Mathlib.Tactic.DeriveFintype",
"Mathlib.Computability.TMConfig"
] | Mathlib/Computability/TMToPartrec.lean | codeSupp_comp | null |
codeSupp_case (f g k) :
codeSupp (Code.case f g) k =
trStmts₁ (trNormal (Code.case f g) k) ∪ (codeSupp f k ∪ codeSupp g k) := by
simp [codeSupp, codeSupp', Finset.union_assoc, Finset.union_left_comm]
@[simp] | theorem | Computability | [
"Mathlib.Computability.Halting",
"Mathlib.Computability.TuringMachine",
"Mathlib.Data.Num.Lemmas",
"Mathlib.Tactic.DeriveFintype",
"Mathlib.Computability.TMConfig"
] | Mathlib/Computability/TMToPartrec.lean | codeSupp_case | null |
codeSupp_fix (f k) :
codeSupp (Code.fix f) k = trStmts₁ (trNormal (Code.fix f) k) ∪ codeSupp f (Cont'.fix f k) := by
simp [codeSupp, codeSupp', contSupp, Finset.union_assoc, Finset.union_left_comm,
Finset.union_left_idem]
@[simp] | theorem | Computability | [
"Mathlib.Computability.Halting",
"Mathlib.Computability.TuringMachine",
"Mathlib.Data.Num.Lemmas",
"Mathlib.Tactic.DeriveFintype",
"Mathlib.Computability.TMConfig"
] | Mathlib/Computability/TMToPartrec.lean | codeSupp_fix | null |
contSupp_cons₁ (fs k) :
contSupp (Cont'.cons₁ fs k) =
trStmts₁
(move₂ (fun _ => false) main aux <|
move₂ (fun s => s = Γ'.consₗ) stack main <|
move₂ (fun _ => false) aux stack <| trNormal fs (Cont'.cons₂ k)) ∪
codeSupp fs (Cont'.cons₂ k) := by
simp [codeSupp, cont... | theorem | Computability | [
"Mathlib.Computability.Halting",
"Mathlib.Computability.TuringMachine",
"Mathlib.Data.Num.Lemmas",
"Mathlib.Tactic.DeriveFintype",
"Mathlib.Computability.TMConfig"
] | Mathlib/Computability/TMToPartrec.lean | contSupp_cons₁ | null |
contSupp_cons₂ (k) :
contSupp (Cont'.cons₂ k) = trStmts₁ (head stack <| Λ'.ret k) ∪ contSupp k :=
rfl
@[simp] | theorem | Computability | [
"Mathlib.Computability.Halting",
"Mathlib.Computability.TuringMachine",
"Mathlib.Data.Num.Lemmas",
"Mathlib.Tactic.DeriveFintype",
"Mathlib.Computability.TMConfig"
] | Mathlib/Computability/TMToPartrec.lean | contSupp_cons₂ | null |
contSupp_comp (f k) : contSupp (Cont'.comp f k) = codeSupp f k :=
rfl | theorem | Computability | [
"Mathlib.Computability.Halting",
"Mathlib.Computability.TuringMachine",
"Mathlib.Data.Num.Lemmas",
"Mathlib.Tactic.DeriveFintype",
"Mathlib.Computability.TMConfig"
] | Mathlib/Computability/TMToPartrec.lean | contSupp_comp | null |
contSupp_fix (f k) : contSupp (Cont'.fix f k) = codeSupp f (Cont'.fix f k) := by
simp +contextual [codeSupp, codeSupp', contSupp, Finset.union_assoc,
Finset.subset_iff, -Finset.singleton_union, -Finset.union_singleton]
@[simp] | theorem | Computability | [
"Mathlib.Computability.Halting",
"Mathlib.Computability.TuringMachine",
"Mathlib.Data.Num.Lemmas",
"Mathlib.Tactic.DeriveFintype",
"Mathlib.Computability.TMConfig"
] | Mathlib/Computability/TMToPartrec.lean | contSupp_fix | null |
contSupp_halt : contSupp Cont'.halt = ∅ :=
rfl | theorem | Computability | [
"Mathlib.Computability.Halting",
"Mathlib.Computability.TuringMachine",
"Mathlib.Data.Num.Lemmas",
"Mathlib.Tactic.DeriveFintype",
"Mathlib.Computability.TMConfig"
] | Mathlib/Computability/TMToPartrec.lean | contSupp_halt | null |
Λ'.Supports (S : Finset Λ') : Λ' → Prop
| Λ'.move _ _ _ q => Λ'.Supports S q
| Λ'.push _ _ q => Λ'.Supports S q
| Λ'.read q => ∀ s, Λ'.Supports S (q s)
| Λ'.clear _ _ q => Λ'.Supports S q
| Λ'.copy q => Λ'.Supports S q
| Λ'.succ q => Λ'.Supports S q
| Λ'.pred q₁ q₂ => Λ'.Supports S q₁ ∧ Λ'.Supports S q₂
... | def | Computability | [
"Mathlib.Computability.Halting",
"Mathlib.Computability.TuringMachine",
"Mathlib.Data.Num.Lemmas",
"Mathlib.Tactic.DeriveFintype",
"Mathlib.Computability.TMConfig"
] | Mathlib/Computability/TMToPartrec.lean | Λ'.Supports | The statement `Λ'.Supports S q` means that `contSupp k ⊆ S` for any `ret k`
reachable from `q`.
(This is a technical condition used in the proof that the machine is supported.) |
Supports (K S : Finset Λ') :=
∀ q ∈ K, TM2.SupportsStmt S (tr q) | def | Computability | [
"Mathlib.Computability.Halting",
"Mathlib.Computability.TuringMachine",
"Mathlib.Data.Num.Lemmas",
"Mathlib.Tactic.DeriveFintype",
"Mathlib.Computability.TMConfig"
] | Mathlib/Computability/TMToPartrec.lean | Supports | A shorthand for the predicate that we are proving in the main theorems `trStmts₁_supports`,
`codeSupp'_supports`, `contSupp_supports`, `codeSupp_supports`. The set `S` is fixed throughout
the proof, and denotes the full set of states in the machine, while `K` is a subset that we are
currently proving a property about. ... |
supports_insert {K S q} :
Supports (insert q K) S ↔ TM2.SupportsStmt S (tr q) ∧ Supports K S := by simp [Supports] | theorem | Computability | [
"Mathlib.Computability.Halting",
"Mathlib.Computability.TuringMachine",
"Mathlib.Data.Num.Lemmas",
"Mathlib.Tactic.DeriveFintype",
"Mathlib.Computability.TMConfig"
] | Mathlib/Computability/TMToPartrec.lean | supports_insert | null |
supports_singleton {S q} : Supports {q} S ↔ TM2.SupportsStmt S (tr q) := by simp [Supports] | theorem | Computability | [
"Mathlib.Computability.Halting",
"Mathlib.Computability.TuringMachine",
"Mathlib.Data.Num.Lemmas",
"Mathlib.Tactic.DeriveFintype",
"Mathlib.Computability.TMConfig"
] | Mathlib/Computability/TMToPartrec.lean | supports_singleton | null |
supports_union {K₁ K₂ S} : Supports (K₁ ∪ K₂) S ↔ Supports K₁ S ∧ Supports K₂ S := by
simp [Supports, or_imp, forall_and] | theorem | Computability | [
"Mathlib.Computability.Halting",
"Mathlib.Computability.TuringMachine",
"Mathlib.Data.Num.Lemmas",
"Mathlib.Tactic.DeriveFintype",
"Mathlib.Computability.TMConfig"
] | Mathlib/Computability/TMToPartrec.lean | supports_union | null |
supports_biUnion {K : Option Γ' → Finset Λ'} {S} :
Supports (Finset.univ.biUnion K) S ↔ ∀ a, Supports (K a) S := by
simpa [Supports] using forall_swap | theorem | Computability | [
"Mathlib.Computability.Halting",
"Mathlib.Computability.TuringMachine",
"Mathlib.Data.Num.Lemmas",
"Mathlib.Tactic.DeriveFintype",
"Mathlib.Computability.TMConfig"
] | Mathlib/Computability/TMToPartrec.lean | supports_biUnion | null |
head_supports {S k q} (H : (q : Λ').Supports S) : (head k q).Supports S := fun _ => by
dsimp only; split_ifs <;> exact H | theorem | Computability | [
"Mathlib.Computability.Halting",
"Mathlib.Computability.TuringMachine",
"Mathlib.Data.Num.Lemmas",
"Mathlib.Tactic.DeriveFintype",
"Mathlib.Computability.TMConfig"
] | Mathlib/Computability/TMToPartrec.lean | head_supports | null |
ret_supports {S k} (H₁ : contSupp k ⊆ S) : TM2.SupportsStmt S (tr (Λ'.ret k)) := by
have W := fun {q} => trStmts₁_self q
cases k with
| halt => trivial
| cons₁ => rw [contSupp_cons₁, Finset.union_subset_iff] at H₁; exact fun _ => H₁.1 W
| cons₂ => rw [contSupp_cons₂, Finset.union_subset_iff] at H₁; exact fun ... | theorem | Computability | [
"Mathlib.Computability.Halting",
"Mathlib.Computability.TuringMachine",
"Mathlib.Data.Num.Lemmas",
"Mathlib.Tactic.DeriveFintype",
"Mathlib.Computability.TMConfig"
] | Mathlib/Computability/TMToPartrec.lean | ret_supports | null |
trStmts₁_supports {S q} (H₁ : (q : Λ').Supports S) (HS₁ : trStmts₁ q ⊆ S) :
Supports (trStmts₁ q) S := by
have W := fun {q} => trStmts₁_self q
induction q with
| move _ _ _ q q_ih => _ | clear _ _ q q_ih => _ | copy q q_ih => _ | push _ _ q q_ih => _
| read q q_ih => _ | succ q q_ih => _ | pred q₁ q₂ q₁_ih ... | theorem | Computability | [
"Mathlib.Computability.Halting",
"Mathlib.Computability.TuringMachine",
"Mathlib.Data.Num.Lemmas",
"Mathlib.Tactic.DeriveFintype",
"Mathlib.Computability.TMConfig"
] | Mathlib/Computability/TMToPartrec.lean | trStmts₁_supports | null |
trStmts₁_supports' {S q K} (H₁ : (q : Λ').Supports S) (H₂ : trStmts₁ q ∪ K ⊆ S)
(H₃ : K ⊆ S → Supports K S) : Supports (trStmts₁ q ∪ K) S := by
simp only [Finset.union_subset_iff] at H₂
exact supports_union.2 ⟨trStmts₁_supports H₁ H₂.1, H₃ H₂.2⟩ | theorem | Computability | [
"Mathlib.Computability.Halting",
"Mathlib.Computability.TuringMachine",
"Mathlib.Data.Num.Lemmas",
"Mathlib.Tactic.DeriveFintype",
"Mathlib.Computability.TMConfig"
] | Mathlib/Computability/TMToPartrec.lean | trStmts₁_supports' | null |
trNormal_supports {S c k} (Hk : codeSupp c k ⊆ S) : (trNormal c k).Supports S := by
induction c generalizing k with simp [Λ'.Supports, head]
| zero' => exact Finset.union_subset_right Hk
| succ => intro; split_ifs <;> exact Finset.union_subset_right Hk
| tail => exact Finset.union_subset_right Hk
| cons f fs ... | theorem | Computability | [
"Mathlib.Computability.Halting",
"Mathlib.Computability.TuringMachine",
"Mathlib.Data.Num.Lemmas",
"Mathlib.Tactic.DeriveFintype",
"Mathlib.Computability.TMConfig"
] | Mathlib/Computability/TMToPartrec.lean | trNormal_supports | null |
codeSupp'_supports {S c k} (H : codeSupp c k ⊆ S) : Supports (codeSupp' c k) S := by
induction c generalizing k with
| cons f fs IHf IHfs =>
have H' := H; simp only [codeSupp_cons, Finset.union_subset_iff] at H'
refine trStmts₁_supports' (trNormal_supports H) (Finset.union_subset_left H) fun h => ?_
ref... | theorem | Computability | [
"Mathlib.Computability.Halting",
"Mathlib.Computability.TuringMachine",
"Mathlib.Data.Num.Lemmas",
"Mathlib.Tactic.DeriveFintype",
"Mathlib.Computability.TMConfig"
] | Mathlib/Computability/TMToPartrec.lean | codeSupp'_supports | null |
contSupp_supports {S k} (H : contSupp k ⊆ S) : Supports (contSupp k) S := by
induction k with
| halt => simp [contSupp_halt, Supports]
| cons₁ f k IH =>
have H₁ := H; rw [contSupp_cons₁] at H₁; have H₂ := Finset.union_subset_right H₁
refine trStmts₁_supports' (trNormal_supports H₂) H₁ fun h => ?_
refi... | theorem | Computability | [
"Mathlib.Computability.Halting",
"Mathlib.Computability.TuringMachine",
"Mathlib.Data.Num.Lemmas",
"Mathlib.Tactic.DeriveFintype",
"Mathlib.Computability.TMConfig"
] | Mathlib/Computability/TMToPartrec.lean | contSupp_supports | null |
codeSupp_supports {S c k} (H : codeSupp c k ⊆ S) : Supports (codeSupp c k) S :=
supports_union.2 ⟨codeSupp'_supports H, contSupp_supports (Finset.union_subset_right H)⟩ | theorem | Computability | [
"Mathlib.Computability.Halting",
"Mathlib.Computability.TuringMachine",
"Mathlib.Data.Num.Lemmas",
"Mathlib.Tactic.DeriveFintype",
"Mathlib.Computability.TMConfig"
] | Mathlib/Computability/TMToPartrec.lean | codeSupp_supports | null |
tr_supports (c k) : @TM2.Supports _ _ _ _ ⟨trNormal c k⟩ tr (codeSupp c k) :=
⟨codeSupp_self _ _ (trStmts₁_self _), fun _ => codeSupp_supports (Finset.Subset.refl _) _⟩ | theorem | Computability | [
"Mathlib.Computability.Halting",
"Mathlib.Computability.TuringMachine",
"Mathlib.Data.Num.Lemmas",
"Mathlib.Tactic.DeriveFintype",
"Mathlib.Computability.TMConfig"
] | Mathlib/Computability/TMToPartrec.lean | tr_supports | The set `codeSupp c k` is a finite set that witnesses the effective finiteness of the `tr`
Turing machine. Starting from the initial state `trNormal c k`, forward simulation uses only
states in `codeSupp c k`, so this is a finite state machine. Even though the underlying type of
state labels `Λ'` is infinite, for a giv... |
RecursiveIn (O : Set (ℕ →. ℕ)) : (ℕ →. ℕ) → Prop
| zero : RecursiveIn O fun _ => 0
| succ : RecursiveIn O Nat.succ
| left : RecursiveIn O fun n => (Nat.unpair n).1
| right : RecursiveIn O fun n => (Nat.unpair n).2
| oracle : ∀ g ∈ O, RecursiveIn O g
| pair {f h : ℕ →. ℕ} (hf : RecursiveIn O f) (hh : Recursi... | inductive | Computability | [
"Mathlib.Computability.Partrec",
"Mathlib.Order.Antisymmetrization"
] | Mathlib/Computability/TuringDegree.lean | RecursiveIn | The type of partial functions recursive in a set of oracles `O` is the smallest type containing
the constant zero, the successor, left and right projections, each oracle `g ∈ O`,
and is closed under pairing, composition, primitive recursion, and μ-recursion. |
TuringReducible (f g : ℕ →. ℕ) : Prop :=
RecursiveIn {g} f | abbrev | Computability | [
"Mathlib.Computability.Partrec",
"Mathlib.Order.Antisymmetrization"
] | Mathlib/Computability/TuringDegree.lean | TuringReducible | `f` is Turing reducible to `g` if `f` is partial recursive given access to the oracle `g` |
TuringEquivalent (f g : ℕ →. ℕ) : Prop :=
AntisymmRel TuringReducible f g
@[inherit_doc] scoped[Computability] infix:50 " ≤ᵀ " => TuringReducible
@[inherit_doc] scoped[Computability] infix:50 " ≡ᵀ " => TuringEquivalent
open scoped Computability | abbrev | Computability | [
"Mathlib.Computability.Partrec",
"Mathlib.Order.Antisymmetrization"
] | Mathlib/Computability/TuringDegree.lean | TuringEquivalent | `f` is Turing equivalent to `g` if `f` is reducible to `g` and `g` is reducible to `f`. |
Nat.Partrec.turingReducible (pF : Nat.Partrec f) : f ≤ᵀ g := by
induction pF with repeat {constructor}
| pair _ _ ih₁ ih₂ => exact RecursiveIn.pair ih₁ ih₂
| comp _ _ ih₁ ih₂ => exact RecursiveIn.comp ih₁ ih₂
| prec _ _ ih₁ ih₂ => exact RecursiveIn.prec ih₁ ih₂
| rfind _ ih => exact RecursiveIn.rfind ih | lemma | Computability | [
"Mathlib.Computability.Partrec",
"Mathlib.Order.Antisymmetrization"
] | Mathlib/Computability/TuringDegree.lean | Nat.Partrec.turingReducible | If a function is partial recursive, then it is recursive in every partial function. |
TuringReducible.partrec_of_zero (fRecInZero : f ≤ᵀ fun _ => Part.some 0) : Nat.Partrec f := by
induction fRecInZero with repeat {constructor}
| oracle _ hg => rw [Set.mem_singleton_iff] at hg; rw [hg]; exact Nat.Partrec.zero
| pair | comp | prec | rfind => repeat {constructor; assumption; try assumption} | lemma | Computability | [
"Mathlib.Computability.Partrec",
"Mathlib.Order.Antisymmetrization"
] | Mathlib/Computability/TuringDegree.lean | TuringReducible.partrec_of_zero | If a function is recursive in the constant zero function,
then it is partial recursive. |
partrec_iff_forall_turingReducible : Nat.Partrec f ↔ ∀ g, f ≤ᵀ g :=
⟨fun hf _ ↦ hf.turingReducible, (· _ |>.partrec_of_zero)⟩ | theorem | Computability | [
"Mathlib.Computability.Partrec",
"Mathlib.Order.Antisymmetrization"
] | Mathlib/Computability/TuringDegree.lean | partrec_iff_forall_turingReducible | A partial function `f` is partial recursive if and only if it is recursive in
every partial function `g`. |
protected TuringReducible.refl (f : ℕ →. ℕ) : f ≤ᵀ f := .oracle _ <| by simp | theorem | Computability | [
"Mathlib.Computability.Partrec",
"Mathlib.Order.Antisymmetrization"
] | Mathlib/Computability/TuringDegree.lean | TuringReducible.refl | null |
protected TuringReducible.rfl : f ≤ᵀ f := .refl _ | theorem | Computability | [
"Mathlib.Computability.Partrec",
"Mathlib.Order.Antisymmetrization"
] | Mathlib/Computability/TuringDegree.lean | TuringReducible.rfl | null |
TuringReducible.trans (hg : f ≤ᵀ g) (hh : g ≤ᵀ h) : f ≤ᵀ h := by
induction hg with repeat {constructor}
| oracle _ hg => rw [Set.mem_singleton_iff] at hg; rw [hg]; exact hh
| pair _ _ ih₁ ih₂ => exact RecursiveIn.pair ih₁ ih₂
| comp _ _ ih₁ ih₂ => exact RecursiveIn.comp ih₁ ih₂
| prec _ _ ih₁ ih₂ => exact Rec... | theorem | Computability | [
"Mathlib.Computability.Partrec",
"Mathlib.Order.Antisymmetrization"
] | Mathlib/Computability/TuringDegree.lean | TuringReducible.trans | null |
TuringEquivalent.equivalence : Equivalence TuringEquivalent :=
(AntisymmRel.setoid _ _).iseqv
@[refl] | theorem | Computability | [
"Mathlib.Computability.Partrec",
"Mathlib.Order.Antisymmetrization"
] | Mathlib/Computability/TuringDegree.lean | TuringEquivalent.equivalence | null |
protected TuringEquivalent.refl (f : ℕ →. ℕ) : f ≡ᵀ f :=
Equivalence.refl equivalence f
@[symm] | theorem | Computability | [
"Mathlib.Computability.Partrec",
"Mathlib.Order.Antisymmetrization"
] | Mathlib/Computability/TuringDegree.lean | TuringEquivalent.refl | null |
TuringEquivalent.symm {f g : ℕ →. ℕ} (h : f ≡ᵀ g) : g ≡ᵀ f :=
Equivalence.symm equivalence h
@[trans] | theorem | Computability | [
"Mathlib.Computability.Partrec",
"Mathlib.Order.Antisymmetrization"
] | Mathlib/Computability/TuringDegree.lean | TuringEquivalent.symm | null |
TuringEquivalent.trans (f g h : ℕ →. ℕ) (h₁ : f ≡ᵀ g) (h₂ : g ≡ᵀ h) : f ≡ᵀ h :=
Equivalence.trans equivalence h₁ h₂ | theorem | Computability | [
"Mathlib.Computability.Partrec",
"Mathlib.Order.Antisymmetrization"
] | Mathlib/Computability/TuringDegree.lean | TuringEquivalent.trans | null |
TuringDegree :=
Antisymmetrization _ TuringReducible | abbrev | Computability | [
"Mathlib.Computability.Partrec",
"Mathlib.Order.Antisymmetrization"
] | Mathlib/Computability/TuringDegree.lean | TuringDegree | Turing degrees are the equivalence classes of partial functions under Turing equivalence. |
TuringDegree.instPartialOrder : PartialOrder TuringDegree :=
instPartialOrderAntisymmetrization
@[simp] lemma recursiveIn_empty_iff_partrec : RecursiveIn {} f ↔ Nat.Partrec f where
mp fRecInNone := by
induction fRecInNone with repeat {constructor}
| oracle _ hg => simp at hg
| pair | comp | prec | rfind... | instance | Computability | [
"Mathlib.Computability.Partrec",
"Mathlib.Order.Antisymmetrization"
] | Mathlib/Computability/TuringDegree.lean | TuringDegree.instPartialOrder | null |
Stmt
| push : ∀ k, (σ → Γ k) → Stmt → Stmt
| peek : ∀ k, (σ → Option (Γ k) → σ) → Stmt → Stmt
| pop : ∀ k, (σ → Option (Γ k) → σ) → Stmt → Stmt
| load : (σ → σ) → Stmt → Stmt
| branch : (σ → Bool) → Stmt → Stmt → Stmt
| goto : (σ → Λ) → Stmt
| halt : Stmt
open Stmt | inductive | Computability | [
"Mathlib.Computability.Tape",
"Mathlib.Data.Fintype.Option",
"Mathlib.Data.Fintype.Prod",
"Mathlib.Data.Fintype.Pi",
"Mathlib.Data.PFun",
"Mathlib.Computability.PostTuringMachine"
] | Mathlib/Computability/TuringMachine.lean | Stmt | The TM2 model removes the tape entirely from the TM1 model,
replacing it with an arbitrary (finite) collection of stacks.
The operation `push` puts an element on one of the stacks,
and `pop` removes an element from a stack (and modifying the
internal state based on the result). `peek` modifies the
internal st... |
Stmt.inhabited : Inhabited (Stmt Γ Λ σ) :=
⟨halt⟩ | instance | Computability | [
"Mathlib.Computability.Tape",
"Mathlib.Data.Fintype.Option",
"Mathlib.Data.Fintype.Prod",
"Mathlib.Data.Fintype.Pi",
"Mathlib.Data.PFun",
"Mathlib.Computability.PostTuringMachine"
] | Mathlib/Computability/TuringMachine.lean | Stmt.inhabited | null |
Cfg where
/-- The current label to run (or `none` for the halting state) -/
l : Option Λ
/-- The internal state -/
var : σ
/-- The (finite) collection of internal stacks -/
stk : ∀ k, List (Γ k) | structure | Computability | [
"Mathlib.Computability.Tape",
"Mathlib.Data.Fintype.Option",
"Mathlib.Data.Fintype.Prod",
"Mathlib.Data.Fintype.Pi",
"Mathlib.Data.PFun",
"Mathlib.Computability.PostTuringMachine"
] | Mathlib/Computability/TuringMachine.lean | Cfg | A configuration in the TM2 model is a label (or `none` for the halt state), the state of
local variables, and the stacks. (Note that the stacks are not `ListBlank`s, they have a definite
size.) |
Cfg.inhabited [Inhabited σ] : Inhabited (Cfg Γ Λ σ) :=
⟨⟨default, default, default⟩⟩
variable {Γ Λ σ} | instance | Computability | [
"Mathlib.Computability.Tape",
"Mathlib.Data.Fintype.Option",
"Mathlib.Data.Fintype.Prod",
"Mathlib.Data.Fintype.Pi",
"Mathlib.Data.PFun",
"Mathlib.Computability.PostTuringMachine"
] | Mathlib/Computability/TuringMachine.lean | Cfg.inhabited | null |
stepAux : Stmt Γ Λ σ → σ → (∀ k, List (Γ k)) → Cfg Γ Λ σ
| push k f q, v, S => stepAux q v (update S k (f v :: S k))
| peek k f q, v, S => stepAux q (f v (S k).head?) S
| pop k f q, v, S => stepAux q (f v (S k).head?) (update S k (S k).tail)
| load a q, v, S => stepAux q (a v) S
| branch f q₁ q₂, v, S => cond... | def | Computability | [
"Mathlib.Computability.Tape",
"Mathlib.Data.Fintype.Option",
"Mathlib.Data.Fintype.Prod",
"Mathlib.Data.Fintype.Pi",
"Mathlib.Data.PFun",
"Mathlib.Computability.PostTuringMachine"
] | Mathlib/Computability/TuringMachine.lean | stepAux | The step function for the TM2 model. |
step (M : Λ → Stmt Γ Λ σ) : Cfg Γ Λ σ → Option (Cfg Γ Λ σ)
| ⟨none, _, _⟩ => none
| ⟨some l, v, S⟩ => some (stepAux (M l) v S)
attribute [simp] stepAux.eq_1 stepAux.eq_2 stepAux.eq_3
stepAux.eq_4 stepAux.eq_5 stepAux.eq_6 stepAux.eq_7 step.eq_1 step.eq_2 | def | Computability | [
"Mathlib.Computability.Tape",
"Mathlib.Data.Fintype.Option",
"Mathlib.Data.Fintype.Prod",
"Mathlib.Data.Fintype.Pi",
"Mathlib.Data.PFun",
"Mathlib.Computability.PostTuringMachine"
] | Mathlib/Computability/TuringMachine.lean | step | The step function for the TM2 model. |
Reaches (M : Λ → Stmt Γ Λ σ) : Cfg Γ Λ σ → Cfg Γ Λ σ → Prop :=
ReflTransGen fun a b ↦ b ∈ step M a | def | Computability | [
"Mathlib.Computability.Tape",
"Mathlib.Data.Fintype.Option",
"Mathlib.Data.Fintype.Prod",
"Mathlib.Data.Fintype.Pi",
"Mathlib.Data.PFun",
"Mathlib.Computability.PostTuringMachine"
] | Mathlib/Computability/TuringMachine.lean | Reaches | The (reflexive) reachability relation for the TM2 model. |
SupportsStmt (S : Finset Λ) : Stmt Γ Λ σ → Prop
| push _ _ q => SupportsStmt S q
| peek _ _ q => SupportsStmt S q
| pop _ _ q => SupportsStmt S q
| load _ q => SupportsStmt S q
| branch _ q₁ q₂ => SupportsStmt S q₁ ∧ SupportsStmt S q₂
| goto l => ∀ v, l v ∈ S
| halt => True | def | Computability | [
"Mathlib.Computability.Tape",
"Mathlib.Data.Fintype.Option",
"Mathlib.Data.Fintype.Prod",
"Mathlib.Data.Fintype.Pi",
"Mathlib.Data.PFun",
"Mathlib.Computability.PostTuringMachine"
] | Mathlib/Computability/TuringMachine.lean | SupportsStmt | Given a set `S` of states, `SupportsStmt S q` means that `q` only jumps to states in `S`. |
noncomputable stmts₁ : Stmt Γ Λ σ → Finset (Stmt Γ Λ σ)
| Q@(push _ _ q) => insert Q (stmts₁ q)
| Q@(peek _ _ q) => insert Q (stmts₁ q)
| Q@(pop _ _ q) => insert Q (stmts₁ q)
| Q@(load _ q) => insert Q (stmts₁ q)
| Q@(branch _ q₁ q₂) => insert Q (stmts₁ q₁ ∪ stmts₁ q₂)
| Q@(goto _) => {Q}
| Q@halt => {Q} | def | Computability | [
"Mathlib.Computability.Tape",
"Mathlib.Data.Fintype.Option",
"Mathlib.Data.Fintype.Prod",
"Mathlib.Data.Fintype.Pi",
"Mathlib.Data.PFun",
"Mathlib.Computability.PostTuringMachine"
] | Mathlib/Computability/TuringMachine.lean | stmts₁ | The set of subtree statements in a statement. |
stmts₁_self {q : Stmt Γ Λ σ} : q ∈ stmts₁ q := by
cases q <;> simp only [Finset.mem_insert_self, Finset.mem_singleton_self, stmts₁] | theorem | Computability | [
"Mathlib.Computability.Tape",
"Mathlib.Data.Fintype.Option",
"Mathlib.Data.Fintype.Prod",
"Mathlib.Data.Fintype.Pi",
"Mathlib.Data.PFun",
"Mathlib.Computability.PostTuringMachine"
] | Mathlib/Computability/TuringMachine.lean | stmts₁_self | null |
stmts₁_trans {q₁ q₂ : Stmt Γ Λ σ} : q₁ ∈ stmts₁ q₂ → stmts₁ q₁ ⊆ stmts₁ q₂ := by
classical
intro h₁₂ q₀ h₀₁
induction q₂ with (
simp only [stmts₁] at h₁₂ ⊢
simp only [Finset.mem_insert, Finset.mem_singleton, Finset.mem_union] at h₁₂)
| branch f q₁ q₂ IH₁ IH₂ =>
rcases h₁₂ with (rfl | h₁₂ | h₁₂)
... | theorem | Computability | [
"Mathlib.Computability.Tape",
"Mathlib.Data.Fintype.Option",
"Mathlib.Data.Fintype.Prod",
"Mathlib.Data.Fintype.Pi",
"Mathlib.Data.PFun",
"Mathlib.Computability.PostTuringMachine"
] | Mathlib/Computability/TuringMachine.lean | stmts₁_trans | null |
stmts₁_supportsStmt_mono {S : Finset Λ} {q₁ q₂ : Stmt Γ Λ σ} (h : q₁ ∈ stmts₁ q₂)
(hs : SupportsStmt S q₂) : SupportsStmt S q₁ := by
induction q₂ with
simp only [stmts₁, SupportsStmt, Finset.mem_insert, Finset.mem_union, Finset.mem_singleton]
at h hs
| branch f q₁ q₂ IH₁ IH₂ => rcases h with (rfl | h ... | theorem | Computability | [
"Mathlib.Computability.Tape",
"Mathlib.Data.Fintype.Option",
"Mathlib.Data.Fintype.Prod",
"Mathlib.Data.Fintype.Pi",
"Mathlib.Data.PFun",
"Mathlib.Computability.PostTuringMachine"
] | Mathlib/Computability/TuringMachine.lean | stmts₁_supportsStmt_mono | null |
noncomputable stmts (M : Λ → Stmt Γ Λ σ) (S : Finset Λ) : Finset (Option (Stmt Γ Λ σ)) :=
Finset.insertNone (S.biUnion fun q ↦ stmts₁ (M q)) | def | Computability | [
"Mathlib.Computability.Tape",
"Mathlib.Data.Fintype.Option",
"Mathlib.Data.Fintype.Prod",
"Mathlib.Data.Fintype.Pi",
"Mathlib.Data.PFun",
"Mathlib.Computability.PostTuringMachine"
] | Mathlib/Computability/TuringMachine.lean | stmts | The set of statements accessible from initial set `S` of labels. |
stmts_trans {M : Λ → Stmt Γ Λ σ} {S : Finset Λ} {q₁ q₂ : Stmt Γ Λ σ} (h₁ : q₁ ∈ stmts₁ q₂) :
some q₂ ∈ stmts M S → some q₁ ∈ stmts M S := by
simp only [stmts, Finset.mem_insertNone, Finset.mem_biUnion, Option.mem_def, Option.some.injEq,
forall_eq', exists_imp, and_imp]
exact fun l ls h₂ ↦ ⟨_, ls, stmts₁_tra... | theorem | Computability | [
"Mathlib.Computability.Tape",
"Mathlib.Data.Fintype.Option",
"Mathlib.Data.Fintype.Prod",
"Mathlib.Data.Fintype.Pi",
"Mathlib.Data.PFun",
"Mathlib.Computability.PostTuringMachine"
] | Mathlib/Computability/TuringMachine.lean | stmts_trans | null |
Supports (M : Λ → Stmt Γ Λ σ) (S : Finset Λ) :=
default ∈ S ∧ ∀ q ∈ S, SupportsStmt S (M q) | def | Computability | [
"Mathlib.Computability.Tape",
"Mathlib.Data.Fintype.Option",
"Mathlib.Data.Fintype.Prod",
"Mathlib.Data.Fintype.Pi",
"Mathlib.Data.PFun",
"Mathlib.Computability.PostTuringMachine"
] | Mathlib/Computability/TuringMachine.lean | Supports | Given a TM2 machine `M` and a set `S` of states, `Supports M S` means that all states in
`S` jump only to other states in `S`. |
stmts_supportsStmt {M : Λ → Stmt Γ Λ σ} {S : Finset Λ} {q : Stmt Γ Λ σ}
(ss : Supports M S) : some q ∈ stmts M S → SupportsStmt S q := by
simp only [stmts, Finset.mem_insertNone, Finset.mem_biUnion, Option.mem_def, Option.some.injEq,
forall_eq', exists_imp, and_imp]
exact fun l ls h ↦ stmts₁_supportsStmt_mo... | theorem | Computability | [
"Mathlib.Computability.Tape",
"Mathlib.Data.Fintype.Option",
"Mathlib.Data.Fintype.Prod",
"Mathlib.Data.Fintype.Pi",
"Mathlib.Data.PFun",
"Mathlib.Computability.PostTuringMachine"
] | Mathlib/Computability/TuringMachine.lean | stmts_supportsStmt | null |
step_supports (M : Λ → Stmt Γ Λ σ) {S : Finset Λ} (ss : Supports M S) :
∀ {c c' : Cfg Γ Λ σ}, c' ∈ step M c → c.l ∈ Finset.insertNone S → c'.l ∈ Finset.insertNone S
| ⟨some l₁, v, T⟩, c', h₁, h₂ => by
replace h₂ := ss.2 _ (Finset.some_mem_insertNone.1 h₂)
simp only [step, Option.mem_def, Option.some.injEq... | theorem | Computability | [
"Mathlib.Computability.Tape",
"Mathlib.Data.Fintype.Option",
"Mathlib.Data.Fintype.Prod",
"Mathlib.Data.Fintype.Pi",
"Mathlib.Data.PFun",
"Mathlib.Computability.PostTuringMachine"
] | Mathlib/Computability/TuringMachine.lean | step_supports | null |
init (k : K) (L : List (Γ k)) : Cfg Γ Λ σ :=
⟨some default, default, update (fun _ ↦ []) k L⟩ | def | Computability | [
"Mathlib.Computability.Tape",
"Mathlib.Data.Fintype.Option",
"Mathlib.Data.Fintype.Prod",
"Mathlib.Data.Fintype.Pi",
"Mathlib.Data.PFun",
"Mathlib.Computability.PostTuringMachine"
] | Mathlib/Computability/TuringMachine.lean | init | The initial state of the TM2 model. The input is provided on a designated stack. |
eval (M : Λ → Stmt Γ Λ σ) (k : K) (L : List (Γ k)) : Part (List (Γ k)) :=
(Turing.eval (step M) (init k L)).map fun c ↦ c.stk k | def | Computability | [
"Mathlib.Computability.Tape",
"Mathlib.Data.Fintype.Option",
"Mathlib.Data.Fintype.Prod",
"Mathlib.Data.Fintype.Pi",
"Mathlib.Data.PFun",
"Mathlib.Computability.PostTuringMachine"
] | Mathlib/Computability/TuringMachine.lean | eval | Evaluates a TM2 program to completion, with the output on the same stack as the input. |
stk_nth_val {K : Type*} {Γ : K → Type*} {L : ListBlank (∀ k, Option (Γ k))} {k S} (n)
(hL : ListBlank.map (proj k) L = ListBlank.mk (List.map some S).reverse) :
L.nth n k = S.reverse[n]? := by
rw [← proj_map_nth, hL, ← List.map_reverse, ListBlank.nth_mk,
List.getI_eq_iget_getElem?, List.getElem?_map]
ca... | theorem | Computability | [
"Mathlib.Computability.Tape",
"Mathlib.Data.Fintype.Option",
"Mathlib.Data.Fintype.Prod",
"Mathlib.Data.Fintype.Pi",
"Mathlib.Data.PFun",
"Mathlib.Computability.PostTuringMachine"
] | Mathlib/Computability/TuringMachine.lean | stk_nth_val | null |
Γ' :=
Bool × ∀ k, Option (Γ k)
variable {K Γ} | def | Computability | [
"Mathlib.Computability.Tape",
"Mathlib.Data.Fintype.Option",
"Mathlib.Data.Fintype.Prod",
"Mathlib.Data.Fintype.Pi",
"Mathlib.Data.PFun",
"Mathlib.Computability.PostTuringMachine"
] | Mathlib/Computability/TuringMachine.lean | Γ' | The alphabet of the TM2 simulator on TM1 is a marker for the stack bottom,
plus a vector of stack elements for each stack, or none if the stack does not extend this far. |
Γ'.inhabited : Inhabited (Γ' K Γ) :=
⟨⟨false, fun _ ↦ none⟩⟩ | instance | Computability | [
"Mathlib.Computability.Tape",
"Mathlib.Data.Fintype.Option",
"Mathlib.Data.Fintype.Prod",
"Mathlib.Data.Fintype.Pi",
"Mathlib.Data.PFun",
"Mathlib.Computability.PostTuringMachine"
] | Mathlib/Computability/TuringMachine.lean | Γ'.inhabited | null |
Γ'.fintype [DecidableEq K] [Fintype K] [∀ k, Fintype (Γ k)] : Fintype (Γ' K Γ) :=
instFintypeProd _ _ | instance | Computability | [
"Mathlib.Computability.Tape",
"Mathlib.Data.Fintype.Option",
"Mathlib.Data.Fintype.Prod",
"Mathlib.Data.Fintype.Pi",
"Mathlib.Data.PFun",
"Mathlib.Computability.PostTuringMachine"
] | Mathlib/Computability/TuringMachine.lean | Γ'.fintype | null |
addBottom (L : ListBlank (∀ k, Option (Γ k))) : ListBlank (Γ' K Γ) :=
ListBlank.cons (true, L.head) (L.tail.map ⟨Prod.mk false, rfl⟩) | def | Computability | [
"Mathlib.Computability.Tape",
"Mathlib.Data.Fintype.Option",
"Mathlib.Data.Fintype.Prod",
"Mathlib.Data.Fintype.Pi",
"Mathlib.Data.PFun",
"Mathlib.Computability.PostTuringMachine"
] | Mathlib/Computability/TuringMachine.lean | addBottom | The bottom marker is fixed throughout the calculation, so we use the `addBottom` function
to express the program state in terms of a tape with only the stacks themselves. |
addBottom_map (L : ListBlank (∀ k, Option (Γ k))) :
(addBottom L).map ⟨Prod.snd, by rfl⟩ = L := by
simp only [addBottom, ListBlank.map_cons]
convert ListBlank.cons_head_tail L
generalize ListBlank.tail L = L'
refine L'.induction_on fun l ↦ ?_; simp | theorem | Computability | [
"Mathlib.Computability.Tape",
"Mathlib.Data.Fintype.Option",
"Mathlib.Data.Fintype.Prod",
"Mathlib.Data.Fintype.Pi",
"Mathlib.Data.PFun",
"Mathlib.Computability.PostTuringMachine"
] | Mathlib/Computability/TuringMachine.lean | addBottom_map | null |
addBottom_modifyNth (f : (∀ k, Option (Γ k)) → ∀ k, Option (Γ k))
(L : ListBlank (∀ k, Option (Γ k))) (n : ℕ) :
(addBottom L).modifyNth (fun a ↦ (a.1, f a.2)) n = addBottom (L.modifyNth f n) := by
cases n <;>
simp only [addBottom, ListBlank.head_cons, ListBlank.modifyNth, ListBlank.tail_cons]
congr; sym... | theorem | Computability | [
"Mathlib.Computability.Tape",
"Mathlib.Data.Fintype.Option",
"Mathlib.Data.Fintype.Prod",
"Mathlib.Data.Fintype.Pi",
"Mathlib.Data.PFun",
"Mathlib.Computability.PostTuringMachine"
] | Mathlib/Computability/TuringMachine.lean | addBottom_modifyNth | null |
addBottom_nth_snd (L : ListBlank (∀ k, Option (Γ k))) (n : ℕ) :
((addBottom L).nth n).2 = L.nth n := by
conv => rhs; rw [← addBottom_map L, ListBlank.nth_map] | theorem | Computability | [
"Mathlib.Computability.Tape",
"Mathlib.Data.Fintype.Option",
"Mathlib.Data.Fintype.Prod",
"Mathlib.Data.Fintype.Pi",
"Mathlib.Data.PFun",
"Mathlib.Computability.PostTuringMachine"
] | Mathlib/Computability/TuringMachine.lean | addBottom_nth_snd | null |
addBottom_nth_succ_fst (L : ListBlank (∀ k, Option (Γ k))) (n : ℕ) :
((addBottom L).nth (n + 1)).1 = false := by
rw [ListBlank.nth_succ, addBottom, ListBlank.tail_cons, ListBlank.nth_map] | theorem | Computability | [
"Mathlib.Computability.Tape",
"Mathlib.Data.Fintype.Option",
"Mathlib.Data.Fintype.Prod",
"Mathlib.Data.Fintype.Pi",
"Mathlib.Data.PFun",
"Mathlib.Computability.PostTuringMachine"
] | Mathlib/Computability/TuringMachine.lean | addBottom_nth_succ_fst | null |
addBottom_head_fst (L : ListBlank (∀ k, Option (Γ k))) : (addBottom L).head.1 = true := by
rw [addBottom, ListBlank.head_cons]
variable (K Γ σ) in | theorem | Computability | [
"Mathlib.Computability.Tape",
"Mathlib.Data.Fintype.Option",
"Mathlib.Data.Fintype.Prod",
"Mathlib.Data.Fintype.Pi",
"Mathlib.Data.PFun",
"Mathlib.Computability.PostTuringMachine"
] | Mathlib/Computability/TuringMachine.lean | addBottom_head_fst | null |
StAct (k : K)
| push : (σ → Γ k) → StAct k
| peek : (σ → Option (Γ k) → σ) → StAct k
| pop : (σ → Option (Γ k) → σ) → StAct k | inductive | Computability | [
"Mathlib.Computability.Tape",
"Mathlib.Data.Fintype.Option",
"Mathlib.Data.Fintype.Prod",
"Mathlib.Data.Fintype.Pi",
"Mathlib.Data.PFun",
"Mathlib.Computability.PostTuringMachine"
] | Mathlib/Computability/TuringMachine.lean | StAct | A stack action is a command that interacts with the top of a stack. Our default position
is at the bottom of all the stacks, so we have to hold on to this action while going to the end
to modify the stack. |
StAct.inhabited {k : K} : Inhabited (StAct K Γ σ k) :=
⟨StAct.peek fun s _ ↦ s⟩ | instance | Computability | [
"Mathlib.Computability.Tape",
"Mathlib.Data.Fintype.Option",
"Mathlib.Data.Fintype.Prod",
"Mathlib.Data.Fintype.Pi",
"Mathlib.Data.PFun",
"Mathlib.Computability.PostTuringMachine"
] | Mathlib/Computability/TuringMachine.lean | StAct.inhabited | null |
stRun {k : K} : StAct K Γ σ k → TM2.Stmt Γ Λ σ → TM2.Stmt Γ Λ σ
| push f => TM2.Stmt.push k f
| peek f => TM2.Stmt.peek k f
| pop f => TM2.Stmt.pop k f | def | Computability | [
"Mathlib.Computability.Tape",
"Mathlib.Data.Fintype.Option",
"Mathlib.Data.Fintype.Prod",
"Mathlib.Data.Fintype.Pi",
"Mathlib.Data.PFun",
"Mathlib.Computability.PostTuringMachine"
] | Mathlib/Computability/TuringMachine.lean | stRun | The TM2 statement corresponding to a stack action. |
stVar {k : K} (v : σ) (l : List (Γ k)) : StAct K Γ σ k → σ
| push _ => v
| peek f => f v l.head?
| pop f => f v l.head? | def | Computability | [
"Mathlib.Computability.Tape",
"Mathlib.Data.Fintype.Option",
"Mathlib.Data.Fintype.Prod",
"Mathlib.Data.Fintype.Pi",
"Mathlib.Data.PFun",
"Mathlib.Computability.PostTuringMachine"
] | Mathlib/Computability/TuringMachine.lean | stVar | The effect of a stack action on the local variables, given the value of the stack. |
stWrite {k : K} (v : σ) (l : List (Γ k)) : StAct K Γ σ k → List (Γ k)
| push f => f v :: l
| peek _ => l
| pop _ => l.tail | def | Computability | [
"Mathlib.Computability.Tape",
"Mathlib.Data.Fintype.Option",
"Mathlib.Data.Fintype.Prod",
"Mathlib.Data.Fintype.Pi",
"Mathlib.Data.PFun",
"Mathlib.Computability.PostTuringMachine"
] | Mathlib/Computability/TuringMachine.lean | stWrite | The effect of a stack action on the stack. |
@[elab_as_elim]
stmtStRec.{l} {motive : TM2.Stmt Γ Λ σ → Sort l}
(run : ∀ (k) (s : StAct K Γ σ k) (q) (_ : motive q), motive (stRun s q))
(load : ∀ (a q) (_ : motive q), motive (TM2.Stmt.load a q))
(branch : ∀ (p q₁ q₂) (_ : motive q₁) (_ : motive q₂), motive (TM2.Stmt.branch p q₁ q₂))
(goto : ∀ l, moti... | def | Computability | [
"Mathlib.Computability.Tape",
"Mathlib.Data.Fintype.Option",
"Mathlib.Data.Fintype.Prod",
"Mathlib.Data.Fintype.Pi",
"Mathlib.Data.PFun",
"Mathlib.Computability.PostTuringMachine"
] | Mathlib/Computability/TuringMachine.lean | stmtStRec. | We have partitioned the TM2 statements into "stack actions", which require going to the end
of the stack, and all other actions, which do not. This is a modified recursor which lumps the
stack actions into one. |
supports_run (S : Finset Λ) {k : K} (s : StAct K Γ σ k) (q : TM2.Stmt Γ Λ σ) :
TM2.SupportsStmt S (stRun s q) ↔ TM2.SupportsStmt S q := by
cases s <;> rfl | theorem | Computability | [
"Mathlib.Computability.Tape",
"Mathlib.Data.Fintype.Option",
"Mathlib.Data.Fintype.Prod",
"Mathlib.Data.Fintype.Pi",
"Mathlib.Data.PFun",
"Mathlib.Computability.PostTuringMachine"
] | Mathlib/Computability/TuringMachine.lean | supports_run | null |
Λ'
| normal : Λ → Λ'
| go (k : K) : StAct K Γ σ k → TM2.Stmt Γ Λ σ → Λ'
| ret : TM2.Stmt Γ Λ σ → Λ'
variable {K Γ Λ σ}
open Λ' | inductive | Computability | [
"Mathlib.Computability.Tape",
"Mathlib.Data.Fintype.Option",
"Mathlib.Data.Fintype.Prod",
"Mathlib.Data.Fintype.Pi",
"Mathlib.Data.PFun",
"Mathlib.Computability.PostTuringMachine"
] | Mathlib/Computability/TuringMachine.lean | Λ' | The machine states of the TM2 emulator. We can either be in a normal state when waiting for the
next TM2 action, or we can be in the "go" and "return" states to go to the top of the stack and
return to the bottom, respectively. |
Λ'.inhabited [Inhabited Λ] : Inhabited (Λ' K Γ Λ σ) :=
⟨normal default⟩
open TM1.Stmt | instance | Computability | [
"Mathlib.Computability.Tape",
"Mathlib.Data.Fintype.Option",
"Mathlib.Data.Fintype.Prod",
"Mathlib.Data.Fintype.Pi",
"Mathlib.Data.PFun",
"Mathlib.Computability.PostTuringMachine"
] | Mathlib/Computability/TuringMachine.lean | Λ'.inhabited | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.