aboutsummaryrefslogtreecommitdiffstats
path: root/src/BoolToProp.v
blob: 1b8c9233d4f27bb146eee827a96e8d75675d2ba7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
(**************************************************************************)
(*                                                                        *)
(*     SMTCoq                                                             *)
(*     Copyright (C) 2011 - 2019                                          *)
(*                                                                        *)
(*     See file "AUTHORS" for the list of authors                         *)
(*                                                                        *)
(*   This file is distributed under the terms of the CeCILL-C licence     *)
(*                                                                        *)
(**************************************************************************)

Require Import
        Bool ZArith BVList Logic BVList FArray
        SMT_classes SMT_classes_instances ReflectFacts.
Import BVList.BITVECTOR_LIST. 

Local Coercion is_true : bool >-> Sortclass.

Infix "-->" := implb (at level 60, right associativity) : bool_scope.
Infix "<-->" := Bool.eqb (at level 60, right associativity) : bool_scope.

Ltac bool2prop :=
  repeat
    match goal with
    | [ |- forall _ : bitvector _, _] => intro
    | [ |- forall _ : farray _ _, _] => intro
    | [ |- forall _ : _ -> _, _] => intro
    | [ |- forall _ : Z, _] => intro
    | [ |- forall _ : bool, _] => intro
    | [ |- forall _ : Type, _] => intro
    | [ p: Type |-  context[ forall _ : ?t, _ ] ] => intro

    | [ |- forall t : Type, CompDec t -> _  ] => intro
    | [ |- CompDec _ -> _  ] => intro

    | [ |- context[ bv_ult _ _ ] ] => unfold is_true; rewrite bv_ult_B2P
    | [ |- context[ bv_slt _ _ ] ] => unfold is_true; rewrite bv_slt_B2P
    | [ |- context[ bv_eq _ _ ] ]  => unfold is_true; rewrite bv_eq_reflect
    | [ |- context[ equal _ _ ] ]  => unfold is_true; rewrite equal_iff_eq
    | [ |- context[ Z.ltb _ _ ] ]  => unfold is_true; rewrite Z.ltb_lt
    | [ |- context[ Z.gtb _ _ ] ]  => unfold is_true; rewrite Z.gtb_lt
    | [ |- context[ Z.leb _ _ ] ]  => unfold is_true; rewrite Z.leb_le
    | [ |- context[ Z.geb _ _ ] ]  => unfold is_true; rewrite Z.geb_le
    | [ |- context[ Z.eqb _ _ ] ]  => unfold is_true; rewrite Z.eqb_eq

    | [ |- context[?G0 --> ?G1 ] ] =>
      unfold is_true; rewrite <- (@reflect_iff (G0 = true -> G1 = true)  (G0 --> G1)); 
      [ | apply implyP]

    | [ |- context[?G0 || ?G1 ] ] =>
      unfold is_true; rewrite <- (@reflect_iff (G0 = true \/ G1 = true) (G0 || G1)); 
      [ | apply orP]

    | [ |- context[?G0 && ?G1 ] ] =>
      unfold is_true; rewrite <- (@reflect_iff (G0 = true /\ G1 = true) (G0 && G1)); 
      [ | apply andP]

    | [ |- context[?G0 <--> ?G1 ] ] =>
      unfold is_true; rewrite <- (@reflect_iff (G0 = true <-> G1 = true) (G0 <--> G1)); 
      [ | apply iffP]

    | [ |- context[ negb ?G ] ] =>
      unfold is_true; rewrite <- (@reflect_iff (G <> true) (negb G)); 
      [ | apply negP]

    | [R : CompDec ?t |- context[ CompDec ?t  ] ] => exact R

    | [R : EqbType ?t |- context[ EqbType ?t  ] ] => exact R

    | [ |- context[ false = true ] ] => rewrite FalseB
                                              
    | [ |- context[ true = true ] ] => rewrite TrueB

    end.