-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Restructured the way reduction pairs work
- Loading branch information
Cynthia Kop
committed
Oct 3, 2024
1 parent
114d94d
commit 8035794
Showing
26 changed files
with
1,361 additions
and
1,758 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 0 additions & 68 deletions
68
app/src/main/java/cora/termination/dependency_pairs/processors/HorpoProcessor.java
This file was deleted.
Oops, something went wrong.
84 changes: 84 additions & 0 deletions
84
app/src/main/java/cora/termination/reduction_pairs/ArgumentFilter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/************************************************************************************************** | ||
Copyright 2024 Cynthia Kop | ||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except | ||
in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software distributed under the | ||
License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
express or implied. | ||
See the License for the specific language governing permissions and limitations under the License. | ||
*************************************************************************************************/ | ||
|
||
package cora.termination.reduction_pairs; | ||
|
||
import charlie.util.Pair; | ||
import charlie.terms.FunctionSymbol; | ||
import charlie.smt.BVar; | ||
import charlie.smt.SmtProblem; | ||
import charlie.smt.Valuation; | ||
|
||
import java.util.ArrayList; | ||
import java.util.TreeMap; | ||
import java.util.TreeSet; | ||
import java.util.function.BiFunction; | ||
|
||
/** | ||
* An instance of the Monotonicity class that represents an argument filtering: a function that | ||
* regards a specific set of arguments, as described by an SMT problem. | ||
*/ | ||
public class ArgumentFilter implements Monotonicity { | ||
private SmtProblem _problem; | ||
private TreeMap<FunctionSymbol,TreeMap<Integer,BVar>> _variables; | ||
|
||
/** | ||
* Creates an argument filtering that will use the given SMT problem to create its "regards" | ||
* variables. The problem will be stored in the ArgumentFiltering. | ||
*/ | ||
public ArgumentFilter(SmtProblem problem) { | ||
_problem = problem; | ||
_variables = new TreeMap<FunctionSymbol,TreeMap<Integer,BVar>>(); | ||
} | ||
|
||
/** @return false */ | ||
public boolean stronglyMonotonic() { | ||
return false; | ||
} | ||
|
||
/** This always returns the same BVar, which has been forced to evaluate to true. */ | ||
public BVar regards(FunctionSymbol f, int index) { | ||
if (!_variables.containsKey(f)) _variables.put(f, new TreeMap<Integer,BVar>()); | ||
TreeMap<Integer,BVar> fmap = _variables.get(f); | ||
if (fmap.containsKey(index)) return fmap.get(index); | ||
BVar newvar = _problem.createBooleanVariable("regards{" + f.queryName() + "," + index + "}"); | ||
fmap.put(index, newvar); | ||
return newvar; | ||
} | ||
|
||
/** | ||
* For the given valuation, returns a non-smt-dependent function to evaluate which arguments were | ||
* regarded. Note that this will only include function symbols and arguments that we have | ||
* actually been asked about. | ||
*/ | ||
public BiFunction<FunctionSymbol,Integer,Boolean> getRegardedArguments(Valuation valuation) { | ||
TreeMap<FunctionSymbol,TreeSet<Integer>> ret = new TreeMap<FunctionSymbol,TreeSet<Integer>>(); | ||
for (FunctionSymbol f : _variables.keySet()) { | ||
TreeMap<Integer,BVar> map = _variables.get(f); | ||
TreeSet<Integer> tmp = null; | ||
for (Integer i : map.keySet()) { | ||
BVar x = map.get(i); | ||
if (!valuation.queryAssignment(x)) continue; | ||
if (tmp == null) { | ||
tmp = new TreeSet<Integer>(); | ||
ret.put(f, tmp); | ||
} | ||
tmp.add(i); | ||
} | ||
} | ||
return (f, i) -> ret.containsKey(f) && ret.get(f).contains(i); | ||
} | ||
} | ||
|
187 changes: 0 additions & 187 deletions
187
app/src/main/java/cora/termination/reduction_pairs/Horpo.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.