Download rust/crates/hyperkitty-art/src/lib.rs from Snapkitty/hyperkitty-constraint-dsl: direct link, hf CLI and curl.
- Browser
- Download file 2.28 kB
-
https://huggingface.co/Snapkitty/hyperkitty-constraint-dsl/resolve/main/rust/crates/hyperkitty-art/src/lib.rs
- Command line
-
hf download hf://Snapkitty/hyperkitty-constraint-dsl/rust/crates/hyperkitty-art/src/lib.rs
-
curl -L -o lib.rs https://huggingface.co/Snapkitty/hyperkitty-constraint-dsl/resolve/main/rust/crates/hyperkitty-art/src/lib.rs
2.28 kB
| //! HyperKitty Art Layer - Formal Proofs to Visual Artifacts | |
| //! | |
| //! Bridges: | |
| //! - Lean 4/Agda theorems β Visual AST | |
| //! - Visual AST β Scene Graph | |
| //! - Scene Graph β Multi-backend renderers (SVG, Canvas, WebGL, PNG, PDF, GIF, WebM) | |
| //! - All artifacts sealed via WORM cryptographic receipts | |
| pub mod theorem_ast; | |
| pub mod scene_graph; | |
| pub mod renderer; | |
| pub mod receipt; | |
| pub use theorem_ast::{TheoremAst, TheoremKind, ProofStep}; | |
| pub use scene_graph::{SceneGraph, Node, Transform, Color}; | |
| pub use renderer::{Renderer, RenderFormat}; | |
| pub use receipt::{ArtifactReceipt, receipt_from_artifact}; | |
| use sha2::{Sha256, Digest}; | |
| use std::io::Write; | |
| /// Complete pipeline: Theorem β Scene β Rendered β Receipt | |
| pub struct VisualizationPipeline { | |
| theorem: TheoremAst, | |
| scene: SceneGraph, | |
| rendered: Vec<u8>, | |
| receipt: ArtifactReceipt, | |
| } | |
| impl VisualizationPipeline { | |
| pub fn new(theorem: TheoremAst) -> Self { | |
| let scene = SceneGraph::from_theorem(&theorem); | |
| Self { | |
| theorem, | |
| scene, | |
| rendered: vec![], | |
| receipt: ArtifactReceipt::default(), | |
| } | |
| } | |
| pub fn render(&mut self, format: RenderFormat) -> Result<Vec<u8>, String> { | |
| let renderer = Renderer::new(format); | |
| self.rendered = renderer.render(&self.scene)?; | |
| // Seal with WORM receipt | |
| let mut hasher = Sha256::new(); | |
| hasher.write_all(&self.rendered).map_err(|e| e.to_string())?; | |
| let hash = hasher.finalize(); | |
| self.receipt = ArtifactReceipt { | |
| theorem_name: self.theorem.name.clone(), | |
| format: format, | |
| hash: format!("{:x}", hash), | |
| size: self.rendered.len(), | |
| }; | |
| Ok(self.rendered.clone()) | |
| } | |
| pub fn receipt(&self) -> &ArtifactReceipt { | |
| &self.receipt | |
| } | |
| pub fn scene(&self) -> &SceneGraph { | |
| &self.scene | |
| } | |
| } | |
| mod tests { | |
| use super::*; | |
| fn pipeline_creation() { | |
| let theorem = TheoremAst { | |
| name: "QLG Sphere".to_string(), | |
| kind: TheoremKind::QLGSphere, | |
| proof_steps: vec![], | |
| }; | |
| let pipeline = VisualizationPipeline::new(theorem); | |
| assert_eq!(pipeline.theorem.name, "QLG Sphere"); | |
| } | |
| } | |