Fixes for regular expressions + sygus (#5044)
authorAndrew Reynolds <andrew.j.reynolds@gmail.com>
Wed, 9 Sep 2020 19:12:52 +0000 (14:12 -0500)
committerGitHub <noreply@github.com>
Wed, 9 Sep 2020 19:12:52 +0000 (14:12 -0500)
Includes not constructing a default value for non-first class types (e.g. RegLan) and a missing printer case for re.diff.

src/printer/smt2/smt2_printer.cpp
src/theory/quantifiers/fmf/full_model_check.cpp
test/regress/CMakeLists.txt
test/regress/regress1/sygus/rex-strings-alarm.sy [new file with mode: 0644]

index 960d17cdc07f7ac7bdeedc4ecdc096a56dba77ff..2cc6c89731ad0d95de68f5341c3791247e46b63b 100644 (file)
@@ -661,6 +661,7 @@ void Smt2Printer::toStream(std::ostream& out,
   case kind::REGEXP_RANGE:
   case kind::REGEXP_LOOP:
   case kind::REGEXP_COMPLEMENT:
+  case kind::REGEXP_DIFF:
   case kind::REGEXP_EMPTY:
   case kind::REGEXP_SIGMA:
   case kind::SEQ_UNIT:
@@ -1242,6 +1243,7 @@ static string smtKindString(Kind k, Variant v)
   case kind::REGEXP_RANGE: return "re.range";
   case kind::REGEXP_LOOP: return "re.loop";
   case kind::REGEXP_COMPLEMENT: return "re.comp";
+  case kind::REGEXP_DIFF: return "re.diff";
   case kind::SEQUENCE_TYPE: return "Seq";
   case kind::SEQ_UNIT: return "seq.unit";
   case kind::SEQ_NTH: return "seq.nth";
index 8022718583cd1d760858b6ed75fdad534caaa4a5..2709bc8f41f36cb5b7a32fcee40b01caaf6b7b76 100644 (file)
@@ -527,7 +527,7 @@ bool FullModelChecker::processBuildModel(TheoryModel* m){
 void FullModelChecker::preInitializeType( FirstOrderModelFmc * fm, TypeNode tn ){
   if( d_preinitialized_types.find( tn )==d_preinitialized_types.end() ){
     d_preinitialized_types[tn] = true;
-    if (!tn.isFunction() || options::ufHo())
+    if (tn.isFirstClass())
     {
       Trace("fmc") << "Get model basis term " << tn << "..." << std::endl;
       Node mb = fm->getModelBasisTerm(tn);
index e06abc0a57e46afa013311d0ce1524e97ba4cb06..ea012a279b948db5619270cc4c0c0d14f671fe8d 100644 (file)
@@ -2001,6 +2001,7 @@ set(regress_1_tests
   regress1/sygus/rec-fun-while-infinite.sy
   regress1/sygus/re-concat.sy
   regress1/sygus/repair-const-rl.sy
+  regress1/sygus/rex-strings-alarm.sy
   regress1/sygus/sets-pred-test.sy
   regress1/sygus/simple-regexp.sy
   regress1/sygus/stopwatch-bt.sy
diff --git a/test/regress/regress1/sygus/rex-strings-alarm.sy b/test/regress/regress1/sygus/rex-strings-alarm.sy
new file mode 100644 (file)
index 0000000..aa2ddb2
--- /dev/null
@@ -0,0 +1,60 @@
+; EXPECT: unsat
+; COMMAND-LINE: --sygus-out=status --lang=sygus2 --strings-exp
+
+(set-logic S)
+
+(set-option :sygus-rec-fun true)
+(set-option :e-matching false)
+
+(define-sort Rex () RegLan)
+    
+    
+;SyGuS Grammar Definition.
+(synth-fun phi () Rex
+
+  ((<R> Rex))  
+  ((<R> Rex (
+    
+    ; alphabets
+    (str.to_re "r") ; r = request 
+    (str.to_re "g") ; g = grant
+    (str.to_re "e") ; e = empty 
+    (str.to_re "b") ; b = request, grant
+
+;    (re.none <R>)
+;    (re.all <R>)
+    
+    ; CHOICE
+    (re.union <R> <R>)
+    
+    ; CONCATENATION
+    (re.++    <R> <R>)
+    
+    ; INTERSECTION
+    (re.inter <R> <R>)
+    
+    ; STAR 
+    (re.* <R>)
+
+    ; PLUS
+    (re.+ <R>)
+
+    ; Complement / Don't work
+    (re.comp <R>)
+    
+    ; Difference / Don't work
+    (re.diff <R> <R>)
+
+    (re.opt <R>)
+
+   )))
+)
+
+(define-fun w1() String "ee")
+
+(constraint (str.in_re  w1 phi))
+
+(define-fun n1() String "bbegre")
+(constraint (str.in_re n1 (re.comp  phi)))
+
+(check-synth)