AI-Quotient commited on
Commit
00104af
·
verified ·
1 Parent(s): d58fa88

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +69 -23
app.py CHANGED
@@ -17,40 +17,86 @@ def llm_response(text):
17
 
18
  def pvsnp(problem):
19
  classification = llm_response(f'''
 
20
 
21
- You are an expert in computational complexity theory with deep knowledge of both classical complexity classes (P, NP, NP-complete, NP-hard) and modern developments such as parameterized complexity, fine-grained complexity, and recent findings like the Minimum Circuit Size Problem (MCSP). Your task is to analyze a given problem description and classify it into one of the following categories:
22
 
23
- - **P**: Problems that can be solved in deterministic polynomial time.
24
- - **NP**: Problems for which a proposed solution can be verified in deterministic polynomial time.
25
- - **NP-complete**: Problems that are both in NP and as hard as any problem in NP, via polynomial-time reductions.
26
- - **NP-hard**: Problems that are at least as hard as NP-complete problems but may not be in NP.
27
- - **Beyond NP**: Problems that likely belong to more complex classes (e.g., PSPACE, EXPTIME) or are undecidable.
28
- - **Other**: If the problem fits into an alternative complexity class (e.g., BPP, co-NP) or does not clearly align with the categories above, note that explicitly.
29
 
30
- **Problem Description:**
 
 
 
 
 
 
 
 
 
 
31
  {problem}
32
 
33
- **Guidelines:**
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
 
35
- 1. **Comprehensive Analysis**:
36
- - Determine whether the problem is primarily a decision problem, an optimization problem, or a function computation.
37
- - Identify key input and output characteristics and any explicit constraints.
38
 
39
- 2. **Complexity Characteristics**:
40
- - Examine if the problem exhibits features common to polynomial-time algorithms (e.g., dynamic programming, greedy strategies) or if it has structural similarities to known NP-complete problems.
41
- - Assess whether there is potential for polynomial-time reductions from or to well-studied problems in the literature.
42
 
43
- 3. **Advanced and Recent Research Considerations**:
44
- - Incorporate insights from the latest research, including the implications of the Minimum Circuit Size Problem (MCSP) for NP-completeness.
45
- - Consider parameterized complexity aspects: does the problem admit fixed-parameter tractable (FPT) solutions under certain parameters?
46
- - Evaluate any connections to fine-grained complexity results, such as relationships to the Strong Exponential Time Hypothesis (SETH) or other conjectures.
47
- - If the problem has probabilistic or average-case aspects, mention how these might affect its classification.
48
 
49
- 4. **Explanation of Reasoning**:
50
- - Provide a brief, clear explanation for your classification. Justify your decision by referencing specific features of the problem and connecting them to established theory and recent research insights.
51
 
52
- **Your Classification and Explanation:**
53
 
 
54
  ''')
55
  return classification
56
 
 
17
 
18
  def pvsnp(problem):
19
  classification = llm_response(f'''
20
+ You are an expert in computational complexity theory, specializing in both classical complexity classes (P, NP, NP-complete, NP-hard) and modern developments (e.g., parameterized complexity, fine-grained complexity, Minimum Circuit Size Problem).
21
 
22
+ Your task is to classify a given problem into one of the following categories:
23
 
24
+ P: Solvable in deterministic polynomial time.
 
 
 
 
 
25
 
26
+ NP: Verifiable in polynomial time.
27
+
28
+ NP-complete: Both in NP and NP-hard.
29
+
30
+ NP-hard: At least as hard as NP-complete problems, possibly outside NP.
31
+
32
+ Beyond NP: Likely in PSPACE, EXPTIME, or undecidable.
33
+
34
+ Other: Fits alternative complexity classes (e.g., BPP, co-NP).
35
+
36
+ Problem Description:
37
  {problem}
38
 
39
+ If the given problem is a NP-hard problem, decompose the NP-hard problem into polynomial-time solvable subproblems without solving them.
40
+
41
+ 🔹 Inputs:
42
+ A formal definition and instance of the NP-hard problem (e.g., SAT, TSP, Graph Coloring).
43
+
44
+ Optional: Constraints or domain knowledge.
45
+
46
+ 🔹 Decomposition Process:
47
+ Graph Representation & Structural Analysis
48
+
49
+ Convert the problem into a graph (if applicable).
50
+
51
+ Identify independent or tractable substructures.
52
+
53
+ Classification of Subproblems
54
+
55
+ Detect polynomially solvable parts (e.g., tree structures, bipartite graphs).
56
+
57
+ Separate them from harder components.
58
+
59
+ Partitioning & Transformation
60
+
61
+ Break the problem into independent or loosely connected subproblems.
62
+
63
+ Ensure each subproblem is in P or provably easier than the original.
64
+
65
+ Output a structured breakdown.
66
+
67
+ 🔹 Outputs:
68
+ A list of P-complexity subproblems.
69
+
70
+ A dependency graph of their relationships in ASCII format.
71
+
72
+ A complexity analysis report quantifying decomposition effectiveness.
73
+
74
+ Guidelines for Classification:
75
+ Problem Analysis
76
+
77
+ Determine if the problem is a decision, optimization, or function computation problem.
78
+
79
+ Identify key input/output characteristics and constraints.
80
+
81
+ Complexity Insights
82
+
83
+ Check for polynomial-time solvability via known techniques (dynamic programming, greedy methods).
84
+
85
+ Assess reductions to/from well-studied problems.
86
+
87
+ Advanced Considerations
88
 
89
+ Incorporate recent research (e.g., MCSP's implications for NP-completeness).
 
 
90
 
91
+ Evaluate parameterized complexity (FPT results) and fine-grained complexity (SETH, other conjectures).
 
 
92
 
93
+ Consider probabilistic or average-case complexity aspects.
 
 
 
 
94
 
95
+ Justification
 
96
 
97
+ Provide a concise explanation for the classification, referencing key problem features and relevant research.
98
 
99
+ Your Classification and Explanation:
100
  ''')
101
  return classification
102