| Copyright | (c) Leon Vatthauer 2026 |
|---|---|
| License | GPL-3 |
| Maintainer | Leon Vatthauer <leon.vatthauer@fau.de> |
| Stability | experimental |
| Portability | non-portable (GHC extensions) |
| Safe Haskell | None |
| Language | GHC2024 |
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
- newtype PrettyProof = PrettyProof Proof
- fromPretty :: PrettyProof -> Proof
- formula :: Int -> Formula
- assumption :: Int -> Assumption
- rule :: Int -> [Reference] -> Wrapper RuleApplication
- derivation :: Int -> Derivation
- data AddrKind = AddrKind {}
- assumptionKind :: AddrKind
- lineKind :: AddrKind
- conclusionKind :: AddrKind
- afterConclusionKind :: AddrKind
- anyKind :: AddrKind
- anyInsideKind :: AddrKind
- arbitraryNodeAddrFor :: Proof -> AddrKind -> Gen NodeAddr
- arbitraryProofAddrFor :: Proof -> Gen ProofAddr
- arbitraryLineRangeFor :: Proof -> Gen (Int, Int)
- prop_naRemoveMinus1 :: PrettyProof -> Property
- prop_naRemoveShiftLine :: PrettyProof -> Property
- prop_naRemoveShiftAssumption :: PrettyProof -> Property
- naInsertBefore' :: Either Assumption Derivation -> NodeAddr -> Proof -> Maybe Proof
- prop_naInsertBeforeAssumptionPlus1 :: PrettyProof -> Property
- prop_naInsertBeforeDerivationPlus1 :: PrettyProof -> Property
- prop_naInsertBeforeNaLookupAssumption :: PrettyProof -> Property
- prop_naInsertBeforeNaLookupDerivation :: PrettyProof -> Property
- prop_naInsertBeforeRemove :: PrettyProof -> Property
- prop_paMoveBeforeRawSameProof :: PrettyProof -> Property
- prop_fromLineNoInverse :: PrettyProof -> Property
- prop_fromNodeAddrInverse :: PrettyProof -> Property
- prop_compareLineNo :: PrettyProof -> Property
- prop_fromLineRangeInverse :: PrettyProof -> Property
- prop_lineRangeFromProofAddrInverse :: PrettyProof -> Property
- naRemoveQCTests :: TestTree
- naInsertBeforeQCTests :: TestTree
- paMoveBeforeQCTests :: TestTree
- lineNoQCTests :: TestTree
- compareQCTests :: TestTree
- lineRangeQCTests :: TestTree
- proofTests :: TestTree
Pretty Printing
newtype PrettyProof Source #
A wrapper around Proof that replaces the derived Show with PrettyPrint.
Constructors
| PrettyProof Proof |
Instances
| Arbitrary PrettyProof Source # | Lifts |
Defined in ProofSyntax | |
| Show PrettyProof Source # | Pretty Printing via |
Defined in ProofSyntax Methods showsPrec :: Int -> PrettyProof -> ShowS # show :: PrettyProof -> String # showList :: [PrettyProof] -> ShowS # | |
| Eq PrettyProof Source # | |
Defined in ProofSyntax | |
fromPretty :: PrettyProof -> Proof Source #
Unwraps a PrettyProof back to the underlying Proof.
Constructing Proofs
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
Used for specifying which kind of NodeAddrs arbitraryNodeAddrFor should
produce.
Constructors
| AddrKind | |
Fields
| |
assumptionKind :: AddrKind Source #
Constructor for setting _assumptionKind
conclusionKind :: AddrKind Source #
Constructor for setting _conclusionKind
afterConclusionKind :: AddrKind Source #
Constructor for setting _afterConclusionKind
anyInsideKind :: AddrKind Source #
Constructor for setting all AddrKinds that are inside of the Proof,
i.e. excluding afterConclusionKind.
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 ) is now reachable at address incrementNodeAddr aa.
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 ) is now reachable at address incrementNodeAddr aa.
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_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
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
naRemoveQCTests :: TestTree Source #
Tests for naRemove
naInsertBeforeQCTests :: TestTree Source #
Tests for naInsertBefore
paMoveBeforeQCTests :: TestTree Source #
Tests for paMoveBefore
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 |
| Arbitrary Derivation Source # | Generates a |
| Arbitrary Proof Source # | |
| Arbitrary (Wrapper RuleApplication) Source # | Generates a |
Methods arbitrary :: Gen (Wrapper RuleApplication) Source # shrink :: Wrapper RuleApplication -> [Wrapper RuleApplication] Source # | |