| Copyright | (c) Nicolás Rodríguez 2021 |
|---|---|
| License | GPL-3 |
| Maintainer | Nicolás Rodríguez |
| Stability | experimental |
| Portability | POSIX |
| Safe Haskell | Safe |
| Language | Haskell2010 |
Data.Tree.AVL.Extern.InsertProofs
Description
Implementation of the necessary proofs to ensure (at compile time) that the insertion algorithm defined in Data.Tree.AVL.Extern.Insert respects the key ordering and height balance restrictions.
Synopsis
- class ProofIsBSTInsert (x :: Nat) (a :: Type) (t :: Tree) where
- class ProofIsBSTInsert' (x :: Nat) (a :: Type) (t :: Tree) (o :: Ordering) where
- class ProofLtNInsert' (x :: Nat) (a :: Type) (t :: Tree) (n :: Nat) (o :: Ordering) where
- class ProofGtNInsert' (x :: Nat) (a :: Type) (t :: Tree) (n :: Nat) (o :: Ordering) where
- class ProofIsBalancedInsert (x :: Nat) (a :: Type) (t :: Tree) where
- proofIsBalancedInsert :: Proxy (Node x a) -> IsBalancedT t -> IsBalancedT (Insert x a t)
- class ProofIsBalancedInsert' (x :: Nat) (a :: Type) (t :: Tree) (o :: Ordering) where
- proofIsBalancedInsert' :: Proxy (Node x a) -> IsBalancedT t -> Proxy o -> IsBalancedT (Insert' x a t o)
Documentation
class ProofIsBSTInsert (x :: Nat) (a :: Type) (t :: Tree) where Source #
Prove that inserting a node with key x and element value a
in a BST tree preserves BST condition.
Instances
| ProofIsBSTInsert x a 'EmptyTree Source # | |
| ProofIsBSTInsert' x a ('ForkTree l (Node n a1) r) (CmpNat x n) => ProofIsBSTInsert x a ('ForkTree l (Node n a1) r) Source # | |
class ProofIsBSTInsert' (x :: Nat) (a :: Type) (t :: Tree) (o :: Ordering) where Source #
Prove that inserting a node with key x and element value a
in a BST tree preserves BST condition, given that the comparison between
x and the root key of the tree equals o.
The BST restrictions were already checked when proofIsBSTInsert was called before.
The o parameter guides the proof.
class ProofLtNInsert' (x :: Nat) (a :: Type) (t :: Tree) (n :: Nat) (o :: Ordering) where Source #
Prove that inserting a node with key x (lower than n) and element value a
in a tree t which verifies LtN t n ~ 'True preserves the LtN invariant,
given that the comparison between x and the root key of the tree equals o.
The o parameter guides the proof.
class ProofGtNInsert' (x :: Nat) (a :: Type) (t :: Tree) (n :: Nat) (o :: Ordering) where Source #
Prove that inserting a node with key x (greater than n) and element value a
in a tree t which verifies GtN t n ~ 'True preserves the GtN invariant,
given that the comparison between x and the root key of the tree equals o.
The o parameter guides the proof.
class ProofIsBalancedInsert (x :: Nat) (a :: Type) (t :: Tree) where Source #
Prove that inserting a node with key x and element value a
in an AVL tree preserves the AVL condition.
Methods
proofIsBalancedInsert :: Proxy (Node x a) -> IsBalancedT t -> IsBalancedT (Insert x a t) Source #
Instances
| ProofIsBalancedInsert x a 'EmptyTree Source # | |
Defined in Data.Tree.AVL.Extern.InsertProofs Methods proofIsBalancedInsert :: Proxy (Node x a) -> IsBalancedT 'EmptyTree -> IsBalancedT (Insert x a 'EmptyTree) Source # | |
| (o ~ CmpNat x n, ProofIsBalancedInsert' x a ('ForkTree l (Node n a1) r) o) => ProofIsBalancedInsert x a ('ForkTree l (Node n a1) r) Source # | |
Defined in Data.Tree.AVL.Extern.InsertProofs Methods proofIsBalancedInsert :: Proxy (Node x a) -> IsBalancedT ('ForkTree l (Node n a1) r) -> IsBalancedT (Insert x a ('ForkTree l (Node n a1) r)) Source # | |
class ProofIsBalancedInsert' (x :: Nat) (a :: Type) (t :: Tree) (o :: Ordering) where Source #
Prove that inserting a node with key x and element value a
in an BST tree preserves the AVL condition, given that the comparison between
x and the root key of the tree equals o.
The AVL condition was already checked when proofIsBSTInsert was called before.
The o parameter guides the proof.
Methods
proofIsBalancedInsert' :: Proxy (Node x a) -> IsBalancedT t -> Proxy o -> IsBalancedT (Insert' x a t o) Source #