~ubuntu-branches/ubuntu/hardy/ocaml-doc/hardy

« back to all changes in this revision

Viewing changes to examples/demonstr/demo.ml

  • Committer: Bazaar Package Importer
  • Author(s): Samuel Mimram
  • Date: 2007-09-08 01:49:22 UTC
  • mfrom: (0.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20070908014922-lvihyehz0ndq7suu
Tags: 3.10-1
* New upstream release.
* Removed camlp4 documentation since it is not up-to-date.
* Updated to standards version 3.7.2, no changes needed.
* Updated my email address.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
(***********************************************************************)
2
 
(*                                                                     *)
3
 
(*                           Objective Caml                            *)
4
 
(*                                                                     *)
5
 
(*               Pierre Weis, projet Cristal, INRIA Rocquencourt       *)
6
 
(*                                                                     *)
7
 
(*  Copyright 2001 Institut National de Recherche en Informatique et   *)
8
 
(*  en Automatique.  All rights reserved.  This file is distributed    *)
9
 
(*  only by permission.                                                *)
10
 
(*                                                                     *)
11
 
(***********************************************************************)
12
 
open Prop;;
13
 
open Asynt;;
14
 
 
15
 
let examine cha�ne =
16
 
    let proposition = analyse_proposition cha�ne in
17
 
    let variables = variables_libres proposition in
18
 
    try
19
 
      v�rifie_tautologie proposition variables;
20
 
      begin match variables with
21
 
      | [] ->
22
 
          print_string "Th�or�me: "
23
 
      | [var] ->
24
 
          print_string ("Th�or�me: pour toute proposition "^var^", ")
25
 
      | _ ->
26
 
          print_string "Th�or�me: pour toutes propositions ";
27
 
          List.iter (function var -> print_string (var^", ")) variables
28
 
      end;
29
 
      print_string cha�ne;
30
 
      print_newline()
31
 
    with R�futation liaisons ->
32
 
      print_string (cha�ne ^ " n'est pas un th�or�me,\n");
33
 
      print_string "car la proposition est fausse quand\n";
34
 
      List.iter
35
 
       (function (var, b) ->
36
 
         print_string (var ^ " est ");
37
 
         print_string (if b then "vraie" else "fausse");
38
 
         print_newline ())
39
 
       liaisons;;
40
 
 
41
 
let boucle () =
42
 
  try
43
 
    while true do
44
 
      print_string ">>> "; examine(read_line())
45
 
    done
46
 
  with End_of_file -> ();;
47
 
 
48
 
if !Sys.interactive then () else begin boucle(); exit 0 end;;