-
Notifications
You must be signed in to change notification settings - Fork 642
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Annotate functions as %hint for auto search
This allows extra hints, as well as constructors, to guide proof search for auto implicit arguments. Added test proof010 which shows how this works to simulate type classes with overlapping instances (and consequently no injectivity restriction or assumption) %hint only works on functions which return an instance of a data type. Proof search exhaustively searches hints and constructors, so use with care especially when adding lots of recursive or overlapping hints.
- Loading branch information
Showing
13 changed files
with
142 additions
and
32 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
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,6 @@ | ||
2, << function >> | ||
3, << function >> | ||
|
||
some bools | ||
some bools | ||
|
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,39 @@ | ||
data MyShow : Type -> Type where | ||
ShowInstance : (show : a -> String) -> MyShow a | ||
|
||
myshow : {auto inst : MyShow a} -> a -> String | ||
myshow {inst = ShowInstance show} x1 = show x1 | ||
|
||
%hint | ||
showNat : MyShow Nat | ||
showNat = ShowInstance show | ||
|
||
%hint | ||
showFn : MyShow (a -> b) | ||
showFn = ShowInstance (\x => "<< function >>") | ||
|
||
%hint | ||
showBools : MyShow (Bool, Bool) | ||
showBools = ShowInstance (\x => "some bools") | ||
|
||
%hint | ||
showStuff : MyShow a -> MyShow b -> MyShow (a, b) | ||
showStuff sa sb = ShowInstance showPair | ||
where | ||
showPair : (a, b) -> String | ||
showPair (x, y) = myshow x ++ ", " ++ myshow y | ||
|
||
testShow : List (Bool, Bool) -> String | ||
testShow [] = "" | ||
testShow (x :: xs) = myshow x ++ "\n" ++ testShow xs | ||
|
||
testShow2 : List (Nat, Int -> Int) -> String | ||
testShow2 [] = "" | ||
testShow2 (x :: xs) = myshow x ++ "\n" ++ testShow2 xs | ||
|
||
main : IO () | ||
main = do putStrLn $ testShow2 [(2, (+1)), (3, abs)] | ||
putStrLn $ testShow [(True, False), (False, True)] | ||
|
||
|
||
|
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,4 @@ | ||
#!/usr/bin/env bash | ||
idris $@ proof010.idr -o proof010 | ||
./proof010 | ||
rm -f proof010 *.ibc |