Last active
August 29, 2015 14:15
-
-
Save puffnfresh/345dc5800722a3139eca to your computer and use it in GitHub Desktop.
Idris version of https://gist.github.com/copumpkin/8758586
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Idris translation of copumpkin's Agda code: | |
-- https://gist.github.com/copumpkin/8758586 | |
-- Proves that List reverse is completely specified by: | |
-- 1. f [] = [] | |
-- 2. f [x] = [x] | |
-- 3. f (xs ++ ys) = f ys ++ f xs | |
reverse' : List a -> List a | |
reverse' [] = [] | |
reverse' (x :: xs) = reverse' xs ++ [x] | |
record ReverseLike : (List a -> List a) -> Type where | |
RL : {reverse : List a -> List a} -> | |
(reverse0 : reverse [] = []) -> | |
(reverse1 : (x : a) -> reverse [x] = [x]) -> | |
(reverseFlip : (xs, ys : List a) -> reverse (xs ++ ys) = reverse ys ++ reverse xs) -> | |
ReverseLike reverse | |
reverse'Proof : (f : List a -> List a) -> ReverseLike f -> (xs : List a) -> f xs = reverse' xs | |
reverse'Proof f (RL reverse0 reverse1 reverseFlip) [] = reverse0 | |
reverse'Proof f (RL reverse0 reverse1 reverseFlip) (x :: xs) = | |
let inductiveHypothesis = reverse'Proof f (RL reverse0 reverse1 reverseFlip) xs | |
in ?reverse'ProofStepCase | |
---------- Proofs ---------- | |
reverse'ProofStepCase = proof | |
intros | |
rewrite sym (reverseFlip [x] xs) | |
rewrite sym (reverse1 x) | |
rewrite inductiveHypothesis | |
trivial |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment