Skip to content
Draft
Show file tree
Hide file tree
Changes from 57 commits
Commits
Show all changes
86 commits
Select commit Hold shift + click to select a range
ef65b0f
commiting before adding some code to rule.rs
xR0xEr Aug 25, 2024
c268d0c
all checks written down + first implementations of some checks
xR0xEr Sep 16, 2024
8b0bc54
some refactoring
xR0xEr Sep 16, 2024
ea509cc
update commit: further refactoring and some implementing for guarded …
xR0xEr Sep 17, 2024
79a5051
fully implemented function for getting positions of variable in a rule
xR0xEr Oct 14, 2024
2769d47
Merge branch 'main' into feature/static_checks
xR0xEr Oct 17, 2024
c88f8b7
fully integrated main branch into my new created files
xR0xEr Oct 18, 2024
e8dfe9c
some refactoring and implementation of initial_affected_positions()
xR0xEr Oct 18, 2024
445a003
update commit and some refactoring
xR0xEr Oct 20, 2024
5b3dd1f
update commit
xR0xEr Oct 24, 2024
b59a0ce
update commit: some refactoring and some implemantation
xR0xEr Oct 24, 2024
5510060
Rewrite Positions subtract method
monsterkrampe Oct 25, 2024
29f6a67
outsourced struct Positions in an own file
xR0xEr Oct 25, 2024
063ce25
outsourced struct RuleSet into an own file, and some major (hopefully…
xR0xEr Oct 25, 2024
ef0dc67
update commit
xR0xEr Oct 28, 2024
61c3802
implemented concluding function to calculate the affected positions
xR0xEr Oct 28, 2024
ed59dda
implemented marking check
xR0xEr Nov 1, 2024
45f6224
implemented jointly guarded checks
xR0xEr Nov 8, 2024
9fb4af2
added shy check
xR0xEr Nov 8, 2024
ecae4a0
update commit
xR0xEr Nov 8, 2024
73370eb
started implementing DependencyGraph for more checks
xR0xEr Nov 11, 2024
ddb1b5e
update commit for creating new branch positions_using_ref
xR0xEr Nov 13, 2024
ea5e28f
added Ord implementation for Tag, so I can use Position as Node for G…
xR0xEr Nov 13, 2024
7fe9dbe
fixed every error so far but it can be optimized
xR0xEr Nov 14, 2024
95f6f4a
new error
xR0xEr Nov 18, 2024
253851b
difference now takes a ref
xR0xEr Nov 19, 2024
5897665
update commit
xR0xEr Nov 20, 2024
b866160
update commit
xR0xEr Nov 20, 2024
b2483d6
some refactoring
xR0xEr Nov 21, 2024
8e811ce
finished implementation of acyclicity graphs
xR0xEr Nov 29, 2024
26e1554
Merge branch 'main' into feature/static_checks for updating reasons
xR0xEr Nov 29, 2024
b132bb4
some refactoring
xR0xEr Nov 29, 2024
8755ad1
some major refactoring and implementation of cycletrait
xR0xEr Dec 2, 2024
6c8c132
some major refactoring and implementation of cycletrait
xR0xEr Dec 2, 2024
da4b60f
resolved merge conflicts
xR0xEr Dec 2, 2024
d8bd6af
implemented acyclicity checks
xR0xEr Dec 6, 2024
927d52f
some refactoring
xR0xEr Dec 9, 2024
0be4cbd
implemented glut guarded checks
xR0xEr Dec 11, 2024
faa0664
all position structs are now type aliases to collections
xR0xEr Dec 16, 2024
33552e2
RuleSet is now a type alias to Vec<Rule>
xR0xEr Dec 17, 2024
4954755
update commit
xR0xEr Dec 18, 2024
5e6b613
RuleSet as type and major refactoring
xR0xEr Dec 24, 2024
de70506
refactored whole ruleset, encapsulated every used method in a trait
xR0xEr Dec 28, 2024
bdf182e
deleted types AffectedPositions, AttackedPositions, MarkedPositions b…
xR0xEr Jan 6, 2025
6f007d5
start of implementation for weakly_sticky check
xR0xEr Jan 6, 2025
50e57a2
refactoring how lukas wanted
xR0xEr Jan 7, 2025
304a01e
refactor how lukas wanted it
xR0xEr Jan 8, 2025
85af7d2
some easy refactoring
xR0xEr Jan 14, 2025
7c8f271
init commit
xR0xEr Jan 15, 2025
be989b3
Merge branch 'main' into feature/static_checks
xR0xEr Jan 17, 2025
49eb764
Merge branch 'feature/static_checks' into test/static_checks
xR0xEr Jan 17, 2025
5c60835
reimplemented infinite_rank_positions because I somehow deleted it :(
xR0xEr Jan 17, 2025
0bdcfdd
Merge branch 'feature/static_checks' into test/static_checks
xR0xEr Jan 17, 2025
219fae9
implemented TestCase struct for static checks and implemented datalog…
xR0xEr Jan 23, 2025
8def53a
added some tests
xR0xEr Jan 24, 2025
81da690
commiting before i try something
xR0xEr Jan 27, 2025
6a69f0d
made all tests work
xR0xEr Jan 30, 2025
3246860
Remove unnecessary acyclicity_graph_constructor
monsterkrampe Feb 3, 2025
b1b64f9
Refactor acyclicity_graphs.rs
monsterkrampe Feb 3, 2025
93e10ab
Revert "Refactor acyclicity_graphs.rs" to implement the Builder-Patte…
xR0xEr Mar 6, 2025
682f6ae
refactored acyclicity_graphs.rs, so the graphs are now Wrapper-Struct…
xR0xEr Mar 6, 2025
abae590
Refactor rule_set.rs: First elimination of some types and traits
xR0xEr Mar 7, 2025
29f945d
Refactor ruleset.rs: ended trait elimination
xR0xEr Mar 9, 2025
e15022a
Refactor: positions.rs: elimination of verbose traits and refactoring…
xR0xEr Mar 10, 2025
9507583
removed macOS specific .DS_Store
xR0xEr Mar 10, 2025
cd399b9
added type RuleAndVariable and refactored with it
xR0xEr Mar 10, 2025
5d0e89a
major refactoring in the building of both graphs. Reduced and Optimis…
xR0xEr Mar 11, 2025
a0f6dea
implemented method positive_variables_iter() for rule
xR0xEr Mar 11, 2025
13d7d5f
renamed methods that return a boolean value to begin with a verb
xR0xEr Mar 13, 2025
88597a4
Renamed traits that are involved in the development of the affected /…
xR0xEr Mar 13, 2025
f9ea8ca
Removed the traits: AllPositivePositions, ExistentialVariables, Exist…
xR0xEr Mar 13, 2025
5ba8e16
Expected parsing and translation results in the implementation of the…
xR0xEr Mar 13, 2025
fe9c62b
update commit, so I can fix something on linux
xR0xEr Mar 29, 2025
9eeccde
created an own crate for static-checks
xR0xEr Mar 30, 2025
258b08f
Merge branch 'main' into feature/static_checks
xR0xEr Jun 12, 2025
55e63f4
fixed some error from merge
xR0xEr Jun 12, 2025
9cd87f6
resolved merge conflicts
xR0xEr Jul 3, 2025
e97864e
resolved some errors
xR0xEr Jul 3, 2025
2d45bd8
implemented msa transformation
xR0xEr Jul 8, 2025
e3d6a7a
finished msa check
xR0xEr Jul 9, 2025
6e4aac1
first commit of file properties refactor
xR0xEr Dec 3, 2025
18e5182
resolved merge conflicts
xR0xEr Dec 3, 2025
c7af2e9
merged main into this branch
xR0xEr Dec 3, 2025
b854b4b
merge branch main + feature/static_checks into refactor/static_checks
xR0xEr Dec 3, 2025
8ba2964
first implementation of cli for nemo-static-checks
xR0xEr Jan 8, 2026
4e6ec94
implemented CliApp for nemo-static-checks; rewrote tests so CliApp is…
xR0xEr Jan 15, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions nemo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ bytecount = "0.6.8"
colored = "2"

[dev-dependencies]
assert_cmd = "2.0"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see why we would need assert_cmd.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will be removed. I overlooked it somehow.

dir-test = "0.2.1"
env_logger = "*"
assert_fs = "1.0"
test-log = "0.2"
Expand Down
2 changes: 2 additions & 0 deletions nemo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ pub mod execution;
pub mod rule_model;
pub mod util;

pub mod static_checks;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At some point, we should rename this as static_check is a bit too generic. Maybe something like ruleset_classification could work but I'm not quite sold on that either.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right now, this module is implemented on data types of the rule_model module. Maybe rule_model_classification would be a good name? Also since it is based on the rule_model module, wouldn't it be better to make it a submodule of rule_model?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I would keep it separate. Maybe even have it in its own crate. These static analysis are useful but not required for anything happening in the Nemo Core so I rather see it as something that we put "on top". But this should be discussed in a bigger group. Some of the checks could potentially be used to influence the reasoning strategies...


pub mod chase_model; // TODO: Make private
pub(crate) mod table_manager;

Expand Down
4 changes: 4 additions & 0 deletions nemo/src/rule_model/components/atom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ impl Atom {
self.predicate.clone()
}

pub fn predicate_ref(&self) -> &Tag {
&self.predicate
}

/// Return an iterator over the arguments of this atom.
pub fn arguments(&self) -> impl Iterator<Item = &Term> {
self.terms.iter()
Expand Down
18 changes: 18 additions & 0 deletions nemo/src/rule_model/components/rule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,24 @@ impl Rule {
result
}

pub fn positive_variables_as_vec(&self) -> Vec<&Variable> {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to return an iterator instead of a vector here?
Probably the above method returning a HashSet could then also be implemented based on the method returning the iterator.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it would make sense. I used it to get the join variables of a rule. Since same elements in a set is not possible, the other method was not sufficient. Maybe this can be added to the IterableVariables-Trait?

let mut result = Vec::new();

for literal in &self.body {
if let Literal::Positive(atom) = literal {
for term in atom.arguments() {
if let Term::Primitive(Primitive::Variable(variable)) = term {
if variable.is_universal() && variable.name().is_some() {
result.push(variable);
}
}
}
}
}

result
}

/// Return a set of "safe" variables.
///
/// A variable is considered safe,
Expand Down
10 changes: 8 additions & 2 deletions nemo/src/rule_model/components/tag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::{fmt::Display, hash::Hash};
use crate::rule_model::origin::Origin;

/// Name of a term or predicate
#[derive(Debug, Clone, Eq)]
#[derive(Clone, Debug, Eq)]
pub struct Tag {
/// Origin of this component.
origin: Origin,
Expand Down Expand Up @@ -53,6 +53,12 @@ impl Display for Tag {
}
}

impl Ord for Tag {
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
self.tag.cmp(&other.tag)
}
}

impl PartialEq for Tag {
fn eq(&self, other: &Self) -> bool {
self.tag == other.tag
Expand All @@ -61,7 +67,7 @@ impl PartialEq for Tag {

impl PartialOrd for Tag {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
self.tag.partial_cmp(&other.tag)
Some(self.tag.cmp(&other.tag))
}
}

Expand Down
2 changes: 1 addition & 1 deletion nemo/src/rule_model/components/term/primitive/variable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ impl Display for VariableName {
///
/// A general placeholder that can be bound to any value.
/// We distinguish [UniversalVariable] and [ExistentialVariable].
#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd)]
#[derive(Debug, Clone, PartialEq, Eq, Hash, Ord, PartialOrd)]
pub enum Variable {
/// Universal variable
Universal(UniversalVariable),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,13 @@ impl PartialEq for ExistentialVariable {

impl PartialOrd for ExistentialVariable {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
self.name.partial_cmp(&other.name)
Some(self.cmp(other))
}
}

impl Ord for ExistentialVariable {
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
self.name.cmp(&other.name)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,13 @@ impl PartialEq for UniversalVariable {

impl PartialOrd for UniversalVariable {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
self.name.partial_cmp(&other.name)
Some(self.cmp(other))
}
}

impl Ord for UniversalVariable {
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
self.name.cmp(&other.name)
}
}

Expand Down
2 changes: 1 addition & 1 deletion nemo/src/rule_model/origin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::hash::Hash;
pub(crate) type ExternalReference = usize;

/// Origin of a program component
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash, Ord, PartialOrd)]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it really required that this is Ord and PartialOrd? I think the structs having Origin as one of their field have a custom implementation of Ord and PartialOrd anyway that does not involve comparing the origin at all.

pub enum Origin {
/// Component was created via a constructor
Created,
Expand Down
8 changes: 8 additions & 0 deletions nemo/src/static_checks.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//! Functionality to give static checks for a RuleSet.
pub mod acyclicity_graph_constructor;
pub mod acyclicity_graphs;
pub mod collection_traits;
pub mod positions;
pub mod rule_properties;
pub mod rule_set;
pub mod rules_properties;
25 changes: 25 additions & 0 deletions nemo/src/static_checks/acyclicity_graph_constructor.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//! Functionality that provides methods to build the (JointAcyclicityGraph / WeakAcyclicityGraph) of a
/// RuleSet.
use crate::static_checks::acyclicity_graphs::{
AcyclicityGraphBuilder, JointAcyclicityGraph, WeakAcyclicityGraph,
};
use crate::static_checks::rule_set::RuleSet;

/// This Trait provides methods of some RuleSet to build the (WeakAcyclicityGraph /
/// JointAcyclicityGraph).
pub trait AcyclicityGraphConstructor<'a> {
/// Builds the JointAcyclicityGraph.
fn joint_acyclicity_graph(&'a self) -> JointAcyclicityGraph<'a>;
/// Builds the WeakAcyclicityGraph.
fn weak_acyclicity_graph(&'a self) -> WeakAcyclicityGraph<'a>;
}

impl<'a> AcyclicityGraphConstructor<'a> for RuleSet {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If only implemented on a RuleSet, the name of the trait is misleading. Also, why have the trait at all if its implementation is just calling JointAcyclicityGraph::build_graph? We could replace calls of the method joint_acyclicity_graph simply by directly calling JointAcyclicityGraph::build_graph.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made this because build_graph method of JointAcyclicityGraph and WeakAcyclicityGraph looked pretty much the same. I hoped to refactor that into actually just one method but I couldn't do it myself. The idea was to give an input (in form of an enum) to decide whether the JointAcyclicityGraph or WeakAcyclicityGraph should be build.

fn joint_acyclicity_graph(&'a self) -> JointAcyclicityGraph<'a> {
JointAcyclicityGraph::build_graph(self)
}

fn weak_acyclicity_graph(&'a self) -> WeakAcyclicityGraph<'a> {
WeakAcyclicityGraph::build_graph(self)
}
}
Loading
Loading