qualia_core_db/modalities/logic/
infrastructure_shacl.rs1use crate::webizen::SlgOpcode;
9
10#[derive(Debug, Clone)]
14pub struct BiologicalDomainConfiguration {
15 pub max_sequence_length: u32, pub max_gene_count: u32, pub allowed_sequence_types: Vec<String>, pub require_quality_score: bool, }
20
21#[derive(Debug, Clone)]
23pub struct ChemicalDomainConfiguration {
24 pub max_molecular_weight: f64, pub max_atom_count: u32, pub allowed_element_types: Vec<String>, pub require_valence_validation: bool, }
29
30#[derive(Debug, Clone)]
32pub struct PhysicalDomainConfiguration {
33 pub max_temperature_kelvin: f64, pub max_pressure_pascal: f64, pub allowed_energy_units: Vec<String>, pub require_dimensional_consistency: bool, }
38
39#[derive(Debug, Clone)]
41pub struct FinancialDomainConfiguration {
42 pub max_transaction_value: f64, pub max_portfolio_size: f64, pub allowed_currencies: Vec<String>, pub require_compliance_check: bool, }
47
48#[derive(Debug, Clone)]
50pub struct MathematicalDomainConfiguration {
51 pub max_precision_bits: u8, pub allowed_number_types: Vec<String>, pub max_expression_depth: u8, pub require_well_formedness: bool, }
56
57#[derive(Debug, Clone)]
59pub struct GeospatialDomainConfiguration {
60 pub max_coordinate_precision: u8, pub allowed_coordinate_systems: Vec<String>, pub max_area_sq_km: f64, pub require_valid_geometry: bool, }
65
66#[derive(Debug, Clone)]
70pub struct ObfuscationConfiguration {
71 pub max_obfuscation_depth: u8, pub allowed_obfuscation_methods: Vec<String>, pub require_reversibility: bool, pub min_entropy_bits: u8, }
76
77#[derive(Debug, Clone)]
79pub struct PolynomialObfuscationConfiguration {
80 pub max_polynomial_degree: u8, pub allowed_coefficient_types: Vec<String>, pub require_irreducibility: bool, }
84
85#[derive(Debug, Clone)]
87pub struct SemanticStripperConfiguration {
88 pub max_context_depth: u8, pub allowed_context_types: Vec<String>, pub require_anonymity: bool, }
92
93#[derive(Debug, Clone)]
95pub struct DomainTransformerConfiguration {
96 pub allowed_target_domains: Vec<String>, pub max_transformation_chain_length: u8, pub require_preservation: bool, }
100
101#[derive(Debug, Clone)]
103pub struct HybridStateConfiguration {
104 pub max_state_size_bytes: u32, pub allowed_state_domains: Vec<String>, pub require_synchronization: bool, }
108
109#[derive(Debug, Clone)]
113pub struct SolverConfiguration {
114 pub max_iterations: u32, pub convergence_tolerance: f64, pub max_step_size: f64, pub min_step_size: f64, pub allowed_solver_types: Vec<String>, }
120
121#[derive(Debug, Clone)]
123pub struct CalculusSolverConfiguration {
124 pub max_ode_order: u8, pub allowed_integrators: Vec<String>, pub require_stability_check: bool, }
128
129#[derive(Debug, Clone)]
131pub struct LinearAlgebraSolverConfiguration {
132 pub max_matrix_dimension: u16, pub allowed_decompositions: Vec<String>, pub require_condition_number_check: bool, }
136
137#[derive(Debug, Clone)]
139pub struct OptimizationSolverConfiguration {
140 pub max_variables: u32, pub allowed_algorithms: Vec<String>, pub require_convexity_check: bool, }
144
145#[derive(Debug, Clone)]
147pub struct QuantumOptimizerConfiguration {
148 pub max_qubits: u16, pub allowed_algorithms: Vec<String>, pub require_error_correction: bool, }
152
153#[derive(Debug, Clone)]
155pub struct SymbolicLogicSolverConfiguration {
156 pub max_clause_count: u32, pub max_variable_count: u32, pub allowed_logic_types: Vec<String>, }
160
161#[derive(Debug, Clone)]
165pub struct GeometricAlgebraConfiguration {
166 pub max_dimension: u8, pub allowed_algebras: Vec<String>, pub require_normalization: bool, }
170
171impl BiologicalDomainConfiguration {
174 pub fn to_opcodes(&self) -> Vec<SlgOpcode> {
177 vec![
178 SlgOpcode::CheckMaxInclusive(self.max_sequence_length as f64),
179 SlgOpcode::CheckMaxInclusive(self.max_gene_count as f64),
180 ]
181 }
182}
183
184impl ChemicalDomainConfiguration {
185 pub fn to_opcodes(&self) -> Vec<SlgOpcode> {
188 vec![
189 SlgOpcode::CheckMaxInclusive(self.max_molecular_weight),
190 SlgOpcode::CheckMaxInclusive(self.max_atom_count as f64),
191 ]
192 }
193}
194
195impl PhysicalDomainConfiguration {
196 pub fn to_opcodes(&self) -> Vec<SlgOpcode> {
199 vec![
200 SlgOpcode::CheckMaxInclusive(self.max_temperature_kelvin),
201 SlgOpcode::CheckMaxInclusive(self.max_pressure_pascal),
202 ]
203 }
204}
205
206impl FinancialDomainConfiguration {
207 pub fn to_opcodes(&self) -> Vec<SlgOpcode> {
210 vec![
211 SlgOpcode::CheckMaxInclusive(self.max_transaction_value),
212 SlgOpcode::CheckMaxInclusive(self.max_portfolio_size),
213 ]
214 }
215}
216
217impl MathematicalDomainConfiguration {
218 pub fn to_opcodes(&self) -> Vec<SlgOpcode> {
221 vec![
222 SlgOpcode::CheckMaxInclusive(self.max_precision_bits as f64),
223 SlgOpcode::CheckMaxInclusive(self.max_expression_depth as f64),
224 ]
225 }
226}
227
228impl GeospatialDomainConfiguration {
229 pub fn to_opcodes(&self) -> Vec<SlgOpcode> {
232 vec![
233 SlgOpcode::CheckMaxInclusive(self.max_coordinate_precision as f64),
234 SlgOpcode::CheckMaxInclusive(self.max_area_sq_km),
235 ]
236 }
237}
238
239impl ObfuscationConfiguration {
240 pub fn to_opcodes(&self) -> Vec<SlgOpcode> {
243 vec![
244 SlgOpcode::CheckMaxInclusive(self.max_obfuscation_depth as f64),
245 SlgOpcode::CheckMinInclusive(self.min_entropy_bits as f64),
246 ]
247 }
248}
249
250impl PolynomialObfuscationConfiguration {
251 pub fn to_opcodes(&self) -> Vec<SlgOpcode> {
253 vec![SlgOpcode::CheckMaxInclusive(
254 self.max_polynomial_degree as f64,
255 )]
256 }
257}
258
259impl SemanticStripperConfiguration {
260 pub fn to_opcodes(&self) -> Vec<SlgOpcode> {
262 vec![SlgOpcode::CheckMaxInclusive(self.max_context_depth as f64)]
263 }
264}
265
266impl DomainTransformerConfiguration {
267 pub fn to_opcodes(&self) -> Vec<SlgOpcode> {
270 vec![SlgOpcode::CheckMaxInclusive(
271 self.max_transformation_chain_length as f64,
272 )]
273 }
274}
275
276impl HybridStateConfiguration {
277 pub fn to_opcodes(&self) -> Vec<SlgOpcode> {
280 vec![SlgOpcode::CheckMaxInclusive(
281 self.max_state_size_bytes as f64,
282 )]
283 }
284}
285
286impl SolverConfiguration {
287 pub fn to_opcodes(&self) -> Vec<SlgOpcode> {
290 vec![
291 SlgOpcode::CheckMaxInclusive(self.max_iterations as f64),
292 SlgOpcode::CheckMaxInclusive(self.convergence_tolerance),
293 SlgOpcode::CheckMaxInclusive(self.max_step_size),
294 SlgOpcode::CheckMinInclusive(self.min_step_size),
295 ]
296 }
297}
298
299impl CalculusSolverConfiguration {
300 pub fn to_opcodes(&self) -> Vec<SlgOpcode> {
302 vec![SlgOpcode::CheckMaxInclusive(self.max_ode_order as f64)]
303 }
304}
305
306impl LinearAlgebraSolverConfiguration {
307 pub fn to_opcodes(&self) -> Vec<SlgOpcode> {
309 vec![SlgOpcode::CheckMaxInclusive(
310 self.max_matrix_dimension as f64,
311 )]
312 }
313}
314
315impl OptimizationSolverConfiguration {
316 pub fn to_opcodes(&self) -> Vec<SlgOpcode> {
318 vec![SlgOpcode::CheckMaxInclusive(self.max_variables as f64)]
319 }
320}
321
322impl QuantumOptimizerConfiguration {
323 pub fn to_opcodes(&self) -> Vec<SlgOpcode> {
325 vec![SlgOpcode::CheckMaxInclusive(self.max_qubits as f64)]
326 }
327}
328
329impl SymbolicLogicSolverConfiguration {
330 pub fn to_opcodes(&self) -> Vec<SlgOpcode> {
332 vec![
333 SlgOpcode::CheckMaxInclusive(self.max_clause_count as f64),
334 SlgOpcode::CheckMaxInclusive(self.max_variable_count as f64),
335 ]
336 }
337}
338
339impl GeometricAlgebraConfiguration {
340 pub fn to_opcodes(&self) -> Vec<SlgOpcode> {
342 vec![SlgOpcode::CheckMaxInclusive(self.max_dimension as f64)]
343 }
344}
345
346pub fn get_infrastructure_shacl_ttl() -> &'static str {
350 r#"
351@prefix q42: <https://webizen.org/q42#> .
352@prefix sh: <http://www.w3.org/ns/shacl#> .
353@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
354
355# ── Domain-Specific Constraints ─────────────────────────────────────────────
356
357q42:BiologicalDomainConfigurationShape a sh:NodeShape ;
358 sh:property [
359 sh:path q42:maxSequenceLength ;
360 sh:datatype xsd:integer ;
361 sh:minInclusive 1 ;
362 sh:maxInclusive 1000000 ;
363 sh:message "Sequence length must be between 1 and 1,000,000" ;
364 ] ;
365 sh:property [
366 sh:path q42:allowedSequenceTypes ;
367 sh:in ("dna" "rna" "protein") ;
368 sh:message "Sequence type must be valid" ;
369 ] .
370
371q42:ChemicalDomainConfigurationShape a sh:NodeShape ;
372 sh:property [
373 sh:path q42:maxMolecularWeight ;
374 sh:datatype xsd:float ;
375 sh:minInclusive 1.0 ;
376 sh:maxInclusive 1000000.0 ;
377 sh:message "Molecular weight must be between 1 and 1,000,000 Da" ;
378 ] ;
379 sh:property [
380 sh:path q42:maxAtomCount ;
381 sh:datatype xsd:integer ;
382 sh:minInclusive 1 ;
383 sh:maxInclusive 10000 ;
384 sh:message "Atom count must be between 1 and 10,000" ;
385 ] .
386
387q42:PhysicalDomainConfigurationShape a sh:NodeShape ;
388 sh:property [
389 sh:path q42:maxTemperatureKelvin ;
390 sh:datatype xsd:float ;
391 sh:minInclusive 0.0 ;
392 sh:maxInclusive 1e6 ;
393 sh:message "Temperature must be between 0K and 1,000,000K" ;
394 ] ;
395 sh:property [
396 sh:path q42:maxPressurePascal ;
397 sh:datatype xsd:float ;
398 sh:minInclusive 0.0 ;
399 sh:maxInclusive 1e12 ;
400 sh:message "Pressure must be reasonable" ;
401 ] .
402
403q42:FinancialDomainConfigurationShape a sh:NodeShape ;
404 sh:property [
405 sh:path q42:maxTransactionValue ;
406 sh:datatype xsd:float ;
407 sh:minInclusive 0.0 ;
408 sh:maxInclusive 1e15 ;
409 sh:message "Transaction value must be reasonable" ;
410 ] ;
411 sh:property [
412 sh:path q42:allowedCurrencies ;
413 sh:message "Currency must be valid ISO 4217 code" ;
414 ] .
415
416q42:MathematicalDomainConfigurationShape a sh:NodeShape ;
417 sh:property [
418 sh:path q42:maxPrecisionBits ;
419 sh:datatype xsd:unsignedByte ;
420 sh:maxInclusive 128 ;
421 sh:message "Precision must be ≤ 128 bits" ;
422 ] ;
423 sh:property [
424 sh:path q42:maxExpressionDepth ;
425 sh:datatype xsd:unsignedByte ;
426 sh:maxInclusive 50 ;
427 sh:message "Expression depth must be ≤ 50" ;
428 ] .
429
430q42:GeospatialDomainConfigurationShape a sh:NodeShape ;
431 sh:property [
432 sh:path q42:maxCoordinatePrecision ;
433 sh:datatype xsd:unsignedByte ;
434 sh:maxInclusive 15 ;
435 sh:message "Coordinate precision must be ≤ 15 decimal places" ;
436 ] ;
437 sh:property [
438 sh:path q42:allowedCoordinateSystems ;
439 sh:in ("wgs84" "utm" "mercator" "geographic") ;
440 sh:message "Coordinate system must be valid" ;
441 ] .
442
443# ── Obfuscation Constraints ─────────────────────────────────────────
444
445q42:ObfuscationConfigurationShape a sh:NodeShape ;
446 sh:property [
447 sh:path q42:maxObfuscationDepth ;
448 sh:datatype xsd:unsignedByte ;
449 sh:maxInclusive 10 ;
450 sh:message "Obfuscation depth must be ≤ 10" ;
451 ] ;
452 sh:property [
453 sh:path q42:minEntropyBits ;
454 sh:datatype xsd:unsignedByte ;
455 sh:minInclusive 64 ;
456 sh:message "Entropy must be ≥ 64 bits" ;
457 ] .
458
459q42:PolynomialObfuscationConfigurationShape a sh:NodeShape ;
460 sh:property [
461 sh:path q42:maxPolynomialDegree ;
462 sh:datatype xsd:unsignedByte ;
463 sh:maxInclusive 20 ;
464 sh:message "Polynomial degree must be ≤ 20" ;
465 ] .
466
467q42:SemanticStripperConfigurationShape a sh:NodeShape ;
468 sh:property [
469 sh:path q42:maxContextDepth ;
470 sh:datatype xsd:unsignedByte ;
471 sh:maxInclusive 10 ;
472 sh:message "Context depth must be ≤ 10" ;
473 ] ;
474 sh:property [
475 sh:path q42:allowedContextTypes ;
476 sh:in ("clinical" "financial" "personal" "legal") ;
477 sh:message "Context type must be valid" ;
478 ] .
479
480q42:HybridStateConfigurationShape a sh:NodeShape ;
481 sh:property [
482 sh:path q42:maxStateSizeBytes ;
483 sh:datatype xsd:integer ;
484 sh:minInclusive 1 ;
485 sh:maxInclusive 1048576 ;
486 sh:message "State size must be between 1 and 1MB" ;
487 ] .
488
489# ── Solver Constraints ─────────────────────────────────────────────────
490
491q42:SolverConfigurationShape a sh:NodeShape ;
492 sh:property [
493 sh:path q42:maxIterations ;
494 sh:datatype xsd:integer ;
495 sh:minInclusive 1 ;
496 sh:maxInclusive 1000000 ;
497 sh:message "Iterations must be between 1 and 1,000,000" ;
498 ] ;
499 sh:property [
500 sh:path q42:convergenceTolerance ;
501 sh:datatype xsd:float ;
502 sh:minInclusive 1e-15 ;
503 sh:maxInclusive 1.0 ;
504 sh:message "Tolerance must be reasonable" ;
505 ] ;
506 sh:property [
507 sh:path q42:maxStepSize ;
508 sh:datatype xsd:float ;
509 sh:minInclusive 1e-15 ;
510 sh:maxInclusive 1.0 ;
511 sh:message "Step size must be reasonable" ;
512 ] ;
513 sh:property [
514 sh:path q42:minStepSize ;
515 sh:datatype xsd:float ;
516 sh:minInclusive 1e-15 ;
517 sh:maxInclusive 1.0 ;
518 sh:message "Step size must be reasonable" ;
519 ] .
520
521q42:CalculusSolverConfigurationShape a sh:NodeShape ;
522 sh:property [
523 sh:path q42:maxOdeOrder ;
524 sh:datatype xsd:unsignedByte ;
525 sh:maxInclusive 10 ;
526 sh:message "ODE order must be ≤ 10" ;
527 ] .
528
529q42:LinearAlgebraSolverConfigurationShape a sh:NodeShape ;
530 sh:property [
531 sh:path q42:maxMatrixDimension ;
532 sh:datatype xsd:unsignedShort ;
533 sh:maxInclusive 1000 ;
534 sh:message "Matrix dimension must be ≤ 1000" ;
535 ] .
536
537q42:OptimizationSolverConfigurationShape a sh:NodeShape ;
538 sh:property [
539 sh:path q42:maxVariables ;
540 sh:datatype xsd:integer ;
541 sh:minInclusive 1 ;
542 sh:maxInclusive 100000 ;
543 sh:message "Variables must be between 1 and 100,000" ;
544 ] .
545
546q42:QuantumOptimizerConfigurationShape a sh:NodeShape ;
547 sh:property [
548 sh:path q42:maxQubits ;
549 sh:datatype xsd:unsignedShort ;
550 sh:maxInclusive 1000 ;
551 sh:message "Qubits must be ≤ 1000" ;
552 ] .
553
554q42:SymbolicLogicSolverConfigurationShape a sh:NodeShape ;
555 sh:property [
556 sh:path q42:maxClauseCount ;
557 sh:datatype xsd:integer ;
558 sh:minInclusive 1 ;
559 sh:maxInclusive 1000000 ;
560 sh:message "Clauses must be between 1 and 1,000,000" ;
561 ] ;
562 sh:property [
563 sh:path q42:maxVariableCount ;
564 sh:datatype xsd:integer ;
565 sh:minInclusive 1 ;
566 sh:maxInclusive 100000 ;
567 sh:message "Variables must be between 1 and 100,000" ;
568 ] .
569
570# ── Geometric Algebra Constraints ─────────────────────────────────────────
571
572q42:GeometricAlgebraConfigurationShape a sh:NodeShape ;
573 sh:property [
574 sh:path q42:maxDimension ;
575 sh:datatype xsd:unsignedByte ;
576 sh:minInclusive 2 ;
577 sh:maxInclusive 8 ;
578 sh:message "Dimension must be between 2 and 8" ;
579 ] ;
580 sh:property [
581 sh:path q42:allowedAlgebras ;
582 sh:in ("pga" "cga" "conformal" "projective") ;
583 sh:message "Algebra type must be valid" ;
584 ] .
585"#
586}