(************************************************************************) (* * The Rocq Prover / The Rocq Development Team *) (* v * Copyright INRIA, CNRS and contributors *) (* <O___,, * (see version control and CREDITS file for authors & dates) *) (* \VV/ **************************************************************) (* // * This file is distributed under the terms of the *) (* * GNU Lesser General Public License Version 2.1 *) (* * (see LICENSE file for the text of the license) *) (************************************************************************)
open Names open Genredexpr open Tac2expr open Tac2val open Tac2ffi open Tac2types open Tac2extffi open Proofview.Notations
module Value = Tac2ffi
(** Make a representation with a dummy from function *) let make_to_repr f = Tac2ffi.make_repr (fun _ -> assert false) f
let return x = Proofview.tclUNIT x let thaw f = f () let uthaw r f = Tac2ffi.to_fun1 Tac2ffi.of_unit (repr_to r) f ()
let to_name c = match Value.to_option Value.to_ident c with
| None -> Anonymous
| Some id -> Name id
let to_hyp_location_flag v = match Value.to_int v with
| 0 -> InHyp
| 1 -> InHypTypeOnly
| 2 -> InHypValueOnly
| _ -> assert false
let to_clause v = match Value.to_tuple v with
| [| hyps; concl |] -> let cast v = match Value.to_tuple v with
| [| hyp; occ; flag |] ->
(Value.to_ident hyp, to_occurrences occ, to_hyp_location_flag flag)
| _ -> assert false in let hyps = Value.to_option (fun h -> Value.to_list cast h) hyps in
{ onhyps = hyps; concl_occs = to_occurrences concl; }
| _ -> assert false
let clause = make_to_repr to_clause
let to_red_strength = function
| ValInt 0 -> Norm
| ValInt 1 -> Head
| _ -> assert false
let reference_with_occs = pair reference occurrences
let to_red_context = to_option (to_pair to_pattern to_occurrences)
let red_context = make_to_repr to_red_context
let rec to_intro_pattern v = match Value.to_block v with
| (0, [| b |]) -> IntroForthcoming (Value.to_bool b)
| (1, [| pat |]) -> IntroNaming (to_intro_pattern_naming pat)
| (2, [| act |]) -> IntroAction (to_intro_pattern_action act)
| _ -> assert false
and to_intro_pattern_naming = function
| ValBlk (0, [| id |]) -> IntroIdentifier (Value.to_ident id)
| ValBlk (1, [| id |]) -> IntroFresh (Value.to_ident id)
| ValInt 0 -> IntroAnonymous
| _ -> assert false
and to_intro_pattern_action = function
| ValInt 0 -> IntroWildcard
| ValBlk (0, [| op |]) -> IntroOrAndPattern (to_or_and_intro_pattern op)
| ValBlk (1, [| inj |]) -> letmap ipat = to_intro_pattern ipat in
IntroInjection (Value.to_list map inj)
| ValBlk (2, [| c; ipat |]) -> let c = Value.to_fun1 Value.of_unit Value.to_constr c in
IntroApplyOn (c, to_intro_pattern ipat)
| ValBlk (3, [| b |]) -> IntroRewrite (Value.to_bool b)
| _ -> assert false
and to_or_and_intro_pattern v = match Value.to_block v with
| (0, [| ill |]) ->
IntroOrPattern (Value.to_list to_intro_patterns ill)
| (1, [| il |]) ->
IntroAndPattern (to_intro_patterns il)
| _ -> assert false
and to_intro_patterns il =
Value.to_list to_intro_pattern il
let rec of_intro_pattern = function
| IntroForthcoming b -> of_block (0, [|of_bool b|])
| IntroNaming pat -> of_block (1, [|of_intro_pattern_naming pat|])
| IntroAction act -> of_block (2, [|of_intro_pattern_action act|])
and of_intro_pattern_naming = function
| IntroIdentifier id -> of_block (0, [|of_ident id|])
| IntroFresh id -> of_block (1, [|of_ident id|])
| IntroAnonymous -> of_int 0
and of_intro_pattern_action = function
| IntroWildcard -> of_int 0
| IntroOrAndPattern op -> of_block (0, [|of_or_and_intro_pattern op|])
| IntroInjection inj -> of_block (1, [|of_list of_intro_pattern inj|])
| IntroApplyOn (c, ipat) -> let c = repr_of (fun1 unit constr) c in
of_block (2, [|c; of_intro_pattern ipat|])
| IntroRewrite b -> of_block (3, [|of_bool b|])
and of_or_and_intro_pattern = function
| IntroOrPattern ill -> of_block (0, [|of_list of_intro_patterns ill|])
| IntroAndPattern il -> of_block (1, [|of_intro_patterns il|])
and of_intro_patterns il = of_list of_intro_pattern il
let intro_pattern = make_repr of_intro_pattern to_intro_pattern
let intro_patterns = make_repr of_intro_patterns to_intro_patterns
let to_destruction_arg v = match Value.to_block v with
| (0, [| c |]) -> let c = uthaw constr_with_bindings c in
ElimOnConstr c
| (1, [| id |]) -> ElimOnIdent (Value.to_ident id)
| (2, [| n |]) -> ElimOnAnonHyp (Value.to_int n)
| _ -> assert false
let destruction_arg = make_to_repr to_destruction_arg
let to_induction_clause v = match Value.to_tuple v with
| [| arg; eqn; as_; in_ |] -> let arg = to_destruction_arg arg in let eqn = Value.to_option to_intro_pattern_naming eqn in let as_ = Value.to_option to_or_and_intro_pattern as_ in let in_ = Value.to_option to_clause in_ in
(arg, eqn, as_, in_)
| _ ->
assert false
let induction_clause = make_to_repr to_induction_clause
let to_assertion v = match Value.to_block v with
| (0, [| ipat; t; tac |]) -> let to_tac t = Value.to_fun1 Value.of_unit Value.to_unit t in let ipat = Value.to_option to_intro_pattern ipat in let t = Value.to_constr t in let tac = Value.to_option to_tac tac in
AssertType (ipat, t, tac)
| (1, [| id; c |]) ->
AssertValue (Value.to_ident id, Value.to_constr c)
| _ -> assert false
let assertion = make_to_repr to_assertion
let to_multi = function
| ValBlk (0, [| n |]) -> Precisely (Value.to_int n)
| ValBlk (1, [| n |]) -> UpTo (Value.to_int n)
| ValInt 0 -> RepeatStar
| ValInt 1 -> RepeatPlus
| _ -> assert false
let to_rewriting v = match Value.to_tuple v with
| [| orient; repeat; c |] -> let orient = Value.to_option Value.to_bool orient in let repeat = to_multi repeat in let c = uthaw constr_with_bindings c in
(orient, repeat, c)
| _ -> assert false
let rewriting = make_to_repr to_rewriting
let to_debug v = match Value.to_int v with
| 0 -> Hints.Off
| 1 -> Hints.Info
| 2 -> Hints.Debug
| _ -> assert false
let debug = make_to_repr to_debug
let to_strategy v = match Value.to_int v with
| 0 -> Class_tactics.Bfs
| 1 -> Class_tactics.Dfs
| _ -> assert false
let strategy = make_to_repr to_strategy
let to_inversion_kind v = match Value.to_int v with
| 0 -> Inv.SimpleInversion
| 1 -> Inv.FullInversion
| 2 -> Inv.FullInversionClear
| _ -> assert false
let inversion_kind = make_to_repr to_inversion_kind
let () =
define "tac_assert"
(assertion @-> tac unit)
Tac2tactics.assert_
let tac_enough c tac ipat = let tac = Option.map (fun o -> Option.map (fun f -> thaw f) o) tac in
Tac2tactics.forward false tac ipat c let () =
define "tac_enough"
(constr @-> option (option (thunk unit)) @-> option intro_pattern @-> tac unit)
tac_enough
let tac_pose na c = Tactics.letin_tac None na c None Locusops.nowhere let () =
define "tac_pose"
(name @-> constr @-> tac unit)
tac_pose
let tac_set ev p cl =
Proofview.tclEVARMAP >>= fun sigma ->
thaw p >>= fun (na, c) ->
Tac2tactics.letin_pat_tac ev None na (Some sigma, c) cl let () =
define "tac_set"
(bool @-> thunk (pair name constr) @-> clause @-> tac unit)
tac_set
let tac_remember ev na c eqpat cl = let eqpat = Option.default (IntroNaming IntroAnonymous) eqpat in match eqpat with
| IntroNaming eqpat ->
Proofview.tclEVARMAP >>= fun sigma ->
thaw c >>= fun c ->
Tac2tactics.letin_pat_tac ev (Some (true, eqpat)) na (Some sigma, c) cl
| _ ->
Tacticals.tclZEROMSG (Pp.str "Invalid pattern for remember") let () =
define "tac_remember"
(bool @-> name @-> thunk constr @-> option intro_pattern @-> clause @-> tac unit)
tac_remember
let () =
define "tac_destruct"
(bool @-> list induction_clause @-> option constr_with_bindings @-> tac unit)
(Tac2tactics.induction_destruct false)
let () =
define "tac_induction"
(bool @-> list induction_clause @-> option constr_with_bindings @-> tac unit)
(Tac2tactics.induction_destruct true)
let () = define "tac_exfalso" (unit @-> tac unit) @@ fun () ->
Tactics.exfalso
let tac_intro id mv = let mv = Option.default Logic.MoveLast mv in
Tactics.intro_move id mv let () =
define "tac_intro" (option ident @-> option move_location @-> tac unit) tac_intro
(*
TACTIC EXTEND exact [ "exact" casted_constr(c) ] -> [ Tactics.exact_no_check c ] END
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.