MCPcopy Create free account
hub / github.com/argumentcomputer/ix / gen_univ

Function gen_univ

crates/kernel/src/level.rs:1052–1073  ·  view source on GitHub ↗

Generate a bounded-depth `KUniv `. Parameter indices are drawn from `0..=max_param` so multiple universes in the same test can share parameters — important for geq transitivity tests.

(rng: &mut UPrng, depth: u32, max_param: u64)

Source from the content-addressed store, hash-verified

1050 assert!(univ_eq(&lhs, &rhs));
1051 assert!(univ_eq(&rhs, &lhs));
1052 // Geq agrees in both directions (norm_level_le already skipped
1053 // empty entries — this is the antisymmetry pair univ_eq now matches).
1054 assert!(univ_geq(&lhs, &rhs));
1055 assert!(univ_geq(&rhs, &lhs));
1056 // Control: the comparator did not get weaker — a semantically
1057 // distinct near-miss stays distinct (at u=v=0: lhs=1, other=0).
1058 let smaller = AU::max(u.clone(), v.clone());
1059 assert!(!univ_eq(&lhs, &smaller));
1060 assert!(!univ_eq(&smaller, &lhs));
1061 }
1062
1063 #[test]
1064 fn univ_geq_basic() {
1065 let z = AU::zero();
1066 let s1 = AU::succ(z.clone());
1067 let s2 = AU::succ(s1.clone());
1068 let p = AU::param(0, ());
1069 assert!(univ_geq(&z, &z));
1070 assert!(univ_geq(&s1, &z));
1071 assert!(univ_geq(&p, &z));
1072 assert!(univ_geq(&s2, &s1));
1073 assert!(!univ_geq(&s1, &s2));
1074 }
1075
1076 #[test]

Calls 3

paramFunction · 0.70
next_u32Method · 0.45
next_u64Method · 0.45