from typing import List, Optional
from pydantic import BaseModel, Field


class Proposition(BaseModel):
    """A declarative statement that can be true or false."""
    statement: str = Field(..., description="The proposition in natural language")
    confidence: Optional[float] = Field(None, ge=0.0, le=1.0, description="Confidence level in this proposition (0-1)")


class Premise(BaseModel):
    """A starting assumption or given fact in logical reasoning."""
    proposition: Proposition = Field(..., description="The premise statement")
    justification: Optional[str] = Field(None, description="Why this premise is accepted (e.g., axiom, observation, prior conclusion)")


class Inference(BaseModel):
    """A logical step that derives a conclusion from premises."""
    rule: str = Field(..., description="The inference rule or reasoning method used (e.g., modus ponens, deduction, induction)")
    premises: List[Proposition] = Field(..., description="The propositions used as input to this inference")
    conclusion: Proposition = Field(..., description="The proposition derived from applying the rule to the premises")
    explanation: Optional[str] = Field(None, description="Human-readable explanation of this inference step")


class Argument(BaseModel):
    """A logical argument: a sequence of inferences from premises to a conclusion."""
    title: str = Field(..., description="Title or main claim of this argument")
    premises: List[Premise] = Field(..., description="Starting premises for this argument")
    inferences: List[Inference] = Field(..., description="Chain of logical inferences")
    conclusion: Proposition = Field(..., description="Final conclusion derived from the premises")
    is_valid: Optional[bool] = Field(None, description="Whether the argument is logically valid")


class Reasoning(BaseModel):
    """A complete reasoning process with multiple arguments supporting an overall conclusion."""
    question: str = Field(..., description="The question or problem being reasoned about")
    context: Optional[str] = Field(None, description="Background context for the reasoning")
    arguments: List[Argument] = Field(..., description="List of arguments contributing to the overall reasoning")
    final_conclusion: Proposition = Field(..., description="The ultimate conclusion of the reasoning process")
    confidence: Optional[float] = Field(None, ge=0.0, le=1.0, description="Overall confidence in the final conclusion")

