Debian Codegraph @

test/regress/cli/regress1/sygus/rec-fun-swap.sy

raw
1 ; EXPECT: feasible
2 ; COMMAND-LINE: --sygus-out=status --lang=sygus2
3
4 (set-logic ALL)
5
6 ; The environment datatypes
7 (declare-datatype NVars ((x) (y)))
8
9 (declare-datatype Pair ((pair (first NVars) (second Int))))
10
11 (declare-datatype Env ((cons (head Pair) (tail Env)) (nil)))
12
13 (define-fun-rec envStore ((var NVars) (value Int) (env Env)) Env
14 (ite (is-nil env)
15 (cons (pair var value) env)
16 (ite (= var (first (head env)))
17 (cons (pair var value) (tail env))
18 (cons (head env) (envStore var value (tail env)))
19 )
20 )
21 )
22
23 (define-fun-rec envSelect ((var NVars) (env Env)) Int
24 (ite (is-nil env)
25 (- 1)
26 (ite (= var (first (head env)))
27 (second (head env))
28 (envSelect var (tail env))
29 )
30 )
31 )
32
33 ; Syntax for arithmetic expressions
34 (declare-datatype Aexp
35 (
36 (Val (val Int))
37 )
38 )
39
40 ; Function to evaluate arithmetic expressions
41 (define-fun-rec evalA ((env Env) (a Aexp)) Int
42 (val a)
43 )
44
45 ; Syntax for commands
46 (declare-datatype Com
47 (
48 (Skip)
49 (Assign (lhs NVars) (rhs Aexp))
50 (CSeq (cBef Com) (aAft Com))
51 )
52 )
53
54 ; Function to evaluate statements
55 (define-fun-rec evalC ((env Env) (c Com)) Env
56 (ite (is-Skip c)
57 env
58 (ite (is-Assign c)
59 (envStore (lhs c) (evalA env (rhs c)) env)
60 (evalC (evalC env (cBef c)) (aAft c)))
61 )
62 )
63
64 (synth-fun prog () Com
65 ((C Com) (V NVars) (A Aexp) (I Int))
66 (
67 (C Com (Skip (Assign V A) (CSeq C C)))
68 (V NVars (x y))
69 (A Aexp ((Val I)))
70 (I Int (0 1))
71 )
72 )
73
74 (constraint (= (evalC (cons (pair y 0) (cons (pair x 1) nil)) prog) (cons (pair y 1) (cons (pair x 0) nil))))
75
76 (check-synth)