Skip to main content

TwoSided

Struct TwoSided 

Source
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, ∃L and ∃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>

Source

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.

Source

pub fn derivation(&self) -> &'a Derivation<'a>

Returns the one-sided derivation the view shows.

Source

pub fn len(&self) -> usize

Returns the number of inferences.

Source

pub fn is_empty(&self) -> bool

Returns whether the view has no inference. A view built from a derivation always has one.

Source

pub fn root(&self) -> InfId

Returns the root: the inference that concludes the sequent.

Source

pub fn rule(&self, id: InfId) -> ClassicalRule

Returns the rule of the inference at id.

§Panics

For an id past the view’s end.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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§

Source§

impl<'a> Clone for TwoSided<'a>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Debug for TwoSided<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for TwoSided<'_>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult

Draws the view as a tree of sequents under the default TextOptions, one line per row, without a trailing newline.

Source§

impl<'a, 'p: 'a> From<&'a TwoSided<'p>> for Drawable<'a>

Source§

fn from(view: &'a TwoSided<'p>) -> Self

Draws the two-sided view of a classical derivation.

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> Finish for T

Source§

fn finish(self)

Does nothing but move self, equivalent to drop.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

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 more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<U, T> ToOwnedObj<U> for T
where U: FromObjRef<T>,

Source§

fn to_owned_obj(&self, data: FontData<'_>) -> U

Convert this type into T, using the provided data to resolve any offsets.
Source§

impl<U, T> ToOwnedTable<U> for T
where U: FromTableRef<T>,

Source§

fn to_owned_table(&self) -> U

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.