-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathp!=np_proof.py
More file actions
65 lines (52 loc) · 2.42 KB
/
p!=np_proof.py
File metadata and controls
65 lines (52 loc) · 2.42 KB
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import tkinter as tk
from tkinter import ttk
import numpy as np
from multiprocessing import Process, Queue
import time
# Function to calculate Boolean function properties
def compute_boolean_properties(n, result_queue):
# Simulate computations; in a real implementation this would involve complex calculations
total_functions = 2 ** (2 ** n)
total_circuits = n ** 10 # for simplicity, use n^10 as polynomial size
# Simulate some long-running calculation
time.sleep(2) # Simulate delay for computation
result_queue.put((total_functions, total_circuits))
# Function to update progress
def run_simulation(progress_bar, output_text, n):
result_queue = Queue()
p = Process(target=compute_boolean_properties, args=(n, result_queue))
p.start()
while True:
progress_bar['value'] += 10
output_text.insert(tk.END, f"Calculating for n={n}: {progress_bar['value']}% done.\n")
output_text.yview(tk.END) # Scroll to the end
if p.is_alive():
time.sleep(0.5) # Update every half second
else:
break
total_functions, total_circuits = result_queue.get()
output_text.insert(tk.END, f"Total Boolean functions: {total_functions}\n")
output_text.insert(tk.END, f"Total polynomial-size circuits: {total_circuits}\n")
output_text.insert(tk.END, "Calculation complete.\nYou can review the findings above.\n")
# Main GUI Function
def create_gui():
root = tk.Tk()
root.title("P ≠ NP Computation Simulator")
frame = ttk.Frame(root, padding="10")
frame.grid(row=0, column=0, sticky=(tk.W, tk.E, tk.N, tk.S))
# Input for n
ttk.Label(frame, text="Enter value for n:").grid(column=0, row=0, sticky=tk.W)
n_entry = ttk.Entry(frame)
n_entry.grid(column=1, row=0, sticky=(tk.W, tk.E))
# Output text area
output_text = tk.Text(frame, height=10, width=50)
output_text.grid(column=0, row=1, columnspan=2, sticky=(tk.W, tk.E))
# Progress bar
progress_bar = ttk.Progressbar(frame, length=200, mode='determinate')
progress_bar.grid(column=0, row=2, columnspan=2, sticky=(tk.W, tk.E))
# Start button
start_button = ttk.Button(frame, text="Start Simulation", command=lambda: run_simulation(progress_bar, output_text, int(n_entry.get())))
start_button.grid(column=0, row=3, columnspan=2)
root.mainloop()
if __name__ == "__main__":
create_gui()