0

次のコードがあります: (declare-const L4 (_ BitVec 6)) (declare-const L1 (_ BitVec 6)) (declare-const L0 (_ BitVec 6)) (declare-const l2 (_ BitVec 6) )))

(assert (= l2 (_ bv8 6)))

;; All is encoding the set that contains {0, 1, 2, 3, 4, 5}
(define-const All (_ BitVec 6) #b111111) 
;; Empty is encoding the empty set
(define-const Empty (_ BitVec 6) #b000000) 

(define-fun LT_l ((S (_ BitVec 6)) (l (_ BitVec 6))) Bool
    ;; True if for all x in S x < l
    (= (bvand (bvshl All l) S) Empty))

(define-fun is_in ((e (_ BitVec 6)) (S (_ BitVec 6))) Bool
   ;; True if e is an element of the "set" S.
   (not (= (bvand (bvshl (_ bv1 6) e) S) Empty))) 

(define-fun is_minimal ((e (_ BitVec 6)) (S (_ BitVec 6))) Bool
    ;; True if e is the minimal element of S
    (and (is_in e S) ;; S contains e
         ;; (1 << e) - 1 represents the set of elements that are smaller than e
         (= (bvand (bvsub (bvshl (_ bv1 6) e) (_ bv1 6)) S) Empty))) 

;; To encode that forall x in L0 and forall y in L1. x < y
(define-fun LT ((L0 (_ BitVec 6)) (L1 (_ BitVec 6))) Bool
    ; True if forall x in L0 and forall y in L1, x < y
    (or (= L0 Empty)
        (= L1 Empty)
        (exists ((min (_ BitVec 6))) (and (is_minimal min L1) (LT_l L0 min)))))

(assert (not (= L0 Empty)))
(assert (not (= L1 Empty)))
(assert (not (= L4 Empty)))
(assert (LT_l L4 l2))
(assert (LT L0 L1))
(check-sat)
(get-model)
(assert (LT L1 L0))
(check-sat)

このコードを実行すると、モデルは次のようになります。 L0 () (_ BitVec 6) #b000100) (define-fun L4 () (_ BitVec 6) #b000100) (define-fun l2 () (_ BitVec 6) #b001000) ) unsat

の結果minは次のとおりです。

(define-fun min!0 () (_ BitVec 6)
    #b000011)

L1 の最小値はこれであり、b000011 ではないため、b001000 ではありません。

誰かが私を説明できますか?

最後に、S x < l 内のすべての x についてチェックする関数 Lt_l を定義しますが、S l < x 内のすべての x についてチェックする GT_l を実行したいと思いました。次のコードがあります。

(define-fun GT_l ((S (_ BitVec 6)) (l (_ BitVec 6))) Bool
    (= (bvand (bvneg (bvshl (_ bv0 6) l)) S) Empty))

しかし、これはなぜうまくいきませんか?

ありがとう

4

1 に答える 1