text: import unittest
  from fractions import Fraction
  
  from cozy.syntax import *
  from cozy.target_syntax import *
  from cozy.value_types import *
  from cozy.contexts import RootCtx
  from cozy.solver import ExtractedFunc, solver_for_context
  from cozy.structures.treemultiset import *
  from cozy.random_assignment import *
  
  tests = [
     (EBinOp(EBinOp(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), '+', ESingleton(EVar('n').with_type(TInt())).with_type(TBag(TInt()))).with_type(TBag(TInt())), '-', EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt()))).with_type(TBag(TInt())), EEmptyList().with_type(TBag(TInt())), {'l': Bag(()), 'n': 0}),
     (EBinOp(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), '-', EBinOp(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), '-', ESingleton(EVar('n').with_type(TInt())).with_type(TBag(TInt()))).with_type(TBag(TInt()))).with_type(TBag(TInt())), EBinOp(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), '-', EBinOp(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), '-', ESingleton(ENum(0).with_type(TInt())).with_type(TBag(TInt()))).with_type(TBag(TInt()))).with_type(TBag(TInt())), {'l': Bag((0, 3, 2)), 'n': 2}),
     (EBinOp(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), '-', EBinOp(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), '-', ESingleton(EVar('n').with_type(TInt())).with_type(TBag(TInt()))).with_type(TBag(TInt()))).with_type(TBag(TInt())), ESingleton(EVar('n').with_type(TInt())).with_type(TBag(TInt())), {'l': Bag(()), 'n': 0}),
     (ECond(EHasKey(EStateVar(EMakeMap2(EVar('l').with_type(TBag(TInt())), ELambda(EVar('_var427').with_type(TInt()), EBool(True).with_type(TBool()))).with_type(TMap(TInt(), TBool()))).with_type(TMap(TInt(), TBool())), EVar('n').with_type(TInt())).with_type(TBool()), ESingleton(EVar('n').with_type(TInt())).with_type(TBag(TInt())), EEmptyList().with_type(TBag(TInt()))).with_type(TBag(TInt())), ECond(EUnaryOp('exists', EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt()))).with_type(TBool()), ESingleton(EVar('n').with_type(TInt())).with_type(TBag(TInt())), EEmptyList().with_type(TBag(TInt()))).with_type(TBag(TInt())), {'l': Bag((3,)), 'n': 2}),
     (EBinOp(EMapKeys(EStateVar(EMakeMap2(EVar('l').with_type(TBag(TInt())), ELambda(EVar('_var427').with_type(TInt()), EBool(True).with_type(TBool()))).with_type(TMap(TInt(), TBool()))).with_type(TMap(TInt(), TBool()))).with_type(TBag(TInt())), '-', EUnaryOp('distinct', EBinOp(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), '-', ESingleton(EVar('n').with_type(TInt())).with_type(TBag(TInt()))).with_type(TBag(TInt()))).with_type(TBag(TInt()))).with_type(TBag(TInt())), EBinOp(EMapKeys(EStateVar(EMakeMap2(EVar('l').with_type(TBag(TInt())), ELambda(EVar('_var427').with_type(TInt()), EBool(True).with_type(TBool()))).with_type(TMap(TInt(), TBool()))).with_type(TMap(TInt(), TBool()))).with_type(TBag(TInt())), '-', EUnaryOp('distinct', EBinOp(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), '-', ESingleton(ENum(0).with_type(TInt())).with_type(TBag(TInt()))).with_type(TBag(TInt()))).with_type(TBag(TInt()))).with_type(TBag(TInt())), {'l': Bag((0, 3)), 'n': 3}),
     (EBinOp(EMapKeys(EStateVar(EMakeMap2(EVar('l').with_type(TBag(TInt())), ELambda(EVar('_var427').with_type(TInt()), EBool(True).with_type(TBool()))).with_type(TMap(TInt(), TBool()))).with_type(TMap(TInt(), TBool()))).with_type(TBag(TInt())), '-', EUnaryOp('distinct', EBinOp(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), '-', ESingleton(EVar('n').with_type(TInt())).with_type(TBag(TInt()))).with_type(TBag(TInt()))).with_type(TBag(TInt()))).with_type(TBag(TInt())), EBinOp(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), '-', EUnaryOp('distinct', EBinOp(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), '-', ESingleton(EVar('n').with_type(TInt())).with_type(TBag(TInt()))).with_type(TBag(TInt()))).with_type(TBag(TInt()))).with_type(TBag(TInt())), {'l': Bag((2, 2)), 'n': 2}),
     (EFilter(EUnaryOp('distinct', EBinOp(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), '+', ESingleton(EVar('n').with_type(TInt())).with_type(TBag(TInt()))).with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var484').with_type(TInt()), EBinOp(EUnaryOp('not', EHasKey(EStateVar(EMakeMap2(EVar('l').with_type(TBag(TInt())), ELambda(EVar('_var427').with_type(TInt()), EBool(True).with_type(TBool()))).with_type(TMap(TInt(), TBool()))).with_type(TMap(TInt(), TBool())), EVar('_var484').with_type(TInt())).with_type(TBool())).with_type(TBool()), 'or', EUnaryOp('not', ECond(EBinOp(EVar('_var484').with_type(TInt()), 'in', EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt()))).with_type(TBool()), ECond(EBinOp(EBool(True).with_type(TBool()), 'or', EBinOp(EVar('_var484').with_type(TInt()), 'in', ESingleton(EVar('n').with_type(TInt())).with_type(TBag(TInt()))).with_type(TBool())).with_type(TBool()), EBool(True).with_type(TBool()), EBinOp(EBool(True).with_type(TBool()), '==', EBool(False).with_type(TBool())).with_type(TBool())).with_type(TBool()), EBinOp(EUnaryOp('not', EBinOp(EBool(False).with_type(TBool()), 'or', EBinOp(EVar('_var484').with_type(TInt()), 'in', ESingleton(EVar('n').with_type(TInt())).with_type(TBag(TInt()))).with_type(TBool())).with_type(TBool())).with_type(TBool()), 'or', EBinOp(EBool(False).with_type(TBool()), '==', EBool(True).with_type(TBool())).with_type(TBool())).with_type(TBool())).with_type(TBool())).with_type(TBool())).with_type(TBool()))).with_type(TBag(TInt())), EFilter(EUnaryOp('distinct', EBinOp(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), '+', ESingleton(ENum(0).with_type(TInt())).with_type(TBag(TInt()))).with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var484').with_type(TInt()), EBinOp(EUnaryOp('not', EHasKey(EStateVar(EMakeMap2(EVar('l').with_type(TBag(TInt())), ELambda(EVar('_var427').with_type(TInt()), EBool(True).with_type(TBool()))).with_type(TMap(TInt(), TBool()))).with_type(TMap(TInt(), TBool())), EVar('_var484').with_type(TInt())).with_type(TBool())).with_type(TBool()), 'or', EUnaryOp('not', ECond(EBinOp(EVar('_var484').with_type(TInt()), 'in', EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt()))).with_type(TBool()), ECond(EBinOp(EBool(True).with_type(TBool()), 'or', EBinOp(EVar('_var484').with_type(TInt()), 'in', ESingleton(EVar('n').with_type(TInt())).with_type(TBag(TInt()))).with_type(TBool())).with_type(TBool()), EBool(True).with_type(TBool()), EBinOp(EBool(True).with_type(TBool()), '==', EBool(False).with_type(TBool())).with_type(TBool())).with_type(TBool()), EBinOp(EUnaryOp('not', EBinOp(EBool(False).with_type(TBool()), 'or', EBinOp(EVar('_var484').with_type(TInt()), 'in', ESingleton(EVar('n').with_type(TInt())).with_type(TBag(TInt()))).with_type(TBool())).with_type(TBool())).with_type(TBool()), 'or', EBinOp(EBool(False).with_type(TBool()), '==', EBool(True).with_type(TBool())).with_type(TBool())).with_type(TBool())).with_type(TBool())).with_type(TBool())).with_type(TBool()))).with_type(TBag(TInt())), {'l': Bag((3, 2)), 'n': 2}),
     (EFilter(EUnaryOp('distinct', EBinOp(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), '+', ESingleton(EVar('n').with_type(TInt())).with_type(TBag(TInt()))).with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var484').with_type(TInt()), EBinOp(EUnaryOp('not', EHasKey(EStateVar(EMakeMap2(EVar('l').with_type(TBag(TInt())), ELambda(EVar('_var427').with_type(TInt()), EBool(True).with_type(TBool()))).with_type(TMap(TInt(), TBool()))).with_type(TMap(TInt(), TBool())), EVar('_var484').with_type(TInt())).with_type(TBool())).with_type(TBool()), 'or', EUnaryOp('not', ECond(EBinOp(EVar('_var484').with_type(TInt()), 'in', EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt()))).with_type(TBool()), ECond(EBinOp(EBool(True).with_type(TBool()), 'or', EBinOp(EVar('_var484').with_type(TInt()), 'in', ESingleton(EVar('n').with_type(TInt())).with_type(TBag(TInt()))).with_type(TBool())).with_type(TBool()), EBool(True).with_type(TBool()), EBinOp(EBool(True).with_type(TBool()), '==', EBool(False).with_type(TBool())).with_type(TBool())).with_type(TBool()), EBinOp(EUnaryOp('not', EBinOp(EBool(False).with_type(TBool()), 'or', EBinOp(EVar('_var484').with_type(TInt()), 'in', ESingleton(EVar('n').with_type(TInt())).with_type(TBag(TInt()))).with_type(TBool())).with_type(TBool())).with_type(TBool()), 'or', EBinOp(EBool(False).with_type(TBool()), '==', EBool(True).with_type(TBool())).with_type(TBool())).with_type(TBool())).with_type(TBool())).with_type(TBool())).with_type(TBool()))).with_type(TBag(TInt())), EEmptyList().with_type(TBag(TInt())), {'l': Bag(()), 'n': 0}),
     (EFilter(EFilter(EMapKeys(EStateVar(EMakeMap2(EVar('l').with_type(TBag(TInt())), ELambda(EVar('_var427').with_type(TInt()), EBool(True).with_type(TBool()))).with_type(TMap(TInt(), TBool()))).with_type(TMap(TInt(), TBool()))).with_type(TBag(TInt())), ELambda(EVar('_var2266').with_type(TInt()), EBinOp(EVar('_var2266').with_type(TInt()), '==', EVar('n').with_type(TInt())).with_type(TBool()))).with_type(TBag(TInt())), ELambda(EVar('_var2266').with_type(TInt()), EBinOp(EMapGet(EStateVar(EMakeMap2(EVar('l').with_type(TBag(TInt())), ELambda(EVar('_var2267').with_type(TInt()), EUnaryOp('len', EFilter(EVar('l').with_type(TBag(TInt())), ELambda(EVar('_var2268').with_type(TInt()), EBinOp(EVar('_var2267').with_type(TInt()), '==', EVar('_var2268').with_type(TInt())).with_type(TBool()))).with_type(TBag(TInt()))).with_type(TInt()))).with_type(TMap(TInt(), TInt()))).with_type(TMap(TInt(), TInt())), EVar('_var2266').with_type(TInt())).with_type(TInt()), '<=', ENum(1).with_type(TInt())).with_type(TBool()))).with_type(TBag(TInt())), EFilter(ESingleton(EVar('n').with_type(TInt())).with_type(TBag(TInt())), ELambda(EVar('_var2266').with_type(TInt()), EBinOp(EMapGet(EStateVar(EMakeMap2(EVar('l').with_type(TBag(TInt())), ELambda(EVar('_var2267').with_type(TInt()), EUnaryOp('len', EFilter(EVar('l').with_type(TBag(TInt())), ELambda(EVar('_var2268').with_type(TInt()), EBinOp(EVar('_var2267').with_type(TInt()), '==', EVar('_var2268').with_type(TInt())).with_type(TBool()))).with_type(TBag(TInt()))).with_type(TInt()))).with_type(TMap(TInt(), TInt()))).with_type(TMap(TInt(), TInt())), EVar('_var2266').with_type(TInt())).with_type(TInt()), '<=', ENum(1).with_type(TInt())).with_type(TBool()))).with_type(TBag(TInt())), {'l': Bag(()), 'n': 0}),
     (EMapGet(EMakeMap2(EBinOp(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), '-', ESingleton(EVar('n').with_type(TInt())).with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var2267').with_type(TInt()), EUnaryOp('len', EFilter(EBinOp(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), '-', ESingleton(EVar('n').with_type(TInt())).with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var2268').with_type(TInt()), EBinOp(EVar('_var2267').with_type(TInt()), '==', EVar('_var2268').with_type(TInt())).with_type(TBool()))).with_type(TBag(TInt()))).with_type(TInt()))).with_type(TMap(TInt(), TInt())), EVar('_var6084').with_type(TInt())).with_type(TInt()), ENum(0).with_type(TInt()), {'l': Bag((3, 3)), 'n': 3, '_var6084': 3, '_var6085': 2}),
     (EMapGet(EMakeMap2(EBinOp(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), '+', ESingleton(EVar('n').with_type(TInt())).with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var2267').with_type(TInt()), EUnaryOp('len', EFilter(EBinOp(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), '+', ESingleton(EVar('n').with_type(TInt())).with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var2268').with_type(TInt()), EBinOp(EVar('_var2267').with_type(TInt()), '==', EVar('_var2268').with_type(TInt())).with_type(TBool()))).with_type(TBag(TInt()))).with_type(TInt()))).with_type(TMap(TInt(), TInt())), EVar('_var2779').with_type(TInt())).with_type(TInt()), ENum(0).with_type(TInt()), {'l': Bag((4, 4, 5, 6)), 'n': 4, '_var2779': 4, '_var2780': 2}),
     (EMapGet(EMakeMap2(EBinOp(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), '-', ESingleton(EVar('n').with_type(TInt())).with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var2267').with_type(TInt()), EUnaryOp('len', EFilter(EBinOp(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), '-', ESingleton(EVar('n').with_type(TInt())).with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var2268').with_type(TInt()), EBinOp(EVar('_var2267').with_type(TInt()), '==', EVar('_var2268').with_type(TInt())).with_type(TBool()))).with_type(TBag(TInt()))).with_type(TInt()))).with_type(TMap(TInt(), TInt())), EVar('_var6084').with_type(TInt())).with_type(TInt()), ENum(1).with_type(TInt()), {'l': Bag((2, 2, 2, 2)), 'n': 2, '_var6084': 2, '_var6085': 4}),
     (EFilter(EMapKeys(EMakeMap2(EBinOp(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), '-', ESingleton(EVar('n').with_type(TInt())).with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var2267').with_type(TInt()), EUnaryOp('len', EFilter(EBinOp(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), '-', ESingleton(EVar('n').with_type(TInt())).with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var2268').with_type(TInt()), EBinOp(EVar('_var2267').with_type(TInt()), '==', EVar('_var2268').with_type(TInt())).with_type(TBool()))).with_type(TBag(TInt()))).with_type(TInt()))).with_type(TMap(TInt(), TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var6084').with_type(TInt()), EBinOp(EUnaryOp('not', EHasKey(EStateVar(EMakeMap2(EVar('l').with_type(TBag(TInt())), ELambda(EVar('_var2267').with_type(TInt()), EUnaryOp('len', EFilter(EVar('l').with_type(TBag(TInt())), ELambda(EVar('_var2268').with_type(TInt()), EBinOp(EVar('_var2267').with_type(TInt()), '==', EVar('_var2268').with_type(TInt())).with_type(TBool()))).with_type(TBag(TInt()))).with_type(TInt()))).with_type(TMap(TInt(), TInt()))).with_type(TMap(TInt(), TInt())), EVar('_var6084').with_type(TInt())).with_type(TBool())).with_type(TBool()), 'or', EUnaryOp('not', ECond(EBinOp(EVar('_var6084').with_type(TInt()), 'in', EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt()))).with_type(TBool()), EBinOp(EUnaryOp('len', EFilter(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var2268').with_type(TInt()), EBinOp(EVar('_var6084').with_type(TInt()), '==', EVar('_var2268').with_type(TInt())).with_type(TBool()))).with_type(TBag(TInt()))).with_type(TInt()), '==', EMapGet(EMakeMap2(EBinOp(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), '-', ESingleton(EVar('n').with_type(TInt())).with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var2267').with_type(TInt()), EUnaryOp('len', EFilter(EBinOp(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), '-', ESingleton(EVar('n').with_type(TInt())).with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var2268').with_type(TInt()), EBinOp(EVar('_var2267').with_type(TInt()), '==', EVar('_var2268').with_type(TInt())).with_type(TBool()))).with_type(TBag(TInt()))).with_type(TInt()))).with_type(TMap(TInt(), TInt())), EVar('_var6084').with_type(TInt())).with_type(TInt())).with_type(TBool()), EBinOp(ENum(0).with_type(TInt()), '==', EMapGet(EMakeMap2(EBinOp(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), '-', ESingleton(EVar('n').with_type(TInt())).with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var2267').with_type(TInt()), EUnaryOp('len', EFilter(EBinOp(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), '-', ESingleton(EVar('n').with_type(TInt())).with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var2268').with_type(TInt()), EBinOp(EVar('_var2267').with_type(TInt()), '==', EVar('_var2268').with_type(TInt())).with_type(TBool()))).with_type(TBag(TInt()))).with_type(TInt()))).with_type(TMap(TInt(), TInt())), EVar('_var6084').with_type(TInt())).with_type(TInt())).with_type(TBool())).with_type(TBool())).with_type(TBool())).with_type(TBool()))).with_type(TBag(TInt())), EFilter(EMapKeys(EMakeMap2(EBinOp(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), '-', ESingleton(ENum(0).with_type(TInt())).with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var2267').with_type(TInt()), EUnaryOp('len', EFilter(EBinOp(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), '-', ESingleton(EVar('n').with_type(TInt())).with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var2268').with_type(TInt()), EBinOp(EVar('_var2267').with_type(TInt()), '==', EVar('_var2268').with_type(TInt())).with_type(TBool()))).with_type(TBag(TInt()))).with_type(TInt()))).with_type(TMap(TInt(), TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var6084').with_type(TInt()), EBinOp(EUnaryOp('not', EHasKey(EStateVar(EMakeMap2(EVar('l').with_type(TBag(TInt())), ELambda(EVar('_var2267').with_type(TInt()), EUnaryOp('len', EFilter(EVar('l').with_type(TBag(TInt())), ELambda(EVar('_var2268').with_type(TInt()), EBinOp(EVar('_var2267').with_type(TInt()), '==', EVar('_var2268').with_type(TInt())).with_type(TBool()))).with_type(TBag(TInt()))).with_type(TInt()))).with_type(TMap(TInt(), TInt()))).with_type(TMap(TInt(), TInt())), EVar('_var6084').with_type(TInt())).with_type(TBool())).with_type(TBool()), 'or', EUnaryOp('not', ECond(EBinOp(EVar('_var6084').with_type(TInt()), 'in', EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt()))).with_type(TBool()), EBinOp(EUnaryOp('len', EFilter(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var2268').with_type(TInt()), EBinOp(EVar('_var6084').with_type(TInt()), '==', EVar('_var2268').with_type(TInt())).with_type(TBool()))).with_type(TBag(TInt()))).with_type(TInt()), '==', EMapGet(EMakeMap2(EBinOp(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), '-', ESingleton(EVar('n').with_type(TInt())).with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var2267').with_type(TInt()), EUnaryOp('len', EFilter(EBinOp(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), '-', ESingleton(EVar('n').with_type(TInt())).with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var2268').with_type(TInt()), EBinOp(EVar('_var2267').with_type(TInt()), '==', EVar('_var2268').with_type(TInt())).with_type(TBool()))).with_type(TBag(TInt()))).with_type(TInt()))).with_type(TMap(TInt(), TInt())), EVar('_var6084').with_type(TInt())).with_type(TInt())).with_type(TBool()), EBinOp(ENum(0).with_type(TInt()), '==', EMapGet(EMakeMap2(EBinOp(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), '-', ESingleton(EVar('n').with_type(TInt())).with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var2267').with_type(TInt()), EUnaryOp('len', EFilter(EBinOp(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), '-', ESingleton(EVar('n').with_type(TInt())).with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var2268').with_type(TInt()), EBinOp(EVar('_var2267').with_type(TInt()), '==', EVar('_var2268').with_type(TInt())).with_type(TBool()))).with_type(TBag(TInt()))).with_type(TInt()))).with_type(TMap(TInt(), TInt())), EVar('_var6084').with_type(TInt())).with_type(TInt())).with_type(TBool())).with_type(TBool())).with_type(TBool())).with_type(TBool()))).with_type(TBag(TInt())), {'l': Bag((2, 3)), 'n': 2, '_var2267': 0}),
     (EFilter(EMapKeys(EMakeMap2(EBinOp(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), '-', ESingleton(EVar('n').with_type(TInt())).with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var2267').with_type(TInt()), EUnaryOp('len', EFilter(EBinOp(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), '-', ESingleton(EVar('n').with_type(TInt())).with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var2268').with_type(TInt()), EBinOp(EVar('_var2267').with_type(TInt()), '==', EVar('_var2268').with_type(TInt())).with_type(TBool()))).with_type(TBag(TInt()))).with_type(TInt()))).with_type(TMap(TInt(), TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var6084').with_type(TInt()), EBinOp(EUnaryOp('not', EHasKey(EStateVar(EMakeMap2(EVar('l').with_type(TBag(TInt())), ELambda(EVar('_var2267').with_type(TInt()), EUnaryOp('len', EFilter(EVar('l').with_type(TBag(TInt())), ELambda(EVar('_var2268').with_type(TInt()), EBinOp(EVar('_var2267').with_type(TInt()), '==', EVar('_var2268').with_type(TInt())).with_type(TBool()))).with_type(TBag(TInt()))).with_type(TInt()))).with_type(TMap(TInt(), TInt()))).with_type(TMap(TInt(), TInt())), EVar('_var6084').with_type(TInt())).with_type(TBool())).with_type(TBool()), 'or', EUnaryOp('not', ECond(EBinOp(EVar('_var6084').with_type(TInt()), 'in', EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt()))).with_type(TBool()), EBinOp(EUnaryOp('len', EFilter(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var2268').with_type(TInt()), EBinOp(EVar('_var6084').with_type(TInt()), '==', EVar('_var2268').with_type(TInt())).with_type(TBool()))).with_type(TBag(TInt()))).with_type(TInt()), '==', EMapGet(EMakeMap2(EBinOp(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), '-', ESingleton(EVar('n').with_type(TInt())).with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var2267').with_type(TInt()), EUnaryOp('len', EFilter(EBinOp(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), '-', ESingleton(EVar('n').with_type(TInt())).with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var2268').with_type(TInt()), EBinOp(EVar('_var2267').with_type(TInt()), '==', EVar('_var2268').with_type(TInt())).with_type(TBool()))).with_type(TBag(TInt()))).with_type(TInt()))).with_type(TMap(TInt(), TInt())), EVar('_var6084').with_type(TInt())).with_type(TInt())).with_type(TBool()), EBinOp(ENum(0).with_type(TInt()), '==', EMapGet(EMakeMap2(EBinOp(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), '-', ESingleton(EVar('n').with_type(TInt())).with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var2267').with_type(TInt()), EUnaryOp('len', EFilter(EBinOp(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), '-', ESingleton(EVar('n').with_type(TInt())).with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var2268').with_type(TInt()), EBinOp(EVar('_var2267').with_type(TInt()), '==', EVar('_var2268').with_type(TInt())).with_type(TBool()))).with_type(TBag(TInt()))).with_type(TInt()))).with_type(TMap(TInt(), TInt())), EVar('_var6084').with_type(TInt())).with_type(TInt())).with_type(TBool())).with_type(TBool())).with_type(TBool())).with_type(TBool()))).with_type(TBag(TInt())), EEmptyList().with_type(TBag(TInt())), {'l': Bag((2, 2, 3, 3)), 'n': 2, '_var2267': 0}),
     (EMapGet(ELet(EBinOp(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), '-', ESingleton(EVar('n').with_type(TInt())).with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var8978').with_type(TBag(TInt())), EMakeMap2(EVar('_var8978').with_type(TBag(TInt())), ELambda(EVar('_var2267').with_type(TInt()), EUnaryOp('len', EFilter(EVar('_var8978').with_type(TBag(TInt())), ELambda(EVar('_var2268').with_type(TInt()), EBinOp(EVar('_var2267').with_type(TInt()), '==', EVar('_var2268').with_type(TInt())).with_type(TBool()))).with_type(TBag(TInt()))).with_type(TInt()))).with_type(TMap(TInt(), TInt())))).with_type(TMap(TInt(), TInt())), EVar('_var6084').with_type(TInt())).with_type(TInt()), EMapGet(ELet(EBinOp(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), '-', ESingleton(EVar('n').with_type(TInt())).with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var8978').with_type(TBag(TInt())), EMakeMap2(EVar('_var8978').with_type(TBag(TInt())), ELambda(EVar('_var2267').with_type(TInt()), EUnaryOp('len', EVar('_var8978').with_type(TBag(TInt()))).with_type(TInt()))).with_type(TMap(TInt(), TInt())))).with_type(TMap(TInt(), TInt())), EVar('_var6084').with_type(TInt())).with_type(TInt()), {'l': Bag((4, 5, 4, 4)), 'n': 4, '_var6084': 4, '_var6085': 3, '_var2267': 5}),
     (EMapGet(EMakeMap2(EBinOp(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), '+', ESingleton(EVar('n').with_type(TInt())).with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var2267').with_type(TInt()), EBinOp(EUnaryOp('len', EFilter(EBinOp(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), '+', ESingleton(EVar('n').with_type(TInt())).with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var2268').with_type(TInt()), EBinOp(EVar('_var2267').with_type(TInt()), '==', EVar('_var2268').with_type(TInt())).with_type(TBool()))).with_type(TBag(TInt()))).with_type(TInt()), '<=', ENum(1).with_type(TInt())).with_type(TBool()))).with_type(TMap(TInt(), TBool())), EVar('_var12007').with_type(TInt())).with_type(TBool()), EBool(True).with_type(TBool()), {'l': Bag((3, 4, 5, 6)), 'n': 3, '_var12007': 3, '_var12008': True}),
     (EMapGet(EMakeMap2(EBinOp(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), '+', ESingleton(EVar('n').with_type(TInt())).with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var2267').with_type(TInt()), EBinOp(EUnaryOp('len', EFilter(EBinOp(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), '+', ESingleton(EVar('n').with_type(TInt())).with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var2268').with_type(TInt()), EBinOp(EVar('_var2267').with_type(TInt()), '==', EVar('_var2268').with_type(TInt())).with_type(TBool()))).with_type(TBag(TInt()))).with_type(TInt()), '<=', ENum(1).with_type(TInt())).with_type(TBool()))).with_type(TMap(TInt(), TBool())), EVar('_var12007').with_type(TInt())).with_type(TBool()), EBool(False).with_type(TBool()), {'l': Bag(()), 'n': 4, '_var12007': 4, '_var12008': False}),
     (EFilter(EMapKeys(EMakeMap2(EBinOp(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), '-', ESingleton(EVar('n').with_type(TInt())).with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var2267').with_type(TInt()), EBinOp(EUnaryOp('len', EFilter(EBinOp(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), '-', ESingleton(EVar('n').with_type(TInt())).with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var2268').with_type(TInt()), EBinOp(EVar('_var2267').with_type(TInt()), '==', EVar('_var2268').with_type(TInt())).with_type(TBool()))).with_type(TBag(TInt()))).with_type(TInt()), '<=', ENum(1).with_type(TInt())).with_type(TBool()))).with_type(TMap(TInt(), TBool()))).with_type(TBag(TInt())), ELambda(EVar('_var17313').with_type(TInt()), EBinOp(EUnaryOp('not', EHasKey(EStateVar(EMakeMap2(EVar('l').with_type(TBag(TInt())), ELambda(EVar('_var2267').with_type(TInt()), EBinOp(EUnaryOp('len', EFilter(EVar('l').with_type(TBag(TInt())), ELambda(EVar('_var2268').with_type(TInt()), EBinOp(EVar('_var2267').with_type(TInt()), '==', EVar('_var2268').with_type(TInt())).with_type(TBool()))).with_type(TBag(TInt()))).with_type(TInt()), '<=', ENum(1).with_type(TInt())).with_type(TBool()))).with_type(TMap(TInt(), TBool()))).with_type(TMap(TInt(), TBool())), EVar('_var17313').with_type(TInt())).with_type(TBool())).with_type(TBool()), 'or', EUnaryOp('not', ECond(EBinOp(EVar('_var17313').with_type(TInt()), 'in', EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt()))).with_type(TBool()), EBinOp(EBinOp(EUnaryOp('len', EFilter(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var2268').with_type(TInt()), EBinOp(EVar('_var17313').with_type(TInt()), '==', EVar('_var2268').with_type(TInt())).with_type(TBool()))).with_type(TBag(TInt()))).with_type(TInt()), '<=', ENum(1).with_type(TInt())).with_type(TBool()), '==', EMapGet(EMakeMap2(EBinOp(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), '-', ESingleton(EVar('n').with_type(TInt())).with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var2267').with_type(TInt()), EBinOp(EUnaryOp('len', EFilter(EBinOp(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), '-', ESingleton(EVar('n').with_type(TInt())).with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var2268').with_type(TInt()), EBinOp(EVar('_var2267').with_type(TInt()), '==', EVar('_var2268').with_type(TInt())).with_type(TBool()))).with_type(TBag(TInt()))).with_type(TInt()), '<=', ENum(1).with_type(TInt())).with_type(TBool()))).with_type(TMap(TInt(), TBool())), EVar('_var17313').with_type(TInt())).with_type(TBool())).with_type(TBool()), EBinOp(EBool(False).with_type(TBool()), '==', EMapGet(EMakeMap2(EBinOp(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), '-', ESingleton(EVar('n').with_type(TInt())).with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var2267').with_type(TInt()), EBinOp(EUnaryOp('len', EFilter(EBinOp(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), '-', ESingleton(EVar('n').with_type(TInt())).with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var2268').with_type(TInt()), EBinOp(EVar('_var2267').with_type(TInt()), '==', EVar('_var2268').with_type(TInt())).with_type(TBool()))).with_type(TBag(TInt()))).with_type(TInt()), '<=', ENum(1).with_type(TInt())).with_type(TBool()))).with_type(TMap(TInt(), TBool())), EVar('_var17313').with_type(TInt())).with_type(TBool())).with_type(TBool())).with_type(TBool())).with_type(TBool())).with_type(TBool()))).with_type(TBag(TInt())), EFilter(EMapKeys(EMakeMap2(EBinOp(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), '-', ESingleton(ENum(0).with_type(TInt())).with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var2267').with_type(TInt()), EBinOp(EUnaryOp('len', EFilter(EBinOp(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), '-', ESingleton(EVar('n').with_type(TInt())).with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var2268').with_type(TInt()), EBinOp(EVar('_var2267').with_type(TInt()), '==', EVar('_var2268').with_type(TInt())).with_type(TBool()))).with_type(TBag(TInt()))).with_type(TInt()), '<=', ENum(1).with_type(TInt())).with_type(TBool()))).with_type(TMap(TInt(), TBool()))).with_type(TBag(TInt())), ELambda(EVar('_var17313').with_type(TInt()), EBinOp(EUnaryOp('not', EHasKey(EStateVar(EMakeMap2(EVar('l').with_type(TBag(TInt())), ELambda(EVar('_var2267').with_type(TInt()), EBinOp(EUnaryOp('len', EFilter(EVar('l').with_type(TBag(TInt())), ELambda(EVar('_var2268').with_type(TInt()), EBinOp(EVar('_var2267').with_type(TInt()), '==', EVar('_var2268').with_type(TInt())).with_type(TBool()))).with_type(TBag(TInt()))).with_type(TInt()), '<=', ENum(1).with_type(TInt())).with_type(TBool()))).with_type(TMap(TInt(), TBool()))).with_type(TMap(TInt(), TBool())), EVar('_var17313').with_type(TInt())).with_type(TBool())).with_type(TBool()), 'or', EUnaryOp('not', ECond(EBinOp(EVar('_var17313').with_type(TInt()), 'in', EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt()))).with_type(TBool()), EBinOp(EBinOp(EUnaryOp('len', EFilter(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var2268').with_type(TInt()), EBinOp(EVar('_var17313').with_type(TInt()), '==', EVar('_var2268').with_type(TInt())).with_type(TBool()))).with_type(TBag(TInt()))).with_type(TInt()), '<=', ENum(1).with_type(TInt())).with_type(TBool()), '==', EMapGet(EMakeMap2(EBinOp(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), '-', ESingleton(EVar('n').with_type(TInt())).with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var2267').with_type(TInt()), EBinOp(EUnaryOp('len', EFilter(EBinOp(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), '-', ESingleton(EVar('n').with_type(TInt())).with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var2268').with_type(TInt()), EBinOp(EVar('_var2267').with_type(TInt()), '==', EVar('_var2268').with_type(TInt())).with_type(TBool()))).with_type(TBag(TInt()))).with_type(TInt()), '<=', ENum(1).with_type(TInt())).with_type(TBool()))).with_type(TMap(TInt(), TBool())), EVar('_var17313').with_type(TInt())).with_type(TBool())).with_type(TBool()), EBinOp(EBool(False).with_type(TBool()), '==', EMapGet(EMakeMap2(EBinOp(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), '-', ESingleton(EVar('n').with_type(TInt())).with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var2267').with_type(TInt()), EBinOp(EUnaryOp('len', EFilter(EBinOp(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), '-', ESingleton(EVar('n').with_type(TInt())).with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var2268').with_type(TInt()), EBinOp(EVar('_var2267').with_type(TInt()), '==', EVar('_var2268').with_type(TInt())).with_type(TBool()))).with_type(TBag(TInt()))).with_type(TInt()), '<=', ENum(1).with_type(TInt())).with_type(TBool()))).with_type(TMap(TInt(), TBool())), EVar('_var17313').with_type(TInt())).with_type(TBool())).with_type(TBool())).with_type(TBool())).with_type(TBool())).with_type(TBool()))).with_type(TBag(TInt())), {'l': Bag((0, 2)), 'n': 2, '_var2267': 0}),
     (EFilter(EMapKeys(EMakeMap2(EBinOp(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), '+', ESingleton(EVar('n').with_type(TInt())).with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var2267').with_type(TInt()), EBinOp(EUnaryOp('len', EFilter(EBinOp(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), '+', ESingleton(EVar('n').with_type(TInt())).with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var2268').with_type(TInt()), EBinOp(EVar('_var2267').with_type(TInt()), '==', EVar('_var2268').with_type(TInt())).with_type(TBool()))).with_type(TBag(TInt()))).with_type(TInt()), '<=', ENum(1).with_type(TInt())).with_type(TBool()))).with_type(TMap(TInt(), TBool()))).with_type(TBag(TInt())), ELambda(EVar('_var12007').with_type(TInt()), EBinOp(EUnaryOp('not', EHasKey(EStateVar(EMakeMap2(EVar('l').with_type(TBag(TInt())), ELambda(EVar('_var2267').with_type(TInt()), EBinOp(EUnaryOp('len', EFilter(EVar('l').with_type(TBag(TInt())), ELambda(EVar('_var2268').with_type(TInt()), EBinOp(EVar('_var2267').with_type(TInt()), '==', EVar('_var2268').with_type(TInt())).with_type(TBool()))).with_type(TBag(TInt()))).with_type(TInt()), '<=', ENum(1).with_type(TInt())).with_type(TBool()))).with_type(TMap(TInt(), TBool()))).with_type(TMap(TInt(), TBool())), EVar('_var12007').with_type(TInt())).with_type(TBool())).with_type(TBool()), 'or', EUnaryOp('not', ECond(EBinOp(EVar('_var12007').with_type(TInt()), 'in', EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt()))).with_type(TBool()), EBinOp(EBinOp(EUnaryOp('len', EFilter(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var2268').with_type(TInt()), EBinOp(EVar('_var12007').with_type(TInt()), '==', EVar('_var2268').with_type(TInt())).with_type(TBool()))).with_type(TBag(TInt()))).with_type(TInt()), '<=', ENum(1).with_type(TInt())).with_type(TBool()), '==', EMapGet(EMakeMap2(EBinOp(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), '+', ESingleton(EVar('n').with_type(TInt())).with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var2267').with_type(TInt()), EBinOp(EUnaryOp('len', EFilter(EBinOp(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), '+', ESingleton(EVar('n').with_type(TInt())).with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var2268').with_type(TInt()), EBinOp(EVar('_var2267').with_type(TInt()), '==', EVar('_var2268').with_type(TInt())).with_type(TBool()))).with_type(TBag(TInt()))).with_type(TInt()), '<=', ENum(1).with_type(TInt())).with_type(TBool()))).with_type(TMap(TInt(), TBool())), EVar('_var12007').with_type(TInt())).with_type(TBool())).with_type(TBool()), EBinOp(EBool(False).with_type(TBool()), '==', EMapGet(EMakeMap2(EBinOp(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), '+', ESingleton(EVar('n').with_type(TInt())).with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var2267').with_type(TInt()), EBinOp(EUnaryOp('len', EFilter(EBinOp(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), '+', ESingleton(EVar('n').with_type(TInt())).with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var2268').with_type(TInt()), EBinOp(EVar('_var2267').with_type(TInt()), '==', EVar('_var2268').with_type(TInt())).with_type(TBool()))).with_type(TBag(TInt()))).with_type(TInt()), '<=', ENum(1).with_type(TInt())).with_type(TBool()))).with_type(TMap(TInt(), TBool())), EVar('_var12007').with_type(TInt())).with_type(TBool())).with_type(TBool())).with_type(TBool())).with_type(TBool())).with_type(TBool()))).with_type(TBag(TInt())), EFilter(EMapKeys(EMakeMap2(EBinOp(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), '+', ESingleton(ENum(0).with_type(TInt())).with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var2267').with_type(TInt()), EBinOp(EUnaryOp('len', EFilter(EBinOp(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), '+', ESingleton(EVar('n').with_type(TInt())).with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var2268').with_type(TInt()), EBinOp(EVar('_var2267').with_type(TInt()), '==', EVar('_var2268').with_type(TInt())).with_type(TBool()))).with_type(TBag(TInt()))).with_type(TInt()), '<=', ENum(1).with_type(TInt())).with_type(TBool()))).with_type(TMap(TInt(), TBool()))).with_type(TBag(TInt())), ELambda(EVar('_var12007').with_type(TInt()), EBinOp(EUnaryOp('not', EHasKey(EStateVar(EMakeMap2(EVar('l').with_type(TBag(TInt())), ELambda(EVar('_var2267').with_type(TInt()), EBinOp(EUnaryOp('len', EFilter(EVar('l').with_type(TBag(TInt())), ELambda(EVar('_var2268').with_type(TInt()), EBinOp(EVar('_var2267').with_type(TInt()), '==', EVar('_var2268').with_type(TInt())).with_type(TBool()))).with_type(TBag(TInt()))).with_type(TInt()), '<=', ENum(1).with_type(TInt())).with_type(TBool()))).with_type(TMap(TInt(), TBool()))).with_type(TMap(TInt(), TBool())), EVar('_var12007').with_type(TInt())).with_type(TBool())).with_type(TBool()), 'or', EUnaryOp('not', ECond(EBinOp(EVar('_var12007').with_type(TInt()), 'in', EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt()))).with_type(TBool()), EBinOp(EBinOp(EUnaryOp('len', EFilter(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var2268').with_type(TInt()), EBinOp(EVar('_var12007').with_type(TInt()), '==', EVar('_var2268').with_type(TInt())).with_type(TBool()))).with_type(TBag(TInt()))).with_type(TInt()), '<=', ENum(1).with_type(TInt())).with_type(TBool()), '==', EMapGet(EMakeMap2(EBinOp(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), '+', ESingleton(EVar('n').with_type(TInt())).with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var2267').with_type(TInt()), EBinOp(EUnaryOp('len', EFilter(EBinOp(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), '+', ESingleton(EVar('n').with_type(TInt())).with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var2268').with_type(TInt()), EBinOp(EVar('_var2267').with_type(TInt()), '==', EVar('_var2268').with_type(TInt())).with_type(TBool()))).with_type(TBag(TInt()))).with_type(TInt()), '<=', ENum(1).with_type(TInt())).with_type(TBool()))).with_type(TMap(TInt(), TBool())), EVar('_var12007').with_type(TInt())).with_type(TBool())).with_type(TBool()), EBinOp(EBool(False).with_type(TBool()), '==', EMapGet(EMakeMap2(EBinOp(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), '+', ESingleton(EVar('n').with_type(TInt())).with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var2267').with_type(TInt()), EBinOp(EUnaryOp('len', EFilter(EBinOp(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), '+', ESingleton(EVar('n').with_type(TInt())).with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var2268').with_type(TInt()), EBinOp(EVar('_var2267').with_type(TInt()), '==', EVar('_var2268').with_type(TInt())).with_type(TBool()))).with_type(TBag(TInt()))).with_type(TInt()), '<=', ENum(1).with_type(TInt())).with_type(TBool()))).with_type(TMap(TInt(), TBool())), EVar('_var12007').with_type(TInt())).with_type(TBool())).with_type(TBool())).with_type(TBool())).with_type(TBool())).with_type(TBool()))).with_type(TBag(TInt())), {'l': Bag((0, 5)), 'n': 3, '_var2267': 0}),
     (EFilter(EMapKeys(EMakeMap2(EBinOp(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), '-', ESingleton(EVar('n').with_type(TInt())).with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var2267').with_type(TInt()), EBinOp(EUnaryOp('len', EFilter(EBinOp(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), '-', ESingleton(EVar('n').with_type(TInt())).with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var2268').with_type(TInt()), EBinOp(EVar('_var2267').with_type(TInt()), '==', EVar('_var2268').with_type(TInt())).with_type(TBool()))).with_type(TBag(TInt()))).with_type(TInt()), '<=', ENum(1).with_type(TInt())).with_type(TBool()))).with_type(TMap(TInt(), TBool()))).with_type(TBag(TInt())), ELambda(EVar('_var17313').with_type(TInt()), EBinOp(EUnaryOp('not', EHasKey(EStateVar(EMakeMap2(EVar('l').with_type(TBag(TInt())), ELambda(EVar('_var2267').with_type(TInt()), EBinOp(EUnaryOp('len', EFilter(EVar('l').with_type(TBag(TInt())), ELambda(EVar('_var2268').with_type(TInt()), EBinOp(EVar('_var2267').with_type(TInt()), '==', EVar('_var2268').with_type(TInt())).with_type(TBool()))).with_type(TBag(TInt()))).with_type(TInt()), '<=', ENum(1).with_type(TInt())).with_type(TBool()))).with_type(TMap(TInt(), TBool()))).with_type(TMap(TInt(), TBool())), EVar('_var17313').with_type(TInt())).with_type(TBool())).with_type(TBool()), 'or', EUnaryOp('not', ECond(EBinOp(EVar('_var17313').with_type(TInt()), 'in', EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt()))).with_type(TBool()), EBinOp(EBinOp(EUnaryOp('len', EFilter(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var2268').with_type(TInt()), EBinOp(EVar('_var17313').with_type(TInt()), '==', EVar('_var2268').with_type(TInt())).with_type(TBool()))).with_type(TBag(TInt()))).with_type(TInt()), '<=', ENum(1).with_type(TInt())).with_type(TBool()), '==', EMapGet(EMakeMap2(EBinOp(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), '-', ESingleton(EVar('n').with_type(TInt())).with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var2267').with_type(TInt()), EBinOp(EUnaryOp('len', EFilter(EBinOp(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), '-', ESingleton(EVar('n').with_type(TInt())).with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var2268').with_type(TInt()), EBinOp(EVar('_var2267').with_type(TInt()), '==', EVar('_var2268').with_type(TInt())).with_type(TBool()))).with_type(TBag(TInt()))).with_type(TInt()), '<=', ENum(1).with_type(TInt())).with_type(TBool()))).with_type(TMap(TInt(), TBool())), EVar('_var17313').with_type(TInt())).with_type(TBool())).with_type(TBool()), EBinOp(EBool(False).with_type(TBool()), '==', EMapGet(EMakeMap2(EBinOp(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), '-', ESingleton(EVar('n').with_type(TInt())).with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var2267').with_type(TInt()), EBinOp(EUnaryOp('len', EFilter(EBinOp(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), '-', ESingleton(EVar('n').with_type(TInt())).with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var2268').with_type(TInt()), EBinOp(EVar('_var2267').with_type(TInt()), '==', EVar('_var2268').with_type(TInt())).with_type(TBool()))).with_type(TBag(TInt()))).with_type(TInt()), '<=', ENum(1).with_type(TInt())).with_type(TBool()))).with_type(TMap(TInt(), TBool())), EVar('_var17313').with_type(TInt())).with_type(TBool())).with_type(TBool())).with_type(TBool())).with_type(TBool())).with_type(TBool()))).with_type(TBag(TInt())), EEmptyList().with_type(TBag(TInt())), {'l': Bag((4, 4)), 'n': 4, '_var2267': 0}),
     (EFilter(EMapKeys(EMakeMap2(EBinOp(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), '+', ESingleton(EVar('n').with_type(TInt())).with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var2267').with_type(TInt()), EBinOp(EUnaryOp('len', EFilter(EBinOp(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), '+', ESingleton(EVar('n').with_type(TInt())).with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var2268').with_type(TInt()), EBinOp(EVar('_var2267').with_type(TInt()), '==', EVar('_var2268').with_type(TInt())).with_type(TBool()))).with_type(TBag(TInt()))).with_type(TInt()), '<=', ENum(1).with_type(TInt())).with_type(TBool()))).with_type(TMap(TInt(), TBool()))).with_type(TBag(TInt())), ELambda(EVar('_var12007').with_type(TInt()), EBinOp(EUnaryOp('not', EHasKey(EStateVar(EMakeMap2(EVar('l').with_type(TBag(TInt())), ELambda(EVar('_var2267').with_type(TInt()), EBinOp(EUnaryOp('len', EFilter(EVar('l').with_type(TBag(TInt())), ELambda(EVar('_var2268').with_type(TInt()), EBinOp(EVar('_var2267').with_type(TInt()), '==', EVar('_var2268').with_type(TInt())).with_type(TBool()))).with_type(TBag(TInt()))).with_type(TInt()), '<=', ENum(1).with_type(TInt())).with_type(TBool()))).with_type(TMap(TInt(), TBool()))).with_type(TMap(TInt(), TBool())), EVar('_var12007').with_type(TInt())).with_type(TBool())).with_type(TBool()), 'or', EUnaryOp('not', ECond(EBinOp(EVar('_var12007').with_type(TInt()), 'in', EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt()))).with_type(TBool()), EBinOp(EBinOp(EUnaryOp('len', EFilter(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var2268').with_type(TInt()), EBinOp(EVar('_var12007').with_type(TInt()), '==', EVar('_var2268').with_type(TInt())).with_type(TBool()))).with_type(TBag(TInt()))).with_type(TInt()), '<=', ENum(1).with_type(TInt())).with_type(TBool()), '==', EMapGet(EMakeMap2(EBinOp(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), '+', ESingleton(EVar('n').with_type(TInt())).with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var2267').with_type(TInt()), EBinOp(EUnaryOp('len', EFilter(EBinOp(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), '+', ESingleton(EVar('n').with_type(TInt())).with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var2268').with_type(TInt()), EBinOp(EVar('_var2267').with_type(TInt()), '==', EVar('_var2268').with_type(TInt())).with_type(TBool()))).with_type(TBag(TInt()))).with_type(TInt()), '<=', ENum(1).with_type(TInt())).with_type(TBool()))).with_type(TMap(TInt(), TBool())), EVar('_var12007').with_type(TInt())).with_type(TBool())).with_type(TBool()), EBinOp(EBool(False).with_type(TBool()), '==', EMapGet(EMakeMap2(EBinOp(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), '+', ESingleton(EVar('n').with_type(TInt())).with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var2267').with_type(TInt()), EBinOp(EUnaryOp('len', EFilter(EBinOp(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), '+', ESingleton(EVar('n').with_type(TInt())).with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var2268').with_type(TInt()), EBinOp(EVar('_var2267').with_type(TInt()), '==', EVar('_var2268').with_type(TInt())).with_type(TBool()))).with_type(TBag(TInt()))).with_type(TInt()), '<=', ENum(1).with_type(TInt())).with_type(TBool()))).with_type(TMap(TInt(), TBool())), EVar('_var12007').with_type(TInt())).with_type(TBool())).with_type(TBool())).with_type(TBool())).with_type(TBool())).with_type(TBool()))).with_type(TBag(TInt())), ESingleton(EVar('n').with_type(TInt())).with_type(TBag(TInt())), {'l': Bag((4, 4)), 'n': 4, '_var2267': 0}),
     (EFilter(EFilter(EMapKeys(EStateVar(EMakeMap2(EVar('l').with_type(TBag(TInt())), ELambda(EVar('_var427').with_type(TInt()), EBool(True).with_type(TBool()))).with_type(TMap(TInt(), TBool()))).with_type(TMap(TInt(), TBool()))).with_type(TBag(TInt())), ELambda(EVar('_var2266').with_type(TInt()), EBinOp(EVar('_var2266').with_type(TInt()), '==', EVar('n').with_type(TInt())).with_type(TBool()))).with_type(TBag(TInt())), ELambda(EVar('_var2266').with_type(TInt()), EMapGet(EStateVar(EMakeMap2(EVar('l').with_type(TBag(TInt())), ELambda(EVar('_var2267').with_type(TInt()), EBinOp(EUnaryOp('len', EFilter(EVar('l').with_type(TBag(TInt())), ELambda(EVar('_var2268').with_type(TInt()), EBinOp(EVar('_var2267').with_type(TInt()), '==', EVar('_var2268').with_type(TInt())).with_type(TBool()))).with_type(TBag(TInt()))).with_type(TInt()), '<=', ENum(1).with_type(TInt())).with_type(TBool()))).with_type(TMap(TInt(), TBool()))).with_type(TMap(TInt(), TBool())), EVar('_var2266').with_type(TInt())).with_type(TBool()))).with_type(TBag(TInt())), EMap(EFilter(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var11251').with_type(TInt()), EBinOp(EVar('_var11251').with_type(TInt()), '!=', EVar('n').with_type(TInt())).with_type(TBool()))).with_type(TBag(TInt())), ELambda(EVar('_var62637').with_type(TInt()), EVar('n').with_type(TInt()))).with_type(TBag(TInt())), {'l': Bag((3, 4, 5)), 'n': 0, '_var2267': 3}),
     (ECond(EHasKey(EStateVar(EMakeMap2(EVar('l').with_type(TBag(TInt())), ELambda(EVar('_var427').with_type(TInt()), EBool(True).with_type(TBool()))).with_type(TMap(TInt(), TBool()))).with_type(TMap(TInt(), TBool())), EVar('n').with_type(TInt())).with_type(TBool()), ESingleton(EVar('n').with_type(TInt())).with_type(TBag(TInt())), EEmptyList().with_type(TBag(TInt()))).with_type(TBag(TInt())), ECond(EStateVar(EBinOp(ENum(0).with_type(TInt()), 'in', EVar('l').with_type(TBag(TInt()))).with_type(TBool())).with_type(TBool()), ESingleton(EVar('n').with_type(TInt())).with_type(TBag(TInt())), EEmptyList().with_type(TBag(TInt()))).with_type(TBag(TInt())), {'l': Bag((0,)), 'n': 2, '_var427': 0}),
     (EFilter(EMapKeys(EMakeMap2(EBinOp(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), '+', ESingleton(EVar('n').with_type(TInt())).with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var2267').with_type(TInt()), EBinOp(EUnaryOp('len', EFilter(EBinOp(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), '+', ESingleton(EVar('n').with_type(TInt())).with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var2268').with_type(TInt()), EBinOp(EVar('_var2267').with_type(TInt()), '==', EVar('_var2268').with_type(TInt())).with_type(TBool()))).with_type(TBag(TInt()))).with_type(TInt()), '<=', ENum(1).with_type(TInt())).with_type(TBool()))).with_type(TMap(TInt(), TBool()))).with_type(TBag(TInt())), ELambda(EVar('_var12007').with_type(TInt()), EBinOp(EUnaryOp('not', EHasKey(EStateVar(EMakeMap2(EVar('l').with_type(TBag(TInt())), ELambda(EVar('_var2267').with_type(TInt()), EBinOp(EUnaryOp('len', EFilter(EVar('l').with_type(TBag(TInt())), ELambda(EVar('_var2268').with_type(TInt()), EBinOp(EVar('_var2267').with_type(TInt()), '==', EVar('_var2268').with_type(TInt())).with_type(TBool()))).with_type(TBag(TInt()))).with_type(TInt()), '<=', ENum(1).with_type(TInt())).with_type(TBool()))).with_type(TMap(TInt(), TBool()))).with_type(TMap(TInt(), TBool())), EVar('_var12007').with_type(TInt())).with_type(TBool())).with_type(TBool()), 'or', EUnaryOp('not', ECond(EBinOp(EVar('_var12007').with_type(TInt()), 'in', EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt()))).with_type(TBool()), EBinOp(EBinOp(EUnaryOp('len', EFilter(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var2268').with_type(TInt()), EBinOp(EVar('_var12007').with_type(TInt()), '==', EVar('_var2268').with_type(TInt())).with_type(TBool()))).with_type(TBag(TInt()))).with_type(TInt()), '<=', ENum(1).with_type(TInt())).with_type(TBool()), '==', EMapGet(EMakeMap2(EBinOp(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), '+', ESingleton(EVar('n').with_type(TInt())).with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var2267').with_type(TInt()), EBinOp(EUnaryOp('len', EFilter(EBinOp(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), '+', ESingleton(EVar('n').with_type(TInt())).with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var2268').with_type(TInt()), EBinOp(EVar('_var2267').with_type(TInt()), '==', EVar('_var2268').with_type(TInt())).with_type(TBool()))).with_type(TBag(TInt()))).with_type(TInt()), '<=', ENum(1).with_type(TInt())).with_type(TBool()))).with_type(TMap(TInt(), TBool())), EVar('_var12007').with_type(TInt())).with_type(TBool())).with_type(TBool()), EBinOp(EBool(False).with_type(TBool()), '==', EMapGet(EMakeMap2(EBinOp(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), '+', ESingleton(EVar('n').with_type(TInt())).with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var2267').with_type(TInt()), EBinOp(EUnaryOp('len', EFilter(EBinOp(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), '+', ESingleton(EVar('n').with_type(TInt())).with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var2268').with_type(TInt()), EBinOp(EVar('_var2267').with_type(TInt()), '==', EVar('_var2268').with_type(TInt())).with_type(TBool()))).with_type(TBag(TInt()))).with_type(TInt()), '<=', ENum(1).with_type(TInt())).with_type(TBool()))).with_type(TMap(TInt(), TBool())), EVar('_var12007').with_type(TInt())).with_type(TBool())).with_type(TBool())).with_type(TBool())).with_type(TBool())).with_type(TBool()))).with_type(TBag(TInt())), EFilter(EMapKeys(EMakeMap2(EBinOp(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), '+', ESingleton(EVar('n').with_type(TInt())).with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var2267').with_type(TInt()), EBinOp(EUnaryOp('len', EFilter(EBinOp(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), '+', ESingleton(EVar('n').with_type(TInt())).with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var2268').with_type(TInt()), EBinOp(EVar('_var2267').with_type(TInt()), '==', EVar('_var2268').with_type(TInt())).with_type(TBool()))).with_type(TBag(TInt()))).with_type(TInt()), '<=', ENum(1).with_type(TInt())).with_type(TBool()))).with_type(TMap(TInt(), TBool()))).with_type(TBag(TInt())), ELambda(EVar('_var12007').with_type(TInt()), EBinOp(EUnaryOp('not', EHasKey(EStateVar(EMakeMap2(EVar('l').with_type(TBag(TInt())), ELambda(EVar('_var2267').with_type(TInt()), EBinOp(EUnaryOp('len', EFilter(EVar('l').with_type(TBag(TInt())), ELambda(EVar('_var2268').with_type(TInt()), EBinOp(EVar('_var2267').with_type(TInt()), '==', EVar('_var2268').with_type(TInt())).with_type(TBool()))).with_type(TBag(TInt()))).with_type(TInt()), '<=', ENum(1).with_type(TInt())).with_type(TBool()))).with_type(TMap(TInt(), TBool()))).with_type(TMap(TInt(), TBool())), EVar('_var12007').with_type(TInt())).with_type(TBool())).with_type(TBool()), 'or', EUnaryOp('not', ECond(EBinOp(EVar('_var12007').with_type(TInt()), 'in', EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt()))).with_type(TBool()), EBool(True).with_type(TBool()), EBinOp(EBool(False).with_type(TBool()), '==', EMapGet(EMakeMap2(EBinOp(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), '+', ESingleton(EVar('n').with_type(TInt())).with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var2267').with_type(TInt()), EBinOp(EUnaryOp('len', EFilter(EBinOp(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), '+', ESingleton(EVar('n').with_type(TInt())).with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var2268').with_type(TInt()), EBinOp(EVar('_var2267').with_type(TInt()), '==', EVar('_var2268').with_type(TInt())).with_type(TBool()))).with_type(TBag(TInt()))).with_type(TInt()), '<=', ENum(1).with_type(TInt())).with_type(TBool()))).with_type(TMap(TInt(), TBool())), EVar('_var12007').with_type(TInt())).with_type(TBool())).with_type(TBool())).with_type(TBool())).with_type(TBool())).with_type(TBool()))).with_type(TBag(TInt())), {'l': Bag((3, 5, 4)), 'n': 3, '_var2267': 0, '_var71738': 0, '_var73145': 0, '_var73375': 0}),
     (EBinOp(EBinOp(EStateVar(EVar('l').with_type(TBag(TFloat()))).with_type(TBag(TFloat())), '+', ESingleton(EVar('v').with_type(TFloat())).with_type(TBag(TFloat()))).with_type(TBag(TFloat())), '-', EStateVar(EVar('l').with_type(TBag(TFloat()))).with_type(TBag(TFloat()))).with_type(TBag(TFloat())), EEmptyList().with_type(TBag(TFloat())), {'get_ith_escaped': ExtractedFunc(cases={}, default=Fraction(0, 1)), 'l': Bag(()), 'v': Fraction(0, 1)}),
     (EBinOp(EStateVar(EVar('l').with_type(TBag(TFloat()))).with_type(TBag(TFloat())), '-', EBinOp(EStateVar(EVar('l').with_type(TBag(TFloat()))).with_type(TBag(TFloat())), '-', ESingleton(EVar('v').with_type(TFloat())).with_type(TBag(TFloat()))).with_type(TBag(TFloat()))).with_type(TBag(TFloat())), EEmptyList().with_type(TBag(TFloat())), {'get_ith_escaped': ExtractedFunc(cases={}, default=Fraction(0, 1)), 'l': Bag((Fraction(0, 1), Fraction(2, 1), Fraction(1, 1), Fraction(0, 1))), 'v': Fraction(0, 1)}),
     (ESorted(EStateVar(EVar('l').with_type(TBag(TFloat()))).with_type(TBag(TFloat())), EVar('asc').with_type(TBool())).with_type(TList(TFloat())), ESorted(EEmptyList().with_type(TBag(TFloat())), EVar('asc').with_type(TBool())).with_type(TList(TFloat())), {'get_ith_escaped': ExtractedFunc(cases={}, default=Fraction(0, 1)), 'l': Bag((Fraction(0, 1), Fraction(1, 1), Fraction(0, 1), Fraction(-1, 1))), 'asc': True}),
     (EListGet(ESorted(EStateVar(EVar('l').with_type(TBag(TFloat()))).with_type(TBag(TFloat())), EVar('asc').with_type(TBool())).with_type(TList(TFloat())), EVar('i').with_type(TInt())).with_type(TFloat()), EListGet(ESorted(EEmptyList().with_type(TBag(TFloat())), EVar('asc').with_type(TBool())).with_type(TList(TFloat())), EVar('i').with_type(TInt())).with_type(TFloat()), {'get_ith_escaped': ExtractedFunc(cases={}, default=Fraction(0, 1)), 'l': Bag((Fraction(-1, 1), Fraction(-2, 1))), 'asc': True, 'i': 1}),
     (EBinOp(EStateVar(EVar('l').with_type(TBag(TFloat()))).with_type(TBag(TFloat())), '-', EBinOp(EStateVar(EVar('l').with_type(TBag(TFloat()))).with_type(TBag(TFloat())), '-', ESingleton(EVar('v').with_type(TFloat())).with_type(TBag(TFloat()))).with_type(TBag(TFloat()))).with_type(TBag(TFloat())), ESingleton(EVar('v').with_type(TFloat())).with_type(TBag(TFloat())), {'get_ith_escaped': ExtractedFunc(cases={}, default=Fraction(0, 1)), 'l': Bag(()), 'v': Fraction(0, 1)}),
     (ECond(EHasKey(EStateVar(EMakeMap2(EVar('l').with_type(TBag(TFloat())), ELambda(EVar('_var409').with_type(TFloat()), EBool(True).with_type(TBool()))).with_type(TMap(TFloat(), TBool()))).with_type(TMap(TFloat(), TBool())), EVar('v').with_type(TFloat())).with_type(TBool()), ESingleton(EVar('v').with_type(TFloat())).with_type(TBag(TFloat())), EEmptyList().with_type(TBag(TFloat()))).with_type(TBag(TFloat())), ECond(EUnaryOp('exists', EStateVar(EVar('l').with_type(TBag(TFloat()))).with_type(TBag(TFloat()))).with_type(TBool()), ESingleton(EVar('v').with_type(TFloat())).with_type(TBag(TFloat())), EEmptyList().with_type(TBag(TFloat()))).with_type(TBag(TFloat())), {'get_ith_escaped': ExtractedFunc(cases={}, default=Fraction(0, 1)), 'l': Bag((Fraction(1, 1),)), 'v': Fraction(0, 1)}),
     (EBinOp(EMapKeys(EStateVar(EMakeMap2(EVar('l').with_type(TBag(TFloat())), ELambda(EVar('_var409').with_type(TFloat()), EBool(True).with_type(TBool()))).with_type(TMap(TFloat(), TBool()))).with_type(TMap(TFloat(), TBool()))).with_type(TBag(TFloat())), '-', EUnaryOp('distinct', EBinOp(EStateVar(EVar('l').with_type(TBag(TFloat()))).with_type(TBag(TFloat())), '-', ESingleton(EVar('v').with_type(TFloat())).with_type(TBag(TFloat()))).with_type(TBag(TFloat()))).with_type(TBag(TFloat()))).with_type(TBag(TFloat())), EEmptyList().with_type(TBag(TFloat())), {'get_ith_escaped': ExtractedFunc(cases={}, default=Fraction(0, 1)), 'l': Bag((Fraction(0, 1),)), 'v': Fraction(0, 1)}),
     (ECond(EVar('asc').with_type(TBool()), ETreeMultisetElems(EStateVar(EMakeMinTreeMultiset(EVar('l').with_type(TBag(TFloat()))).with_type(TMinTreeMultiset(TFloat()))).with_type(TMinTreeMultiset(TFloat()))).with_type(TList(TFloat())), ETreeMultisetElems(EStateVar(EMakeMaxTreeMultiset(EVar('l').with_type(TBag(TFloat()))).with_type(TMaxTreeMultiset(TFloat()))).with_type(TMaxTreeMultiset(TFloat()))).with_type(TList(TFloat()))).with_type(TList(TFloat())), ETreeMultisetElems(EStateVar(EMakeMinTreeMultiset(EVar('l').with_type(TBag(TFloat()))).with_type(TMinTreeMultiset(TFloat()))).with_type(TMinTreeMultiset(TFloat()))).with_type(TList(TFloat())), {'get_ith_escaped': ExtractedFunc(cases={}, default=Fraction(0, 1)), 'l': Bag((Fraction(0, 1), Fraction(4, 1))), 'asc': False}),
     (EListGet(ECond(EVar('asc').with_type(TBool()), ETreeMultisetElems(EStateVar(EMakeMinTreeMultiset(EVar('l').with_type(TBag(TFloat()))).with_type(TMinTreeMultiset(TFloat()))).with_type(TMinTreeMultiset(TFloat()))).with_type(TList(TFloat())), ETreeMultisetElems(EStateVar(EMakeMaxTreeMultiset(EVar('l').with_type(TBag(TFloat()))).with_type(TMaxTreeMultiset(TFloat()))).with_type(TMaxTreeMultiset(TFloat()))).with_type(TList(TFloat()))).with_type(TList(TFloat())), EVar('i').with_type(TInt())).with_type(TFloat()), EListGet(ETreeMultisetElems(EStateVar(EMakeMinTreeMultiset(EVar('l').with_type(TBag(TFloat()))).with_type(TMinTreeMultiset(TFloat()))).with_type(TMinTreeMultiset(TFloat()))).with_type(TList(TFloat())), EVar('i').with_type(TInt())).with_type(TFloat()), {'get_ith_escaped': ExtractedFunc(cases={}, default=Fraction(0, 1)), 'l': Bag((Fraction(-2, 1), Fraction(-1, 1))), 'asc': False, 'i': 0}),
     (EUnaryOp('sum', EMap(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('i').with_type(TInt()), EVar('i').with_type(TInt()))).with_type(TBag(TInt()))).with_type(TInt()), ENum(0).with_type(TInt()), {'l': Bag((0, 1236, -1237))}),
     (EUnaryOp('sum', EMap(EFilter(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('i').with_type(TInt()), EBinOp(EVar('i').with_type(TInt()), '>', ENum(10).with_type(TInt())).with_type(TBool()))).with_type(TBag(TInt())), ELambda(EVar('i').with_type(TInt()), ENum(1).with_type(TInt()))).with_type(TBag(TInt()))).with_type(TInt()), ENum(0).with_type(TInt()), {'l': Bag((11, 0, 10, 11))}),
     (EBinOp(EBinOp(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), '+', ESingleton(EVar('i').with_type(TInt())).with_type(TBag(TInt()))).with_type(TBag(TInt())), '-', EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt()))).with_type(TBag(TInt())), EEmptyList().with_type(TBag(TInt())), {'l': Bag(()), 'i': 0}),
     (EStateVar(EUnaryOp('sum', EVar('l').with_type(TBag(TInt()))).with_type(TInt())).with_type(TInt()), EUnaryOp('-', ENum(1).with_type(TInt())).with_type(TInt()), {'l': Bag(())}),
     (EBinOp(EUnaryOp('sum', EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt()))).with_type(TInt()), '+', EVar('i').with_type(TInt())).with_type(TInt()), ENum(0).with_type(TInt()), {'l': Bag((0, -2438, 2437)), 'i': 0}),
     (EBinOp(EBinOp(EFilter(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var372').with_type(TInt()), EBinOp(EVar('_var372').with_type(TInt()), '>', ENum(10).with_type(TInt())).with_type(TBool()))).with_type(TBag(TInt())), '+', ECond(EBinOp(EVar('i').with_type(TInt()), '>', ENum(10).with_type(TInt())).with_type(TBool()), ESingleton(EVar('i').with_type(TInt())).with_type(TBag(TInt())), EEmptyList().with_type(TBag(TInt()))).with_type(TBag(TInt()))).with_type(TBag(TInt())), '-', EStateVar(EFilter(EVar('l').with_type(TBag(TInt())), ELambda(EVar('_var492').with_type(TInt()), EBinOp(EVar('_var492').with_type(TInt()), '>', ENum(10).with_type(TInt())).with_type(TBool()))).with_type(TBag(TInt()))).with_type(TBag(TInt()))).with_type(TBag(TInt())), EBinOp(EBinOp(EFilter(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var372').with_type(TInt()), EBinOp(EVar('_var372').with_type(TInt()), '>', ENum(10).with_type(TInt())).with_type(TBool()))).with_type(TBag(TInt())), '+', ECond(EBool(True).with_type(TBool()), ESingleton(EVar('i').with_type(TInt())).with_type(TBag(TInt())), EEmptyList().with_type(TBag(TInt()))).with_type(TBag(TInt()))).with_type(TBag(TInt())), '-', EStateVar(EFilter(EVar('l').with_type(TBag(TInt())), ELambda(EVar('_var492').with_type(TInt()), EBinOp(EVar('_var492').with_type(TInt()), '>', ENum(10).with_type(TInt())).with_type(TBool()))).with_type(TBag(TInt()))).with_type(TBag(TInt()))).with_type(TBag(TInt())), {'l': Bag(()), 'i': 0}),
     (EBinOp(EUnaryOp('sum', EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt()))).with_type(TInt()), '+', EVar('i').with_type(TInt())).with_type(TInt()), EUnaryOp('sum', EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt()))).with_type(TInt()), {'l': Bag((0, 0, 0)), 'i': 1}),
     (EBinOp(EUnaryOp('sum', EMap(EFilter(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var899').with_type(TInt()), EBinOp(EVar('_var899').with_type(TInt()), '>', ENum(10).with_type(TInt())).with_type(TBool()))).with_type(TBag(TInt())), ELambda(EVar('_var900').with_type(TInt()), ENum(1).with_type(TInt()))).with_type(TBag(TInt()))).with_type(TInt()), '+', EUnaryOp('sum', EMap(ECond(EBinOp(EVar('i').with_type(TInt()), '>', ENum(10).with_type(TInt())).with_type(TBool()), ESingleton(EVar('i').with_type(TInt())).with_type(TBag(TInt())), EEmptyList().with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var900').with_type(TInt()), ENum(1).with_type(TInt()))).with_type(TBag(TInt()))).with_type(TInt())).with_type(TInt()), EBinOp(EUnaryOp('sum', EMap(EFilter(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var899').with_type(TInt()), EBinOp(EVar('_var899').with_type(TInt()), '>', ENum(10).with_type(TInt())).with_type(TBool()))).with_type(TBag(TInt())), ELambda(EVar('_var900').with_type(TInt()), ENum(1).with_type(TInt()))).with_type(TBag(TInt()))).with_type(TInt()), '+', EUnaryOp('sum', EMap(ECond(EBool(True).with_type(TBool()), ESingleton(EVar('i').with_type(TInt())).with_type(TBag(TInt())), EEmptyList().with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var900').with_type(TInt()), ENum(1).with_type(TInt()))).with_type(TBag(TInt()))).with_type(TInt())).with_type(TInt()), {'l': Bag(()), 'i': 0}),
     (EBinOp(EUnaryOp('sum', EMap(EFilter(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var899').with_type(TInt()), EBinOp(EVar('_var899').with_type(TInt()), '>', ENum(10).with_type(TInt())).with_type(TBool()))).with_type(TBag(TInt())), ELambda(EVar('_var900').with_type(TInt()), ENum(1).with_type(TInt()))).with_type(TBag(TInt()))).with_type(TInt()), '+', EUnaryOp('sum', EMap(ECond(EBinOp(EVar('i').with_type(TInt()), '>', ENum(10).with_type(TInt())).with_type(TBool()), ESingleton(EVar('i').with_type(TInt())).with_type(TBag(TInt())), EEmptyList().with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var900').with_type(TInt()), ENum(1).with_type(TInt()))).with_type(TBag(TInt()))).with_type(TInt())).with_type(TInt()), EBinOp(EUnaryOp('sum', EMap(EFilter(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var899').with_type(TInt()), EBinOp(EVar('_var899').with_type(TInt()), '>', ENum(10).with_type(TInt())).with_type(TBool()))).with_type(TBag(TInt())), ELambda(EVar('_var900').with_type(TInt()), ENum(1).with_type(TInt()))).with_type(TBag(TInt()))).with_type(TInt()), '+', EUnaryOp('sum', EMap(ECond(EBool(False).with_type(TBool()), ESingleton(EVar('i').with_type(TInt())).with_type(TBag(TInt())), EEmptyList().with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var900').with_type(TInt()), ENum(1).with_type(TInt()))).with_type(TBag(TInt()))).with_type(TInt())).with_type(TInt()), {'l': Bag(()), 'i': 11}),
     (EBinOp(EUnaryOp('sum', EMap(EFilter(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var899').with_type(TInt()), EBinOp(EVar('_var899').with_type(TInt()), '>', ENum(10).with_type(TInt())).with_type(TBool()))).with_type(TBag(TInt())), ELambda(EVar('_var900').with_type(TInt()), ENum(1).with_type(TInt()))).with_type(TBag(TInt()))).with_type(TInt()), '+', EUnaryOp('sum', EMap(ECond(EBinOp(EVar('i').with_type(TInt()), '>', ENum(10).with_type(TInt())).with_type(TBool()), ESingleton(EVar('i').with_type(TInt())).with_type(TBag(TInt())), EEmptyList().with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var900').with_type(TInt()), ENum(1).with_type(TInt()))).with_type(TBag(TInt()))).with_type(TInt())).with_type(TInt()), EBinOp(ENum(0).with_type(TInt()), '+', EUnaryOp('sum', EMap(ECond(EBinOp(EVar('i').with_type(TInt()), '>', ENum(10).with_type(TInt())).with_type(TBool()), ESingleton(EVar('i').with_type(TInt())).with_type(TBag(TInt())), EEmptyList().with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var900').with_type(TInt()), ENum(1).with_type(TInt()))).with_type(TBag(TInt()))).with_type(TInt())).with_type(TInt()), {'l': Bag((11, 0, 10, 10)), 'i': 0}),
     (EBinOp(EBinOp(EFilter(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var899').with_type(TInt()), EBinOp(EVar('_var899').with_type(TInt()), '>', ENum(10).with_type(TInt())).with_type(TBool()))).with_type(TBag(TInt())), '+', ECond(EBinOp(EVar('i').with_type(TInt()), '>', ENum(10).with_type(TInt())).with_type(TBool()), ESingleton(EVar('i').with_type(TInt())).with_type(TBag(TInt())), EEmptyList().with_type(TBag(TInt()))).with_type(TBag(TInt()))).with_type(TBag(TInt())), '-', EStateVar(EFilter(EVar('l').with_type(TBag(TInt())), ELambda(EVar('_var899').with_type(TInt()), EBinOp(EVar('_var899').with_type(TInt()), '>', ENum(10).with_type(TInt())).with_type(TBool()))).with_type(TBag(TInt()))).with_type(TBag(TInt()))).with_type(TBag(TInt())), EBinOp(EBinOp(EFilter(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var899').with_type(TInt()), EBinOp(EVar('_var899').with_type(TInt()), '>', ENum(10).with_type(TInt())).with_type(TBool()))).with_type(TBag(TInt())), '+', ECond(EBool(True).with_type(TBool()), ESingleton(EVar('i').with_type(TInt())).with_type(TBag(TInt())), EEmptyList().with_type(TBag(TInt()))).with_type(TBag(TInt()))).with_type(TBag(TInt())), '-', EStateVar(EFilter(EVar('l').with_type(TBag(TInt())), ELambda(EVar('_var899').with_type(TInt()), EBinOp(EVar('_var899').with_type(TInt()), '>', ENum(10).with_type(TInt())).with_type(TBool()))).with_type(TBag(TInt()))).with_type(TBag(TInt()))).with_type(TBag(TInt())), {'l': Bag(()), 'i': 0}),
     (EBinOp(EBinOp(EFilter(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var899').with_type(TInt()), EBinOp(EVar('_var899').with_type(TInt()), '>', ENum(10).with_type(TInt())).with_type(TBool()))).with_type(TBag(TInt())), '+', ECond(EBinOp(EVar('i').with_type(TInt()), '>', ENum(10).with_type(TInt())).with_type(TBool()), ESingleton(EVar('i').with_type(TInt())).with_type(TBag(TInt())), EEmptyList().with_type(TBag(TInt()))).with_type(TBag(TInt()))).with_type(TBag(TInt())), '-', EStateVar(EFilter(EVar('l').with_type(TBag(TInt())), ELambda(EVar('_var899').with_type(TInt()), EBinOp(EVar('_var899').with_type(TInt()), '>', ENum(10).with_type(TInt())).with_type(TBool()))).with_type(TBag(TInt()))).with_type(TBag(TInt()))).with_type(TBag(TInt())), EBinOp(EBinOp(EFilter(EStateVar(EVar('l').with_type(TBag(TInt()))).with_type(TBag(TInt())), ELambda(EVar('_var899').with_type(TInt()), EBinOp(EVar('_var899').with_type(TInt()), '>', ENum(10).with_type(TInt())).with_type(TBool()))).with_type(TBag(TInt())), '+', ECond(EBool(False).with_type(TBool()), ESingleton(EVar('i').with_type(TInt())).with_type(TBag(TInt())), EEmptyList().with_type(TBag(TInt()))).with_type(TBag(TInt()))).with_type(TBag(TInt())), '-', EStateVar(EFilter(EVar('l').with_type(TBag(TInt())), ELambda(EVar('_var899').with_type(TInt()), EBinOp(EVar('_var899').with_type(TInt()), '>', ENum(10).with_type(TInt())).with_type(TBool()))).with_type(TBag(TInt()))).with_type(TBag(TInt()))).with_type(TBag(TInt())), {'l': Bag((-1, 0)), 'i': 11}),
     (EStateVar(EUnaryOp('sum', EMap(EFilter(EVar('l').with_type(TBag(TInt())), ELambda(EVar('i').with_type(TInt()), EBinOp(EVar('i').with_type(TInt()), '>', ENum(10).with_type(TInt())).with_type(TBool()))).with_type(TBag(TInt())), ELambda(EVar('i').with_type(TInt()), ENum(1).with_type(TInt()))).with_type(TBag(TInt()))).with_type(TInt())).with_type(TInt()), EBinOp(ENum(1).with_type(TInt()), '+', ENum(1).with_type(TInt())).with_type(TInt()), {'l': Bag(())}) ]
  
  tests2 = [
      EUnaryOp('not', EBinOp(EFlatMap(EStateVar(EVar('Rs').with_type(TBag(TRecord((('A', TInt()), ('B', TString())))))).with_type(TBag(TRecord((('A', TInt()), ('B', TString()))))), ELambda(EVar('r').with_type(TRecord((('A', TInt()), ('B', TString())))), EFlatMap(EStateVar(EVar('Ss').with_type(TBag(TRecord((('B', TString()), ('C', TInt())))))).with_type(TBag(TRecord((('B', TString()), ('C', TInt()))))), ELambda(EVar('s').with_type(TRecord((('B', TString()), ('C', TInt())))), EFlatMap(EStateVar(EVar('Qs').with_type(TBag(TRecord((('B', TString()), ('C', TInt())))))).with_type(TBag(TRecord((('B', TString()), ('C', TInt()))))), ELambda(EVar('q').with_type(TRecord((('B', TString()), ('C', TInt())))), EMap(EFilter(EStateVar(EVar('Ws').with_type(TBag(TRecord((('B', TString()), ('C', TInt())))))).with_type(TBag(TRecord((('B', TString()), ('C', TInt()))))), ELambda(EVar('w').with_type(TRecord((('B', TString()), ('C', TInt())))), EBinOp(EBinOp(EGetField(EVar('q').with_type(TRecord((('B', TString()), ('C', TInt())))), 'B').with_type(TString()), '==', EGetField(EVar('w').with_type(TRecord((('B', TString()), ('C', TInt())))), 'B').with_type(TString())).with_type(TBool()), 'and', EBinOp(EGetField(EVar('r').with_type(TRecord((('A', TInt()), ('B', TString())))), 'A').with_type(TInt()), '==', ENum(15).with_type(TInt())).with_type(TBool())).with_type(TBool()))).with_type(TBag(TRecord((('B', TString()), ('C', TInt()))))), ELambda(EVar('w').with_type(TRecord((('B', TString()), ('C', TInt())))), ETuple((EGetField(EVar('r').with_type(TRecord((('A', TInt()), ('B', TString())))), 'A').with_type(TInt()), EGetField(EVar('s').with_type(TRecord((('B', TString()), ('C', TInt())))), 'C').with_type(TInt()), EGetField(EVar('q').with_type(TRecord((('B', TString()), ('C', TInt())))), 'B').with_type(TString()), EGetField(EVar('w').with_type(TRecord((('B', TString()), ('C', TInt())))), 'C').with_type(TInt()))).with_type(TTuple((TInt(), TInt(), TString(), TInt()))))).with_type(TBag(TTuple((TInt(), TInt(), TString(), TInt())))))).with_type(TBag(TTuple((TInt(), TInt(), TString(), TInt())))))).with_type(TBag(TTuple((TInt(), TInt(), TString(), TInt())))))).with_type(TBag(TTuple((TInt(), TInt(), TString(), TInt())))), '==', EFlatMap(EEmptyList().with_type(TBag(TRecord((('A', TInt()), ('B', TString()))))), ELambda(EVar('r').with_type(TRecord((('A', TInt()), ('B', TString())))), EFlatMap(EStateVar(EVar('Ss').with_type(TBag(TRecord((('B', TString()), ('C', TInt())))))).with_type(TBag(TRecord((('B', TString()), ('C', TInt()))))), ELambda(EVar('s').with_type(TRecord((('B', TString()), ('C', TInt())))), EFlatMap(EStateVar(EVar('Qs').with_type(TBag(TRecord((('B', TString()), ('C', TInt())))))).with_type(TBag(TRecord((('B', TString()), ('C', TInt()))))), ELambda(EVar('q').with_type(TRecord((('B', TString()), ('C', TInt())))), EMap(EFilter(EStateVar(EVar('Ws').with_type(TBag(TRecord((('B', TString()), ('C', TInt())))))).with_type(TBag(TRecord((('B', TString()), ('C', TInt()))))), ELambda(EVar('w').with_type(TRecord((('B', TString()), ('C', TInt())))), EBinOp(EBinOp(EGetField(EVar('q').with_type(TRecord((('B', TString()), ('C', TInt())))), 'B').with_type(TString()), '==', EGetField(EVar('w').with_type(TRecord((('B', TString()), ('C', TInt())))), 'B').with_type(TString())).with_type(TBool()), 'and', EBinOp(EGetField(EVar('r').with_type(TRecord((('A', TInt()), ('B', TString())))), 'A').with_type(TInt()), '==', ENum(15).with_type(TInt())).with_type(TBool())).with_type(TBool()))).with_type(TBag(TRecord((('B', TString()), ('C', TInt()))))), ELambda(EVar('w').with_type(TRecord((('B', TString()), ('C', TInt())))), ETuple((EGetField(EVar('r').with_type(TRecord((('A', TInt()), ('B', TString())))), 'A').with_type(TInt()), EGetField(EVar('s').with_type(TRecord((('B', TString()), ('C', TInt())))), 'C').with_type(TInt()), EGetField(EVar('q').with_type(TRecord((('B', TString()), ('C', TInt())))), 'B').with_type(TString()), EGetField(EVar('w').with_type(TRecord((('B', TString()), ('C', TInt())))), 'C').with_type(TInt()))).with_type(TTuple((TInt(), TInt(), TString(), TInt()))))).with_type(TBag(TTuple((TInt(), TInt(), TString(), TInt())))))).with_type(TBag(TTuple((TInt(), TInt(), TString(), TInt())))))).with_type(TBag(TTuple((TInt(), TInt(), TString(), TInt())))))).with_type(TBag(TTuple((TInt(), TInt(), TString(), TInt()))))).with_type(TBool())).with_type(TBool())
  ]
  
  tests3 = [
      EUnaryOp('not', EBinOp(EFlatMap(EStateVar(EVar('Rs').with_type(TBag(TRecord((('A', TInt()), ('B', TString())))))).with_type(TBag(TRecord((('A', TInt()), ('B', TString()))))), ELambda(EVar('r').with_type(TRecord((('A', TInt()), ('B', TString())))), EFlatMap(EStateVar(EVar('Ss').with_type(TBag(TRecord((('B', TString()), ('C', TInt())))))).with_type(TBag(TRecord((('B', TString()), ('C', TInt()))))), ELambda(EVar('s').with_type(TRecord((('B', TString()), ('C', TInt())))), EFlatMap(EStateVar(EVar('Qs').with_type(TBag(TRecord((('B', TString()), ('C', TInt())))))).with_type(TBag(TRecord((('B', TString()), ('C', TInt()))))), ELambda(EVar('q').with_type(TRecord((('B', TString()), ('C', TInt())))), EMap(EFilter(EStateVar(EVar('Ws').with_type(TBag(TRecord((('B', TString()), ('C', TInt())))))).with_type(TBag(TRecord((('B', TString()), ('C', TInt()))))), ELambda(EVar('w').with_type(TRecord((('B', TString()), ('C', TInt())))), EBinOp(EBinOp(EGetField(EVar('q').with_type(TRecord((('B', TString()), ('C', TInt())))), 'B').with_type(TString()), '==', EGetField(EVar('w').with_type(TRecord((('B', TString()), ('C', TInt())))), 'B').with_type(TString())).with_type(TBool()), 'and', EBinOp(EGetField(EVar('r').with_type(TRecord((('A', TInt()), ('B', TString())))), 'A').with_type(TInt()), '==', ENum(15).with_type(TInt())).with_type(TBool())).with_type(TBool()))).with_type(TBag(TRecord((('B', TString()), ('C', TInt()))))), ELambda(EVar('w').with_type(TRecord((('B', TString()), ('C', TInt())))), ETuple((EGetField(EVar('r').with_type(TRecord((('A', TInt()), ('B', TString())))), 'A').with_type(TInt()), EGetField(EVar('s').with_type(TRecord((('B', TString()), ('C', TInt())))), 'C').with_type(TInt()), EGetField(EVar('q').with_type(TRecord((('B', TString()), ('C', TInt())))), 'B').with_type(TString()), EGetField(EVar('w').with_type(TRecord((('B', TString()), ('C', TInt())))), 'C').with_type(TInt()))).with_type(TTuple((TInt(), TInt(), TString(), TInt()))))).with_type(TBag(TTuple((TInt(), TInt(), TString(), TInt())))))).with_type(TBag(TTuple((TInt(), TInt(), TString(), TInt())))))).with_type(TBag(TTuple((TInt(), TInt(), TString(), TInt())))))).with_type(TBag(TTuple((TInt(), TInt(), TString(), TInt())))), '==', EStateVar(EFlatMap(EVar('Rs').with_type(TBag(TRecord((('A', TInt()), ('B', TString()))))), ELambda(EVar('r').with_type(TRecord((('A', TInt()), ('B', TString())))), EFlatMap(EVar('Ss').with_type(TBag(TRecord((('B', TString()), ('C', TInt()))))), ELambda(EVar('s').with_type(TRecord((('B', TString()), ('C', TInt())))), EFlatMap(EVar('Qs').with_type(TBag(TRecord((('B', TString()), ('C', TInt()))))), ELambda(EVar('q').with_type(TRecord((('B', TString()), ('C', TInt())))), EMap(EFilter(EVar('Ws').with_type(TBag(TRecord((('B', TString()), ('C', TInt()))))), ELambda(EVar('w').with_type(TRecord((('B', TString()), ('C', TInt())))), EBinOp(EBinOp(EGetField(EVar('q').with_type(TRecord((('B', TString()), ('C', TInt())))), 'B').with_type(TString()), '==', EGetField(EVar('w').with_type(TRecord((('B', TString()), ('C', TInt())))), 'B').with_type(TString())).with_type(TBool()), 'and', EBinOp(EGetField(EVar('r').with_type(TRecord((('A', TInt()), ('B', TString())))), 'A').with_type(TInt()), '==', ENum(15).with_type(TInt())).with_type(TBool())).with_type(TBool()))).with_type(TBag(TRecord((('B', TString()), ('C', TInt()))))), ELambda(EVar('w').with_type(TRecord((('B', TString()), ('C', TInt())))), ETuple((EGetField(EVar('r').with_type(TRecord((('A', TInt()), ('B', TString())))), 'A').with_type(TInt()), EGetField(EVar('s').with_type(TRecord((('B', TString()), ('C', TInt())))), 'C').with_type(TInt()), EGetField(EVar('q').with_type(TRecord((('B', TString()), ('C', TInt())))), 'B').with_type(TString()), EGetField(EVar('w').with_type(TRecord((('B', TString()), ('C', TInt())))), 'C').with_type(TInt()))).with_type(TTuple((TInt(), TInt(), TString(), TInt()))))).with_type(TBag(TTuple((TInt(), TInt(), TString(), TInt())))))).with_type(TBag(TTuple((TInt(), TInt(), TString(), TInt())))))).with_type(TBag(TTuple((TInt(), TInt(), TString(), TInt())))))).with_type(TBag(TTuple((TInt(), TInt(), TString(), TInt()))))).with_type(TBag(TTuple((TInt(), TInt(), TString(), TInt()))))).with_type(TBool())).with_type(TBool())
  ]
  
  def init_solver():
      context = RootCtx()
      return solver_for_context(context)
  
  class TestRandomAssignment(unittest.TestCase):
      def test_satisfy_regression(self):
          for target, new_target, expected in tests:
              solver = init_solver()
              e = ENot(EEq(target, new_target))
              actual = satisfy(e, solver, [])
              assert eval(e, expected)
              if actual is None:
                  print("missed solution: %s\nfor: %s\n" % (expected, pprint(e)))
              elif actual.keys() != expected.keys():
                  print("different solution: \n actual: %s \n expected: %s\n for: %s\n" % (expected, actual, pprint(e)))
              else:
                  print("Found solution\n")
  
      def test_satisfy_true(self):
          for test in tests2:
              solver = init_solver()
              assert satisfy(test, solver, []), pprint(test)
  
      def test_unsatisfiable_true(self):
          for test in tests3:
              solver = init_solver()
              assert unsatisfiable(test), pprint(test)
  