-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added array literal creation to API and implementation #367
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,6 +46,15 @@ protected <TI extends Formula, TE extends Formula> Term internalMakeArray( | |
return getFormulaCreator().makeVariable(cvc5ArrayType, pName); | ||
} | ||
|
||
@Override | ||
protected <TI extends Formula, TE extends Formula> Term internalMakeArray( | ||
Term elseElem, FormulaType<TI> pIndexType, FormulaType<TE> pElementType) { | ||
final ArrayFormulaType<TI, TE> arrayFormulaType = | ||
FormulaType.getArrayType(pIndexType, pElementType); | ||
final Sort cvc5ArrayType = toSolverType(arrayFormulaType); | ||
return solver.mkConstArray(cvc5ArrayType, elseElem); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I took this part of the code and merged it to master. |
||
|
||
@Override | ||
protected Term equivalence(Term pArray1, Term pArray2) { | ||
return solver.mkTerm(Kind.EQUAL, pArray1, pArray2); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
|
||
package org.sosy_lab.java_smt.solvers.mathsat5; | ||
|
||
import static org.sosy_lab.java_smt.solvers.mathsat5.Mathsat5NativeApi.msat_make_array_const; | ||
import static org.sosy_lab.java_smt.solvers.mathsat5.Mathsat5NativeApi.msat_make_array_read; | ||
import static org.sosy_lab.java_smt.solvers.mathsat5.Mathsat5NativeApi.msat_make_array_write; | ||
import static org.sosy_lab.java_smt.solvers.mathsat5.Mathsat5NativeApi.msat_make_equal; | ||
|
@@ -48,6 +49,15 @@ protected <TI extends Formula, TE extends Formula> Long internalMakeArray( | |
return getFormulaCreator().makeVariable(mathsatArrayType, pName); | ||
} | ||
|
||
@Override | ||
protected <TI extends Formula, TE extends Formula> Long internalMakeArray( | ||
Long elseElem, FormulaType<TI> pIndexType, FormulaType<TE> pElementType) { | ||
final ArrayFormulaType<TI, TE> arrayFormulaType = | ||
FormulaType.getArrayType(pIndexType, pElementType); | ||
final Long mathsatArrayType = toSolverType(arrayFormulaType); | ||
return msat_make_array_const(mathsatEnv, mathsatArrayType, elseElem); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I took this part of the code and merged it to master. |
||
|
||
@Override | ||
protected Long equivalence(Long pArray1, Long pArray2) { | ||
return msat_make_equal(mathsatEnv, pArray1, pArray2); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
package org.sosy_lab.java_smt.solvers.z3; | ||
|
||
import com.microsoft.z3.Native; | ||
import java.util.List; | ||
import org.sosy_lab.java_smt.api.Formula; | ||
import org.sosy_lab.java_smt.api.FormulaType; | ||
import org.sosy_lab.java_smt.api.FormulaType.ArrayFormulaType; | ||
|
@@ -45,6 +46,22 @@ protected <TI extends Formula, TE extends Formula> Long internalMakeArray( | |
return getFormulaCreator().makeVariable(z3ArrayType, pName); | ||
} | ||
|
||
@Override | ||
protected <TI extends Formula, TE extends Formula> Long internalMakeArray( | ||
FormulaType<TI> pIndexType, FormulaType<TE> pElementType) { | ||
long func = | ||
getFormulaCreator() | ||
.declareUFImpl( | ||
"__unnamed_arr", toSolverType(pElementType), List.of(toSolverType(pIndexType))); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this extra UF really necessary? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't see another way of creating a non-initialized array literal. I added some extra tests to verify that these do not create problems with e.g. vars with the same name. It turns out that only Z3 works well with such literals (without a default value), and only Z3, MathSAT and CVC5 work with initialized literals. |
||
return Native.mkAsArray(z3context, func); | ||
} | ||
|
||
@Override | ||
protected <TI extends Formula, TE extends Formula> Long internalMakeArray( | ||
Long elseElem, FormulaType<TI> pIndexType, FormulaType<TE> pElementType) { | ||
return Native.mkConstArray(z3context, toSolverType(pIndexType), elseElem); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I took this part of the code and merged it to master. |
||
|
||
@Override | ||
protected Long equivalence(Long pArray1, Long pArray2) { | ||
return Native.mkEq(z3context, pArray1, pArray2); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please do not change basic project files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah sorry, I didn't pay attention when adding files to the commit (and IntelliJ is adamant on changing these all the time..)