From 31f877fe0b3f0c0a4d5f03ff40c5afe5eb3f326f Mon Sep 17 00:00:00 2001 From: Claudio Sacerdoti Coen Date: Mon, 22 Mar 2004 11:27:32 +0000 Subject: [PATCH] - power notation - mult for BinInt *** DANGEROUS *** - multiple NUM instances now are different instances --- helm/ocaml/cic_disambiguation/arit_notation.ml | 12 ++++++++++++ helm/ocaml/cic_disambiguation/cicTextualParser2.ml | 10 +++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/helm/ocaml/cic_disambiguation/arit_notation.ml b/helm/ocaml/cic_disambiguation/arit_notation.ml index d07cc49ef..780fed363 100644 --- a/helm/ocaml/cic_disambiguation/arit_notation.ml +++ b/helm/ocaml/cic_disambiguation/arit_notation.ml @@ -42,6 +42,12 @@ EXTEND return_term loc (CicAst.Appl [CicAst.Symbol ("divide", 0); t1; t2]) ] ]; + term: LEVEL "power" + [ + [ t1 = term; SYMBOL "^"; t2 = term -> + return_term loc (CicAst.Appl [CicAst.Symbol ("power", 0); t1; t2]) + ] + ]; term: LEVEL "inv" [ [ SYMBOL "-"; t = term -> @@ -117,6 +123,12 @@ let _ = (const HelmLibraryObjects.Reals.rmult_URI); DisambiguateChoices.add_binary_op "times" "binary positive times" HelmLibraryObjects.BinPos.pmult; + DisambiguateChoices.add_binary_op "times" "binary integer times" + HelmLibraryObjects.BinInt.zmult; + DisambiguateChoices.add_binary_op "power" "real power" + (const HelmLibraryObjects.Reals.pow_URI); + DisambiguateChoices.add_binary_op "power" "integer power" + (const HelmLibraryObjects.BinInt.zpower_URI); DisambiguateChoices.add_binary_op "divide" "real divide" (const HelmLibraryObjects.Reals.rdiv_URI); DisambiguateChoices.add_unary_op "uminus" "real unary minus" diff --git a/helm/ocaml/cic_disambiguation/cicTextualParser2.ml b/helm/ocaml/cic_disambiguation/cicTextualParser2.ml index f530a31be..2b6d6c0c9 100644 --- a/helm/ocaml/cic_disambiguation/cicTextualParser2.ml +++ b/helm/ocaml/cic_disambiguation/cicTextualParser2.ml @@ -40,6 +40,13 @@ type tactical = (CicAst.term, string) TacticAst.tactic TacticAst.tactical type command = CicAst.term CommandAst.command type script = CicAst.term CommandAst.Script.script +let fresh_num_instance = + let n = ref 0 in + function () -> + incr n; + !n +;; + let choice_of_uri (uri: string) = let cic = HelmLibraryObjects.term_of_uri (UriManager.uri_of_string uri) in (uri, (fun _ _ _ -> cic)) @@ -175,13 +182,14 @@ EXTEND ] | "add" LEFTA [ (* nothing here by default *) ] | "mult" LEFTA [ (* nothing here by default *) ] + | "power" LEFTA [ (* nothing here by default *) ] | "inv" NONA [ (* nothing here by default *) ] | "simple" NONA [ sort = sort -> CicAst.Sort sort | n = substituted_name -> return_term loc n | PAREN "("; head = term; args = LIST1 term; PAREN ")" -> return_term loc (CicAst.Appl (head :: args)) - | i = NUM -> return_term loc (CicAst.Num (i, 0)) + | i = NUM -> return_term loc (CicAst.Num (i, (fresh_num_instance ()))) | IMPLICIT -> return_term loc CicAst.Implicit | m = META; substs = [ -- 2.39.2