Skip to content

Commit 5c1049e

Browse files
committed
Cleanup a bit
1 parent 1136268 commit 5c1049e

File tree

1 file changed

+8
-88
lines changed

1 file changed

+8
-88
lines changed

chalk-engine/src/logic.rs

Lines changed: 8 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -1310,44 +1310,17 @@ impl<C: Context> Forest<C> {
13101310
/// abstraction function to yield the canonical form that will be
13111311
/// used to pick a table. Typically, this abstraction has no
13121312
/// effect, and hence we are simply returning the canonical form
1313-
/// of `subgoal`, but if the subgoal is getting too big, we may
1314-
/// truncate the goal to ensure termination.
1315-
///
1316-
/// This technique is described in the SA paper.
1313+
/// of `subgoal`; but if the subgoal is getting too big, we return
1314+
/// `None`, which causes the subgoal to flounder.
13171315
fn abstract_positive_literal(
13181316
&mut self,
13191317
infer: &mut dyn InferenceTable<C>,
13201318
subgoal: &C::GoalInEnvironment,
13211319
) -> Option<(C::UCanonicalGoalInEnvironment, C::UniverseMap)> {
1322-
// Subgoal abstraction: Rather than looking up the table for
1323-
// `selected_goal` directly, first apply the truncation
1324-
// function. This may introduce fresh variables, making the
1325-
// goal that we are looking up more general, and forcing us to
1326-
// reuse an existing table. For example, if we had a selected
1327-
// goal of
1328-
//
1329-
// // Vec<Vec<Vec<Vec<i32>>>>: Sized
1330-
//
1331-
// we might now produce a truncated goal of
1332-
//
1333-
// // Vec<Vec<?T>>: Sized
1334-
//
1335-
// Obviously, the answer we are looking for -- if it exists -- will be
1336-
// found amongst the answers of this new, truncated goal.
1337-
//
1338-
// Subtle point: Note that the **selected goal** remains
1339-
// unchanged and will be carried over into the "pending
1340-
// clause" for the positive link on the new subgoal. This
1341-
// means that if our new, truncated subgoal produces
1342-
// irrelevant answers (e.g., `Vec<Vec<u32>>: Sized`), they
1343-
// will fail to unify with our selected goal, producing no
1344-
// resolvent.
1345-
1346-
if infer.truncate_goal(subgoal).is_some() {
1347-
return None;
1320+
match infer.truncate_goal(subgoal) {
1321+
Some(_) => None,
1322+
None => Some(infer.fully_canonicalize_goal(subgoal)),
13481323
}
1349-
1350-
return Some(infer.fully_canonicalize_goal(subgoal));
13511324
}
13521325

13531326
/// Given a selected negative subgoal, the subgoal is "inverted"
@@ -1401,63 +1374,10 @@ impl<C: Context> Forest<C> {
14011374
// affect completeness when it comes to subgoal abstraction.
14021375
let inverted_subgoal = infer.invert_goal(subgoal)?;
14031376

1404-
// DIVERGENCE
1405-
//
1406-
// If the negative subgoal has grown so large that we would have
1407-
// to truncate it, we currently just abort the computation
1408-
// entirely. This is not necessary -- the SA paper makes no
1409-
// such distinction, for example, and applies truncation equally
1410-
// for positive/negative literals. However, there are some complications
1411-
// that arise that I do not wish to deal with right now.
1412-
//
1413-
// Let's work through an example to show you what I
1414-
// mean. Imagine we have this (negative) selected literal;
1415-
// hence `selected_subgoal` will just be the inner part:
1416-
//
1417-
// // not { Vec<Vec<Vec<Vec<i32>>>>: Sized }
1418-
// // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1419-
// // `selected_goal`
1420-
//
1421-
// (In this case, the `inverted_subgoal` would be the same,
1422-
// since there are no free universal variables.)
1423-
//
1424-
// If truncation **doesn't apply**, we would go and lookup the
1425-
// table for the selected goal (`Vec<Vec<..>>: Sized`) and see
1426-
// whether it has any answers. If it does, and they are
1427-
// definite, then this negative literal is false. We don't
1428-
// really care even how many answers there are and so forth
1429-
// (if the goal is ground, as in this case, there can be at
1430-
// most one definite answer, but if there are universals, then
1431-
// the inverted goal would have variables; even so, a single
1432-
// definite answer suffices to show that the `not { .. }` goal
1433-
// is false).
1434-
//
1435-
// Truncation muddies the water, because the table may
1436-
// generate answers that are not relevant to our original,
1437-
// untruncated literal. Suppose that we truncate the selected
1438-
// goal to:
1439-
//
1440-
// // Vec<Vec<T>>: Sized
1441-
//
1442-
// Clearly this table will have some solutions that don't
1443-
// apply to us. e.g., `Vec<Vec<u32>>: Sized` is a solution to
1444-
// this table, but that doesn't imply that `not {
1445-
// Vec<Vec<Vec<..>>>: Sized }` is false.
1446-
//
1447-
// This can be made to work -- we carry along the original
1448-
// selected goal when we establish links between tables, and
1449-
// we could use that to screen the resulting answers. (There
1450-
// are some further complications around the fact that
1451-
// selected goal may contain universally quantified free
1452-
// variables that have been inverted, as discussed in the
1453-
// prior paragraph above.) I just didn't feel like dealing
1454-
// with it yet.
1455-
1456-
if infer.truncate_goal(&inverted_subgoal).is_some() {
1457-
return None;
1377+
match infer.truncate_goal(&inverted_subgoal) {
1378+
Some(_) => None,
1379+
None => Some(infer.fully_canonicalize_goal(&inverted_subgoal)),
14581380
}
1459-
1460-
return Some(infer.fully_canonicalize_goal(&inverted_subgoal));
14611381
}
14621382

14631383
/// Removes the subgoal at `subgoal_index` from the strand's

0 commit comments

Comments
 (0)