@@ -381,14 +381,16 @@ def native_veq : SmtValue -> SmtValue -> native_Bool
381381 | x, y => decide (x = y)
382382
383383macro_rules
384- | `(native_veq_ext $m1 $m2) => do
384+ | `(native_veq_ext $T $U $ m1 $m2) => do
385385 let lookupId := Lean.mkIdent `__smtx_msm_lookup
386+ let valueEqId := Lean.mkIdent `__smtx_value_eq
386387 `(by
387388 classical
388389 exact
389390 if hExt :
390391 ∀ v : SmtValue,
391- $lookupId $m1 v = $lookupId $m2 v then
392+ $valueEqId $U ($lookupId $T $m1 v)
393+ ($lookupId $T $m2 v) = true then
392394 true
393395 else
394396 false )
@@ -484,15 +486,14 @@ def __vsm_apply_arg_nth : SmtValue -> native_Nat -> native_Nat -> SmtValue
484486 | a, n, npos => SmtValue.NotValue
485487
486488
487- def __smtx_value_eq : SmtValue -> SmtValue -> native_Bool
488- | (SmtValue.Map m1), (SmtValue.Map m2) => (native_veq_ext m1 m2)
489- | (SmtValue.Set m1), (SmtValue.Set m2) => (native_veq_ext m1 m2)
490- | (SmtValue.Fun m1), (SmtValue.Fun m2) => (native_veq_ext m1 m2)
491- | (SmtValue.RegLan r1), (SmtValue.RegLan r2) => (native_re_ext_eq r1 r2)
492- | (SmtValue.Seq (SmtSeq.empty T1)), (SmtValue.Seq (SmtSeq.empty T2)) => true
493- | (SmtValue.Seq (SmtSeq.cons v1 vs1)), (SmtValue.Seq (SmtSeq.cons v2 vs2)) => (native_and (__smtx_value_eq v1 v2) (__smtx_value_eq (SmtValue.Seq vs1) (SmtValue.Seq vs2)))
494- | (SmtValue.Apply f1 v1), (SmtValue.Apply f2 v2) => (native_and (__smtx_value_eq f1 f2) (__smtx_value_eq v1 v2))
495- | v1, v2 => (native_veq v1 v2)
489+ def __smtx_value_eq : SmtType -> SmtValue -> SmtValue -> native_Bool
490+ | (SmtType.Map T1 T2), (SmtValue.Map m1), (SmtValue.Map m2) => (native_veq_ext T1 T2 m1 m2)
491+ | (SmtType.Set T1), (SmtValue.Set m1), (SmtValue.Set m2) => (native_veq_ext T1 SmtType.Bool m1 m2)
492+ | (SmtType.FunType T1 T2), (SmtValue.Fun m1), (SmtValue.Fun m2) => (native_veq_ext T1 T2 m1 m2)
493+ | SmtType.RegLan, (SmtValue.RegLan r1), (SmtValue.RegLan r2) => (native_re_ext_eq r1 r2)
494+ | (SmtType.Seq T), (SmtValue.Seq (SmtSeq.empty T1)), (SmtValue.Seq (SmtSeq.empty T2)) => true
495+ | (SmtType.Seq T), (SmtValue.Seq (SmtSeq.cons v1 vs1)), (SmtValue.Seq (SmtSeq.cons v2 vs2)) => (native_and (__smtx_value_eq T v1 v2) (__smtx_value_eq (SmtType.Seq T) (SmtValue.Seq vs1) (SmtValue.Seq vs2)))
496+ | T, v1, v2 => (native_veq v1 v2)
496497
497498
498499def __smtx_dt_cons_wf_rec : SmtDatatypeCons -> RefList -> native_Bool
@@ -528,9 +529,9 @@ def __smtx_typeof_guard (T : SmtType) (U : SmtType) : SmtType :=
528529def __smtx_typeof_guard_wf (T : SmtType) (U : SmtType) : SmtType :=
529530 (native_ite (__smtx_type_wf T) U SmtType.None)
530531
531- def __smtx_msm_lookup : SmtMap -> SmtValue -> SmtValue
532- | (SmtMap.cons j e m), i => (native_ite (__smtx_value_eq j i) e (__smtx_msm_lookup m i))
533- | (SmtMap.default T e), i => e
532+ def __smtx_msm_lookup (T : SmtType) : SmtMap -> SmtValue -> SmtValue
533+ | (SmtMap.cons j e m), i => (native_ite (__smtx_value_eq T j i) e (__smtx_msm_lookup T m i))
534+ | (SmtMap.default U e), i => e
534535
535536
536537def __smtx_typeof_map_value : SmtMap -> SmtType
@@ -540,6 +541,11 @@ def __smtx_typeof_map_value : SmtMap -> SmtType
540541 | (SmtMap.default T e) => (SmtType.Map T (__smtx_typeof_value e))
541542
542543
544+ def __smtx_index_typeof_map : SmtType -> SmtType
545+ | (SmtType.Map T U) => T
546+ | T => SmtType.None
547+
548+
543549def __smtx_map_to_set_type : SmtType -> SmtType
544550 | (SmtType.Map T SmtType.Bool) => (SmtType.Set T)
545551 | T => SmtType.None
@@ -632,11 +638,11 @@ def __smtx_model_eval_ite : SmtValue -> SmtValue -> SmtValue -> SmtValue
632638
633639
634640def __smtx_model_eval_eq (v1 : SmtValue) (v2 : SmtValue) : SmtValue :=
635- (SmtValue.Boolean (__smtx_value_eq v1 v2))
641+ (SmtValue.Boolean (__smtx_value_eq (__smtx_typeof_value v1) v1 v2))
636642
637643def __smtx_map_select : SmtValue -> SmtValue -> SmtValue
638- | (SmtValue.Map m), i => (__smtx_msm_lookup m i)
639- | (SmtValue.Set m), i => (__smtx_msm_lookup m i)
644+ | (SmtValue.Map m), i => (__smtx_msm_lookup (__smtx_index_typeof_map (__smtx_typeof_map_value m)) m i)
645+ | (SmtValue.Set m), i => (__smtx_msm_lookup (__smtx_index_typeof_map (__smtx_typeof_map_value m)) m i)
640646 | v, i => SmtValue.NotValue
641647
642648
0 commit comments