File size: 4,326 Bytes
f1121ec
 
 
 
be20c4a
 
142a8b5
 
e06e0e9
be20c4a
e06e0e9
 
be20c4a
e06e0e9
 
 
 
 
 
 
cf2e9b3
 
 
 
 
 
 
 
 
 
 
 
 
f6354a2
cf2e9b3
e06e0e9
f212151
e06e0e9
1b5092f
e06e0e9
 
 
df4271d
e06e0e9
 
 
 
1b5092f
 
 
 
 
 
 
 
 
e06e0e9
1b5092f
 
 
 
 
 
 
 
 
e06e0e9
1b5092f
 
 
 
 
 
 
 
 
 
 
 
 
 
e06e0e9
1b5092f
 
 
 
 
 
 
 
 
e06e0e9
1b5092f
 
 
 
 
 
 
 
 
 
 
e06e0e9
1b5092f
 
 
 
 
 
 
 
 
 
df4271d
 
 
 
 
 
 
 
 
 
 
 
e06e0e9
1b5092f
e06e0e9
1b5092f
e06e0e9
f1121ec
e06e0e9
 
 
f1121ec
e06e0e9
2146469
e06e0e9
 
 
f49b266
e06e0e9
f1121ec
e06e0e9
 
 
 
f1121ec
 
 
 
fce0dfa
 
e06e0e9
fce0dfa
 
 
e06e0e9
 
fce0dfa
794b4b5
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
---
license: mit
---

# PVSGym: A Proof Learning Environment

https://www.manojacharya.com/pvsgym

Paper: https://openreview.net/forum?id=NpytqGYVPa&noteId=NpytqGYVPa

This repository contains models and a web server that use LLMs to assist
theorem proving in PVS.

------------------------------------------------------------------------

## Model Files

Place all model files in a directory that follows this structure:

``` text
pvs_sft5
β”œβ”€β”€ config.json
β”œβ”€β”€ generation_config.json
β”œβ”€β”€ model-00001-of-00003.safetensors
β”œβ”€β”€ model-00002-of-00003.safetensors
β”œβ”€β”€ model-00003-of-00003.safetensors
β”œβ”€β”€ model.safetensors.index.json
β”œβ”€β”€ recommended_commands.csv
β”œβ”€β”€ special_tokens_map.json
β”œβ”€β”€ tokenizer_config.json
β”œβ”€β”€ tokenizer.json
β”œβ”€β”€ tokenizer.model
└── training_args.bin
```

------------------------------------------------------------------------

## Input Format

> **Important:** The model is sensitive to newline formatting.\
> For reference, see the `recommend` implementation here:\
> https://huggingface.co/ma7583/pvs_oracle/blob/main/sft_fastapi.py
> Note: The history requires three previous commands or "None" to denote empty.

Each query to the recommender should be formatted like this:

``` text
Current Sequent:
[1]   norm((# x := -1, y := 0 #)) = 1

Prev Command 1: (EXPAND "point_on_polygon_perimeter?")
Prev Command 2: (INST + "s")
Prev Command 3: (HIDE-ALL-BUT 1)
Next Command:
```

``` text
Current Sequent:
{1}   expt(c, (3 + 4 * n)) = expt(c, (1 + 4 * n)) * expt(c, 2)

Prev Command 1: (PROPAX)
Prev Command 2: (HIDE 2)
Prev Command 3: (EXPAND "^")
Next Command:
```

``` text
Current Sequent:
[-1]  derivable?(sin, x!1) AND derivable?(sin, x!1) IMPLIES deriv(sin * sin, x!1) = 2 * (deriv(sin, x!1) * sin(x!1))
[-2]  derivable?[real](sin * sin, x!1)
[-3]  derivable?[real](cos * cos, x!1)
[-4]  FORALL (x: real): derivable?[real](sin, x)
{-5}  FORALL (x: real): derivable?[real](cos, x)
[1]   deriv(cos * cos, x!1) + deriv(sin * sin, x!1) = const_fun(0)(x!1)

Prev Command 1: (ASSERT)
Prev Command 2: (EXPAND "derivable?" -4)
Prev Command 3: (EXPAND "derivable?" -5)
Next Command:
```

``` text
Current Sequent:
[1]   FORALL (x: real): LET S = LAMBDA (n: nat): powerseq(cos_coef, x)(2 * n) IN conv_series?(S) AND cos(x) = inf_sum(S)

Prev Command 1: (ASSERT)
Prev Command 2: (ASSERT)
Prev Command 3: (HIDE 2)
Next Command:
```

``` text
Current Sequent:
{-1}  FORALL (a: {x: real | 0 < x AND x <= pi / 2}): sin(a) > 0
[-2]  a <= pi / 2
[1]   sin(a) > 0

Prev Command 1: (SKEEP)
Prev Command 2: (CASE "a <= pi/2")
Prev Command 3: (LEMMA "sin_pos_0tohalfpi")
Next Command:
```

``` text
Current Sequent:
{-1}  FORALL (x_1: real): NOT (key_arb_intersections(p, v, G)(x_1) OR parallel_intersections(p, v, G)(x_1))
{1}   FORALL (x: real): NOT key_arb_intersections(p, v, G)(x)

Prev Command 1: (EXPAND "empty?")
Prev Command 2: (EXPAND "member")
Prev Command 3: (GROUND)
Next Command:
```

``` text
Current Sequent:
{-1}  FORALL (x_1: real): NOT (key_arb_intersections(p, v, G)(x_1) OR parallel_intersections(p, v, G)(x_1))
{1}   FORALL (x: real): NOT key_arb_intersections(p, v, G)(x)

Prev Command 1: None
Prev Command 2: None
Prev Command 3: (GROUND)
Next Command:
```


------------------------------------------------------------------------

## Running the Web Server

Start the FastAPI server with:

``` bash
python -m uvicorn sft_fastapi:app --host 0.0.0.0 --port 8000
```

### Health Check

``` bash
curl http://localhost:8000/health
```

### Command Recommendation Endpoint

Example request:

``` bash
curl -X POST http://localhost:8000/recommend   -H "Content-Type: application/json"   -d '{
    "sequent": "{1}   FORALL (A, B: simple_polygon_2d, j: below(A`num_vertices), i: nat): LET IV = injected_vertices(A, B, A`num_vertices), s = edges_of_polygon(A)(j), L = injected_vertices(A, B, j)`length, Q = injected_edge_seq(s, injected_edge(s, B)) IN i < IV`length AND i >= L AND i < Q`length + L IMPLIES IV`seq(i) = Q`seq(i - L)",
    "prev_commands": ["None", "None", "None"],
    "top_k": 3
  }'
```

------------------------------------------------------------------------

## PVSgym

PVSGym is not strictly required to run this server, but a joint demo
will be added later.

Repository: https://github.com/manoja328/pvsgym