use std::convert::TryFrom;
use tnt::formula::Formula;
use tnt::logic_errors::LogicError;
fn main() -> Result<(), LogicError> {
println!("This example shows how decision problems can be presented as Formulas of TNT with free variables.");
println!("To start with it is well known that \"a is even if and only if it is a multiple of two\". We can write this in TNT as follows.");
let is_even = Formula::try_from("Eb:(b*SS0)=a")?;
println!(
"\n{}\nwhich translates to\n{}\n",
is_even,
is_even.to_english()
);
println!("Likewise to represent the idea that a is divisible by b we can use the following.");
let is_factor = Formula::try_from("Ec:(b*c)=a")?;
println!(
"\n{}\nwhich translates to\n{}\n",
is_factor,
is_factor.to_english()
);
println!("We can slightly adapt this to represent primality.");
let is_prime = Formula::try_from("Ab:Ac:[(SSb*c)=a>c=S0]")?;
println!(
"\n{}\nwhich translates to\n{}\n",
is_prime,
is_prime.to_english()
);
Ok(())
}