Year: 2021

Abstract:
We study the problem of learning worst-case-safe parameters for programs that use neural networks as well as symbolic, human-written code. Such neurosymbolic programs arise in many safety-critical domains. However, because they need not be continuous, let alone differentiable, they cannot be learned using existing gradient-based approaches to safe learning. Our method, Differentiable Symbolic Execution (DSE), learns such programs by sampling code paths using symbolic execution, constructing gradients of a worst-case “safety loss” along these paths, and then backpropagating these gradients through program operations using a generalization of the REINFORCE estimator. We evaluate the method on a mix of synthetic tasks and real-world benchmarks. Our experiments show that DSE significantly outperforms the state-of-the-art DIFFAI method on these tasks.

text: We study the problem of learning worst-case-safe parameters for programs that use neural networks as well as symbolic, human-written code. Such neurosymbolic programs arise in many safety-critical domains. However, because they need not be continuous, let alone differentiable, they cannot be learned using existing gradient-based approaches to safe learning. Our method, Differentiable Symbolic Execution (DSE), learns such programs by sampling code paths using symbolic execution, constructing gradients of a worst-case “safety loss” along these paths, and then backpropagating these gradients through program operations using a generalization of the REINFORCE estimator. We evaluate the method on a mix of synthetic tasks and real-world benchmarks. Our experiments show that DSE significantly outperforms the state-of-the-art DIFFAI method on these tasks.

heading: 1 INTRODUCTION
text: Safety on worst-case inputs has recently emerged as a key challenge in deep learning research. Formal verification of neural networks (Albarghouthi, 2021) is an established response to this challenge. In particular, an exciting body of recent work (Mirman et al., 2018; Madry et al., 2017; Cohen et al., 2019; Singh et al., 2018) has sought to incorporate formal verification into the training of neural networks. DIFFAI, among the most prominent of such approaches, uses a neural network verifier to construct a differentiable, worst-case safety loss for the learner. This loss is used to regularize a standard data-driven loss, biasing the learner towards parameters that are both performant and safe.
A weakness of these methods is that they only consider functional properties (such as adversarial robustness) of isolated neural networks. By contrast, in real-world applications, neural networks are often embedded within human-written symbolic code, and correctness requirements apply to the entire neurosymbolic composition. For example, consider a car directed by a neural controller (Qin & Badgwell, 2000). Safety properties for the car are functions of its trajectories, and these trajectories depend not just on the controller but also the symbolic equations that define the environment. While recent work (Christakis et al., 2021) has studied the verification of such neurosymbolic programs, there is no prior work on integrating verification and learning for such systems.
In this paper, we present the first steps towards such an integration. The fundamental technical challenge here is that while a neural network is differentiable over its parameters, the code surrounding may be non-differentiable or even discontinuous. This puts our problem beyond the scope of existing methods for integrated learning and verification.
We overcome this difficulty using a new method, Differentiable Symbolic Execution (DSE), for estimating gradients of worst-case safety losses of nondifferentiable neurosymbolic programs. DSE is based on a generalization of the classic REINFORCE estimator, which backpropagates gradients through non-differentiable operations by approximating integrals with sampling. In our problem, the integral is the aggregate of the safety losses along symbolic control flow paths in the program. To apply REINFORCE-like ideas here, we need to represent and sample paths in a symbolic way. We do so through an adaptation of the classic method of symbolic execution.
We evaluate DSE through several case studies in the embedded control and navigation domains. Our baselines include an extended version of DIFFAI, the current state of the art, and an ablation that does not use an explicit safety loss. Our experiments show that DSE significantly outperforms the
baselines in finding safe and high-performance model parameters. We also do a series of synthetic experiments that highlight the practical difficulty that DIFFAI-style approaches face in our setting.
To summarize, our main contributions are:
• We present the first approach to worst-case-safe parameter learning for neural networks embedded within nondifferentiable, symbolic programs.
• As part of our learning algorithm, we give a new way to bring together symbolic execution and stochastic gradient estimators that might have applications outside our immediate task.
• We present experimental results that indicate the advantages of DSE over the state-of-the-art in verified learning.

heading: 2 PROBLEM FORMULATION
text: Programs. We define programs with embedded neural networks as symbolic transition systems (STS) (Manna & Pnueli, 2012). Formally, a program Fθ is a tuple (Loc, X, l0, Init ,Safe,Transθ). Here, Loc is a finite set of (control) locations, X = {x1, . . . , xm} is a set of real-valued variables, and l0 ∈ Loc is the initial location. Init , a boolean formula over X , is an initial condition for the program. Safe is a map from locations to constraints over X; intuitively, Safe(l) is a safety requirement asserted at location l. Finally, Transθ is a transition relation consisting of transitions (l, G, Uθ, l
′) such that: (i) l is the source location and l′ is the destination location; (ii) the guard G is a constraint over X; and (iii) the update Uθ is a vector 〈U1,θ, . . . , Um,θ〉, where each Ui,θ is a real-valued expression over X constructed using standard symbolic operators and neural networks with parameters θ. Intuitively, Ui,θ represents the update to the i-th variable. We assume that each Ui,θ is differentiable in θ. Also, we assume that the programs are deterministic. That is, if G and G′ are guards for two distinct transitions from the same source state, then G ∧G′ is unsatisfiable. Programs in higher-level languages can be translated to the STS notation in a standard way. For example, Figure 1 (left) shows a simple high-level program. The STS for this program appears in Figure 1 (right). Remarkably, while the program is simple, the state-of-the-art DIFFAI approach to verified learning fails to learn safe parameters for it.
Safety Semantics. In classical formal methods, a program is considered to be safe if all of its executions satisfy a logical constraint. However, in learning settings, it helps to know not only whether a program is unsafe, but also the extent to which it is unsafe. Consequently, we define the safety semantics of programs in a quantitative way, in terms of a (worst-case) safety loss that quantifies the extent program’s safeness.
Formally, let a state of Fθ be a pair s = (l, v), where l is a location and v ∈ Rm is an assignment of values to the variables (i.e., v(i) is the value of xi). Such a state is said to be at location l. For boolean constraints B and assignments v to variables in B, let us write B(v) if v satisfies B. A state (l0, v), where Init(v), is an initial state. A state (l, v) is safe if (Safe(l))(v).
Let v ∈ Rm be an assignment to the variables. For a real-valued expression E over X , let E(v) be the value of E when xi is substituted by v(i). For an update U = 〈U1, . . . , Un〉, we define U(v) as the assignment 〈U1(v), . . . , Un(v)〉. A length-n trajectory of Fθ is a sequence τ = 〈s0, . . . , sn〉, with si = (li, vi), such that: (i) s0 is an initial state; and (ii) for each i, there is a transition (li, G, U, li+1) such that G(vi) and vi+1 = U(vi).
Let us fix a size bound N for trajectories. A trajectory τ = 〈s0, . . . , sn〉 is maximal if it has length N , or if there is no trajectory τ ′ = 〈s0, . . . , sn, sn+1〉 with length ≤ N . Because our programs are deterministic, there is a unique maximal trajectory from each s0. We denote this trajectory by τ(s0).
Let us assume a real-valued loss Unsafe(s) that quantifies the unsafeness of each state s. We require Unsafe(s) = 0 if s is safe and Unsafe(s) > 0 otherwise. We lift this measure to trajectories τ by letting Unsafe(τ) = ∑ s appears in τ Unsafe(s). The safety loss C(θ) for Fθ is now defined as:
C(θ) = max s is an initial state Unsafe(τ(s)). (1)
Thus, C(θ) = 0 if and only if all program trajectories are safe.
Problem Statement. Our learning problem formalizes a setting in which we have training data for neural networks inside a program Fθ. While training the networks with respect to this data, we must ensure that the overall program satisfies its safety requirements.
To ensure that the parameters of the different neural networks in Fθ are not incorrectly entangled, we assume that only one of these networks, NNθ, has trainable parameters.1 We expect as input a training set of i.i.d. samples from an unknown distribution over the inputs and outputs of NNθ, and a differentiable data loss Q(θ) that quantifies the network’s fidelity to this training set. Our learning goal is to solve the following constrained optimization problem:
min θ Q(θ) s.t. C(θ) ≤ 0. (2)

heading: 3 LEARNING ALGORITHM
text: Our learning approach is based on two ideas. First, we directly apply a recently-developed equivalence between constrained and regularized learning (Agarwal et al., 2018; Le et al., 2019) to reduce Equation (2) to a series of unconstrained optimization problems. Second, we use the novel technique of Differentiable Symbolic Execution (DSE) to solve these unconstrained problems.
At the highest level, we convexify the class of programs Fθ by allowing stochastic combination of programs. That is, we now allow programs of the form Fθ̂ = ∑T t=1 αtFθt , where ∑ i αt = 1. To execute the program Fθ from a given initial state, one samples a specific program Fθt from the distribution (α1, . . . , αt) and then executes it from that state.
Equation (2) can now be written into the problem maxλ∈R+ minθ̂ Q(θ̂) + λC(θ̂), which in turn can be solved using a classic algorithm (Freund & Schapire, 1999) for computing equilibria in a twoplayer game. We omit further details about this algorithm because it follows Le et al. (2019). (For more details, see Appendix A.1).
A key feature of our high-level algorithm is that it repeatedly solves the optimization problem min θ Q(θ) + λC(θ) (3)
for fixed values of λ. This problem is challenging because while Q(θ) is differentiable in θ, C(θ) depends on the entirety of Fθ and may not even be continuous. As we demonstrate in Section 5, this makes it difficult to apply state-of-the-art gradient-based approaches to worst-case safe learning.
DSE, our main contribution, addresses this challenge by estimating gradients ∇θC#(θ) of a differentiable approximation C#(θ) of C(θ). We present the details of this method in the next section.

heading: 4 DIFFERENTIABLE SYMBOLIC EXECUTION
text: Background on Symbolic Execution. DSE is a refinement of symbolic execution (Baldoni et al., 2018), a classic technique for systematic formal analysis of programs. Symbolic execution has been
1Note that some of our experimental benchmarks have k > 1 trainable neural modules. In these tasks, each neural module comes with its own training data; thus, in effect, we have k instances of the learning problem. Our implementation learns the modules simultaneously by interleaving their gradient updates. However, the gradient of Q for each module is only influenced by its own data.
recently used to analyze the safety of neural networks (Gopinath et al., 2018). However, we are not aware of any prior attempt to incorporate symbolic execution into neural network training.
A symbolic executor systematically searches the set of symbolic trajectories of programs, which we now define. Consider a program Fθ = (Loc, X = {x1, . . . , xm}, l0, Init ,Safe,Transθ) as in Section 2. First, we fix a syntactically restricted class Vθ of boolean constraints over the variablesX and parameters θ. Vθ is required to be closed under conjunction. For example, in our implementation, Vθ consists of formulas that specify closed or open intervals, with bounds given by expressions over parameters, in which each variable lies.
A symbolic state of Fθ is a pair σθ = (l, Vθ), where l is a location and Vθ ∈ Vθ. Intuitively, σθ represents the set of states of Fθ that are at location l and satisfy the property Vθ.
In particular, we designate a finite set of initial symbolic states (l0, V 10 ), . . . , (lp, V p 0 ). It is required that Init ⇒ ∨ i V i 0 . Intuitively, these initial symbolic states “cover” all the possible initial states of the program Fθ.
We also construct an overapproximate update U#θ : Vθ → Vθ for each update Uθ in Fθ. For all V ∈ Vθ, we have Post ⇒ U#θ (V ), where Post(v) is the formula ∃v′ : V (v′) ∧ (U(v′) = v). Intuitively, U#θ (V ) is an overapproximate representation of the set of states reached by applying Uθ to a state that satisfies V .
Let us call a transition t = (l, G, U, l′) enabled at a symbolic state (l, V ) if (G∧V ) is satisfiable. A symbolic trajectory of Fθ is a sequence τ # θ = 〈σ0, . . . , σn〉 with the following properties:
• σ0 is an initial symbolic state.
• Let σi = (li, Vi). Then there exists a transition t = (li, Gi, Ui, li+1) such that: (i) t is enabled at σi, and (ii) Vi+1 = U#(Gi ∧ Vi). In this case, we write σi+1 = t(σi).
Intuitively, τ#θ represents an overapproximation of the set of concrete trajectories of Fθ that pass through the “control path” 〈l0, . . . , ln〉. The above symbolic trajectory is safe if for all i, Vi ⇒ Safe(li). Intuitively, in this case, all concrete trajectories that the symbolic trajectory represents follow the program’s safety requirements.
Example(Cont.) Consider the example program in Figure 1. Let us assume a single initial symbolic state where x ∈ [−5, 5] and NNθ ∈ [−2, 2] when x ∈ [−5, 5]. The program has two symbolic trajectories from this state:
• τ#1 = 〈(`2, x ∈ [−5, 5]), (`3, x ∈ [−5, 5]∧y ∈ [−2, 2]), (`7, x ∈ [−5, 5]∧y ∈ [−2, 1]∧z ∈ [5, 15])〉
• τ#2 = 〈(`2, x ∈ [−5, 5]), (`3, x ∈ [−5, 5]∧y ∈ [−2, 2]), (`7, x ∈ [−5, 5]∧y ∈ (1, 2]∧ z ∈ [−10, 0])〉.
We note that only τ#2 is safe.
Probabilistic Symbolic Execution. A key difficulty with using symbolic execution to estimate the safety loss C(θ) is that our programs need not be differentiable, or even continuous. To understand the issues here, consider our running example once again. Here, the parameter θ is used to calculate the variable y, which is used in a discontinuous conditional statement that assigns very different values to the variable z in its two branches. Additionally, a slight change in θ can sometimes cause the guard G of the conditional to go from being True on some values of y, to being False on all values of y. In the second case, the updated θ would have one, rather than two, symbolic trajectories. If the symbolic trajectory τ# in whichG is True serves as an edge case to judge whether a program is worst-case-safe, learning safe parameters would be difficult, as there would be no gradient guiding the optimizer back to the case in which G is True.
DSE overcomes these difficulties using a probabilistic approach to symbolic execution. Specifically, at a symbolic state σi = (li, Vi), the symbolic executor in DSE samples its next action following a probability distribution pθ(t | σi), where t ranges over program transitions or a special action Stop.
For a boolean expression Vθ over the program variables and parameters, let Vol(Vθ) denote the volume of the assignments to X that satisfy Vθ. Then we define:
• If there is a unique program transition t that is enabled at σi, then pθ(t|σi) = 1. • If there is no transition t that is enabled at σi, then pθ(Stop|σi) = 1. • Otherwise, let t1, . . . , tk be the transitions that are enabled at σi, with ti = (li, Gi, Ui, li+1). Then pθ(tj |σi) = Vol(Gj∧Vi)Vol(Vi) .
We also define a volume-weighted probability distribution p(σ0) over the (finite set of) initial symbolic states σi0. Specifically, for each σ i 0 = (l0, V i 0 ), we have
p(σi0) = Vol(V i0 )∑ jVol(V j 0 ) . (4)
DSE uses the distributions pθ(t|σi) and p(σ0) to sample symbolic trajectories. Let τ#θ = 〈σ0, . . . , σn〉, with σi+1 = ti(σi). The probability of sampling τ# is
pθ(τ # θ ) = p(σ0) ∏ i pθ(ti|σi−1). (5)
We note that pθ is differentiable in θ.
Approximate Safety Loss. A key decision in DSE is to approximate the overall worst-case loss C(θ) by the expectation of a differentiable safety loss computed per sampled symbolic trajectory. Recall the safety loss Unsafe(s) for individual states. For σ = (l, V ), we define Unsafeθ(σ) as a differentiable approximation of the worst-case loss maxs satisfies V Unsafe(s). We lift this loss to symbolic trajectories τ#θ = 〈σ0, . . . , σn〉 by defining Unsafeθ(τ#) = ∑ iUnsafeθ(σi). We observe that Unsafeθ is differentiable in θ.
Our approximation to the safety loss is now given by:
C#(θ) = Eτ#∼pθ(τ#)Unsafeθ(τ #). (6)
Intuitively, C#(θ) guides the learner towards either making the unsafe trajectories safer or lowering the probability of the program falling into unsafe trajectories. If C#(θ) equals zero, the program is provably safe. That said, in practice, we must estimate the expectation in Equation (6) using sampling. As this sampling process may miss trajectories, a low empirical estimate of C#(θ) need not guarantee worst-case safety. As an extreme example, suppose a program has one unsafe symbolic trajectory, but the volume portion of certain states in this trajectory is near-zero. This trajectory is likely to be missed by the sampling process, leading to an artificially low value of C#(θ).
Example(Cont.) Consider the trajectories τ#1 and τ # 2 in our running example. We have p(τ # 1 ) = p(t2|σ2), as the other transitions in τ#1 have probability 1. We compute p(t2|σ2) = Vol([−2,1]) Vol([−2,2]) = 0.75. Thus, p(τ#1 ) = 0.75 and similarly, p(τ # 2 ) = 0.25.
Gradient Estimation. Our ultimate goal is to compute the gradient ∇θC#(θ) of the approximate safety loss. At first sight, the classic REINFORCE estimator, or its lower-variance refinements, seems suitable for this task, given that they can differentiate an integral over sampled “paths”. However, a subtlety in our setting is that the losses for individual paths (symbolic trajectories) is a function of θ. This calls for a generalization of traditional REINFORCE-like estimators.
More precisely, we adapt the derivation of REINFORCE to our setting as follows:
∇θ(C#(θ)) = ∇θEτ#∼pθ(τ#)Unsafeθ(τ #) = ∇θ ∫ τ#∼pθ(τ#) pθ(τ #)Unsafeθ(τ #)dτ#
= ∫ τ#∼pθ(τ#) pθ(τ #)∇θUnsafeθ(τ#) +Unsafeθ(τ#)∇θpθ(τ#)dτ#
= Eτ#∼pθ(τ#)[∇θUnsafeθ(τ #)] +Eτ#∼pθ(τ#)[Unsafeθ(τ #)∇θ(logpθ(τ#))]
The above derivation can be further refined to incorporate the variance reduction techniques for REINFORCE that are commonly employed in generative modeling and reinforcement learning. The use of such techniques is orthogonal to our main contribution, and we ignore it in this paper.

heading: 5 EVALUATION
text: Our experimental evaluation seeks to to answer the following research questions:
(RQ1): How does DSE compare with the state of the art in its ability to learn safe and performant parameters?
(RQ2): How does data size influence DSE and baselines?
(RQ3): How well does DSE scale as the program being learned gets more complex?

heading: 5.1 EXPERIMENTAL SETUP
text: System Setup. Our framework is built on top of PyTorch (Paszke et al., 2019). We use the Adam Optimizer (Kingma & Ba, 2014) for all the experiments with default parameters and a weight decay of 0.000001. We ran all the experiments using a single-thread implementation on a Linux system with Intel Xeon Gold 5218 2.30GHz CPUs and GeForce RTX 2080 Ti GPUs.
Baselines. We use two types of baselines: (i) Ablation, which ignores the safety constraint and learns only from data; (ii) DIFFAI+, an extended version of the original DIFFAI method (Mirman et al., 2018). DIFFAI does not directly fit our setting of neurosymbolic programs as it does not handle general conditional statements. DIFFAI+ extends DIFFAI by adding the meet and join operations following the abstract interpretation framework (Cousot & Cousot, 1977). Also, we allow DIFFAI+ to split the input set into several (100 if not specified) initial symbolic states to increase the precision of symbolic execution of each trajectory. (The original DIFFAI does not need to perform such splits because, being focused on adversarial robustness, it only propagates small regions around each input point through the model.) However, the parts of DIFFAI that propagate losses and their gradients through neural networks remain the same in DIFFAI+.
We use the box (interval) domain for both DSE and DIFFAI+ in all the experiments. DSE samples 50 symbolic trajectories for each starting component.
Benchmarks. Our evaluation uses 5 synthetic microbenchmarks and 3 case studies. The microbenchmarks (Appendix A.5) are small programs consisting of basic neural network modules, arithmetic function assignment and conditional branches and are designed to highlight the relationship between DIFFAI+ and DSE. The case studies, described below, involve more complicated programs (see Appendix A.4 for more details):
• In Thermostat, we want to learn safe parameters for two neural networks that control the temperature of a room.
• Racetrack is a navigation benchmark (Barto et al., 1995; Christakis et al., 2021). Two vehicles are trained by path planners separately. The racetrack system is expected to learn two safe controllers so that vehicles do not crash into walls or into each other.
• In Aircraft-Collision(AC), the goal is to learn safe parameters for an airplane that performs maneuvers to avoid a collision with a second plane.
For each benchmark, we first write a ground-truth program that does not include neural networks and provably satisfies a safety requirement. We identify certain modules of these programs as candidates for learning. Then we replace the modules with neural networks with trainable parameters.
For all benchmarks with the exception of Racetrack, we execute the ground-truth programs on uniformly sampled inputs to collect input-output datasets for each of these modules. As for Racetrack, recall that this benchmark involves two simulated vehicles with neural controllers; learned parameters for these controllers are safe if the vehicles do not crash into each other or a wall. To model real-world navigation, we generate the training data for the controllers from a ground-truth trajectory constructed using a path planner. This path planner only tries to avoid the walls in the map and does not have a representation of distances from other vehicles. Thus, in this problem, even a very large data set does not contain all the information needed for learning safe parameters.
Evaluation of Safety and Data Loss. Once training is over, we expect the learned program to fare well in terms of safety and data loss values. We evaluate the test data loss by running the learned program on 10000 initial states that were not seen during training. We evaluate the safety loss using an abstract interpreter (Cousot & Cousot, 1977) that splits the initial condition into 10000 intervals, then constructs symbolic trajectories from these programs. This analysis is sound (unlike the approximate loss employed during DSE training) , meaning that the program is safe if the safety loss evaluates to 0. Our safety metric is the provably safe portion, which is the fraction of these 10000 trajectories that are safe.

heading: 5.2 RESULTS
text: RQ1: Overall Quality of Learned Parameters. Figure 2 exhibits the provably safe portion of DIFFAI+ and DSE on our microbenchmarks. Here, the first two patterns only use neural modules in the condition part and the last three benchmarks use the neural modules both in the conditional statement and the assignment statement which is directly related to the final safety representation. We see that DIFFAI+ cannot learn safe highly non-differentiable modules (pattern1, pattern2) while DSE can. For the cases where optimization across branches is not required to give safe programs, DIFFAI+ can handle them (pattern3). For the patterns with neural assignments, DIFFAI+ finds it hard to learn to jump from one conditional branch to another to increase safety (pattern4, pattern5).
We show the training-time and test-time safety and data losses for our larger benchmarks in Figure 3. From Figure 3a, 3b, 3c, we exhibit that DSE can learn programs with 0.99 provably safe portion even with 200 data points and the results keep when the number of training data points is increased. Meanwhile, both DIFFAI+ and Ablation fail to provide safe programs for AC and Racetrack. For Thermostat, Ablation and DIFFAI+ can achieve a provably safe portion of 0.8 only when using 5000 and 10000 data points to train.
Our test data loss is sometimes larger yet comparable with the Ablation and DIFFAI+ from Figure 3d, 3f. For AC specifically, the safety constraint can help the learner overcome some local optimal yet unsafe areas to get a safer result with more accurate behaviors.
Overall, we find that DSE outperforms DIFFAI+ when neural modules are used in the conditional statement and the interaction between neural modules is important for the safety property. This is the case in our larger benchmarks. For example, in Thermostat and AC, the neural modules’ outputs decide the actions that the neural module to take in the next steps. In Racetrack, the distance between two neural modules regulates each step of the vehicles’ controllers.
We display representative symbolic trajectories from the programs learned by Ablation, DIFFAI+ and DSE in Figure 4. The larger portion of the symbolic trajectories is provably safe from DSE than the ones from baselines, which is indicated by the less overlapping between the green trajectories and the gray area. Because the symbolic trajectories are overapproximate, we also depict some representative concrete trajectories for each approach. We note that more concrete trajectories of Thermostat, AC, and the distance property of Racetrack from DSE fall into the safe area compared with DIFFAI+ and Ablation.
RQ2: Impact of Data Size. Figure 3 compares the different methods’ performance on the test metrics as the number of training data points is changed. The Ablation and DIFFAI+ can reach 0.95 provably safe portion with 10000 data points for Thermostat. However, the variance of results is large, as the minimum provably safe portion across training can reach 0.74 and 0.0 for Ablation and DIFFAI+. In the Thermostat benchmark, DIFFAI+’s performance mainly comes from the guidance from the data loss rather than the safety loss. For the other two cases, a larger training data set cannot help the Ablation and DIFFAI+ to give much safer programs. For AC, as is in Figure 4e, the program learnt from Ablation is very close to the safe area but the Ablation is still not accurate enough to give a safe program in the third step. In Racetrack, increasing the data size to train the vehicles’ controllers can only satisfy the requirement of “not crashing into walls”. The networks cannot learn to satisfy the property of not crashing into other vehicles as this information is not available in the training data.
RQ3: Scalability. As our solution for the safety loss does not rely on the number of data points, the solution is scalable in terms of both data size and neural network size. In Figure 2, we use the three types of neural networks: (i) NNSmall (with about 33000 parameters); (ii) NNMed (with over 0.5 million parameters); (iii) NNBig (with over 2 million parameters), the training time per epoch is 0.09 sec, 0.10sec, 0.11sec for NNSmall, NNMed, NNBig separately. For the synthetic benchmarks, the program can converge within about 200 epochs which takes 18 sec, 20sec, and 22 sec.
Our Thermostat, AC and Racetrack benchmarks consist of neural networks with 4933, 8836 and 4547 parameters respectively, and loops with 20, 15 and 20 iterations respectively. There are 2, 1 and 2 neural modules (respectively) in each benchmark. The training times for DIFFAI+ and DSE are comparable on these benchmarks. Specifically, for Thermostat, AC, and Racetrack, the total training time of DSE is less than 1 hour, less than 90 minutes, and around 13 hours. The corresponding numbers are over 90 minutes, more than 2 hours, and more than 17 hours for DIFFAI+.

heading: 6 RELATED WORK
text: Verification of Neural and Neurosymbolic Models. There are many recent papers on the verification of worst-case properties of neural networks (Anderson et al., 2019; Gehr et al., 2018; Katz et al., 2017; Elboher et al., 2020; Wang et al., 2018). There are also several recent papers (Ivanov et al., 2019; Tran et al., 2020; Sun et al., 2019; Christakis et al., 2021) on the verification of compositions of neural networks and symbolic systems (for example, plant models). To our knowledge, the present effort is the first to integrate a method of this sort — propagation of worst-case intervals through neurosymbolic program — with the gradient-based training of neurosymbolic programs.
Verified Deep Learning. There is a growing literature on methods that incorporate worst-case objectives (safety, robustness, or stability) into the training loops of neural networks (Zhang et al., 2019; Mirman et al., 2018; Madry et al., 2017; Cohen et al., 2019; Singh et al., 2018). Most prior work on this topic focuses on the training of single neural networks. There are a few domainspecific efforts that consider the environment of the neural networks being trained. For example, (Shi et al., 2019) uses spectral normalization to constrain the neural network module of a neurosymbolic controller and ensure that it respects certain stability properties. Unlike DSE, the training process in these methods treat the neural network in an isolated way and does not consider the interactions between the neural network modules and surrounding human-written code (Stone et al., 2016; Qin & Badgwell, 2000; Nassi et al., 2020; Katz et al., 2021).
Verified Parameter Synthesis for Symbolic Code. There is a large body of work on parameter synthesis for traditional symbolic code (Alur et al., 2013; Chaudhuri et al., 2014) with respect to worst-case correctness constraints. However, because these methods do not use contemporary gradient-based learning, scaling them to programs with neural modules is impractical.

heading: 7 CONCLUSION
text: We presented DSE, the first approach to worst-case-safe parameter learning for neurosymbolic programs that embed neural networks inside potentially discontinuous symbol code. Our key innovation is that we design and implement a new way to bridge symbolic execution and stochastic gradient estimator to represent and learn the loss of symbolic properties. We exhibit that DSE outperforms a state-of-the-art approach to worst-case-safe deep learning.
Our current implementation of DSE uses an interval representation of symbolic states. Future work should explore more precise representations such as zonotopes. Incorporating modern variance reduction techniques in our gradient estimator is another natural next step. Finally, one challenge in DSE is that learning here can get harder as the symbolic state representation gets more precise. In particular, if we increase the number of initial symbolic states beyond a point, each state would only lead to a unique symbolic trajectory, and there would be no gradient signal to adjust the relative weights of the different symbolic trajectories. Future work should seek to identify good, possible adaptive, tradeoffs between precision of symbolic states and ease of learning.

heading: A APPENDIX

heading: A.1 LEARNING FRAMEWORK
text: We use an equivalence between constrained and regularized learning that (Agarwal et al., 2018; Le et al., 2019), among others, have recently developed in other learning settings, we reduce our problem to a series of unconstrained optimization tasks.
We convexify the program set {Fθ : θ ∈ Rk} by considering stochastic mixtures (Le et al., 2019) and represent the convexified set as a probabilistic function Fθ̂. Following DSE, we rewrite Equation 2 in terms of these mixtures:
θ̂∗ = argmin θ̂ Q(θ̂) s.t. C#(θ̂) ≤ 0 (7)
We convert Equation 7 to a Lagrangian function
L(θ̂, λ) = Q(θ̂) + λC#(θ̂) (8) (9)
, where λ ∈ R+ is a Lagrange multiplier. Following the equilibrium computation technique by Freund & Schapire (1996), Equation 7 can be rewritten as
max λ∈R+ min θ̂ L(θ̂, λ). (10)
Solutions to this problem can be interpreted as equilibria of a game between a λ-player and a θ̂player in which the θ̂-player minimizes L(θ̂, λ) given the current λ, and the λ-player maximizes L(θ̂, λ) given the current θ̂. Our overall algorithm is shown in Algorithm 1. In this pseudocode, ν is a predefined positive real. Uniform(θ1, . . . , θt) is the mixture that selects a θi out of {θ1, . . . , θt} uniformly at random.
Bestθ(λ) refers to the θ̂ player’s best response for a given value of λ (it can be shown that this best response is a single parameter value, rather than a mixture of parameters). Computing this best response amounts to solving the unconstrained optimization problem minθ L(θ, λ), i.e.,
Bestθ(λ) = min θ Q(θ) + λC#(θ). (11)
Bestλ(θ̂) is the λ-player’s best response to a particular parameter mixture θ̂. We define this function as
Bestλ(θ̂) = { 0 if C#(θ̂) ≤ 0 S otherwise
(12)
where S is the upper bound on λ. Intuitively, when C#(θ̂) is non-positive, the current parameter mixture is safe. As L is a linear function of λ, the minimum value of L is achieved in this case when λ is zero. For other cases, the minimum L is reached by setting λ to the maximum value S.
Finally, λ-Update(θt) computes, in constant time, a new value of λ based on the most recent best response by θ̂ player. We do not describe this function in detail; please see (Agarwal et al., 2018) for more details.
Following prior work, we can show that Algorithm 1 converges to a value (θ̂, λ̂) that is within additive distance ν from a saddle point for Equation 10. To solve our original problem (Equation 2),
we take the returned θ̂ and then return the real-valued parameter θi to which this mixture assigns the highest probability. It is easy to see that this value is an approximate solution to Equation 2.

heading: A.2 ABSTRACT UPDATE FOR NEURAL NETWORK MODULES
text: We consider the box domain in the implementation. For a program with m variables, each component in the domain represents a m-dimensional box. Each component of the domain is a pair b = 〈bc, be〉, where bc ∈ Rm is the center of the box and be ∈ Rm≥0 represents the non-negative deviations. The interval concretization of the i-th dimension variable of b is given by
[(bc)i − (be)i, (bc)i + (be)i].
Now we give the abstract update for the box domain following Mirman et al. (2018).
Add. For a concrete function f that replaces the i-th element in the input vector x ∈ Rm by the sum of the j-th and k-th element:
f(x) = (x1, . . . , xi−1, xj + xk, xi+1, . . . xm) T .
The abstraction function of f is given by:
f#(b) = 〈M · bc,M · be〉, where M ∈ Rm×m can replace the i-th element of x by the sum of the j-th and k-th element by M · bc.
Multiplication. For a concrete function f that multiplies the i-th element in the input vector x ∈ Rm by a constant w:
f(x) = (x1, . . . , xi−1, w · xi, xi+1, . . . , xm)T . The abstraction function of f is given by:
f#(b) = 〈Mw · bc,M|w| · be〉, where Mw · bc multiplies the i-th element of bc by w and M|w| · be multiplies the i-th element of be with |w|.
Matrix Multiplication. For a concrete function f that multiplies the input x ∈ Rm by a fixed matrix M ∈ Rm′×m:
f(x) =M · x. The abstraction function of f is given by:
f#(b) = 〈M · bc, |M | · be〉, where M is an element-wise absolute value operation. Convolutions follow the same approach, as they are also linear operations.
ReLU. For a concrete element-wise ReLU operation over x ∈ Rm: ReLU(x) = (max(x1, 0), . . . ,max(xm, 0))T ,
the abstraction function of ReLU is given by:
ReLU#(b) = 〈ReLU(bc + be) + ReLU(bc − be) 2 , ReLU(bc + be)− ReLU(bc − be) 2 〉.
where bc + be and bc − be denotes the element-wise sum and element-wise subtraction between bc and be.
Sigmoid. As Sigmoid and ReLU are both monotonic functions, the abstraction functions follow the same approach. For a concrete element-wise Sigmoid operation over x ∈ Rm:
Sigmoid(x) = ( 1
1 + exp(−x1) , . . . ,
1
1 + exp(−xm) )T ,
the abstraction function of Sigmoid is given by:
Sigmoid#(b) = 〈Sigmoid(bc + be) + Sigmoid(bc − be) 2 , Sigmoid(bc + be)− Sigmoid(bc − be) 2 〉. where bc + be and bc − be denotes the element-wise sum and element-wise subtraction between bc and be. All the above abstract updates can be easily differentiable and parallelized on the GPU.
A.3 INSTANTIATION OF THE Unsafe FUNCTION
In general, the Unsafe(s) function over individual states can be any differentiable distance function between a point and a set which satisfies the property that Unsafe(s) = 0 if s is in the safe set, A, and Unsafe(s) > 0 if s is not inA. We give the following instantiation as the unsafeness score over individual states:
Unsafe(s) =
{ minx∈A DIST(s, x) if s /∈ A
0 if s ∈ A where DIST denotes the euclidean distance between two points.
Similarly, the Unsafe(σ) function over symbolic states can be any differentiable distance function between two sets which satisfies the property that Unsafe(σ) = 0 if V is in A, and Unsafe(σ) > 0 if V is not in A. We give the following instantiation as a differentiable approximation of the worstcase loss maxs satisfies V Unsafe(s) in our implementation:
Unsafe(σ) =
{ mins satisfies V Unsafe(s) + 1 if V ∧ A = ∅
1− Vol(V ∧A)Vol(V ) if V ∧ A 6= ∅

heading: A.4 BENCHMARKS FOR CASE STUDIES
text: The detailed programs describing Aircraft Collision, Thermostat and Racetrack are in Figure 5, 6 and 7. The πθ of Aircraft Collision and πcoolθ , π heat θ in Thermostat are a 3 layer feed forward net with 64 nodes in each and a ReLU after each layer except the last one. A sigmoid layer serves as the last layer. Both the πagent1θ and π agent2 θ in Racetrack are a 3 layer feed forward net with 64 nodes in each and a ReLU after each layer.

heading: A.5 SYNTHETIC MICROBENCHMARKS
text: Figure 8 exhibits the 5 synthetic microbenchmarks in our evaluation. Specifically, the neural network modules are used as conditions in pattern 1 and pattern 2. The neural network modules serve as both conditions and the assignment variable in pattern 3, pattern 4 and pattern 5. To highlight the impact from the safety loss, we only train with safety loss for synthetic microbenchmarks.

heading: A.6 TRAINING PERFORMANCE
text: Figure 9 and Figure 10 illustrates the training performance of safety loss and data loss when we vary data points (2%, 10%, 20%, 50%, 100% of the training dataset) used by DIFFAI + and DSE. We can see that the safety loss of DSE can converge while the variance of the safety loss of DIFFAI + is quite large for these three cases and can not converge to a small safety loss.
While we found that starting from random initialization can give us safe programs in Thermostat, we achieved much quicker convergence when initializing Thermostat programs trained purely with data and then continue to train with safety loss. We show the results and training performance for Thermostat with data-loss initialized program. The other two benchmarks do not benefit a lot from the data loss initialized program. We keep the training of them with random initialization.

heading: A.6.1 SAFETY LOSS

heading: A.6.2 DATA LOSS

heading: A.6.3 DETAILS OF TRAINING AND TEST DATA
text: We also attach the detailed training data loss (Q), training safety loss (C#), test data loss and provably safe portion for Thermostat(Figure 11), AC(Figure 12) and Racetrack(Figure 13). Specifically, training safety loss measures the expectation of the quantitative safety of the symbolic trajectories and provably safe portion measures the portion of the symbolic trajectories that is provably safe. Intuitively, in training, if the number of unsafe symbolic trajectories is larger and the unsafe symbolic trajectories are further away from safe areas, C# is larger. In test, if the number of provably safe symbolic trajectories is larger, the provably safe portion is larger.

heading: A.7 DATA GENERATION
text: In this section, we provide more details about our data generation process. We give our ground-truth programs and the description of each benchmark:
• Thermostat: Figure 6 exhibits the program with initial temperature x ∈ [60.0, 64.0] in training, where a 20-length loop is involved. The COOLING and WARMING are two differentiable functions updating the temperature, x. The πcoolθ and π heat θ are two lin-
ear feed-forward neural networks. We set the safe temperature to the area [55.0, 83.0]. EXTREME_TEMPERATURE measures that whether x is not within the safe temperature scope. The ground-truth program replaces πcoolθ and π heat θ with two different functional mechanisms(including branches and assignment), which decides the value of isOn and heat. To mimic the real-world signal sensing process of thermostat, we carefully add noise to the output of these functional mechanisms and restricts the noise does not influence the safety of the ground-truth program.
• AC: Figure 5 illustrates the program in training with initial input x-axis of aircraft1 x ∈ [12.0, 16.0], where a 15-length loop is involved. The MOVE_* functions update the position of aircraft in a differentiable way. The πθ is one linear feed-forward neural networks. IS_CRASH measures the distances between two aircraft and the safe distance area is set to be larger than 40.0. In the ground-truth program, the πθ is replaced by one functional mechanism mimicing the real-world aircraft planner. If the stage is CRUISE, the groundtruth planner detects the distance between aircraft and decides the next step’s stage by assignment values 1 or 0 to p0, p1, p2, p3. The step is set to 0. When the stage is in LEFT or RIGHT, stage keeps and the step increases if the number of steps in this stage is within a threshold, and the stage changes to STRAIGHT or CRUISE and the step is set to 0 otherwise. Specifically, we convert the argmax to a nested If-Then-Else(ITE) block to select the index of the p with the maximum value.
• Racetrack: Figure 7 illustrates the program in training with the input x-axis of each agent x ∈ [5.0, 6.0] (The two agents start from the same location.) This program has a 20-length loop with a dynamic length of 223 lines (The unfold ITE of argmax consists of 3 lines code.) In training, the πagent1θ and π agent2 θ are two linear feed-forward neural network.
The MOVE is differentiable functions that update agents’ positions. CRASH_WALL measures whether the agents’ position collides with the wall. CRASH measures whether the two agents crash into each other. In ground-truth program, πagent1θ and π agent2 θ are replaced by functional path planners guiding the agent’s direction. The path planner only tries to avoid wall-collision in the map. That is to say, in the trajectories data generated, an arbitrary pair of trajectories of agent1 and agent2 is not guaranteed to be nocollision with each other. To model real-world navigation, we also add noise in the next step selection for one position to generate independent trajectories of each agent. In the ground-truth program, the noise is added by uniformly selecting from the safe next step area.
When generating the trajectory dataset, we uniformly sample the input from the input space and run the ground-truth program to get the trajectory. Specifically, the trajectories in the dataset is represented by a sequence of neural network input-output pairs and the index of the neural networks. Take Thermostat as an example, we get a sequence of ([x0], [isOn0],cool), . . . , ([xk], [isOnk,hk],heat), . . . for one starting point. The k represents the data collected in the k-th step of the program.

heading: A.8 TRAINING PROCEDURE
text: Our framework is built on top of PyTorch (Paszke et al., 2019). We use the Adam Optimizer (Kingma & Ba, 2014) for all the experiments with a learning rate of 0.001 and a weight decay of 0.000001. We ran all the experiments using a single-thread implementation on a Linux system with Intel Xeon Gold 5218 2.30GHz CPUs and GeForce RTX 2080 Ti GPUs.
We represent the data loss(Q) following imitation learning techniques. The trajectory dataset is converted to several input-output example pair sets. Each input-output pair set represents the inputoutput pairs for each neural network. Q is calculated by the average of the Mean Squared Error of the each neural network over the corresponding input-output pair set.
The C# of DSE follows the algorithm given in the Section 4 with one symbolic state covering the input space. In DIFFAI+, we use sound join operation, which is used in classic abstract interpretation Cousot & Cousot (1977), whenever encountering branches. Sound join means that the symbolic state after the branch block is the join of the symbolic states computed from each branch. The concretization of the symbolic state after sound join covers the union of the concretization of the symbolic states from each branch. Intuitively, starting from one input symbolic state, DIFFAI+ gets one symbolic trajectory which covers all the potential trajectories starting from the concrete input satisfying the input symbolic state. For the safety loss of DIFFAI+, we first split the input space into 100 subregions evenly to give more accuracy for DIFFAI+. After that, we can get 100 symbolic trajectories. We compute the average of the safety loss of all the 100 symbolic trajectories as the training safety loss C# of DIFFAI+.
We set the convergence criterion as a combination of epoch number and loss. In each training iteration, the final loss is represented as Q(θ)+C#(θ). We set the maximum epoch for Thermostat, AC and Racetrack as 1500, 1200 and 6000. We set the early stop if the final loss has less than a 1% decrease over 200 epochs.

heading: A.9 ADDITIONAL PATTERN ANALYSIS
text: Figure 2 exhibits safety performance of learnt patterns. The details of the patterns are in Figure 8. We highlight the patterns that cover the scope differences between DIFFAI+ and DSE, including parameterized branch conditions(Pattern 1-4) and bad joins(Pattern 5). In addition, we describe the characteristics in each pattern that influence DSE’s performance, including deep local minimum in branches and limitations on sampling. In implementation, we randomly initialize the neural network’s parameter (DIFFAI+ and DSE start from the initialization). We observe that all the neural networks are initialized to come with an output y ≤ 1 when x ∈ [−5, 5], which gives 0.0 provably unsafe portion for Pattern 1, 2 and 5 in initialization.
We give a detailed description of each patterns’ characteristic (with results analysis), where all the patterns’ safety loss is over the only variable z in assertion:
• Pattern1: The output, y, of the neural network module is only used as the parameters to calculate the branch condition satisfaction. In each branch, z is only updated with constants. When the gradient back-propagation executes in DIFFAI+, the gradients over θ is constantly zero since the branch splitting computation is not involved in safety loss. While for DSE, we consider the y by using the volume-based probability in safety loss calculation. Therefore, DSE is able to guide the program to fall into the second branch thoroughly by reducing the probability of y falling into the first branch.
• Pattern2: Similar to Pattern 1, the output of the neural network is used in branch condition. Different from Pattern 1, the input of the neural network, x, participates the assignment for z. DIFFAI+ has the same “0 gradient" issue as in Pattern 1. DSE sometimes reaches an area during training where only a super small portion of y falls into the first branch and the sampling operation does not pick the portion because the probability is super small. In this way, DSE still steadily converges with a C# = 0.0. However, the program is safer but not worst-case safe because C# = 0.0 represents all the trajectories sampled by DSE during training is safe.
• Pattern3: Pattern 3 uses y in the branch condition as well. For the two branches, z in the first branch is directly assigned by a function over y and the second branch is naturally safe. Therefore, the goal for learning safe programs is to optimize z := 10 − y to the safe area. Both DIFFAI+ and DSE success on this pattern only optimizing over one branch is enough to learn a safe program.
• Pattern4: Pattern 4 is a typical example of local minimum. As the branch condition is y ≤ −1.0, the neural network may be initialized to fall into both branches. The first branch is naturally safe and the second branch comes with a local minimum z = 2. DIFFAI+ is not able to learn the safe programs guided by the safe loss and DSE can learn. DSE not achieving 1.0 provably safe portion as there is a part of training gets stuck in the local minimum with the second branch. There is an exception for DIFFAI+: it gets 0.58 for NNBig. The 0.58 can not be viewed as a result benefiting from the safety loss calculation as it specifically benefits from the random initialization. Since this is not a complicated task, DiffAI+ benefits from weights initialization when using NNBig. Specifically, some random initializations of NNBig may pick neural network parameters that make all the y fall into the first branch(safe). This leads to a not bad result of DiffAI+ for Pattern4 with NNBig. If there are other random initializations that can benefit the approach, DiffAI+ and DSE should benefit in the same way. DSE does not specifically benefit from the random initialization for Pattern 4 since DiffAI+ fails on NNSmall and NNMed while DSE does not and DSE gives a safer program on NNBig.
• Pattern5: The first branch in this pattern is a function over the output of the neural network and the second branch is unsafe. There are bad joins for DIFFAI+. For here, one symbolic representation of y falling into both branches always joins with the unsafe results (z := −10). There is no gradient from z := −10.0 can direct the neural network to the safe area. DSE can work on this pattern as there is a volume-based probability used in learning to guide the y to fall into the first branch.

heading: A.10 ADDITIONAL DETAILS OF THE CORE ALGORITHM
text: The key point of “sampling based on volume” is the volume-based probability, which is measured by the volume portion satisfying one condition. Therefore, the volume portion must be differentiable (w.r.t θ). In addition, the volume is not required to be non-zero. We give a detailed description as below: - We represent the Vθ by the box domain (The detailed definition of Vθ is in Appendix A.2). - When the branch condition splits the box domain into two polyhedra (direct volume calculation for polyhedra is -P hard [1]), we add one new dimension (with a new variable) to allow that the splitting is over this new dimension. Formally, starting from one state s = (l, V ), a condition iff(x1, . . . , xk) <= M : . . . , DSE transforms the program first by converting the condition to xk+1 = f(x1, . . . , xk);ifxk+1 <= M : . . . . Then, the volume portion is measured by the intersection portion of the concrete interval representation of xk+1. Specifically, if the additional variable’s concrete interval length is 0, it indicates that the variable represents one point. It falls into one branch (Say branch 1) completely. Then the probability to select branch 1 is 1.0, and the probability to select other branches is 0.0.

heading: A.11 ADDITIONAL SCALABILITY EVALUATION
text: For most of the additional experiments for scalability, we take Thermostat. We take AC as the base benchmark for ‘different neural network architectures’ as we add convolutional layers. There is one variable as the input for the NN in Thermostat, and using Conv1d with kernel size=1 is the same as fully connected layers.
In the original Thermostat, there is a 20-length loop with a dynamic program length of 20∗6 = 120. In each iteration, there are 2 branches. Branches stacking on each other would increase the number of branches exponentially. Thus, in the original Thermostat, there is 220 paths to go in total. We evaluate the scalability over Thermostat by increase the number of branch in each iteration, doubling the loop length, and use a super refined input size.

heading: A.11.1 DIFFERENT NUMBER OF BRANCHES
text: With Thermostat, we increase the number of branches in the iteration from 2 to 3, by allowing the isOn has three branches to go. We convert the branches from {cool, heat} to {cool, lowHeat, highHeat}. That said, the entire number of branches in the program increases from 220 to 320. We show that DSE still performs well. And DiffAI+ can not give very good results even if ablation gives a reasonable number.

heading: A.11.2 DIFFERENT DYNAMIC LENGTH
text: With the same structure as the original thermostat, we set the loop length of 40, which doubles the dynamic length and the number of branches increases from 220 to 240 accordingly.
We show that with 200 data, DSE gives a result better than baselines but definitely less-than-perfect. In the training where DSE did not give safe programs in the cases where the symbolic state (split by too many branches) is too refined. The symbolic state gets stuck in an area where it’s not safe but it falls into one trajectory fully. In this way, the volume-based probability is always 1.0 for the later transitions and the gradient over θ is 0.0. The highly unsafe stuck state gives very high state safety loss, which is exhibited by the large training safety loss for DSE. When DSE is not stuck, it can learn safe programs. That’s why the average provable safe portion is still larger than baselines.
We also show that, with more data, DSE can give a very good safe program for this challenging task while baselines can not. Specifically, DIFFAI+ (splitting 100) easily gets stuck when guided by the highly non-differentiable representation of the safety loss even if ablation gives a reasonable result.

heading: A.11.3 SUPER REFINED INPUT SIZE
text: With the Thermostat, this task starts from a super refined input size: [60.0, 60.1]. The input in the original Thermostat is [60.0, 64.0]. We can see here DSE does not give good results with 200 data and gives the same result with the Ablation when using the full dataset.
This benchmark exhibits the trade-off between refinement and the ease of learning of DSE. When the input size is small enough that it only fully falls into one trajectory with an updated θ during learning. In this way, the volume-base probability is also 1.0 for this trajectory and there is not gradient guiding the state to jump from this trajectory to another. Thus, when this case occurs in the training, DSE gets stuck.

heading: A.11.4 DIFFERENT NEURAL NETWORK ARCHITECTURE
text: With AC, we use a NN with Conv1d(1, 1, 2)-ReLU()-Conv1d(1, 1, 2)-ReLU()-Linear(4, 32)- ReLU()-Linear(32, 6)-Sigmoid(), where Conv1d(X, Y, Z) means an input channel of X, an output channel of Y and a kernel size of Z and Linear(X, Y) means an input channel of X and an output channel of Y.
The above table exhibits that DSE can work for neural networks with convolutional layers. For AC specifically, all the training data comes from safe trajectories. There is a lack of generality for Ablation to get good test data loss. When adding additional safety constraint(e.g. In DSE), it helps to overcome some local minimum areas and gives a better test data loss even if the training data loss is worse than Ablation.

heading: A.11.5 CART-POLE EXPERIMENTS
text: In the Cartpole experiment, we use the trajectories data from Imitation Package. Starting from S0 = [−0.05, 0.05]4, we follow Bastani et al. (2018) to train a cart of which the pole keeps upright (θ ∈ [−12 ∗ 2 ∗math.pi/360, 12 ∗ 2 ∗math.pi/360], the definition of upright is the standard one from OpenAI Gym). The state space is 4 and the action space is 2. We use a 3 layer fully connected neural network (each layer followed by a ReLU and the last layer followed by a Sigmoid) to train. We follow the two points in Bastani et al. (2018) below to setup the experiment:
• We approximate the system using a finite time horizon Tmax = 10; • we use a linear approximation f(s, a) ' As + Ba.
We did the verification by splitting the input space into 204 boxes. And we extract the percentage of safe concrete trajectories from 100 uniformly sampled starting points. The results for restricting pole angle are as shown in Figure 18.
As indicated by the above figure, pure imitation learning(Ablation) can already learn a pole keeping upright. As the training data is almost all ‘safe’, DSE ’s generability(test data loss) benefits from the additional safety constraint.
To show DSE ’s ability to train a safe program without too much help from the data loss, we add another experiment following the same setting above except the constraint. We require the cart’s position to be within a range. That said, the cart keeps in the middle of the figure. We set the constraint of x in the trajectory to be [-0.1, 0.1].
From the Figure 19, we can see that DSE is better than baselines in terms of safety. We also added the concrete trajectories measurement to clarify the safety measurement with provably safe portions.

heading: A.11.6 TRAIN DSE FROM HIGHLY UNSAFE DATA
text: In summary, DSE can scale to programs with reasonable length, branches and different neural network architectures. One challenge in DSE is that learning becomes harder when symbolic state rep-
resentation becomes more refined(including super refined input space, safety constraint, and branch splitting). We leave this open for future works to seek to identify better tradeoffs between precision of symbolic states and ease of learning.

Review summaries:
This paper presents an approach to learn worst-case safe parameters for neurosymbolic programs (programs with neural networks + symbolic portions). The key contribution is an algorithm to compute gradients for the worst-case safety loss by symbolically sampling control paths in the programs and using a modification of the Reinforce estimate to approximate the gradients. The approach is compared with DiffAI on several synthetic tasks. 

The paper proposes DSE, an approach to optimizing parameters of neurosymbolic programs (programs with mixed neural and symbolic components) while satisfying a safety constraint. To accomplish this, DSE defines a *safety loss*, a nonnegative term in the loss function which is nonzero when the function does not satisfy the safety constraint. This safety loss is constructed by symbolically executing the program, executing discrete transitions probabilistically according to a uniform distribution over concrete states. The paper evaluates DSE on a set of small-scale case studies, showing that in programs with discrete control flow, DSE can often train neural networks that soundly lead to safe behavior, with similar quality of learned results as those of a neurosymbolic training approach which does not take into account safety.

This paper targets the problem of learning parameters of programs that involve both neural and symbolic components, with the objective that the program is guaranteed to be safe. This objective is challenging because it is not differentiable. The proposed method uses symbolic execution to finitize the execution trajectories and uses sampling with REINFORCE-styled algorithm to optimize for an approximated objective. Results show that although the proposed method is not guaranteed to be sound, it in practice produces programs that are safe on the example benchmarks.