Definition:
(defchoose env-diff-index1 (idx) (env1 env2) (not (equal (env-lookup idx env1) (env-lookup idx env2))))
Function:
(defun env-diff-index (env1 env2) (declare (xargs :guard (and (natp env1) (natp env2)))) (let ((__function__ 'env-diff-index)) (declare (ignorable __function__)) (b* ((idx (nfix (env-diff-index1 (lnfix env1) (lnfix env2))))) (if (equal (env-lookup idx env1) (env-lookup idx env2)) 0 idx))))
Theorem:
(defthm natp-of-env-diff-index (b* ((idx (env-diff-index env1 env2))) (natp idx)) :rule-classes :type-prescription)
Theorem:
(defthm env-diff-index-correct (implies (not (equal (nfix env1) (nfix env2))) (b* ((idx (env-diff-index env1 env2))) (equal (env-lookup idx env1) (not (env-lookup idx env2))))))
Theorem:
(defthm env-diff-index-of-nfix-env1 (equal (env-diff-index (nfix env1) env2) (env-diff-index env1 env2)))
Theorem:
(defthm env-diff-index-nat-equiv-congruence-on-env1 (implies (nat-equiv env1 env1-equiv) (equal (env-diff-index env1 env2) (env-diff-index env1-equiv env2))) :rule-classes :congruence)
Theorem:
(defthm env-diff-index-of-nfix-env2 (equal (env-diff-index env1 (nfix env2)) (env-diff-index env1 env2)))
Theorem:
(defthm env-diff-index-nat-equiv-congruence-on-env2 (implies (nat-equiv env2 env2-equiv) (equal (env-diff-index env1 env2) (env-diff-index env1 env2-equiv))) :rule-classes :congruence)