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> {
175 vec![
176 SlgOpcode::CheckMaxInclusive(self.max_sequence_length as f64),
177 SlgOpcode::CheckMaxInclusive(self.max_gene_count as f64),
178 ]
179 }
180}
181
182impl ChemicalDomainConfiguration {
183 pub fn to_opcodes(&self) -> Vec<SlgOpcode> {
184 vec![
185 SlgOpcode::CheckMaxInclusive(self.max_molecular_weight),
186 SlgOpcode::CheckMaxInclusive(self.max_atom_count as f64),
187 ]
188 }
189}
190
191impl PhysicalDomainConfiguration {
192 pub fn to_opcodes(&self) -> Vec<SlgOpcode> {
193 vec![
194 SlgOpcode::CheckMaxInclusive(self.max_temperature_kelvin),
195 SlgOpcode::CheckMaxInclusive(self.max_pressure_pascal),
196 ]
197 }
198}
199
200impl FinancialDomainConfiguration {
201 pub fn to_opcodes(&self) -> Vec<SlgOpcode> {
202 vec![
203 SlgOpcode::CheckMaxInclusive(self.max_transaction_value),
204 SlgOpcode::CheckMaxInclusive(self.max_portfolio_size),
205 ]
206 }
207}
208
209impl MathematicalDomainConfiguration {
210 pub fn to_opcodes(&self) -> Vec<SlgOpcode> {
211 vec![
212 SlgOpcode::CheckMaxInclusive(self.max_precision_bits as f64),
213 SlgOpcode::CheckMaxInclusive(self.max_expression_depth as f64),
214 ]
215 }
216}
217
218impl GeospatialDomainConfiguration {
219 pub fn to_opcodes(&self) -> Vec<SlgOpcode> {
220 vec![
221 SlgOpcode::CheckMaxInclusive(self.max_coordinate_precision as f64),
222 SlgOpcode::CheckMaxInclusive(self.max_area_sq_km),
223 ]
224 }
225}
226
227impl ObfuscationConfiguration {
228 pub fn to_opcodes(&self) -> Vec<SlgOpcode> {
229 vec![
230 SlgOpcode::CheckMaxInclusive(self.max_obfuscation_depth as f64),
231 SlgOpcode::CheckMinInclusive(self.min_entropy_bits as f64),
232 ]
233 }
234}
235
236impl PolynomialObfuscationConfiguration {
237 pub fn to_opcodes(&self) -> Vec<SlgOpcode> {
238 vec![SlgOpcode::CheckMaxInclusive(
239 self.max_polynomial_degree as f64,
240 )]
241 }
242}
243
244impl SemanticStripperConfiguration {
245 pub fn to_opcodes(&self) -> Vec<SlgOpcode> {
246 vec![SlgOpcode::CheckMaxInclusive(self.max_context_depth as f64)]
247 }
248}
249
250impl DomainTransformerConfiguration {
251 pub fn to_opcodes(&self) -> Vec<SlgOpcode> {
252 vec![SlgOpcode::CheckMaxInclusive(
253 self.max_transformation_chain_length as f64,
254 )]
255 }
256}
257
258impl HybridStateConfiguration {
259 pub fn to_opcodes(&self) -> Vec<SlgOpcode> {
260 vec![SlgOpcode::CheckMaxInclusive(
261 self.max_state_size_bytes as f64,
262 )]
263 }
264}
265
266impl SolverConfiguration {
267 pub fn to_opcodes(&self) -> Vec<SlgOpcode> {
268 vec![
269 SlgOpcode::CheckMaxInclusive(self.max_iterations as f64),
270 SlgOpcode::CheckMaxInclusive(self.convergence_tolerance),
271 SlgOpcode::CheckMaxInclusive(self.max_step_size),
272 SlgOpcode::CheckMinInclusive(self.min_step_size),
273 ]
274 }
275}
276
277impl CalculusSolverConfiguration {
278 pub fn to_opcodes(&self) -> Vec<SlgOpcode> {
279 vec![SlgOpcode::CheckMaxInclusive(self.max_ode_order as f64)]
280 }
281}
282
283impl LinearAlgebraSolverConfiguration {
284 pub fn to_opcodes(&self) -> Vec<SlgOpcode> {
285 vec![SlgOpcode::CheckMaxInclusive(
286 self.max_matrix_dimension as f64,
287 )]
288 }
289}
290
291impl OptimizationSolverConfiguration {
292 pub fn to_opcodes(&self) -> Vec<SlgOpcode> {
293 vec![SlgOpcode::CheckMaxInclusive(self.max_variables as f64)]
294 }
295}
296
297impl QuantumOptimizerConfiguration {
298 pub fn to_opcodes(&self) -> Vec<SlgOpcode> {
299 vec![SlgOpcode::CheckMaxInclusive(self.max_qubits as f64)]
300 }
301}
302
303impl SymbolicLogicSolverConfiguration {
304 pub fn to_opcodes(&self) -> Vec<SlgOpcode> {
305 vec![
306 SlgOpcode::CheckMaxInclusive(self.max_clause_count as f64),
307 SlgOpcode::CheckMaxInclusive(self.max_variable_count as f64),
308 ]
309 }
310}
311
312impl GeometricAlgebraConfiguration {
313 pub fn to_opcodes(&self) -> Vec<SlgOpcode> {
314 vec![SlgOpcode::CheckMaxInclusive(self.max_dimension as f64)]
315 }
316}
317
318pub fn get_infrastructure_shacl_ttl() -> &'static str {
322 r#"
323@prefix q42: <https://webizen.org/q42#> .
324@prefix sh: <http://www.w3.org/ns/shacl#> .
325@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
326
327# ── Domain-Specific Constraints ─────────────────────────────────────────────
328
329q42:BiologicalDomainConfigurationShape a sh:NodeShape ;
330 sh:property [
331 sh:path q42:maxSequenceLength ;
332 sh:datatype xsd:integer ;
333 sh:minInclusive 1 ;
334 sh:maxInclusive 1000000 ;
335 sh:message "Sequence length must be between 1 and 1,000,000" ;
336 ] ;
337 sh:property [
338 sh:path q42:allowedSequenceTypes ;
339 sh:in ("dna" "rna" "protein") ;
340 sh:message "Sequence type must be valid" ;
341 ] .
342
343q42:ChemicalDomainConfigurationShape a sh:NodeShape ;
344 sh:property [
345 sh:path q42:maxMolecularWeight ;
346 sh:datatype xsd:float ;
347 sh:minInclusive 1.0 ;
348 sh:maxInclusive 1000000.0 ;
349 sh:message "Molecular weight must be between 1 and 1,000,000 Da" ;
350 ] ;
351 sh:property [
352 sh:path q42:maxAtomCount ;
353 sh:datatype xsd:integer ;
354 sh:minInclusive 1 ;
355 sh:maxInclusive 10000 ;
356 sh:message "Atom count must be between 1 and 10,000" ;
357 ] .
358
359q42:PhysicalDomainConfigurationShape a sh:NodeShape ;
360 sh:property [
361 sh:path q42:maxTemperatureKelvin ;
362 sh:datatype xsd:float ;
363 sh:minInclusive 0.0 ;
364 sh:maxInclusive 1e6 ;
365 sh:message "Temperature must be between 0K and 1,000,000K" ;
366 ] ;
367 sh:property [
368 sh:path q42:maxPressurePascal ;
369 sh:datatype xsd:float ;
370 sh:minInclusive 0.0 ;
371 sh:maxInclusive 1e12 ;
372 sh:message "Pressure must be reasonable" ;
373 ] .
374
375q42:FinancialDomainConfigurationShape a sh:NodeShape ;
376 sh:property [
377 sh:path q42:maxTransactionValue ;
378 sh:datatype xsd:float ;
379 sh:minInclusive 0.0 ;
380 sh:maxInclusive 1e15 ;
381 sh:message "Transaction value must be reasonable" ;
382 ] ;
383 sh:property [
384 sh:path q42:allowedCurrencies ;
385 sh:message "Currency must be valid ISO 4217 code" ;
386 ] .
387
388q42:MathematicalDomainConfigurationShape a sh:NodeShape ;
389 sh:property [
390 sh:path q42:maxPrecisionBits ;
391 sh:datatype xsd:unsignedByte ;
392 sh:maxInclusive 128 ;
393 sh:message "Precision must be ≤ 128 bits" ;
394 ] ;
395 sh:property [
396 sh:path q42:maxExpressionDepth ;
397 sh:datatype xsd:unsignedByte ;
398 sh:maxInclusive 50 ;
399 sh:message "Expression depth must be ≤ 50" ;
400 ] .
401
402q42:GeospatialDomainConfigurationShape a sh:NodeShape ;
403 sh:property [
404 sh:path q42:maxCoordinatePrecision ;
405 sh:datatype xsd:unsignedByte ;
406 sh:maxInclusive 15 ;
407 sh:message "Coordinate precision must be ≤ 15 decimal places" ;
408 ] ;
409 sh:property [
410 sh:path q42:allowedCoordinateSystems ;
411 sh:in ("wgs84" "utm" "mercator" "geographic") ;
412 sh:message "Coordinate system must be valid" ;
413 ] .
414
415# ── Obfuscation Constraints ─────────────────────────────────────────
416
417q42:ObfuscationConfigurationShape a sh:NodeShape ;
418 sh:property [
419 sh:path q42:maxObfuscationDepth ;
420 sh:datatype xsd:unsignedByte ;
421 sh:maxInclusive 10 ;
422 sh:message "Obfuscation depth must be ≤ 10" ;
423 ] ;
424 sh:property [
425 sh:path q42:minEntropyBits ;
426 sh:datatype xsd:unsignedByte ;
427 sh:minInclusive 64 ;
428 sh:message "Entropy must be ≥ 64 bits" ;
429 ] .
430
431q42:PolynomialObfuscationConfigurationShape a sh:NodeShape ;
432 sh:property [
433 sh:path q42:maxPolynomialDegree ;
434 sh:datatype xsd:unsignedByte ;
435 sh:maxInclusive 20 ;
436 sh:message "Polynomial degree must be ≤ 20" ;
437 ] .
438
439q42:SemanticStripperConfigurationShape a sh:NodeShape ;
440 sh:property [
441 sh:path q42:maxContextDepth ;
442 sh:datatype xsd:unsignedByte ;
443 sh:maxInclusive 10 ;
444 sh:message "Context depth must be ≤ 10" ;
445 ] ;
446 sh:property [
447 sh:path q42:allowedContextTypes ;
448 sh:in ("clinical" "financial" "personal" "legal") ;
449 sh:message "Context type must be valid" ;
450 ] .
451
452q42:HybridStateConfigurationShape a sh:NodeShape ;
453 sh:property [
454 sh:path q42:maxStateSizeBytes ;
455 sh:datatype xsd:integer ;
456 sh:minInclusive 1 ;
457 sh:maxInclusive 1048576 ;
458 sh:message "State size must be between 1 and 1MB" ;
459 ] .
460
461# ── Solver Constraints ─────────────────────────────────────────────────
462
463q42:SolverConfigurationShape a sh:NodeShape ;
464 sh:property [
465 sh:path q42:maxIterations ;
466 sh:datatype xsd:integer ;
467 sh:minInclusive 1 ;
468 sh:maxInclusive 1000000 ;
469 sh:message "Iterations must be between 1 and 1,000,000" ;
470 ] ;
471 sh:property [
472 sh:path q42:convergenceTolerance ;
473 sh:datatype xsd:float ;
474 sh:minInclusive 1e-15 ;
475 sh:maxInclusive 1.0 ;
476 sh:message "Tolerance must be reasonable" ;
477 ] ;
478 sh:property [
479 sh:path q42:maxStepSize ;
480 sh:datatype xsd:float ;
481 sh:minInclusive 1e-15 ;
482 sh:maxInclusive 1.0 ;
483 sh:message "Step size must be reasonable" ;
484 ] ;
485 sh:property [
486 sh:path q42:minStepSize ;
487 sh:datatype xsd:float ;
488 sh:minInclusive 1e-15 ;
489 sh:maxInclusive 1.0 ;
490 sh:message "Step size must be reasonable" ;
491 ] .
492
493q42:CalculusSolverConfigurationShape a sh:NodeShape ;
494 sh:property [
495 sh:path q42:maxOdeOrder ;
496 sh:datatype xsd:unsignedByte ;
497 sh:maxInclusive 10 ;
498 sh:message "ODE order must be ≤ 10" ;
499 ] .
500
501q42:LinearAlgebraSolverConfigurationShape a sh:NodeShape ;
502 sh:property [
503 sh:path q42:maxMatrixDimension ;
504 sh:datatype xsd:unsignedShort ;
505 sh:maxInclusive 1000 ;
506 sh:message "Matrix dimension must be ≤ 1000" ;
507 ] .
508
509q42:OptimizationSolverConfigurationShape a sh:NodeShape ;
510 sh:property [
511 sh:path q42:maxVariables ;
512 sh:datatype xsd:integer ;
513 sh:minInclusive 1 ;
514 sh:maxInclusive 100000 ;
515 sh:message "Variables must be between 1 and 100,000" ;
516 ] .
517
518q42:QuantumOptimizerConfigurationShape a sh:NodeShape ;
519 sh:property [
520 sh:path q42:maxQubits ;
521 sh:datatype xsd:unsignedShort ;
522 sh:maxInclusive 1000 ;
523 sh:message "Qubits must be ≤ 1000" ;
524 ] .
525
526q42:SymbolicLogicSolverConfigurationShape a sh:NodeShape ;
527 sh:property [
528 sh:path q42:maxClauseCount ;
529 sh:datatype xsd:integer ;
530 sh:minInclusive 1 ;
531 sh:maxInclusive 1000000 ;
532 sh:message "Clauses must be between 1 and 1,000,000" ;
533 ] ;
534 sh:property [
535 sh:path q42:maxVariableCount ;
536 sh:datatype xsd:integer ;
537 sh:minInclusive 1 ;
538 sh:maxInclusive 100000 ;
539 sh:message "Variables must be between 1 and 100,000" ;
540 ] .
541
542# ── Geometric Algebra Constraints ─────────────────────────────────────────
543
544q42:GeometricAlgebraConfigurationShape a sh:NodeShape ;
545 sh:property [
546 sh:path q42:maxDimension ;
547 sh:datatype xsd:unsignedByte ;
548 sh:minInclusive 2 ;
549 sh:maxInclusive 8 ;
550 sh:message "Dimension must be between 2 and 8" ;
551 ] ;
552 sh:property [
553 sh:path q42:allowedAlgebras ;
554 sh:in ("pga" "cga" "conformal" "projective") ;
555 sh:message "Algebra type must be valid" ;
556 ] .
557"#
558}