82 lines
1.5 KiB
Rust
82 lines
1.5 KiB
Rust
use std::{default, fmt::Display};
|
|
|
|
use log::info;
|
|
use owo_colors::{OwoColorize, colors::css::Gray};
|
|
|
|
use crate::ast::Variable;
|
|
|
|
#[derive(Clone, Copy)]
|
|
pub enum ProofType
|
|
{
|
|
Body,
|
|
And,
|
|
Predicate,
|
|
}
|
|
|
|
impl Display for ProofType
|
|
{
|
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result
|
|
{
|
|
match self
|
|
{
|
|
ProofType::Body => write!(f, "body_prover"),
|
|
ProofType::And => write!(f, "and_prover"),
|
|
ProofType::Predicate => write!(f, "predicate_prover"),
|
|
}
|
|
}
|
|
}
|
|
|
|
pub trait Tracer
|
|
{
|
|
fn begin_proof(&self, proof_type: ProofType) -> Self;
|
|
fn print_step<T: Display>(&self, show: T);
|
|
fn end_proof(self);
|
|
}
|
|
|
|
pub struct SimpleTracer
|
|
{
|
|
proof_type: ProofType,
|
|
}
|
|
|
|
impl SimpleTracer
|
|
{
|
|
pub fn new(proof_type: ProofType) -> Self
|
|
{
|
|
Self { proof_type }
|
|
}
|
|
}
|
|
|
|
impl Tracer for SimpleTracer
|
|
{
|
|
fn begin_proof(&self, proof_type: ProofType) -> Self
|
|
{
|
|
SimpleTracer { proof_type }
|
|
}
|
|
|
|
fn print_step<T: Display>(&self, show: T)
|
|
{
|
|
let str = format!("{}", self.proof_type);
|
|
info!(target: &str, "{}", show);
|
|
}
|
|
|
|
fn end_proof(self)
|
|
{
|
|
todo!()
|
|
}
|
|
}
|
|
|
|
pub fn colored_var(var: &Variable) -> String
|
|
{
|
|
let mut idx = None;
|
|
for (i, char) in var.chars().enumerate()
|
|
{
|
|
if char == '['
|
|
{
|
|
idx = Some(i);
|
|
}
|
|
}
|
|
let (var, unique) = var.split_at(idx.unwrap_or(var.len()));
|
|
let unique = unique.fg::<Gray>();
|
|
format!("{}{}", var, unique)
|
|
}
|