Steps to Reproduce
Stick this code at the bottom of Prelude.idr:
interface Semigroup a => VerifiedSemigroup a where
semigroupOpIsAssociative : (l, c, r : a) -> l <+> (c <+> r) = (l <+> c) <+> r
interface (VerifiedSemigroup a, Monoid a) => VerifiedMonoid a where
monoidNeutralIsNeutralL : (l : a) -> l <+> Prelude.neutral = l
monoidNeutralIsNeutralR : (r : a) -> Prelude.neutral <+> r = r
mtimes : Monoid a => (n : Nat) -> a -> a
mtimes Z x = Prelude.neutral
mtimes (S k) x = x <+> mtimes k x
mtimesTimes : VerifiedMonoid a => (x : a) -> (n, m : Nat) ->
mtimes (n + m) x = mtimes n x <+> mtimes m x
mtimesTimes x Z m = sym $ monoidNeutralIsNeutralR $ mtimes m x
mtimesTimes x (S k) m =
rewrite mtimesTimes x k m in
semigroupOpIsAssociative x (mtimes k x) (mtimes m x)
Expected Behavior
No problem
Observed Behavior
mtimesTimes fails with this error:
Prelude.idr:1703:5--1704:1:While processing right hand side of mtimesTimes at Prelude.idr:1701:1--1704:1:
Can't solve constraint between:
Constraint (Semigroup a) (let 0 _ = \{rwarg:8186} => x <+> rwarg = (x <+> mtimes k x) <+> mtimes m x in let 0 _ = mtimesTimes x k m in Constraint (VerifiedSemigroup a) conArg)
and
Constraint (Semigroup ty) (Constraint (Monoid a) conArg)
But the proof itself is fine, and it goes through with this change:
-mtimes : Monoid a => (n : Nat) -> a -> a
+mtimes : VerifiedMonoid a => (n : Nat) -> a -> a
mtimes, with the Monoid constraint, says, if you implement those syntactic elements, you get to use this syntactic element. mtimesTimes, with the VerifiedMonoid constraint, says, if you further prove certain guarantees about the behavior of those syntactic elements, you also get some guarantees about the behavior of this new element. So the "verified" constraint shouldn't be necessary for defining mtimes, because mtimes doesn't make any guarantees about behavior.
The inheritance structure looks like this:
Semigroup --------------> Monoid
| |
| |
| |
| |
\/ \/
VerifiedSemigroup ------> VerifiedMonoid
This bug is in Idris 1 too.
Steps to Reproduce
Stick this code at the bottom of Prelude.idr:
Expected Behavior
No problem
Observed Behavior
mtimesTimesfails with this error:But the proof itself is fine, and it goes through with this change:
mtimes, with theMonoidconstraint, says, if you implement those syntactic elements, you get to use this syntactic element.mtimesTimes, with theVerifiedMonoidconstraint, says, if you further prove certain guarantees about the behavior of those syntactic elements, you also get some guarantees about the behavior of this new element. So the "verified" constraint shouldn't be necessary for definingmtimes, becausemtimesdoesn't make any guarantees about behavior.The inheritance structure looks like this:
This bug is in Idris 1 too.