-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
112 lines (103 loc) · 4.08 KB
/
main.py
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
import os
import sys
from src.synthesis import synthesis_method
from src.verification import verification_method
from src.parser import check_Formula
def read_text_file(file_path):
Formula =""
try:
with open(file_path, 'r') as file:
lines = file.readlines()
for line in lines:
Formula =Formula+line.strip()
return Formula
except FileNotFoundError:
print("File not found at the given location.")
except Exception as e:
print("An error occurred:", e)
def remove_spaces(input_string):
return input_string.replace(" ", "")
# Function to execute specific tasks based on user's choice
def execute_task(choice):
#uncomment shortest path or any other for its function to work
switch = {
1: "shortest_path",
2: "Robustness under initial uncertainty",
3: "Robustness under action uncertainty",
4: "Initial-state opacity",
5: "Current-state opacity",
6: "Service Level Agreement",
7: "Non Interference",
8: "Linearizability",
9: "Mutation Testing",
10: "side channel timing attacks",
11: "observational Determinism"
}
task = switch.get(choice, "Invalid choice")
if callable(task):
task() # Execute the function
elif task != "Invalid choice":
print("Algorithm : ", task)
return task
# Here you can perform any specific action related to the chosen task
else:
print("Invalid choice. Please select a number from 1 to 11.")
# Function for Shortest Path algorithm
def shortest_path():
# Write your shortest path algorithm implementation here
print("Executing Shortest Path algorithm...")
def is_valid_file_path(file_path):
return os.path.isfile(file_path)
def is_valid_input(user_input):
return user_input.lower() in ['yes', 'no']
# Press the green button in the gutter to run the script.
if __name__ == '__main__':
#file_location =("C:/Users/v revanth reddy/Downloads/pythonProject/pythonProject/input_files/text")
file_location = ("input_files/text")
dts_file_location =("input_files/dts.txt")
Formula=read_text_file(file_location)
print("Formula : "+Formula)
print("==========================================================================================")
"""
while True:
print("Choose from the following tasks:")
print("1. Shortest path")
print("2. Robustness under initial uncertainty")
print("3. Robustness under action uncertainty")
print("4. Initial-state opacity")
print("5. Current-state opacity")
print("6: Service Level Agreement")
print("7. Non Interference")
print("8. Linearizability")
print("9. Mutation Testing")
print("10. side channel timing attacks")
print("11. observational Determinism")
choice = input("Enter the number corresponding to your choice: ")
if choice.isdigit():
choice = int(choice)
if choice in range(1, 12):
break
else:
print("Invalid choice. Please select a number from 1 to 12.")
else:
print("Invalid input. Please enter a number.")
Algorithm = execute_task(choice) #use this to write functions to specific task
Num_Algorithm = choice
"""
Num_Algorithm=check_Formula(Formula)
if Num_Algorithm==12:
print("Invalid Formula")
sys.exit(1)
print("==============================================================================================")
choice = read_text_file(dts_file_location)
choice = remove_spaces(choice)
choice = choice.split(';')[4]
print(choice)
if choice.lower() == "verification":
method = "verification"
verification_method(Formula, Num_Algorithm,dts_file_location,method)
elif choice.lower()== "synthesis":
method = "synthesis"
synthesis_method(Formula, Num_Algorithm,dts_file_location,method)
#print("Method : "+ method)
print("===============================================================================================")