Browse Source

Added the problems

master
Joshua Moerman 6 years ago
parent
commit
a1a44c953a
  1. 5
      README.md
  2. 70
      main.smt
  3. 208
      opg22.smt
  4. 248
      opgave4aivd.smt
  5. 59
      superperm.smt
  6. 37
      superperm2.proof
  7. 135
      superperm2.smt

5
README.md

@ -1,3 +1,6 @@
# smt-solving # smt-solving
Collections of smt problems Collections of smt problems. Some for AVID
kerstpuzzel. I have some for an A&D assignment.
And there is one for superpermutations.

70
main.smt

@ -0,0 +1,70 @@
(set-option :produce-proofs true)
(declare-datatypes () ((Box (mk-box (fst Real) (snd Real) (trd Real)))))
; Valid interval = (1/2, 1)
(define-fun valint ((x Real)) Bool
(and (< 0.5 x) (< x 1)))
; Valid box
(define-fun valbox ((x Box)) Bool
(and (valint (fst x))
(valint (snd x))
(valint (trd x))))
(define-fun fits1 ((x1 Real) (x2 Real) (x3 Real) (y1 Real) (y2 Real) (y3 Real)) Bool
(and (< x1 y1) (< x2 y2) (< x3 y3)))
(define-fun fits2 ((x1 Real) (x2 Real) (x3 Real) (y1 Real) (y2 Real) (y3 Real)) Bool
(or
(fits1 x1 x2 x3 y1 y2 y3)
(fits1 x1 x2 x3 y1 y3 y2)
(fits1 x1 x2 x3 y2 y1 y3)
(fits1 x1 x2 x3 y2 y3 y1)
(fits1 x1 x2 x3 y3 y1 y2)
(fits1 x1 x2 x3 y3 y2 y1)))
; Box x fits inside box y
(define-fun fits ((x Box) (y Box)) Bool
(fits2 (fst x) (snd x) (trd x) (fst y) (snd y) (trd y)))
; x and y do not fit in each other
(define-fun nfits ((x Box) (y Box)) Bool
(and (not (fits x y)) (not (fits y x))))
; nodes
(declare-datatypes () ((Dom A1 A2 A4 A7 A8 A11 A13 A14)))
; edges
(declare-fun rel (Dom Dom) Bool)
; transitive
(assert (forall ((x Dom) (y Dom) (z Dom)) (implies (and (rel x y) (rel y z)) (rel x z))))
; acyclic
(assert (forall ((x Dom) (y Dom)) (not (and (rel x y) (rel y x)))))
(assert (rel A1 A7))
(assert (rel A2 A7))
(assert (rel A4 A7))
(assert (not (rel A8 A7)))
(assert (rel A1 A11))
(assert (rel A2 A11))
(assert (not (rel A4 A11)))
(assert (rel A8 A11))
(assert (rel A1 A13))
(assert (not (rel A2 A13)))
(assert (rel A4 A13))
(assert (rel A8 A13))
(assert (not (rel A1 A14)))
(assert (rel A2 A14))
(assert (rel A4 A14))
(assert (rel A8 A14))
; check graph
(check-sat)
(push)
; strong homomorphism to boxes
(declare-fun boxes (Dom) Box)
(assert (forall ((x Dom)) (valbox (boxes x))))
(assert (forall ((x Dom) (y Dom)) (implies (rel x y) (fits (boxes x) (boxes y)))))
(assert (forall ((x Dom) (y Dom)) (implies (fits (boxes x) (boxes y)) (rel x y))))
; Compute boxes
(check-sat)
; (get-proof)
(pop)
(exit)

208
opg22.smt

File diff suppressed because one or more lines are too long

248
opgave4aivd.smt

@ -0,0 +1,248 @@
(set-option :produce-proofs true)
(define-fun chr ((x Int)) String
(ite (= x 26) "z" (ite (= x 25) "y" (ite (= x 24) "x" (ite (= x 23) "w" (ite (= x 22) "v" (ite (= x 21) "u" (ite (= x 20) "t" (ite (= x 19) "s" (ite (= x 18) "r" (ite (= x 17) "q" (ite (= x 16) "p" (ite (= x 15) "o" (ite (= x 14) "n" (ite (= x 13) "m" (ite (= x 12) "l" (ite (= x 11) "k" (ite (= x 10) "j" (ite (= x 9) "i" (ite (= x 8) "h" (ite (= x 7) "g" (ite (= x 6) "f" (ite (= x 5) "e" (ite (= x 4) "d" (ite (= x 3) "c" (ite (= x 2) "b" (ite (= x 1) "a" "-")))))))))))))))))))))))))))
(define-fun klinker ((x Int)) Bool
(or (= x 1) (= x 5) (= x 9) (= x 15) (= x 21) (= x 25)))
(define-fun verboden ((x Int)) Bool
(or
(= x 25)
(= x 24)
))
(define-fun ran ((x Int)) Bool
(and (<= 0 x) (<= x 44)))
;
;
; 3
; _4_ 5 _10_
; _0_ _1_ 2 6 7 _8_ 9 11 12 _13_
;
(declare-fun letter (Int) Int)
(define-fun drie ((x Int) (y Int) (z Int)) Bool
(= (letter x) (+ (letter y) (letter z))))
(assert (forall ((x Int)) (and (>= (letter x) 1) (<= (letter x) 26))))
(assert (= (letter 0) 4))
(assert (= (letter 1) 5))
(assert (drie 3 4 5))
(assert (= (letter 4) 13))
(assert (drie 4 6 7))
(assert (drie 5 7 8))
(assert (= (letter 8) 4))
(assert (= (letter 10) 23))
(assert (drie 10 11 12))
(assert (= (letter 13) 4))
(assert (= (letter 14) 26))
(assert (drie 15 16 17))
(assert (= (letter 16) 5))
(assert (= (letter 18) 5))
(assert (= (letter 19) 14))
(assert (= (letter 21) 20))
(assert (= (letter 24) 14))
(assert (drie 21 22 23))
(assert (drie 22 24 25))
(assert (drie 23 25 26))
(assert (= (letter 27) 5))
(assert (= (letter 28) 5))
(assert (= (letter 29) 14))
(assert (= (letter 38) 4))
(assert (drie 30 31 32))
(assert (drie 31 33 34))
(assert (drie 32 34 35))
(assert (drie 33 36 37))
(assert (drie 34 37 38))
(assert (drie 35 38 39))
(assert (= (letter 44) 6))
(assert (drie 42 43 44))
(define-fun rk ((x Int)) Bool
(and (ran x) (klinker (letter x))))
(assert (exists ((a1 Int) (a2 Int) (a3 Int) (a4 Int) (a5 Int) (a6 Int) (a7 Int))
(and
(distinct a1 a2 a3 a4 a5 a6 a7)
(rk a1) (rk a2) (rk a3) (rk a4) (rk a5) (rk a6) (rk a7)
)))
; nergens een 'x','y'...
(assert (forall ((a Int)) (not (verboden (letter a)))))
; (a,1),(b,2),(c,3),(d,4),(e,5),(f,6),(g,7),(h,8),(i,9),
; (j,10),(k,11),(l,12),(m,13),(n,14),(o,15),(p,16),(q,17),
; (r,18),(s,19),(t,20),(u,21),(v,22),(w,23),(x,24),(y,25),(z,26)
; '...mih...' kan niet
(assert (forall ((a Int))
(not (and (= (letter (+ a 0)) 13)
(= (letter (+ a 1)) 9)
(= (letter (+ a 2)) 8)
))))
; '...zmm...' kan niet
(assert (forall ((a Int))
(not (and (= (letter (+ a 0)) 26)
(= (letter (+ a 1)) 13)
(= (letter (+ a 2)) 13)
))))
; '...dzz...' kan niet
(assert (forall ((a Int))
(not (and (= (letter (+ a 0)) 4)
(= (letter (+ a 1)) 26)
(= (letter (+ a 2)) 26)
))))
; '...tpd...' kan niet
(assert (forall ((a Int))
(not (and (= (letter (+ a 0)) 20)
(= (letter (+ a 1)) 16)
(= (letter (+ a 2)) 4)
))))
; '...nzl...' kan niet
(assert (forall ((a Int))
(not (and (= (letter (+ a 0)) 14)
(= (letter (+ a 1)) 26)
(= (letter (+ a 2)) 12)
))))
; '...ggb...' kan niet
(assert (forall ((a Int))
(not (and (= (letter (+ a 0)) 7)
(= (letter (+ a 1)) 7)
(= (letter (+ a 2)) 2)
))))
; '...cff...' kan niet
(assert (forall ((a Int))
(not (and (= (letter (+ a 0)) 3)
(= (letter (+ a 1)) 6)
(= (letter (+ a 2)) 6)
))))
; '...bcd...' kan niet
(assert (forall ((a Int))
(not (and (= (letter (+ a 0)) 2)
(= (letter (+ a 1)) 3)
(= (letter (+ a 2)) 4)
))))
; nzn
(assert (forall ((a Int))
(not (and (= (letter (+ a 0)) 14)
(= (letter (+ a 1)) 26)
(= (letter (+ a 2)) 14)
))))
; nwh
(assert (forall ((a Int))
(not (and (= (letter (+ a 0)) 14)
(= (letter (+ a 1)) 23)
(= (letter (+ a 2)) 8)
))))
; nwm
(assert (forall ((a Int))
(not (and (= (letter (+ a 0)) 14)
(= (letter (+ a 1)) 23)
(= (letter (+ a 2)) 13)
))))
; nwk
(assert (forall ((a Int))
(not (and (= (letter (+ a 0)) 14)
(= (letter (+ a 1)) 23)
(= (letter (+ a 2)) 11)
))))
; rhj
(assert (forall ((a Int))
(not (and (= (letter (+ a 0)) 18)
(= (letter (+ a 1)) 8)
(= (letter (+ a 2)) 10)
))))
; zpj
(assert (forall ((a Int))
(not (and (= (letter (+ a 0)) 26)
(= (letter (+ a 1)) 16)
(= (letter (+ a 2)) 10)
))))
; qgj
(assert (forall ((a Int))
(not (and (= (letter (+ a 0)) 17)
(= (letter (+ a 1)) 7)
(= (letter (+ a 2)) 10)
))))
; '...umhi...' kan niet
(assert (forall ((a Int))
(not (and (= (letter (+ a 0)) 21)
(= (letter (+ a 1)) 13)
(= (letter (+ a 2)) 8)
(= (letter (+ a 3)) 9)
))))
(assert (= (letter 11) 9)) ; w_i_nd
(assert (<= (letter 37) 2)) ; a of b.
(assert (= (letter 43) 1)) ; g_a_f.
(check-sat)
(get-value ((chr (letter 0))))
(get-value ((chr (letter 1))))
(get-value ((chr (letter 2))))
(get-value ((chr (letter 3))))
(get-value ((chr (letter 4))))
(get-value ((chr (letter 5))))
(get-value ((chr (letter 6))))
(get-value ((chr (letter 7))))
(get-value ((chr (letter 8))))
(get-value ((chr (letter 9))))
(get-value ((chr (letter 10))))
(get-value ((chr (letter 11))))
(get-value ((chr (letter 12))))
(get-value ((chr (letter 13))))
(get-value ((chr (letter 14))))
(get-value ((chr (letter 15))))
(get-value ((chr (letter 16))))
(get-value ((chr (letter 17))))
(get-value ((chr (letter 18))))
(get-value ((chr (letter 19))))
(get-value ((chr (letter 20))))
(get-value ((chr (letter 21))))
(get-value ((chr (letter 22))))
(get-value ((chr (letter 23))))
(get-value ((chr (letter 24))))
(get-value ((chr (letter 25))))
(get-value ((chr (letter 26))))
(get-value ((chr (letter 27))))
(get-value ((chr (letter 28))))
(get-value ((chr (letter 29))))
(get-value ((chr (letter 30))))
(get-value ((chr (letter 31))))
(get-value ((chr (letter 32))))
(get-value ((chr (letter 33))))
(get-value ((chr (letter 34))))
(get-value ((chr (letter 35))))
(get-value ((chr (letter 36))))
(get-value ((chr (letter 37))))
(get-value ((chr (letter 38))))
(get-value ((chr (letter 39))))
(get-value ((chr (letter 40))))
(get-value ((chr (letter 41))))
(get-value ((chr (letter 42))))
(get-value ((chr (letter 43))))
(get-value ((chr (letter 44))))

59
superperm.smt

@ -0,0 +1,59 @@
;(set-option :produce-proofs true)
(define-fun n () Int 4) ; number of symbols
(define-fun len () Int 33) ; length of string
(define-fun len2 () Int 29)
(define-fun ran ((x Int)) Bool
(and (<= 0 x) (< x len)))
(define-fun ran2 ((x Int)) Bool
(and (<= 0 x) (<= x len2)))
(declare-fun perm (Int) Int)
(assert (forall ((x Int))
(and (>= (perm x) 1) (<= (perm x) n))))
(define-fun subWord ((a0 Int) (a1 Int) (a2 Int) (a3 Int)) Bool
(exists ((x Int))
(and (ran2 x)
(= (perm (+ x 0)) a0)
(= (perm (+ x 1)) a1)
(= (perm (+ x 2)) a2)
(= (perm (+ x 3)) a3) )))
;(assert (forall ((x Int)) (not (= (perm x) (perm (+ x 1)))) ))
;(assert (forall ((x Int)) (not (= (perm x) (perm (+ x 2)))) ))
(assert (= 1 (perm 0)))
(assert (= 2 (perm 1)))
(assert (= 3 (perm 2)))
(assert (= 4 (perm 3)))
;(assert (subWord 1 2 3 4 5))
(assert (subWord 1 2 3 4))
(assert (subWord 2 1 3 4))
(assert (subWord 3 2 1 4))
(assert (subWord 2 3 1 4))
(assert (subWord 3 1 2 4))
(assert (subWord 1 3 2 4))
(assert (subWord 4 3 2 1))
(assert (subWord 3 4 2 1))
(assert (subWord 3 2 4 1))
(assert (subWord 4 2 3 1))
(assert (subWord 2 4 3 1))
(assert (subWord 2 3 4 1))
(assert (subWord 4 1 2 3))
(assert (subWord 1 4 2 3))
(assert (subWord 1 2 4 3))
(assert (subWord 4 2 1 3))
(assert (subWord 2 4 1 3))
(assert (subWord 2 1 4 3))
(assert (subWord 4 1 3 2))
(assert (subWord 1 4 3 2))
(assert (subWord 1 3 4 2))
(assert (subWord 4 3 1 2))
(assert (subWord 3 4 1 2))
(assert (subWord 3 1 4 2))
(check-sat)

37
superperm2.proof

@ -0,0 +1,37 @@
unknown
(error "line 135 column 11: proof is not available")
(:added-eqs 103686431
:arith-add-rows 345
:arith-assert-diseq 75045628
:arith-assert-lower 61627173
:arith-assert-upper 63603655
:arith-bound-prop 2163
:arith-conflicts 205
:arith-eq-adapter 15320
:arith-fixed-eqs 556790
:arith-offset-eqs 56410
:arith-pivots 2351
:bv-bit2core 52377850
:bv-conflicts 36500
:bv-dynamic-eqs 18457182
:bv->core-eq 18457182
:conflicts 86074
:decisions 60974940
:del-clause 3076236
:final-checks 402793
:max-memory 67.43
:memory 67.26
:minimized-lits 12979
:mk-bool-var 129261498
:mk-clause 3148986
:num-allocs 5465284107.00
:num-checks 1
:propagations 169737856
:restarts 341
:rlimit-count 1494080384
:seq-add-axiom 88311
:seq-branch 321201
:seq-fixed-length 81592
:seq-num-reductions 63534116
:time 6184.33
:total-time 6137.96)

135
superperm2.smt

@ -0,0 +1,135 @@
(set-option :produce-proofs true)
; Some string
(declare-const perm String)
; of this length
(assert (= (str.len perm) 152))
; with these substrings...
(assert (str.prefixof "12345" perm))
(assert (str.contains perm "21345"))
(assert (str.contains perm "32145"))
(assert (str.contains perm "23145"))
(assert (str.contains perm "31245"))
(assert (str.contains perm "13245"))
(assert (str.contains perm "43215"))
(assert (str.contains perm "34215"))
(assert (str.contains perm "32415"))
(assert (str.contains perm "42315"))
(assert (str.contains perm "24315"))
(assert (str.contains perm "23415"))
(assert (str.contains perm "41235"))
(assert (str.contains perm "14235"))
(assert (str.contains perm "12435"))
(assert (str.contains perm "42135"))
(assert (str.contains perm "24135"))
(assert (str.contains perm "21435"))
(assert (str.contains perm "41325"))
(assert (str.contains perm "14325"))
(assert (str.contains perm "13425"))
(assert (str.contains perm "43125"))
(assert (str.contains perm "34125"))
(assert (str.contains perm "31425"))
(assert (str.contains perm "54321"))
(assert (str.contains perm "45321"))
(assert (str.contains perm "43521"))
(assert (str.contains perm "43251"))
(assert (str.contains perm "53421"))
(assert (str.contains perm "35421"))
(assert (str.contains perm "34521"))
(assert (str.contains perm "34251"))
(assert (str.contains perm "52341"))
(assert (str.contains perm "25341"))
(assert (str.contains perm "23541"))
(assert (str.contains perm "23451"))
(assert (str.contains perm "53241"))
(assert (str.contains perm "35241"))
(assert (str.contains perm "32541"))
(assert (str.contains perm "32451"))
(assert (str.contains perm "52431"))
(assert (str.contains perm "25431"))
(assert (str.contains perm "24531"))
(assert (str.contains perm "24351"))
(assert (str.contains perm "54231"))
(assert (str.contains perm "45231"))
(assert (str.contains perm "42531"))
(assert (str.contains perm "42351"))
(assert (str.contains perm "51234"))
(assert (str.contains perm "15234"))
(assert (str.contains perm "12534"))
(assert (str.contains perm "12354"))
(assert (str.contains perm "52134"))
(assert (str.contains perm "25134"))
(assert (str.contains perm "21534"))
(assert (str.contains perm "21354"))
(assert (str.contains perm "52314"))
(assert (str.contains perm "25314"))
(assert (str.contains perm "23514"))
(assert (str.contains perm "23154"))
(assert (str.contains perm "51324"))
(assert (str.contains perm "15324"))
(assert (str.contains perm "13524"))
(assert (str.contains perm "13254"))
(assert (str.contains perm "53124"))
(assert (str.contains perm "35124"))
(assert (str.contains perm "31524"))
(assert (str.contains perm "31254"))
(assert (str.contains perm "53214"))
(assert (str.contains perm "35214"))
(assert (str.contains perm "32514"))
(assert (str.contains perm "32154"))
(assert (str.contains perm "51432"))
(assert (str.contains perm "15432"))
(assert (str.contains perm "14532"))
(assert (str.contains perm "14352"))
(assert (str.contains perm "54132"))
(assert (str.contains perm "45132"))
(assert (str.contains perm "41532"))
(assert (str.contains perm "41352"))
(assert (str.contains perm "54312"))
(assert (str.contains perm "45312"))
(assert (str.contains perm "43512"))
(assert (str.contains perm "43152"))
(assert (str.contains perm "51342"))
(assert (str.contains perm "15342"))
(assert (str.contains perm "13542"))
(assert (str.contains perm "13452"))
(assert (str.contains perm "53142"))
(assert (str.contains perm "35142"))
(assert (str.contains perm "31542"))
(assert (str.contains perm "31452"))
(assert (str.contains perm "53412"))
(assert (str.contains perm "35412"))
(assert (str.contains perm "34512"))
(assert (str.contains perm "34152"))
(assert (str.contains perm "51423"))
(assert (str.contains perm "15423"))
(assert (str.contains perm "14523"))
(assert (str.contains perm "14253"))
(assert (str.contains perm "54123"))
(assert (str.contains perm "45123"))
(assert (str.contains perm "41523"))
(assert (str.contains perm "41253"))
(assert (str.contains perm "54213"))
(assert (str.contains perm "45213"))
(assert (str.contains perm "42513"))
(assert (str.contains perm "42153"))
(assert (str.contains perm "51243"))
(assert (str.contains perm "15243"))
(assert (str.contains perm "12543"))
(assert (str.contains perm "12453"))
(assert (str.contains perm "52143"))
(assert (str.contains perm "25143"))
(assert (str.contains perm "21543"))
(assert (str.contains perm "21453"))
(assert (str.contains perm "52413"))
(assert (str.contains perm "25413"))
(assert (str.contains perm "24513"))
(assert (str.contains perm "24153"))
; Does it exist?
(check-sat)
;(get-model)
(get-proof)
Loading…
Cancel
Save