use open_hypergraphs::array::vec::*;
use open_hypergraphs::semifinite::*;
use open_hypergraphs::strict::open_hypergraph::*;
use core::ops::{Add, Mul};
use num_traits::{One, Zero};
use std::iter::{Product, Sum};
pub trait Semiring: Sized + Add + Zero + Sum + Mul + One + Product + Copy {}
impl Semiring for usize {}
#[derive(Clone, PartialEq, Eq, Debug)]
pub struct Obj;
#[derive(Clone, PartialEq, Eq, Debug)]
pub enum Arr {
Add,
Zero,
Mul,
One,
Copy,
Discard,
}
pub type Term = OpenHypergraph<VecKind, Obj, Arr>;
pub fn arr_type(a: &Arr) -> (usize, usize) {
use Arr::*;
match a {
Add => (2, 1),
Zero => (0, 1),
Mul => (2, 1),
One => (0, 1),
Copy => (1, 2),
Discard => (1, 0),
}
}
pub fn mktype(n: usize) -> SemifiniteFunction<VecKind, Obj> {
SemifiniteFunction(VecArray(vec![Obj; n]))
}
pub fn arr(op: Arr) -> Term {
let (a, b) = arr_type(&op);
OpenHypergraph::singleton(op, mktype(a), mktype(b))
}