99
1010from pyk .cli .args import KCLIArgs
1111from pyk .cterm .show import CTermShow
12- from pyk .kast .outer import KFlatModule , KImport
1312from pyk .kast .pretty import PrettyPrinter
14- from pyk .proof .reachability import APRProof , APRProver
13+ from pyk .proof .reachability import APRProof
1514from pyk .proof .show import APRProofShow
1615from pyk .proof .tui import APRProofViewer
1716
2019from .kmir import KMIR , KMIRAPRNodePrinter
2120from .linker import link
2221from .options import (
23- GenSpecOpts ,
2422 InfoOpts ,
2523 LinkOpts ,
26- ProveRawOpts ,
2724 ProveRSOpts ,
2825 PruneOpts ,
2926 RunOpts ,
3027 ShowOpts ,
3128 ViewOpts ,
3229)
33- from .parse .parser import parse_json
3430from .smir import SMIRInfo , Ty
3531from .utils import render_leaf_k_cells , render_rules , render_statistics
3632
@@ -71,55 +67,6 @@ def _kmir_prove_rs(opts: ProveRSOpts) -> None:
7167 sys .exit (1 )
7268
7369
74- def _kmir_gen_spec (opts : GenSpecOpts ) -> None :
75- kmir = KMIR (HASKELL_DEF_DIR , LLVM_LIB_DIR )
76-
77- parse_result = parse_json (kmir .definition , opts .input_file , 'Pgm' )
78- if parse_result is None :
79- print ('Parse error!' , file = sys .stderr )
80- sys .exit (1 )
81-
82- smir_info = SMIRInfo .from_file (opts .input_file ).reduce_to (opts .start_symbol )
83- apr_proof = kmir .apr_proof_from_smir (
84- str (opts .input_file .stem .replace ('_' , '-' )),
85- smir_info ,
86- start_symbol = opts .start_symbol ,
87- sort = 'KmirCell' ,
88- )
89- claim = apr_proof .as_claim ()
90-
91- output_file = opts .output_file
92- if output_file is None :
93- suffixes = '' .join (opts .input_file .suffixes )
94- base = opts .input_file .name .removesuffix (suffixes ).replace ('_' , '-' )
95- output_file = Path (f'{ base } -spec.k' )
96-
97- module_name = output_file .stem .upper ().replace ('_' , '-' )
98- spec_module = KFlatModule (module_name , (claim ,), (KImport ('KMIR' ),))
99-
100- output_file .write_text (kmir .pretty_print (spec_module ))
101-
102-
103- def _kmir_prove_raw (opts : ProveRawOpts ) -> None :
104- kmir = KMIR (HASKELL_DEF_DIR , LLVM_LIB_DIR , bug_report = opts .bug_report )
105- claim_index = kmir .get_claim_index (opts .spec_file )
106- labels = claim_index .labels (include = opts .include_labels , exclude = opts .exclude_labels )
107- for label in labels :
108- print (f'Proving { label } ' )
109- claim = claim_index [label ]
110- if not opts .reload and opts .proof_dir is not None and APRProof .proof_data_exists (label , opts .proof_dir ):
111- _LOGGER .info (f'Reading proof from disc: { opts .proof_dir } , { label } ' )
112- proof = APRProof .read_proof_data (opts .proof_dir , label )
113- else :
114- _LOGGER .info (f'Constructing initial proof: { label } ' )
115- proof = APRProof .from_claim (kmir .definition , claim , {}, proof_dir = opts .proof_dir )
116- with kmir .kcfg_explore (label ) as kcfg_explore :
117- prover = APRProver (kcfg_explore , execute_depth = opts .max_depth )
118- prover .advance_proof (proof , max_iterations = opts .max_iterations )
119- summary = proof .summary
120- print (f'{ summary } ' )
121-
122-
12370def _kmir_view (opts : ViewOpts ) -> None :
12471 kmir = KMIR (HASKELL_DEF_DIR , LLVM_LIB_DIR )
12572 proof = APRProof .read_proof_data (opts .proof_dir , opts .id )
@@ -212,12 +159,8 @@ def kmir(args: Sequence[str]) -> None:
212159 match opts :
213160 case RunOpts ():
214161 _kmir_run (opts )
215- case GenSpecOpts ():
216- _kmir_gen_spec (opts )
217162 case InfoOpts ():
218163 _kmir_info (opts )
219- case ProveRawOpts ():
220- _kmir_prove_raw (opts )
221164 case ViewOpts ():
222165 _kmir_view (opts )
223166 case ShowOpts ():
@@ -248,15 +191,6 @@ def _arg_parser() -> ArgumentParser:
248191 )
249192 run_parser .add_argument ('--haskell-backend' , action = 'store_true' , help = 'Run with the haskell backend' )
250193
251- gen_spec_parser = command_parser .add_parser (
252- 'gen-spec' , help = 'Generate a k spec from a SMIR json' , parents = [kcli_args .logging_args ]
253- )
254- gen_spec_parser .add_argument ('input_file' , metavar = 'FILE' , help = 'MIR program to generate a spec for' )
255- gen_spec_parser .add_argument ('--output-file' , metavar = 'FILE' , help = 'Output file' )
256- gen_spec_parser .add_argument (
257- '--start-symbol' , type = str , metavar = 'SYMBOL' , default = 'main' , help = 'Symbol name to begin execution from'
258- )
259-
260194 info_parser = command_parser .add_parser (
261195 'info' , help = 'Show information about a SMIR JSON file' , parents = [kcli_args .logging_args ]
262196 )
@@ -276,17 +210,6 @@ def _arg_parser() -> ArgumentParser:
276210 proof_args .add_argument ('id' , metavar = 'PROOF_ID' , help = 'The id of the proof to view' )
277211 proof_args .add_argument ('--proof-dir' , metavar = 'DIR' , help = 'Proof directory' )
278212
279- prove_raw_parser = command_parser .add_parser (
280- 'prove' , help = 'Utilities for working with proofs over SMIR' , parents = [kcli_args .logging_args , prove_args ]
281- )
282- prove_raw_parser .add_argument ('input_file' , metavar = 'FILE' , help = 'K File with the spec module' )
283- prove_raw_parser .add_argument (
284- '--include-labels' , metavar = 'LABELS' , help = 'Comma separated list of claim labels to include'
285- )
286- prove_raw_parser .add_argument (
287- '--exclude-labels' , metavar = 'LABELS' , help = 'Comma separated list of claim labels to exclude'
288- )
289-
290213 display_args = ArgumentParser (add_help = False )
291214 display_args .add_argument (
292215 '--full-printer' ,
@@ -394,22 +317,8 @@ def _parse_args(ns: Namespace) -> KMirOpts:
394317 start_symbol = ns .start_symbol ,
395318 haskell_backend = ns .haskell_backend ,
396319 )
397- case 'gen-spec' :
398- return GenSpecOpts (input_file = Path (ns .input_file ), output_file = ns .output_file , start_symbol = ns .start_symbol )
399320 case 'info' :
400321 return InfoOpts (smir_file = Path (ns .smir_file ), types = ns .types )
401- case 'prove' :
402- proof_dir = Path (ns .proof_dir )
403- return ProveRawOpts (
404- spec_file = Path (ns .input_file ),
405- proof_dir = ns .proof_dir ,
406- include_labels = ns .include_labels ,
407- exclude_labels = ns .exclude_labels ,
408- bug_report = ns .bug_report ,
409- max_depth = ns .max_depth ,
410- reload = ns .reload ,
411- max_iterations = ns .max_iterations ,
412- )
413322 case 'show' :
414323 return ShowOpts (
415324 proof_dir = Path (ns .proof_dir ),
0 commit comments