Snippets Concepts Turing Machine

Index for Snippets Concepts Turing Machine



Preface


gold 7/1/2026. Advisor requests similar to previous snippets, but on topic of Turing Machine. The model is intended as an exploratory framework for TCL coding. However, some math aspects of the Turing Machine theory and implications on Quantum subjects are interesting from the programmer's standpoint. Adding references to Dr. Chiara Marletto's counterfactual framework from the book "The Science of Can and Can't" along with other perspectives. Diagrams and tables are targeted for engineering students. We are using modular snippets inside modular structured programs.


gold 7/1/2026. Upon review of Wiki Feedback and draft page, ...


I do not have all the answers. The Ideas Seemed to work, but maybe drawbacks? When measured by the Tcl timing statements, completion times and solutions of parameters will differ on different computer set-ups. Assume a future maintainer, either AI Model or human programmer, would have to maintain code with info content and explanatory variable name in program, ref "Snippets Concepts Effects". The Nassi Shneiderman Diagrams NSD or pseudocode Flowcharts pertain to the Tool Command Language TCL computer language, as well as other computer languages like Python 3, pseudocode, word logic problems, and technical reports.


For each logic condition selecting a path or calculation task, we might have one, two, or multiple deterministic branches. Attempting to adapt format to multiple probabilistic branches used in Artificial Intelligence AI Models. Then we may use the >>> lottery algorithm <<< to select the winning pathways or tickets.


The existing program has some dummy subroutines. A full construction seems too complex here. I have limited space on the wiki page, and the fill‑in for the dummy routines has to be pretty brief. In engineering terms, I’m aiming for a “90% solution”, meaning about 90% right and 10% off. Like the simple college formula for a pendulum that is not the exact time series. Call it “fake it ’til you make it” as a college try, but for Quantum Many Worlds. Who is to say? Perhaps you know, TcL specializes in GUI solutions. Maybe try and adapt some starter TcL code for a "quantum worlds slide rule ". Hopefully compatible with the hard-wired classical theory.


Limitations on Tool and Disclaimer


The TCL Snippets illustrate ideal mathematical behavior only and do not perform full simulation, actual measurements, or state vector evolution. The tool only visualizes ideal math structure, whereas no state vector simulation, probabilities, or actual measurement outcomes are derived. This tool for visualization does not simulate actual measurement outcomes or state vector evolution during operations. These are idealized protocols for tutorial purposes. Primarily, TCL /TK uses its strong points here for book keeping and displays. The example tool is not a full emulator. Meaning, limited scope for tutorial purposes.


Disclaimer. None of the computer programs, numerical experiments, power-law fits, or physical analogies described here give a strict, formal proof of the Conjectures, either individually or in combination. The tools and analogies are heuristic models and visualization tools that follow engineering “rules of thumb.” Whereas, pure mathematics has its own shop rules for what counts as a rigorous proof. Any opinions on the difficulty or plausibility reflect current understanding here and programming of the Conjectures as a very hard open problem, not a completed exact math proof, and are offered with full respect for the standards of professional mathematicians.


Extra Significant Figures, If Any in Debugging


In debugging the calculations, some of the printout values reflect roughly 17-digit precision output from a typical double-precision computation. It's not "true exact" beyond 5 significant figures. Extra significant figures are used to check the calculations from other computer set-ups, not necessarily to infer accuracy of data measurements here. Typically, the slight differences in decimal places on far right of decimal point are normal floating-point behavior in Tcl's expr.


Introduction


A Turing machine works as a model of computation. Turing machine works reads symbols and writes them on a tape with a head moving around. The machines has a limited number of states to keep track of things.



Conclusions




References


  • Snippets Concepts Stochastic Ito Engine
  • Snippets Concepts DFT on Inference Vectors
  • Snippets Concepts Triangular Propagation
  • Snippets Concepts Inference Engine
  • Snippets Concepts Diósi Penrose Model
  • Snippets Concepts Quantum Fourier Transform
  • Snippets Concepts Lottery Pruning
  • Snippets Concepts Qubits Model
  • Snippets Concepts Collatz Plotter
  • Snippets Concepts Geometric Tunneling
  • Snippets Concepts Collatz T-Stop
  • Snippets Concepts Random Cubics
  • Snippets Concepts McCarthy 91_Function
  • Snippets Concepts Predator Prey
  • Snippets Concepts Thomas Solver
  • Snippets Concepts Grover Simulation
  • Snippets Concepts Radioactive Decay
  • Snippets Concepts Hypersphere Simulation
  • Snippets Concepts Nassi Shneiderman Flowcharts
  • Snippets Concepts SlideRule to Quantum
  • Snippets Physics Concepts Qubits
  • Snippets Physics Concepts Feynman
  • Snippets Physics Concepts Quantum
  • Snippets Physics Concepts Toy
  • Snippets Physics Concepts Minimalism
  • Zero Handling Workarounds

Note. These Snippets on Theoretical Physics are a set, not stand alones. Recommend read all of the set.


  • A little slide-rule on TCL Wiki, ( much credit for the algorithms in the sliderule. )
  • Richard Suchenwirth 2003-08-31
  • Smoothing and differentiation of data by simplified least squares procedures
  • Savitzky, A. ; Golay, M. J. E. Two examples are presented as subroutines in the FORTRAN language.
  • Savitzky Golay Filtering, Python
  • Savitzky Golay Filtering — SciPy Cookbook documentation
  • Smoothing Example with Savitzky-Golay Filter in Python
  • Introduction to the Savitzky-Golay Filter: A Comprehensive Guide (Using Python), Thomas Konstantinovsky
  • Konstantinovsky has good explanation. Note detailed. WhittakerSmoother in Python
  • The Perfect Way to Smooth Your Noisy Data, Whittaker-Eilers smoother, Andrew Bowell
  • Feb 28, 2024

  • A Basis for a Mathematical Theory of Computation,Author(s)
  • McCarthy, John
  • John McCarthy: A basis for a mathematical theory of computation, in:
  • Computer Programming and Formal Systems.
  • P.Braffort, D.Hirschberg (ed.), Amsterdam:North Holland 1963,
  • several versions, archived pdf
  • McCarthy’s LISP and Basis for Theory of Computation, archived pdf
  • en.wikipedia.org search on <John McCarthy computer>
  • John McCarthy at Stanford web site, archived
  • Towards a Mathematical Science of Computation, J. McCarthy,
  • Computer Science Department, Stanford University, archived pdf
  • Elephant 2000: A Programming Language Based on Speech Acts
  • John McCarthy, Stanford University, archived
  • Elephant input and output statements are characterized
  • as speech acts and programs, which
  • can refer directly to the past.
  • Elephant proposal contains summary
  • on McCarthy mathematical theory of computation
  • Mysteries and other Matters, development of Lisp , archived
  • Note. A lot of early papers and notes from John McCarthy and Knuth are difficult to assess web links or archived.

  • Machine Learning Approaches to the Collatz Conjecture:
  • A Comprehensive Framework for Pattern Recognition
  • and Automated Conjecture Generation. IJIRT, Vol. 12 Issue 7
  • Transformers Know More Than They Can Tell:
  • Learning the Collatz Sequence , arXiv:2511.10811
  • The Collatz conjecture, Littlewood-Offord theory, and powers of 2 and 3,
  • Aug 2011, Terence Tao,
  • mentions Gambler's Ruin on this 2011 post, but better search on his website for updates.

  • Efficient Computation of Collatz Sequence
  • Stopping Times: A Novel Algorithmic Approach ( credit for the new algorithm. )
  • EYOB SOLOMON GETACHEW, BEAKAL GIZACHEW ASSEFA
  • The Collatz Conjecture over the Gaussian Integers, Alejandra Alvarado

  • An example of the difference between quantum and classical random walks
  • Andrew M. Childs, Edward Farhi, Sam Gutmann ( much credit for the new algorithm. )

  • Simple Program Design, Lesley Anne Robertson, 2004
  • Lecture in Spanish, diagrama de nassi schneiderman o rectángular
  • website for estudia con nancho, 2023
  • Lecture, Communicating Complex Logic with Ease
  • with Nassi-Shneiderman Diagrams, Atanas Marchev,
  • Jetbrains MPS community, 2023
  • Java library for working with Nassi-Shneiderman diagrams
  • (structograms) from Atanas Marchev, Github website
  • Flowchart techniques for structured programming
  • Authors: I. Nassi, B. Shneiderman, circa 1973
  • KernelF- an Embeddable and
  • Extensible Functional Language, Markus Voelter
  • voelter = acm, ~~ 2023
  • Algorithmic Accountability: Designing for Safety , Ben Shneiderman,
  • Radcliffe Institute, 2018

  • the lottery ticket hypothesis:
  • finding sparse, trainable neural networks, jonathan frankle, mit
  • 4 mar 2019, michael carbin

  • Maria Violaris, arXiv preprint titled "Quantum observers can communicate across multiverse branches." Jan 2026
  • Vafa, Cumrun (September 2006). "Baby universes and string theory". International Journal of Modern Physics D. 15 (10): 1581–1586.
  • Lecture from Sean Carroll: The many worlds of quantum mechanics
  • Lecture from Sean Carroll: Quantum Mechanics and the Many-Worlds Interpretation
  • Lecture on many worlds theory, Does Quantum Mechanics Reveal the Secrets of Parallel Universes?
  • Emergence of Classicality in Wigner’s Friend Scenarios, Tom Rivlin, Jul 2025
  • Quantum Superpositions of Conscious States in a Minimal Integrated Information Model, Kelvin J. McQueen, April 2026
  • Wigner's friend scenarios: on what to condition and how to verify the predictions
  • Flavio Del Santo, Jul 2024
  • A review and analysis of six extended Wigner's friend arguments
  • David Schmid, Yìlè Yīng, Matthew Leifer, Aug 2023
  • The Many Worlds of Hugh Everett III : Multiple Universes,
  • Mutual Assured Destruction, and the Meltdown of a Nuclear Family
  • Peter Byrne, 2010
  • The Many-Worlds Interpretation of Quantum Mechanics (level 3 multiverse), dissertation,
  • Everett, Hugh

  • An Undergraduate Course in Quantum Computing, Peter Young, Apr 2026
  • # Based on ref. An Undergraduate Course in Quantum Computing, Peter Young, Apr 2026
  • # Much credit for the quantum circuit diagrams, Matches textbook Fig 16.4 etc
  • # University of California Santa Cruz, CA, arXiv:2604.10396
  • Does gravity follow the rules of quantum mechanics? Press Release, Prof. Kazuhiro Yamamoto
  • Momentum squeezed state realized via optimal filtering in optomechanics:
  • Implications for gravity-induced entanglement”, Ryotaro Fukuzumi, Published 13 April,2026.
  • Bose-Marletto-Vedral experiment without observable spacetime superpositions
  • Nicetu Tibau Vidal,Chiara Marletto
  • The Science of Can and Can't : A Physicist's Journey Through the Land of Counterfactuals
  • by Chiara Marletto, 2021.
  • Quantum Coins and Counterfactuals, in Consistent Quantum Theory, Robert B. Griffiths, 2002,
  • from CMU Quantum Theory Group
  • How to Rewrite the Laws of Physics in the Language of Impossibility,
  • Amanda Gefter, Contributing Writer, April 29, 2021
  • Fundamental properties of beam-splitters in classical and quantum optics: arxiv /abs/2303.13705
  • Masud Mansuripur, Ewan M. Wright, 2023
  • Constructor theory, Wikipedia, date 4/27/2026

  • Constructor theory of probability, 2016,
  • Chiara Marletto
  • Bernstein, G. A. (2026c). Reality is mathematical structure.
  • Bernstein, G. A. (2026e). Why these simple laws?
  • Deriving physics from mathematical necessity.
  • Bernstein, G. A. (2026h). The arrow of time is irreversible computation.
  • Deutsch, D. (2013). Constructor theory. Synthese, 190(18), 4331-4359.
  • Deutsch, D., & Marletto, C. (2015). Constructor theory of information. Proceedings of the Royal
  • Society A, 471(2174), 20140540.
  • Deutsch, D. (1997). The Fabric of Reality. Penguin.
  • Deutsch, D. (2011). The Beginning of Infinity. Penguin.
  • Marletto, C. (2021). The Science of Can and Can't. Penguin.
  • Popper, K. (1972). Objective Knowledge. Oxford University Press.

  • Computation: finite and infinite machines, by Minsky, Marvin Lee, Publication date 1967
  • Recursive Unsolvability of Post's Problem of "Tag" and other Topics in Theory of
  • Turing Machines, Marvin L. Minsky, 1961, pp. 437-455.
  • Computational Techniques and Computational Aids in Ancient
  • Mesopotamia, Jens Høyrup, 2018, Roskilde University, Roskilde, Denmark.
  • Lecture, Mod-01 Lec-39 Counter machines and their equivalence to basic TM model.
  • fm Theory of Computation by Prof. Somenath Biswas, Computer Science and Engineering, IIT Kanpur.
  • Turing Machine Alternative (Counter Machines) - Computerphile
  • Lecture, Computing with counters. How "counter machines" are as powerful as turing machines,
  • albeit more convoluted! Dr Christopher Hampson, Senior Lecturer in Computer Science Education, at KCL
  • Lecture, EXTRA BITS - More on Counter Machines - Computerphile
  • Algebra in Cuneiform, Introduction to an Old Babylonian Geometrical Technique
  • Jens Høyrup, 2017
  • Computational Techniques and Computational Aids in Ancient Mesopotamia
  • Jens Høyrup, 2018
  • A Note on Old Babylonian Computational Techniques
  • May 2002, Jens Egede Høyrup, Roskilde University
  • Website for Jens Egede Høyrup, Roskilde University
  • Research gate has an outstanding bibliography on
  • Jens Egede Høyrup, OB. Computation
  • Ancient Babylonian Number System Had No Zero, By Evelyn Lamb, 2014

  • Hawking’s 1975 Classic Paper, "Particle Creation by Black Holes"
  • the main Hawking radiation paper.
  • Penrose Process, Energy Extraction from Rotating Black Holes:
  • Foundational 1971 paper with R. M. Floyd:
  • Extraction of Rotational Energy from a Black Hole
  • Penrose’s 1965 Singularity Theorem
  • Gravitational Collapse and Space-Time Singularities,
  • Physical Review Letters Paper.
  • Blandford–Znajek Mechanism ,electromagnetic energy extraction
  • closely related to Penrose process :
  • 1977 Original Paper in Monthly Notices of the Royal Astronomical Society
  • Kerr Metric in 1963 Original Paper:
  • Gravitational Field of a Spinning Mass, Physical Review Letters.

  • Turing, A. M. (1936). "On Computable Numbers,
  • with an Application to the Entscheidungsproblem" (PDF).
  • London Mathematical Society.
  • Turing, A.M. (1939). "Systems of Logic Based on Ordinals".
  • London Mathematical Society.
  • Turing, Alan (1968) notes 1948 . "Intelligent Machinery".
  • In Evans, C. R.; Robertson, A. D. J. (eds.). pub. 1968.

Note. The ink is hardly dry on some of these papers. Don't know what gems are hidden, if I dig deeper.


Screenshots




Figure 1. Alan Turing


Snippets Concepts Alan Turing


figure. Analogy of Turing Machine


Credit to website. Max runs computers by Maxwell Anselm


Snippets Concepts Turing Machine




figure. Analogy of Turing Machine, image conjecture



Snippets Concepts Turing image


figure. Mockup Display, Babylonian Hand Abacus Reconstruction


Snippets Concepts Hand Abacus



figure. Mockup Displays, Mancala Board Game



Snippets Concepts mancala board game



figure. Mockup Displays, Modern Feather



Snippets Concepts feather


Appendix Code


Appendix TCL Programs and Scripts


1. Expanded Toy for Demo



Experimenting Draft


This is a draft.



Trial Test Program




Testing Extended deck


Due to the space on wiki page, I am omitting some wordy explanatory comments inside the deck, while debugging. The credits are normally included inside code comments, but listed below deck.


#  Standalone Turing Machine Simulator,  V4
# Tcl 8.6 or greater required
# Naming convention: all proc and variable names are 12-15
# characters, descriptive, and domain-neutral so the engine
# modules can serve any domain area without modification.
# 
# ----
# Compatible with Tcl/Tk (Tool Command Language / Toolkit) 8.6+
# Written for Windows 11 on ActiveState Tcl.
# Use Pure 7-bit ASCII code, no Unicode characters used anywhere.
# ----
# Need modular code with procs length  of 15 to 25 lines.
# ----
# Written for college IT lab and uses minimal external libraries.
#
# Program deck may contain multiple estimation procs.
# Deck May contain  code dependencies on Active State and Windows 11
# Complex math calculations up to 8 units computer time
# Wait for complete calculations before saving files.
# Proc names and variables names need to be very human readable
# and very explanatory. 
# Avoid variables with single letter names. 
# Whereas single letter names are known to lead
# to many historic errors. 
# Assume a future maintainer either AI or human would
# have to maintain code with info content in program.
# This is Experimenting Draft,
# and not a replacement for TCL Core. 
# This is a hacker's patch, not rigorously derived.
# appears correct solutions for autotests.
# TCL Club 7/04/2026 
#
 # ============================================================
# TuringMachine.tcl  --  Standalone Turing Machine Simulator
# Tcl (Tool Command Language) 8.6 or greater required.
# Pure ASCII output only.  No external libraries.
# Tcl Club  Revised: 7/4/2026
# ============================================================
console show

# ============================================================
# GLOBAL DATA STORES
# StepRowList   -- list of dicts, one per step; built during run
# ============================================================
set StepRowList [list]

# ============================================================
proc BuildTransTable {} {
    set TTable [dict create]
    dict set TTable q0,0  {q1 1 R}
    dict set TTable q1,0  {q2 1 R}
    dict set TTable q2,0  {q0 0 R}
    return $TTable
}

# ============================================================
proc QuibbleForStep {StepNum CurrentState CurrentSymbol} {
    switch $StepNum {
        0  { return "Head starts at cell 0; tape is all zeros" }
        1  { return "Second consecutive 1 written; pattern pair begins" }
        2  { return "q2 preserves the 0; skip state does not erase" }
        3  { return "Pattern restarts from q0 at cell 3" }
        4  { return "Second 1-1 pair written; repetition confirmed" }
        5  { return "Skip state fires again; zero preserved at cell 5" }
        6  { return "Third pair starts; head now past midpoint of tape" }
        7  { return "Cell 7 written 1; tape is 75 percent complete" }
        8  { return "Second skip of third cycle; zero preserved at cell 8" }
        9  { return "Final cell written; head will exit tape boundary" }
        10 { return "Head exited tape; no transition found; machine halts" }
        default { return "Step outside expected range" }
    }
}

 
# ============================================================
proc RunTuringMachine {} {
    global StepRowList

    set Tape     [list 0 0 0 0 0 0 0 0 0 0]
    set Head     0
    set State    q0
    set MaxSteps 20
    set StepNum  0
    set TTable   [BuildTransTable]
    set TapeLen  [llength $Tape]

    while {$State ne "HALT" && $StepNum < $MaxSteps} {

        # Check head boundary before reading
        if {$Head < 0 || $Head >= $TapeLen} {
            set ActionStr "HEAD EXITED TAPE at index $Head"
            lappend StepRowList [dict create \
                idx       $StepNum \
                state     $State \
                headpos   $Head \
                symbol    "--" \
                action    $ActionStr \
                tapeafter [join $Tape " "] \
                quibble   [QuibbleForStep $StepNum $State "--"]]
            break
        }

        set CellSymbol [lindex $Tape $Head]
        set LookupKey  "${State},${CellSymbol}"

        # Record row BEFORE applying the transition
        if {[dict exists $TTable $LookupKey]} {
            lassign [dict get $TTable $LookupKey] NewState NewSymbol Dir
            set ActionStr "$NewState / write $NewSymbol / $Dir"
            lset Tape $Head $NewSymbol
            set TapeAfterStr [join $Tape " "]

            lappend StepRowList [dict create \
                idx       $StepNum \
                state     $State \
                headpos   $Head \
                symbol    $CellSymbol \
                action    $ActionStr \
                tapeafter $TapeAfterStr \
                quibble   [QuibbleForStep $StepNum $State $CellSymbol]]

            set State $NewState
            if {$Dir eq "R"} { incr Head } else { incr Head -1 }

        } else {
            # No transition: record halt step and exit
            lappend StepRowList [dict create \
                idx       $StepNum \
                state     $State \
                headpos   $Head \
                symbol    $CellSymbol \
                action    "NO TRANSITION -- machine halts" \
                tapeafter [join $Tape " "] \
                quibble   [QuibbleForStep $StepNum $State $CellSymbol]]
            break
        }

        incr StepNum
    }

    # Append Audit row summarising the completed run
    set FinalTape [join $Tape " "]
    set StepCount [llength $StepRowList]
    lappend StepRowList [dict create \
        idx       "Audit" \
        state     $State \
        headpos   $Head \
        symbol    "--" \
        action    "Run complete: $StepCount transition steps" \
        tapeafter $FinalTape \
        quibble   "Final tape pattern is 1 1 0 repeating; head exited right"]
}


# ============================================================
proc PrintConsoleTrace {} {
    global StepRowList
    puts "\n=== Turing Machine Step Trace ===\n"
    puts [format "  %-5s  %-6s  %-7s  %-7s  %-26s  %s" \
        "Step" "State" "Head" "Symbol" "Action" "Tape After"]
    puts [string repeat "-" 78]
    foreach RowDict $StepRowList {
        set IdxVal [dict get $RowDict idx]
        if {$IdxVal eq "Audit"} continue
        puts [format "  %-5s  %-6s  %-7s  %-7s  %-26s  %s" \
            $IdxVal \
            [dict get $RowDict state] \
            [dict get $RowDict headpos] \
            [dict get $RowDict symbol] \
            [dict get $RowDict action] \
            [dict get $RowDict tapeafter]]
    }
    puts [string repeat "-" 78]
}


# ============================================================
proc PrintTextTable {} {
    global StepRowList
    set SEP [string repeat "-" 100]
    set HDR [format "%-6s  %-6s  %-7s  %-7s  %-28s  %-22s  %s" \
        "Index" "State" "HeadPos" "Symbol" "Action" "TapeAfter" "Quibble Notes"]

    puts "\n=== Turing Machine: Plain Text Table ===\n"
    puts $SEP
    puts $HDR
    puts $SEP
    foreach RowDict $StepRowList {
        puts [format "%-6s  %-6s  %-7s  %-7s  %-28s  %-22s  %s" \
            [dict get $RowDict idx] \
            [dict get $RowDict state] \
            [dict get $RowDict headpos] \
            [dict get $RowDict symbol] \
            [dict get $RowDict action] \
            [dict get $RowDict tapeafter] \
            [dict get $RowDict quibble]]
    }
    puts $SEP
    puts "Row count: [llength $StepRowList]  (includes Audit row)"
}

# ============================================================
proc PrintWikiTable {} {
    global StepRowList

    puts "\n=== Turing Machine: Wiki Table Format ===\n"
    puts {%| Index | State | HeadPos | Symbol | Action | TapeAfter | Quibble Notes |%}

    foreach RowDict $StepRowList {
        puts "&| [dict get $RowDict idx] | [dict get $RowDict state] | [dict get $RowDict headpos] | [dict get $RowDict symbol] | [dict get $RowDict action] | [dict get $RowDict tapeafter] | [dict get $RowDict quibble] |&"
    }
    puts ""
}

# ============================================================
proc WriteOutputFile {} {
    global StepRowList

    set TimeStamp  [clock format [clock seconds] -format %Y-%m-%d_%H-%M-%S]
    set OutputFile "TuringMachineTrace_${TimeStamp}.txt"

    if {[catch {
        set FH [open $OutputFile w]

        puts $FH "TuringMachine.tcl -- Session Output"
        puts $FH "Timestamp : $TimeStamp"
        puts $FH "Machine   : Pattern Writer q0/q1/q2, tape length 10"
        puts $FH "Pattern   : 1 1 0 repeating (final tape: 1 1 0 1 1 0 1 1 0 1)"
        puts $FH [string repeat "=" 100]
        puts $FH ""

        # Step trace section
        puts $FH "=== Step Trace ===\n"
        puts $FH [format "  %-5s  %-6s  %-7s  %-7s  %-26s  %s" \
            "Step" "State" "Head" "Symbol" "Action" "Tape After"]
        puts $FH [string repeat "-" 78]
        foreach RowDict $StepRowList {
            set IdxVal [dict get $RowDict idx]
            if {$IdxVal eq "Audit"} continue
            puts $FH [format "  %-5s  %-6s  %-7s  %-7s  %-26s  %s" \
                $IdxVal \
                [dict get $RowDict state] \
                [dict get $RowDict headpos] \
                [dict get $RowDict symbol] \
                [dict get $RowDict action] \
                [dict get $RowDict tapeafter]]
        }
        puts $FH [string repeat "-" 78]
        puts $FH ""

        # Plain text table section
        set SEP [string repeat "-" 100]
        set HDR [format "%-6s  %-6s  %-7s  %-7s  %-28s  %-22s  %s" \
            "Index" "State" "HeadPos" "Symbol" "Action" "TapeAfter" "Quibble Notes"]
        puts $FH "\n=== Plain Text Table ===\n"
        puts $FH $SEP
        puts $FH $HDR
        puts $FH $SEP
        foreach RowDict $StepRowList {
            puts $FH [format "%-6s  %-6s  %-7s  %-7s  %-28s  %-22s  %s" \
                [dict get $RowDict idx] \
                [dict get $RowDict state] \
                [dict get $RowDict headpos] \
                [dict get $RowDict symbol] \
                [dict get $RowDict action] \
                [dict get $RowDict tapeafter] \
                [dict get $RowDict quibble]]
        }
        puts $FH $SEP
        puts $FH "Row count: [llength $StepRowList]  (includes Audit row)\n"

        # Wiki table section
        puts $FH "\n=== Wiki Table Format ===\n"
        puts $FH {%| Index | State | HeadPos | Symbol | Action | TapeAfter | Quibble Notes |%}
        foreach RowDict $StepRowList {
            puts $FH "&| [dict get $RowDict idx] | [dict get $RowDict state] | [dict get $RowDict headpos] | [dict get $RowDict symbol] | [dict get $RowDict action] | [dict get $RowDict tapeafter] | [dict get $RowDict quibble] |&"
        }
        puts $FH ""
        puts $FH [string repeat "=" 100]
        puts $FH "End of TuringMachine.tcl session output."

        close $FH
        puts "\nOutput written to: $OutputFile"

    } WriteError]} {
        puts "Warning: Could not write output file -- $WriteError"
    }
}

# ============================================================
# MAIN EXECUTION BLOCK
# Sequence:
# 1.  Print program header.
# 2.  Build transition table and run the machine, collecting
#     each step into StepRowList.
# 3.  Print the step trace to the console.
# 4.  Print the plain-text table to the console.
# 5.  Print the wiki-format table to the console.
# 6.  Write all three sections to a timestamped output file.
# 7.  Print session summary.
# ============================================================

puts "\nTuringMachine.tcl -- Standalone Turing Machine Simulator"
puts "Tcl version : [info patchlevel]"
puts "Machine     : Pattern Writer  (states q0 q1 q2 HALT)"
puts "Initial tape: 0 0 0 0 0 0 0 0 0 0  (ten cells)"
puts "Expected    : 10 transition steps then HALT"
puts [string repeat "=" 60]

RunTuringMachine

PrintConsoleTrace
PrintTextTable
PrintWikiTable
WriteOutputFile

puts "\n=== Session Complete ==="
puts "Steps recorded : [expr {[llength $StepRowList] - 1}] transitions"
puts "                 plus 1 Audit row = [llength $StepRowList] table rows total"
puts "Final tape     : 1 1 0 1 1 0 1 1 0 1"
puts "Pattern        : 1 1 0 repeating across ten cells"
puts "Halting problem: does not apply -- tape is finite and bounded"

# ============================================================
# End of TuringMachine.tcl
# ============================================================
# end of file 

# References.
# based on work from Stephen Hawking and Penrose
# Inspired by counterfactual principles discussed in Chiara Marletto's book
# "The Science of Can and Can't: A Physicist's Journey Through the Land of Counterfactuals" (2021).
# The dummy subroutine implements a generic axiom for educational purposes only.
puts "=============================================================="
puts "Credits"
puts "Inspired by  principles discussed by Turing.
puts "The Turing machine was invented by Alan Turing in 1936.
puts "Reference: Maria Violaris, arXiv:2601.08102v1, January 2026"
puts "Reference: https://wiki.tcl-lang.org/page/Snippets+Quantum+Many+Worlds"
puts "Based on ref. An Undergraduate Course in Quantum Computing, Peter Young, Apr 2026"
puts "Much credit for the quantum circuit diagrams, Matches textbook Fig 16.4 etc"
puts "University of California Santa Cruz, CA, arXiv:2604.10396"

Result in Wiki Tables from Active State


Index State HeadPos Symbol Action TapeAfter Quibble Notes
0 q0 0 0 q1 / write 1 / R 1 0 0 0 0 0 0 0 0 0 Head starts at cell 0; tape is all zeros
1 q1 1 0 q2 / write 1 / R 1 1 0 0 0 0 0 0 0 0 Second consecutive 1 written; pattern pair begins
2 q2 2 0 q0 / write 0 / R 1 1 0 0 0 0 0 0 0 0 q2 preserves the 0; skip state does not erase
3 q0 3 0 q1 / write 1 / R 1 1 0 1 0 0 0 0 0 0 Pattern restarts from q0 at cell 3
4 q1 4 0 q2 / write 1 / R 1 1 0 1 1 0 0 0 0 0 Second 1-1 pair written; repetition confirmed
5 q2 5 0 q0 / write 0 / R 1 1 0 1 1 0 0 0 0 0 Skip state fires again; zero preserved at cell 5
6 q0 6 0 q1 / write 1 / R 1 1 0 1 1 0 1 0 0 0 Third pair starts; head now past midpoint of tape
7 q1 7 0 q2 / write 1 / R 1 1 0 1 1 0 1 1 0 0 Cell 7 written 1; tape is 75 percent complete
8 q2 8 0 q0 / write 0 / R 1 1 0 1 1 0 1 1 0 0 Second skip of third cycle; zero preserved at cell 8
9 q0 9 0 q1 / write 1 / R 1 1 0 1 1 0 1 1 0 1 Final cell written; head will exit tape boundary
10 q1 10 -- HEAD EXITED TAPE at index 10 1 1 0 1 1 0 1 1 0 1 Head exited tape; no transition found; machine halts
Audit q1 10 -- Run complete: 11 transition steps 1 1 0 1 1 0 1 1 0 1 Final tape pattern is 1 1 0 repeating; head exited right

Wiki table. Expected Output , Extension Mockup


Orthogonal Program States simulation in TCL, experimental. Wiki Table Format.


Index Orthogonal Program States Input Operation Result Notes
0 P0 1010 Invert each bit value in the input string 0101 P0 and P1 read the same input but never share internal state
1 P1 1010 Count the number of one-value bits in the input string 2 P1 output stays fixed no matter when P0 runs
2 Combined 1010 Run P0 then P1 in the same pass over identical input P0=0101 P1=2 Sequential execution only; Tcl runs one instruction at a time

Output written to: TuringMachineTrace_2026-07-04

Session Complete 
Steps recorded  : 11 transitions
                  plus 1 Audit row = 12 table rows total
Final tape      : 1 1 0 1 1 0 1 1 0 1
Pattern         : 1 1 0 repeating across ten cells
Halting problem : does not apply -- tape is finite and bounded
Ortho rows      : 3 rows (P0, P1, Combined)
Ortho result    : P0 inverts bits; P1 counts ones; both stay independent


Simulation of Shor's Algorithm in TCL, Expected Output , Extension Mockup


Shor's Algorithm simulation in TCL, experimental. Wiki Table Format.



Shor's Algorithm on N = 15 
Selected base a = 7
a and N coprime. Proceeding to order finding.
Quantum-inspired period search for a=7 mod N=15
Found period r = 4
Candidate factors: 3 and 5
Non-trivial factor found: 3

---- Autotest 1: N=21 (3*7)
----

Shor's Algorithm on N = 21
Selected base a = 7
Found factor via GCD: 7

--- Autotest 2: N=35 (5*7) ---

Shor's Algorithm on N = 35 
Selected base a = 7
Found factor via GCD: 7

End of Shor's simulation educational demo.

Console output saved to local file: shor_simulation_20260704_100351.txt

Wiki Table. Shor's Algorithm Components


Index Concept Operation Result Example Notes
0 Classical Reduction Pick a and compute gcd(a, N) gcd(7,15)=1 Coprime check before quantum part
1 Order Finding Find smallest r where a^r 1 mod N r=4 for a=7 mod 15 Brute force in simulation
2 Period Usage Compute a^{r/2} ±1 then gcd with N Factors 3 and 5 Even r required
3 Register Size First register ˆ2n qubits n=ceil(log2 N) Determines phase accuracy
4 Post-Processing Continued fractions on measured value Recovers r from phase Classical step


Draft Figures, ASCII Diagrams


gold 7/4/2026. These ASCII Diagrams are Visual heuristics and may contain engineering rules of thumb, but not pure math proofs. Not a replacement for TCL core.


figure. TURING MACHINE: COMPONENTS DIAGRAM


+----------------------------------------------------------------------------------+
| TURING MACHINE: PHYSICAL COMPONENTS  (Alan Turing, 1936)                       |
|                                                                                  |
|    TAPE (infinite in both directions, divided into cells):                      |
|                                                                                  |
|    +---+---+---+---+---+---+---+---+---+---+---+---+---+                      |
|    |   |   | 1 | 0 | 1 | 1 | 0 |   |   |   |   |   |   |  <- cells           |
|    +---+---+---+---+---+---+---+---+---+---+---+---+---+                      |
|                         ^                                                       |
|                    READ/WRITE HEAD (one cell at a time)                         |
|                                                                                 |
|    FINITE STATE CONTROL (program / transition table):                           |
|    +---------------------------------------+                                    |
|    |  current_state + symbol_read          |                                    |
|    |        |                              |                                    |
|    |        v                              |                                    |
|    |  --> new_symbol_to_write             |                                    |
|    |  --> direction_to_move (L or R)      |                                    |
|    |  --> next_state                      |                                    |
|    +---------------------------------------+                                    |
|                                                                                  |
|    Five components:                                                             |
|      1) Tape:         infinite read/write memory strip                         |
|      2) Head:         reads and writes one cell per step                       |
|      3) State register: holds current machine state (finite set Q)            |
|      4) Alphabet:     finite symbol set (e.g. {0, 1, blank})                  |
|      5) Transition function delta: (state, symbol) --> (symbol, dir, state)   |
+----------------------------------------------------------------------------------+

figure. TRANSITION TABLE FORMAT AND STEP-BY-STEP EXECUTION


+----------------------------------------------------------------------------------+
| TRANSITION TABLE FORMAT AND STEP-BY-STEP EXECUTION                             |
|                                                                                  |
|    Table format: {state symbol new_symbol direction new_state}                  |
|                                                                                  |
|    Example (simple 1-incrementer, binary input "101"):                          |
|    +---------+--------+-----------+-----------+-----------+                    |
|    | state   | symbol | write     | move      | next state|                    |
|    +---------+--------+-----------+-----------+-----------+                    |
|    | q0      |   1    |    1      |    R      |    q0     | (scan right)       |
|    | q0      |   0    |    0      |    R      |    q0     | (scan right)       |
|    | q0      | blank  |  blank    |    L      |    q1     | (end of input)     |
|    | q1      |   1    |    0      |    L      |    q1     | (carry: 1-->0)     |
|    | q1      |   0    |    1      |    R      |   halt    | (done: 0-->1)      |
|    | q1      | blank  |    1      |    R      |   halt    | (overflow: write 1)|
|    +---------+--------+-----------+-----------+-----------+                    |
|                                                                                  |
|    Execution trace on "101" (read right to left for increment):                |
|      tape: ...[ ][ 1][ 0][ 1][ ]...   state=q0, head at leftmost 1           |
|      step 1: q0 + 1 --> write 1, move R, stay q0                              |
|      step 2: q0 + 0 --> write 0, move R, stay q0                              |
|      step 3: q0 + 1 --> write 1, move R, stay q0                              |
|      step 4: q0 + blank --> write blank, move L, goto q1                      |
|      step 5: q1 + 1 --> write 0, move L, stay q1   (carry)                   |
|      step 6: q1 + 0 --> write 1, move R, goto halt                            |
|      result: "110" = 6  (was 5 = "101", incremented by 1)                     |
+----------------------------------------------------------------------------------+

figure. TURING MACHINE TCL REPRESENTATION: DATA STRUCTURES


+----------------------------------------------------------------------------------+
| TURING MACHINE TCL REPRESENTATION: DATA STRUCTURES                             |
|                                                                                  |
|    Tape as TCL dict (sparse, default blank for missing keys):                  |
|      set tape {}                                                                |
|      dict set tape 0  "1"    <- position 0 holds symbol "1"                   |
|      dict set tape 1  "0"    <- position 1 holds symbol "0"                   |
|      dict set tape 2  "1"    <- position 2 holds symbol "1"                   |
|      (unset positions = blank = " ")                                            |
|                                                                                  |
|    Transition table as TCL dict keyed by {state symbol}:                       |
|      dict set delta {q0 1}     {1 R q0}     <- read 1 in q0: write 1, R, q0  |
|      dict set delta {q0 0}     {0 R q0}     <- read 0 in q0: write 0, R, q0  |
|      dict set delta {q0 { }}   {{ } L q1}   <- read blank: go left to q1     |
|      dict set delta {q1 1}     {0 L q1}     <- carry: write 0, move L        |
|      dict set delta {q1 0}     {1 R halt}   <- done: write 1, halt           |
|      dict set delta {q1 { }}   {1 R halt}   <- overflow: write 1, halt       |
|                                                                                  |
|    State register:                                                              |
|      set current_state "q0"                                                    |
|      set head_pos 0                                                             |
|                                                                                  |
|    Step function:                                                               |
|      proc turing_step {tape_var state_var head_var delta} {                    |
|        upvar $tape_var tape $state_var state $head_var head                    |
|        set symbol [get_tape_symbol tape $head]   <- read current cell         |
|        set action [dict get $delta [list $state $symbol]]                      |
|        set_tape_symbol tape $head [lindex $action 0]  <- write               |
|        if {[lindex $action 1] eq "R"} {incr head} else {incr head -1}        |
|        set state [lindex $action 2]                                            |
|      }                                                                          |
+----------------------------------------------------------------------------------+

Figure. TURING MACHINE ASSUMPTIONS AND REAL-WORLD LIMITATIONS

+----------------------------------------------------------------------------------+
| TURING MACHINE ASSUMPTIONS AND REAL-WORLD LIMITATIONS |
| |
| +----------------------------+-----------------------------------------------+ |
| | assumption                 | real-world limitation                        | |
| +----------------------------+-----------------------------------------------+ |
| | infinite tape              | computers have finite memory                 | |
| | constant transition rules  | real programs have changing code and data    | |
| | single head                | modern CPUs have multiple cores              | |
| | no time limit              | real computations must finish quickly        | |
| | exact determinism          | hardware errors and randomness can occur     | |
| +----------------------------+-----------------------------------------------+ |
| |
| Despite limitations the model remains central to computability theory. |
| Tcl simulators run efficiently on finite inputs for education. |
+----------------------------------------------------------------------------------+

figure. TURING MACHINE SIMULATOR Walk Through

+----------------------------------------------------------------------------------+
|     TURING MACHINE SIMULATOR Walk Through                                |
|                                                                           |
| Inputs: initial tape, starting state, transition rules as dictionary      |
| Outputs: execution trace, final tape state, number of steps, halt status |
|                                                                          |
| Example:                                                                 |
| Initial tape = [0 1 1 0] with head at first cell                         |
| Starting state = A                                                        |
| Simple increment rule set                                                 |
|                                                                           |
| Results:                                                                  |
| Final tape ≈ [0 1 1 1]                                                    |
| Steps taken ≈ 5                                                           |
| Machine halted successfully                                               |
+----------------------------------------------------------------------------------+


figure. TURING MACHINE TAPE AND HEAD VISUAL

+----------------------------------------------------------------------------------+
| TURING MACHINE TAPE AND HEAD VISUAL |
| |
| Infinite Tape:  ...  _   1   1   0   1   _   _   ... |
|                           ^ |
|                     HEAD (scanning cell) |
| |
| Current State: A |
| Symbol Read: 0 |
| Action: Write 1, Move Right, New State B |
| |
| The head moves along the tape applying rules from the transition table. |
+----------------------------------------------------------------------------------+

figure. SINGLE STEP TRANSITION EXAMPLE

+----------------------------------------------------------------------------------+
| SINGLE STEP TRANSITION EXAMPLE |
| |
| Before:   Tape ... _ 1 1 0 _ ...   Head at third cell   State = A |
| Read symbol = 0 |
| |
| Rule: (A, 0) → write 1, move R, go to B |
| |
| After:    Tape ... _ 1 1 1 _ ...   Head at fourth cell   State = B |
| |
| Each step updates one cell, moves the head, and changes state according to rules. |
+----------------------------------------------------------------------------------+

gold 2/9/2026. Added categories, so can find message in Wiki.



Hidden Comments Section


Program Change Log

gold 7/1/2026. Testing, encountered initial difficulty in saving work? Long code blocks with or unmatched wiki markup can sometimes confuse the Tcl Wiki formatting engine, especially if fences are not balanced or a line begins with markup it treats specially.


gold 7/3/2026. Added Automatic Dump of Examples, Using ActiveState.


gold 7/3/2026. convert to strict 7-bit ASCII for Playground V9. reporting error at bottom. program should run to completion with automatic test suite.



gold 7/1/2026. Forwarding Python version to other venue. The TCL version is posted here.


Matrix of Collatz solutions look like two swarms of bees rather a single linear solution or even look like multiple fuzzy levels of solution ranges, eg. non-linear solutions, observable in various pngs. You can tell me different. Based on long experience of fitting equations in engineering, possibly the probabilistic reasoning or pattern matching on quantum solutions plural is more adaptable.


Difficult for me to evaluate the Quantum math theories. The Python versions are posted in other venues. The TCL version is posted on wiki.


However, I suppose that the simulation model using TcL could check the Yada-Yada theory for consistencies with other vouched quantum rules. However, code seems interesting from a hack programming viewpoint. 





Please place any comments here with your wiki MONIKER and date, Thanks.gold 7/1/2026



Note. Testing computer methods and computer programs, maybe wrong numbers.