#[non_exhaustive]pub enum CheckError {
Invalid(Box<Invalid>),
Refused(Refused),
}Expand description
Why a check did not accept a proof: a verdict that the term is no proof, or a check that ended before it decided.
Keep the two variants apart:
Invalidis a verdict. The term does not prove its conclusion in the mode, andInvalidsays at which node and why.Refusedis no verdict. The check reached a bound of itsLimits, or the caller’s stop, before it decided. Never report it as an invalid proof. To get a verdict, check again with a larger bound.
describe writes either with formulas in place of
member ids.
§Examples
use deduxit::Limits;
use deduxit::linear::proofs::Fault;
use deduxit::linear::{CheckError, Forest, Member, Mode, Node, NodeId, Proof, Sequent};
// ⊢ ~A, A ⊗ ~B, B, with the members 0: ~A, 1: A ⊗ ~B, 2: A,
// 3: ~B, 4: B, and the premises of the ⊗ the wrong way round.
let sequent: Sequent = "A, A -o B |- B".parse()?;
let (o, n) = (Member::new, NodeId::new);
let nodes = vec![
Node::Ax(o(0), o(2)),
Node::Ax(o(3), o(4)),
Node::Tensor(o(1), n(1), n(0)),
];
let proof = Proof::new(Forest::new(&sequent)?, nodes, n(2))?;
let error = proof.check(Mode::CLASSICAL).unwrap_err();
let CheckError::Invalid(invalid) = &error else {
panic!("a verdict was expected: {error}");
};
assert!(matches!(invalid.fault, Fault::Missing { premise: 0, .. }));
assert_eq!(
error.describe(&proof).to_string(),
"node 2 (⊗ on A ⊗ ~B from 1, 0) with premises ⊢ ~B, B and ⊢ ~A, A: \
premise 0 lacks A"
);
// Within one byte of memory the check ends before it decides.
let limits = Limits::default().with_memory_bytes(Some(1));
let error = proof.check_within(Mode::CLASSICAL, &limits, |_| false).unwrap_err();
assert!(matches!(error, CheckError::Refused(_)));Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
Invalid(Box<Invalid>)
The term is not a proof of its conclusion in the mode.
Refused(Refused)
The check ended without a verdict, at a bound or at the caller’s stop.
Implementations§
Source§impl CheckError
impl CheckError
Source§impl CheckError
impl CheckError
Sourcepub fn describe<'a>(&'a self, owner: &'a impl Owner) -> Described<'a>
pub fn describe<'a>(&'a self, owner: &'a impl Owner) -> Described<'a>
Returns the error for display with formulas in place of member ids,
read from owner: the proof that failed, or its forest. Nodes keep
their ids, as in node 2 (⊗ on A ⊗ ~B from 0, 1) with premises ⊢ ~A, ~B and ⊢ ~B, B: premise 0 lacks A.
Trait Implementations§
Source§impl Clone for CheckError
impl Clone for CheckError
Source§impl Debug for CheckError
impl Debug for CheckError
Source§impl Display for CheckError
impl Display for CheckError
impl Eq for CheckError
Source§impl Error for CheckError
impl Error for CheckError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0:
use the Display impl or to_string()
Source§impl From<CheckError> for Error
impl From<CheckError> for Error
Source§fn from(error: CheckError) -> Self
fn from(error: CheckError) -> Self
Wraps the checker’s error, a fault and a refusal alike.
Source§impl PartialEq for CheckError
impl PartialEq for CheckError
Source§impl Serialize for CheckError
impl Serialize for CheckError
impl StructuralPartialEq for CheckError
Auto Trait Implementations§
impl Forget for CheckError
impl Freeze for CheckError
impl Move for CheckError
impl RefUnwindSafe for CheckError
impl Send for CheckError
impl Sync for CheckError
impl Unpin for CheckError
impl UnsafeUnpin for CheckError
impl UnwindSafe for CheckError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<U, T> ToOwnedObj<U> for Twhere
U: FromObjRef<T>,
impl<U, T> ToOwnedObj<U> for Twhere
U: FromObjRef<T>,
Source§fn to_owned_obj(&self, data: FontData<'_>) -> U
fn to_owned_obj(&self, data: FontData<'_>) -> U
Convert this type into
T, using the provided data to resolve any offsets.