Listable typeclass #
This is a crude version of finite types. It is a typeclass that provides a list of all the elements of a type.
Equations
- instListableBool = { elems := [false, true], elemsComplete := instListableBool.proof_1 }
Application of listable #
Suppose α is Listable and f, g: α → ℕ are functions. Then we can decide (algorithmically) if f = g . This is impossible for α = ℕ and f, g arbitrary.
Having decision procedures is captured by the Decidable typeclass. This gives a Boolean-valued function decide.
We will use Listable to make a similar decision procedure.
Equations
Instances For
Equations
- instListableShortAnswer = { elems := [ShortAnswer.yes, ShortAnswer.no, ShortAnswer.maybe], elemsComplete := instListableShortAnswer.proof_1 }
Equations
- ShortAnswerEg.f (ShortAnswer.yes, ShortAnswer.yes) = ShortAnswer.yes
- ShortAnswerEg.f (ShortAnswer.yes, ShortAnswer.no) = ShortAnswer.yes
- ShortAnswerEg.f (ShortAnswer.yes, ShortAnswer.maybe) = ShortAnswer.yes
- ShortAnswerEg.f (ShortAnswer.no, ShortAnswer.yes) = ShortAnswer.yes
- ShortAnswerEg.f (ShortAnswer.no, ShortAnswer.no) = ShortAnswer.no
- ShortAnswerEg.f (ShortAnswer.no, ShortAnswer.maybe) = ShortAnswer.maybe
- ShortAnswerEg.f (ShortAnswer.maybe, ShortAnswer.yes) = ShortAnswer.yes
- ShortAnswerEg.f (ShortAnswer.maybe, ShortAnswer.no) = ShortAnswer.maybe
- ShortAnswerEg.f (ShortAnswer.maybe, ShortAnswer.maybe) = ShortAnswer.maybe
Instances For
Equations
- ShortAnswerEg.g (ShortAnswer.yes, ShortAnswer.yes) = ShortAnswer.yes
- ShortAnswerEg.g (ShortAnswer.yes, ShortAnswer.no) = ShortAnswer.yes
- ShortAnswerEg.g (ShortAnswer.yes, ShortAnswer.maybe) = ShortAnswer.yes
- ShortAnswerEg.g (ShortAnswer.no, ShortAnswer.yes) = ShortAnswer.yes
- ShortAnswerEg.g (ShortAnswer.no, ShortAnswer.no) = ShortAnswer.no
- ShortAnswerEg.g (ShortAnswer.no, ShortAnswer.maybe) = ShortAnswer.maybe
- ShortAnswerEg.g (ShortAnswer.maybe, ShortAnswer.yes) = ShortAnswer.yes
- ShortAnswerEg.g (ShortAnswer.maybe, ShortAnswer.no) = ShortAnswer.maybe
- ShortAnswerEg.g (ShortAnswer.maybe, ShortAnswer.maybe) = ShortAnswer.maybe