5

I'd like to verify the Ring instance for Data.Complex.Complex t assuming of course t is also Ring. It was easy until Abelian Group, but with the Ring instance something weird is going on:

VerifiedRing t => VerifiedRing (Complex t) where
    ringOpIsAssociative (l :+ li) (c :+ ci) (r :+ ri) =
        ?VerifiedRing_rhs_1

Now Idris does some expansion on its own and the hole get the following type:

(l <.> (c <.> r <+> inverse (ci <.> ri)) <+> inverse (li <.> (c <.> ri <+> ci <.> r))) :+ (l <.> (c <.> ri <+> ci <.> r) <+> li <.> (c <.> r <+> inverse (ci <.> ri))) =
((l <.> c <+> inverse (li <.> ci)) <.> r <+> inverse ((l <.> ci <+> li <.> c) <.> ri)) :+ ((l <.> c <+> inverse (li <.> ci)) <.> ri <+> (l <.> ci <+> li <.> c) <.> r)

I figure that to prove the equality I need to skip some brackets. So i start with the first one on the left:

rewrite ringOpIsDistributiveL l (c <.> r) (inverse (ci <.> ri)) in
?VerifiedRing_rhs1

To which Idris responds that:

rewriting l <.> (c <.> r <+> inverse (ci <.> ri)) to l <.> (c <.> r) <+>
                                                 l <.>
                                                 inverse (ci <.>
                                                          ri) did not change type (l <.>
                                                                                   (c <.>
                                                                                    r <+>
                                                                                    inverse (ci <.>
                                                                                             ri)) <+>
                                                                                   inverse (li <.>
                                                                                            (c <.>
                                                                                             ri <+>
                                                                                             ci <.>
                                                                                             r)) ...

Note that the type after did not change the type is different than the one suggested earlier. I am at a loss to understand why does it change and why the rewrite does not work when it certainly should.

Sventimir
  • 1,996
  • 3
  • 14
  • 25

0 Answers0