See answers inline below:
On Thu, Apr 30, 2020 at 11:55 PM Calvin Loncaric <
c.a.lo...@gmail.com> wrote:
>
> Sorry, I definitely didn't explain my question well.
>
>> as long as the axioms you write don't introduce a logical inconsistency, there should be no problem
>
>
> I am trying to figure out if one particular axiom in my tool could introduce a logical inconsistency. I want to axiomatize this second-order "array construction" primitive:
>
> (assert
> (forall ((f Function))
> (exists ((a Array))
> (forall ((i Int)) (= (select a i) (f i))))))
>
> This axiom is useful because it lets a programmer define all kinds of useful arrays, such as the "zero array" where every element is zero or the "identity array" where every element maps to itself.
>
> Smt-lib doesn't have first-class functions, so the "array construction" axiom has to be instantiated as needed. Specifically, when a programmer writes "makeArray(f)" in the tool, it gets translated into:
>
> (declare-const a Array)
> (assert (forall ((i Int)) (= (select a i) (f i))))
This seems very reasonable and should be fine, with one caveat - you
would need a fresh symbol "f" for each such array a, otherwise you
could indeed create an unexpected inconsistency.
> However, this approach leads to a big surprise! (Or at least, a surprise for me.) The surprise is that adding those two lines to define "a"---even when the array "a" is not used elsewhere---can flip the solver's result from SAT to UNSAT. Consider:
>
> (set-logic ALIA)
> (define-fun f ((x Int)) Int ...)
> ; (declare-const a (Array Int Int))
> ; (assert (forall ((i Int)) (= (select a i) (f i))))
> (assert (forall ((arr (Array Int Int))) (exists ((i Int)) (not (= (select arr i) (f i))))))
> (check-sat)
>
> If I am not mistaken, this query should be SAT without the commented lines, but UNSAT if they are included. I want to believe in my heart that my array construction axiom is true, but there is nothing in the smt-lib arrays theory that requires it.
That's correct, but why are you surprised? By adding an axiom, you
extend the theory (and thereby reduce the corresponding models), so
there will be some formulas that were satisfiable before but are not
any longer (specifically formulas that contradict your axiom as in the
example above).
> Question 1: How should my tool interpret the solver's output, when the mere mention of "makeArray" changes the solver's output? The answer, I think, is:
>
> UNSAT means UNSAT. Adding more "makeArray" terms does will not make the problem satisfiable.
That's right. Adding constraints can never make something UNSAT become SAT.
> SAT (from the solver) does not mean SAT (in the extended theory of the tool that includes my array construction axiom). SAT should be interpreted as "unknown". This makes sense: the tool believes in an array construction axiom that it is not able to communicate to the solver, so any model the solver finds may not satisfy the "hidden" array construction axiom.
Hmm, I don't think that is right. You *are* communicating the
relevant instances of your array construction axiom, so I think that
if you get SAT, it is really SAT. Even in the "extended theory of the
tool", you would just have one such axiom (with a unique function f)
for each array, and this should never introduce any inconsistency with
an existing formula, since the functions are fresh.
>
> Question 2: Does my array construction axiom create any inconsistencies? I have no idea how to approach this question. I think it does not, but I have no tools at my disposal to prove it.
Given any satisfiable formula, adding an instance of your axiom with a
fresh function symbol f cannot introduce an inconsistency. There is a
simple argument showing that a model for the first formula can be
extended to a model that includes f.
Hope that helps,
-Clark