summaryrefslogtreecommitdiff
path: root/proofs/signatures/th_lra_test.plf
blob: fb3ca828c9846c17a27c4518c19d0785fafa45a0 (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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
; Depends On: th_lra.plf
;; Proof (from predicates on linear polynomials) that the following imply bottom
;
; -x - 1/2 y + 2 >= 0
;  x +     y - 8 >= 0
;  x -     y + 0 >= 0
;
(check
  ; Variables
  (% x var_real
  (% y var_real
  ; linear monomials (combinations)
  (@ m1 (lmonc (~ 1/1) x (lmonc (~ 1/2) y lmonn))
  (@ m2 (lmonc 1/1 x (lmonc 1/1 y lmonn))
  (@ m3 (lmonc 1/1 x (lmonc (~ 1/1) y lmonn))
  ; linear polynomials (affine)
  (@ p1 (polyc 2/1 m1)
  (@ p2 (polyc (~ 8/1) m2)
  (@ p3 (polyc 0/1 m3)
  (% pf_nonneg_1 (th_holds (>=0_poly p1))
  (% pf_nonneg_2 (th_holds (>=0_poly p2))
  (% pf_nonneg_3 (th_holds (>=0_poly p3))
     (:
       (holds cln)
       (lra_contra_>=
         _
         (lra_add_>=_>= _ _ _
           (lra_mul_c_>= _ _ 4/1 pf_nonneg_1)
           (lra_add_>=_>= _ _ _
             (lra_mul_c_>= _ _ 3/1 pf_nonneg_2)
             (lra_add_>=_>= _ _ _
               (lra_mul_c_>= _ _ 1/1 pf_nonneg_3)
               (lra_axiom_>= 0/1))))))
  )))))
  ))))
  ))
)

;; Proof (from predicates on real terms) that the following imply bottom
;
; -x - 1/2 y >= 2
;  x +     y >= 8
;  x -     y >= 0
;
(check
  ; Declarations
  ; Variables
  (% x var_real
  (% y var_real
  ; real predicates
  (@ f1 (>=_Real (+_Real (*_Real (a_real (~ 1/1)) (a_var_real x)) (*_Real (a_real (~ 1/2)) (a_var_real y))) (a_real (~ 2/1)))
  (@ f2 (>=_Real (+_Real (*_Real (a_real 1/1) (a_var_real x)) (*_Real (a_real 1/1) (a_var_real y))) (a_real 8/1))
  (@ f3 (>=_Real (+_Real (*_Real (a_real 1/1) (a_var_real x)) (*_Real (a_real (~ 1/1)) (a_var_real y))) (a_real 0/1))
  ; proof of real predicates
  (% pf_f1 (th_holds f1)
  (% pf_f2 (th_holds f2)
  (% pf_f3 (th_holds f3)


  ; Normalization
  ; real term -> linear polynomial normalization witnesses
  (@ n1 (poly_formula_norm_>=  _ _ _
        (pn_- _ _ _ _ _
          (pn_+ _ _ _ _ _
            (pn_mul_c_L _ _ _ (~ 1/1) (pn_var x))
            (pn_mul_c_L _ _ _ (~ 1/2) (pn_var y)))
          (pn_const (~ 2/1))))
  (@ n2 (poly_formula_norm_>=  _ _ _
        (pn_- _ _ _ _ _
          (pn_+ _ _ _ _ _
            (pn_mul_c_L _ _ _ 1/1 (pn_var x))
            (pn_mul_c_L _ _ _ 1/1 (pn_var y)))
          (pn_const 8/1)))
  (@ n3 (poly_formula_norm_>=  _ _ _
        (pn_- _ _ _ _ _
          (pn_+ _ _ _ _ _
            (pn_mul_c_L _ _ _ 1/1 (pn_var x))
            (pn_mul_c_L _ _ _ (~ 1/1) (pn_var y)))
          (pn_const 0/1)))
  ; proof of linear polynomial predicates
  (@ pf_n1 (poly_form _ _ n1 pf_f1)
  (@ pf_n2 (poly_form _ _ n2 pf_f2)
  (@ pf_n3 (poly_form _ _ n3 pf_f3)

  ; derivation of a contradiction using farkas coefficients
    (:
      (holds cln)
      (lra_contra_>= _
       (lra_add_>=_>= _ _ _
         (lra_mul_c_>= _ _ 4/1 pf_n1)
         (lra_add_>=_>= _ _ _
           (lra_mul_c_>= _ _ 3/1 pf_n2)
           (lra_add_>=_>= _ _ _
             (lra_mul_c_>= _ _ 1/1 pf_n3)
             (lra_axiom_>= 0/1))))))
  )))
  )))
  )))
  )))
  ))
)

;; Term proof, 2 (>=), one (not >=)
;; Proof (from predicates on real terms) that the following imply bottom
;
;        -x +     y >=  2
;         x +     y >=  2
;     not[        y >= -2] => [y < -2] => [-y > 2]
;
(check
  ; Declarations
  ; Variables
  (% x var_real
  (% y var_real
  ; real predicates
  (@ f1 (>=_Real
          (+_Real (*_Real (a_real (~ 1/1)) (a_var_real x)) (a_var_real y))
          (a_real 2/1))
  (@ f2 (>=_Real
          (+_Real (a_var_real x) (a_var_real y))
          (a_real 2/1))
  (@ f3 (not (>=_Real (a_var_real y) (a_real (~ 2/1))))

  ; Normalization
  ; proof of real predicates
  (% pf_f1 (th_holds f1)
  (% pf_f2 (th_holds f2)
  (% pf_f3 (th_holds f3)
  ; real term -> linear polynomial normalization witnesses
  (@ n1 (poly_formula_norm_>=  _ _ _
        (pn_- _ _ _ _ _
          (pn_+ _ _ _ _ _
            (pn_mul_c_L _ _ _ (~ 1/1) (pn_var x))
            (pn_var y))
          (pn_const 2/1)))
  (@ n2 (poly_formula_norm_>=  _ _ _
        (pn_- _ _ _ _ _
          (pn_+ _ _ _ _ _
            (pn_var x)
            (pn_var y))
          (pn_const 2/1)))
  (@ n3 (poly_formula_norm_>=  _ _ _
        (pn_- _ _ _ _ _
          (pn_var y)
          (pn_const (~ 2/1))))
  ; proof of linear polynomial predicates
  (@ pf_n1 (poly_form _ _ n1 pf_f1)
  (@ pf_n2 (poly_form _ _ n2 pf_f2)
  (@ pf_n3 (poly_flip_not_>= _ _ (poly_form_not _ _ n3 pf_f3))

  ; derivation of a contradiction using farkas coefficients
    (:
      (holds cln)
      (lra_contra_> _
       (lra_add_>=_> _ _ _
         (lra_mul_c_>= _ _ 1/1 pf_n1)
         (lra_add_>=_> _ _ _
           (lra_mul_c_>= _ _ 1/1 pf_n2)
           (lra_add_>_>= _ _ _
             (lra_mul_c_> _ _ 2/1 pf_n3)
             (lra_axiom_>= 0/1))))))
  )))
  )))
  )))
  )))
  ))
)
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback