-
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 ] totality checking can look under constructors (#3362)
- Loading branch information
1 parent
8f1f276
commit 12e7939
Showing
16 changed files
with
214 additions
and
45 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,5 @@ | ||
total | ||
f : (a, List a) -> () | ||
f (_, []) = () | ||
f (x, _::xs) = f (x, 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,12 @@ | ||
import Data.Fin | ||
|
||
covering | ||
g : Fin 64 -> Unit | ||
g FZ = () | ||
g (FS i') = g $ weaken i' | ||
|
||
total | ||
g' : Fin 64 -> Unit | ||
g' FZ = () | ||
g' i@(FS i') = g' $ assert_smaller i $ weaken i' | ||
|
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,14 @@ | ||
%default total | ||
|
||
%totality_depth 1 | ||
|
||
failing "not total" | ||
one : List a -> Nat | ||
one (a :: b :: c :: es) = one (a :: b :: es) | ||
one _ = 0 | ||
|
||
%totality_depth 3 | ||
|
||
two : List a -> Nat | ||
two (a :: b :: c :: es) = two (a :: b :: es) | ||
two _ = 0 |
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,50 @@ | ||
%default total | ||
|
||
-- This one needed withHoles on tcOnly (instead of withArgHoles) | ||
-- or the solved implicit for the (ty : Type) on Maybe would not be | ||
-- substituted. | ||
length : Maybe (List a) -> Nat | ||
length Nothing = 0 | ||
length (Just []) = 0 | ||
length (Just (x :: xs)) = 1 + length (Just xs) | ||
|
||
one : List a -> Nat | ||
one (x :: y :: zs) = one (x :: zs) | ||
one _ = 0 | ||
|
||
two : List a -> Nat | ||
two (a :: b :: c :: d :: es) = two (a :: c :: es) | ||
two _ = 0 | ||
|
||
three : List a -> Nat | ||
three (a :: b :: c :: d :: es) = three (b :: c :: es) | ||
three _ = 0 | ||
|
||
failing "not total" | ||
four : List Nat -> Nat | ||
four (a :: b :: c :: es) = four (b :: c :: a :: es) | ||
four _ = 0 | ||
|
||
-- also needs withHoles | ||
five : (List a, List a) -> List a | ||
five (a :: as, bs) = a :: five (as, bs) | ||
five ([], _) = [] | ||
|
||
-- This is total, but not supported | ||
failing "not total" | ||
six : (List a, List a) -> List a | ||
six (a :: as, bs) = a :: six (bs, as) | ||
six ([], _) = [] | ||
|
||
|
||
failing "not total" | ||
-- If we didn't check all of the arguments of MkTuple for | ||
-- Same/Smaller, then this would be incorrectly accepted as total | ||
first : (List Nat, List Nat) -> Nat | ||
second : (List Nat, List Nat) -> Nat | ||
|
||
first (x :: xs, ys) = second (xs, Z :: ys) | ||
first _ = Z | ||
|
||
second (xs, y :: ys) = first (1 :: xs, ys) | ||
second _ = Z |
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 @@ | ||
1/1: Building Issue3317 (Issue3317.idr) | ||
1/1: Building Totality (Totality.idr) | ||
1/1: Building Issue3353 (Issue3353.idr) | ||
1/1: Building Pragma (Pragma.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,6 @@ | ||
. ../../../testutils.sh | ||
|
||
idris2 --check Issue3317.idr | ||
idris2 --check Totality.idr | ||
idris2 --check Issue3353.idr | ||
idris2 --check Pragma.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