Starting tracer
This commit is contained in:
@ -2,6 +2,7 @@ use std::fmt::Display;
|
||||
|
||||
use litemap::LiteMap;
|
||||
|
||||
use crate::ast::Body;
|
||||
use crate::ast::Predicate;
|
||||
use crate::ast::Variable;
|
||||
|
||||
@ -128,8 +129,7 @@ impl Predicate
|
||||
{
|
||||
if let Some(pred) = constraints.set.get(name)
|
||||
{
|
||||
let max_sub = pred.substitute(constraints);
|
||||
max_sub
|
||||
pred.substitute(constraints)
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -151,10 +151,23 @@ impl Predicate
|
||||
match self
|
||||
{
|
||||
Predicate::Variable(var_name) => name == var_name,
|
||||
Predicate::Fixed(_, predicates) => predicates
|
||||
.iter()
|
||||
.find(|x| x.contains_variable(name))
|
||||
.is_some(),
|
||||
Predicate::Fixed(_, predicates) => predicates.iter().any(|x| x.contains_variable(name)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Body
|
||||
{
|
||||
pub fn substitute(&self, constraints: &Constraints) -> Body
|
||||
{
|
||||
match self
|
||||
{
|
||||
Body::Term(predicate) => Body::Term(predicate.substitute(constraints)),
|
||||
Body::And(items) =>
|
||||
{
|
||||
Body::And(items.iter().map(|x| x.substitute(constraints)).collect())
|
||||
}
|
||||
Body::Or(items) => Body::Or(items.iter().map(|x| x.substitute(constraints)).collect()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
use std::fmt::Display;
|
||||
use std::{default, fmt::Display};
|
||||
|
||||
use log::info;
|
||||
|
||||
@ -25,9 +25,9 @@ impl Display for ProofType
|
||||
|
||||
pub trait Tracer
|
||||
{
|
||||
fn next_step(&mut self, proof_type: ProofType) -> Self;
|
||||
fn milestone<T: Display>(&self, str: T);
|
||||
fn explain<T: Display>(&self, str: T);
|
||||
fn begin_proof<T: Display>(&self, proof_type: ProofType) -> Self;
|
||||
fn print_step<T: Display>(&self, show: T);
|
||||
fn end_proof(self);
|
||||
}
|
||||
|
||||
pub struct SimpleTracer
|
||||
@ -35,21 +35,29 @@ pub struct SimpleTracer
|
||||
proof_type: ProofType,
|
||||
}
|
||||
|
||||
impl SimpleTracer
|
||||
{
|
||||
pub fn new(proof_type: ProofType) -> Self
|
||||
{
|
||||
Self { proof_type }
|
||||
}
|
||||
}
|
||||
|
||||
impl Tracer for SimpleTracer
|
||||
{
|
||||
fn next_step(&mut self, proof_type: ProofType) -> Self
|
||||
fn begin_proof<T: Display>(&self, proof_type: ProofType) -> Self
|
||||
{
|
||||
SimpleTracer { proof_type }
|
||||
}
|
||||
|
||||
fn explain<T: Display>(&self, str: T)
|
||||
fn print_step<T: Display>(&self, show: T)
|
||||
{
|
||||
let proof_str = format!("{}", self.proof_type);
|
||||
info!(target: &proof_str, "{}", str);
|
||||
let str = format!("{}", self.proof_type);
|
||||
info!(target: &str, "{}", show);
|
||||
}
|
||||
|
||||
fn milestone<T: Display>(&self, str: T)
|
||||
fn end_proof(self)
|
||||
{
|
||||
self.explain(str);
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,3 @@
|
||||
use std::process::Output;
|
||||
|
||||
use log::debug;
|
||||
|
||||
use crate::ast::Predicate;
|
||||
@ -17,7 +15,7 @@ impl Predicate
|
||||
{
|
||||
Predicate::Variable(variable) =>
|
||||
{
|
||||
debug!("Unifying var {} against {}", self, other);
|
||||
//debug!("Unifying var {} against {}", self, other);
|
||||
// We are trying to see if X (any) matches the other Predicate.
|
||||
// This is always true if X = other_predicate
|
||||
Some(Constraints::with(variable.clone(), other.clone()))
|
||||
@ -32,7 +30,7 @@ impl Predicate
|
||||
// We are trying to see if something like "predicate(..., ...)" matches X
|
||||
// (any)
|
||||
// This is always true
|
||||
debug!("Unifying pred {} against var {}", self, other);
|
||||
//debug!("Unifying pred {} against var {}", self, other);
|
||||
Some(Constraints::with(var.clone(), self.clone()))
|
||||
}
|
||||
// Match pred(X, Y, Z, ...) with pred(_X, _Y, _Z, ...)
|
||||
@ -40,7 +38,7 @@ impl Predicate
|
||||
if other_name == name && other_arguments.len() == arguments.len() =>
|
||||
{
|
||||
// If there is no arguments, no constraints
|
||||
debug!("Unifying fixed {} against fixed {}", self, other);
|
||||
//debug!("Unifying fixed {} against fixed {}", self, other);
|
||||
if arguments.is_empty()
|
||||
{
|
||||
return Some(Constraints::none());
|
||||
|
||||
Reference in New Issue
Block a user