File tree Expand file tree Collapse file tree 3 files changed +47
-0
lines changed
regression/smt2_solver/arrays Expand file tree Collapse file tree 3 files changed +47
-0
lines changed Original file line number Diff line number Diff line change
1
+ CORE
2
+ as_const1.smt2
3
+
4
+ ^EXIT=0$
5
+ ^SIGNAL=0$
6
+ ^unsat$
7
+ --
Original file line number Diff line number Diff line change
1
+ ; an array consisting of all #x10
2
+ (declare-const array (Array (_ BitVec 16 ) (_ BitVec 8 )))
3
+ (assert (= array ((as const (Array (_ BitVec 16 ) (_ BitVec 8 ))) #x10 )))
4
+
5
+ (declare-const index (_ BitVec 16 ))
6
+ (assert (not (= #x10 (select array index))))
7
+
8
+ (check-sat )
Original file line number Diff line number Diff line change @@ -690,6 +690,38 @@ exprt smt2_parsert::function_application()
690
690
<< smt2_tokenizer.get_buffer () << ' \' ' ;
691
691
}
692
692
}
693
+ else if (smt2_tokenizer.get_buffer () == " as" )
694
+ {
695
+ // This is an extension understood by Z3 and CVC4.
696
+ if (
697
+ smt2_tokenizer.peek () == smt2_tokenizert::SYMBOL &&
698
+ smt2_tokenizer.get_buffer () == " const" )
699
+ {
700
+ next_token (); // eat the "const"
701
+ auto sort = this ->sort ();
702
+
703
+ if (sort.id () != ID_array)
704
+ throw error ()
705
+ << " unexpected 'as const' expression expects array type" ;
706
+
707
+ const auto &array_sort = to_array_type (sort);
708
+
709
+ if (smt2_tokenizer.next_token () != smt2_tokenizert::CLOSE)
710
+ throw error () << " expecting ')' after sort in 'as const'" ;
711
+
712
+ auto value = expression ();
713
+
714
+ if (value.type () != array_sort.subtype ())
715
+ throw error () << " unexpected 'as const' with wrong element type" ;
716
+
717
+ if (smt2_tokenizer.next_token () != smt2_tokenizert::CLOSE)
718
+ throw error () << " expecting ')' at the end of 'as const'" ;
719
+
720
+ return array_of_exprt (value, to_array_type (sort));
721
+ }
722
+ else
723
+ throw error () << " unexpected 'as' expression" ;
724
+ }
693
725
else
694
726
{
695
727
// just double parentheses
You can’t perform that action at this time.
0 commit comments