Created
September 4, 2019 19:42
-
-
Save tsani/35c369f7153fd606a1d8698ea1d55b38 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
all' : (a -> Bool) -> List a -> Bool | |
all' f [] = True | |
all' f (x :: xs) = f x && all' f xs | |
allLemma : f x = True -> all' f xs = True -> all' f (x :: xs) = True | |
allLemma p1 p2 = rewrite p1 in rewrite p2 in Refl | |
allFiltered : (f : a -> Bool) -> (xs : List a) -> all' f (filter f xs) = True | |
allFiltered f [] = Refl | |
allFiltered f (x :: xs) = lemma (allFiltered f xs) (f x) Refl where | |
lemma : all' f (filter f xs) = True -> (b : Bool) -> b = f x -> all' f (filter f (x :: xs)) = True | |
lemma p False p2 = | |
rewrite sym p2 in p | |
lemma p True p2 = rewrite sym p2 in allLemma (sym p2) p |
Oh my god, this is incredible! It's like Idris has the "inspect" pattern from Agda built right in! Thanks for showing me
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
There's a section at the bottom of http://docs.idris-lang.org/en/latest/tutorial/views.html explaining this, basically
fx
is the name of the variable that will hold the proof that the expression being matched on equals the corresponding result for each matcher branch.