pub struct TwoSided<'a> { /* private fields */ }Expand description
The two-sided view of a derivation of classical linear logic, drawn as its sequent was written.
Each formula stands on the side of ⊢ it was written on, each rule
has its two-sided name (⊗L, ⅋R, ⊸L, …, ClassicalRule), and
a negation step (~L, ~R) stands wherever a negation was written.
A negation step moves a formula across ⊢: from Γ, A ⊢ Δ to
Γ ⊢ A⊥, Δ. The one-sided calculus has no such step.
A one-sided proof has many two-sided derivations. The record of the
written sequent
(ClassicalSequent::writing)
picks the one written:
- A formula is shown on the side its connective was written on.
- A formula written with a negation is shown with it, on the side its parent puts it, only in the premise of the rule that exposes it (or in the conclusion, for a formula of the sequent). A negation step right above moves it. So every rule acts on formulas as they were written.
- A compact run of weakenings or contractions that acts on both sides
of
⊢is shown as two inferences,!w*below?w*, so that each inference is one rule. - The derivation of a goal (a proof of a goal rather than of the sequent) ends in the goal as the rules above it read it, with no negation step below: that is how the goal stands in a larger derivation.
- At first order the quantifier rules are
∀L,∀R,∃Land∃R, and an instance is written with the eigenvariables and witnesses of its frame, as the derivation writes it.
Read one-sided (every formula on the left negated and moved right), every inference is the one-sided inference it shows, and a negation step’s conclusion is its premise’s sequent again.
Display draws the tree as Derivation’s does.
§Examples
use deduxit::{Limits, linear::{ClassicalSequent, Mode, Options, TwoSided, prove}};
let written: ClassicalSequent = "|- A^ par A".parse()?;
let outcome = prove(written.sequent(), Mode::CLASSICAL, &Options::default())?;
let proof = outcome.verdict.proof().unwrap();
let derivation = proof.derivation()?;
let view = TwoSided::new(&derivation, written.writing(), &Limits::default())?;
assert_eq!(
view.to_string(),
" ───── ax\n A ⊢ A\n─────── ~R\n⊢ ~A, A\n──────── ⅋R\n⊢ ~A ⅋ A"
);Implementations§
Source§impl<'a> TwoSided<'a>
impl<'a> TwoSided<'a>
Sourcepub fn new(
derivation: &'a Derivation<'a>,
writing: &'a [Written],
limits: &Limits,
) -> Result<Self, Error>
pub fn new( derivation: &'a Derivation<'a>, writing: &'a [Written], limits: &Limits, ) -> Result<Self, Error>
Returns the two-sided view of a one-sided derivation whose sequent
was written as writing records, unless the view is estimated past
limits.derivation_bytes. A negation step repeats a sequent, so
the view has at most three times the derivation’s inferences, plus
one per formula of the sequent.
§Errors
Refusal::Output past the bound and Refusal::Index for more
inferences than an InfId counts, which only a call without a
bound can reach, each with nothing built.
§Panics
For a record of another sequent than the derivation’s: one entry
per occurrence of its forest, as
ClassicalSequent::writing or
a session’s writing gives it.
Sourcepub fn derivation(&self) -> &'a Derivation<'a>
pub fn derivation(&self) -> &'a Derivation<'a>
Returns the one-sided derivation the view shows.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns whether the view has no inference. A view built from a derivation always has one.
Sourcepub fn rule(&self, id: InfId) -> ClassicalRule
pub fn rule(&self, id: InfId) -> ClassicalRule
Sourcepub fn premises(&self, id: InfId) -> &[InfId]
pub fn premises(&self, id: InfId) -> &[InfId]
Returns the premises of the inference at id, in the rule’s order.
§Panics
For an id past the view’s end.
Sourcepub fn shows(&self, id: InfId) -> InfId
pub fn shows(&self, id: InfId) -> InfId
Returns the inference of the one-sided derivation whose sequent the
inference at id shows: its own, or for a negation step its
premise’s.
§Panics
For an id past the view’s end.
Sourcepub fn sides(
&self,
id: InfId,
) -> impl Iterator<Item = (Member, Side, bool)> + '_
pub fn sides( &self, id: InfId, ) -> impl Iterator<Item = (Member, Side, bool)> + '_
Returns the formulas of the sequent of the inference at id as it
shows them, in the order of the one-sided sequent: each member, the
side of ⊢ it stands on, and whether it is shown with the negation
it was written with.
§Panics
For an id past the view’s end.
Sourcepub fn sequent(&self, id: InfId) -> impl Display + '_
pub fn sequent(&self, id: InfId) -> impl Display + '_
Returns the sequent of the inference at id, Γ ⊢ Δ, as the text
tree writes it.
§Panics
For an id past the view’s end.
Sourcepub fn text_size(&self, options: &TextOptions) -> (usize, usize)
pub fn text_size(&self, options: &TextOptions) -> (usize, usize)
Returns the width and the height of the text tree the options
draw, as Derivation::text_size does.
Sourcepub fn write_text(
&self,
options: &TextOptions,
out: &mut impl Write,
stop: impl FnMut(Progress) -> bool,
) -> Result<(), Error>
pub fn write_text( &self, options: &TextOptions, out: &mut impl Write, stop: impl FnMut(Progress) -> bool, ) -> Result<(), Error>
Writes the text tree into out under options, as
Derivation::write_text does, asking stop after each row.
§Errors
Refusal::Stopped when stop fired, and Error::WriteFailed
when out refused the text.
Trait Implementations§
Auto Trait Implementations§
impl<'a> Forget for TwoSided<'a>
impl<'a> Freeze for TwoSided<'a>
impl<'a> Move for TwoSided<'a>
impl<'a> RefUnwindSafe for TwoSided<'a>
impl<'a> Send for TwoSided<'a>
impl<'a> Sync for TwoSided<'a>
impl<'a> Unpin for TwoSided<'a>
impl<'a> UnsafeUnpin for TwoSided<'a>
impl<'a> UnwindSafe for TwoSided<'a>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> ⓘ
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> ⓘ
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
T, using the provided data to resolve any offsets.