Skip to content

Instantly share code, notes, and snippets.

@rwbarton
Last active September 17, 2018 13:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rwbarton/440ef225da3c243c1c03028d5d32f87b to your computer and use it in GitHub Desktop.
Save rwbarton/440ef225da3c243c1c03028d5d32f87b to your computer and use it in GitHub Desktop.
; z3 zagier.smt2
(declare-const p Int)
(declare-const k Int)
(assert (> k 0))
(assert (= p (+ 1 (* 4 k))))
(assert (forall ((a Int) (b Int)) (not (and (<= 2 a) (<= 2 b) (= p (* a b))))))
(declare-datatypes () ((Triple (mk (x Int) (y Int) (z Int)))))
(define-fun S ((t Triple)) Bool
(and (= (+ (* (x t) (x t)) (* 4 (y t) (z t))) p)
(<= 0 (x t)) (<= 0 (y t)) (<= 0 (z t))))
(define-fun f1 ((t Triple)) Triple
(mk (x t) (z t) (y t)))
(define-fun f2 ((t Triple)) Triple
(ite (< (+ (x t) (z t)) (y t))
(mk (+ (x t) (* 2 (z t))) (z t) (- (y t) (x t) (z t)))
(ite (< (* 2 (y t)) (x t))
(mk (- (x t) (* 2 (y t))) (+ (- (x t) (y t)) (z t)) (y t))
(mk (- (* 2 (y t)) (x t)) (y t) (+ (- (x t) (y t)) (z t))))))
(declare-const t Triple)
(assert (S t))
(push)
(assert (not (S (f1 t))))
(check-sat) ; unsat
(pop)
(push)
(assert (not (= t (f1 (f1 t)))))
(check-sat) ; unsat
(pop)
(push)
(assert (not (S (f2 t))))
(check-sat) ; unsat
(pop)
(push)
(assert (not (= t (f2 (f2 t)))))
(check-sat) ; unsat
(pop)
(push)
(assert (= t (f2 t)))
(assert (not (= (x t) (y t))))
(check-sat) ; unsat
(pop)
(push)
(assert (= t (f2 t)))
(assert (not (and (= 1 (x t)) (= 1 (y t)))))
(check-sat) ; unknown
(pop)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment