/- Copyright 2025 The Formal Conjectures Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -/ module public import Mathlib.Computability.TuringMachine.PostTuringMachine public import Mathlib.Logic.Relation@[expose] public sectiontheorem Part.get_eq_get {σ : Type*} {a b : Part σ} (ha : a.Dom) (hb : a.get ha b) : a = b := σ:Type u_1a:Part σb:Part σha:a.Domhb:a.get ha ba = b σ:Type u_1a:Part σb:Part σha:a.Domhb:a.get ha bhb':b.Doma = b rwa [σ:Type u_1a:Part σb:Part σha:a.Domhb':b.Domhb:a.get ha = b.get hb'a = b σ:Type u_1a:Part σb:Part σha:a.Domhb':b.Domhb:a = ba = bσ:Type u_1a:Part σb:Part σha:a.Domhb':b.Domhb:a = ba = b at hbnamespace StateTransitionlemma dom_of_apply_eq_none {σ : Type*} {f : σ Option σ} {s : σ} (hf : f s = none) : s eval f s := σ:Type u_1f:σ Option σs:σhf:f s = nones eval f s σ:Type u_1f:σ Option σs:σhf:f s = noneSum.inl s Part.some ((f s).elim (Sum.inl s) Sum.inr) All goals completed! 🐙σ:Type u_1f:σ Option σs:σH:(eval f s).Domthis:Reaches f s ((eval f s).get H) f ((eval f s).get H) = nonef ((eval f s).get H) = none All goals completed! 🐙-- TODO(Paul-Lez): also prove this for `PFun.fix`/golf using the `PFun.fix` API theorem eval_get_eval {σ : Type*} {f : σ Option σ} {s : σ} (H : (eval f s).Dom) : eval f ((eval f s).get H) = eval f s := σ:Type u_1f:σ Option σs:σH:(eval f s).Domeval f ((eval f s).get H) = eval f s σ:Type u_1f:σ Option σs:σH:(eval f s).Domeval f s = eval f ((eval f s).get H) σ:Type u_1f:σ Option σs:σH:(eval f s).Domf ((eval f s).get H) = none All goals completed! 🐙σ:Type u_1f:σ Option σa:σa':σH:f a = some a'a' some a' All goals completed! 🐙σ:Type u_1f:σ Option σs:σH:(eval f s).DomC:σ Prop := fun s (eval f s).Dom n, (fun x x.bind f)^[n + 1] (some s) = nonea:σha:(eval f s).get H eval f ah: (a' : σ), f a = some a' C a'HH:(eval f a).Doma':σha':f a = some a'n:hn:(fun x x.bind f)^[n + 1] (some a') = none n, (fun x x.bind f)^[n + 1] (some a) = none σ:Type u_1f:σ Option σs:σH:(eval f s).DomC:σ Prop := fun s (eval f s).Dom n, (fun x x.bind f)^[n + 1] (some s) = nonea:σha:(eval f s).get H eval f ah: (a' : σ), f a = some a' C a'HH:(eval f a).Doma':σha':f a = some a'n:hn:(fun x x.bind f)^[n + 1] (some a') = none(fun x x.bind f)^[n + 1 + 1] (some a) = none σ:Type u_1f:σ Option σs:σH:(eval f s).DomC:σ Prop := fun s (eval f s).Dom n, (fun x x.bind f)^[n + 1] (some s) = nonea:σha:(eval f s).get H eval f ah: (a' : σ), f a = some a' C a'HH:(eval f a).Doma':σha':f a = some a'n:hn:(fun x x.bind f)^[n] (f a') = none(fun x x.bind f)^[n + 1 + 1] (some a) = none All goals completed! 🐙end StateTransition