Skip to content

Commit 306c261

Browse files
authored
Merge pull request #4258 from FStarLang/gebner_default_smtfail
Print SMT query for failing assertions.
2 parents a8582c7 + e198009 commit 306c261

80 files changed

Lines changed: 1243 additions & 498 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

pulse/src/checker/Pulse.Checker.Pure.fst

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -177,19 +177,27 @@ let ill_typed_term (t:term) (expected_typ got_typ : option term)
177177
(ensures fun _ -> True)
178178
=
179179
let open Pulse.PP in
180-
match expected_typ, got_typ with
181-
| None, None -> [
182-
prefix 2 1 (text "Ill-typed term:") (pp t)
183-
]
184-
| Some ty, None -> [
185-
prefix 2 1 (text "Ill-typed term:") (pp t);
186-
prefix 2 1 (text "Expected a term of type") (pp ty);
187-
]
188-
| Some ty, Some ty' -> [
189-
prefix 2 1 (text "Expected term of type") (pp ty) ^/^
190-
prefix 2 1 (text "got term") (pp t) ^/^
191-
prefix 2 1 (text "of type") (pp ty')
192-
]
180+
// We used to print the term and the expected type as part of the error
181+
// message, but this is often misleading and unhelpful:
182+
// - It implies that the top-level term is at fault,
183+
// but the error might be in a subterm
184+
// - It implies that the term has the wrong type,
185+
// but the error might just be a failing precondition.
186+
[text "Ill-typed term"]
187+
188+
// match expected_typ, got_typ with
189+
// | None, None -> [
190+
// prefix 2 1 (text "Ill-typed term:") (pp t)
191+
// ]
192+
// | Some ty, None -> [
193+
// prefix 2 1 (text "Ill-typed term:") (pp t);
194+
// prefix 2 1 (text "Expected a term of type") (pp ty);
195+
// ]
196+
// | Some ty, Some ty' -> [
197+
// prefix 2 1 (text "Expected term of type") (pp ty) ^/^
198+
// prefix 2 1 (text "got term") (pp t) ^/^
199+
// prefix 2 1 (text "of type") (pp ty')
200+
// ]
193201

194202
let instantiate_term_implicits
195203
(g:env) (t0:term) (expected:option typ) (inst_extra:bool)

pulse/test/LoopInvariants.fst.output.expected

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,13 @@
44
- Pulse.Lib.Reference.pts_to s 3
55
- Pulse.Lib.Reference.pts_to s 2
66
- Assertion failed
7-
- The SMT solver could not prove the query. Use --query_stats for more
8-
details.
7+
- The SMT solver could not prove the query.
8+
- Env =
9+
(r : Pulse.Lib.Reference.ref Prims.int)
10+
(s : Pulse.Lib.Reference.ref Prims.int) (meas : Prims.unit)
11+
(__ : Prims.squash (meas == ())) (__ : Prims.squash (true == true))
12+
(__ : Prims.unit)
13+
- VC = Pulse.Lib.Reference.pts_to s 3 == Pulse.Lib.Reference.pts_to s 2
914
- See also LoopInvariants.fst(65,4-65,10)
1015

1116
* Info at LoopInvariants.fst(76,4-76,8):
@@ -14,7 +19,12 @@
1419
- Pulse.Lib.Reference.pts_to s 3
1520
- Pulse.Lib.Reference.pts_to s 2
1621
- Assertion failed
17-
- The SMT solver could not prove the query. Use --query_stats for more
18-
details.
22+
- The SMT solver could not prove the query.
23+
- Env =
24+
(r : Pulse.Lib.Reference.ref Prims.int)
25+
(s : Pulse.Lib.Reference.ref Prims.int) (meas : Prims.unit)
26+
(__ : Prims.squash (meas == ())) (__ : Prims.squash (true == true))
27+
(__ : Prims.unit)
28+
- VC = Pulse.Lib.Reference.pts_to s 3 == Pulse.Lib.Reference.pts_to s 2
1929
- See also LoopInvariants.fst(76,4-76,10)
2030

pulse/test/MatchBasic.fst.output.expected

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
- Expected failure:
33
- Could not verify that this match is exhaustive.
44
- Patterns are incomplete
5-
- The SMT solver could not prove the query. Use --query_stats for more
6-
details.
5+
- The SMT solver could not prove the query.
6+
- Env = (xs : Prims.list Prims.int)
7+
- VC = ~(Nil? xs) ==> Prims.l_False
78
- Also see: MatchBasic.fst(134,8-134,10)
89

Lines changed: 43 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,51 @@
11
* Info at Test.Recursion.fst(84,2-84,20):
22
- Expected failure:
3-
- Ill-typed term: test_ghost_loop ()
4-
- Expected a term of type
5-
ghost fn
6-
requires emp
7-
ensures emp
3+
- Ill-typed term
84
- Could not prove termination
9-
- The SMT solver could not prove the query. Use --query_stats for more
10-
details.
5+
- The SMT solver could not prove the query.
6+
- Env =
7+
(x : Prims.unit)
8+
(test_ghost_loop
9+
:
10+
11+
x':
12+
Prims.unit
13+
{ FStar.Range.labeled FStar.Range.range_0
14+
"Could not prove termination"
15+
(() << ()) }
16+
-> ghost fn
17+
requires Pulse.Lib.Core.emp
18+
ensures Pulse.Lib.Core.emp)
19+
- VC =
20+
FStar.Range.labeled FStar.Range.range_0
21+
"Could not prove termination"
22+
(() << ())
1123

1224
* Info at Test.Recursion.fst(127,4-127,22):
1325
- Expected failure:
14-
- Ill-typed term: test5' (z - 1) (y - 1)
15-
- Expected a term of type
16-
ghost fn
17-
requires emp
18-
ensures emp
26+
- Ill-typed term
1927
- Could not prove termination
20-
- The SMT solver could not prove the query. Use --query_stats for more
21-
details.
28+
- The SMT solver could not prove the query.
29+
- Env =
30+
(z : Prims.int) (y : Prims.nat)
31+
(test5'
32+
:
33+
34+
z': Prims.int ->
35+
y':
36+
Prims.nat
37+
{ FStar.Range.labeled FStar.Range.range_0
38+
"Could not prove termination"
39+
(z' << z) }
40+
-> ghost fn
41+
requires Pulse.Lib.Core.emp
42+
ensures Pulse.Lib.Core.emp)
43+
(_if_hyp
44+
:
45+
Prims.squash (Pulse.Lib.Core.rewrites_to_p (z <> 0 && y <> 0) true))
46+
- VC =
47+
y - 1 >= 0 /\
48+
FStar.Range.labeled FStar.Range.range_0
49+
"Could not prove termination"
50+
(z - 1 << z)
2251

pulse/test/bug-reports/Bug.DesugaringError.fst.output.expected

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@
1313

1414
* Info at Bug.DesugaringError.fst(36,4-36,8):
1515
- Expected failure:
16-
- Ill-typed term: f true
16+
- Ill-typed term
1717
- Expected expression of type Prims.nat got expression true of type Prims.bool
1818

pulse/test/bug-reports/Bug100.fst.output.expected

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,31 @@
33
- Subtyping check failed
44
- Expected type FStar.Seq.Base.seq Prims.int
55
got type FStar.Seq.Base.seq Prims.nat
6-
- The SMT solver could not prove the query. Use --query_stats for more
7-
details.
6+
- The SMT solver could not prove the query.
7+
- Env =
8+
- VC =
9+
forall (a1: Pulse.Lib.Array.Core.array Prims.int)
10+
(s1: FStar.Seq.Base.seq Prims.nat).
11+
(* - Subtyping check failed\n - Expected type FStar.Seq.Base.seq Prims.int\n got type FStar.Seq.Base.seq Prims.nat *)
12+
forall (i: Prims.int). i >= 0
813
- See also Prims.fst(642,18-642,24)
914

1015
* Info at Bug100.fst(19,57-19,58):
1116
- Expected failure:
1217
- Subtyping check failed
1318
- Expected type FStar.Seq.Base.seq Prims.int
1419
got type FStar.Seq.Base.seq Prims.nat
15-
- The SMT solver could not prove the query. Use --query_stats for more
16-
details.
20+
- The SMT solver could not prove the query.
21+
- Env = (a : Bug100.array Prims.int) (s : FStar.Seq.Base.seq Prims.nat)
22+
- VC = forall (i: Prims.int). i >= 0
1723
- See also Prims.fst(642,18-642,24)
1824

1925
* Info at Bug100.fst(23,11-23,17):
2026
- Expected failure:
21-
- Ill-typed term: pts_to int a1 s1
22-
- Expected a term of type slprop
27+
- Ill-typed term
2328
- Assertion failed
24-
- The SMT solver could not prove the query. Use --query_stats for more
25-
details.
29+
- The SMT solver could not prove the query.
30+
- Env = (a1 : Bug100.array Prims.int) (s1 : FStar.Seq.Base.seq Prims.nat)
31+
- VC = forall (i: Prims.int). Prims.l_True == (i >= 0 == true)
2632
- Also see: Prims.fst(165,27-165,38)
2733

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
* Info at Bug206.fst(14,2-14,6):
22
- Expected failure:
3-
- Ill-typed term: test x
4-
- Expected a term of type
5-
fn
6-
requires emp
7-
ensures emp
3+
- Ill-typed term
84
- Assertion failed
9-
- The SMT solver could not prove the query. Use --query_stats for more
10-
details.
5+
- The SMT solver could not prove the query.
6+
- Env = (x : Prims.nat)
7+
- VC = x > 0
118
- See also Bug206.fst(14,2-14,8)
129

pulse/test/bug-reports/Bug266.fst.output.expected

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
- Expected failure:
33
- Failed to prove pure property: l_False
44
- Assertion failed
5-
- The SMT solver could not prove the query. Use --query_stats for more
6-
details.
5+
- The SMT solver could not prove the query.
6+
- Env = (uu___0 : Prims.unit)
7+
- VC = Prims.l_False
78
- See also Bug266.fst(10,31-10,36)
89

910
* Info at Bug266.fst(24,2-24,9):

pulse/test/bug-reports/Bug267.fst.output.expected

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,17 @@
77
- Expected failure:
88
- Could not prove equality between computed type int and expected type nat
99
- Assertion failed
10-
- The SMT solver could not prove the query. Use --query_stats for more
11-
details.
10+
- The SMT solver could not prove the query.
11+
- Env =
12+
(x : Prims.nat) (y : Prims.nat) (ctr : Pulse.Lib.Reference.ref Prims.int)
13+
(acc : Pulse.Lib.Reference.ref Prims.int) (__ : Prims.unit)
14+
(___8 : FStar.Ghost.erased Prims.unit)
15+
(__c89 : FStar.Ghost.erased (FStar.Ghost.erased Prims.int))
16+
(__a910 : FStar.Ghost.erased (FStar.Ghost.erased Prims.int))
17+
(__ : Prims.squash (__c89 <= x /\ __a910 == __c89 * y))
18+
(__ : Prims.squash (___8 == ()))
19+
(__ : Prims.squash (false == (__c89 < x)))
20+
- VC = forall (i: Prims.int). Prims.l_True == (i >= 0 == true)
1221
- Also see: Prims.fst(165,27-165,38)
1322
- See also Bug267.fst(58,4-58,8)
1423

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
* Info at Bug59.fst(12,11-12,24):
22
- Expected failure:
3-
- Ill-typed term: pure (x == y)
4-
- Expected a term of type slprop
3+
- Ill-typed term
54
- Assertion failed
6-
- The SMT solver could not prove the query. Use --query_stats for more
7-
details.
5+
- The SMT solver could not prove the query.
6+
- Env = (a : Type0) (b : Type0) (x : a) (y : b)
7+
- VC = b == a
88

0 commit comments

Comments
 (0)