engine.derivation

Engine-native derivation logging, contradiction recording, and proof reconstruction.

Exceptions

ContradictionWarning

Warning emitted when a contradiction is detected.

ContradictionDetectedError

Error raised when a contradiction is detected.

Classes

DerivationLogger

Interface for sinks of engine-native derivation records.

ContradictionRecorder

Interface for sinks of engine-native contradiction records.

InMemoryDerivationLogger

Simple in-memory sink for engine-native derivation records.

DropDerivationLogger

Drop-all sink for derivation records (no retention).

InMemoryContradictionRecorder

Append-all sink for contradiction diagnostics (unbounded retention).

RaiseOnContradictionRecorder

Append each contradiction then raise ContradictionDetectedError.

DropContradictionRecorder

Discard contradiction diagnostics after optional warning (zero retention).

ExplanationReconstructor

Interface for rebuilding DirectProof values from derivation records.

DerivationProofReconstructor

Rebuild a DirectProof tree from engine-native trace records.

Functions

format_contradiction_record(→ str)

Format one contradiction diagnostic for logs, warnings, or exceptions.

Module Contents

engine.derivation.format_contradiction_record(record: engine.proof.ContradictionRecord) → str

Format one contradiction diagnostic for logs, warnings, or exceptions.

exception engine.derivation.ContradictionWarning

Bases: UserWarning

Warning emitted when a contradiction is detected.

class engine.derivation.DerivationLogger

Bases: Protocol

Interface for sinks of engine-native derivation records.

These records are engine provenance artifacts, not user-facing proof steps.

record(record: engine.proof.DerivationRecord) → None

Append one engine-native derivation record.

iter_records() → collections.abc.Iterable[engine.proof.DerivationRecord]

Yield derivation records currently held by the sink.

clear() → None

Remove all derivation records from the sink.

class engine.derivation.ContradictionRecorder

Bases: Protocol

Interface for sinks of engine-native contradiction records.

record(record: engine.proof.ContradictionRecord) → None

Append one engine-native contradiction record.

iter_records() → collections.abc.Iterable[engine.proof.ContradictionRecord]

Yield contradiction records currently held by the sink.

clear() → None

Remove all contradiction records from the sink.

class engine.derivation.InMemoryDerivationLogger

Simple in-memory sink for engine-native derivation records.

records: collections.abc.MutableSequence[engine.proof.DerivationRecord] = []
record(record: engine.proof.DerivationRecord) → None

Append one derivation record to the in-memory log.

iter_records() → collections.abc.Iterable[engine.proof.DerivationRecord]

Return a snapshot of all logged derivation records.

clear() → None

Remove all logged derivation records.

class engine.derivation.DropDerivationLogger

Drop-all sink for derivation records (no retention).

record(record: engine.proof.DerivationRecord) → None

Discard record without retaining it.

iter_records() → collections.abc.Iterable[engine.proof.DerivationRecord]

Return an empty sequence because no records are retained.

clear() → None

No-op because no records are retained.

class engine.derivation.InMemoryContradictionRecorder

Append-all sink for contradiction diagnostics (unbounded retention).

When warn is true (default), each contradiction also emits ContradictionWarning via warnings.warn().

warn: bool = True
records: collections.abc.MutableSequence[engine.proof.ContradictionRecord] = []
record(record: engine.proof.ContradictionRecord) → None

Append one contradiction record to the in-memory log.

iter_records() → collections.abc.Iterable[engine.proof.ContradictionRecord]

Return a snapshot of all logged contradiction records.

clear() → None

Remove all logged contradiction records.

exception engine.derivation.ContradictionDetectedError(record: engine.proof.ContradictionRecord)

Bases: RuntimeError

Error raised when a contradiction is detected.

record: engine.proof.ContradictionRecord
class engine.derivation.RaiseOnContradictionRecorder

Append each contradiction then raise ContradictionDetectedError.

Retention is unbounded (same list semantics as InMemoryContradictionRecorder) unless clear() is called.

records: collections.abc.MutableSequence[engine.proof.ContradictionRecord] = []
record(record: engine.proof.ContradictionRecord) → None

Append record and raise ContradictionDetectedError.

iter_records() → collections.abc.Iterable[engine.proof.ContradictionRecord]

Return a snapshot of contradiction records logged before any raise.

clear() → None

Remove all logged contradiction records.

class engine.derivation.DropContradictionRecorder

Discard contradiction diagnostics after optional warning (zero retention).

iter_records() is always empty—there is nothing for contradiction_records() or explanation reconstruction to read from this recorder alone.

warn: bool = True
record(record: engine.proof.ContradictionRecord) → None

Optionally warn about record and discard it without retention.

iter_records() → collections.abc.Iterable[engine.proof.ContradictionRecord]

Return an empty sequence because no records are retained.

clear() → None

No-op because no records are retained.

class engine.derivation.ExplanationReconstructor

Bases: Protocol

Interface for rebuilding DirectProof values from derivation records.

reconstruct(goal: engine.proof.ProofPayload, records: collections.abc.Iterable[engine.proof.DerivationRecord | engine.proof.ContradictionRecord]) → engine.proof.DirectProof

Rebuild a DirectProof for goal from engine trace records.

class engine.derivation.DerivationProofReconstructor

Rebuild a DirectProof tree from engine-native trace records.

Triple goals are reconstructed from DerivationRecord values. Contradiction goals are reconstructed from ContradictionRecord values.

reconstruct(goal: engine.proof.ProofPayload, records: collections.abc.Iterable[engine.proof.DerivationRecord | engine.proof.ContradictionRecord]) → engine.proof.DirectProof

Build a DirectProof tree for goal from derivation and contradiction records.