import Problems.PVersusNP.Machines.WordStacks import Problems.PVersusNP.Machines.ExtraStacks /-! Regression checks for copying into a nonempty destination, comparing unequal words, and keeping an initialized host stack while a subprogram runs. -/ namespace Tests.PVersusNP.WordStacks noncomputable section open Turing StateTransition Millennium.Machines.WordStacks Millennium.Machines.ExtraStacks private noncomputable def host := extendMachine (machine Bool) Unit (fun _ => Bool) private def saved (_ : Unit) : List Bool := [false, true] /-- The source is restored and the order of the destination's existing suffix is preserved. -/ example : EvalsToInTime host.step (extendCfg (fun _ : Unit => Bool) saved (atPhase .gather (none, true) [true, false] [] [true] [])) (some (extendCfg (fun _ : Unit => Bool) saved (atPhase .compare (none, true) [true, false] [] [true, false, true] []))) 6 := liftRun (machine Bool) (fun _ : Unit => Bool) saved (copyThrough [true, false] [true] (none, true) []) /-- An extra symbol at the end rejects even when the shorter word matched in full. -/ example : EvalsToInTime (machine Bool).step (atPhase .compare (none, true) [true] [] [true, false] []) (some (cfg none (none, true) ([] : List Bool) [] [] [false])) 3 := by simpa using compareWords [true] [true, false] (none, true) [] end end Tests.PVersusNP.WordStacks