Skip to content

Instantly share code, notes, and snippets.

@relrod
Last active August 29, 2015 14:00
Show Gist options
  • Save relrod/3b595b2fdd42b46bdb58 to your computer and use it in GitHub Desktop.
Save relrod/3b595b2fdd42b46bdb58 to your computer and use it in GitHub Desktop.
-- This is really Idris code, but it will highlight reasonably as Haskell
module vectorTripleStuff
data Triple = VectorTriple Nat Nat Nat
instance Semigroup Triple where
(VectorTriple a b c) <+> (VectorTriple d e f) = VectorTriple (a + d) (b + e) (c + f)
instance VerifiedSemigroup Triple where
semigroupOpIsAssociative (VectorTriple a b c) (VectorTriple d e f) (VectorTriple g h i) = ?tripleTripleTriple
instance Monoid Triple where
neutral = VectorTriple 0 0 0
instance VerifiedMonoid Triple where
monoidNeutralIsNeutralL (VectorTriple a b c) = ?monoidLeft
monoidNeutralIsNeutralR (VectorTriple a b c) = ?monoidRight
---------- Proofs ----------
monoidLeft = proof
intros
rewrite plusZeroRightNeutral a
rewrite plusZeroRightNeutral b
rewrite plusZeroRightNeutral c
trivial
monoidRight = proof
intros
rewrite plusZeroLeftNeutral a
rewrite plusZeroLeftNeutral b
rewrite plusZeroLeftNeutral c
trivial
tripleTripleTriple = proof
intros
rewrite plusAssociative a d g
rewrite plusAssociative b e h
rewrite plusAssociative c f i
trivial
@relrod
Copy link
Author

relrod commented Apr 30, 2014

(This doesn't have much of a purpose, but we were talking about similar proofs in my math class at YSU and I thought it'd be a good excuse to try out theorem proving in Idris).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment