@@ -87,45 +87,61 @@ def kcfg_explore(self, label: str | None = None) -> Iterator[KCFGExplore]:
8787        ) as  cts :
8888            yield  KCFGExplore (cts , kcfg_semantics = KMIRSemantics ())
8989
90-     def  make_call_config (
90+     def  _make_concrete_call_config (self , smir_info : SMIRInfo , * , start_symbol : str  =  'main' ) ->  KInner :
91+         def  init_subst () ->  dict [str , KInner ]:
92+             init_config  =  self .definition .init_config (KSort ('GeneratedTopCell' ))
93+             _ , res  =  split_config_from (init_config )
94+             return  res 
95+ 
96+         if  not  start_symbol  in  smir_info .function_tys :
97+             raise  KeyError (f'{ start_symbol }   not found in program' )
98+ 
99+         args_info  =  smir_info .function_arguments [start_symbol ]
100+         if  args_info :
101+             raise  ValueError (
102+                 f'Cannot create concrete call configuration for { start_symbol }  : function has parameters: { args_info }  ' 
103+             )
104+ 
105+         # The configuration is the default initial configuration, with the K cell updated with the call terminator 
106+         # TODO: see if this can be expressed in more simple terms 
107+         subst  =  Subst (
108+             {
109+                 ** init_subst (),
110+                 ** {
111+                     'K_CELL' : mk_call_terminator (smir_info .function_tys [start_symbol ], len (args_info )),
112+                 },
113+             }
114+         )
115+         empty_config  =  self .definition .empty_config (KSort ('GeneratedTopCell' ))
116+         config  =  subst (empty_config )
117+         assert  not  free_vars (config ), f'Config by construction should not have any free variables: { config }  ' 
118+         return  config 
119+ 
120+     def  _make_symbolic_call_config (
91121        self ,
92122        smir_info : SMIRInfo ,
93123        * ,
94124        start_symbol : str  =  'main' ,
95-         sort : str  =  'GeneratedTopCell' ,
96-         init : bool  =  False ,
97125    ) ->  tuple [KInner , list [KInner ]]:
98126        if  not  start_symbol  in  smir_info .function_tys :
99127            raise  KeyError (f'{ start_symbol }   not found in program' )
100128
101129        args_info  =  smir_info .function_arguments [start_symbol ]
102130        locals , constraints  =  symbolic_locals (smir_info , args_info )
103- 
104-         _subst  =  {
105-             'K_CELL' : mk_call_terminator (smir_info .function_tys [start_symbol ], len (args_info )),
106-             'STACK_CELL' : list_empty (),  # FIXME see #560, problems matching a symbolic stack 
107-             'LOCALS_CELL' : list_of (locals ),
108-         }
109- 
110-         _init_subst : dict [str , KInner ] =  {}
111-         if  init :
112-             _subst ['LOCALS_CELL' ] =  list_empty ()
113-             init_config  =  self .definition .init_config (KSort (sort ))
114-             _ , _init_subst  =  split_config_from (init_config )
115- 
116-         for  key  in  _init_subst :
117-             if  key  not  in   _subst :
118-                 _subst [key ] =  _init_subst [key ]
119- 
120-         subst  =  Subst (_subst )
121-         config  =  self .definition .empty_config (KSort (sort ))
122-         return  (subst .apply (config ), constraints )
131+         subst  =  Subst (
132+             {
133+                 'K_CELL' : mk_call_terminator (smir_info .function_tys [start_symbol ], len (args_info )),
134+                 'STACK_CELL' : list_empty (),  # FIXME see #560, problems matching a symbolic stack 
135+                 'LOCALS_CELL' : list_of (locals ),
136+             },
137+         )
138+         empty_config  =  self .definition .empty_config (KSort ('GeneratedTopCell' ))
139+         config  =  subst (empty_config )
140+         return  config , constraints 
123141
124142    def  run_smir (self , smir_info : SMIRInfo , start_symbol : str  =  'main' , depth : int  |  None  =  None ) ->  Pattern :
125143        smir_info  =  smir_info .reduce_to (start_symbol )
126-         init_config , init_constraints  =  self .make_call_config (smir_info , start_symbol = start_symbol , init = True )
127-         if  len (free_vars (init_config )) >  0  or  len (init_constraints ) >  0 :
128-             raise  ValueError (f'Cannot run function with variables: { start_symbol }   - { free_vars (init_config )}  ' )
144+         init_config  =  self ._make_concrete_call_config (smir_info , start_symbol = start_symbol )
129145        init_kore  =  self .kast_to_kore (init_config , KSort ('GeneratedTopCell' ))
130146        result  =  self .run_pattern (init_kore , depth = depth )
131147        return  result 
@@ -135,10 +151,9 @@ def apr_proof_from_smir(
135151        id : str ,
136152        smir_info : SMIRInfo ,
137153        start_symbol : str  =  'main' ,
138-         sort : str  =  'GeneratedTopCell' ,
139154        proof_dir : Path  |  None  =  None ,
140155    ) ->  APRProof :
141-         lhs_config , constraints  =  self .make_call_config (smir_info , start_symbol = start_symbol ,  sort = sort )
156+         lhs_config , constraints  =  self ._make_symbolic_call_config (smir_info , start_symbol = start_symbol )
142157        lhs  =  CTerm (lhs_config , constraints )
143158
144159        var_config , var_subst  =  split_config_from (lhs_config )
0 commit comments