Skip to content
This repository was archived by the owner on Apr 25, 2024. It is now read-only.

Commit 465cca1

Browse files
h0nzZikrv-auditorehildenb
authored
test APRProver: what if a dependency fails (#631)
Adds an untrue RL claim which depends on an untrue dependency, and two tests: (1) if the dependency is admitted, the main claim passes (even though untrue), and (2) if the dependency is not admitted, then the main claim will not be proved (will have status 'pending'). --------- Co-authored-by: devops <[email protected]> Co-authored-by: Everett Hildenbrandt <[email protected]>
1 parent 9d780f1 commit 465cca1

File tree

4 files changed

+58
-5
lines changed

4 files changed

+58
-5
lines changed

package/version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.1.432
1+
0.1.433

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
44

55
[tool.poetry]
66
name = "pyk"
7-
version = "0.1.432"
7+
version = "0.1.433"
88
description = ""
99
authors = [
1010
"Runtime Verification, Inc. <[email protected]>",

src/tests/integration/k-files/imp-simple-spec.k

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,4 +164,12 @@ module IMP-SIMPLE-SPEC
164164
</state>
165165
requires 0 <=Int N
166166

167+
claim [simple-untrue]:
168+
<state>... $s |-> (1 => 2) ...</state>
169+
170+
claim [dep-fail-1]:
171+
<k> $s = $s + 1; => . ...</k>
172+
<state> $s |-> (0 => 2) </state>
173+
[depends(simple-untrue)]
174+
167175
endmodule

src/tests/integration/kcfg/test_imp.py

Lines changed: 48 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,9 @@ def same_loop(self, c1: CTerm, c2: CTerm) -> bool:
343343
),
344344
)
345345

346-
APR_PROVE_TEST_DATA: Iterable[tuple[str, Path, str, str, int | None, int | None, Iterable[str], ProofStatus, int]] = (
346+
APR_PROVE_TEST_DATA: Iterable[
347+
tuple[str, Path, str, str, int | None, int | None, Iterable[str], bool, ProofStatus, int]
348+
] = (
347349
(
348350
'imp-simple-addition-1',
349351
K_FILES / 'imp-simple-spec.k',
@@ -352,6 +354,7 @@ def same_loop(self, c1: CTerm, c2: CTerm) -> bool:
352354
2,
353355
1,
354356
[],
357+
True,
355358
ProofStatus.PASSED,
356359
1,
357360
),
@@ -363,6 +366,7 @@ def same_loop(self, c1: CTerm, c2: CTerm) -> bool:
363366
2,
364367
7,
365368
[],
369+
True,
366370
ProofStatus.PASSED,
367371
1,
368372
),
@@ -374,6 +378,7 @@ def same_loop(self, c1: CTerm, c2: CTerm) -> bool:
374378
2,
375379
1,
376380
[],
381+
True,
377382
ProofStatus.PASSED,
378383
1,
379384
),
@@ -385,6 +390,7 @@ def same_loop(self, c1: CTerm, c2: CTerm) -> bool:
385390
2,
386391
100,
387392
[],
393+
True,
388394
ProofStatus.PASSED,
389395
1,
390396
),
@@ -396,6 +402,7 @@ def same_loop(self, c1: CTerm, c2: CTerm) -> bool:
396402
2,
397403
1,
398404
['IMP.while'],
405+
True,
399406
ProofStatus.PASSED,
400407
1,
401408
),
@@ -407,6 +414,7 @@ def same_loop(self, c1: CTerm, c2: CTerm) -> bool:
407414
4,
408415
100,
409416
['IMP.while'],
417+
True,
410418
ProofStatus.PASSED,
411419
1,
412420
),
@@ -418,6 +426,7 @@ def same_loop(self, c1: CTerm, c2: CTerm) -> bool:
418426
10,
419427
1,
420428
[],
429+
True,
421430
ProofStatus.FAILED,
422431
2,
423432
),
@@ -429,6 +438,7 @@ def same_loop(self, c1: CTerm, c2: CTerm) -> bool:
429438
None,
430439
None,
431440
[],
441+
True,
432442
ProofStatus.PASSED,
433443
1,
434444
),
@@ -440,6 +450,7 @@ def same_loop(self, c1: CTerm, c2: CTerm) -> bool:
440450
None,
441451
None,
442452
[],
453+
True,
443454
ProofStatus.PASSED,
444455
1,
445456
),
@@ -451,6 +462,7 @@ def same_loop(self, c1: CTerm, c2: CTerm) -> bool:
451462
None,
452463
None,
453464
[],
465+
True,
454466
ProofStatus.PASSED,
455467
1,
456468
),
@@ -462,6 +474,7 @@ def same_loop(self, c1: CTerm, c2: CTerm) -> bool:
462474
None,
463475
None,
464476
[],
477+
True,
465478
ProofStatus.PASSED,
466479
2,
467480
),
@@ -473,6 +486,7 @@ def same_loop(self, c1: CTerm, c2: CTerm) -> bool:
473486
None,
474487
None,
475488
[],
489+
True,
476490
ProofStatus.PASSED,
477491
2,
478492
),
@@ -484,6 +498,7 @@ def same_loop(self, c1: CTerm, c2: CTerm) -> bool:
484498
None,
485499
None,
486500
[],
501+
True,
487502
ProofStatus.PASSED,
488503
1, # We can reuse subproofs.
489504
),
@@ -495,6 +510,7 @@ def same_loop(self, c1: CTerm, c2: CTerm) -> bool:
495510
None,
496511
None,
497512
[],
513+
True,
498514
ProofStatus.PASSED,
499515
1, # We can reuse subproofs.
500516
),
@@ -506,6 +522,7 @@ def same_loop(self, c1: CTerm, c2: CTerm) -> bool:
506522
None,
507523
None,
508524
['IMP.while'], # If we do not include `IMP.while` in this list, we get 4 branches instead of 2
525+
True,
509526
ProofStatus.PASSED,
510527
2,
511528
),
@@ -517,6 +534,7 @@ def same_loop(self, c1: CTerm, c2: CTerm) -> bool:
517534
None,
518535
None,
519536
[],
537+
True,
520538
ProofStatus.PASSED,
521539
1,
522540
),
@@ -528,9 +546,34 @@ def same_loop(self, c1: CTerm, c2: CTerm) -> bool:
528546
None,
529547
None,
530548
[],
549+
False,
531550
ProofStatus.FAILED,
532551
1,
533552
),
553+
(
554+
'imp-dep-untrue-fail',
555+
K_FILES / 'imp-simple-spec.k',
556+
'IMP-SIMPLE-SPEC',
557+
'dep-fail-1',
558+
None,
559+
None,
560+
[],
561+
False,
562+
ProofStatus.PENDING, # because we do NOT admit the dependency
563+
1,
564+
),
565+
(
566+
'imp-dep-untrue-admitted',
567+
K_FILES / 'imp-simple-spec.k',
568+
'IMP-SIMPLE-SPEC',
569+
'dep-fail-1',
570+
None,
571+
None,
572+
[],
573+
True,
574+
ProofStatus.PASSED, # because we DO admit the dependency, even though it is untrue
575+
1,
576+
),
534577
)
535578

536579
PATH_CONSTRAINTS_TEST_DATA: Iterable[
@@ -824,7 +867,7 @@ def test_assume_defined(
824867
assert actual == expected
825868

826869
@pytest.mark.parametrize(
827-
'test_id,spec_file,spec_module,claim_id,max_iterations,max_depth,cut_rules,proof_status,expected_leaf_number',
870+
'test_id,spec_file,spec_module,claim_id,max_iterations,max_depth,cut_rules,admit_deps,proof_status,expected_leaf_number',
828871
APR_PROVE_TEST_DATA,
829872
ids=[test_id for test_id, *_ in APR_PROVE_TEST_DATA],
830873
)
@@ -839,6 +882,7 @@ def test_all_path_reachability_prove(
839882
max_iterations: int | None,
840883
max_depth: int | None,
841884
cut_rules: Iterable[str],
885+
admit_deps: bool,
842886
proof_status: ProofStatus,
843887
expected_leaf_number: int,
844888
tmp_path_factory: TempPathFactory,
@@ -871,7 +915,8 @@ def qualify(module: str, label: str) -> str:
871915
for c in deps_claims
872916
]
873917
for dp in deps_proofs:
874-
dp.admit()
918+
if admit_deps:
919+
dp.admit()
875920
dp.write_proof_data()
876921
# </Admit all the dependencies >
877922

0 commit comments

Comments
 (0)