X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Focaml%2Fcic_disambiguation%2Farit_notation.ml;h=51faaa6acc06a91e6cc1d400e661b92217c203a1;hb=b3bfd6b249600b15552c890306a635aee30c2a74;hp=53de39449b24de7af95169348594d5ae18a66c8c;hpb=0d853dfc19b683f5d37741df405a2db721f7221a;p=helm.git diff --git a/helm/ocaml/cic_disambiguation/arit_notation.ml b/helm/ocaml/cic_disambiguation/arit_notation.ml index 53de39449..51faaa6ac 100644 --- a/helm/ocaml/cic_disambiguation/arit_notation.ml +++ b/helm/ocaml/cic_disambiguation/arit_notation.ml @@ -39,7 +39,7 @@ EXTEND [ t1 = term; SYMBOL "*"; t2 = term -> return_term loc (CicAst.Appl [CicAst.Symbol ("times", 0); t1; t2]) | t1 = term; SYMBOL "/"; t2 = term -> - return_term loc (CicAst.Appl [CicAst.Symbol ("div", 0); t1; t2]) + return_term loc (CicAst.Appl [CicAst.Symbol ("divide", 0); t1; t2]) ] ]; term: LEVEL "inv" @@ -48,31 +48,88 @@ EXTEND return_term loc (CicAst.Appl [CicAst.Symbol ("uminus", 0); t]) ] ]; + term: LEVEL "relop" + [ + [ t1 = term; SYMBOL <:unicode> (* ≤ *); t2 = term -> + return_term loc (CicAst.Appl [CicAst.Symbol ("leq", 0); t1; t2]) + | t1 = term; SYMBOL <:unicode> (* ≥ *); t2 = term -> + return_term loc (CicAst.Appl [CicAst.Symbol ("geq", 0); t1; t2]) + | t1 = term; SYMBOL "<"; t2 = term -> + return_term loc (CicAst.Appl [CicAst.Symbol ("lt", 0); t1; t2]) + | t1 = term; SYMBOL ">"; t2 = term -> + return_term loc (CicAst.Appl [CicAst.Symbol ("gt", 0); t1; t2]) + | t1 = term; SYMBOL <:unicode> (* ≠ *); t2 = term -> + return_term loc (CicAst.Appl [CicAst.Symbol ("neq", 0); t1; t2]) + ] + ]; END let _ = + let const s = Cic.Const (s, []) in + let mutind s = Cic.MutInd (s, 0, []) in + DisambiguateChoices.add_num_choice ("natural number", (fun _ num _ -> HelmLibraryObjects.build_nat (int_of_string num))); DisambiguateChoices.add_num_choice ("real number", (fun _ num _ -> HelmLibraryObjects.build_real (int_of_string num))); - DisambiguateChoices.add_symbol_choice "plus" - ("natural plus", - (fun env _ args -> - let t1, t2 = - match args with - | [t1; t2] -> t1, t2 - | _ -> raise DisambiguateChoices.Invalid_choice - in - Cic.Appl [ HelmLibraryObjects.Peano.plus; t1; t2 ])); - DisambiguateChoices.add_symbol_choice "plus" - ("real plus", - (fun env _ args -> - let t1, t2 = - match args with - | [t1; t2] -> t1, t2 - | _ -> raise DisambiguateChoices.Invalid_choice - in - Cic.Appl [ HelmLibraryObjects.Reals.rplus; t1; t2 ])); + + DisambiguateChoices.add_binary_op "plus" "natural plus" + HelmLibraryObjects.Peano.plus; + DisambiguateChoices.add_binary_op "plus" "real plus" + HelmLibraryObjects.Reals.rplus; + DisambiguateChoices.add_binary_op "minus" "natural minus" + (const HelmLibraryObjects.Peano.minus_URI); + DisambiguateChoices.add_binary_op "minus" "real minus" + (const HelmLibraryObjects.Reals.rminus_URI); + DisambiguateChoices.add_binary_op "times" "natural times" + (const HelmLibraryObjects.Peano.mult_URI); + DisambiguateChoices.add_binary_op "times" "real times" + (const HelmLibraryObjects.Reals.rmult_URI); + DisambiguateChoices.add_binary_op "divide" "real divide" + (const HelmLibraryObjects.Reals.rdiv_URI); + DisambiguateChoices.add_unary_op "uminus" "real unary minus" + (const HelmLibraryObjects.Reals.ropp_URI); + + DisambiguateChoices.add_binary_op "leq" "natural 'less or equal to'" + (mutind HelmLibraryObjects.Peano.le_URI); + DisambiguateChoices.add_binary_op "leq" "real 'less or equal to'" + (const HelmLibraryObjects.Reals.rle_URI); + DisambiguateChoices.add_binary_op "geq" "natural 'greater or equal to'" + (const HelmLibraryObjects.Peano.ge_URI); + DisambiguateChoices.add_binary_op "geq" "real 'greater or equal to'" + (const HelmLibraryObjects.Reals.rge_URI); + DisambiguateChoices.add_binary_op "lt" "natural 'less than'" + (const HelmLibraryObjects.Peano.lt_URI); + DisambiguateChoices.add_binary_op "lt" "real 'less than'" + (const HelmLibraryObjects.Reals.rlt_URI); + DisambiguateChoices.add_binary_op "gt" "natural 'greater than'" + (const HelmLibraryObjects.Peano.gt_URI); + DisambiguateChoices.add_binary_op "gt" "real 'greater than'" + (const HelmLibraryObjects.Reals.rgt_URI); + DisambiguateChoices.add_symbol_choice "neq" + ("not equal to (leibnitz)", + (fun env _ args -> + let t1, t2 = + match args with + | [t1; t2] -> t1, t2 + | _ -> raise DisambiguateChoices.Invalid_choice + in + Cic.Appl [ const HelmLibraryObjects.Logic.not_URI; + Cic.Appl [ + Cic.MutInd (HelmLibraryObjects.Logic.eq_URI, 0, []); + Cic.Implicit (Some `Type); t1; t2 ] ])); + DisambiguateChoices.add_symbol_choice "neq" + ("not equal to (sort Type)", + (fun env _ args -> + let t1, t2 = + match args with + | [t1; t2] -> t1, t2 + | _ -> raise DisambiguateChoices.Invalid_choice + in + Cic.Appl [ const HelmLibraryObjects.Logic.not_URI; + Cic.Appl [ + Cic.MutInd (HelmLibraryObjects.Logic_Type.eqt_URI, 0, []); + Cic.Implicit (Some `Type); t1; t2 ] ]));