UNPKG

chop-logic-core

Version:

Core classes, methods and functions for calculating logical formulas and constructing proofs within the Chop Logic project.

91 lines (90 loc) 3.41 kB
import type { HilbertAxiomPayload, HilbertDerivedPayload, PropAtom, PropFormula, PropProofStep } from "../../../models"; /** * Represents a complete proof in Hilbert-style calculus. * Manages a sequence of proof steps where the final step is the goal formula. * Each step can be an axiom, premise, or derived from previous steps. * * @category Hilbert Calculus */ export declare class HilbertProof { private steps; private readonly goal; /** * Creates a new Hilbert proof with a goal formula. * @param goal - The target formula to prove */ constructor(goal: PropFormula); /** * Gets all proof steps in order. * @returns Array of proof steps */ getSteps(): readonly PropProofStep[]; /** * Gets the goal formula of this proof. * @returns The target formula */ getGoal(): PropFormula; /** * Gets the number of steps in the proof. * @returns The current step count */ getStepCount(): number; /** * Gets a specific step by index (1-based). * @param index - The step number (1-based) * @returns The proof step, or undefined if not found */ getStep(index: number): PropProofStep | undefined; /** * Adds a premise (given assumption) to the proof. * @param formula - The premise formula * @param comment - Optional explanation for the premise * @returns The added proof step */ addPremise(formula: PropFormula, comment?: string): PropProofStep; /** * Adds an axiom step to the proof. * @param payload - The axiom payload containing formulas and schema * @param comment - Optional explanation for the axiom * @returns The added proof step */ addAxiom(payload: HilbertAxiomPayload, comment?: string): PropProofStep; /** * Adds a derived step to the proof using a Hilbert calculus rule. * @param payload - The derived step payload containing formulas, schema, and step references * @param comment - Optional explanation for the derivation * @returns The added proof step */ addDerivedStep(payload: HilbertDerivedPayload, comment?: string): PropProofStep[]; /** * Checks if the proof is complete (last step matches the goal). * @returns True if the last step's formula matches the goal */ isComplete(): boolean; /** * Gets the last step in the proof (which should be the goal). * @returns The final proof step, or undefined if no steps exist */ getLastStep(): PropProofStep | undefined; /** * Reiterates (repeats) a previously proved step. * Allows referring to a formula from an earlier step in the proof. * @param fromIndex - The index of the step to reiterate (1-based) * @param comment - Optional explanation for the reiteration * @returns The added reiteration step * @throws {Error} if the step index is invalid */ reiterateStep(fromIndex: number, comment?: string): PropProofStep; /** * Clears all steps from the proof. */ clear(): void; /** * Replaces all occurrences of an atom with a formula or atom in all proof steps. * The goal formula is not modified. * * @param atom - The atomic proposition to replace * @param substitute - The formula or atom to substitute */ replace(atom: PropAtom, substitute: PropFormula | PropAtom): void; }