Skip to content

Commit 0961495

Browse files
Merge branch 'ucsd-progsys:develop' into develop
2 parents 1a80b0d + a21bd66 commit 0961495

File tree

35 files changed

+333
-368
lines changed

35 files changed

+333
-368
lines changed

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[submodule "liquid-fixpoint"]
22
path = liquid-fixpoint
3-
url = https://github.com/ucsd-progsys/liquid-fixpoint.git
3+
url = https://github.com/ucsd-progsys/liquid-fixpoint.git

CHANGES.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## Next
44

5+
- Simplify kvar solutions in fqout files [liquid-fixpoint#741](https://github.com/ucsd-progsys/liquid-fixpoint/pull/741).
6+
7+
## 0.9.10.1.2 (2025-03-06)
8+
59
- Implement opaque reflection, a feature to allow reflecting functions which
610
call to non-reflected functions [#2323](https://github.com/ucsd-progsys/liquidhaskell/pull/2323).
711
- Implement reflection from interface files, which can reflect functions from
@@ -15,11 +19,20 @@
1519
and constraint generation [#2336](https://github.com/ucsd-progsys/liquidhaskell/pull/2336).
1620
- Augmented the context of error messages [#2350](https://github.com/ucsd-progsys/liquidhaskell/pull/2350).
1721
- Add a new flag `--etabeta` to reason with lambdas in PLE [#2356](https://github.com/ucsd-progsys/liquidhaskell/pull/2356)
22+
- Add a new flag `--dependentcase` to expand support for higher-order reasoning [#2384](https://github.com/ucsd-progsys/liquidhaskell/pull/2384)
23+
- Add support for reflecting lambda expressions [#2465](https://github.com/ucsd-progsys/liquidhaskell/pull/2465).
1824
- Enabling the LiquidHaskell plugin now enables `-fno-ignore-interface-pragmas` ([#2326](https://github.com/ucsd-progsys/liquidhaskell/pull/2326))
1925
and `-dkeep-comments` ([#2367](https://github.com/ucsd-progsys/liquidhaskell/pull/2367)).
2026
- LiquidHaskell earned a new `--minimal` verbosity level as default that prints the banner with the
2127
amount of constraints checked ([#2395](https://github.com/ucsd-progsys/liquidhaskell/pull/2395)).
2228
This banner is now suppressed when the verbosity is set to `--quiet` ([#2391](https://github.com/ucsd-progsys/liquidhaskell/pull/2391)).
29+
- Avoid reparsing and retypechecking when verifying modules [#2389](https://github.com/ucsd-progsys/liquidhaskell/pull/2389).
30+
- Name resolution is done only when verifying a module. It is no longer done when
31+
importing it [#2169](https://github.com/ucsd-progsys/liquidhaskell/issues/2169). One
32+
side effect of this change is that LH can now pick up names in scope using import aliases
33+
in most places (but see [#2481](https://github.com/ucsd-progsys/liquidhaskell/issues/2481)).
34+
- Allow to link Haskell definitions with logical primitives via `define` declarations [#2463](https://github.com/ucsd-progsys/liquidhaskell/pull/2463).
35+
- CVC5 solver is now supported for all logical theories, including Sets/Bags [#2483](https://github.com/ucsd-progsys/liquidhaskell/pull/2483)
2336

2437
## 0.9.10.1 (2024-08-21)
2538

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
![LiquidHaskell](/resources/logo.png)
22

33

4-
[![Hackage](https://img.shields.io/hackage/v/liquidhaskell.svg)](https://hackage.haskell.org/package/liquidhaskell) [![Hackage-Deps](https://img.shields.io/hackage-deps/v/liquidhaskell.svg)](http://packdeps.haskellers.com/feed?needle=liquidhaskell) [![Build Status](https://img.shields.io/circleci/project/ucsd-progsys/liquidhaskell/master.svg)](https://circleci.com/gh/ucsd-progsys/liquidhaskell)
4+
[![Hackage](https://img.shields.io/hackage/v/liquidhaskell.svg)](https://hackage.haskell.org/package/liquidhaskell) [![Build Status](https://img.shields.io/circleci/project/ucsd-progsys/liquidhaskell/develop.svg)]([https://circleci.com/gh/ucsd-progsys/liquidhaskell](https://app.circleci.com/pipelines/github/ucsd-progsys/liquidhaskell?branch=develop))
55

66
This is the **development** site of the LiquidHaskell formal verification tool.
77

@@ -98,7 +98,11 @@ For example:
9898

9999
$ cabal build tests:unit-neg --ghc-options=-fplugin-opt=LiquidHaskell:--no-termination
100100

101-
Or your favorite number of threads, depending on cores etc.
101+
Another useful option is to change the underlying solver:
102+
103+
$ cabal build tests:unit-pos --ghc-options=-fplugin-opt=LiquidHaskell:--smtsolver=cvc5
104+
105+
You can also modify the number of used threads, depending on cores etc.
102106

103107
You can directly extend and run the tests by modifying the files in
104108

docs/mkDocs/docs/options.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -359,16 +359,15 @@ to run a given file with full-checking, add the pragma:
359359

360360
**Options:** `smtsolver`
361361

362-
By default, LiquidHaskell uses the SMTLIB2 interface for Z3.
362+
By default, LiquidHaskell uses the SMTLIB2 interface for [Z3](https://github.com/Z3Prover/z3).
363363

364364
To run a different solver (supporting SMTLIB2) do:
365365

366366
$ liquid --smtsolver=NAME foo.hs
367367

368-
Currently, LiquidHaskell supports
368+
Currently, LiquidHaskell additionally supports
369369

370-
+ [CVC4](http://cvc4.cs.stanford.edu/web/)
371-
+ [MathSat](http://mathsat.fbk.eu/download.html )
370+
+ [CVC5](https://cvc5.github.io/)
372371

373372
To use these solvers, you must install the corresponding binaries
374373
from the above web-pages into your `PATH`.

docs/mkDocs/docs/specifications.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,3 +1026,22 @@ Or in a Haskell source file:
10261026
- No support for abstract refinements. All abstract refinements are erased before relational typechecking. Notably, this happens for the standard list `[a]` and tuple `(a, b)` types!
10271027

10281028
- Limited support for higher-order relational signatures. Use `!=>` instead of `:=>` after the function arguments to enable higher-order checking.
1029+
1030+
## Lazy Variables
1031+
1032+
A variable can be specified as `lazyvar` to defer its checking until it is used. This is useful in cases where a variable is defined in a `where` clause and should only be checked in the context where it is used.
1033+
1034+
For example, consider the following code:
1035+
1036+
```haskell
1037+
{-@ safeDiv :: Int -> {v:Int | v /= 0} -> Int @-}
1038+
safeDiv :: Int -> Int -> Int
1039+
safeDiv x y
1040+
| y == 0 = help
1041+
| otherwise = x `div` y
1042+
where
1043+
{-@ lazyvar help @-}
1044+
help = error "lol"
1045+
```
1046+
1047+
In this example, the `lazyvar` annotation on `help` ensures that the check for `help` is deferred until it is used. Without this annotation, LiquidHaskell would incorrectly report an error like `Error: Liquid Type Mismatch`.

liquid-prelude/src/Language/Haskell/Liquid/Bag.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ data Bag a = Bag { toMap :: M.Map a Int } deriving Eq
2323
empty :: Bag k
2424
empty = Bag M.empty
2525

26-
{-@ assume get :: (Ord k) => k:k -> b:Bag k -> {v:Nat | v = Bag_count b k} @-}
27-
{-@ define get k b = (Bag_count b k) @-}
26+
{-@ assume get :: (Ord k) => k:k -> b:Bag k -> {v:Nat | v = Bag_count k b} @-}
27+
{-@ define get k b = (Bag_count k b) @-}
2828
get :: (Ord k) => k -> Bag k -> Int
2929
get k b = M.findWithDefault 0 k (toMap b)
3030

liquid-prelude/src/Language/Haskell/Liquid/ProofCombinators.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ _ *** _ = ()
7575

7676
data QED = Admit | QED
7777

78-
{-@ measure isAdmit :: QED -> Bool @-}
78+
{-@ measure isAdmit @-}
7979
isAdmit :: QED -> Bool
8080
isAdmit Admit = True
8181
isAdmit QED = False

liquidhaskell-boot/liquidhaskell-boot.cabal

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cabal-version: 2.4
22
name: liquidhaskell-boot
3-
version: 0.9.10.1
3+
version: 0.9.10.1.2
44
synopsis: Liquid Types for Haskell
55
description: This package provides a plugin to verify Haskell programs.
66
But most likely you should be using the [liquidhaskell package](https://hackage.haskell.org/package/liquidhaskell)
@@ -142,7 +142,7 @@ library
142142
, gitrev
143143
, hashable >= 1.3 && < 1.6
144144
, hscolour >= 1.22
145-
, liquid-fixpoint == 0.9.6.3.1
145+
, liquid-fixpoint == 0.9.6.3.2
146146
, mtl >= 2.1
147147
, optparse-applicative < 0.19
148148
, githash
@@ -202,7 +202,6 @@ test-suite ghc-api-tests
202202
test-suite liquidhaskell-parser
203203
type: exitcode-stdio-1.0
204204
main-is: Parser.hs
205-
other-modules: Paths_liquidhaskell_boot
206205
hs-source-dirs: tests
207206
build-depends: base >= 4.8.1.0 && < 5
208207
, directory >= 1.2.5 && < 1.4

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

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ import qualified Language.Haskell.Liquid.Bare.Axiom as Bare
5858
import qualified Language.Haskell.Liquid.Bare.ToBare as Bare
5959
import qualified Language.Haskell.Liquid.Bare.Class as Bare
6060
import qualified Language.Haskell.Liquid.Bare.Check as Bare
61+
import qualified Language.Haskell.Liquid.Bare.Resolve as Resolve
6162
import qualified Language.Haskell.Liquid.Bare.Typeclass as Bare
6263
import qualified Language.Haskell.Liquid.Transforms.CoreToLogic as CoreToLogic
6364
import Language.Haskell.Liquid.UX.Config
@@ -178,7 +179,6 @@ ghcSpecEnv sp = F.notracepp "RENV" $ fromListSEnv binds
178179
[ [(x, rSort t) | (x, Loc _ _ t) <- gsMeas (_gsData sp)]
179180
, [(symbol v, rSort t) | (v, Loc _ _ t) <- gsCtors (_gsData sp)]
180181
, [(symbol v, vSort v) | v <- gsReflects (_gsRefl sp)]
181-
, [(x, vSort v) | (x, v) <- gsFreeSyms (_gsName sp), Ghc.isConLikeId v ]
182182
, [(x, RR s mempty) | (x, s) <- wiredSortedSyms ]
183183
, [(x, RR s mempty) | (x, s) <- _gsImps sp ]
184184
]
@@ -252,7 +252,7 @@ makeGhcSpec0 cfg ghcTyLookupEnv tcg instEnvs lenv localVars src lmap targetSpec
252252
, _gsRefl = refl
253253
, _gsData = sData
254254
, _gsQual = qual
255-
, _gsName = makeSpecName env tycEnv measEnv
255+
, _gsName = makeSpecName tycEnv measEnv dataConIds
256256
, _gsVars = spcVars
257257
, _gsTerm = spcTerm
258258

@@ -334,12 +334,19 @@ makeGhcSpec0 cfg ghcTyLookupEnv tcg instEnvs lenv localVars src lmap targetSpec
334334
embs = makeEmbeds src ghcTyLookupEnv (mySpec0 : map snd dependencySpecs)
335335
dm = Bare.tcDataConMap tycEnv0
336336
(dg0, datacons, tycEnv0) = makeTycEnv0 cfg name env embs mySpec2 iSpecs2
337-
env = Bare.makeEnv cfg ghcTyLookupEnv usedDcs tcg instEnvs localVars src lmap ((name, targetSpec) : dependencySpecs)
337+
env = Bare.makeEnv cfg ghcTyLookupEnv dataConIds tcg instEnvs localVars src lmap ((name, targetSpec) : dependencySpecs)
338338
-- check barespecs
339339
name = F.notracepp ("ALL-SPECS" ++ zzz) $ _giTargetMod src
340340
zzz = F.showpp (fst <$> mspecs)
341341

342342
usedDcs = collectAllDataCons (_giCbs src) $ targetSpec : map snd dependencySpecs
343+
dataConIds =
344+
[ Ghc.dataConWorkId dc
345+
| lhn <- S.toList usedDcs
346+
, Just (Ghc.AConLike (Ghc.RealDataCon dc)) <-
347+
[maybeReflectedLHName lhn >>= Resolve.lookupGhcTyThingFromName ghcTyLookupEnv]
348+
]
349+
343350

344351
collectAllDataCons :: Ghc.CoreProgram -> [BareSpec] -> S.HashSet LHName
345352
collectAllDataCons cbs =
@@ -1183,16 +1190,16 @@ mkReft _ _ _ _
11831190

11841191
-- REBARE: formerly, makeGhcSpec3
11851192
-------------------------------------------------------------------------------------------
1186-
makeSpecName :: Bare.Env -> Bare.TycEnv -> Bare.MeasEnv -> GhcSpecNames
1193+
makeSpecName :: Bare.TycEnv -> Bare.MeasEnv -> [Ghc.Id] -> GhcSpecNames
11871194
-------------------------------------------------------------------------------------------
1188-
makeSpecName env tycEnv measEnv = SpNames
1189-
{ gsFreeSyms = Bare.reSyms env
1190-
, gsDconsP = [ F.atLoc dc (dcpCon dc) | dc <- datacons ++ cls ]
1195+
makeSpecName tycEnv measEnv dataConIds = SpNames
1196+
{ gsDconsP = [ F.atLoc dc (dcpCon dc) | dc <- datacons ++ cls ]
11911197
, gsTconsP = tycons
11921198
-- , gsLits = mempty -- TODO-REBARE, redundant with gsMeas
11931199
, gsTcEmbeds = Bare.tcEmbs tycEnv
11941200
, gsADTs = Bare.tcAdts tycEnv
11951201
, gsTyconEnv = Bare.tcTyConMap tycEnv
1202+
, gsDataConIds = dataConIds
11961203
}
11971204
where
11981205
datacons, cls :: [DataConP]
@@ -1373,12 +1380,10 @@ makeLiftedSpec name src env refl sData sig qual myRTE lSpec0 = lSpec0
13731380
where
13741381
myDCs = filter (isLocalName . val . fst) $ mkSigs (gsCtors sData)
13751382
mkSigs xts = [ toBare (x, t) | (x, t) <- xts
1376-
, S.member x sigVars && isExportedVar (toTargetSrc src) x
1383+
, not (S.member x reflVars) && isExportedVar (toTargetSrc src) x
13771384
]
13781385
toBare (x, t) = (makeGHCLHNameLocatedFromId x, Bare.specToBare <$> t)
13791386
xbs = toBare <$> reflTySigs
1380-
sigVars = S.difference defVars reflVars
1381-
defVars = S.fromList (_giDefVars src)
13821387
reflTySigs = [(x, t) | (x,t,_) <- gsHAxioms refl]
13831388
reflVars = S.fromList (fst <$> reflTySigs)
13841389
-- myAliases fld = M.elems . fld $ myRTE

0 commit comments

Comments
 (0)