-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhalting_problem.py
More file actions
28 lines (21 loc) · 855 Bytes
/
halting_problem.py
File metadata and controls
28 lines (21 loc) · 855 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import random
import time
# Simulated Turing Machine Runner for Halting Problem demo
def simulate_tm_execution(tm_description, input_string):
print(f"Simulating TM: {tm_description} with input: {input_string}")
# Simulated behavior
print("Running...")
time.sleep(1)
# Fake a halting decision
halts = random.choice([True, False])
if halts:
print("✅ This Turing Machine HALTS on the given input.")
else:
print("❌ This Turing Machine DOES NOT HALT on the given input.")
print("(Simulation stopped due to potential infinite loop)")
# User interaction
if __name__ == "__main__":
print("=== Halting Problem Simulator ===")
desc = input("Enter a description of the Turing Machine: ")
user_input = input("Enter the input string: ")
simulate_tm_execution(desc, user_input)