Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -15,147 +15,53 @@ def llm_response(text):
|
|
15 |
contents= text)
|
16 |
return response.text
|
17 |
|
18 |
-
def
|
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 |
-
1
|
59 |
-
)
|
60 |
-
2
|
61 |
-
β
|
62 |
-
i=1
|
63 |
-
n
|
64 |
-
β
|
65 |
-
i=
|
66 |
-
2
|
67 |
-
n(n+1)
|
68 |
-
β
|
69 |
-
.
|
70 |
-
Case Analysis β Use when different scenarios must be considered separately. Example: Proving that a quadratic equation has at most two real roots.
|
71 |
-
Constructive Proof β Show existence by explicitly constructing an example. Example: Proving that there exists an irrational number
|
72 |
-
π₯
|
73 |
-
x such that
|
74 |
-
π₯
|
75 |
-
π₯
|
76 |
-
x
|
77 |
-
x
|
78 |
-
is rational.
|
79 |
-
Non-constructive Proof β Prove existence without constructing an explicit example, often using logic or set theory. Example: Proving that there exists a prime number between
|
80 |
-
π
|
81 |
-
n and
|
82 |
-
2
|
83 |
-
π
|
84 |
-
2n.
|
85 |
-
Proof by Exhaustion β Use when a theorem holds for a small, finite set of cases that can be checked individually. Example: Verifying a property for small integers.
|
86 |
-
Proof using a Counterexample β Disprove a general claim by providing a specific case where it fails. Example: Showing that not all differentiable functions are continuous.
|
87 |
-
The model should analyze the structure of the theorem and automatically select the most suitable proof technique based on these guidelines.
|
88 |
-
|
89 |
-
3. Construct the Proof
|
90 |
-
Step-by-step logical explanation.
|
91 |
-
|
92 |
-
Verification and validation.
|
93 |
-
4. Handle Edge Cases
|
94 |
-
If proof fails:
|
95 |
-
|
96 |
-
Highlight missing assumptions.
|
97 |
-
Provide a minimal counterexample (if the statement is false).
|
98 |
-
Suggest a reformulation or alternative direction.
|
99 |
-
Expected Output:
|
100 |
-
β Proof Found:
|
101 |
-
|
102 |
-
Step-by-step reasoning.
|
103 |
-
Proof strategy justification.
|
104 |
-
|
105 |
-
β Proof Not Possible:
|
106 |
-
|
107 |
-
Identified logical gap or missing assumptions.
|
108 |
-
Suggested refinement or counterexample.
|
109 |
-
Example Usage:
|
110 |
-
Input:
|
111 |
-
"Every even integer greater than 2 can be expressed as the sum of two prime numbers."
|
112 |
-
|
113 |
-
Output:
|
114 |
-
β Proof Attempt:
|
115 |
-
|
116 |
-
Identified Proof Strategy:
|
117 |
-
|
118 |
-
This is an existential statement (β two primes p1, p2 such that p1 + p2 = n).
|
119 |
-
Since direct proof is difficult, contradiction and case analysis are common approaches.
|
120 |
-
Computational methods confirm the conjecture for large values of
|
121 |
-
π
|
122 |
-
n, but no general proof exists.
|
123 |
-
Proof Attempt:
|
124 |
-
|
125 |
-
|
126 |
-
theorem goldbach_conjecture (n : β) (h : even n β§ n > 2) :
|
127 |
-
β p1 p2, prime p1 β§ prime p2 β§ p1 + p2 = n :=
|
128 |
-
begin
|
129 |
-
-- Step 1: Assume n is an even integer greater than 2
|
130 |
-
-- Step 2: Search for prime pairs (p1, p2) such that p1 + p2 = n
|
131 |
-
-- Step 3: If no counterexamples exist up to a given range, assume general case
|
132 |
-
-- Theorem remains unproven but verified for large n using computational methods
|
133 |
-
end
|
134 |
-
β Proof Not Found:
|
135 |
-
|
136 |
-
No general proof within standard number theory axioms.
|
137 |
-
Computational verification up to
|
138 |
-
10
|
139 |
-
18
|
140 |
-
10
|
141 |
-
18
|
142 |
-
supports the conjecture.
|
143 |
-
Suggest refining the conjecture by imposing additional constraints.
|
144 |
-
|
145 |
-
You should intelligently selects the best proof strategy.
|
146 |
-
Provides clear justifications for strategy choice.
|
147 |
-
|
148 |
-
Output a rigorous proof or meaningful insight even when a full proof is impossible in markdown format.''')
|
149 |
-
return theorem_llm
|
150 |
|
151 |
iface = gr.Interface(
|
152 |
-
fn=
|
153 |
-
inputs=gr.Textbox(label="
|
154 |
outputs=gr.Markdown(label="Agent's response"), # Output as HTML
|
155 |
title="PolyProb",
|
156 |
-
description="PolyProb is an advanced AI agent that guides users through the intricate maze of computational complexity. This agent scrutinizes problem descriptions with sophisticated LLM prompts and symbolic reasoning. It classifies problems into categories such as P, NP, NP-complete, NP-hard, or beyond (e.g., PSPACE, EXPTIME), while providing clear, concise explanations of its reasoning. As part of AI Quotientβs Millennium Math Challenge, it is the first step towards solving the P vs NP problem",
|
157 |
theme = gr.themes.Ocean(),
|
158 |
-
examples = ["
|
159 |
)
|
160 |
|
161 |
# Launch the app
|
|
|
15 |
contents= text)
|
16 |
return 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 |
|
57 |
iface = gr.Interface(
|
58 |
+
fn=pvsnp,
|
59 |
+
inputs=gr.Textbox(label="What problem would you like to classify as P or NP?"),
|
60 |
outputs=gr.Markdown(label="Agent's response"), # Output as HTML
|
61 |
title="PolyProb",
|
62 |
+
description="PolyProb is an advanced AI agent that guides users through the intricate maze of computational complexity. This agent scrutinizes problem descriptions with sophisticated LLM prompts and symbolic reasoning. It classifies problems into categories such as P, NP, NP-complete, NP-hard, or beyond (e.g., PSPACE, EXPTIME), while providing clear, concise explanations of its reasoning. As part of AI Quotientβs Millennium Math Challenge, it is the first step towards solving the P vs NP problem.",
|
63 |
theme = gr.themes.Ocean(),
|
64 |
+
examples = ["Can you find a path that visits each node exactly once in a given graph?", "How efficiently can two nXn matrices be multiplied?", "Is there a subset of given numbers that sums to a target value?"]
|
65 |
)
|
66 |
|
67 |
# Launch the app
|