Skip to content

Commit e3025bc

Browse files
authored
Merge pull request #2577 from ucsd-progsys/CVC5-cardinality
add CVC5 cardinality support
2 parents 70f298c + f166925 commit e3025bc

File tree

6 files changed

+34
-1
lines changed

6 files changed

+34
-1
lines changed

liquidhaskell-boot/src/Language/Haskell/Liquid/WiredIn.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ wiredTheorySortedSyms =
113113
, "Set_sub"
114114
, "Set_add"
115115
, "Set_com"
116+
, "Set_card"
116117

117118
, "Bag_count"
118119
, "Bag_empty"

src/Data/Set_LHAssumptions.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ embed Set as Set_Set
1717
assume isSubsetOf :: (Ord a) => x:(Set a) -> y:(Set a) -> {v:Bool | v <=> Set_sub x y}
1818
assume member :: Ord a => x:a -> xs:(Set a) -> {v:Bool | v <=> Set_mem x xs}
1919
assume null :: Ord a => xs:(Set a) -> {v:Bool | v <=> Set_emp xs}
20+
assume size :: xs:(Set a) -> {v:Nat | v = Set_card xs}
2021

2122
assume empty :: {v:(Set a) | Set_emp v}
2223
assume singleton :: x:a -> {v:(Set a) | v = (Set_sng x)}
@@ -44,6 +45,7 @@ define intersection x y = (Set_cap x y)
4445
define difference x y = (Set_dif x y)
4546
define empty = (Set_empty 0)
4647
define null x = (Set_emp x)
48+
define size x = (Set_card x)
4749
define member x xs = (Set_mem x xs)
4850
define isSubsetOf x y = (Set_sub x y)
4951
define fromList xs = (Data.Set_LHAssumptions.listElts xs)

tests/neg/Card.hs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{-@ LIQUID "--expect-any-error" @-}
2+
{-@ LIQUID "--smtsolver=CVC5" @-}
3+
module Card where
4+
5+
import Data.Set
6+
import qualified Data.Set as Set
7+
8+
9+
{-@ insert :: x:Int -> xs:[Int] -> {v:[Int] | Set.size (Set.fromList v) == Set.size (Set.fromList xs)} @-}
10+
insert :: Int -> [Int] -> [Int]
11+
insert x xs = x:xs

tests/pos/Card.hs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{-@ LIQUID "--smtsolver=CVC5" @-}
2+
module Card where
3+
4+
import Data.Set
5+
import qualified Data.Set as Set
6+
7+
8+
{-@ insert :: x:Int -> xs:[Int] -> {v:[Int] | Set.size (Set.fromList v) >= Set.size (Set.fromList xs)} @-}
9+
insert :: Int -> [Int] -> [Int]
10+
insert x xs = x:xs
11+
12+
13+
14+
{-@ insert' :: x:Int -> xs:{[Int] | not (member x (fromList xs))}
15+
-> {v:[Int] | Set.size (Set.fromList v) = 1 + Set.size (Set.fromList xs)} @-}
16+
insert' :: Int -> [Int] -> [Int]
17+
insert' x xs = x:xs

tests/tests.cabal

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,6 +1102,7 @@ executable unit-neg
11021102
, BigNum
11031103
, BinarySearchOverflow
11041104
, Books
1105+
-- , Card
11051106
, CastedTotality
11061107
, CharLiterals
11071108
, CheckedNum
@@ -1440,6 +1441,7 @@ executable unit-pos-2
14401441
buildable: False
14411442

14421443
other-modules:
1444+
-- Card
14431445
ExactADT6
14441446
, ExactGADT0
14451447
, ExactGADT1

0 commit comments

Comments
 (0)