(* Copyright (C) 2004, HELM Team. * * This file is part of HELM, an Hypertextual, Electronic * Library of Mathematics, developed at the Computer Science * Department, University of Bologna, Italy. * * HELM is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * HELM is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with HELM; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, * MA 02111-1307, USA. * * For details, see the HELM World-Wide-Web page, * http://helm.cs.unibo.it/ *) open CicTextualParser2 EXTEND term: LEVEL "add" [ [ t1 = term; SYMBOL "+"; t2 = term -> return_term loc (CicAst.Appl [CicAst.Symbol ("plus", 0); t1; t2]) | t1 = term; SYMBOL "-"; t2 = term -> return_term loc (CicAst.Appl [CicAst.Symbol ("minus", 0); t1; t2]) ] ]; term: LEVEL "mult" [ [ 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 ("divide", 0); t1; t2]) ] ]; term: LEVEL "inv" [ [ SYMBOL "-"; t = term -> 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_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 ] ]));