mtonnberg/refinement-proofs/1.0.0

NOTE: the latest version is 5.0.1

RefinementProofs

This library allows for stronger types in Elm for both library writer and end users

Definition

type Proven a b

A value "a" that is proven to hold the property "b"

Logic operator types

type And a b

Both "a" and "b" holds

type Or a b

"a" or "b" holds

type Not a

A negation of a proof

type alias XOr a b =
Or (And a (Not b)) (And (Not a) b)

Exlusive or

type Implies a b

Implies that if "a" holds than "b" holds

Basic function

axiom : p -> a -> Proven a p

Used by library writers to create axioms with non-exported constructors

or : p1 -> p2 -> Or p1 p2

Used by library writers to create build a Or proof

and : p1 -> p2 -> And p1 p2

Used by library writers to create build a And proof

not : p1 -> Not p1

Used by library writers to create build a Not proof

Logic operators

introOrR : Proven a p1 -> Proven a (Or p1 p2)

Basic logic

introOrL : Proven a p1 -> Proven a (Or p2 p1)

Basic logic

elimOrR : Proven a (Or b c) -> Proven a b

Basic logic

elimOrL : Proven a (Or b c) -> Proven a c

Basic logic

(a -> Maybe (Proven a b))
-> (a -> Maybe (Proven a c))
-> a
-> Maybe (Proven a (Or b c))

A convience method to check two proofs

(a -> Maybe (Proven a b))
-> (a -> Maybe (Proven a c))
-> a
-> Maybe (Proven a (And b c))

A convience method to check two proofs at once

(a -> Maybe (Proven a p1))
-> a
-> Result (Proven a (Not p1)) (Proven a p1)

Basic logic

inverse : (a -> Maybe (Proven a p1)) -> a -> Maybe (Proven a (Not p1))

Basic logic

elimAndL : Proven a (And b c) -> Proven a b

Basic logic

elimAndR : Proven a (And b c) -> Proven a c

Basic logic

exorcise : Proven a b -> a

Extract the actual value and remove the proof

modusPonens : Implies p1 p2 -> Proven a p1 -> Proven a p2

Basic logic

since : Implies p1 p2 -> Proven a p1 -> Proven a p2

Synonym for "modus ponens"

modusTollens : Implies p1 p2 -> Proven a (Not p1) -> Proven a (Not p2)

Basic logic

sinceNot : Implies p1 p2 -> Proven a (Not p1) -> Proven a (Not p2)

Synonym for "modus tollens"

imply : p1 -> p2 -> Implies p1 p2

Used by library writers to imply proof relations

absurd : a

Used by library writers to carefully ignore "impossible" states