xrs-0.1.0.0
Safe HaskellSafe-Inferred
LanguageGHC2021

Logic.Proof

Synopsis

Proof Trees

data Proof j #

The type of proof trees parameterized by the type of judgments j.

Constructors

Node j [Proof j] 

Instances

Instances details
Foldable Proof # 
Instance details

Defined in Logic.Proof

Methods

fold :: Monoid m => Proof m -> m #

foldMap :: Monoid m => (a -> m) -> Proof a -> m #

foldMap' :: Monoid m => (a -> m) -> Proof a -> m #

foldr :: (a -> b -> b) -> b -> Proof a -> b #

foldr' :: (a -> b -> b) -> b -> Proof a -> b #

foldl :: (b -> a -> b) -> b -> Proof a -> b #

foldl' :: (b -> a -> b) -> b -> Proof a -> b #

foldr1 :: (a -> a -> a) -> Proof a -> a #

foldl1 :: (a -> a -> a) -> Proof a -> a #

toList :: Proof a -> [a] #

null :: Proof a -> Bool #

length :: Proof a -> Int #

elem :: Eq a => a -> Proof a -> Bool #

maximum :: Ord a => Proof a -> a #

minimum :: Ord a => Proof a -> a #

sum :: Num a => Proof a -> a #

product :: Num a => Proof a -> a #

Traversable Proof # 
Instance details

Defined in Logic.Proof

Methods

traverse :: Applicative f => (a -> f b) -> Proof a -> f (Proof b) #

sequenceA :: Applicative f => Proof (f a) -> f (Proof a) #

mapM :: Monad m => (a -> m b) -> Proof a -> m (Proof b) #

sequence :: Monad m => Proof (m a) -> m (Proof a) #

Applicative Proof # 
Instance details

Defined in Logic.Proof

Methods

pure :: a -> Proof a #

(<*>) :: Proof (a -> b) -> Proof a -> Proof b #

liftA2 :: (a -> b -> c) -> Proof a -> Proof b -> Proof c #

(*>) :: Proof a -> Proof b -> Proof b #

(<*) :: Proof a -> Proof b -> Proof a #

Functor Proof # 
Instance details

Defined in Logic.Proof

Methods

fmap :: (a -> b) -> Proof a -> Proof b #

(<$) :: a -> Proof b -> Proof a #

Monad Proof # 
Instance details

Defined in Logic.Proof

Methods

(>>=) :: Proof a -> (a -> Proof b) -> Proof b #

(>>) :: Proof a -> Proof b -> Proof b #

return :: a -> Proof a #

Show j => Show (Proof j) # 
Instance details

Defined in Logic.Proof

Methods

showsPrec :: Int -> Proof j -> ShowS #

show :: Proof j -> String #

showList :: [Proof j] -> ShowS #

Latex j => Latex (Proof j) # 
Instance details

Defined in Logic.Proof

Methods

latex :: Proof j -> String #

pattern Proof :: j -> [Proof j] -> Proof j #

A constructor synonym for Node.

pattern Leaf :: j -> Proof j #

A constructor synonym for Node with no premises.

Proof Generation

class Explain j where #

Methods

premises :: j -> [[j]] #

Returns a list of all possible premises of a given judgment.

  • premises j = [] if j is decidably false.A
  • premises j = [[]] if j is an axiom.
  • premises j = [p1,p2,...,pn] : tail (premises j) if j is provable from the conclusions of p1, p2, ..., pn.

Instances

Instances details
Explain EvalJ # 
Instance details

Defined in Lang.Operation

Methods

premises :: EvalJ -> [[EvalJ]] #

proofs :: Explain j => j -> [Proof j] #

Returns a list of all possible proofs of a given judgment.

prove :: Explain j => j -> Maybe (Proof j) #

Returns the first proof of a given judgment.

prove j = listToMaybe (proofs j)

prove' :: Explain j => j -> Proof j #

Returns a proof of a given judgment or fails if the judgment is not provable.

prove' j = fromJust (prove j)

suppose :: Explain j => j -> Proof j #

Gives the first proof of a given judgment and doesn't fail if the judgement is not provable.

Proof Tree Manipulation

conclusion :: Proof j -> j #

Extract the conclusion/root from a proof tree.

children :: Proof j -> [Proof j] #

Extract the premises/children from a proof tree.

hidePast :: Int -> Proof j -> Proof j #

Get the proof tree with the premises hidden after the \(n\)th level.

hide :: Eq j => j -> Proof j -> Maybe (Proof j) #

Hide the subtrees of a proof tree that have the given judgment as their conclusion.

countNodes :: Proof j -> Int #

Count the number of judgemnets in a proof tree.

getRow :: Int -> Proof j -> [j] #

Get the \(n\)th row of a proof tree.

toList :: Eq j => Proof j -> [j] #

Convert the proof tree to a list of judgements.

toList' :: Proof a -> [a] #

Convert the proof tree to a list of judgements.