package coq-core
The Coq Proof Assistant -- Core Binaries and Tools
Install
Dune Dependency
Authors
Maintainers
Sources
coq-8.20.1.tar.gz
md5=0cfaa70f569be9494d24c829e6555d46
sha512=8ee967c636b67b22a4f34115871d8f9b9114df309afc9ddf5f61275251088c6e21f6cf745811df75554d30f4cebb6682f23eeb2e88b771330c4b60ce3f6bf5e2
doc/src/funind_plugin/g_indfun.ml.html
Source file g_indfun.ml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568
# 11 "plugins/funind/g_indfun.mlg" open Ltac_plugin open Util open Pp open Constrexpr open Indfun_common open Indfun open Stdarg open Tacarg open Extraargs open Tactypes open Pcoq.Prim open Pcoq.Constr open Pltac let _ = Mltop.add_known_module "coq-core.plugins.funind" # 31 "plugins/funind/g_indfun.mlg" let pr_fun_ind_using env sigma prc prlc _ opt_c = match opt_c with | None -> mt () | Some b -> spc () ++ hov 2 (str "using" ++ spc () ++ Miscprint.pr_with_bindings (prc env sigma) (prlc env sigma) b) (* Duplication of printing functions because "'a with_bindings" is (internally) not uniform in 'a: indeed constr_with_bindings at the "typed" level has type "open_constr with_bindings" instead of "constr with_bindings"; hence, its printer cannot be polymorphic in (prc,prlc)... *) let pr_fun_ind_using_typed prc prlc _ opt_c = match opt_c with | None -> mt () | Some b -> let env = Global.env () in let evd = Evd.from_env env in let (_, b) = b env evd in spc () ++ hov 2 (str "using" ++ spc () ++ Miscprint.pr_with_bindings (prc env evd) (prlc env evd) b) let (wit_fun_ind_using, fun_ind_using) = Tacentries.argument_extend ~plugin:"coq-core.plugins.funind" ~name:"fun_ind_using" { Tacentries.arg_parsing = Vernacextend.Arg_rules ( [(Pcoq.Production.make (Pcoq.Rule.stop) (fun loc -> # 61 "plugins/funind/g_indfun.mlg" None )); (Pcoq.Production.make (Pcoq.Rule.next (Pcoq.Rule.next (Pcoq.Rule.stop) ((Pcoq.Symbol.token (Pcoq.terminal "using")))) ((Pcoq.Symbol.nterm constr_with_bindings))) (fun c _ loc -> # 60 "plugins/funind/g_indfun.mlg" Some c ))]); Tacentries.arg_tag = Some (Geninterp.Val.Opt (Geninterp.val_tag (Genarg.topwit wit_constr_with_bindings))); Tacentries.arg_intern = Tacentries.ArgInternWit (Genarg.OptArg (wit_constr_with_bindings)); Tacentries.arg_subst = Tacentries.ArgSubstWit (Genarg.OptArg (wit_constr_with_bindings)); Tacentries.arg_interp = Tacentries.ArgInterpWit (Genarg.OptArg (wit_constr_with_bindings)); Tacentries.arg_printer = ((fun env sigma -> # 58 "plugins/funind/g_indfun.mlg" pr_fun_ind_using env sigma ), (fun env sigma -> # 59 "plugins/funind/g_indfun.mlg" pr_fun_ind_using env sigma ), (fun env sigma -> # 57 "plugins/funind/g_indfun.mlg" pr_fun_ind_using_typed )); } let _ = (wit_fun_ind_using, fun_ind_using) let () = Tacentries.tactic_extend "coq-core.plugins.funind" "newfuninv" ~level:0 [(Tacentries.TyML (Tacentries.TyIdent ("functional", Tacentries.TyIdent ("inversion", Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_quantified_hypothesis), Tacentries.TyArg ( Extend.TUopt ( Extend.TUentry (Genarg.get_arg_tag wit_reference)), Tacentries.TyNil)))), (fun hyp fname ist -> # 67 "plugins/funind/g_indfun.mlg" Invfun.invfun hyp fname )))] # 72 "plugins/funind/g_indfun.mlg" let pr_intro_as_pat prc pat = match pat with | Some pat -> str "as" ++ spc () ++ Miscprint.pr_intro_pattern prc pat | None -> mt () let out_disjunctive = CAst.map (function | IntroAction (IntroOrAndPattern l) -> l | _ -> CErrors.user_err Pp.(str "Disjunctive or conjunctive intro pattern expected.")) let (wit_with_names, with_names) = Tacentries.argument_extend ~plugin:"coq-core.plugins.funind" ~name:"with_names" { Tacentries.arg_parsing = Vernacextend.Arg_rules ( [(Pcoq.Production.make (Pcoq.Rule.stop) (fun loc -> # 91 "plugins/funind/g_indfun.mlg" None )); (Pcoq.Production.make (Pcoq.Rule.next (Pcoq.Rule.next (Pcoq.Rule.stop) ((Pcoq.Symbol.token (Pcoq.terminal "as")))) ((Pcoq.Symbol.nterm simple_intropattern))) (fun ipat _ loc -> # 90 "plugins/funind/g_indfun.mlg" Some ipat ))]); Tacentries.arg_tag = Some (Geninterp.Val.Opt (Geninterp.val_tag (Genarg.topwit wit_intro_pattern))); Tacentries.arg_intern = Tacentries.ArgInternWit (Genarg.OptArg (wit_intro_pattern)); Tacentries.arg_subst = Tacentries.ArgSubstWit (Genarg.OptArg (wit_intro_pattern)); Tacentries.arg_interp = Tacentries.ArgInterpWit (Genarg.OptArg (wit_intro_pattern)); Tacentries.arg_printer = ((fun env sigma -> # 88 "plugins/funind/g_indfun.mlg" fun prc _ _ -> pr_intro_as_pat (prc env sigma) ), (fun env sigma -> # 89 "plugins/funind/g_indfun.mlg" fun prc _ _ -> pr_intro_as_pat (prc env sigma) ), (fun env sigma -> # 87 "plugins/funind/g_indfun.mlg" fun prc _ _ -> pr_intro_as_pat (fun c -> prc env sigma @@ snd @@ c env sigma) )); } let _ = (wit_with_names, with_names) # 94 "plugins/funind/g_indfun.mlg" let functional_induction b c x pat = functional_induction true c x (Option.map out_disjunctive pat) let () = Tacentries.tactic_extend "coq-core.plugins.funind" "newfunind" ~level:0 [(Tacentries.TyML (Tacentries.TyIdent ("functional", Tacentries.TyIdent ("induction", Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_lconstr), Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_fun_ind_using), Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_with_names), Tacentries.TyNil))))), (fun c princl pat ist -> # 103 "plugins/funind/g_indfun.mlg" (Ltac_plugin.Internals.onSomeWithHoles (fun x -> functional_induction true c x pat) princl) )))] let () = Tacentries.tactic_extend "coq-core.plugins.funind" "snewfunind" ~level:0 [(Tacentries.TyML (Tacentries.TyIdent ("soft", Tacentries.TyIdent ("functional", Tacentries.TyIdent ("induction", Tacentries.TyArg ( Extend.TUlist1 ( Extend.TUentry (Genarg.get_arg_tag wit_constr)), Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_fun_ind_using), Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_with_names), Tacentries.TyNil)))))), (fun cl princl pat ist -> # 112 "plugins/funind/g_indfun.mlg" let c = match cl with | [] -> assert false | [c] -> c | c::cl -> EConstr.applist(c,cl) in Ltac_plugin.Internals.onSomeWithHoles (fun x -> functional_induction false c x pat) princl )))] # 121 "plugins/funind/g_indfun.mlg" let pr_constr_comma_sequence env sigma prc _ _ = prlist_with_sep pr_comma (prc env sigma) let (wit_constr_comma_sequence', constr_comma_sequence') = Tacentries.argument_extend ~plugin:"coq-core.plugins.funind" ~name:"constr_comma_sequence'" { Tacentries.arg_parsing = Vernacextend.Arg_rules ( [(Pcoq.Production.make (Pcoq.Rule.next (Pcoq.Rule.stop) ((Pcoq.Symbol.nterm constr))) (fun c loc -> # 131 "plugins/funind/g_indfun.mlg" [c] )); (Pcoq.Production.make (Pcoq.Rule.next (Pcoq.Rule.next (Pcoq.Rule.next (Pcoq.Rule.stop) ((Pcoq.Symbol.nterm constr))) ((Pcoq.Symbol.token (Pcoq.terminal ",")))) (Pcoq.Symbol.self)) (fun l _ c loc -> # 130 "plugins/funind/g_indfun.mlg" c::l ))]); Tacentries.arg_tag = Some (Geninterp.Val.List (Geninterp.val_tag (Genarg.topwit wit_constr))); Tacentries.arg_intern = Tacentries.ArgInternWit (Genarg.ListArg (wit_constr)); Tacentries.arg_subst = Tacentries.ArgSubstWit (Genarg.ListArg (wit_constr)); Tacentries.arg_interp = Tacentries.ArgInterpWit (Genarg.ListArg (wit_constr)); Tacentries.arg_printer = ((fun env sigma -> # 129 "plugins/funind/g_indfun.mlg" pr_constr_comma_sequence env sigma ), (fun env sigma -> # 129 "plugins/funind/g_indfun.mlg" pr_constr_comma_sequence env sigma ), (fun env sigma -> # 129 "plugins/funind/g_indfun.mlg" pr_constr_comma_sequence env sigma )); } let _ = (wit_constr_comma_sequence', constr_comma_sequence') # 134 "plugins/funind/g_indfun.mlg" let pr_auto_using env sigma prc _prlc _prt = Pptactic.pr_auto_using (prc env sigma) let (wit_auto_using', auto_using') = Tacentries.argument_extend ~plugin:"coq-core.plugins.funind" ~name:"auto_using'" { Tacentries.arg_parsing = Vernacextend.Arg_rules ( [(Pcoq.Production.make (Pcoq.Rule.stop) (fun loc -> # 144 "plugins/funind/g_indfun.mlg" [] )); (Pcoq.Production.make (Pcoq.Rule.next (Pcoq.Rule.next (Pcoq.Rule.stop) ((Pcoq.Symbol.token (Pcoq.terminal "using")))) ((Pcoq.Symbol.nterm constr_comma_sequence'))) (fun l _ loc -> # 143 "plugins/funind/g_indfun.mlg" l ))]); Tacentries.arg_tag = Some (Geninterp.Val.List (Geninterp.val_tag (Genarg.topwit wit_constr))); Tacentries.arg_intern = Tacentries.ArgInternWit (Genarg.ListArg (wit_constr)); Tacentries.arg_subst = Tacentries.ArgSubstWit (Genarg.ListArg (wit_constr)); Tacentries.arg_interp = Tacentries.ArgInterpWit (Genarg.ListArg (wit_constr)); Tacentries.arg_printer = ((fun env sigma -> # 142 "plugins/funind/g_indfun.mlg" pr_auto_using env sigma ), (fun env sigma -> # 142 "plugins/funind/g_indfun.mlg" pr_auto_using env sigma ), (fun env sigma -> # 142 "plugins/funind/g_indfun.mlg" pr_auto_using env sigma )); } let _ = (wit_auto_using', auto_using') # 147 "plugins/funind/g_indfun.mlg" module Vernac = Pvernac.Vernac_ let (wit_function_fix_definition : Vernacexpr.fixpoint_expr Loc.located Genarg.uniform_genarg_type) = Genarg.create_arg "function_fix_definition" let function_fix_definition = Pcoq.create_generic_entry2 "function_fix_definition" (Genarg.rawwit wit_function_fix_definition) let _ = let () = assert (Pcoq.Entry.is_empty function_fix_definition) in let () = Egramml.grammar_extend ~plugin_uid:("coq-core.plugins.funind", "g_indfun.mlg:0") function_fix_definition (Pcoq.Fresh (Gramlib.Gramext.First, [(None, None, [Pcoq.Production.make (Pcoq.Rule.next (Pcoq.Rule.stop) ((Pcoq.Symbol.nterm Vernac.fix_definition))) (fun g loc -> # 163 "plugins/funind/g_indfun.mlg" Loc.tag ~loc g )])])) in () # 168 "plugins/funind/g_indfun.mlg" let () = let raw_printer env sigma _ _ _ (loc,body) = Ppvernac.pr_rec_definition body in Pptactic.declare_extra_vernac_genarg_pprule wit_function_fix_definition raw_printer let is_proof_termination_interactively_checked recsl = List.exists (function | _,( Vernacexpr.{ rec_order = Some { CAst.v = CMeasureRec _ } } | Vernacexpr.{ rec_order = Some { CAst.v = CWfRec _} }) -> true | _, Vernacexpr.{ rec_order = Some { CAst.v = CStructRec _ } } | _, Vernacexpr.{ rec_order = None } -> false) recsl let classify_as_Fixpoint recsl = Vernac_classifier.classify_vernac (Vernacexpr.(CAst.make @@ { control = []; attrs = []; expr = VernacSynPure (VernacFixpoint(NoDischarge, List.map snd recsl))})) let classify_funind recsl = match classify_as_Fixpoint recsl with | Vernacextend.VtSideff (ids, _) when is_proof_termination_interactively_checked recsl -> Vernacextend.(VtStartProof (GuaranteesOpacity, ids)) | x -> x let is_interactive recsl = match classify_funind recsl with | Vernacextend.VtStartProof _ -> true | _ -> false let () = Vernacextend.static_vernac_extend ~plugin:(Some "coq-core.plugins.funind") ~command:"Function" ?entry:None [(Vernacextend.TyML (false, Vernacextend.TyTerminal ("Function", Vernacextend.TyNonTerminal (Extend.TUlist1sep ( Extend.TUentry (Genarg.get_arg_tag wit_function_fix_definition), "with"), Vernacextend.TyNil)), (let coqpp_body recsl () = # 211 "plugins/funind/g_indfun.mlg" let warn = "-unused-pattern-matching-variable,-non-recursive" in if is_interactive recsl then Vernactypes.vtopenproof (fun () -> CWarnings.with_warn warn Gen_principle.do_generate_principle_interactive (List.map snd recsl)) else Vernactypes.vtdefault (fun () -> CWarnings.with_warn warn Gen_principle.do_generate_principle (List.map snd recsl)) in fun recsl ?loc ~atts () -> coqpp_body recsl (Attributes.unsupported_attributes atts)), Some (fun recsl -> # 210 "plugins/funind/g_indfun.mlg" classify_funind recsl )))] # 224 "plugins/funind/g_indfun.mlg" let pr_fun_scheme_arg (princ_name,fun_name,s) = Names.Id.print princ_name ++ str " :=" ++ spc() ++ str "Induction for " ++ Libnames.pr_qualid fun_name ++ spc() ++ str "Sort " ++ Sorts.pr_sort_family s let (wit_fun_scheme_arg, fun_scheme_arg) = Vernacextend.vernac_argument_extend ~plugin:"coq-core.plugins.funind" ~name:"fun_scheme_arg" { Vernacextend.arg_parsing = Vernacextend.Arg_rules ([( Pcoq.Production.make (Pcoq.Rule.next (Pcoq.Rule.next (Pcoq.Rule.next (Pcoq.Rule.next (Pcoq.Rule.next (Pcoq.Rule.next (Pcoq.Rule.next (Pcoq.Rule.stop) ((Pcoq.Symbol.nterm identref))) ((Pcoq.Symbol.token (Pcoq.terminal ":=")))) ((Pcoq.Symbol.token (Pcoq.terminal "Induction")))) ((Pcoq.Symbol.token (Pcoq.terminal "for")))) ((Pcoq.Symbol.nterm reference))) ((Pcoq.Symbol.token (Pcoq.terminal "Sort")))) ((Pcoq.Symbol.nterm sort_family))) (fun s _ fun_name _ _ _ princ_name loc -> # 235 "plugins/funind/g_indfun.mlg" (princ_name.CAst.v,fun_name,s) ))]); Vernacextend.arg_printer = fun env sigma -> # 234 "plugins/funind/g_indfun.mlg" pr_fun_scheme_arg ; } let _ = (wit_fun_scheme_arg, fun_scheme_arg) # 238 "plugins/funind/g_indfun.mlg" let warning_error names e = match e with | Building_graph e -> let names = pr_enum Libnames.pr_qualid names in let error = if do_observe () then (spc () ++ CErrors.print e) else mt () in Gen_principle.warn_cannot_define_graph (names,error) | Defining_principle e -> let names = pr_enum Libnames.pr_qualid names in let error = if do_observe () then CErrors.print e else mt () in Gen_principle.warn_cannot_define_principle (names,error) | _ -> raise e let () = Vernacextend.static_vernac_extend ~plugin:(Some "coq-core.plugins.funind") ~command:"NewFunctionalScheme" ?entry:None [(Vernacextend.TyML (false, Vernacextend.TyTerminal ("Functional", Vernacextend.TyTerminal ("Scheme", Vernacextend.TyNonTerminal (Extend.TUlist1sep ( Extend.TUentry (Genarg.get_arg_tag wit_fun_scheme_arg), "with"), Vernacextend.TyNil))), (let coqpp_body fas () = Vernactypes.vtdefault (fun () -> # 258 "plugins/funind/g_indfun.mlg" begin try Gen_principle.build_scheme fas with | Gen_principle.No_graph_found -> begin match fas with | (_,fun_name,_)::_ -> begin Gen_principle.make_graph (Smartlocate.global_with_alias fun_name); try Gen_principle.build_scheme fas with | Gen_principle.No_graph_found -> CErrors.user_err Pp.(str "Cannot generate induction principle(s)") | e when CErrors.noncritical e -> let names = List.map (fun (_,na,_) -> na) fas in warning_error names e end | _ -> assert false (* we can only have non empty list *) end | e when CErrors.noncritical e -> let names = List.map (fun (_,na,_) -> na) fas in warning_error names e end ) in fun fas ?loc ~atts () -> coqpp_body fas (Attributes.unsupported_attributes atts)), Some (fun fas -> # 256 "plugins/funind/g_indfun.mlg" Vernacextend.(VtSideff(List.map pi1 fas, VtLater)) )))] let () = Vernacextend.static_vernac_extend ~plugin:(Some "coq-core.plugins.funind") ~command:"NewFunctionalCase" ?entry:None [(Vernacextend.TyML (false, Vernacextend.TyTerminal ("Functional", Vernacextend.TyTerminal ("Case", Vernacextend.TyNonTerminal (Extend.TUentry (Genarg.get_arg_tag wit_fun_scheme_arg), Vernacextend.TyNil))), (let coqpp_body fas () = Vernactypes.vtdefault (fun () -> # 289 "plugins/funind/g_indfun.mlg" Gen_principle.build_case_scheme fas ) in fun fas ?loc ~atts () -> coqpp_body fas (Attributes.unsupported_attributes atts)), Some (fun fas -> # 288 "plugins/funind/g_indfun.mlg" Vernacextend.(VtSideff([pi1 fas], VtLater)) )))] let () = Vernacextend.static_vernac_extend ~plugin:(Some "coq-core.plugins.funind") ~command:"GenerateGraph" ~classifier:(fun _ -> Vernacextend.classify_as_query) ?entry:None [(Vernacextend.TyML (false, Vernacextend.TyTerminal ("Generate", Vernacextend.TyTerminal ("graph", Vernacextend.TyTerminal ("for", Vernacextend.TyNonTerminal (Extend.TUentry (Genarg.get_arg_tag wit_reference), Vernacextend.TyNil)))), (let coqpp_body c () = Vernactypes.vtdefault (fun () -> # 295 "plugins/funind/g_indfun.mlg" Gen_principle.make_graph (Smartlocate.global_with_alias c) ) in fun c ?loc ~atts () -> coqpp_body c (Attributes.unsupported_attributes atts)), None))]
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>