Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trace generation #330

Merged
merged 100 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
100 commits
Select commit Hold shift + click to select a range
5e7b522
Added basic dfs trace generator; not tested yet
AdamZsofi Jun 13, 2022
24e9ef6
tracgen half-done, but ran into some issues; refactor next
AdamZsofi Jun 14, 2022
b1c120d
no propert concretizer in progress
AdamZsofi Jun 15, 2022
a709678
Writing generated traces into files
AdamZsofi Jun 16, 2022
585c62a
minor changes
AdamZsofi Jun 20, 2022
0ad3ac9
Generating maximal traces from xsts
AdamZsofi Jun 23, 2022
c9bccbf
Deleted some commented code
AdamZsofi Jul 2, 2022
9d103eb
Fixed xsts based bug generating extra traces
AdamZsofi Jul 11, 2022
130fcdf
Added temporary ARG to file to cegarchecker
AdamZsofi Aug 12, 2022
cd6504c
Started adding advanced arg trace for trace generation
AdamZsofi Sep 13, 2022
4a4018c
iterative trace lengthening works on small example
AdamZsofi Sep 18, 2022
5df7980
Added get full traces as an option
AdamZsofi Sep 20, 2022
9ed5b22
Cleaning up tracegen code
AdamZsofi Sep 27, 2022
0675afb
Refactored full trace generation
AdamZsofi Sep 28, 2022
af92d1c
Adding configurable initial precision
AdamZsofi Sep 28, 2022
fc2b102
Added some trace gen options
AdamZsofi Oct 2, 2022
8b6db64
Shortened tracegen algorithm code
AdamZsofi Oct 3, 2022
5225be8
Fixed accidentally changed code
AdamZsofi Oct 3, 2022
d8d0731
Patched tracegen feasibility check
AdamZsofi Oct 8, 2022
4a9ac61
Patched xsts specific superfluous node removal
AdamZsofi Oct 8, 2022
3c40481
Patch superfluous node filtering
AdamZsofi Oct 10, 2022
b263b0f
minor fix
AdamZsofi Oct 10, 2022
f3f79a6
Fixed typo in shortened trace containment check
AdamZsofi Oct 10, 2022
750291e
Added heuristics for incomplete abstract state coverages
AdamZsofi Oct 17, 2022
b553dd6
added correct check inbetween abstract states
AdamZsofi Oct 17, 2022
7a959fd
Fixed typo
AdamZsofi Nov 13, 2022
8e97f22
Added insecure delete to google recursive delete for windows
AdamZsofi Nov 13, 2022
008e6a5
Added basic dfs trace generator; not tested yet
AdamZsofi Jun 13, 2022
7215db1
tracgen half-done, but ran into some issues; refactor next
AdamZsofi Jun 14, 2022
1f92802
no propert concretizer in progress
AdamZsofi Jun 15, 2022
8d17fdd
Writing generated traces into files
AdamZsofi Jun 16, 2022
f6fc8b4
minor changes
AdamZsofi Jun 20, 2022
9935a31
Generating maximal traces from xsts
AdamZsofi Jun 23, 2022
fcee7dd
Deleted some commented code
AdamZsofi Jul 2, 2022
5850399
Fixed xsts based bug generating extra traces
AdamZsofi Jul 11, 2022
5ac18f0
Added temporary ARG to file to cegarchecker
AdamZsofi Aug 12, 2022
3ac8c77
Started adding advanced arg trace for trace generation
AdamZsofi Sep 13, 2022
1bb9e4c
iterative trace lengthening works on small example
AdamZsofi Sep 18, 2022
ba7367e
Added get full traces as an option
AdamZsofi Sep 20, 2022
ee5100d
Cleaning up tracegen code
AdamZsofi Sep 27, 2022
037ff53
Refactored full trace generation
AdamZsofi Sep 28, 2022
e96a338
Adding configurable initial precision
AdamZsofi Sep 28, 2022
2754697
Added some trace gen options
AdamZsofi Oct 2, 2022
bcf53fd
Shortened tracegen algorithm code
AdamZsofi Oct 3, 2022
1b2555b
Fixed accidentally changed code
AdamZsofi Oct 3, 2022
9ac420e
Patched tracegen feasibility check
AdamZsofi Oct 8, 2022
a0a3443
Patched xsts specific superfluous node removal
AdamZsofi Oct 8, 2022
849cba0
Patch superfluous node filtering
AdamZsofi Oct 10, 2022
8d9f68d
minor fix
AdamZsofi Oct 10, 2022
ffc7432
Fixed typo in shortened trace containment check
AdamZsofi Oct 10, 2022
9816819
Added heuristics for incomplete abstract state coverages
AdamZsofi Oct 17, 2022
0f9af8d
added correct check inbetween abstract states
AdamZsofi Oct 17, 2022
319231d
Fixed typo
AdamZsofi Nov 13, 2022
7d1ce6b
Added insecure delete to google recursive delete for windows
AdamZsofi Nov 13, 2022
549d0ed
optimized imports after rebase
leventeBajczi Jun 22, 2023
3ec7f82
Merge branch 'trace-generation' of github.com:ftsrg/theta into trace-…
AdamZsofi Feb 11, 2024
70b4108
merged xcfa-refactor into tracegen
AdamZsofi Feb 11, 2024
b000dcf
Merge branch 'master' into trace-generation
AdamZsofi Feb 18, 2024
24720c7
added promela frontend project
AdamZsofi Feb 18, 2024
cdeecb6
promela grammar can parse models now
AdamZsofi Feb 19, 2024
611105f
solve merge conflict
AdamZsofi Feb 19, 2024
bcace2a
some promela boilerplate
AdamZsofi Feb 23, 2024
b6465e9
adding grammar and model classes to promela frontend
AdamZsofi Feb 23, 2024
8b525cf
commented out some of promela grammar
AdamZsofi Feb 26, 2024
253faaa
promela frontend update
AdamZsofi Apr 13, 2024
a8981c9
started refactoring trace generation
AdamZsofi Apr 16, 2024
1b9a31f
refactored and minimized tracegen
AdamZsofi Apr 17, 2024
ee9d26c
tracegen refactor wip
AdamZsofi Apr 22, 2024
2b0587d
Merge branch 'master' into trace-generation
AdamZsofi Apr 29, 2024
af7ce82
adding predicates to tracegen
AdamZsofi May 3, 2024
e7537c6
readded full traces option and started developing trace metadata
AdamZsofi Jul 14, 2024
67286f1
merge master into tracegen
AdamZsofi Aug 19, 2024
41f6809
cleaning up before trace metadata
AdamZsofi Aug 29, 2024
37089d3
added v0 trace metadata, wip refactor tracegen checker
AdamZsofi Sep 19, 2024
9b8c51e
added basic trace metadata collection; tracegen refactored to clikt
AdamZsofi Sep 20, 2024
388a9cc
changing return value of trace generation
AdamZsofi Sep 21, 2024
e4adab5
refactor trace metadata to trace summary
AdamZsofi Sep 23, 2024
a49a7c8
basic trace summary and visualization added
AdamZsofi Sep 23, 2024
23301f7
trace generation checker is now a Checker
AdamZsofi Sep 29, 2024
b7df932
summary concretization and least/most over approx arg node wip
AdamZsofi Oct 7, 2024
077c7bf
working on summary concretization
AdamZsofi Oct 13, 2024
22d2896
added feasible concretization and concrete summary
AdamZsofi Oct 14, 2024
a581e5f
clean up some templates
AdamZsofi Oct 14, 2024
50672da
adding summary statuses
AdamZsofi Oct 16, 2024
ef4ee50
basic summary concretization works
AdamZsofi Oct 19, 2024
7c13253
.cexs can exported, but todos for tracegen with abstraction still pre…
AdamZsofi Oct 21, 2024
aabe64e
wip tracegen to xcfa
AdamZsofi Oct 26, 2024
8cc79dc
Merge branch 'master' into trace-generation
AdamZsofi Oct 26, 2024
5520360
tracegen added to xcfa execute config
AdamZsofi Oct 27, 2024
e412918
xcfa-cli trace generation can be built, but not tested
AdamZsofi Oct 28, 2024
74d3be7
fix config node result type
AdamZsofi Nov 4, 2024
6c110d3
added some post tracegen log
AdamZsofi Nov 10, 2024
8f7a3b9
added trace concretizations to xcfa tracegen
AdamZsofi Nov 11, 2024
7e987e8
Merge branch 'master' into trace-generation
AdamZsofi Nov 11, 2024
21e7acf
reformatting after merge
AdamZsofi Nov 11, 2024
e3503f3
add _ in cexs node id
AdamZsofi Nov 13, 2024
506f776
added options to (not) get summary/trace set after tracegen for xsts
AdamZsofi Nov 23, 2024
000ebfb
added options to (not) get summary/trace set after tracegen for xsts
AdamZsofi Nov 23, 2024
ec1a632
fixed --traces and --summary in xsts cli
AdamZsofi Nov 25, 2024
a520e15
Merged, removed gen folder, formatted
leventeBajczi Dec 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,18 @@
*/
package hu.bme.mit.theta.analysis.algorithm.arg;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;

import hu.bme.mit.theta.analysis.Action;
import hu.bme.mit.theta.analysis.State;
import hu.bme.mit.theta.common.Utils;
import hu.bme.mit.theta.common.container.Containers;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Optional;
import java.util.stream.Stream;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;

public final class ArgNode<S extends State, A extends Action> {

final ARG<S, A> arg;
Expand All @@ -47,7 +46,12 @@ public final class ArgNode<S extends State, A extends Action> {

public boolean expanded; // Set by ArgBuilder

ArgNode(final ARG<S, A> arg, final S state, final int id, final int depth, final boolean target) {
ArgNode(
final ARG<S, A> arg,
final S state,
final int id,
final int depth,
final boolean target) {
this.arg = arg;
this.state = state;
this.id = id;
Expand All @@ -67,8 +71,8 @@ public int getId() {
}

/**
* Gets the depth of the node, which is 0 if the node has no parent, and
* depth(parent) + 1 otherwise.
* Gets the depth of the node, which is 0 if the node has no parent, and depth(parent) + 1
* otherwise.
*/
public int getDepth() {
return depth;
Expand All @@ -83,6 +87,10 @@ public void setState(final S state) {
this.state = state;
}

public boolean inPartialOrder(final ArgNode<S, A> node) {
return arg.getPartialOrd().isLeq(node.getState(), this.getState());
}

public boolean mayCover(final ArgNode<S, A> node) {
if (arg.getPartialOrd().isLeq(node.getState(), this.getState())) {
return ancestors().noneMatch(n -> n.equals(node) || n.isSubsumed());
Expand Down Expand Up @@ -162,77 +170,59 @@ public Stream<S> getSuccStates() {

////

/**
* Checks if the node is covered, i.e., there is a covering edge for the
* node.
*/
/** Checks if the node is covered, i.e., there is a covering edge for the node. */
public boolean isCovered() {
return coveringNode.isPresent();
}

/**
* Checks if the node is not a bottom state.
*/
/** Checks if the node is not a bottom state. */
public boolean isFeasible() {
return !state.isBottom();
}

/**
* Checks if the node is subsumed, i.e., the node is covered or not
* feasible.
*/
/** Checks if the node is subsumed, i.e., the node is covered or not feasible. */
public boolean isSubsumed() {
return isCovered() || !isFeasible();
}

/**
* Checks if the node is excluded, i.e., the node is subsumed or has an
* excluded parent.
*/
/** Checks if the node is excluded, i.e., the node is subsumed or has an excluded parent. */
public boolean isExcluded() {
return ancestors().anyMatch(ArgNode::isSubsumed);
}

/**
* Checks if the node is target, i.e., the target predicate holds (e.g., it
* is an error state).
* Checks if the node is target, i.e., the target predicate holds (e.g., it is an error state).
*/
public boolean isTarget() {
return target;
}

/**
* Checks if the node is expanded, i.e., all of its successors are present.
*/
/** Checks if the node is expanded, i.e., all of its successors are present. */
public boolean isExpanded() {
return expanded;
}

/**
* Checks if the node is leaf, i.e., it has no successors.
*/
/** Checks if the node is leaf, i.e., it has no successors. */
public boolean isLeaf() {
return outEdges.isEmpty();
}

/**
* Checks if the node is safe, i.e., not target or excluded.
*/
/** Checks if the node is safe, i.e., not target or excluded. */
public boolean isSafe() {
return !isTarget() || isExcluded();
}

/**
* Checks if the node is complete, i.e., expanded or excluded.
*/
/** Checks if the node is complete, i.e., expanded or excluded. */
public boolean isComplete() {
return isExpanded() || isExcluded();
}

////

public Stream<ArgNode<S, A>> properAncestors() {
return getParent().map(p -> Stream.concat(Stream.of(p), p.properAncestors())).orElse(Stream.empty());
return getParent()
.map(p -> Stream.concat(Stream.of(p), p.properAncestors()))
.orElse(Stream.empty());
}

public Stream<ArgNode<S, A>> ancestors() {
Expand Down Expand Up @@ -263,7 +253,8 @@ private Stream<ArgNode<S, A>> unexcludedDescendantsOfNode() {
if (this.isSubsumed()) {
return Stream.empty();
} else {
return Stream.concat(Stream.of(this), this.children().flatMap(ArgNode::unexcludedDescendantsOfNode));
return Stream.concat(
Stream.of(this), this.children().flatMap(ArgNode::unexcludedDescendantsOfNode));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ public SafetyResult<Pr, C> check(final P initPrec) {
WebDebuggerLogger wdl = WebDebuggerLogger.getInstance();
do {
++iteration;

logger.write(Level.MAINSTEP, "Iteration %d%n", iteration);
logger.write(Level.MAINSTEP, "| Checking abstraction...%n");
final long abstractorStartTime = stopwatch.elapsed(TimeUnit.MILLISECONDS);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
/*
* Copyright 2024 Budapest University of Technology and Economics
*
* 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 hu.bme.mit.theta.analysis.algorithm.tracegeneration;

import static com.google.common.base.Preconditions.checkNotNull;
import static java.util.stream.Collectors.toList;

import hu.bme.mit.theta.analysis.Action;
import hu.bme.mit.theta.analysis.State;
import hu.bme.mit.theta.analysis.Trace;
import hu.bme.mit.theta.analysis.algorithm.arg.ArgEdge;
import hu.bme.mit.theta.analysis.algorithm.arg.ArgNode;
import java.util.*;
import java.util.stream.Collectors;

class AdvancedArgTrace<S extends State, A extends Action> implements Iterable<ArgNode<S, A>> {
private static final int HASH_SEED = 7453;
private volatile int hashCode = 0;

private final List<ArgNode<S, A>> nodes;
private final List<ArgEdge<S, A>> edges;
private final Collection<State> states;

private AdvancedArgTrace(final ArgNode<S, A> node) {
// adding items to first index will lead to O(N^2) performance
final List<ArgNode<S, A>> nodeList = new ArrayList<>();
final List<ArgEdge<S, A>> edgeList = new ArrayList<>();

ArgNode<S, A> running = node;
nodeList.add(running);

while (running.getInEdge().isPresent()) {
final ArgEdge<S, A> inEdge = running.getInEdge().get();
running = inEdge.getSource();
edgeList.add(inEdge);
nodeList.add(running);
}

// create the correct order by reversing O(N)
Collections.reverse(nodeList);
Collections.reverse(edgeList);

this.nodes = Collections.unmodifiableList(nodeList);
this.edges = Collections.unmodifiableList(edgeList);
states = nodes.stream().map(ArgNode::getState).collect(Collectors.toList());
}

private AdvancedArgTrace(List<ArgNode<S, A>> nodeList, List<ArgEdge<S, A>> edgeList) {
this.nodes = Collections.unmodifiableList(nodeList);
this.edges = Collections.unmodifiableList(edgeList);
states = nodes.stream().map(ArgNode::getState).collect(Collectors.toList());
}

////

public static <S extends State, A extends Action> AdvancedArgTrace<S, A> to(
final ArgNode<S, A> node) {
checkNotNull(node);
return new AdvancedArgTrace<>(node);
}

public static <S extends State, A extends Action> AdvancedArgTrace<S, A> fromTo(
final ArgNode<S, A> fromNode, final ArgNode<S, A> toNode) {
checkNotNull(fromNode);
checkNotNull(toNode);
AdvancedArgTrace<S, A> differenceTrace = new AdvancedArgTrace<>(fromNode);
AdvancedArgTrace<S, A> fullTrace = new AdvancedArgTrace<>(toNode);
return substituteTrace(fullTrace, differenceTrace);
}

/**
* Substitutes the differenceTrace from the fullTrace, where the differenceTrace should be the
* beginning of the full trace
*/
private static <A extends Action, S extends State> AdvancedArgTrace<S, A> substituteTrace(
AdvancedArgTrace<S, A> fullTrace, AdvancedArgTrace<S, A> differenceTrace) {
List<ArgNode<S, A>> differenceNodes = differenceTrace.nodes;

List<ArgNode<S, A>> remainingNodes = new ArrayList<>(fullTrace.nodes);
remainingNodes.removeIf(
saArgNode ->
!(saArgNode.equals(differenceNodes.get(differenceNodes.size() - 1)))
&& differenceNodes.contains(saArgNode));

List<ArgEdge<S, A>> remainingEdges = new ArrayList<>(fullTrace.edges);
remainingEdges.removeIf(differenceTrace.edges::contains);

return new AdvancedArgTrace<>(remainingNodes, remainingEdges);
}

////

/** Gets the length of the trace, i.e., the number of edges. */
public int length() {
return edges.size();
}

public ArgNode<S, A> node(final int index) {
return nodes.get(index);
}

public ArgEdge<S, A> edge(final int index) {
return edges.get(index);
}

public List<ArgNode<S, A>> nodes() {
return nodes;
}

public List<ArgEdge<S, A>> edges() {
return edges;
}

////

/**
* Converts the ArgTrace to a Trace by extracting states and actions from nodes and edges
* respectively.
*/
public Trace<S, A> toTrace() {
final List<S> states = nodes.stream().map(ArgNode::getState).collect(toList());
final List<A> actions = edges.stream().map(ArgEdge::getAction).collect(toList());
return Trace.of(states, actions);
}

////

@Override
public Iterator<ArgNode<S, A>> iterator() {
return nodes.iterator();
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
AdvancedArgTrace<?, ?> argTrace = (AdvancedArgTrace<?, ?>) o;
return states.equals(argTrace.states); // && edges.equals(argTrace.edges);
}

@Override
public int hashCode() {
int result = hashCode;
if (result == 0) {
result = HASH_SEED;
result = 31 * result + states.hashCode();
result = 31 * result + edges.hashCode();
hashCode = result;
}
return result;
// return Objects.hash(states, edges);
}
}
Loading
Loading