Skip to content

Invalid Triggers via Subslicing #1030

Description

@ArquintL

The following program results in a Viper encoding with invalid triggers.
In particular, the first two assert stmts have valid triggers while the latter two end up having invalid triggers.
It's however unclear to me why the end up being invalid as the difference (also in the encoding) is 1 vs i-1 and it seems that Viper does not like the subtraction.

package search

func foo() (r []int, i int) {
	r = make([]int, 10)
	i = 2

	// @ assert forall j int :: { r[1:][j] } 0 <= j && j < len(r[1:]) ==> &r[1:][j] == &r[1+j]
	// @ assert forall j int :: { &r[1:][j] } 0 <= j && j < len(r[1:]) ==> &r[1:][j] == &r[1+j]

	// @ assert forall j int :: { r[i-1:][j] } 0 <= j && j < len(r[i-1:]) ==> &r[i-1:][j] == &r[i-1+j]
	// @ assert forall j int :: { &r[i-1:][j] } 0 <= j && j < len(r[i-1:]) ==> &r[i-1:][j] == &r[i-1+j]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions