Skip to content

Commit

Permalink
Revert util#recursiveDeleteMapping to old (working) definition with m…
Browse files Browse the repository at this point in the history
…ore docs
  • Loading branch information
jputlock committed Dec 16, 2021
1 parent 4c03446 commit 63374fa
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
1 change: 1 addition & 0 deletions src/common/tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -840,6 +840,7 @@ export class TruthTreeNode {
// If there are still assignments left, then we did not instantiate every
// possible assignment of constants in this branch
if (Object.keys(uninstantiated).length !== 0) {
console.log(uninstantiated);
const mapping = getFirstUnassigned(uninstantiated);
leafError = new CorrectnessError(
'universal_domain_not_decomposed',
Expand Down
21 changes: 10 additions & 11 deletions src/common/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export interface EvaluationResponse {
* constant in the universe is a key which maps to an (N-1)-dimensional map.
* Effectively, if there are |U| elements in the universe, then the N-dimensional
* map will have |U|^N elements.
*
*
* @param num_dims N - the number of dimensions (variables)
* @param universe U - the set of constants
* @returns an N-dimensional map representing every N-tuple of the elements in the universe
Expand Down Expand Up @@ -65,26 +65,25 @@ function recursiveDeleteMapping(
const assignedValue = assignment[variable.toString()].toString();

// If this assignment is already satisfied, stop early
if (!Object.keys(map).includes(assignedValue)) {
return Object.keys(map).length;
if (!(assignedValue in map)) {
return;
}

// Recurse if we haven't gotten to the end
// Recurse to the last variable
if (variableIndex < variables.length - 1) {
const leftOver = recursiveDeleteMapping(
recursiveDeleteMapping(
map[assignedValue],
assignment,
variables,
variableIndex + 1
);

// We deleted the last element in this
if (leftOver === 0) {
delete map[assignedValue];
}
}

return Object.keys(map).length;
// If the submap is empty, we can delete it
// The last variable's submap will always be empty, so we always delete it
if (Object.keys(map[assignedValue]).length === 0) {
delete map[assignedValue];
}
}

/**
Expand Down

0 comments on commit 63374fa

Please sign in to comment.