func nextStateFunc(ds deltaState) nextstatefunc {
	res := func(state commands.State) commands.State {
		state.(*csState).nbPublicVariables += ds.nbPublicVariables
		state.(*csState).nbSecretVariables += ds.nbSecretVariables
		state.(*csState).nbInternalVariables += ds.nbInternalVariables
		state.(*csState).nbConstraints += ds.nbConstraints
		return state
	}
	return res
}
------------------------------------------------------------------------------
build the next state function using the delta state
package frontend
import (
	"math/big"
	"testing"
	"github.com/consensys/gnark-crypto/ecc"
	"github.com/consensys/gnark/backend"
	"github.com/leanovate/gopter"
	"github.com/leanovate/gopter/commands"
	"github.com/leanovate/gopter/gen"
)
var variableName big.Int
type csState struct {
	nbPublicVariables   int
	nbSecretVariables   int
	nbInternalVariables int
	nbConstraints       int
}
type deltaState = csState
type csResult struct {
	cs                *ConstraintSystem  
	publicVariables   []Variable         
	secretVariables   []Variable         
	internalVariables []Variable         
}
type runfunc func(systemUnderTest commands.SystemUnderTest) commands.Result
type nextstatefunc func(state commands.State) commands.State
func incVariableName() {
	variableName.Add(&variableName, new(big.Int).SetUint64(1))
}
func buildProtoCommands(name string, rf runfunc, ns nextstatefunc) *commands.ProtoCommand {
	return &commands.ProtoCommand{
		Name:              name,
		RunFunc:           rf,
		NextStateFunc:     ns,
		PostConditionFunc: postConditionAPI,
	}
}
func checkPublicVariables(csRes csResult) bool {
	for i, args := range csRes.publicVariables {
		expectedID := len(csRes.cs.public.variables) - len(csRes.publicVariables) + i
		if args.val != nil || args.id != expectedID {
			return false
		}
	}
	return true
}
func checkSecretVariables(csRes csResult) bool {
	for i, args := range csRes.secretVariables {
		expectedID := len(csRes.cs.secret.variables) - len(csRes.secretVariables) + i
		if args.val != nil || args.id != expectedID {
			return false
		}
	}
	return true
}
func postConditionAPI(state commands.State, result commands.Result) *gopter.PropResult {
	st := state.(*csState)
	csRes := result.(csResult)
	var witness bool
	witness = checkPublicVariables(csRes)
	if !witness {
		return &gopter.PropResult{Status: gopter.PropFalse}
	}
	witness = checkSecretVariables(csRes)
	if !witness {
		return &gopter.PropResult{Status: gopter.PropFalse}
	}
	if len(csRes.cs.public.variables) != st.nbPublicVariables ||
		len(csRes.cs.secret.variables) != st.nbSecretVariables ||
		len(csRes.cs.internal.variables) != st.nbInternalVariables ||
		len(csRes.cs.constraints) != st.nbConstraints {
		return &gopter.PropResult{Status: gopter.PropFalse}
	}
	return &gopter.PropResult{Status: gopter.PropTrue}
}
func rfAddSub() runfunc {
	res := func(systemUnderTest commands.SystemUnderTest) commands.Result {
		pVariablesCreated := make([]Variable, 0)
		sVariablesCreated := make([]Variable, 0)
		iVariablesCreated := make([]Variable, 0)
		a := systemUnderTest.(*ConstraintSystem).newPublicVariable()
		pVariablesCreated = append(pVariablesCreated, a)
		incVariableName()
		b := systemUnderTest.(*ConstraintSystem).newSecretVariable()
		sVariablesCreated = append(sVariablesCreated, b)
		incVariableName()
		c := systemUnderTest.(*ConstraintSystem).newSecretVariable()
		sVariablesCreated = append(sVariablesCreated, c)
		incVariableName()
		u := systemUnderTest.(*ConstraintSystem).Add(a, b, 3, 4)
		v := systemUnderTest.(*ConstraintSystem).Sub(u, c)
		systemUnderTest.(*ConstraintSystem).Sub(v, 3)
		systemUnderTest.(*ConstraintSystem).Sub(3, v)
		systemUnderTest.(*ConstraintSystem).Sub(4, 3)
		csRes := csResult{
			systemUnderTest.(*ConstraintSystem),
			pVariablesCreated,
			sVariablesCreated,
			iVariablesCreated}
		return csRes
	}
	return res
}
var nsAddSub = deltaState{1, 2, 0, 0}  
func rfMul() runfunc {
	res := func(systemUnderTest commands.SystemUnderTest) commands.Result {
		pVariablesCreated := make([]Variable, 0)
		sVariablesCreated := make([]Variable, 0)
		iVariablesCreated := make([]Variable, 0)
		a := systemUnderTest.(*ConstraintSystem).newPublicVariable()
		incVariableName()
		pVariablesCreated = append(pVariablesCreated, a)
		b := systemUnderTest.(*ConstraintSystem).newSecretVariable()
		incVariableName()
		sVariablesCreated = append(sVariablesCreated, b)
		c := systemUnderTest.(*ConstraintSystem).Mul(a, b, 3, 4, 5)
		iVariablesCreated = append(iVariablesCreated, c)
		csRes := csResult{
			systemUnderTest.(*ConstraintSystem),
			pVariablesCreated,
			sVariablesCreated,
			iVariablesCreated}
		return csRes
	}
	return res
}
var nsMul = csState{1, 1, 1, 1}
func rfInverse() runfunc {
	res := func(systemUnderTest commands.SystemUnderTest) commands.Result {
		pVariablesCreated := make([]Variable, 0)
		sVariablesCreated := make([]Variable, 0)
		iVariablesCreated := make([]Variable, 0)
		a := systemUnderTest.(*ConstraintSystem).newPublicVariable()
		incVariableName()
		pVariablesCreated = append(pVariablesCreated, a)
		v := systemUnderTest.(*ConstraintSystem).Inverse(a)
		iVariablesCreated = append(iVariablesCreated, v)
		csRes := csResult{
			systemUnderTest.(*ConstraintSystem),
			pVariablesCreated,
			sVariablesCreated,
			iVariablesCreated}
		return csRes
	}
	return res
}
var nsInverse = deltaState{1, 0, 1, 1}
func rfDiv() runfunc {
	res := func(systemUnderTest commands.SystemUnderTest) commands.Result {
		pVariablesCreated := make([]Variable, 0)
		sVariablesCreated := make([]Variable, 0)
		iVariablesCreated := make([]Variable, 0)
		a := systemUnderTest.(*ConstraintSystem).newPublicVariable()
		incVariableName()
		pVariablesCreated = append(pVariablesCreated, a)
		b := systemUnderTest.(*ConstraintSystem).newSecretVariable()
		incVariableName()
		sVariablesCreated = append(sVariablesCreated, b)
		u := systemUnderTest.(*ConstraintSystem).Div(a, b)
		iVariablesCreated = append(iVariablesCreated, u)
		v := systemUnderTest.(*ConstraintSystem).Div(a, 3)
		iVariablesCreated = append(iVariablesCreated, v)
		w := systemUnderTest.(*ConstraintSystem).Div(3, a)
		iVariablesCreated = append(iVariablesCreated, w)
		x := systemUnderTest.(*ConstraintSystem).Div(3, 3)
		iVariablesCreated = append(iVariablesCreated, x)
		csRes := csResult{
			systemUnderTest.(*ConstraintSystem),
			pVariablesCreated,
			sVariablesCreated,
			iVariablesCreated}
		return csRes
	}
	return res
}
var nsDiv = deltaState{1, 1, 4, 4}
func rfXor() runfunc {
	res := func(systemUnderTest commands.SystemUnderTest) commands.Result {
		pVariablesCreated := make([]Variable, 0)
		sVariablesCreated := make([]Variable, 0)
		iVariablesCreated := make([]Variable, 0)
		a := systemUnderTest.(*ConstraintSystem).newPublicVariable()
		incVariableName()
		pVariablesCreated = append(pVariablesCreated, a)
		b := systemUnderTest.(*ConstraintSystem).newSecretVariable()
		incVariableName()
		sVariablesCreated = append(sVariablesCreated, b)
		v := systemUnderTest.(*ConstraintSystem).Xor(a, b)
		iVariablesCreated = append(iVariablesCreated, v)
		csRes := csResult{
			systemUnderTest.(*ConstraintSystem),
			pVariablesCreated,
			sVariablesCreated,
			iVariablesCreated}
		return csRes
	}
	return res
}
var nsXor = deltaState{1, 1, 1, 3}
func rfToBinary() runfunc {
	res := func(systemUnderTest commands.SystemUnderTest) commands.Result {
		pVariablesCreated := make([]Variable, 0)
		sVariablesCreated := make([]Variable, 0)
		a := systemUnderTest.(*ConstraintSystem).newPublicVariable()
		incVariableName()
		pVariablesCreated = append(pVariablesCreated, a)
		iVariablesCreated := systemUnderTest.(*ConstraintSystem).ToBinary(a, 256)
		csRes := csResult{
			systemUnderTest.(*ConstraintSystem),
			pVariablesCreated,
			sVariablesCreated,
			iVariablesCreated}
		return csRes
	}
	return res
}
var nsToBinary = deltaState{1, 0, 256, 257}
func rfSelect() runfunc {
	res := func(systemUnderTest commands.SystemUnderTest) commands.Result {
		pVariablesCreated := make([]Variable, 0)
		sVariablesCreated := make([]Variable, 0)
		iVariablesCreated := make([]Variable, 0)
		a := systemUnderTest.(*ConstraintSystem).newPublicVariable()
		incVariableName()
		pVariablesCreated = append(pVariablesCreated, a)
		b := systemUnderTest.(*ConstraintSystem).newSecretVariable()
		incVariableName()
		sVariablesCreated = append(sVariablesCreated, b)
		c := systemUnderTest.(*ConstraintSystem).newSecretVariable()
		incVariableName()
		sVariablesCreated = append(sVariablesCreated, c)
		u := systemUnderTest.(*ConstraintSystem).Select(a, b, c)
		iVariablesCreated = append(iVariablesCreated, u)
		v := systemUnderTest.(*ConstraintSystem).Select(a, 3, c)
		iVariablesCreated = append(iVariablesCreated, v)
		w := systemUnderTest.(*ConstraintSystem).Select(a, b, 3)
		iVariablesCreated = append(iVariablesCreated, w)
		systemUnderTest.(*ConstraintSystem).Select(a, 3, 3)
		csRes := csResult{
			systemUnderTest.(*ConstraintSystem),
			pVariablesCreated,
			sVariablesCreated,
			iVariablesCreated}
		return csRes
	}
	return res
}
var nsSelect = deltaState{1, 2, 3, 4}
func rfConstant() runfunc {
	res := func(systemUnderTest commands.SystemUnderTest) commands.Result {
		pVariablesCreated := make([]Variable, 0)
		sVariablesCreated := make([]Variable, 0)
		iVariablesCreated := make([]Variable, 0)
		a := systemUnderTest.(*ConstraintSystem).newPublicVariable()
		incVariableName()
		pVariablesCreated = append(pVariablesCreated, a)
		systemUnderTest.(*ConstraintSystem).Constant(a)
		systemUnderTest.(*ConstraintSystem).Constant(3)
		csRes := csResult{
			systemUnderTest.(*ConstraintSystem),
			pVariablesCreated,
			sVariablesCreated,
			iVariablesCreated}
		return csRes
	}
	return res
}
var nsConstant = deltaState{1, 0, 0, 0}
func rfIsEqual() runfunc {
	res := func(systemUnderTest commands.SystemUnderTest) commands.Result {
		pVariablesCreated := make([]Variable, 0)
		sVariablesCreated := make([]Variable, 0)
		iVariablesCreated := make([]Variable, 0)
		a := systemUnderTest.(*ConstraintSystem).newPublicVariable()
		incVariableName()
		pVariablesCreated = append(pVariablesCreated, a)
		b := systemUnderTest.(*ConstraintSystem).newSecretVariable()
		incVariableName()
		sVariablesCreated = append(sVariablesCreated, b)
		systemUnderTest.(*ConstraintSystem).AssertIsEqual(a, b)
		u := systemUnderTest.(*ConstraintSystem).Add(a, b)
		v := systemUnderTest.(*ConstraintSystem).Mul(a, 3)
		systemUnderTest.(*ConstraintSystem).AssertIsEqual(u, v)
		csRes := csResult{
			systemUnderTest.(*ConstraintSystem),
			pVariablesCreated,
			sVariablesCreated,
			iVariablesCreated}
		return csRes
	}
	return res
}
var nsIsEqual = deltaState{1, 1, 0, 2}
func rfFromBinary() runfunc {
	res := func(systemUnderTest commands.SystemUnderTest) commands.Result {
		pVariablesCreated := make([]Variable, 256)
		sVariablesCreated := make([]Variable, 0)
		iVariablesCreated := make([]Variable, 0)
		for i := 0; i < 256; i++ {
			pVariablesCreated[i] = systemUnderTest.(*ConstraintSystem).newPublicVariable()
			incVariableName()
		}
		systemUnderTest.(*ConstraintSystem).FromBinary(pVariablesCreated...)
		csRes := csResult{
			systemUnderTest.(*ConstraintSystem),
			pVariablesCreated,
			sVariablesCreated,
			iVariablesCreated}
		return csRes
	}
	return res
}
var nsFromBinary = deltaState{256, 0, 0, 256}
func rfIsBoolean() runfunc {
	res := func(systemUnderTest commands.SystemUnderTest) commands.Result {
		pVariablesCreated := make([]Variable, 0)
		sVariablesCreated := make([]Variable, 0)
		iVariablesCreated := make([]Variable, 0)
		a := systemUnderTest.(*ConstraintSystem).newPublicVariable()
		incVariableName()
		pVariablesCreated = append(pVariablesCreated, a)
		b := systemUnderTest.(*ConstraintSystem).newSecretVariable()
		incVariableName()
		sVariablesCreated = append(sVariablesCreated, b)
		systemUnderTest.(*ConstraintSystem).AssertIsBoolean(a)
		systemUnderTest.(*ConstraintSystem).AssertIsBoolean(a)
		systemUnderTest.(*ConstraintSystem).AssertIsBoolean(b)
		systemUnderTest.(*ConstraintSystem).AssertIsBoolean(b)
		csRes := csResult{
			systemUnderTest.(*ConstraintSystem),
			pVariablesCreated,
			sVariablesCreated,
			iVariablesCreated}
		return csRes
	}
	return res
}
var nsIsBoolean = deltaState{1, 1, 0, 2}
var nsMustBeLessOrEqVar = deltaState{1, 1, 1281, 1539}
var nsMustBeLessOrEqConst = csState{1, 0, 257, 513}  