| use hyperkitty_core::Glyph; |
|
|
| |
| |
| |
| pub const Q: [[usize; 6]; 6] = [ |
| [2, 2, 3, 3, 2, 2], |
| [2, 3, 3, 3, 2, 3], |
| [3, 3, 3, 3, 2, 3], |
| [3, 3, 3, 3, 3, 3], |
| [0, 1, 2, 3, 4, 5], |
| [2, 3, 3, 3, 2, 3], |
| ]; |
|
|
| pub fn next_glyph(curr: Glyph, prev: Glyph) -> Glyph { |
| let c = curr.index(); let p = prev.index(); |
| Glyph::by_index(Q[c][p]).unwrap() |
| } |
|
|
| pub fn is_absorber(g: Glyph) -> bool { matches!(g, Glyph::Omega) } |
| pub fn is_identity(g: Glyph) -> bool { matches!(g, Glyph::Lambda) } |
|
|
| pub fn validate_identity_row() -> bool { |
| let l = Glyph::Lambda.index(); |
| (0..6).all(|j| Q[l][j] == j) |
| } |
|
|
| pub fn validate_absorber_row() -> bool { |
| let o = Glyph::Omega.index(); |
| (0..6).all(|j| Q[o][j] == o) |
| } |
|
|
| pub fn evolve_witness(w: &[Glyph]) -> Vec<Glyph> { |
| if w.len() != 3 { return vec![]; } |
| vec![next_glyph(w[0],w[1]), next_glyph(w[1],w[2]), next_glyph(w[2],w[0])] |
| } |
|
|
| pub fn canonical_witness() -> Vec<Glyph> { |
| vec![Glyph::Pi, Glyph::Gamma, Glyph::Delta] |
| } |
|
|
| pub fn validate_canonical_exhaustion() -> bool { |
| let w0 = canonical_witness(); |
| let w1 = evolve_witness(&w0); |
| let w2 = evolve_witness(&w1); |
| w2.iter().all(|&g| is_absorber(g)) |
| } |
|
|