quickspec-2.1: Equational laws for free!

Safe HaskellNone
LanguageHaskell98

QuickSpec.Term

Contents

Description

This module is internal to QuickSpec.

Typed terms and operations on them.

Synopsis

Documentation

data Term f Source #

A typed term.

Constructors

Var !Var 
App !f ![Term f] 

Instances

Functor Term Source # 

Methods

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

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

Symbolic f (Term f) Source # 

Methods

termsDL :: Term f -> DList (Term f) Source #

subst :: (Var -> Term f) -> Term f -> Term f Source #

Eq f => Eq (Term f) Source # 

Methods

(==) :: Term f -> Term f -> Bool #

(/=) :: Term f -> Term f -> Bool #

Ord f => Ord (Term f) Source # 

Methods

compare :: Term f -> Term f -> Ordering #

(<) :: Term f -> Term f -> Bool #

(<=) :: Term f -> Term f -> Bool #

(>) :: Term f -> Term f -> Bool #

(>=) :: Term f -> Term f -> Bool #

max :: Term f -> Term f -> Term f #

min :: Term f -> Term f -> Term f #

Show f => Show (Term f) Source # 

Methods

showsPrec :: Int -> Term f -> ShowS #

show :: Term f -> String #

showList :: [Term f] -> ShowS #

PrettyTerm f => Pretty (Term f) Source # 

Methods

pPrintPrec :: PrettyLevel -> Rational -> Term f -> Doc #

pPrint :: Term f -> Doc #

pPrintList :: PrettyLevel -> [Term f] -> Doc #

Typed f => Typed (Term f) Source # 
Sized f => Sized (Term f) Source # 

Methods

size :: Term f -> Int Source #

data Var Source #

A variable, which has a type and a number.

Constructors

V 

Fields

Instances

Eq Var Source # 

Methods

(==) :: Var -> Var -> Bool #

(/=) :: Var -> Var -> Bool #

Ord Var Source # 

Methods

compare :: Var -> Var -> Ordering #

(<) :: Var -> Var -> Bool #

(<=) :: Var -> Var -> Bool #

(>) :: Var -> Var -> Bool #

(>=) :: Var -> Var -> Bool #

max :: Var -> Var -> Var #

min :: Var -> Var -> Var #

Show Var Source # 

Methods

showsPrec :: Int -> Var -> ShowS #

show :: Var -> String #

showList :: [Var] -> ShowS #

Generic Var Source # 

Associated Types

type Rep Var :: * -> * #

Methods

from :: Var -> Rep Var x #

to :: Rep Var x -> Var #

CoArbitrary Var Source # 

Methods

coarbitrary :: Var -> Gen b -> Gen b #

Pretty Var Source # 
Typed Var Source # 
type Rep Var Source # 
type Rep Var = D1 * (MetaData "Var" "QuickSpec.Term" "quickspec-2.1-5fSNb7X5HLABGdHB0i89ut" False) (C1 * (MetaCons "V" PrefixI True) ((:*:) * (S1 * (MetaSel (Just Symbol "var_ty") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 * Type)) (S1 * (MetaSel (Just Symbol "var_id") SourceUnpack SourceStrict DecidedStrict) (Rec0 * Int))))

class Symbolic f a | a -> f where Source #

A class for things that contain terms.

Minimal complete definition

termsDL, subst

Methods

termsDL :: a -> DList (Term f) Source #

A different list of all terms contained in the thing.

subst :: (Var -> Term f) -> a -> a Source #

Apply a substitution to all terms in the thing.

Instances

Symbolic f a => Symbolic f [a] Source # 

Methods

termsDL :: [a] -> DList (Term f) Source #

subst :: (Var -> Term f) -> [a] -> [a] Source #

Symbolic f (Term f) Source # 

Methods

termsDL :: Term f -> DList (Term f) Source #

subst :: (Var -> Term f) -> Term f -> Term f Source #

class Sized a where Source #

Minimal complete definition

size

Methods

size :: a -> Int Source #

Instances

Sized f => Sized (Term f) Source # 

Methods

size :: Term f -> Int Source #

(Sized fun1, Sized fun2) => Sized ((:+:) fun1 fun2) Source # 

Methods

size :: (fun1 :+: fun2) -> Int Source #

isApp :: Term f -> Bool Source #

Is a term an application (i.e. not a variable)?

isVar :: Term f -> Bool Source #

Is a term a variable?

terms :: Symbolic f a => a -> [Term f] Source #

All terms contained in a Symbolic.

funs :: Symbolic f a => a -> [f] Source #

All function symbols appearing in a Symbolic, in order of appearance, with duplicates included.

vars :: Symbolic f a => a -> [Var] Source #

All variables appearing in a Symbolic, in order of appearance, with duplicates included.

freeVar :: Symbolic f a => a -> Int Source #

Compute the number of a variable which does not appear in the Symbolic.

occ :: (Eq f, Symbolic f a) => f -> a -> Int Source #

Count how many times a given function symbol occurs.

occVar :: Symbolic f a => Var -> a -> Int Source #

Count how many times a given variable occurs.

mapVar :: (Var -> Var) -> Term f -> Term f Source #

Map a function over variables.

subterms :: Term f -> [Term f] Source #

Find all subterms of a term. Includes the term itself.

properSubterms :: Term f -> [Term f] Source #

Find all subterms of a term. Does not include the term itself.

canonicalise :: Symbolic fun a => a -> a Source #

Renames variables so that they appear in a canonical order. Also makes sure that variables of different types have different numbers.

evalTerm :: (Typed fun, Apply a, Monad m) => (Var -> m a) -> (fun -> m a) -> Term fun -> m a Source #

Evaluate a term, given a valuation for variables and function symbols.

type Measure f = (Int, Int, MeasureFuns f, Int, [Var]) Source #

A standard term ordering - size, skeleton, generality. Satisfies the property: if measure (schema t) < measure (schema u) then t < u.

measure :: Sized f => Term f -> Measure f Source #

Compute the term ordering for a term.

newtype MeasureFuns f Source #

A helper for Measure.

Constructors

MeasureFuns (Term f) 

compareFuns :: Ord f => Term f -> Term f -> Ordering Source #

A helper for Measure.

Data types a la carte-ish.

data a :+: b Source #

A sum type. Intended to be used to build the type of function symbols. Comes with instances that are useful for QuickSpec.

Constructors

Inl a 
Inr b 

Instances

(Eq b, Eq a) => Eq ((:+:) a b) Source # 

Methods

(==) :: (a :+: b) -> (a :+: b) -> Bool #

(/=) :: (a :+: b) -> (a :+: b) -> Bool #

(Ord b, Ord a) => Ord ((:+:) a b) Source # 

Methods

compare :: (a :+: b) -> (a :+: b) -> Ordering #

(<) :: (a :+: b) -> (a :+: b) -> Bool #

(<=) :: (a :+: b) -> (a :+: b) -> Bool #

(>) :: (a :+: b) -> (a :+: b) -> Bool #

(>=) :: (a :+: b) -> (a :+: b) -> Bool #

max :: (a :+: b) -> (a :+: b) -> a :+: b #

min :: (a :+: b) -> (a :+: b) -> a :+: b #

(Pretty fun1, Pretty fun2) => Pretty ((:+:) fun1 fun2) Source # 

Methods

pPrintPrec :: PrettyLevel -> Rational -> (fun1 :+: fun2) -> Doc #

pPrint :: (fun1 :+: fun2) -> Doc #

pPrintList :: PrettyLevel -> [fun1 :+: fun2] -> Doc #

(Arity fun1, Arity fun2) => Arity ((:+:) fun1 fun2) Source # 

Methods

arity :: (fun1 :+: fun2) -> Int #

(PrettyTerm fun1, PrettyTerm fun2) => PrettyTerm ((:+:) fun1 fun2) Source # 

Methods

termStyle :: (fun1 :+: fun2) -> TermStyle #

(Typed fun1, Typed fun2) => Typed ((:+:) fun1 fun2) Source # 

Methods

typ :: (fun1 :+: fun2) -> Type Source #

otherTypesDL :: (fun1 :+: fun2) -> DList Type Source #

typeSubst_ :: (Var -> Builder TyCon) -> (fun1 :+: fun2) -> fun1 :+: fun2 Source #

(Sized fun1, Sized fun2) => Sized ((:+:) fun1 fun2) Source # 

Methods

size :: (fun1 :+: fun2) -> Int Source #

module Twee.Base