type-safe-avl-1.0.0.1: Type safe BST and AVL trees
Copyright(c) Nicolás Rodríguez 2021
LicenseGPL-3
MaintainerNicolás Rodríguez
Stabilityexperimental
PortabilityPOSIX
Safe HaskellSafe
LanguageHaskell2010

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

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.

Methods

proofIsBSTInsert :: Proxy (Node x a) -> IsBSTT t -> IsBSTT (Insert x a t) Source #

Instances

Instances details
ProofIsBSTInsert x a 'EmptyTree Source # 
Instance details

Defined in Data.Tree.AVL.Extern.InsertProofs

ProofIsBSTInsert' x a ('ForkTree l (Node n a1) r) (CmpNat x n) => ProofIsBSTInsert x a ('ForkTree l (Node n a1) r) Source # 
Instance details

Defined in Data.Tree.AVL.Extern.InsertProofs

Methods

proofIsBSTInsert :: Proxy (Node x a) -> IsBSTT ('ForkTree l (Node n a1) r) -> IsBSTT (Insert 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.

Methods

proofIsBSTInsert' :: Proxy (Node x a) -> IsBSTT t -> Proxy o -> IsBSTT (Insert' x a t o) Source #

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.

Methods

proofLtNInsert' :: (CmpNat x n ~ 'LT, LtN t n ~ 'True) => Proxy (Node x a) -> IsBSTT t -> Proxy n -> Proxy o -> LtN (Insert' x a t o) n :~: 'True Source #

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.

Methods

proofGtNInsert' :: (CmpNat x n ~ 'GT, GtN t n ~ 'True) => Proxy (Node x a) -> IsBSTT t -> Proxy n -> Proxy o -> GtN (Insert' x a t o) n :~: 'True Source #

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.

Instances

Instances details
ProofIsBalancedInsert x a 'EmptyTree Source # 
Instance details

Defined in Data.Tree.AVL.Extern.InsertProofs

(o ~ CmpNat x n, ProofIsBalancedInsert' x a ('ForkTree l (Node n a1) r) o) => ProofIsBalancedInsert x a ('ForkTree l (Node n a1) r) Source # 
Instance details

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.