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

Function level_congruent

crates/kernel/src/congruence.rs:34–59  ·  view source on GitHub ↗

Check that a Lean-side Level matches a zero Univ structurally.

(
  lean_lvl: &lean::Level,
  zero_univ: &KUniv<Anon>,
  _nr: &NameResolver,
)

Source from the content-addressed store, hash-verified

32
33/// Check that a Lean-side Level matches a zero Univ structurally.
34pub fn level_congruent(
35 lean_lvl: &lean::Level,
36 zero_univ: &KUniv<Anon>,
37 _nr: &NameResolver,
38) -> Result<(), String> {
39 use lean::LevelData as LD;
40 match (lean_lvl.as_data(), zero_univ.data()) {
41 (LD::Zero(_), UnivData::Zero(_)) => Ok(()),
42 (LD::Succ(a, _), UnivData::Succ(b, _)) => level_congruent(a, b, _nr),
43 (LD::Max(a1, a2, _), UnivData::Max(b1, b2, _))
44 | (LD::Imax(a1, a2, _), UnivData::IMax(b1, b2, _)) => {
45 level_congruent(a1, b1, _nr)?;
46 level_congruent(a2, b2, _nr)
47 },
48 (LD::Param(_, _), UnivData::Param(_, _, _)) => {
49 // Lean uses named params, zero uses positional indices.
50 // Can't check correspondence without level_params list.
51 Ok(())
52 },
53 _ => Err(format!(
54 "level mismatch: lean={} vs zero={}",
55 lean_lvl_tag(lean_lvl),
56 zero_univ_tag(zero_univ),
57 )),
58 }
59}
60
61/// Check that a Lean-side Expr matches a zero Expr<Anon> structurally.
62pub fn expr_congruent(

Callers 9

expr_congruentFunction · 0.85
level_zero_matchesFunction · 0.85
level_succ_matchesFunction · 0.85
level_max_matchesFunction · 0.85
level_imax_matchesFunction · 0.85
level_param_matchesFunction · 0.85
level_zero_vs_succ_failsFunction · 0.85
level_max_vs_imax_failsFunction · 0.85

Calls 2

as_dataMethod · 0.80
dataMethod · 0.45

Tested by 8

level_zero_matchesFunction · 0.68
level_succ_matchesFunction · 0.68
level_max_matchesFunction · 0.68
level_imax_matchesFunction · 0.68
level_param_matchesFunction · 0.68
level_zero_vs_succ_failsFunction · 0.68
level_max_vs_imax_failsFunction · 0.68