Skip to content
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

Possible scoping issue #1

Open
ibnyusuf opened this issue Jun 2, 2021 · 3 comments
Open

Possible scoping issue #1

ibnyusuf opened this issue Jun 2, 2021 · 3 comments
Assignees
Labels
help wanted Extra attention is needed invalid This doesn't seem right

Comments

@ibnyusuf
Copy link
Member

ibnyusuf commented Jun 2, 2021

Consider the following while program:

func main() {

  Int a = 2;
  if(a > 0){
    Int b = 3;
  }  else {
    skip;
  } 
}

(conjecture
    (= (b main_end) 3) 
)

My assumption is that the variable b should be local to the if block and therefore, the conjecture should not be provable as it refers to b outside of the scope in which it is defined. However, this is not the case. The translation to SMT is:

; {
;    a = 2 @l3
;    if (a > 0) @l4
;    {
;       b = 3 @l5
;    }
;    else
;    {
;       skip @l7
;    }
; }
; 

(set-logic UFDTLIA)

(declare-nat Nat zero s p Sub)
(declare-sort Time 0)
(declare-sort Trace 0)
(declare-fun to-int (Nat) Int)
(declare-fun a (Time) Int)
(declare-fun b (Time) Int)
(declare-const l3 Time)
(declare-const l4 Time)
(declare-const l5 Time)
(declare-const l7 Time)
(declare-const main_end Time)
(declare-const t1 Trace)
(declare-const tp Time)

; Axiom: Semantics of function main
(assert
   ;Semantics of IfElse at location l4
   (and
      ;Semantics of left branch
      (=>
         (> 2 0)
         (= (b main_end) 3)
      )
      ;Semantics of right branch
      (=>
         (not
            (> 2 0)
         )
         (= (b main_end) (b l7))
      )
   )
)

; Conjecture: user-conjecture-0
(assert-not
   (= (b main_end) 3)
)

(check-sat)

Which is easily refutable by Vampire

@ibnyusuf ibnyusuf added help wanted Extra attention is needed invalid This doesn't seem right labels Jun 2, 2021
@ibnyusuf
Copy link
Member Author

ibnyusuf commented Jun 2, 2021

All program variables are global no matter where they are defined.

@ibnyusuf ibnyusuf closed this as completed Jun 2, 2021
@selig
Copy link

selig commented Jun 2, 2021 via email

@ibnyusuf
Copy link
Member Author

ibnyusuf commented Jun 17, 2021

I am reopening this. It appears that variables in While are scoped. For example, the following program results in a parse error:

func main() {
  const Int c = 5;
  Int d = 2;
  while(d < 0){
     Int e = 1;
     d = d - 1;
     if(d >0){
        skip;
     } else {
        skip;
     }
  }
  e = 1;
}

(conjecture
    (= (value_int main_end c) 5)  
)

The issue, it seems, is that we don't check that variables in the conjecture are only referenced at points at which they are in scope.

@ibnyusuf ibnyusuf reopened this Jun 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

3 participants