-
Notifications
You must be signed in to change notification settings - Fork 380
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ new ] Quantity for proof in with-clauses (#3415)
* [ new ] Quantity for proof in with-clauses * [ test ] Add failing tests for quantities of proofs * [ cleanup ] Match on pairs * [ test ] Add test for 0 proof in elaborator script * [ cleanup ] Use `So` and `All` from base in tests
- Loading branch information
Showing
16 changed files
with
148 additions
and
19 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
module WithProof0 | ||
|
||
%default total | ||
|
||
%hide List.filter | ||
|
||
filter : (p : a -> Bool) -> (xs : List a) -> List a | ||
filter p [] = [] | ||
filter p (x :: xs) with (p x) | ||
filter p (x :: xs) | False = filter p xs | ||
filter p (x :: xs) | True = x :: filter p xs | ||
|
||
|
||
filterSquared : (p : a -> Bool) -> (xs : List a) -> | ||
filter p (filter p xs) === filter p xs | ||
filterSquared p [] = Refl | ||
filterSquared p (x :: xs) with (p x) proof 0 eq | ||
filterSquared p (x :: xs) | False = filterSquared p xs -- easy | ||
filterSquared p (x :: xs) | True | ||
= rewrite eq in cong (x ::) (filterSquared p xs) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
module WithProof0ElabFail | ||
|
||
import Data.So | ||
import Data.List.Quantifiers | ||
import Language.Reflection | ||
|
||
%default total | ||
|
||
%language ElabReflection | ||
|
||
%hide List.filter | ||
|
||
filter : (p : a -> Bool) -> (xs : List a) -> List a | ||
filter p [] = [] | ||
filter p (x :: xs) with (p x) | ||
filter p (x :: xs) | False = filter p xs | ||
filter p (x :: xs) | True = x :: filter p xs | ||
|
||
failing "While processing right hand side of with block in allFilter. prf is not accessible in this context" | ||
%runElab declare `[ | ||
allFilter : (p : a -> Bool) -> (xs : List a) -> All (So . p) (filter p xs) | ||
allFilter p [] = [] | ||
allFilter p (x :: xs) with (p x) proof 0 prf | ||
allFilter p (x :: xs) | False = allFilter p xs | ||
allFilter p (x :: xs) | True = eqToSo prf :: allFilter p xs | ||
] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
module WithProof0Fail | ||
|
||
import Data.So | ||
import Data.List.Quantifiers | ||
|
||
%default total | ||
|
||
%hide List.filter | ||
|
||
filter : (p : a -> Bool) -> (xs : List a) -> List a | ||
filter p [] = [] | ||
filter p (x :: xs) with (p x) | ||
filter p (x :: xs) | False = filter p xs | ||
filter p (x :: xs) | True = x :: filter p xs | ||
|
||
failing "While processing right hand side of with block in allFilter. prf is not accessible in this context" | ||
allFilter : (p : a -> Bool) -> (xs : List a) -> All (So . p) (filter p xs) | ||
allFilter p [] = [] | ||
allFilter p (x :: xs) with (p x) proof 0 prf | ||
allFilter p (x :: xs) | False = allFilter p xs | ||
allFilter p (x :: xs) | True = eqToSo prf :: allFilter p xs |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
module WithProof1 | ||
|
||
%default total | ||
|
||
%hide List.filter | ||
|
||
filter : (p : a -> Bool) -> (xs : List a) -> List a | ||
filter p [] = [] | ||
filter p (x :: xs) with (p x) | ||
filter p (x :: xs) | False = filter p xs | ||
filter p (x :: xs) | True = x :: filter p xs | ||
|
||
consumeEq : (1 _ : x === y) -> () | ||
consumeEq Refl = () | ||
|
||
filterSquared : (p : a -> Bool) -> (xs : List a) -> | ||
filter p (filter p xs) === filter p xs | ||
filterSquared p [] = Refl | ||
filterSquared p (x :: xs) with (p x) proof 1 eq | ||
filterSquared p (x :: xs) | False = case consumeEq eq of | ||
() => filterSquared p xs | ||
filterSquared p (x :: xs) | True = case consumeEq eq of | ||
() => rewrite eq in cong (x ::) (filterSquared p xs) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
module WithProof1Fail | ||
|
||
%default total | ||
|
||
%hide List.filter | ||
|
||
filter : (p : a -> Bool) -> (xs : List a) -> List a | ||
filter p [] = [] | ||
filter p (x :: xs) with (p x) | ||
filter p (x :: xs) | False = filter p xs | ||
filter p (x :: xs) | True = x :: filter p xs | ||
|
||
failing "While processing right hand side of with block in filterSquared. There are 0 uses of linear name eq" | ||
filterSquared : (p : a -> Bool) -> (xs : List a) -> | ||
filter p (filter p xs) === filter p xs | ||
filterSquared p [] = Refl | ||
filterSquared p (x :: xs) with (p x) proof 1 eq | ||
filterSquared p (x :: xs) | False = filterSquared p xs | ||
filterSquared p (x :: xs) | True = filterSquared p xs |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
1/1: Building WithProof0 (WithProof0.idr) | ||
1/1: Building WithProof1 (WithProof1.idr) | ||
1/1: Building WithProof0Fail (WithProof0Fail.idr) | ||
1/1: Building WithProof1Fail (WithProof1Fail.idr) | ||
1/1: Building WithProof0ElabFail (WithProof0ElabFail.idr) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
. ../../../testutils.sh | ||
|
||
check WithProof0.idr | ||
check WithProof1.idr | ||
check WithProof0Fail.idr | ||
check WithProof1Fail.idr | ||
check WithProof0ElabFail.idr |