Finch
Copyright(c) Leon Vatthauer 2026
LicenseGPL-3
MaintainerLeon Vatthauer <leon.vatthauer@fau.de>
Stabilityexperimental
Portabilitynon-portable (GHC extensions)
Safe HaskellNone
LanguageGHC2024

ProofSyntax

Description

QuickCheck property tests for the Proof manipulation functions defined in Fitch.Proof.

The module defines various helpers for constructing Proofs, generators for arbitrarily generating Proof and their contents as well as NodeAddr and ProofAddr.

Finally, this module defined properties concerning Proof, NodeAddr and ProofAddr.

Synopsis

Pretty Printing

newtype PrettyProof Source #

A wrapper around Proof that replaces the derived Show with PrettyPrint.

Constructors

PrettyProof Proof 

Instances

Instances details
Arbitrary PrettyProof Source #

Lifts Arbitrary from Proof to PrettyProof.

Instance details

Defined in ProofSyntax

Show PrettyProof Source #

Pretty Printing via prettyPrint.

Instance details

Defined in ProofSyntax

Eq PrettyProof Source # 
Instance details

Defined in ProofSyntax

fromPretty :: PrettyProof -> Proof Source #

Unwraps a PrettyProof back to the underlying Proof.

Constructing Proofs

formula :: Int -> Formula Source #

Constructs a trivial Formula consisting of an Int.

assumption :: Int -> Assumption Source #

Constructs a trivial Assumption consisting of an Int.

rule :: Int -> [Reference] -> Wrapper RuleApplication Source #

Constructs a trivial RuleApplication consisting of an Int.

derivation :: Int -> Derivation Source #

Constructs a trivial Derivation using formula and rule.

Address Generators

data AddrKind Source #

Used for specifying which kind of NodeAddrs arbitraryNodeAddrFor should produce.

Constructors

AddrKind 

Fields

Instances

Instances details
Monoid AddrKind Source #

Empty AddrKind with all fields set to False

Instance details

Defined in ProofSyntax

Semigroup AddrKind Source #

Combining AddrKinds, combines the fields with ||.

Instance details

Defined in ProofSyntax

assumptionKind :: AddrKind Source #

Constructor for setting _assumptionKind

lineKind :: AddrKind Source #

Constructor for setting _lineKind

conclusionKind :: AddrKind Source #

Constructor for setting _conclusionKind

anyKind :: AddrKind Source #

Constructor for setting all AddrKinds.

anyInsideKind :: AddrKind Source #

Constructor for setting all AddrKinds that are inside of the Proof, i.e. excluding afterConclusionKind.

arbitraryNodeAddrFor :: Proof -> AddrKind -> Gen NodeAddr Source #

Generates a valid NodeAddr of the specified AddrKind for the given Proof.

arbitraryProofAddrFor :: Proof -> Gen ProofAddr Source #

Generates a valid ProofAddr for the given Proof.

arbitraryLineRangeFor :: Proof -> Gen (Int, Int) Source #

Generates a valid (start, end) line-number range within the given tProof.

Properties: naRemove

prop_naRemoveMinus1 :: PrettyProof -> Property Source #

Removing a lineKind or assumptionKind decreases pLength by exactly 1.

pLength <$> naRemove a p  ===  Just (pLength p - 1)

prop_naRemoveShiftLine :: PrettyProof -> Property Source #

After removing the Derivation at address a, the entry that was immediately after a (at incrementNodeAddr a) is now reachable at address a.

naLookup a <$> naRemove a p === Just ((`naLookup` p) =<< incrementNodeAddr a)

prop_naRemoveShiftAssumption :: PrettyProof -> Property Source #

After removing the Assumption at address a, the entry that was immediately after a (at incrementNodeAddr a) is now reachable at address a.

naLookup a <$> naRemove a p === Just ((`naLookup` p) =<< incrementNodeAddr a)

Properties: naInsertBefore

naInsertBefore' :: Either Assumption Derivation -> NodeAddr -> Proof -> Maybe Proof Source #

A wrapper around naInsertBefore that discards the returned NodeAddr and returns only the modified Proof.

prop_naInsertBeforeAssumptionPlus1 :: PrettyProof -> Property Source #

Inserting an Assumption before an anyInsideKind address increases pLength by exactly 1.

pLength <$> naInsertBefore' (Left (assumption 0)) a p  ===  Just (pLength p + 1)

prop_naInsertBeforeDerivationPlus1 :: PrettyProof -> Property Source #

Inserting a Derivation before an anyInsideKind address increases pLength by exactly 1.

pLength <$> naInsertBefore' (Right (derivation 0)) a p  ===  Just (pLength p + 1)

prop_naInsertBeforeNaLookupAssumption :: PrettyProof -> Property Source #

After inserting assumption 0 before an assumptionKind address, naLookup returns assumption 0.

naLookup a <$> naInsertBefore' (Left (assumption 0)) a p ===  Just (Just (Left (assumption 0)))

prop_naInsertBeforeNaLookupDerivation :: PrettyProof -> Property Source #

After inserting derivation 0 before a lineKind address, naLookup returns derivation 0.

naLookup a <$> naInsertBefore' (Right (derivation 0)) a p ===  Just (Just (Right (derivation 0)))

prop_naInsertBeforeRemove :: PrettyProof -> Property Source #

Inserting an element and then removing it should return the original proof.

Properties: paMoveBefore

prop_paMoveBeforeRawSameProof :: PrettyProof -> Property Source #

Moving a Proof to a new position with paMoveBeforeRaw preserves its content, i.e. looking up the source address in the original Proof yields the same Proof as looking up the destination address in the modified t'Proof.

paLookup paTarget' p'  ===  paLookup paSource p

Properties: Line Number Conversion

prop_fromLineNoInverse :: PrettyProof -> Property Source #

fromLineNo followed by fromNodeAddr is the identity on valid line numbers.

(fromNodeAddr addr p =<< fromLineNo n p)  ===  Just (Just n)

prop_fromNodeAddrInverse :: PrettyProof -> Property Source #

fromNodeAddr followed by fromLineNo is the identity on valid tNodeAddr values.

(fromLineNo n p =<< fromNodeAddr a p)  ===  Just (Just a)

Properties: Ordering on Addresses

prop_compareLineNo :: PrettyProof -> Property Source #

The Ord instance for NodeAddr is consistent with line-number ordering: for any two addresses a and b,

compare a b  ===  compare (fromNodeAddr a p) (fromNodeAddr b p)

Properties: Line Range Conversion

prop_fromLineRangeInverse :: PrettyProof -> Property Source #

lineRangeFromProofAddr followed by fromLineRange is the identity on valid ProofAddr values.

(fromLineRange s e p =<< lineRangeFromProofAddr pa p)  ===  Just pa

prop_lineRangeFromProofAddrInverse :: PrettyProof -> Property Source #

fromLineRange followed by lineRangeFromProofAddr is the identity on valid (start, end) line ranges.

(lineRangeFromProofAddr pa p =<< fromLineRange start end p) ===  Just (start, end)

Tests

lineNoQCTests :: TestTree Source #

Tests regarding the conversion of line numbers and NodeAddrs.

compareQCTests :: TestTree Source #

Tests for compare instances of address types like NodeAddr and t'ProofAddr.

lineRangeQCTests :: TestTree Source #

Tests regarding the conversion of line ranges and ProofAddrs.

proofTests :: TestTree Source #

Groups all tests in this module.

Orphan instances

Arbitrary Assumption Source #

Generates an Assumption based on assumption.

Instance details

Arbitrary Derivation Source #

Generates a Derivation based on derivation.

Instance details

Arbitrary Proof Source #

Generates an arbitrary Proof using sized.

  • At size 0: a SubProof consisting only of a conclusion.
  • At size n > 0: a SubProof with arbitrary assumptions, between 1 and 8 body lines (to prevent huge Proofs.), and an arbitrary conclusion.
Instance details

Arbitrary (Wrapper RuleApplication) Source #

Generates a RuleApplication based on rule.

Instance details