ScientificReasoner<T>

Models & Types · AiDotNet.Reasoning.DomainSpecific

Specialized reasoner for scientific problems and hypotheses.

Implements: IDomainReasoner<T>

For Beginners

This reasoner helps solve scientific problems using the scientific method.

What is ScientificReasoner? A specialized reasoning system for scientific problems that follows the scientific method:

  1. Observation → 2. Hypothesis → 3. Prediction → 4. Experiment → 5. Analysis → 6. Conclusion

Example - Physics Problem:

Problem: "A ball is dropped from a 20-meter tall building. How long does it take to hit the ground?"

Scientific reasoning:

1. Identify known values: height = 20m, g = 9.8 m/s²
2. Identify unknown: time (t)
3. Choose formula: h = ½gt²
4. Solve: 20 = ½(9.8)t² → t² = 4.08 → t ≈ 2.02 seconds
5. Verify: Units check (seconds), magnitude reasonable
6. Conclusion: The ball takes approximately 2 seconds to hit the ground

Example - Chemistry Problem:

Problem: "Balance this equation: H₂ + O₂ → H₂O"

Scientific reasoning:

1. Count atoms on each side

Left: H=2, O=2
Right: H=2, O=1

2. Observe imbalance: Need 2 oxygen on right
3. Add coefficient: H₂ + O₂ → 2H₂O
4. Recount: Left H=2, Right H=4 (imbalanced!)
5. Adjust: 2H₂ + O₂ → 2H₂O
6. Verify: H: 4=4 ✓, O: 2=2 ✓
7. Conclusion: Balanced equation is 2H₂ + O₂ → 2H₂O

Example - Biology Problem:

Problem: "Why do cells need mitochondria?"

Scientific reasoning:

1. What are mitochondria? Organelles in cells
2. What do they do? Produce ATP (energy)
3. Why is ATP needed? Powers cellular processes
4. What if no mitochondria? No energy production
5. Evidence: Cells without mitochondria die or are inactive
6. Conclusion: Cells need mitochondria to generate energy for survival

Scientific domains:

  • Physics (mechanics, thermodynamics, electromagnetism)
  • Chemistry (equations, reactions, stoichiometry)
  • Biology (cells, genetics, evolution, ecology)
  • Earth Science (geology, meteorology, oceanography)
  • Astronomy (celestial mechanics, cosmology)

Reasoning patterns:

  • Hypothesis generation
  • Experimental design
  • Data analysis and interpretation
  • Formula application
  • Unit conversion and dimensional analysis
  • Equation balancing
  • Causal mechanism explanation
  • Prediction and verification

Key features:

  • Systematic problem-solving approach
  • Emphasis on verification and validation
  • Uses scientific notation and units
  • Incorporates domain-specific formulas
  • Checks for physical plausibility
  • Multiple verification methods

Usage example:

var chatModel = new OllamaChatClient<double>("llama3");
var reasoner = new ScientificReasoner<double>(chatModel);

// Physics problem
var result = await reasoner.SolveAsync(
"Calculate the kinetic energy of a 2kg object moving at 5 m/s",
domain: "physics",
useFormulas: true
);

// Chemistry problem
result = await reasoner.SolveAsync(
"Balance the equation: CH₄ + O₂ → CO₂ + H₂O",
domain: "chemistry"
);

Constructors

Constructor Summary
ScientificReasoner(IChatClient<T> chatModel, bool enableCriticalValidation) Initializes a new instance of the ScientificReasoner class.

Methods

Method Summary
Task<ReasoningResult<T>> AnalyzeDataAsync(string experimentData, string hypothesis, ReasoningConfig config, CancellationToken cancellationToken) Analyzes experimental data and draws conclusions.
Task<ReasoningResult<T>> DesignExperimentAsync(string hypothesis, string domain, ReasoningConfig config, CancellationToken cancellationToken) Designs an experiment to test a hypothesis.
Task<ReasoningResult<T>> GenerateHypothesisAsync(string observation, string domain, ReasoningConfig config, CancellationToken cancellationToken) Generates a hypothesis for an observation or phenomenon.
Task<ReasoningResult<T>> SolveAsync(string problem, string domain, ReasoningConfig config, bool useFormulas, bool useSelfConsistency, CancellationToken cancellationToken) Solves a scientific problem using domain-specific reasoning.