RequirementMachine: Homotopy reduction tweaks

- Skip permanent rules (there's no point, we'll add them back next time)
- Skip conformance rules (these will be handled separately)
- Delete 3-cells that are entirely "in-context" (but don't quote me on
  this one, I'm not quite yet convinced it's correct, but it feels right)
This commit is contained in:
Slava Pestov
2021-09-25 00:26:09 -04:00
parent 2923a334f5
commit 5f3d781ed3
5 changed files with 197 additions and 99 deletions

View File

@@ -23,6 +23,12 @@
using namespace swift;
using namespace rewriting;
/// If this is a rule of the form T.[p] => T where [p] is a property symbol,
/// returns the symbol. Otherwise, returns None.
///
/// Note that this is meant to be used with a simplified rewrite system,
/// where the right hand sides of rules are canonical, since this also means
/// that T is canonical.
Optional<Symbol> Rule::isPropertyRule() const {
auto property = LHS.back();
@@ -38,6 +44,8 @@ Optional<Symbol> Rule::isPropertyRule() const {
return property;
}
/// If this is a rule of the form T.[p] => T where [p] is a protocol symbol,
/// return true, otherwise return false.
bool Rule::isProtocolConformanceRule() const {
if (auto property = isPropertyRule())
return property->getKind() == Symbol::Kind::Protocol;
@@ -418,8 +426,8 @@ void RewriteSystem::dump(llvm::raw_ostream &out) const {
out << "}\n";
out << "Homotopy generators: {\n";
for (const auto &loop : HomotopyGenerators) {
out << "- " << loop.Basepoint << ": ";
loop.Path.dump(out, loop.Basepoint, *this);
out << "- ";
loop.dump(out, *this);
out << "\n";
}
out << "}\n";