afaceuser09 commited on
Commit
ed0d8f2
·
verified ·
1 Parent(s): f57e5ca

Update reasoning_engine.py

Browse files
Files changed (1) hide show
  1. reasoning_engine.py +150 -0
reasoning_engine.py CHANGED
@@ -88,6 +88,156 @@ _REASONING_SKILLS = [
88
  ("software engineering", "architecture", "identify requirements and boundaries, choose components/interfaces, evaluate tradeoffs, and define failure handling"),
89
  ("software engineering", "testing", "identify observable behavior, partition cases, include edge cases, assert invariants, and test regressions"),
90
  ("software engineering", "security review", "map trust boundaries, identify attack surfaces, validate inputs/authorization, and verify mitigations"),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
91
  ]
92
 
93
  _VARIANTS = [
 
88
  ("software engineering", "architecture", "identify requirements and boundaries, choose components/interfaces, evaluate tradeoffs, and define failure handling"),
89
  ("software engineering", "testing", "identify observable behavior, partition cases, include edge cases, assert invariants, and test regressions"),
90
  ("software engineering", "security review", "map trust boundaries, identify attack surfaces, validate inputs/authorization, and verify mitigations"),
91
+ ("mathematics", "arithmetic", "break the problem into operations, preserve order of operations, calculate carefully, and independently verify the result"),
92
+ ("mathematics", "fractions", "convert representations consistently, identify common denominators when needed, perform the operation, simplify, and verify"),
93
+ ("mathematics", "ratios", "identify corresponding quantities, establish the ratio relationship, solve proportionally, and check whether the result has the correct scale"),
94
+ ("mathematics", "percentages", "identify the reference quantity, distinguish percentage change from percentage points, calculate precisely, and sanity-check the magnitude"),
95
+ ("mathematics", "word problems", "translate the natural-language description into variables and equations, solve systematically, and verify the answer against the wording"),
96
+ ("mathematics", "linear equations", "isolate the unknown using equivalent operations, preserve equality at every step, and substitute the result back into the original equation"),
97
+ ("mathematics", "systems of equations", "identify variables and equations, choose substitution/elimination/matrix methods appropriately, solve, and verify every equation"),
98
+ ("mathematics", "quadratic equations", "identify the quadratic structure, select factoring/completing-the-square/quadratic-formula methods, solve all relevant roots, and verify"),
99
+ ("mathematics", "inequalities", "transform both sides while preserving the inequality relationship, reverse the sign when multiplying or dividing by a negative, and check intervals"),
100
+ ("mathematics", "sequences", "identify the generating pattern or recurrence, distinguish arithmetic/geometric/nonlinear behavior, derive the requested term, and test against known terms"),
101
+ ("mathematics", "series", "identify whether the sequence is finite or infinite, select the appropriate summation method, apply convergence conditions when necessary, and verify"),
102
+ ("mathematics", "exponents", "apply exponent laws consistently, simplify symbolic expressions, handle zero and negative exponents correctly, and verify with numerical substitution"),
103
+ ("mathematics", "logarithms", "apply logarithm identities and domain restrictions, transform the equation into a solvable form, solve, and check the original domain"),
104
+ ("mathematics", "functions", "identify inputs, outputs, domain, range, and transformations, apply the function definition, and verify composition or inverse relationships"),
105
+ ("mathematics", "coordinate geometry", "translate geometric relationships into coordinate equations, calculate using distance/slope/midpoint formulas, and verify geometrically"),
106
+ ("mathematics", "trigonometry", "identify the relevant triangle or periodic relationship, choose the correct identity or theorem, calculate carefully, and check angle/domain constraints"),
107
+ ("mathematics", "vectors", "represent quantities as components, apply vector operations consistently, preserve dimensional meaning, and verify the magnitude or direction"),
108
+ ("mathematics", "matrices", "identify dimensions and compatible operations, perform transformations carefully, and verify dimensions and results"),
109
+ ("mathematics", "linear algebra", "represent the problem using vectors/matrices, identify the required transformation or system, solve, and verify algebraic consistency"),
110
+ ("mathematics", "optimization", "define the objective and constraints, identify candidate extrema, evaluate boundary cases, and verify that the proposed optimum satisfies all constraints"),
111
+ ("mathematics", "number theory", "identify divisibility, modular, prime, or factorization structure, exploit relevant properties, and verify the result"),
112
+ ("mathematics", "combinatorics", "define what constitutes a distinct outcome, determine whether order and repetition matter, choose the appropriate counting principle, and verify with a smaller case"),
113
+ ("mathematics", "permutations", "determine whether arrangement order matters, account for repeated elements when necessary, calculate systematically, and verify"),
114
+ ("mathematics", "combinations", "determine whether order matters, identify the population and selection size, apply the correct counting formula, and sanity-check"),
115
+ ("mathematics", "expected value", "define possible outcomes and probabilities, multiply each outcome by its probability, sum contributions, and verify the result lies within plausible bounds"),
116
+ ("mathematics", "Bayesian reasoning", "define hypotheses and evidence, distinguish prior probability from likelihood, apply Bayes' rule correctly, and check normalization"),
117
+ ("mathematics", "conditional probability", "define the conditioning event explicitly, restrict the sample space appropriately, calculate the conditional probability, and check independence assumptions"),
118
+ ("mathematics", "discrete probability", "define the sample space, identify mutually exclusive and overlapping events, select the appropriate probability rule, and verify bounds"),
119
+ ("mathematics", "continuous probability", "identify the density or distribution, determine the required interval or tail probability, integrate or use the appropriate distribution function, and check normalization"),
120
+ ("mathematics", "statistical inference", "identify the parameter of interest, select an appropriate estimator or test, state assumptions, calculate uncertainty, and interpret cautiously"),
121
+ ("mathematics", "data interpretation", "identify what the axes, units, sample, and statistic actually represent, calculate relevant comparisons, and avoid unsupported causal conclusions"),
122
+
123
+ # --------------------------- LOGIC -----------------------------
124
+
125
+ ("logic", "formal logic", "translate statements into propositions, identify premises and conclusions, apply valid inference rules, and distinguish implication from equivalence"),
126
+ ("logic", "syllogisms", "identify premises, determine their logical structure, derive only conclusions supported by the premises, and test for counterexamples"),
127
+ ("logic", "inductive reasoning", "identify observed patterns, generate the strongest supported generalization, distinguish evidence from certainty, and identify possible counterexamples"),
128
+ ("logic", "abductive reasoning", "identify the observations, generate plausible explanations, compare how well each explains the evidence, and distinguish plausibility from proof"),
129
+ ("logic", "counterexamples", "identify the universal claim being tested, search for the smallest valid counterexample, verify that it satisfies the premises, and use it to assess the claim"),
130
+ ("logic", "contradiction", "identify mutually incompatible claims, trace the assumptions producing the conflict, and determine which premise or inference requires revision"),
131
+ ("logic", "truth tables", "identify all relevant propositions, enumerate combinations systematically, evaluate operators correctly, and determine validity or equivalence"),
132
+ ("logic", "causal reasoning", "distinguish correlation, temporal order, confounding, and mechanism, identify alternative explanations, and state what evidence would discriminate between them"),
133
+ ("logic", "fallacy detection", "identify the exact claim and supporting argument, inspect whether the inference follows, and distinguish genuine logical errors from mere disagreement"),
134
+ ("logic", "constraint reasoning", "identify variables, domains, hard constraints, and soft preferences, propagate restrictions, search systematically, and verify every solution"),
135
+ ("logic", "invariant reasoning", "identify a property that remains unchanged under allowed operations, prove that the invariant holds, and use it to constrain possible outcomes"),
136
+ ("logic", "case analysis", "partition the problem into exhaustive and mutually appropriate cases, solve each case, and ensure no case is omitted or double-counted"),
137
+ ("logic", "proof construction", "state the proposition precisely, select direct proof/contradiction/induction/construction as appropriate, establish each implication, and check for hidden assumptions"),
138
+ ("logic", "proof by induction", "define the base case, formulate the induction hypothesis precisely, prove the inductive step, and conclude only what the induction establishes"),
139
+ ("logic", "necessary and sufficient conditions", "distinguish conditions that guarantee a result from those merely required for it, prove each direction separately, and identify edge cases"),
140
+
141
+ # ---------------------- GENERAL PROBLEM SOLVING -----------------
142
+
143
+ ("reasoning", "problem decomposition", "divide the problem into independent or dependent subproblems, solve the highest-leverage components first, then integrate and verify"),
144
+ ("reasoning", "root cause analysis", "separate symptoms from causes, construct a causal chain, test competing explanations against evidence, and identify the deepest actionable cause"),
145
+ ("reasoning", "first principles", "strip the problem down to fundamental facts and constraints, derive consequences from those foundations, and avoid relying on unsupported assumptions"),
146
+ ("reasoning", "constraint analysis", "list hard constraints, soft constraints, resources, dependencies, and objectives before selecting a solution"),
147
+ ("reasoning", "tradeoff analysis", "identify competing objectives, quantify or characterize the relevant tradeoffs, identify constraints, and explain what changes under different priorities"),
148
+ ("reasoning", "scenario analysis", "define plausible scenarios, identify variables that differ between them, determine consequences, and avoid treating uncertain scenarios as established facts"),
149
+ ("reasoning", "counterfactual reasoning", "define the hypothetical change precisely, hold unrelated conditions constant where appropriate, trace consequences, and distinguish inference from speculation"),
150
+ ("reasoning", "hypothesis testing", "state a falsifiable hypothesis, identify predictions, gather relevant evidence, test alternatives, and update the conclusion based on evidence"),
151
+ ("reasoning", "error analysis", "identify where an error could enter, determine its direction and magnitude, isolate the root cause, and estimate its effect on the final result"),
152
+ ("reasoning", "uncertainty analysis", "identify uncertain inputs and assumptions, determine how they affect the conclusion, distinguish known from estimated values, and communicate uncertainty clearly"),
153
+ ("reasoning", "estimation", "identify the quantity to estimate, choose reasonable reference values, simplify the problem, calculate an order-of-magnitude result, and sanity-check it"),
154
+ ("reasoning", "Fermi estimation", "break an unknown quantity into estimable factors, use defensible approximations, calculate the order of magnitude, and identify the dominant uncertainty"),
155
+ ("reasoning", "backward reasoning", "start from the desired outcome, determine the conditions required immediately before it, recursively establish prerequisites, and verify the resulting path"),
156
+ ("reasoning", "forward reasoning", "start from established facts, apply valid rules step by step, track newly established information, and stop when the target is reached or impossible"),
157
+ ("reasoning", "analogy reasoning", "identify the structural similarity between problems, map corresponding elements carefully, and verify that the analogy does not break under relevant differences"),
158
+ ("reasoning", "simplification", "remove irrelevant complexity while preserving the essential structure, solve the simplified model, and determine whether the simplification changes the conclusion"),
159
+ ("reasoning", "verification", "independently reconstruct the key result, test assumptions and edge cases, and compare the independent result with the original"),
160
+ ("reasoning", "self-correction", "inspect a proposed solution for unsupported steps, locate inconsistencies, revise the weakest step, and rerun the affected reasoning"),
161
+ ("reasoning", "ambiguity resolution", "identify multiple plausible interpretations, determine which are supported by context, state the interpretation used, and explain how the answer changes under alternatives"),
162
+ ("reasoning", "information sufficiency", "identify exactly what information is required to answer the question, distinguish necessary from optional information, and avoid fabricating missing values"),
163
+ ("reasoning", "decision under uncertainty", "identify possible actions, outcomes, probabilities or uncertainty ranges where available, costs and benefits, and sensitivity to assumptions"),
164
+ ("reasoning", "prioritization", "identify objectives, urgency, impact, dependencies, and resource constraints, then construct a defensible ordering without confusing importance with urgency"),
165
+
166
+ # -------------------------- SCIENCE ----------------------------
167
+
168
+ ("science", "scientific method", "formulate a testable hypothesis, identify variables and controls, predict observations, evaluate evidence, and distinguish results from interpretation"),
169
+ ("science", "experimental design", "define the research question, identify independent/dependent/control variables, minimize confounding, choose measurements, and define success criteria"),
170
+ ("science", "measurement", "identify the quantity and units, distinguish precision from accuracy, track uncertainty, and verify dimensional consistency"),
171
+ ("science", "dimensional analysis", "express quantities using fundamental units, cancel compatible dimensions, detect invalid equations, and verify the final units"),
172
+ ("science", "physics problem solving", "translate the physical situation into variables and governing laws, solve symbolically where possible, substitute values, and check units and limiting cases"),
173
+ ("science", "mechanics", "identify forces, motion variables, reference frames, and conservation laws, construct the governing equations, solve, and check physical plausibility"),
174
+ ("science", "energy conservation", "identify the system and energy forms, account for transfers and losses, write the conservation equation, solve, and verify the energy balance"),
175
+ ("science", "momentum", "define the system, identify external impulses, apply momentum conservation when justified, solve component-wise, and verify direction and magnitude"),
176
+ ("science", "thermodynamics", "define the system and state variables, identify energy and entropy transfers, apply the appropriate law, and check physical constraints"),
177
+ ("science", "electricity", "identify voltage, current, resistance, power, and circuit topology, apply governing relationships, and verify conservation and component limits"),
178
+ ("science", "chemistry calculations", "identify substances and quantities, balance the chemical relationship, convert units through stoichiometry, calculate, and verify conservation"),
179
+ ("science", "chemical equilibrium", "identify the reaction and equilibrium expression, account for concentrations/activities, apply the relevant equilibrium relationship, and check the direction of change"),
180
+ ("science", "acid-base reasoning", "identify the acid/base system, determine relevant equilibria and concentrations, calculate pH or related quantities, and check approximations"),
181
+ ("science", "biology mechanisms", "identify the biological entities and mechanism, connect cause to effect through intermediate processes, and distinguish established evidence from hypothesis"),
182
+ ("science", "ecology", "identify populations, resources, interactions, and environmental constraints, model relevant relationships, and consider feedback and time scale"),
183
+ ("science", "evolutionary reasoning", "identify variation, inheritance, selection pressures, and population-level effects, then distinguish individual adaptation from population change"),
184
+ ("science", "scientific evidence evaluation", "identify study design, sample, measurement, controls, effect size, uncertainty, and limitations before interpreting the conclusion"),
185
+
186
+ # ------------------------ ENGINEERING --------------------------
187
+
188
+ ("engineering", "requirements analysis", "translate vague goals into measurable requirements, identify constraints and acceptance criteria, and distinguish mandatory requirements from preferences"),
189
+ ("engineering", "failure mode analysis", "identify components and failure modes, estimate causes and effects, prioritize risks, and design mitigations and detection mechanisms"),
190
+ ("engineering", "reliability", "identify failure mechanisms, estimate rates or probabilities, model system dependencies, and determine how redundancy or maintenance affects reliability"),
191
+ ("engineering", "safety analysis", "identify hazards, exposure paths, severity and likelihood, protective controls, and residual risk, then verify that controls address the actual hazard"),
192
+ ("engineering", "optimization", "define objective function and constraints, identify dominant variables, compare feasible designs, and verify robustness rather than optimizing a fragile nominal case"),
193
+ ("engineering", "capacity planning", "estimate workload, resource demand, growth, bottlenecks, utilization, and safety margins, then test the design under peak conditions"),
194
+ ("engineering", "systems thinking", "identify components, interfaces, feedback loops, dependencies, bottlenecks, and emergent behavior before proposing local fixes"),
195
+ ("engineering", "control systems", "identify the controlled variable, actuator, sensor, feedback path, disturbance, and stability requirements, then analyze response and failure modes"),
196
+ ("engineering", "signal analysis", "identify the signal, noise, sampling constraints, frequency characteristics, and measurement objectives, then select an appropriate analysis method"),
197
+ ("engineering", "design validation", "translate requirements into measurable tests, construct representative test conditions, define pass/fail criteria, execute checks, and document limitations"),
198
+
199
+ # ---------------------- COMPUTER SCIENCE ------------------------
200
+
201
+ ("computer science", "recursion", "define the base case, identify the recursive reduction, prove progress toward termination, and verify returned values"),
202
+ ("computer science", "search", "define the search space and target condition, choose an appropriate search strategy, preserve completeness/correctness, and analyze complexity"),
203
+ ("computer science", "binary search", "establish the sorted invariant, maintain valid bounds, choose the midpoint safely, eliminate the impossible half, and verify termination"),
204
+ ("computer science", "hashing", "identify the key and lookup requirements, choose a suitable hash structure, account for collisions and equality semantics, and analyze expected complexity"),
205
+ ("computer science", "trees", "identify the tree invariant, choose traversal or update operations appropriate to the structure, preserve invariants, and analyze complexity"),
206
+ ("computer science", "heaps", "identify priority-queue requirements, preserve the heap property after updates, choose appropriate operations, and analyze complexity"),
207
+ ("computer science", "database reasoning", "identify entities, relationships, constraints, query requirements, consistency needs, and indexing opportunities before selecting a schema or query"),
208
+ ("computer science", "distributed systems", "identify nodes, communication, state ownership, failure modes, consistency requirements, and recovery behavior before selecting a design"),
209
+ ("computer science", "networking", "identify endpoints, protocols, addressing, transport behavior, failure points, and expected traffic, then trace the data path"),
210
+ ("computer science", "operating systems", "identify processes, threads, memory, files, scheduling, synchronization, and system calls relevant to the problem"),
211
+ ("computer science", "compiler reasoning", "separate lexical, syntactic, semantic, intermediate, optimization, and code-generation stages, then identify where an error or transformation occurs"),
212
+ ("computer science", "formal verification", "state the invariant or specification precisely, identify the implementation obligation, prove relevant properties, and test assumptions"),
213
+ ("computer science", "algorithm correctness", "state the invariant or correctness condition, show initialization, preservation, and termination where appropriate, and verify edge cases"),
214
+ ("computer science", "amortized analysis", "identify operations whose costs vary, select an accounting/potential method, derive aggregate cost, and convert it to amortized complexity"),
215
+
216
+ # ---------------------- SOFTWARE PRACTICE -----------------------
217
+
218
+ ("software engineering", "requirements clarification", "separate explicit requirements from assumptions, identify ambiguities and edge cases, and define observable acceptance criteria"),
219
+ ("software engineering", "code review", "inspect correctness, maintainability, security, performance, error handling, and compatibility, prioritizing concrete defects over stylistic preferences"),
220
+ ("software engineering", "refactoring", "identify the behavior that must remain unchanged, isolate structural improvements, make small transformations, and run regression checks"),
221
+ ("software engineering", "bug diagnosis", "reproduce the issue, minimize the failing case, inspect relevant state transitions, identify the root cause, patch the cause, and retest"),
222
+ ("software engineering", "API compatibility", "identify the existing contract, inputs, outputs, errors, side effects, and version constraints, then preserve compatibility or document deliberate changes"),
223
+ ("software engineering", "test design", "identify behavior partitions, boundary conditions, invalid inputs, state transitions, and regressions, then construct tests with clear expected outcomes"),
224
+ ("software engineering", "performance diagnosis", "measure before changing code, identify the dominant bottleneck, distinguish CPU/memory/I/O/contention costs, optimize the bottleneck, and benchmark again"),
225
+ ("software engineering", "security reasoning", "identify assets, trust boundaries, attacker capabilities, entry points, authorization requirements, and failure modes, then verify mitigations"),
226
+ ("software engineering", "maintainability", "identify coupling, cohesion, duplication, unclear contracts, and hidden dependencies, then improve structure while preserving observable behavior"),
227
+ ("software engineering", "documentation reasoning", "identify the intended audience and task, explain prerequisites and behavior accurately, include examples where useful, and avoid documenting assumptions as guarantees"),
228
+
229
+ # --------------------- LANGUAGE & COMMUNICATION -----------------
230
+
231
+ ("language", "reading comprehension", "identify the main claim, supporting evidence, qualifications, assumptions, and conclusions before answering questions about the text"),
232
+ ("language", "text analysis", "separate explicit statements from implications, identify structure and evidence, and avoid attributing claims that the text does not support"),
233
+ ("language", "summarization", "identify the central information and supporting points, remove redundancy, preserve important qualifications, and avoid introducing new claims"),
234
+ ("language", "argument analysis", "identify claims, premises, evidence, assumptions, counterarguments, and conclusions, then evaluate whether the reasoning follows"),
235
+ ("language", "instruction following", "extract explicit requirements, ordering constraints, formatting requirements, exclusions, and success conditions before producing the requested result"),
236
+ ("language", "ambiguity analysis", "identify words or constructions with multiple plausible meanings, use context to distinguish them, and state remaining ambiguity when material"),
237
+ ("language", "analogy explanation", "map an unfamiliar concept onto a familiar structure while explicitly identifying where the analogy holds and where it breaks"),
238
+ ("language", "explanation", "identify the audience's likely knowledge level, introduce concepts in dependency order, use precise examples, and verify that the explanation answers the actual question"),
239
+ ("language", "technical communication", "separate facts, assumptions, procedures, results, and caveats, use precise terminology, and structure information for easy verification"),
240
+ ("language", "translation reasoning", "preserve meaning, intent, register, ambiguity, and important technical terminology rather than translating words mechanically"),
241
  ]
242
 
243
  _VARIANTS = [