Skip to content

Commit 26902b1

Browse files
Dwight Guthrv-jenkins
andauthored
Remove injections from output files of proof hint tests (#1048)
Since the Pi2 team that consumes the proof hint is discarding the injections, and we have a minor issue in our upcoming serialization PR that does not quite deserialize injections correctly, I figured the expedient thing to do would be to test whether or not the updated serialization format provides the same output modulo the injections in the provided terms. We implement this by simply recursively visiting each term as it is printed by `kore-proof-trace` and stripping out the injections prior to printing it. This will be used to show that the deserialized output does not change modulo the injections in a follow-up PR. --------- Co-authored-by: rv-jenkins <[email protected]>
1 parent 336e4e4 commit 26902b1

File tree

7 files changed

+67142
-67125
lines changed

7 files changed

+67142
-67125
lines changed

include/kllvm/ast/AST.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,7 @@ class kore_pattern : public std::enable_shared_from_this<kore_pattern> {
420420
SubsortMap const &subsorts, SymbolMap const &overloads,
421421
std::vector<ptr<kore_declaration>> const &axioms, bool reverse);
422422
virtual sptr<kore_pattern> unflatten_and_or() = 0;
423+
virtual sptr<kore_pattern> strip_injections() = 0;
423424

424425
/*
425426
* Recursively expands productions of the form:
@@ -506,6 +507,7 @@ class kore_variable_pattern : public kore_pattern {
506507
}
507508

508509
sptr<kore_pattern> unflatten_and_or() override { return shared_from_this(); }
510+
sptr<kore_pattern> strip_injections() override { return shared_from_this(); }
509511

510512
bool matches(
511513
substitution &subst, SubsortMap const &, SymbolMap const &,
@@ -585,6 +587,7 @@ class kore_composite_pattern : public kore_pattern {
585587
std::map<std::string, int> gather_var_counts() override;
586588
sptr<kore_pattern> desugar_associative() override;
587589
sptr<kore_pattern> unflatten_and_or() override;
590+
sptr<kore_pattern> strip_injections() override;
588591
sptr<kore_pattern> filter_substitution(
589592
pretty_print_data const &data,
590593
std::set<std::string> const &vars) override;
@@ -648,6 +651,7 @@ class kore_string_pattern : public kore_pattern {
648651
}
649652

650653
sptr<kore_pattern> unflatten_and_or() override { return shared_from_this(); }
654+
sptr<kore_pattern> strip_injections() override { return shared_from_this(); }
651655

652656
sptr<kore_pattern> filter_substitution(
653657
pretty_print_data const &data,

lib/ast/AST.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1122,6 +1122,19 @@ sptr<kore_pattern> kore_composite_pattern::unflatten_and_or() {
11221122
return result;
11231123
}
11241124

1125+
sptr<kore_pattern> kore_composite_pattern::strip_injections() {
1126+
if (constructor_->get_name() == "inj" && arguments_.size() == 1) {
1127+
return arguments_[0]->strip_injections();
1128+
}
1129+
auto result = kore_composite_pattern::create(constructor_.get());
1130+
1131+
for (auto &arg : arguments_) {
1132+
result->add_argument(arg->strip_injections());
1133+
}
1134+
1135+
return result;
1136+
}
1137+
11251138
sptr<kore_pattern> kore_composite_pattern::expand_macros(
11261139
SubsortMap const &subsorts, SymbolMap const &overloads,
11271140
std::vector<ptr<kore_declaration>> const &macros, bool reverse,

lib/binary/ProofTraceParser.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ void llvm_rewrite_event::print_substitution(
3535
for (auto const &p : substitution_) {
3636
if (expand_terms) {
3737
out << fmt::format("{}{} = kore[", indent, p.first);
38-
p.second.first->print(out);
38+
p.second.first->strip_injections()->print(out);
3939
out << fmt::format("]\n");
4040
} else {
4141
out << fmt::format("{}{} = kore[{}]\n", indent, p.first, p.second.second);
@@ -87,7 +87,7 @@ void llvm_hook_event::print(
8787
}
8888
if (expand_terms) {
8989
out << fmt::format("{}hook result: kore[", indent);
90-
kore_pattern_->print(out);
90+
kore_pattern_->strip_injections()->print(out);
9191
out << fmt::format("]\n");
9292
} else {
9393
out << fmt::format("{}hook result: kore[{}]\n", indent, pattern_length_);
@@ -102,7 +102,7 @@ void llvm_event::print(
102102
std::string indent(ind * indent_size, ' ');
103103
if (expand_terms) {
104104
out << fmt::format("{}{}: kore[", indent, is_arg ? "arg" : "config");
105-
kore_pattern_->print(out);
105+
kore_pattern_->strip_injections()->print(out);
106106
out << fmt::format("]\n");
107107
} else {
108108
out << fmt::format(

test/output/imp-sum-slow.proof.out.diff

Lines changed: 4612 additions & 4612 deletions
Large diffs are not rendered by default.

test/output/imp-sum.proof.out.diff

Lines changed: 3727 additions & 3727 deletions
Large diffs are not rendered by default.

test/output/imp.proof.out.diff

Lines changed: 48206 additions & 48206 deletions
Large diffs are not rendered by default.

test/output/kool-static.proof.out.diff

Lines changed: 10577 additions & 10577 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)